LibWeb: Implement the "forwardDelete" editing command

This commit is contained in:
Jelle Raaijmakers 2025-01-07 16:51:16 +01:00 committed by Andreas Kling
commit 7736d63290
Notes: github-actions[bot] 2025-01-10 22:37:23 +00:00
4 changed files with 218 additions and 0 deletions

View file

@ -0,0 +1,18 @@
<script src="../include.js"></script>
<div contenteditable="true">foobar</div>
<script>
test(() => {
var divElm = document.querySelector('div');
println(`Before: ${divElm.textContent}`);
// Put cursor after 'foo'
var range = document.createRange();
range.setStart(divElm.childNodes[0], 3);
getSelection().addRange(range);
// Press delete
document.execCommand('forwardDelete');
println(`After: ${divElm.textContent}`);
});
</script>