Text

API reference for text nodes in Slate.

A Text node contains the actual text content of a Slate document along with any formatting properties. They are always leaf nodes in the document tree as they cannot contain any children.

type TText = {
  text: string
  [key: string]: unknown
}

TextApi

decorations

Parameters

Collapse all

    The text node to get leaves from.

    The array of decorated ranges to apply.

ReturnsTText[]

    An array of text nodes with the decorations applied.

equals

Parameters

Collapse all

    The first text node to compare.

    The second text node to compare.

    Additional comparison options.

OptionsTextEqualsOptions

Collapse all

    If true, the text content is not compared. This is used to check whether sibling text nodes can be merged based only on their formatting properties.

Returnsboolean

    true if the text nodes are equal according to the comparison rules.

isText

Parameters

Collapse all

    The value to check.

Returnsboolean

    true if the value is a valid text node.

isTextList

Parameters

Collapse all

    The value to check.

Returnsboolean

    true if the value is an array of text nodes.

isTextProps

Parameters

Collapse all

    The props to check.

Returnsboolean

    true if the props match a partial text node structure.

matches

Parameters

Collapse all

    The text node to check.

    The properties to match against.

Returnsboolean

    true if the text node matches the properties.

Types

TText

Text is a type alias for TText.

Attributes

Collapse all

    The text content of the node.

    Additional formatting properties that can be added to the text node.

TextEntry

Text entries represent a Text node and its path.

Attributes

Collapse all

    The Text node.

    The path to the text node.

DecoratedRange

A range object that includes decoration information. Used to apply formatting or styling to specific ranges of text within a document.

TextOf<N>

A utility type that extracts all possible text node types from a root node type.

Parameters

Collapse all

    The root node type to extract text types from.

TextIn<V>

A utility type that extracts all text node types from a Value type.

Parameters

Collapse all

    The Value type to extract text types from.

MarksOf<N>

A utility type that extracts all possible mark types from a root node type. Marks are the formatting properties that can be applied to text nodes.

Parameters

Collapse all

    The root node type to extract mark types from.

MarksIn<V>

A utility type that extracts all mark types from a Value type. Similar to MarksOf but works specifically with editor Value types.

Parameters

Collapse all

    The Value type to extract mark types from.

MarkKeysOf<N>

A utility type that extracts all possible mark property keys from a node type.

Parameters

Collapse all

    The node type to extract mark keys from.