Element

API reference for elements in Slate.

Element objects are a type of node in a Slate document that contain other element nodes or text nodes. They can be either "blocks" or "inlines" depending on the Slate editor's configuration.

Element

Find the corresponding documentation in the Slate docs.

isElementType

Checks if a value implements the TElement interface and has elementKey with selected value.

Parameters

Collapse all

    The value to check.

    The value to match against.

    The key to check. Defaults to 'type'.

Returns

    Returns true if the value is an element with matching type.

isAncestor

Checks if a value implements the 'Ancestor' interface.

Parameters

Collapse all

    The value to check.

Returns

    Returns true if the value is an ancestor node.

isElement

Checks if a value implements the TElement interface.

Parameters

Collapse all

    The value to check.

Returns

    Returns true if the value is an element.

isElementList

Checks if a value is an array of TElement objects.

Parameters

Collapse all

    The value to check.

Returns

    Returns true if the value is an array of elements.

isElementProps

Checks if a set of props is a partial of TElement.

Parameters

Collapse all

    The props to check.

Returns

    Returns true if the props match element properties.

matches

Checks if an element matches set of properties.

Parameters

Collapse all

    The element to check.

    The properties to match against.

Returns

    Returns true if the element matches all properties (excluding children).

Types

TElement

The base element type.

Attributes

Collapse all

    Properties:

    • children: Descendant[] - Array of child nodes
    • type: string - Element type identifier
    • [key: string]: unknown - Additional custom properties

Element

The concrete element type (same as TElement).

ElementOrTextOf

A union type representing either an element or text node of an editor.

Attributes

Collapse all

    Generic type for elements or text nodes from a specific editor type.

ElementOrTextIn

A union type representing either an element or text node in a value.

Attributes

Collapse all

    Generic type for elements or text nodes from a specific value type.

ElementOf

A utility type to get all the element nodes type from a root node.

Attributes

Collapse all

    Generic type that extracts element types from a node type.

ElementIn

A utility type to get element types from a value type.

Attributes

Collapse all

    Generic type that extracts element types from a value type.