EditorViewDelegate

public protocol EditorViewDelegate : AnyObject

Describes an object interested in listening to events raised from EditorView

  • Invoked when a special key like enter, tab etc. is intercepted in the Editor

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, shouldHandle key: EditorKey, modifierFlags: UIKeyModifierFlags, at range: NSRange, handled: inout Bool)

    Parameters

    editor

    Editor view receiving the event.

    key

    Key that is intercepted.

    range

    Range of the key in editor

    handled

    Set to true to hijack the key press i.e. when true, the key press is not passed to the Editor

  • editor(_:didReceiveKey:at:) Default implementation

    Invoked when a special key like enter, tab etc. is entered in the Editor

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didReceiveKey key: EditorKey, at range: NSRange)

    Parameters

    editor

    Editor view receiving the event.

    key

    Key that is received.

    range

    Range of the key in editor

  • editor(_:didReceiveFocusAt:) Default implementation

    Invoked when editor receives focus.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didReceiveFocusAt range: NSRange)

    Parameters

    editor

    Editor view receiving the event.

    range

    Range where focus is received.

  • editor(_:didLoseFocusFrom:) Default implementation

    Invoked when editor loses the focus.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didLoseFocusFrom range: NSRange)

    Parameters

    editor

    Editor view receiving the event.

    range

    Range from where focus is lost.

  • editor(_:didChangeTextAt:) Default implementation

    Invoked when text is changed in editor.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didChangeTextAt range: NSRange)

    Parameters

    editor

    Editor view receiving the event.

    range

    Range where text is modified.

  • Invoked when the selection range changes in the editor as a result of moving the cursor using keys/mouse or taps.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didChangeSelectionAt range: NSRange, attributes: [NSAttributedString.Key : Any], contentType: EditorContent.Name)

    Parameters

    editor

    Editor view receiving the event.

    range

    Range where selection is changed.

    attributes

    Attributes at the updated range.

    contentType

    Name of the content at the updated range.

  • editor(_:didExecuteProcessors:at:) Default implementation

    Invoked when text processors are executed in the editor.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didExecuteProcessors processors: [TextProcessing], at range: NSRange)

    Parameters

    editor

    Editor view receiving the event.

    processors

    Processors that are executed.

    range

    Range where processors are executed.

  • editor(_:didChangeSize:previousSize:) Default implementation

    Invoked when the size of EditorView changes.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didChangeSize currentSize: CGSize, previousSize: CGSize)

    Parameters

    editor

    Editor view receiving the event.

    currentSize

    Current size of Editor after updates.

    previousSize

    Size of Editor before the update.

  • Invoked when a location within the EditorView is tapped.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didTapAtLocation location: CGPoint, characterRange: NSRange?)

    Parameters

    editor

    Editor view receiving the event.

    location

    Location of the tap event

    characterRange

    Range of character at the tapped location, if available.

  • editor(_:didLayout:) Default implementation

    Invoked whenever layout pass completes as a result of changing or text or attributes

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didLayout content: NSAttributedString)

    Parameters

    editor

    Editor view receiving the event.

    content

    Attributed text value.

  • Invoked before attributedText is set on the EditorView

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, willSetAttributedText attributedText: NSAttributedString, isDeferred: Bool)

    Parameters

    editor

    Editor view receiving the event.

    attributedText

    Attributed text value to be set.

    isDeferred

    true if setter is called deferred owing to Editor not being on window when attributedText was originally set.

  • Invoked after attributedText is set on the EditorView

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didSetAttributedText attributedText: NSAttributedString, isDeferred: Bool)

    Parameters

    editor

    Editor view receiving the event.

    attributedText

    Attributed text value set on the editor.

    isDeferred

    true if setter is called deferred owing to Editor not being on window when attributedText was originally set.

  • editor(_:isReady:) Default implementation

    Invoked when Editor has been added to the view hierarchy and is ready to receive events.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, isReady: Bool)

    Parameters

    editor

    Editor view receiving the event.

    isReady

    true if Editor is loaded. false when Editor is initialized but not yet in view hierarchy.

  • editor(_:didChangeEditable:) Default implementation

    Invoked when Editor’s isEditable status is changed

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didChangeEditable isEditable: Bool)

    Parameters

    editor

    Editor view receiving the event.

    isEditable

    true if editor is editable, else false

  • editor(_:willRenderAttachment:) Default implementation

    Notifies when an Attachment is going to rendered for the first time in EditorView

    Note

    This invocation only applies in default mode of rendering attachment. If EditorView has AsyncAttachmentRenderingDelegate provided, that delegate will receive the event instead.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, willRenderAttachment attachment: Attachment)

    Parameters

    editor

    Editor view receiving the event.

    attachment

    Attachment getting rendered

  • editor(_:didRenderAttachment:) Default implementation

    Notifies when an Attachment is rendered for the first time in EditorView

    Note

    This invocation only applies in default mode of rendering attachment. If EditorView has AsyncAttachmentRenderingDelegate provided, that delegate will receive the event instead.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, didRenderAttachment attachment: Attachment)

    Parameters

    editor

    Editor view receiving the event.

    attachment

    Attachment getting rendered

  • Determines if attachment should be deleted when encountering backspace on attachment

    Note

    If either this orAttachments property of selectBeforeDelete is true, the attachment will be shown as selected on backspace.

    Default Implementation

    Declaration

    Swift

    func editor(_ editor: EditorView, shouldSelectAttachmentOnBackspace attachment: Attachment) -> Bool?

    Parameters

    editor

    Editor view receiving the event.

    attachment

    Attachment at the range where backspace is received

    Return Value

    true to delete, else false

  • Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    func editor(_ editor: EditorView, didChangeBackgroundColor color: UIColor?, oldColor: UIColor?)