PathRef API

PreviousNext

Mutable path references that track a path as operations change the document.

PathRef objects keep a specific path 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 Path value. Call unref() when you no longer need to track the path. affinity controls which side the path follows when content is inserted at the current position.

interface PathRef {
  current: Path | null;
  affinity: "forward" | "backward" | null;
  unref(): Path | null;
}
interface PathRef {
  current: Path | null;
  affinity: "forward" | "backward" | null;
  unref(): Path | null;
}

Instance Methods

unref() => Path | null

Stop tracking this path and return the final path value, or null when the path is already invalid.

Static Methods

Transform Methods

PathRefApi.transform(ref: PathRef, op: Operation)

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