mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
LibWeb: Implement the "formatBlock" editing command
This commit is contained in:
committed by
Andreas Kling
parent
e686328cbd
commit
a12d887eb4
Notes:
github-actions[bot]
2025-01-10 22:35:50 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/a12d887eb46 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
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>
|
||||
Reference in New Issue
Block a user