- Source:
Methods
-
<inner> commonContainer(start, end) → {Node}
-
Return the ancestor container that contains both the given boundaries.
Parameters:
Name Type Description start
Boundary end
Boundary - Source:
Returns:
- Type
- Node
-
<inner> container(boundary) → {Node}
-
Returns a boundary's container node.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Node
-
<inner> create(node, offset) → {Boundary}
-
Creates a node boundary representing an offset position inside of a container node. The resulting boundary will be a normalized boundary, such that the boundary will never describe a terminal position in a text node.
Parameters:
Name Type Description node
Node offset
number Positive integer - Source:
Returns:
- Type
- Boundary
-
<inner> equals(a, b)
-
Compares two boundaries for equality. Boundaries are equal if their corresponding containers and offsets are strictly equal.
Parameters:
Name Type Description a
Boundary b
Boundary - Source:
-
<inner> fromEndOfNode(node) → {Boundary}
-
Returns a boundary that is at the end position of the given node.
Parameters:
Name Type Description node
Node - Source:
Returns:
- Type
- Boundary
-
<inner> fromNode(node) → {Boundary}
-
Returns a boundary that is right in front of the given node.
Parameters:
Name Type Description node
Node - Source:
Returns:
- Type
- Boundary
-
<inner> fromRange(range) → {Array.<Boundary>}
-
Returns a start/end boundary tuple representing the start and end positions of the given range.
Parameters:
Name Type Description range
Range - Source:
Returns:
- Type
- Array.<Boundary>
-
<inner> fromRangeEnd(range) → {Boundary}
-
Creates a boundary from the given range's end position.
Parameters:
Name Type Description range
Range - Source:
Returns:
- Type
- Boundary
-
<inner> fromRanges(ranges) → {Array.<Boundary>}
-
Returns an even-sized contiguous sequence of start/end boundaries aligned in their pairs.
Parameters:
Name Type Description ranges
Array.<Range> - Source:
Returns:
- Type
- Array.<Boundary>
-
<inner> fromRangeStart(range) → {Boundary}
-
Creates a boundary from the given range's start position.
Parameters:
Name Type Description range
Range - Source:
Returns:
- Type
- Boundary
-
<inner> get(doc) → {?Array.<Boundary>}
-
Gets the boundaries of the currently selected range from the given document element. If no document element is given, the document element of the calling frame's window will be used.
Parameters:
Name Type Argument Description doc
Document <optional>
- Source:
Returns:
- Type
- ?Array.<Boundary>
-
<inner> isAtEnd(boundary) → {boolean}
-
Checks if a boundary represents a position at the end of its container's content. The end boundary of the given ranges is at the end position: f{oo] and f{oo} The first is at end of the text node "oo"and the other at end of the element.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> isAtRawEnd(boundary) → {boolean}
-
Checks if the unnormalized boundary is at the end position of it's container.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> isAtRawStart(boundary) → {boolean}
-
Checks if the unnormalized boundary is at the start position of it's container.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> isAtStart(boundary) → {boolean}
-
Checks if a boundary (when normalized) represents a position at the start of its container's content. The start boundary of the given ranges is at the start position: f[oo] and {foo} The first is at the start of the text node "oo" and the other at start of the element.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> isNodeBoundary(boundary) → {boolean}
-
Checks whether the given boundary is a position between nodes (as opposed to a position inside of a text node).
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> isTextBoundary(boundary) → {boolean}
-
Checks whether the given boundary is a position inside of a text nodes.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- boolean
-
<inner> jumpOver(boundary) → {Boundary}
-
Skips the given boundary over the node that is next to the boundary.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> next(boundary) → {Boundary}
-
Like Boundaries.prev(), but returns the boundary position that follows from the given.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> nextNode(boundary) → {Node}
-
Returns the node after the given boundary, or the boundary's container if the boundary is at the end position.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Node
-
<inner> nextRawBoundary(boundary) → {Boundary}
-
Like Boundaries.next() but treats the given boundary as an unnormalized boundary.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> nextWhile(boundary, cond) → {Boundary}
-
Steps forward while the given condition is true.
Parameters:
Name Type Description boundary
Boundary cond
function - Source:
Returns:
- Type
- Boundary
-
<inner> nodeAfter(boundary) → {Node}
-
Returns the node that is after the given boundary position. Will return null if the given boundary is at the end position. Note that the given boundary will be normalized.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Node
-
<inner> nodeBefore(boundary) → {Node}
-
Returns the node that is before the given boundary position. Will returns null if the given boundary is at the start position. Note that the given boundary will be normalized.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Node
-
<inner> normalize(boundary) → {Boundary}
-
Normalizes the boundary point (represented by a container and an offset tuple) such that it will not point to the start or end of a text node. This normalization reduces the number of states the a boundary can be in, and thereby slightly increases the robusteness of the code written against it. It should be noted that native ranges controlled by the browser's DOM implementation have the habit of changing by themselves, so even if a range is set using a boundary that has been normalized this way, the range could revert to an un-normalized state. See StableRange(). The returned value will either be a normalized copy of the given boundary, or the given boundary itself if no normalization was done.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> offset(boundary) → {number}
-
Returns a boundary's offset.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- number
-
<inner> precedingTextLength(boundary) → {number}
-
Calculates the cumulative length of contiguous text nodes immediately preceding the given boundary.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- number
-
<inner> prev(boundary) → {Boundary}
-
Returns a boundary that is at the previous position to the given. If the given boundary represents a position inside of a text node, the returned boundary will be moved behind that text node. Given the markup below:foothe boundary positions which can be traversed with this function are those marked with the pipe ("|") below: |foo|
bar baz
|bar||||baz||
| This function complements Boundaries.next()Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> prevNode(boundary) → {Node}
-
Returns the node before the given boundary, or the boundary container if the boundary is at the end position.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Node
-
<inner> prevRawBoundary(boundary) → {Boundary}
-
Like Boundaries.prev() but treats the given boundary as an unnormalized boundary.
Parameters:
Name Type Description boundary
Boundary - Source:
Returns:
- Type
- Boundary
-
<inner> prevWhile(boundary, cond) → {Boundary}
-
Steps backwards while the given condition is true.
Parameters:
Name Type Description boundary
Boundary cond
function - Source:
Returns:
- Type
- Boundary
-
<inner> raw(node, offset) → {Boundary}
-
Creates a "raw" (un-normalized) boundary from the given node and offset.
Parameters:
Name Type Description node
Node offset
number - Source:
Returns:
- Type
- Boundary
-
<inner> select(start, end)
-
Sets the a range to the browser selection according to the given start and end boundaries. This operation will cause the selection to be visually rendered by the user agent.
Parameters:
Name Type Argument Description start
Boundary end
Boundary <optional>
- Source:
-
<inner> setRange(range, start, end)
-
Sets the given range's start and end position from two respective boundaries.
Parameters:
Name Type Description range
Range Range to modify. start
Boundary Boundary to set the start position to end
Boundary Boundary to set the end position to - Source:
-
<inner> setRangeEnd(range, boundary)
-
Sets the given range's end boundary.
Parameters:
Name Type Description range
Range Range to modify boundary
Boundary - Source:
-
<inner> setRanges(ranges, boundaries)
-
Sets the start and end position of a list of ranges from the given list of boundaries. Because the range at index i in `ranges` will be modified using the boundaries at index 2i and 2i + 1 in `boundaries`, the size of `ranges` must be no less than half the size of `boundaries`. Because the list of boundaries will need to be partitioned into pairs of start/end tuples, it is required that the length of `boundaries` be even. See Arrays.partition().
Parameters:
Name Type Description ranges
Array.<Range> List of ranges to modify boundaries
Array.<Boundary> Even list of boundaries - Source:
-
<inner> setRangeStart(range, boundary)
-
Sets the given range's start boundary.
Parameters:
Name Type Description range
Range Range to modify. boundary
Boundary - Source:
-
<inner> stepWhile(boundary, cond, step) → {Boundary}
-
Steps through boundaries while the given condition is true.
Parameters:
Name Type Description boundary
Boundary Start position cond
function Predicate step
function Gets the next boundary - Source:
Returns:
- Type
- Boundary
-
<inner> walkWhile(boundary, cond, step, callback)
-
Walks along boundaries according to step(), applying callback() to each boundary along the traversal until cond() returns false.
Parameters:
Name Type Description boundary
Boundary Start position cond
function Predicate step
function Gets the next boundary callback
function Applied to each boundary - Source: