LibWeb: Implement the "insertText" editing command

Minus the autolinking algorithm.
This commit is contained in:
Jelle Raaijmakers 2025-01-10 13:28:32 +01:00 committed by Andreas Kling
commit 26cadf06d2
Notes: github-actions[bot] 2025-01-10 22:35:07 +00:00
6 changed files with 216 additions and 11 deletions

View file

@ -0,0 +1,18 @@
<script src="../include.js"></script>
<div contenteditable="true">foobar</div>
<script>
test(() => {
var divElm = document.querySelector('div');
// Put cursor between 'foo' and 'bar'
var range = document.createRange();
getSelection().addRange(range);
range.setStart(divElm.childNodes[0], 3);
range.setEnd(divElm.childNodes[0], 3);
// Insert text
document.execCommand('insertText', false, 'baz');
println(divElm.innerHTML);
});
</script>