Location
API reference for locations in Slate.
The Location
interface is a union of the ways to refer to a specific location in a Slate document: paths, points, or ranges. Methods often accept a Location
instead of requiring only a Path
, Point
, or Range
. This eliminates the need for developers to manage converting between the different interfaces in their own code base.
Location
Find the corresponding documentation in the Slate docs.
isAt
Checks if a value implements the At
interface.
Parameters
The value to check.
Returns
Returns true
if the value is either a Location or a Node.
isLocation
Checks if a value implements the Location
interface.
Parameters
The value to check.
Returns
Returns true
if the value is a Path, Point, or Range.
Span
The Span
interface is a low-level way to refer to locations in nodes without using Point
which requires leaf text nodes to be present. It is represented as a tuple of two paths.
isSpan
Checks if a value implements the Span
interface.
Parameters
The value to check.
Returns
Returns true
if the value is a valid Span (tuple of two paths).
Types
TLocation
The base location type that can be either a Path, Point, or Range.
Parameters
A union type that can be:
Location
The concrete location type (same as TLocation but using concrete types).
Parameters
A union type that can be:
Span
A low-level location representation.
Parameters
A tuple containing: