Plate Utils

API reference for @platejs/utils.

@platejs/utils contains utility functions for Plate.

Hooks

useEditorString

Returnsstring

    The concatenated text content of all text nodes in the editor.

useMarkToolbarButtonState

Generates the state for a mark toolbar button.

Parameters

  • nodeType string

    The type of the node to check for active marks.

  • clear optional string | string[]

    Type or types of the node to clear when the mark is applied.

Returnsobject

Collapse all
  • pressed boolean

    Whether the nodeType mark is active in the current selection.

  • nodeType string

    The type of the node.

  • clear optional string | string[]

    The type or types to clear when toggling this mark.

useMarkToolbarButton

Generates the props for a mark toolbar button using the state created by useMarkToolbarButtonState.

Parameters

Collapse all
  • state ReturnType<typeof useMarkToolbarButtonState>

    The state for the mark toolbar button generated by useMarkToolbarButtonState.

Returnsobject

Collapse all
  • props object

useRemoveNodeButton

Generates props for a button that removes a node from the editor when clicked.

Parameters

Collapse all
  • element TElement

    The node element to be removed.

Returnsobject

Collapse all
  • props object