mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement the "insertUnorderedList" editing command
This commit is contained in:
parent
26cadf06d2
commit
1c3251e2d5
Notes:
github-actions[bot]
2025-01-10 22:35:00 +00:00
Author: https://github.com/gmta
Commit: 1c3251e2d5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3216
4 changed files with 67 additions and 0 deletions
|
@ -1841,6 +1841,28 @@ bool command_insert_text_action(DOM::Document& document, String const& value)
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-insertunorderedlist-command
|
||||
bool command_insert_unordered_list_action(DOM::Document& document, String const&)
|
||||
{
|
||||
// Toggle lists with tag name "ul", then return true.
|
||||
toggle_lists(document, HTML::TagNames::ul);
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-insertunorderedlist-command
|
||||
bool command_insert_unordered_list_indeterminate(DOM::Document const& document)
|
||||
{
|
||||
// True if the selection's list state is "mixed" or "mixed ul", false otherwise.
|
||||
return first_is_one_of(selections_list_state(document), SelectionsListState::Mixed, SelectionsListState::MixedUl);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-insertunorderedlist-command
|
||||
bool command_insert_unordered_list_state(DOM::Document const& document)
|
||||
{
|
||||
// True if the selection's list state is "ul", false otherwise.
|
||||
return selections_list_state(document) == SelectionsListState::Ul;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-italic-command
|
||||
bool command_italic_action(DOM::Document& document, String const&)
|
||||
{
|
||||
|
@ -2245,6 +2267,14 @@ static Array const commands {
|
|||
.command = CommandNames::insertText,
|
||||
.action = command_insert_text_action,
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-insertunorderedlist-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::insertUnorderedList,
|
||||
.action = command_insert_unordered_list_action,
|
||||
.indeterminate = command_insert_unordered_list_indeterminate,
|
||||
.state = command_insert_unordered_list_state,
|
||||
.preserves_overrides = true,
|
||||
},
|
||||
// https://w3c.github.io/editing/docs/execCommand/#the-italic-command
|
||||
CommandDefinition {
|
||||
.command = CommandNames::italic,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue