Point
API reference for points in Slate.
A Point
represents a specific location in a Slate document. It consists of a path to a text node and an offset within that text node's content.
Point
Find the corresponding documentation in the Slate docs.
get
Gets the point from a location. If the location is a range, gets the anchor point (or focus point if specified). If the location is a path, gets the point at this path with offset 0.
Parameters
The location to get the point from. Can be a Range, Point, or Path.
Returns
Returns the point at the specified location, or undefined
if not found.
transform
Transforms a point by an operation.
Parameters
The point to transform.
The operation to apply to the point.
Returns
Returns the transformed point, or null
if the point was deleted.
compare
Compares a point to another, returning an integer indicating whether the point was before, at, or after the other.
Parameters
The first point to compare.
The second point to compare.
Returns
-1
if the first point is before the second0
if the points are at the same location1
if the first point is after the second
Returns:
equals
Checks if a point is exactly equal to another.
Parameters
The first point to compare.
The second point to compare.
Returns
Returns true
if the points are equal, false
otherwise.
isAfter
Checks if a point is after another.
Parameters
The point to check.
The point to compare against.
Returns
Returns true
if the first point is after the second, false
otherwise.
isBefore
Checks if a point is before another.
Parameters
The point to check.
The point to compare against.
Returns
Returns true
if the first point is before the second, false
otherwise.
isPoint
Checks if a value implements the Point
interface.
Parameters
The value to check.
Returns
Returns true
if the value is a point, false
otherwise.
Types
Point
The base point type that represents a specific location in a Slate document.
Attributes
The index of the character in the text node.
The path to the text node.
PointTransformOptions
Options for transforming a point.
Attributes
The direction to prefer when transforming the point.
PointEntry
A tuple type returned when iterating over points in a range.
Attributes
The point location.
Indicates whether this point is the anchor or focus of a range.