EditorListFormattingProvider

public protocol EditorListFormattingProvider : AnyObject

Describes an object capable of providing style and formatting information for rendering lists in EditorView.

  • Line formatting to be used for a list item.

    Declaration

    Swift

    var listLineFormatting: LineFormatting { get }
  • Returns the marker to be drawn for list item (bullet/number etc.) for given parameters.

    Note

    This function is called multiple times for same index level based on TextKit layout cycles. It is advisable to cache the values if calculation/drawing is performance intensive.

    Declaration

    Swift

    func listLineMarkerFor(editor: EditorView, index: Int, level: Int, previousLevel: Int, attributeValue: Any?) -> ListLineMarker

    Parameters

    editor

    Editor in which list marker is being drawn.

    index

    Index of list item in the given list.

    level

    Indentation level of the list.

    previousLevel

    Previous indentation level. Using this, it can be determined if the list is being indented, outdented or is at same level.

    attributeValue

    Value of list item attribute for given index. Nil if there is no content set in list item yet.

    Return Value

    Marker to be drawn for the given list item.

  • Invoked before the indentation level is changed. This may be used to change the list attribute value, if needed.

    Default Implementation

    Declaration

    Swift

    func willChangeListIndentation(editor: EditorView, range: NSRange, currentLevel: Int, indentMode: Indentation, latestAttributeValueAtProposedLevel: Any?)

    Parameters

    editor

    Editor in which indentation is going to be changed.

    range

    Range of affected text

    currentLevel

    Current nested level of list, with first level being 1.

    indentMode

    Indentation action to be performed

    latestAttributeValueAtProposedLevel

    List item attribute value immediately preceding the current item at the new level that the current item will be indented to. The value isnil if preceding item does not exist at the new level.