LibWeb: Implement the "removeFormat" editing command

This commit is contained in:
Jelle Raaijmakers 2025-01-08 16:47:11 +01:00 committed by Andreas Kling
commit aee8a75c40
Notes: github-actions[bot] 2025-01-10 22:36:28 +00:00
6 changed files with 143 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<script src="../include.js"></script>
<div contenteditable="true">f<b>o</b>ob<i>a</i>r</div>
<script>
test(() => {
const range = document.createRange();
getSelection().addRange(range);
const divElm = document.querySelector('div');
println(`Div contents: "${divElm.innerHTML}"`);
// Remove all formatting from 'foobar'
range.setStart(divElm, 0);
range.setEnd(divElm, 5);
document.execCommand('removeFormat');
println(`Div contents: "${divElm.innerHTML}"`);
});
</script>