mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 23:59:49 +00:00
LibWeb: Implement document.execCommand("defaultParagraphSeparator")
This commit is contained in:
parent
7bb865052a
commit
4a64557876
Notes:
github-actions[bot]
2024-11-30 16:37:16 +00:00
Author: https://github.com/gmta
Commit: 4a64557876
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2655
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/yyny
3 changed files with 38 additions and 0 deletions
|
@ -19,6 +19,34 @@
|
|||
|
||||
namespace Web::Editing {
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-defaultparagraphseparator-command
|
||||
bool command_default_paragraph_separator_action(DOM::Document& document, String const& input_value)
|
||||
{
|
||||
// Let value be converted to ASCII lowercase.
|
||||
auto value = input_value.to_ascii_lowercase();
|
||||
|
||||
// If value is then equal to "p" or "div", set the context object's default single-line
|
||||
// container name to value, then return true.
|
||||
if (value == HTML::TagNames::p) {
|
||||
document.set_default_single_line_container_name(HTML::TagNames::p);
|
||||
return true;
|
||||
}
|
||||
if (value == HTML::TagNames::div) {
|
||||
document.set_default_single_line_container_name(HTML::TagNames::div);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-defaultparagraphseparator-command
|
||||
String command_default_paragraph_separator_value(DOM::Document const& document)
|
||||
{
|
||||
// Return the context object's default single-line container name.
|
||||
return document.default_single_line_container_name().to_string();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-delete-command
|
||||
bool command_delete_action(DOM::Document& document, String const&)
|
||||
{
|
||||
|
@ -326,6 +354,7 @@ bool command_delete_action(DOM::Document& document, String const&)
|
|||
|
||||
static Array const commands {
|
||||
CommandDefinition { CommandNames::delete_, command_delete_action, {}, {}, {} },
|
||||
CommandDefinition { CommandNames::defaultParagraphSeparator, command_default_paragraph_separator_action, {}, {}, command_default_paragraph_separator_value },
|
||||
};
|
||||
|
||||
Optional<CommandDefinition const&> find_command_definition(FlyString const& command)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue