NodeList (engine/model)
@ckeditor/ckeditor5-engine/src/model/nodelist
Provides an interface to operate on a list of nodes. NodeList is used internally
in classes like Element
or DocumentFragment.
Filtering
Properties
-
Number of nodes contained inside this node list.
-
Sum of offset sizes of all nodes contained inside this node list.
-
Nodes contained in this node list.
-
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
-
-
Symbol.iterator() → IterableIterator<Node>module:engine/model/nodelist~NodeList#Symbol.iteratorIterable interface.
Iterates over all nodes contained inside this node list.
Returns
IterableIterator<Node>
-
Gets the node at the given index. Returns
nullif incorrect index was passed.Parameters
index : number
Returns
null | Node
-
getNodeAtOffset( offset ) → null | Nodemodule:engine/model/nodelist~NodeList#getNodeAtOffsetGets the node at the given offset. Returns
nullif incorrect offset was passed.Parameters
offset : number
Returns
null | Node
-
getNodeIndex( node ) → null | numbermodule:engine/model/nodelist~NodeList#getNodeIndex -
getNodeStartOffset( node ) → null | numbermodule:engine/model/nodelist~NodeList#getNodeStartOffsetReturns 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 : Node
Returns
null | number
-
indexToOffset( index ) → numbermodule:engine/model/nodelist~NodeList#indexToOffsetConverts index to offset in node list.
Throws CKEditorError
model-nodelist-index-out-of-boundsif given index is less than0or more thanlength.Parameters
index : number
Returns
number
-
offsetToIndex( offset ) → numbermodule:engine/model/nodelist~NodeList#offsetToIndexConverts offset in node list to index.
Throws CKEditorError
model-nodelist-offset-out-of-boundsif given offset is less than0or more thanmaxOffset.Parameters
offset : number
Returns
number
-
toJSON() → unknownmodule:engine/model/nodelist~NodeList#toJSONConverts
NodeListinstance to an array containing nodes that were inserted in the node list. Nodes are also converted to their plain object representation.Returns
unknownNodeListinstance converted toArray.
-
Inserts given nodes at given index.
Parameters
index : numberIndex at which nodes should be inserted.
nodes : Iterable<Node>Nodes to be inserted.
Returns
void
-
internal
_removeNodes( indexStart, howMany ) → Array<Node>module:engine/model/nodelist~NodeList#_removeNodesRemoves one or more nodes starting at the given index.
Parameters
indexStart : numberIndex of the first node to remove.
howMany : numberNumber of nodes to remove.
Defaults to
1
Returns
Array<Node>Array containing removed nodes.
-
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<Node>Array of nodes.
Returns
void
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.