RendererCommand
public protocol RendererCommand
Describes a command that can be executed on RendererView
. A command may be invoked directly on the renderer
by providing an instance.
However, in a typical usage scenario, these should be invoked via RendererCommandExecutor
which manages all the RendererView
s 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 Renderer. 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
RendererView
. When a command is executed usingRendererCommandExecutor
, it ensures that only the commands returningtrue
for the activeRendererView
are executed when invoked. Defaults totrue
.Default Implementation
Declaration
Swift
func canExecute(on renderer: RendererView) -> Bool
Parameters
renderer
EditorView
to execute the command on. -
Execute the command on the given
EditorView
. You may useselectedRange
property ofEditorView
if the command operates on the selected text only. for e.g. a command to make selected text bold.Declaration
Swift
func execute(on renderer: RendererView)
Parameters
renderer
EditorView
to execute the command on.