Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

function onLoad() {
// For emulating the traditional behavior, collapse Selection to end of the
// text node which is the last child of the <dd contenteditable> which is the
// last child of the <body>.
const dd = document.querySelector("dd[contenteditable]");
getSelection().collapse(dd.lastChild, dd.lastChild.length);
document.execCommand("selectAll");"DOMNodeRemoved", () => {
document.execCommand("insertHTML", false, undefined)
document.execCommand("heading", false, "H1")
<body onload="onLoad()">
<dd contenteditable>A
<!-- A -->