PointRef API

PreviousNext

Mutable point references that track a point as operations change text and nodes.

PointRef objects keep a specific point synced over time as operations are applied. They are low-level location values used by Slate internals and advanced runtime code.

Shape

Read current for the up-to-date Point value. Call unref() when you no longer need to track the point. affinity controls which side the point follows when content is inserted at the current position.

interface PointRef {
  current: Point | null;
  affinity: "forward" | "backward" | null;
  unref(): Point | null;
}
interface PointRef {
  current: Point | null;
  affinity: "forward" | "backward" | null;
  unref(): Point | null;
}

Instance Methods

unref() => Point | null

Call this when you no longer need to sync this point. It also returns the current value.

Static Methods

Transform Methods

PointRefApi.transform(ref: PointRef, op: Operation)

Transform the point ref's current value by an op. The editor calls this as needed, so normally you won't need to.