LibWeb: Implement the "useCSS" editing command

This commit is contained in:
Jelle Raaijmakers 2025-01-10 16:22:35 +01:00 committed by Andreas Kling
parent 70af48c18b
commit 98ec1825de
Notes: github-actions[bot] 2025-01-10 22:34:32 +00:00
2 changed files with 17 additions and 0 deletions

View file

@ -2448,6 +2448,17 @@ bool command_unlink_action(DOM::Document& document, String const&)
return true;
}
// https://w3c.github.io/editing/docs/execCommand/#the-usecss-command
bool command_use_css_action(DOM::Document& document, String const& value)
{
// If value is an ASCII case-insensitive match for the string "false", set the CSS styling flag to true.
// Otherwise, set the CSS styling flag to false.
document.set_css_styling_flag(value.equals_ignoring_ascii_case("false"sv));
// Either way, return true.
return true;
}
static Array const commands {
// https://w3c.github.io/editing/docs/execCommand/#the-backcolor-command
CommandDefinition {
@ -2671,6 +2682,11 @@ static Array const commands {
.command = CommandNames::unlink,
.action = command_unlink_action,
},
// https://w3c.github.io/editing/docs/execCommand/#the-usecss-command
CommandDefinition {
.command = CommandNames::useCSS,
.action = command_use_css_action,
},
};
Optional<CommandDefinition const&> find_command_definition(FlyString const& command)

View file

@ -85,5 +85,6 @@ bool command_superscript_action(DOM::Document&, String const&);
bool command_superscript_indeterminate(DOM::Document const&);
bool command_underline_action(DOM::Document&, String const&);
bool command_unlink_action(DOM::Document&, String const&);
bool command_use_css_action(DOM::Document&, String const&);
}