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
,tab
etc. is intercepted in theEditor
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. whentrue
, the key press is not passed to theEditor
-
editor(_:
Default implementationdidReceiveKey: at: ) Invoked when a special key like
enter
,tab
etc. is entered in theEditor
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(_:
Default implementationdidReceiveFocusAt: ) 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(_:
Default implementationdidLoseFocusFrom: ) 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(_:
Default implementationdidChangeTextAt: ) 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.
-
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
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(_:
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
editor
Editor view receiving the event.
processors
Processors that are executed.
range
Range 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
editor
Editor view receiving the event.
currentSize
Current size of Editor after updates.
previousSize
Size of Editor before the update.
-
editor(_:
Default implementationdidTapAtLocation: characterRange: ) 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(_:
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
editor
Editor view receiving the event.
content
Attributed text value.
-
editor(_:
Default implementationwillSetAttributedText: isDeferred: ) 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 onwindow
whenattributedText
was originally set. -
editor(_:
Default implementationdidSetAttributedText: isDeferred: ) 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 onwindow
whenattributedText
was 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
editor
Editor view receiving the event.
isReady
true
if Editor is loaded.false
when 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
editor
Editor view receiving the event.
isEditable
true
if editor is editable, elsefalse
-
editor(_:
Default implementationwillRenderAttachment: ) Notifies when an
Attachment
is going to rendered for the first time inEditorView
Note
This invocation only applies in default mode of rendering attachment. IfEditorView
hasAsyncAttachmentRenderingDelegate
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(_:
Default implementationdidRenderAttachment: ) Notifies when an
Attachment
is rendered for the first time inEditorView
Note
This invocation only applies in default mode of rendering attachment. IfEditorView
hasAsyncAttachmentRenderingDelegate
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 -
editor(_:
Default implementationshouldSelectAttachmentOnBackspace: ) Determines if attachment should be deleted when encountering backspace on attachment
Note
If either this orAttachment
s property ofselectBeforeDelete
istrue
, 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, elsefalse
-
editor(_:
Default implementationdidChangeBackgroundColor: oldColor: ) Undocumented
Default Implementation
Undocumented
Declaration
Swift
func editor(_ editor: EditorView, didChangeBackgroundColor color: UIColor?, oldColor: UIColor?)