diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp index e925ab06575..b82feb09e72 100644 --- a/Libraries/LibWeb/Editing/Commands.cpp +++ b/Libraries/LibWeb/Editing/Commands.cpp @@ -492,6 +492,14 @@ bool command_delete_action(DOM::Document& document, String const&) return true; } +// https://w3c.github.io/editing/docs/execCommand/#the-fontname-command +bool command_font_name_action(DOM::Document& document, String const& value) +{ + // Set the selection's value to value, then return true. + set_the_selections_value(document, CommandNames::fontName, value); + return true; +} + // https://w3c.github.io/editing/docs/execCommand/#the-forwarddelete-command bool command_forward_delete_action(DOM::Document& document, String const&) { @@ -1115,6 +1123,12 @@ static Array const commands { .action = command_default_paragraph_separator_action, .value = command_default_paragraph_separator_value, }, + // https://w3c.github.io/editing/docs/execCommand/#the-fontname-command + CommandDefinition { + .command = CommandNames::fontName, + .action = command_font_name_action, + .relevant_css_property = CSS::PropertyID::FontFamily, + }, // https://w3c.github.io/editing/docs/execCommand/#the-forwarddelete-command CommandDefinition { .command = CommandNames::forwardDelete, diff --git a/Libraries/LibWeb/Editing/Commands.h b/Libraries/LibWeb/Editing/Commands.h index f333b0cef39..62df3b2d996 100644 --- a/Libraries/LibWeb/Editing/Commands.h +++ b/Libraries/LibWeb/Editing/Commands.h @@ -35,6 +35,7 @@ bool command_create_link_action(DOM::Document&, String const&); bool command_default_paragraph_separator_action(DOM::Document&, String const&); String command_default_paragraph_separator_value(DOM::Document const&); bool command_delete_action(DOM::Document&, String const&); +bool command_font_name_action(DOM::Document&, String const&); bool command_forward_delete_action(DOM::Document&, String const&); bool command_insert_linebreak_action(DOM::Document&, String const&); bool command_insert_paragraph_action(DOM::Document&, String const&); diff --git a/Tests/LibWeb/Text/expected/Editing/execCommand-fontName.txt b/Tests/LibWeb/Text/expected/Editing/execCommand-fontName.txt new file mode 100644 index 00000000000..31ccbcc8d67 --- /dev/null +++ b/Tests/LibWeb/Text/expected/Editing/execCommand-fontName.txt @@ -0,0 +1,2 @@ +foobar +foobar diff --git a/Tests/LibWeb/Text/input/Editing/execCommand-fontName.html b/Tests/LibWeb/Text/input/Editing/execCommand-fontName.html new file mode 100644 index 00000000000..1ed21216331 --- /dev/null +++ b/Tests/LibWeb/Text/input/Editing/execCommand-fontName.html @@ -0,0 +1,22 @@ + +
foobar
+