blob: d7eb01e03b29abf7f1f734a5a8954f589d697f3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<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>
|