forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Implement the "unlink" editing command
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
d1 contents: "ladybird" | ||
d2 contents: "ladybird" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |