docs/api/slate/element.mdx
TElement objects are a type of Node in a Plate document that contain other TElement nodes or Text nodes.
interface TElement {
children: Descendant[]
type: string
[key: string]: unknown
}
Elements can have different behaviors depending on the editor's configuration:
Elements can be either "block" or "inline" as defined by plugin node.isInline:
Elements can be either "void" or "non-void" as defined by plugin node.isVoid:
Some void elements can support marks through plugin node.markableVoid. For example, a mention element might need to support bold or italic formatting.
ElementAPIisElementTypeCheck if a value implements the TElement interface and has elementKey matching a specified value. Defaults to checking the 'type' key.
isAncestorCheck if a value implements the Ancestor interface.
isElementCheck if a value implements the TElement interface.
isElementListCheck if a value is an array of TElement objects.
isElementPropsCheck if a set of props is a partial of TElement.
matchesCheck if an element matches a set of properties.
<API name="matches"> <APIParameters> <APIItem name="element" type="TElement"> The element to check. </APIItem> <APIItem name="props" type="Partial<TElement>"> The properties to match against. </APIItem> </APIParameters> <APIReturns type="boolean"> `true` if the element matches all provided properties. </APIReturns> </API>TElementTElement objects are a type of node in a Plate document that contain other element nodes or text nodes. They can be either "blocks" or "inlines" depending on the editor's configuration.
Element is a type alias for TElement.
ElementEntryElement entries represent an Element node and its path.
<API name="ElementEntry"> <APIAttributes> <APIItem name="0" type="Element"> The Element node. </APIItem> <APIItem name="1" type="Path"> The path to the element. </APIItem> </APIAttributes> </API>ElementOrTextOftype ElementOrTextOf<E extends Editor> = ElementOf<E> | TextOf<E>;
The ElementOrTextOf type represents either an element or a text node from a specific editor type.
ElementOrTextIntype ElementOrTextIn<V extends Value> = ElementIn<V> | TextIn<V>;
The ElementOrTextIn type represents either an element or a text node from a specific value type.
ElementOfElementOf is a utility type to get all the element node types from a given root node type.
ElementIntype ElementIn<V extends Value> = ElementOf<V[number]>;
ElementIn is a utility type to get an element type from a Plate Value type.