AsyncAttachmentRenderingDelegate

public protocol AsyncAttachmentRenderingDelegate : AnyObject

Describes an object that fulfils requirements to enable asynchronous rendering of attachments in the EditorView

  • Provides the viewport for the Editor. In typical cases, this would be used if the EditorView is made non-scrollable and hosted within another scrollable container i.e. ScrollView.

    Note

    To use default value, i.e. viewport of the EditorView, leave this value as nil

    Important

    EditorView also has a viewport property that also depends on this property. Care must be taken to not to return editor.viewport here. Doing so will cause a stack overflow crash. An independently calculated value can safely be returned here.

    Declaration

    Swift

    var prioritizedViewport: CGRect? { get }
  • Determines if particular attachment should be rendered asynchronously. The check may also be used to render certain types of attachments synchronously or asynchronously.

    Declaration

    Swift

    func shouldRenderAsync(attachment: Attachment) -> Bool

    Parameters

    attachment

    Attachment to be rendered.

    Return Value

    true to render asynchronously.

  • Notifies when an attachment is rendered asynchronously.

    Declaration

    Swift

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

    Parameters

    attachment

    Attachment that is rendered.

    editor

    Editor in which the attachment is rendered.

  • Notifies when the viewport is rendered. Value of viewport is governed by viewport property in AsyncAttachmentRenderingDelegate when not nil, else from EditorView

    Note

    There may be more than one invocation for the same viewport especially when user scroll out and back to the same viewport. This is invoked when all the attachments in the viewport are rendered or the text is laid out and there are no attachments to render.

    Declaration

    Swift

    func didCompleteRenderingViewport(_ viewport: CGRect, in editor: EditorView)

    Parameters

    viewport

    Viewport that is rendered.

    editor

    Editor for which the viewport rendering is completed.