EditorCommand
public protocol EditorCommand : AnyObject
Describes a command that can be executed on EditorView. A command may be invoked directly on the editor by providing an instance.
However, in a typical usage scenario, these should be invoked via EditorCommandExecutor which manages all the EditorViews in the
view including the ones that are contained in the attachments.
-
Identifies a command. This value is used to maintain unique registrations of commands in an Editor. Adding a command with the same name as one registered already would end up replacing the previously registered command with the same name.
Declaration
Swift
var name: CommandName { get } -
canExecute(on:Default implementation) Determines if the current command can be executed on the given
EditorView. When a command is executed usingEditorCommandExecutor, it ensures that only the commands returningtruefor the activeEditorVieware executed when invoked. Defaults totrue.Default Implementation
Declaration
Swift
func canExecute(on editor: EditorView) -> BoolParameters
editorEditorViewto execute the command on. -
Execute the command on the given
EditorView. You may useselectedRangeproperty ofEditorViewif the command operates on the selected text only. for e.g. a command to make selected text bold.Declaration
Swift
func execute(on editor: EditorView)Parameters
editorEditorViewto execute the command on.
View on GitHub
EditorCommand Protocol Reference