Represents a resolved position in a ProseMirror document.
You can resolve a position to get more information about it. Objects of this struct represent such a resolved position, providing various pieces of context information, and some helper methods.
Throughout this module, functions that take an optional depth parameter
will interpret nil as self.depth and negative numbers as self.depth + value.
Ported from ProseMirror's resolvedpos.ts.
Summary
Functions
The (absolute) position directly after the wrapping node at the given level,
or the original position when depth is self.depth + 1.
The (absolute) position directly before the wrapping node at the given level,
or, when depth is self.depth + 1, the original position.
Returns a range based on the place where this position and the given position diverge around block content.
The root node in which the position was resolved.
The (absolute) position at the end of the node at the given level.
The index into the ancestor at the given level.
The index pointing after this position into the ancestor at the given level.
Get the marks at this position, factoring in the surrounding marks'
inclusive property.
Get the marks after the current position, if any, except those that are
non-inclusive and not present at position end_rpos. This is mostly useful
for getting the set of marks to preserve after a deletion.
Return the greater of this and the given position.
Return the smaller of this and the given position.
The ancestor node at the given level. node(rpos, rpos.depth) is the
same as parent(rpos).
Get the node directly after the position, if any. If the position points into a text node, only the part of that node after the position is returned.
Get the node directly before the position, if any. If the position points into a text node, only the part of that node before the position is returned.
The parent node that the position points into.
Get the position at the given index in the parent node at the given depth
(which defaults to self.depth).
Resolve the given position in the given document, returning a ResolvedPos.
Normalize a depth value. nil becomes self.depth, negative values become self.depth + val.
Query whether the given position shares the same parent node.
The depth up to which this position and the given (non-resolved) position share the same parent nodes.
The (absolute) position at the start of the node at the given level.
When this position points into a text node, this returns the distance between the position and the start of the text node. Will be zero for positions that point between nodes.
String representation of this resolved position (for debugging).
Functions
The (absolute) position directly after the wrapping node at the given level,
or the original position when depth is self.depth + 1.
The (absolute) position directly before the wrapping node at the given level,
or, when depth is self.depth + 1, the original position.
Returns a range based on the place where this position and the given position diverge around block content.
The root node in which the position was resolved.
The (absolute) position at the end of the node at the given level.
The index into the ancestor at the given level.
The index pointing after this position into the ancestor at the given level.
Get the marks at this position, factoring in the surrounding marks'
inclusive property.
Get the marks after the current position, if any, except those that are
non-inclusive and not present at position end_rpos. This is mostly useful
for getting the set of marks to preserve after a deletion.
Return the greater of this and the given position.
Return the smaller of this and the given position.
The ancestor node at the given level. node(rpos, rpos.depth) is the
same as parent(rpos).
Get the node directly after the position, if any. If the position points into a text node, only the part of that node after the position is returned.
Get the node directly before the position, if any. If the position points into a text node, only the part of that node before the position is returned.
The parent node that the position points into.
Get the position at the given index in the parent node at the given depth
(which defaults to self.depth).
Resolve the given position in the given document, returning a ResolvedPos.
Normalize a depth value. nil becomes self.depth, negative values become self.depth + val.
Query whether the given position shares the same parent node.
The (absolute) position at the start of the node at the given level.
When this position points into a text node, this returns the distance between the position and the start of the text node. Will be zero for positions that point between nodes.
String representation of this resolved position (for debugging).