| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-12-22 21:34:50 +01:00
										 |  |  |  * Copyright (c) 2024-2025, Jelle Raaijmakers <jelle@ladybird.org> | 
					
						
							| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Editing { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-18 12:45:02 +01:00
										 |  |  | // https://w3c.github.io/editing/docs/execCommand/#properties-of-commands
 | 
					
						
							| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  | struct CommandDefinition { | 
					
						
							|  |  |  |     FlyString const& command; | 
					
						
							| 
									
										
										
										
											2024-12-16 15:48:24 +01:00
										 |  |  |     Function<bool(DOM::Document&, String const&)> action {}; | 
					
						
							|  |  |  |     Function<bool(DOM::Document const&)> indeterminate {}; | 
					
						
							|  |  |  |     Function<bool(DOM::Document const&)> state {}; | 
					
						
							|  |  |  |     Function<String(DOM::Document const&)> value {}; | 
					
						
							| 
									
										
										
										
											2024-12-18 12:45:02 +01:00
										 |  |  |     Optional<CSS::PropertyID> relevant_css_property {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 21:34:50 +01:00
										 |  |  |     // https://w3c.github.io/editing/docs/execCommand/#preserves-overrides
 | 
					
						
							|  |  |  |     bool preserves_overrides { false }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-18 12:45:02 +01:00
										 |  |  |     // https://w3c.github.io/editing/docs/execCommand/#inline-command-activated-values
 | 
					
						
							| 
									
										
										
										
											2025-01-07 14:15:09 +01:00
										 |  |  |     Vector<StringView> inline_activated_values {}; | 
					
						
							| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<CommandDefinition const&> find_command_definition(FlyString const&); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Command implementations
 | 
					
						
							| 
									
										
										
										
											2025-01-08 13:17:04 +01:00
										 |  |  | bool command_back_color_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-07 14:15:09 +01:00
										 |  |  | bool command_bold_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 14:33:18 +01:00
										 |  |  | bool command_create_link_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2024-11-29 11:56:28 +01:00
										 |  |  | bool command_default_paragraph_separator_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | String command_default_paragraph_separator_value(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  | bool command_delete_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 14:39:31 +01:00
										 |  |  | bool command_font_name_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:01:07 +01:00
										 |  |  | bool command_font_size_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | String command_font_size_value(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:18:35 +01:00
										 |  |  | bool command_fore_color_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-09 23:42:29 +01:00
										 |  |  | bool command_format_block_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | bool command_format_block_indeterminate(DOM::Document const&); | 
					
						
							|  |  |  | String command_format_block_value(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2025-01-07 16:51:16 +01:00
										 |  |  | bool command_forward_delete_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-10 00:26:25 +01:00
										 |  |  | bool command_indent_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-10 00:38:20 +01:00
										 |  |  | bool command_insert_horizontal_rule_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-10 09:33:38 +01:00
										 |  |  | bool command_insert_html_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2024-12-10 16:16:56 +01:00
										 |  |  | bool command_insert_linebreak_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2024-12-03 16:29:21 +01:00
										 |  |  | bool command_insert_paragraph_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:24:38 +01:00
										 |  |  | bool command_italic_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:47:11 +01:00
										 |  |  | bool command_remove_format_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 16:54:19 +01:00
										 |  |  | bool command_strikethrough_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2024-12-03 16:28:49 +01:00
										 |  |  | bool command_style_with_css_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | bool command_style_with_css_state(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 17:06:20 +01:00
										 |  |  | bool command_subscript_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | bool command_subscript_indeterminate(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 17:10:07 +01:00
										 |  |  | bool command_superscript_action(DOM::Document&, String const&); | 
					
						
							|  |  |  | bool command_superscript_indeterminate(DOM::Document const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 17:26:06 +01:00
										 |  |  | bool command_underline_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2025-01-08 17:38:02 +01:00
										 |  |  | bool command_unlink_action(DOM::Document&, String const&); | 
					
						
							| 
									
										
										
										
											2024-11-27 11:57:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |