Slate
ExamplesGitHubSlack
main
main
  • Introduction
  • Walkthroughs
    • Installing Slate
    • Adding Event Handlers
    • Defining Custom Elements
    • Applying Custom Formatting
    • Executing Commands
    • Saving to a Database
    • Enabling Collaborative Editing
    • Using the Bundled Source
  • Concepts
    • Interfaces
    • Nodes
    • Locations
    • Transforms
    • Operations
    • Commands
    • Editor
    • Plugins
    • Rendering
    • Serializing
    • Normalizing
    • TypeScript
    • Migrating
  • API
    • Transforms
    • Node Types
      • Editor
      • Element
      • Node
      • NodeEntry
      • Text
    • Location Types
      • Location
      • Path
      • PathRef
      • Point
      • PointEntry
      • PointRef
      • Range
      • RangeRef
      • Span
    • Operation Types
      • Operation
    • Scrubber
  • Libraries
    • Slate React
      • withReact
      • ReactEditor
      • Hooks
      • Slate Component
      • Editable Component
      • Event Handling
    • Slate History
      • withHistory
      • HistoryEditor
      • History
    • Slate Hyperscript
  • General
    • Resources
    • Contributing
    • Changelog
    • FAQ
Powered by GitBook
On this page
  • Instance methods
  • Static methods
  • Transform methods
  1. API
  2. Location Types

PathRef

PreviousPathNextPoint

Last updated 1 month ago

PathRef objects keep a specific path in a document synced over time as new operations are applied to the editor. It is created using the Editor.pathRef method. You can access their property current at any time for the up-to-date Path value. When you no longer need to track this location, call unref() to free the resources. The affinity refers to the direction the PathRef will go when a user inserts content at the current position of the Path.

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

Instance methods

unref() => Path | null

Free the resources used by the PathRef. This should be called when you no longer need to track the path. Returns the final path value before being unrefed, or null if the path was already invalid.

Static methods

Transform methods

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

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

Instance methods
Static methods
Transform methods