Element nodes behave differently depending on the Plate editor's schema. An element can be:
state.schema.isInline(element)state.schema.isVoid(element)A "block" element can only be siblings with other "block" elements. An "inline" node can be siblings with Text nodes or other "inline" elements.
In a not "void" element, Plate handles the rendering of its children (e.g. in a paragraph where the Text and Inline children are rendered by Plate). In a "void" element, Plate owns the DOM shell and selection anchor while app code renders only the visible content.
Some void elements are effectively stand-ins for text, such as with the
mentions example, where the
mention element renders the character's name. Users might want to format Void
elements like this with bold, or set their font and size, so
state.schema.isMarkableVoid(element) tells Plate whether or not to apply Marks
to the text children of void elements.
Keep the empty text child in the document. Bind a component to the owning plugin and render EditorElement with its children so Plate preserves the editable shell and selection anchor.
Use the Image, Mention, or Horizontal Rule component for a complete example. useElementSelected() subscribes to selection for the rendered element; keep its selection ring in that component.
Marks on a markable void's text child can control its visible style. The schema's isMarkableVoid policy determines whether the editor applies those marks.
Check if an element matches a set of props. Note: This checks custom properties, but it does not ensure that any children are equivalent.
Check if a value implements the 'Ancestor' interface.
Check if a value implements the Element interface.
Check if a value is an array of Element objects.
Check if a value is an object that can be used as partial Element props.
ElementApi.isElementType<T extends Element>(value: unknown, elementVal: string, elementKey: string = 'type'): value is TCheck if a value implements the Element interface and has elementKey with
the selected value. The default key is type.