mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Implement the "strikethrough" editing command
This commit is contained in:
parent
aee8a75c40
commit
8c51d6863f
Notes:
github-actions[bot]
2025-01-10 22:36:23 +00:00
Author: https://github.com/gmta
Commit: 8c51d6863f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 62 additions and 0 deletions
|
@ -1281,6 +1281,23 @@ bool command_remove_format_action(DOM::Document& document, String const&)
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-strikethrough-command
|
||||
bool command_strikethrough_action(DOM::Document& document, String const&)
|
||||
{
|
||||
// If queryCommandState("strikethrough") returns true, set the selection's value to null.
|
||||
if (document.query_command_state(CommandNames::strikethrough)) {
|
||||
set_the_selections_value(document, CommandNames::strikethrough, {});
|
||||
}
|
||||
|
||||
// Otherwise set the selection's value to "line-through".
|
||||
else {
|
||||
set_the_selections_value(document, CommandNames::strikethrough, "line-through"_string);
|
||||
}
|
||||
|
||||
// Either way, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-stylewithcss-command
|
||||
bool command_style_with_css_action(DOM::Document& document, String const& value)
|
||||
{
|
||||
|
@ -1385,6 +1402,12 @@ static Array const commands {
|
|||
.command = CommandNames::removeFormat,
|
||||
.action = command_remove_format_action,
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-strikethrough-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::strikethrough,
|
||||
.action = command_strikethrough_action,
|
||||
.inline_activated_values = { "line-through"sv },
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-stylewithcss-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::styleWithCSS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue