RangeRef API

PreviousNext

RangeRef objects keep a specific range synced over time as operations are applied. They are low-level location values used by Slate internals and advanced runtime code. Read current for the up-to-date Range value. Call unref() when you no longer need to track the range. affinity controls how the range follows insertions at its edges. inward keeps the range tight; outward lets the range grow.

interface RangeRef {
  current: Range | null
  affinity: 'forward' | 'backward' | 'outward' | 'inward' | null
  unref(): Range | null
}
interface RangeRef {
  current: Range | null
  affinity: 'forward' | 'backward' | 'outward' | 'inward' | null
  unref(): Range | null
}

Instance methods

unref() => Range | null

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

Static methods

Transform methods

RangeRefApi.transform(ref: RangeRef, op: Operation)

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