mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Implement the "underline" editing command
This commit is contained in:
parent
679fbb5eda
commit
043a28baeb
Notes:
github-actions[bot]
2025-01-10 22:36:05 +00:00
Author: https://github.com/gmta
Commit: 043a28baeb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 62 additions and 0 deletions
|
@ -1422,6 +1422,23 @@ bool command_superscript_indeterminate(DOM::Document const& document)
|
|||
return has_mixed_value;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-underline-command
|
||||
bool command_underline_action(DOM::Document& document, String const&)
|
||||
{
|
||||
// If queryCommandState("underline") returns true, set the selection's value to null.
|
||||
if (document.query_command_state(CommandNames::underline)) {
|
||||
set_the_selections_value(document, CommandNames::underline, {});
|
||||
}
|
||||
|
||||
// Otherwise set the selection's value to "underline".
|
||||
else {
|
||||
set_the_selections_value(document, CommandNames::underline, "underline"_string);
|
||||
}
|
||||
|
||||
// Either way, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
static Array const commands {
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-backcolor-command
|
||||
CommandDefinition {
|
||||
|
@ -1534,6 +1551,12 @@ static Array const commands {
|
|||
.indeterminate = command_superscript_indeterminate,
|
||||
.inline_activated_values = { "superscript"sv },
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-underline-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::underline,
|
||||
.action = command_underline_action,
|
||||
.inline_activated_values = { "underline"sv },
|
||||
},
|
||||
};
|
||||
|
||||
Optional<CommandDefinition const&> find_command_definition(FlyString const& command)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue