JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" onmousedown="inserthtml(); return false" value="insert html" >
<div contenteditable="true">Click somewhere in here and press the 'insert html' button</div>
JavaScript
function inserthtml() {
var sel = document.selection;
if (sel) {
var textRange = sel.createRange();
document.execCommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png' height='42' width='42'></div>");
textRange.collapse(false);
textRange.select();
} else {
document.execCommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png' height='42' width='42'></div>");
}
}