Plate Core
API reference for @udecode/plate-core.
API
createPlugins
Creates a new array of plugins by overriding the plugins in the original array.
Parameters
The original array of plugins.
The options to override plugins.
Returns
An array of plugins with overridden components or attributes.
Returns
An object containing the following properties:
A boolean indicating whether the nodeType
mark is active in the current
selection.
The type of the node.
Type or types of the node to clear.
createAtomStore
Creates an atom store from an initial value. Each property of the initial value will have a getter and setter.
Parameters
The initial state of the atom store.
An optional object which can contain a scope, an initial store, and a name.
Returns
An AtomStoreApi
object.
createPlateEditor
Generates a new instance of a PlateEditor
, initialized with a set of plugins and their configurations.
Parameters
Initial editor without withPlate
.
An array of editor plugins.
Components to inject into plugins.
Plugins to override by key.
A flag indicating whether to normalize the initial editor value.
Options for the withPlate
function, excluding plugins
.
Returns
An instance of PlateEditor
with the specified plugins, components, and
settings applied.
createPluginFactory
Generates a factory for creating plugins with a default plugin, which can be overridden.
Parameters
The default plugin. The only required property is key
.
Overrides for the default plugin.
Overrides for nested plugins (in plugin.plugins
) by key.
Returns
A plugin factory based on the default one, with the specified overrides applied.
getPlugin
Retrieves a plugin by plugin key.
Parameters
The editor to extract the plugin from.
The key of the plugin to retrieve.
Returns
Returns the requested plugin. If the plugin does not exist, returns an object with only the key.
getPluginInjectProps
Retrieves the props to be injected by a plugin, identified by its key.
Parameters
The editor to extract the plugin from.
The key of the plugin whose inject props to retrieve.
Returns
Returns the props to be injected by the specified plugin. If the plugin does not exist or does not have inject props, returns an empty object.
getPluginOptions
Retrieves the options of a plugin, identified by its key.
Parameters
The editor to extract the plugin from.
The key of the plugin whose options to retrieve.
Returns
Returns the options of the specified plugin. If the plugin does not exist or does not have options, returns an empty object.
getPluginType
Retrieves the type of a plugin, identified by its key.
Parameters
The editor to extract the plugin from.
The key of the plugin whose type to retrieve.
Returns
Returns the type of the specified plugin. If the plugin does not exist or does not have a type, returns the key.
Hotkeys
An object containing functions to check for various hotkeys. Each function takes a KeyboardEvent
and returns a boolean indicating whether the hotkey was pressed.
Parameters
toggleNodeType
Toggle the type of the selected node. No operation is performed if activeType
equals inactiveType
.
Parameters
The editor.
Options for getting the nodes of the editor.
useElement
Hook to get the element from a node component.
Parameters
- Default:
SCOPE_ELEMENT
.
The plugin key.
Returns
The value of the element as a TElement.
useEditorRef
Get the Slate editor reference.
- Does not re-render on editor change.
- Does not support nested editors.
- Should be used inside
Plate
.
Returns
A PlateEditor
object, which is the Slate editor.
useEditorState
Get the Slate editor reference.
- Re-renders on editor change.
- Does not support nested editors.
- Should be used inside
Plate
.
Returns
A PlateEditor
object, which is the Slate editor.
usePlateEditorRef
Get an editor reference which is never updated.
- Does not re-render on editor change.
- Supports nested editors.
- Should be used inside
Plate
orPlateProvider
.
Parameters
The ID of the plate editor. Useful only when nesting editors.
Returns
A PlateEditor
object, which is the Slate editor.
usePlateEditorState
Get the Slate editor reference. Re-renders on editor change.
- Re-renders on editor change.
- Supports nested editors.
- Should be used inside
Plate
orPlateProvider
.
Parameters
The ID of the plate editor.
Returns
A PlateEditor
object, which is the Slate editor.
usePlateReadOnly
Get the editor's readOnly
state.
Parameters
The ID of the plate editor.
Returns
The readOnly
state of the editor.
usePlateSelection
Get the editor's selection which is updated on each editor change.
Parameters
The ID of the plate editor.
Returns
- The current selection in the editor.
Core plugins
createDeserializeAstPlugin
Enables support for deserializing inserted content from Slate Ast format to Slate format while applying a small bug fix.
createDeserializeHtmlPlugin
Enables support for deserializing inserted content from HTML format to Slate format.
createEditorProtocolPlugin
Reset marks when the selection is at the start of a block and after delete operations.
createEventEditorPlugin
Creates a plugin that dispatches focus and blur events.
createHistoryPlugin
Creates a plugin that enables history support for the editor.
createInlineVoidPlugin
Creates a plugin that merges and registers all the inline types and void types from the plugins and options, using editor.isInline
and editor.isVoid
.
createInsertDataPlugin
Creates a plugin that overrides the default insertData
function in the editor, which is called when data is being pasted or dragged into the editor.
createNodeFactoryPlugin
Creates a plugin that overrides the default blockFactory
and childrenFactory
functions in the editor. These functions are used to generate the default blocks and children for the editor.
createPrevSelectionPlugin
Creates a plugin that keeps track of the previous selection in the editor and the current keyboard event being processed.
createReactPlugin
Creates a plugin that adds withTReact
to the editor, which is a generic typed version of withReact
from 'slate-react' library.
withPlate
An overrider that applies the withInlineVoid
and all plate plugins' withOverrides
.
withTReact
Generic typed version of withReact
from 'slate-react' library.