mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 11:48:06 +00:00
LibWeb: Implement the "unlink" editing command
This commit is contained in:
parent
043a28baeb
commit
e686328cbd
Notes:
github-actions[bot]
2025-01-10 22:35:59 +00:00
Author: https://github.com/gmta
Commit: e686328cbd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 66 additions and 0 deletions
23
Tests/LibWeb/Text/input/Editing/execCommand-unlink.html
Normal file
23
Tests/LibWeb/Text/input/Editing/execCommand-unlink.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<script src="../include.js"></script>
|
||||
<div contenteditable="true" id="d1"><a href="https://ladybird.dev">ladybird</a></div>
|
||||
<div contenteditable="true" id="d2">lady<a href="https://ladybird.dev">bird</a></div>
|
||||
<script>
|
||||
test(() => {
|
||||
const range = document.createRange();
|
||||
getSelection().addRange(range);
|
||||
|
||||
// Unlink d1's ladybird
|
||||
const div1 = document.querySelector('#d1');
|
||||
range.setStart(div1.childNodes[0].childNodes[0], 0);
|
||||
range.setEnd(div1.childNodes[0].childNodes[0], 8);
|
||||
document.execCommand('unlink');
|
||||
println(`d1 contents: "${div1.innerHTML}"`);
|
||||
|
||||
// Unlink d2's 'bird'
|
||||
const div2 = document.querySelector('#d2');
|
||||
range.setStart(div2.childNodes[1].childNodes[0], 2);
|
||||
range.setEnd(div2.childNodes[1].childNodes[0], 3);
|
||||
document.execCommand('unlink');
|
||||
println(`d2 contents: "${div2.innerHTML}"`);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue