ModelNodeList
Provides an interface to operate on a list of nodes. NodeList is used internally in classes like Element or ModelDocumentFragment.
Properties
- length : numberreadonly- module:engine/model/nodelist~ModelNodeList#length- Number of nodes contained inside this node list. 
- maxOffset : numberreadonly- module:engine/model/nodelist~ModelNodeList#maxOffset- Sum of offset sizes of all nodes contained inside this node list. 
- module:engine/model/nodelist~ModelNodeList#_nodes- Nodes contained in this node list. 
- _offsetToNode : Array<ModelNode>private- module:engine/model/nodelist~ModelNodeList#_offsetToNode- This array maps numbers (offsets) to node that is placed at that offset. - This array is similar to - _nodeswith the difference that one node may occupy multiple consecutive items in the array.- This array is needed to quickly retrieve a node that is placed at given offset. 
Methods
- constructor( [ nodes ] )internal- module:engine/model/nodelist~ModelNodeList#constructor
- Symbol.iterator() → IterableIterator<ModelNode>- module:engine/model/nodelist~ModelNodeList#Symbol.iterator- Iterable interface. - Iterates over all nodes contained inside this node list. - Returns- IterableIterator<ModelNode>
 
- module:engine/model/nodelist~ModelNodeList#getNode- Gets the node at the given index. Returns - nullif incorrect index was passed.- Parameters- index : number
 - Returns- null | ModelNode
 
- getNodeAtOffset( offset ) → null | ModelNode- module:engine/model/nodelist~ModelNodeList#getNodeAtOffset- Gets the node at the given offset. Returns - nullif incorrect offset was passed.- Parameters- offset : number
 - Returns- null | ModelNode
 
- getNodeIndex( node ) → null | number- module:engine/model/nodelist~ModelNodeList#getNodeIndex
- getNodeStartOffset( node ) → null | number- module:engine/model/nodelist~ModelNodeList#getNodeStartOffset- Returns the offset at which given node is placed in its parent or - nullif given node does not have a parent.- This is an alias to - startOffset.- Parameters- node : ModelNode
 - Returns- null | number
 
- indexToOffset( index ) → number- module:engine/model/nodelist~ModelNodeList#indexToOffset- Converts index to offset in node list. - Throws CKEditorError - model-nodelist-index-out-of-boundsif given index is less than- 0or more than- length.- Parameters- index : number
 - Returns- number
 
- offsetToIndex( offset ) → number- module:engine/model/nodelist~ModelNodeList#offsetToIndex- Converts offset in node list to index. - Throws CKEditorError - model-nodelist-offset-out-of-boundsif given offset is less than- 0or more than- maxOffset.- Parameters- offset : number
 - Returns- number
 
- toJSON() → unknown- module:engine/model/nodelist~ModelNodeList#toJSON- Converts - NodeListinstance to an array containing nodes that were inserted in the node list. Nodes are also converted to their plain object representation.- Returns- unknown
- NodeListinstance converted to- Array.
 
- _insertNodes( index, nodes ) → voidinternal- module:engine/model/nodelist~ModelNodeList#_insertNodes- Inserts given nodes at given index. - Parameters- index : number
- Index at which nodes should be inserted. 
- nodes : Iterable<ModelNode>
- Nodes to be inserted. 
 - Returns- void
 
- _removeNodes( indexStart, howMany ) → Array<ModelNode>internal- module:engine/model/nodelist~ModelNodeList#_removeNodes- Removes one or more nodes starting at the given index. - Parameters- indexStart : number
- Index of the first node to remove. 
- howMany : number
- Number of nodes to remove. - Defaults to - 1
 - Returns- Array<ModelNode>
- Array containing removed nodes. 
 
- _removeNodesArray( nodes ) → voidinternal- module:engine/model/nodelist~ModelNodeList#_removeNodesArray- Removes children nodes provided as an array. These nodes do not need to be direct siblings. - This method is faster than removing nodes one by one, as it recalculates offsets only once. - Parameters- nodes : Array<ModelNode>
- Array of nodes. 
 - Returns- void