Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

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);
dd.addEventListener("DOMNodeInserted", () => {
document.execCommand("insertText", false, "");
document.execCommand("insertImage", false, "#");
<body onload="onLoad()">
<dd contenteditable>