Protocols
The following protocols are available globally.
-
An object capable of resolving text asynchronously to another representation. New representation may contain change in attributes or the string itself.
See moreDeclaration
Swift
public protocol AsyncTextResolving -
Describes an object (typically attachment view) that may change size during the layout pass
See moreDeclaration
Swift
public protocol DynamicBoundsProviding : AnyObject -
Denotes an
See moreAttachmentcontent view that observes background color changes incontainerEditorViewDeclaration
Swift
public protocol BackgroundColorObserving : UIView -
Describes an object capable of providing offsets for the
Attachment. The value is used to offset theAttachmentwhen rendered alongside the text. This may be used to align the content baselines inAttachmentcontent to that of it’s container’s content baselines.Note
This function may be called m0re than once in the same rendering pass. Changing offsets does not resize the container i.e. unlike how container resizes to fit the attachment, if the offset is change such that the attachment ends up rendering outside the bounds of it’s container, it will not resize the container.See moreAttention
While offset can be provided for any type ofAttachmenti.e. Inline or Block, it is recommended that offset be provided only for Inline. If an offset is provided for Block attachment, it is possible that the attachment starts overlapping the content inEditorin the following line since the offset does not affect the line height.Declaration
Swift
public protocol AttachmentOffsetProviding : AnyObject -
Describes an object that fulfils requirements to enable asynchronous rendering of attachments in the
See moreEditorViewDeclaration
Swift
public protocol AsyncAttachmentRenderingDelegate : AnyObject -
Marker protocol for attachment views that may need to defer completion of rendering in asynchronous mode until the view bounds are changed. This may be important for cases like
GridViewthat does not directly contain the Editors within but instead hosts another view that in turn hosts multiple editors i.e. one per cell. Conformance to this protocol defers invoking thedidRenderAttachmentonAsyncAttachmentRenderingDelegateuntil the view size are changed to a non-zero value. In absence of this,didRenderAttachmentis invoked as soon as the attachment is rendered in the editor.Important
In almost all the cases where theEditorViewis hosted directly inside the attachment, this conformance is not required and not advised. When used in such cases, the async rendering may result in unexpected results. This is advisable only in case thedidRenderAttachmentis getting triggered sooner than the layout of view within theAttachmentis able to complete.Declaration
Swift
public protocol AsyncDeferredRenderable -
Describes an object capable of gaining focus.
See moreNote
If a content view in anAttachmentis madeFocusable,setFocuswill automatically be called when the attachment with a focusable view is added to the editor.Declaration
Swift
public protocol Focusable -
Describes an object capable of providing numbers to be displayed when
See moreisLineNumbersEnabledis set totrueinEditorViewDeclaration
Swift
public protocol LineNumberProvider : AnyObject -
Describes an object capable of providing style and formatting information for rendering lists in
See moreEditorView.Declaration
Swift
public protocol EditorListFormattingProvider : AnyObject -
Represents a Sequence generator that can return a value based on given index. Besides other possible uses, this is used in Lists for generation of bullets/numbering.
See moreDeclaration
Swift
public protocol SequenceGenerator -
An object capable of decoding attributes for use in
See moreNSAttributedStringDeclaration
Swift
public protocol AttributesDecoding -
An object capable of decoding the given type of content into
See moreNSAttributedStringfor using inEditorViewor theRendererView.Declaration
Swift
public protocol EditorContentDecoding -
Identifies a content type within the
See moreEditorDeclaration
Swift
public protocol EditorContentIdentifying -
Undocumented
See moreDeclaration
Swift
public protocol AttachmentTypeIdentifying -
Describes a view contained in
See moreAttachmentthat contains a singleEditorView. This is a helper protocol that can be applied to the view so that basic properties and functions are made available on the view as passthrough.Declaration
Swift
public protocol EditorContentView : Focusable -
Describes an object interested in observing the bounds of a view.
AttachmentisBoundsObservingand reacts to changes in the bounds of views hosted within theAttachment. Any view contained in theAttachmentthat is capable of changing its bounds must define and setBoundsObservingtoAttachment.Usage Example
See moreclass MyAttachmentView: UIView { weak var boundsObserver: BoundsObserving? override var bounds: CGRect { didSet { guard oldValue != bounds else { return } boundsObserver?.didChangeBounds(bounds) } } } let myView = MyAttachmentView() let attachment = Attachment(myView, size: .matchContent) myView.boundsObserver = attachmentDeclaration
Swift
public protocol BoundsObserving : AnyObject -
Describes an object interested in listening to events raised from EditorView
See moreDeclaration
Swift
public protocol EditorViewDelegate : AnyObject -
Describes a command that can be executed on
See moreEditorView. A command may be invoked directly on theeditorby providing an instance. However, in a typical usage scenario, these should be invoked viaEditorCommandExecutorwhich manages all theEditorViews in the view including the ones that are contained in the attachments.Declaration
Swift
public protocol EditorCommand : AnyObject -
Undocumented
See moreDeclaration
Swift
public protocol EditorCommandExecutorDelegate : AnyObject -
Describes an encoder for a content type in Editor. This can be used in conjunction with
AnyEditorTextEncodingto register various encoders for each of the supported content types. ### Usage Example ###struct ParagraphEncoder: EditorTextEncoding { func encode(name: EditorContent.Name, string: NSAttributedString) -> JSON { var paragraph = JSON() paragraph.type = name.rawValue if let style = string.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle { paragraph[style.key] = style.value } paragraph.contents = contentsFrom(string) return paragraph } }See moreSee also
EditorContentEncoderDeclaration
Swift
public protocol EditorTextEncoding -
Describes an object capable of encoding contents of at
See moreAttachmentDeclaration
Swift
public protocol AttachmentEncoding -
An object capable of encoding
See moreEditorContentto given type.Declaration
Swift
public protocol EditorContentEncoding -
A generic encoder for encoding
EditorContent. You may create encoders for individual types of contents in theEditor, and useEditorContentEncoderto register and encode the all the contents of the givenEditorView.Usage Example
See moretypealias JSON = [String: Any] struct JSONEncoder: EditorContentEncoder { let textEncoders: [EditorContent.Name: AnyEditorTextEncoding<JSON>] = [ .paragraph: AnyEditorTextEncoding(ParagraphEncoder()), .text: AnyEditorTextEncoding(TextEncoder()) ] let attachmentEncoders: [EditorContent.Name: AnyEditorContentAttachmentEncoding<JSON>] = [ .panel: AnyEditorContentAttachmentEncoding(PanelEncoder()), .media: AnyEditorContentAttachmentEncoding(MediaEncoder()), ] } // Get the encoded content from the editor let encodedContent = editor.transformContents(using: JSONEncoder())Declaration
Swift
public protocol EditorContentEncoder : EditorContentEncoding -
An object capable of intercepting and modifying the text and attributes in an
See moreEditorViewwhen registered with theEditorView.Declaration
Swift
public protocol TextProcessing
View on GitHub
Protocols Reference