mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibWeb: Implement the "backColor" and "hiliteColor" editing commands
This commit is contained in:
parent
7736d63290
commit
05386fe99c
Notes:
github-actions[bot]
2025-01-10 22:37:15 +00:00
Author: https://github.com/gmta
Commit: 05386fe99c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 59 additions and 0 deletions
22
Tests/LibWeb/Text/input/Editing/execCommand-backColor.html
Normal file
22
Tests/LibWeb/Text/input/Editing/execCommand-backColor.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<script src="../include.js"></script>
|
||||
<div contenteditable="true">foobar</div>
|
||||
<script>
|
||||
test(() => {
|
||||
const range = document.createRange();
|
||||
getSelection().addRange(range);
|
||||
|
||||
const divElm = document.querySelector('div');
|
||||
|
||||
// Make 'foo' blue
|
||||
range.setStart(divElm.childNodes[0], 0);
|
||||
range.setEnd(divElm.childNodes[0], 3);
|
||||
document.execCommand('backColor', false, '#0000ff');
|
||||
println(`Div contents: "${divElm.innerHTML}"`);
|
||||
|
||||
// Make 'bar' red
|
||||
range.setStart(divElm.childNodes[1], 0);
|
||||
range.setEnd(divElm.childNodes[1], 3);
|
||||
document.execCommand('hiliteColor', false, 'red');
|
||||
println(`Div contents: "${divElm.innerHTML}"`);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue