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 RendererViews 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 using RendererCommandExecutor, it ensures that only the commands returning true for the active RendererView are executed when invoked. Defaults to true.

    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 use selectedRange property of EditorView 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.