list/list/utils/model
Classes
ListItemUidinternalmodule:list/list/utils/model~ListItemUid
Interfaces
module:list/list/utils/model~ListElement
Functions
canBecomeSimpleListItem( block, schema ) → booleaninternalmodule:list/list/utils/model~canBecomeSimpleListItemChecks 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 : ModelElementA block to be tested.
schema : ModelSchemaThe schema of the document.
Returns
boolean
expandListBlocksToCompleteItems( blocks, options = { [options.withNested] } ) → Array<ListElement>internalmodule:list/list/utils/model~expandListBlocksToCompleteItemsExpands 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 ] : booleanWhether should include nested list items.
Defaults to
{}
Returns
Array<ListElement>
expandListBlocksToCompleteList( blocks ) → Array<ListElement>internalmodule:list/list/utils/model~expandListBlocksToCompleteListExpands 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>
getAllListItemBlocks( listItem, options = { [options.higherIndent] } ) → Array<ListElement>internalmodule:list/list/utils/model~getAllListItemBlocksReturns an array with all elements that represents the same list item.
It means that values for
listIndent, andlistItemIdfor all items are equal.Parameters
listItem : ModelNodeStarting list item element.
options : object- Properties
[ options.higherIndent ] : booleanWhether blocks with a higher indent level than the start block should be included in the result.
Defaults to
{}
Returns
Array<ListElement>
getListItemBlocks( listItem, options = { [options.direction], [options.higherIndent] } ) → Array<ListElement>internalmodule:list/list/utils/model~getListItemBlocksReturns an array with elements that represents the same list item in the specified direction.
It means that values for
listIndentandlistItemIdfor 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 : ModelNodeStarting list item element.
options : object- Properties
[ options.direction ] : 'forward' | 'backward'Walking direction.
[ options.higherIndent ] : booleanWhether blocks with a higher indent level than the start block should be included in the result.
Defaults to
{}
Returns
Array<ListElement>
getListItems( listItem, [ options ] ) → Array<ListElement>internalmodule:list/list/utils/model~getListItemsReturns array of all blocks/items of the same list as given block (same indent, same type and properties).
Parameters
listItem : ModelElementStarting list item element.
[ options ] : ListWalkerOptionsAdditional list walker options to modify the range of returned list items.
Returns
Array<ListElement>
getNestedListBlocks( listItem ) → Array<ListElement>internalmodule:list/list/utils/model~getNestedListBlocksReturns a list items nested inside the given list item.
Parameters
listItem : ModelElement
Returns
Array<ListElement>
getSelectedBlockObject( model ) → ModelElement | nullinternalmodule:list/list/utils/model~getSelectedBlockObjectReturns a selected block object. If a selected object is inline or when there is no selected object,
nullis returned.Parameters
model : ModelThe instance of editor model.
Returns
ModelElement | nullSelected block object or
null.
indentBlocks( blocks, writer, options = { options.attributeNames, [options.expand], [options.indentBy] } ) → Array<ListElement>internalmodule:list/list/utils/model~indentBlocksIncreases indentation of given list blocks.
Parameters
blocks : ArrayOrItem<ListElement>The block or iterable of blocks.
writer : ModelWriterThe model writer.
options : objectAdditional options.
Propertiesoptions.attributeNames : Array<string>List of attribute names to remove when a block leaves the list (when blockIndent < 0).
[ options.expand ] : booleanWhether should expand the list of blocks to include complete list items.
[ options.indentBy ] : numberThe number of levels the indentation should change (could be negative).
Defaults to
1
Returns
Array<ListElement>
isFirstBlockOfListItem( listBlock ) → booleaninternalmodule:list/list/utils/model~isFirstBlockOfListItemCheck if the given block is the first in the list item.
Parameters
listBlock : ModelNodeThe list block element.
Returns
boolean
isFirstListItemInList( listItem ) → booleanmodule:list/list/utils/model~isFirstListItemInListChecks 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
isLastBlockOfListItem( listBlock ) → booleaninternalmodule:list/list/utils/model~isLastBlockOfListItemCheck if the given block is the last in the list item.
Parameters
listBlock : ModelElement
Returns
boolean
isListItemBlock( node ) → node is ListElementinternalmodule:list/list/utils/model~isListItemBlockReturns true if the given model node is a list item block.
Parameters
node : ModelDocumentFragment | ModelItem | null
Returns
node is ListElement
isNumberedListType( listType ) → booleaninternalmodule:list/list/utils/model~isNumberedListTypeReturns true if listType is of type
numberedorcustomNumbered.Parameters
listType : ListType
Returns
boolean
isSingleListItem( blocks ) → booleaninternalmodule:list/list/utils/model~isSingleListItemChecks whether the given blocks are related to a single list item.
Parameters
blocks : Array<ModelNode>The list block elements.
Returns
boolean
mergeListItemBefore( listBlock, parentBlock, writer ) → Array<ListElement>internalmodule:list/list/utils/model~mergeListItemBeforeMerges the list item with the parent list item.
Parameters
listBlock : ModelNodeThe list block element.
parentBlock : ModelElementThe list block element to merge with.
writer : ModelWriterThe model writer.
Returns
Array<ListElement>The array of updated blocks.
outdentBlocksWithMerge( blocks, writer, options = { options.attributeNames } ) → Array<ListElement>internalmodule:list/list/utils/model~outdentBlocksWithMergeDecreases 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 : ModelWriterThe model writer.
options : objectAdditional options.
Propertiesoptions.attributeNames : Array<string>List of attribute names to remove when a block leaves the list (when blockIndent < 0).
Returns
Array<ListElement>
outdentFollowingItems( lastBlock, writer ) → Array<ListElement>internalmodule:list/list/utils/model~outdentFollowingItemsModifies 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 : ModelElementThe last list block that has become a non-list element.
writer : ModelWriterThe model writer.
Returns
Array<ListElement>Array of altered blocks.
removeListAttributes( blocks, writer, attributeNames ) → Array<ModelElement>internalmodule:list/list/utils/model~removeListAttributesRemoves all list attributes from the given blocks.
Parameters
blocks : ArrayOrItem<ModelElement>The block or iterable of blocks.
writer : ModelWriterThe model writer.
attributeNames : Array<string>List of attribute names to remove.
Returns
Array<ModelElement>Array of altered blocks.
sortBlocks( blocks ) → Array<T>internalmodule:list/list/utils/model~sortBlocksReturns the array of given blocks sorted by model indexes (document order).
Type parameters
T : extends ModelElement
Parameters
blocks : Iterable<T>
Returns
Array<T>
splitListItemBefore( listBlock, writer ) → Array<ListElement>internalmodule:list/list/utils/model~splitListItemBeforeSplits the list item just before the provided list block.
Parameters
listBlock : ModelElementThe list block element.
writer : ModelWriterThe model writer.
Returns
Array<ListElement>The array of updated blocks.