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
-
length : Number
module:engine/model/nodelist~NodeList#length
readonly
Number of nodes contained inside this node list.
-
maxOffset : Number
module:engine/model/nodelist~NodeList#maxOffset
readonly
Sum of offset sizes of all nodes contained inside this node list.
-
Nodes contained in this node list.
Methods
-
constructor( nodes )
module:engine/model/nodelist~NodeList#constructor
protected
Creates an empty node list.
Parameters
nodes : Iterable.<Node>
Nodes contained in this node list.
-
Symbol.iterator() → Iterable.<Node>
module:engine/model/nodelist~NodeList#Symbol.iterator
Iterable interface.
-
Gets the node at the given index. Returns
null
if incorrect index was passed. -
getNodeIndex( node ) → Number | null
module:engine/model/nodelist~NodeList#getNodeIndex
Returns an index of the given node. Returns
null
if given node is not inside this node list. -
getNodeStartOffset( node ) → Number | null
module:engine/model/nodelist~NodeList#getNodeStartOffset
Returns the starting offset of given node. Starting offset is equal to the sum of offset sizes of all nodes that are before this node in this node list.
-
indexToOffset( index ) → Number
module:engine/model/nodelist~NodeList#indexToOffset
Converts index to offset in node list.
Returns starting offset of a node that is at given index. Throws CKEditorError
model-nodelist-index-out-of-bounds
if given index is less than0
or more thanlength
.Parameters
index : Number
Node's index.
Returns
Number
Node's starting offset.
-
offsetToIndex( offset ) → Number
module:engine/model/nodelist~NodeList#offsetToIndex
Converts offset in node list to index.
Returns index of a node that occupies given offset. Throws CKEditorError
model-nodelist-offset-out-of-bounds
if given offset is less than0
or more thanmaxOffset
.Parameters
offset : Number
Offset to look for.
Returns
Number
Index of a node that occupies given offset.
-
Converts
NodeList
instance to an array containing nodes that were inserted in the node list. Nodes are also converted to their plain object representation.Returns
Array.<Node>
NodeList
instance converted toArray
.
-
_insertNodes( index, nodes )
module:engine/model/nodelist~NodeList#_insertNodes
protected
Inserts given nodes at given index.
Parameters
index : Number
Index at which nodes should be inserted.
nodes : Iterable.<Node>
Nodes to be inserted.
-
_removeNodes( indexStart, [ howMany ] ) → Array.<Node>
module:engine/model/nodelist~NodeList#_removeNodes
protected
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.<Node>
Array containing removed nodes.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.