EditorViewDelegate
public protocol EditorViewDelegate : AnyObject
Describes an object interested in listening to events raised from EditorView
-
editor(_:Default implementationshouldHandle: modifierFlags: at: handled: ) Invoked when a special key like
enter,tabetc. is intercepted in theEditorDefault Implementation
Declaration
Swift
func editor(_ editor: EditorView, shouldHandle key: EditorKey, modifierFlags: UIKeyModifierFlags, at range: NSRange, handled: inout Bool)Parameters
editorEditor view receiving the event.
keyKey that is intercepted.
rangeRange of the key in editor
handledSet to
trueto hijack the key press i.e. whentrue, the key press is not passed to theEditor -
editor(_:Default implementationdidReceiveKey: at: ) Invoked when a special key like
enter,tabetc. is entered in theEditorDefault Implementation
Declaration
Swift
func editor(_ editor: EditorView, didReceiveKey key: EditorKey, at range: NSRange)Parameters
editorEditor view receiving the event.
keyKey that is received.
rangeRange of the key in editor
-
editor(_:Default implementationdidReceiveFocusAt: ) Invoked when editor receives focus.
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didReceiveFocusAt range: NSRange)Parameters
editorEditor view receiving the event.
rangeRange where focus is received.
-
editor(_:Default implementationdidLoseFocusFrom: ) Invoked when editor loses the focus.
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didLoseFocusFrom range: NSRange)Parameters
editorEditor view receiving the event.
rangeRange from where focus is lost.
-
editor(_:Default implementationdidChangeTextAt: ) Invoked when text is changed in editor.
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didChangeTextAt range: NSRange)Parameters
editorEditor view receiving the event.
rangeRange where text is modified.
-
editor(_:Default implementationdidChangeSelectionAt: attributes: contentType: ) 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
editorEditor view receiving the event.
rangeRange where selection is changed.
attributesAttributes at the updated range.
contentTypeName of the content at the updated range.
-
editor(_:Default implementationdidExecuteProcessors: at: ) Invoked when text processors are executed in the editor.
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didExecuteProcessors processors: [TextProcessing], at range: NSRange)Parameters
editorEditor view receiving the event.
processorsProcessors that are executed.
rangeRange where processors are executed.
-
editor(_:Default implementationdidChangeSize: previousSize: ) Invoked when the size of EditorView changes.
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didChangeSize currentSize: CGSize, previousSize: CGSize)Parameters
editorEditor view receiving the event.
currentSizeCurrent size of Editor after updates.
previousSizeSize of Editor before the update.
-
editor(_:Default implementationdidTapAtLocation: characterRange: ) Invoked when a location within the
EditorViewis tapped.Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didTapAtLocation location: CGPoint, characterRange: NSRange?)Parameters
editorEditor view receiving the event.
locationLocation of the tap event
characterRangeRange of character at the tapped location, if available.
-
editor(_:Default implementationdidLayout: ) 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
editorEditor view receiving the event.
contentAttributed text value.
-
editor(_:Default implementationwillSetAttributedText: isDeferred: ) Invoked before attributedText is set on the
EditorViewDefault Implementation
Declaration
Swift
func editor(_ editor: EditorView, willSetAttributedText attributedText: NSAttributedString, isDeferred: Bool)Parameters
editorEditor view receiving the event.
attributedTextAttributed text value to be set.
isDeferredtrueif setter is called deferred owing to Editor not being onwindowwhenattributedTextwas originally set. -
editor(_:Default implementationdidSetAttributedText: isDeferred: ) Invoked after attributedText is set on the
EditorViewDefault Implementation
Declaration
Swift
func editor(_ editor: EditorView, didSetAttributedText attributedText: NSAttributedString, isDeferred: Bool)Parameters
editorEditor view receiving the event.
attributedTextAttributed text value set on the editor.
isDeferredtrueif setter is called deferred owing to Editor not being onwindowwhenattributedTextwas originally set. -
editor(_:Default implementationisReady: ) 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
editorEditor view receiving the event.
isReadytrueif Editor is loaded.falsewhen Editor is initialized but not yet in view hierarchy. -
editor(_:Default implementationdidChangeEditable: ) Invoked when Editor’s isEditable status is changed
Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didChangeEditable isEditable: Bool)Parameters
editorEditor view receiving the event.
isEditabletrueif editor is editable, elsefalse -
editor(_:Default implementationwillRenderAttachment: ) Notifies when an
Attachmentis going to rendered for the first time inEditorViewNote
This invocation only applies in default mode of rendering attachment. IfEditorViewhasAsyncAttachmentRenderingDelegateprovided, that delegate will receive the event instead.Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, willRenderAttachment attachment: Attachment)Parameters
editorEditor view receiving the event.
attachmentAttachmentgetting rendered -
editor(_:Default implementationdidRenderAttachment: ) Notifies when an
Attachmentis rendered for the first time inEditorViewNote
This invocation only applies in default mode of rendering attachment. IfEditorViewhasAsyncAttachmentRenderingDelegateprovided, that delegate will receive the event instead.Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, didRenderAttachment attachment: Attachment)Parameters
editorEditor view receiving the event.
attachmentAttachmentgetting rendered -
editor(_:Default implementationshouldSelectAttachmentOnBackspace: ) Determines if attachment should be deleted when encountering backspace on attachment
Note
If either this orAttachments property ofselectBeforeDeleteistrue, the attachment will be shown as selected on backspace.Default Implementation
Declaration
Swift
func editor(_ editor: EditorView, shouldSelectAttachmentOnBackspace attachment: Attachment) -> Bool?Parameters
editorEditor view receiving the event.
attachmentAttachment at the range where backspace is received
Return Value
trueto delete, elsefalse -
editor(_:Default implementationdidChangeBackgroundColor: oldColor: ) Undocumented
Default Implementation
Undocumented
Declaration
Swift
func editor(_ editor: EditorView, didChangeBackgroundColor color: UIColor?, oldColor: UIColor?)
View on GitHub
EditorViewDelegate Protocol Reference