LibWeb: Implement the "justifyCenter/Full/Left/Right" editing commands

This commit is contained in:
Jelle Raaijmakers 2025-01-10 15:25:35 +01:00 committed by Andreas Kling
commit fbc0d40d2c
Notes: github-actions[bot] 2025-01-10 22:34:54 +00:00
12 changed files with 524 additions and 0 deletions

View file

@ -0,0 +1,21 @@
<script src="../include.js"></script>
<div contenteditable="true" id="d1">foobar</div>
<div contenteditable="true" id="d2"><div style="text-align: right">foobar</div></div>
<script>
test(() => {
const range = document.createRange();
getSelection().addRange(range);
const div1 = document.querySelector('#d1');
range.setStart(div1.firstChild, 0);
range.setEnd(div1.firstChild, 6);
document.execCommand('justifyFull');
println(div1.innerHTML);
const div2 = document.querySelector('#d2');
range.setStart(div2.firstChild, 0);
range.setEnd(div2.firstChild, 1);
document.execCommand('justifyFull');
println(div2.innerHTML);
});
</script>