NEWCKEditor AI on your premises: Hook your LLM and register MCP tools. Webinar coming soon!
Sign up (with export icon)

list/list/utils/model

Api-module iconmodule

Classes

  • ListItemUid
    internal

Interfaces

Functions

  • Chevron-right icon

    canBecomeSimpleListItem( block, schema ) → boolean
    internal

    Checks whether the given block can be replaced by a listItem.

    Note that this is possible only when multiBlock = false option is set in feature config.

    Parameters

    block : ModelElement

    A block to be tested.

    schema : ModelSchema

    The schema of the document.

    Returns

    boolean
  • Chevron-right icon

    expandListBlocksToCompleteItems( blocks, options = { [options.withNested] } ) → Array<ListElement>
    internal

    Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items.

    Parameters

    blocks : ArrayOrItem<ModelElement>

    The list of selected blocks.

    options : object
    Properties
    [ options.withNested ] : boolean

    Whether should include nested list items.

    Defaults to {}

    Returns

    Array<ListElement>
  • Chevron-right icon

    expandListBlocksToCompleteList( blocks ) → Array<ListElement>
    internal

    Expands the given list of selected blocks to include all the items of the lists they're in.

    Parameters

    blocks : ArrayOrItem<ModelElement>

    The list of selected blocks.

    Returns

    Array<ListElement>
  • Chevron-right icon

    getAllListItemBlocks( listItem, options = { [options.higherIndent] } ) → Array<ListElement>
    internal

    Returns an array with all elements that represents the same list item.

    It means that values for listIndent, and listItemId for all items are equal.

    Parameters

    listItem : ModelNode

    Starting list item element.

    options : object
    Properties
    [ options.higherIndent ] : boolean

    Whether blocks with a higher indent level than the start block should be included in the result.

    Defaults to {}

    Returns

    Array<ListElement>
  • Chevron-right icon

    getListItemBlocks( listItem, options = { [options.direction], [options.higherIndent] } ) → Array<ListElement>
    internal

    Returns an array with elements that represents the same list item in the specified direction.

    It means that values for listIndent and listItemId for all items are equal.

    Note: For backward search the provided item is not included, but for forward search it is included in the result.

    Parameters

    listItem : ModelNode

    Starting list item element.

    options : object
    Properties
    [ options.direction ] : 'forward' | 'backward'

    Walking direction.

    [ options.higherIndent ] : boolean

    Whether blocks with a higher indent level than the start block should be included in the result.

    Defaults to {}

    Returns

    Array<ListElement>
  • Chevron-right icon

    getListItems( listItem, [ options ] ) → Array<ListElement>
    internal

    Returns array of all blocks/items of the same list as given block (same indent, same type and properties).

    Parameters

    listItem : ModelElement

    Starting list item element.

    [ options ] : ListWalkerOptions

    Additional list walker options to modify the range of returned list items.

    Returns

    Array<ListElement>
  • Chevron-right icon

    getNestedListBlocks( listItem ) → Array<ListElement>
    internal

    Returns a list items nested inside the given list item.

    Parameters

    listItem : ModelElement

    Returns

    Array<ListElement>
  • Chevron-right icon

    getSelectedBlockObject( model ) → ModelElement | null
    internal

    Returns a selected block object. If a selected object is inline or when there is no selected object, null is returned.

    Parameters

    model : Model

    The instance of editor model.

    Returns

    ModelElement | null

    Selected block object or null.

  • Chevron-right icon

    indentBlocks( blocks, writer, options = { options.attributeNames, [options.expand], [options.indentBy] } ) → Array<ListElement>
    internal

    Increases indentation of given list blocks.

    Parameters

    blocks : ArrayOrItem<ListElement>

    The block or iterable of blocks.

    writer : ModelWriter

    The model writer.

    options : object

    Additional options.

    Properties
    options.attributeNames : Array<string>

    List of attribute names to remove when a block leaves the list (when blockIndent < 0).

    [ options.expand ] : boolean

    Whether should expand the list of blocks to include complete list items.

    [ options.indentBy ] : number

    The number of levels the indentation should change (could be negative).

    Defaults to 1

    Returns

    Array<ListElement>
  • Chevron-right icon

    isFirstBlockOfListItem( listBlock ) → boolean
    internal

    Check if the given block is the first in the list item.

    Parameters

    listBlock : ModelNode

    The list block element.

    Returns

    boolean
  • Chevron-right icon

    isFirstListItemInList( listItem ) → boolean

    Checks if the given list item is the first item in the list.

    This function checks if there's any other list item before the given list item at the same indent level with the same list type.

    Parameters

    listItem : ModelElement

    Returns

    boolean
  • Chevron-right icon

    isLastBlockOfListItem( listBlock ) → boolean
    internal

    Check if the given block is the last in the list item.

    Parameters

    listBlock : ModelElement

    Returns

    boolean
  • Chevron-right icon

    isListItemBlock( node ) → node is ListElement
    internal

    Returns true if the given model node is a list item block.

    Parameters

    node : ModelDocumentFragment | ModelItem | null

    Returns

    node is ListElement
  • Chevron-right icon

    isNumberedListType( listType ) → boolean
    internal

    Returns true if listType is of type numbered or customNumbered.

    Parameters

    listType : ListType

    Returns

    boolean
  • Chevron-right icon

    isSingleListItem( blocks ) → boolean
    internal

    Checks whether the given blocks are related to a single list item.

    Parameters

    blocks : Array<ModelNode>

    The list block elements.

    Returns

    boolean
  • Chevron-right icon

    mergeListItemBefore( listBlock, parentBlock, writer ) → Array<ListElement>
    internal

    Merges the list item with the parent list item.

    Parameters

    listBlock : ModelNode

    The list block element.

    parentBlock : ModelElement

    The list block element to merge with.

    writer : ModelWriter

    The model writer.

    Returns

    Array<ListElement>

    The array of updated blocks.

  • Chevron-right icon

    outdentBlocksWithMerge( blocks, writer, options = { options.attributeNames } ) → Array<ListElement>
    internal

    Decreases indentation of given list of blocks. If the indentation of some blocks matches the indentation of surrounding blocks, they get merged together.

    Parameters

    blocks : ArrayOrItem<ListElement>

    The block or iterable of blocks.

    writer : ModelWriter

    The model writer.

    options : object

    Additional options.

    Properties
    options.attributeNames : Array<string>

    List of attribute names to remove when a block leaves the list (when blockIndent < 0).

    Returns

    Array<ListElement>
  • Chevron-right icon

    outdentFollowingItems( lastBlock, writer ) → Array<ListElement>
    internal

    Modifies the indents of list blocks following the given list block so the indentation is valid after the given block is no longer a list item.

    Parameters

    lastBlock : ModelElement

    The last list block that has become a non-list element.

    writer : ModelWriter

    The model writer.

    Returns

    Array<ListElement>

    Array of altered blocks.

  • Chevron-right icon

    removeListAttributes( blocks, writer, attributeNames ) → Array<ModelElement>
    internal

    Removes all list attributes from the given blocks.

    Parameters

    blocks : ArrayOrItem<ModelElement>

    The block or iterable of blocks.

    writer : ModelWriter

    The model writer.

    attributeNames : Array<string>

    List of attribute names to remove.

    Returns

    Array<ModelElement>

    Array of altered blocks.

  • Chevron-right icon

    sortBlocks( blocks ) → Array<T>
    internal

    Returns the array of given blocks sorted by model indexes (document order).

    Type parameters

    T : extends ModelElement

    Parameters

    blocks : Iterable<T>

    Returns

    Array<T>
  • Chevron-right icon

    splitListItemBefore( listBlock, writer ) → Array<ListElement>
    internal

    Splits the list item just before the provided list block.

    Parameters

    listBlock : ModelElement

    The list block element.

    writer : ModelWriter

    The model writer.

    Returns

    Array<ListElement>

    The array of updated blocks.