mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
LibWeb: Implement the "selectAll" editing command
This commit is contained in:
parent
03bcfb9b8c
commit
70af48c18b
Notes:
github-actions[bot]
2025-01-10 22:34:39 +00:00
Author: https://github.com/gmta
Commit: 70af48c18b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 73 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
No range.
|
||||
DIV 0 - DIV 0
|
||||
BODY 0 - BODY 5
|
37
Tests/LibWeb/Text/input/Editing/execCommand-selectAll.html
Normal file
37
Tests/LibWeb/Text/input/Editing/execCommand-selectAll.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<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 selection = getSelection();
|
||||
|
||||
const reportSelection = () => {
|
||||
if (selection.rangeCount === 0) {
|
||||
println('No range.');
|
||||
return;
|
||||
}
|
||||
const range = selection.getRangeAt(0);
|
||||
println(`${range.startContainer.nodeName} ${range.startOffset} - ${range.endContainer.nodeName} ${range.endOffset}`);
|
||||
};
|
||||
|
||||
reportSelection();
|
||||
|
||||
let divElm = document.querySelector('div');
|
||||
let range = document.createRange();
|
||||
range.setStart(divElm, 0);
|
||||
range.setEnd(divElm, 0);
|
||||
selection.addRange(range);
|
||||
|
||||
reportSelection();
|
||||
|
||||
// Perform selectAll
|
||||
document.execCommand('selectAll');
|
||||
reportSelection();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue