docs/api/utils.mdx
@platejs/utils contains utility functions for Plate.
useEditorStringuseMarkToolbarButtonStateGenerates the state for a mark toolbar button.
<API name="useMarkToolbarButtonState"> <APIParameters> <APIItem name="nodeType" type="string"> The type of the node to check for active marks. </APIItem> <APIItem name="clear" type="string | string[]" optional> Type or types of the node to clear when the mark is applied. </APIItem> </APIParameters> <APIReturns type="object"> <APIItem name="pressed" type="boolean"> Whether the `nodeType` mark is active in the current selection. </APIItem> <APIItem name="nodeType" type="string"> The type of the node. </APIItem> <APIItem name="clear" type="string | string[]" optional> The type or types to clear when toggling this mark. </APIItem> </APIReturns> </API>useMarkToolbarButtonGenerates the props for a mark toolbar button using the state created by useMarkToolbarButtonState.
useRemoveNodeButtonGenerates props for a button that removes a node from the editor when clicked.
<API name="useRemoveNodeButton"> <APIParameters> <APIItem name="element" type="TElement"> The node element to be removed. </APIItem> </APIParameters> <APIReturns type="object"> <APIItem name="props" type="object"> <APISubList> <APISubListItem parent="props" name="onClick" type="() => void"> Removes the node and focuses the editor. </APISubListItem> </APISubList> </APIItem> </APIReturns> </API>