mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement the "bold" editing command
This commit is contained in:
parent
fef02036dd
commit
a71e999ac8
Notes:
github-actions[bot]
2025-01-10 22:37:28 +00:00
Author: https://github.com/gmta
Commit: a71e999ac8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
6 changed files with 64 additions and 40 deletions
|
@ -25,6 +25,23 @@
|
|||
|
||||
namespace Web::Editing {
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-bold-command
|
||||
bool command_bold_action(DOM::Document& document, String const&)
|
||||
{
|
||||
// If queryCommandState("bold") returns true, set the selection's value to "normal".
|
||||
if (document.query_command_state(CommandNames::bold)) {
|
||||
set_the_selections_value(document, CommandNames::bold, "normal"_string);
|
||||
}
|
||||
|
||||
// Otherwise set the selection's value to "bold".
|
||||
else {
|
||||
set_the_selections_value(document, CommandNames::bold, "bold"_string);
|
||||
}
|
||||
|
||||
// Either way, return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-defaultparagraphseparator-command
|
||||
bool command_default_paragraph_separator_action(DOM::Document& document, String const& input_value)
|
||||
{
|
||||
|
@ -822,6 +839,13 @@ bool command_style_with_css_state(DOM::Document const& document)
|
|||
}
|
||||
|
||||
static Array const commands {
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-bold-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::bold,
|
||||
.action = command_bold_action,
|
||||
.relevant_css_property = CSS::PropertyID::FontWeight,
|
||||
.inline_activated_values = { "bold"sv, "600"sv, "700"sv, "800"sv, "900"sv },
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-delete-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::delete_,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue