JSFiddle - React, Tailwind, and code Playground
by timdown
HTML
<input type="button" onmousedown="insertImage(); return false" value="insert image" unselectable="on">
<div contenteditable="true">Click somewhere in here and press the button</div>
JavaScript
function insertImage() {
var sel = document.selection;
if (sel) {
var textRange = sel.createRange();
document.execCommand('insertImage', false, "http://jsfiddle.net/img/logo.png");
textRange.collapse(false);
textRange.select();
} else {
document.execCommand('insertImage', false, "http://jsfiddle.net/img/logo.png");
}
}