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.

type Point = {
  path: Path
  offset: number
}

PointAPI

get

Get a point from a location.

Parameters

Collapse all

    The location to get the point from. Can be a TRange, Point, or Path.

    Additional options for point retrieval.

Optionsobject

Collapse all

    If true and the location is a range, returns the focus point instead of the anchor point.

ReturnsPoint | undefined

    The point at the specified location, or undefined if not found.

transform

Transform a point by an operation.

Parameters

Collapse all

    The point to transform.

    The operation to apply.

    Options for transforming the point.

OptionsPointTransformOptions

Collapse all

    The direction to prefer when transforming the point.

ReturnsPoint | null

    The transformed point, or null if the point was deleted.

compare

Compare a point to another.

Parameters

Collapse all

    The first point to compare.

    The second point to compare.

Returns-1 | 0 | 1

    -1 if before, 0 if at the same location, 1 if after.

equals

Check if two points are exactly equal.

Parameters

Collapse all

    The first point to compare.

    The second point to compare.

Returnsboolean

    true if the points are equal, false otherwise.

isAfter

Check if a point is after another.

Parameters

Collapse all

    The point to check.

    The point to compare against.

Returnsboolean

    true if the first point is after the second.

isBefore

Check if a point is before another.

Parameters

Collapse all

    The point to check.

    The point to compare against.

Returnsboolean

    true if the first point is before the second.

isPoint

Check if a value implements the Point interface.

Parameters

Collapse all

    The value to check.

Returnsboolean

    true if the value is a point.

Types

Point

A point represents a specific location in a Slate document.

Attributes

Collapse all

    The index of the character in the text node.

    The path to the text node.

PointEntry

A point entry is returned when iterating over Point objects that belong to a range.

Attributes

Collapse all

    The point location.

    Indicates whether this point is the anchor or focus of a range.