Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<script>
function onLoad() {
const dd = document.querySelector("dd[contenteditable]");
// For emulating the traditional behavior, collapse Selection to end of the
// text node at end of the <dd contenteditable> which is the deepest last
// child of the <body> (end of the text node after the <template>).
getSelection().collapse(dd.lastChild, dd.lastChild.length);
getSelection().setPosition(
document.querySelector("template")
);
dd.addEventListener("DOMNodeInserted", () => {
document.execCommand("selectAll");
document.execCommand("insertText", false, "");
});
document.execCommand("insertImage", false, "#");
}
</script>
<body onload="onLoad()">
<dd contenteditable>
<template></template>
</dd></body>