mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
LibWeb: Implement the "indent" editing command
This commit is contained in:
parent
a12d887eb4
commit
c6cde85534
Notes:
github-actions[bot]
2025-01-10 22:35:43 +00:00
Author: https://github.com/gmta
Commit: c6cde85534
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 120 additions and 0 deletions
31
Tests/LibWeb/Text/input/Editing/execCommand-indent.html
Normal file
31
Tests/LibWeb/Text/input/Editing/execCommand-indent.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<script src="../include.js"></script>
|
||||
<div contenteditable="true">
|
||||
<span>foobar</span>
|
||||
<ul>
|
||||
<li>foo</li>
|
||||
<li>bar</li>
|
||||
<li>baz</li>
|
||||
</ul>
|
||||
</div>
|
||||
<script>
|
||||
test(() => {
|
||||
const range = document.createRange();
|
||||
getSelection().addRange(range);
|
||||
|
||||
const divElm = document.querySelector('div');
|
||||
|
||||
// Indent 'foobar'
|
||||
const spanElm = document.querySelector('span');
|
||||
range.setStart(spanElm.childNodes[0], 0);
|
||||
range.setEnd(spanElm.childNodes[0], 6);
|
||||
document.execCommand('indent');
|
||||
|
||||
// Indent the middle <li>
|
||||
const liElm = document.querySelector('li:nth-child(2)');
|
||||
range.setStart(liElm.childNodes[0], 0);
|
||||
range.setEnd(liElm.childNodes[0], 3);
|
||||
document.execCommand('indent');
|
||||
|
||||
println(divElm.innerHTML);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue