API reference for points in Plate.

A Point represents a specific location in a Plate 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

  • at optional At | null

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

  • options optional object

    Additional options for point retrieval.

Optionsobject

Collapse all
  • focus optional boolean

    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
  • point Point

    The point to transform.

  • op Operation

    The operation to apply.

  • options optional PointTransformOptions

    Options for transforming the point.

OptionsPointTransformOptions

Collapse all
  • affinity optional TextDirection | null

    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
  • point Point

    The first point to compare.

  • another Point

    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
  • point Point

    The first point to compare.

  • another Point

    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
  • point Point

    The point to check.

  • another Point

    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
  • point Point

    The point to check.

  • another Point

    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
  • value any

    The value to check.

Returnsboolean

    true if the value is a point.

Types

Point

A point represents a specific location in a Plate document.

Attributes

Collapse all
  • offset number

    The index of the character in the text node.

  • path Path

    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
  • [0] Point

    The point location.

  • [1] 'anchor' | 'focus'

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