Module: Cursors

Cursors

Source:

Methods

<inner> create(node, atEnd) → {Cursor}

Creates a cursor instance. A cursor has the added utility over other iteration methods of iterating over the end position of an element. The start and end positions of an element are immediately before the element and immediately after the last child respectively. All node positions except end positions can be identified just by a node. To distinguish between element start and end positions, the additional atEnd boolean is necessary.
Parameters:
Name Type Description
node Node The container in which the cursor is in.
atEnd boolean Whether or not the cursor is at the end of the container.
Source:
Returns:
Type
Cursor

<inner> createFromBoundary(container, offset) → {Cursor}

Creates a new cursor from the given container and offset.
Parameters:
Name Type Description
container Node If a text node, should have a parent node.
offset Number If container is a text node, the offset will be ignored.
Source:
Returns:
Type
Cursor

<inner> Cursor()

Cursor abstraction of the startContainer/startOffset and endContainer/endOffset range boundary points.
Source:

<inner> setRangeEnd(range, pos) → {Range}

Sets the end boundary of a given range from the given range position.
Parameters:
Name Type Description
range Range
pos Cursor
Source:
Returns:
The given range, having been modified.
Type
Range

<inner> setRangeStart(pos, range) → {Range}

Sets the start boundary of a given range from the given range position.
Parameters:
Name Type Description
pos Cursor
range Range
Source:
Returns:
The modified range.
Type
Range

<inner> setToRange(range, start, end) → {Range}

Sets the startContainer/startOffset and endContainer/endOffset boundary points of the given range, based on the given start and end Cursors.
Parameters:
Name Type Description
range Range
start Cursor
end Cursor
Source:
Returns:
The given range, having had its boundary points modified.
Type
Range

<inner> toBoundary(cursor) → {Boundary}

Transforms a cursor to a boundary.
Parameters:
Name Type Description
cursor Cursor
Source:
Returns:
Type
Boundary