Chile,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<textarea id="txt" name="" cols="80"></textarea>
<script>
function doImage(obj) {
textarea = document.getElementById(obj);
var url = prompt('Имя изображения:', '/public/images/uploads/');
var scrollTop = textarea.scrollTop;
var scrollLeft = textarea.scrollLeft;
if (url != null && (url = url.trim())) {
if (document.selection) {
textarea.focus();
var sel = document.selection.createRange();
sel.text = `<img src="${url}" alt="${url}" />`;
} else {
var len = textarea.value.length;
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var sel = textarea.value.substring(start, end);
var rep = `<img src="${url}" alt="${url}" />`;
textarea.value = textarea.value.substring(0, start) + rep + textarea.value.substring(end, len);
textarea.scrollTop = scrollTop;
textarea.scrollLeft = scrollLeft;
}
}
}
var obj = 'txt';
document.write("<span name=\"btnPicture\" title=\"Иллюстрация\" onClick=\"doImage('" + obj + "')\">IMG</span>");
</script>
</body>
</html>