LibWeb: Implement the "fontSize" editing command

This commit is contained in:
Jelle Raaijmakers 2025-01-08 16:01:07 +01:00 committed by Andreas Kling
commit 1d2500e31f
Notes: github-actions[bot] 2025-01-10 22:36:54 +00:00
5 changed files with 141 additions and 1 deletions

View file

@ -0,0 +1,26 @@
<script src="../include.js"></script>
<div contenteditable="true">foobar</div>
<script>
test(() => {
const range = document.createRange();
getSelection().addRange(range);
const divElm = document.querySelector('div');
println(`div: "${divElm.innerHTML}"`);
println(`fontSize value: ${document.queryCommandValue('fontSize')}`);
// Set fontSize for 'bar'
range.setStart(divElm.childNodes[0], 3);
range.setEnd(divElm.childNodes[0], 6);
document.execCommand('fontSize', false, '5');
println(`div: "${divElm.innerHTML}"`);
println(`fontSize value: ${document.queryCommandValue('fontSize')}`);
// Set fontSize for 'foobar'
range.setStart(divElm.childNodes[0], 0);
range.setEnd(divElm.childNodes[1].childNodes[0], 3);
document.execCommand('fontSize', false, '4');
println(`div: "${divElm.innerHTML}"`);
println(`fontSize value: ${document.queryCommandValue('fontSize')}`);
});
</script>