mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement the "formatBlock" editing command
This commit is contained in:
parent
e686328cbd
commit
a12d887eb4
Notes:
github-actions[bot]
2025-01-10 22:35:50 +00:00
Author: https://github.com/gmta
Commit: a12d887eb4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
6 changed files with 304 additions and 3 deletions
23
Tests/LibWeb/Text/input/Editing/execCommand-formatBlock.html
Normal file
23
Tests/LibWeb/Text/input/Editing/execCommand-formatBlock.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<script src="../include.js"></script>
|
||||
<div contenteditable="true">
|
||||
<div id="d1">foo<br>bar</div>
|
||||
<div id="d2">foo<br>bar</div>
|
||||
</div>
|
||||
<script>
|
||||
test(() => {
|
||||
const range = document.createRange();
|
||||
getSelection().addRange(range);
|
||||
|
||||
const div1 = document.querySelector('#d1');
|
||||
range.setStart(div1.childNodes[0], 0);
|
||||
range.setEnd(div1, 3);
|
||||
document.execCommand('formatBlock', false, 'p');
|
||||
|
||||
const div2 = document.querySelector('#d2');
|
||||
range.setStart(div2.childNodes[0], 0);
|
||||
range.setEnd(div2, 3);
|
||||
document.execCommand('formatBlock', false, 'h1');
|
||||
|
||||
println(document.querySelector('div[contenteditable]').innerHTML);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue