LibWeb: Implement the "insertHorizontalRule" editing command

This commit is contained in:
Jelle Raaijmakers 2025-01-10 00:38:20 +01:00 committed by Andreas Kling
commit cb05ab6515
Notes: github-actions[bot] 2025-01-10 22:35:36 +00:00
4 changed files with 95 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');
// 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 horizontal rule
document.execCommand('insertHorizontalRule');
println(divElm.innerHTML);
});
</script>