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