Docs
Plate Core

Plate Core

API reference for @udecode/plate-core.

API

createPlateEditor

Generates a new instance of a PlateEditor, initialized with a set of plugins and their configurations.

Parameters

Collapse all

    Options for creating the Plate editor.

Returns

    An instance of PlateEditor with the specified plugins and settings applied.

For more details on editor configuration, refer to the Editor Configuration guide.

createPlatePlugin

Creates a new Plate plugin with the given configuration, supporting extension, nested plugin manipulation, and runtime configuration.

Parameters

Collapse all

    The configuration object for the plugin, or a function that returns the configuration. If a function is provided, it will be executed when the plugin is resolved with the editor.

    For details on the PlatePluginConfig type, refer to the PlatePlugin API.

Returns

    A new PlatePlugin<PluginConfig<K, O, A, T>> instance.

createTPlatePlugin

Explicitly typed version of createPlatePlugin.

Parameters

Collapse all

    The configuration object for the plugin, or a function that returns the configuration. This version requires an explicit type parameter C extending AnyPluginConfig.

    For details on the TPlatePluginConfig type, refer to the PlatePlugin API.

Returns

    A new PlatePlugin<C> instance.

toPlatePlugin

Extends a SlatePlugin to create a React PlatePlugin.

Parameters

Collapse all

    The base SlatePlugin to be extended.

    A function or object that provides the extension configuration. If a function, it receives the plugin context and should return a partial PlatePlugin. If an object, it should be a partial PlatePlugin configuration.

Returns

    A new PlatePlugin that combines the base SlatePlugin functionality with React-specific features defined in the extension configuration.

toTPlatePlugin

Explicitly typed version of toPlatePlugin.

Parameters

Collapse all

    The base SlatePlugin to be extended.

    A function or object that provides the extension configuration. This version requires explicit type parameters for both the base plugin configuration (TContext) and the extension configuration (C).

a

Returns

    A new PlatePlugin with precise type control.

useEditorContainerRef

Get the editor container DOM reference.

Parameters

Collapse all

    The ID of the plate editor. Default is using the closest editor id.

Returns

    A React ref object containing the editor container DOM element.

useEditorScrollRef

Get the editor scroll container reference. Returns the scroll ref if it exists, otherwise returns the container ref.

Parameters

Collapse all

    The ID of the plate editor. Default is using the closest editor id.

Returns

    A React ref object containing either the scroll container or the editor container DOM element.

useEditorPlugin

Get editor and plugin context.

Parameters

Collapse all

    The plugin or plugin configuration with a required key.

Returns

    A PlatePluginContext object containing:

useEditorRef

Get the Slate editor reference without re-rendering.

Parameters

Collapse all

    The ID of the plate editor. Useful only when nesting editors. Default is using the closest editor id.

Returns

    A PlateEditor object, which is the Slate editor.

useEditorSelector

Subscribe to a specific property of the editor.

Parameters

Collapse all

    The selector function.

    The dependency list for the selector function.

Returns

    The return value of the selector function.

useEditorState

Get the Slate editor reference with re-rendering.

Parameters

Collapse all

    The ID of the plate editor. Default is using the closest editor id.

Returns

    A PlateEditor object, which is the Slate editor.

useEditorReadOnly

Get the editor's readOnly state.

Parameters

Collapse all

    The ID of the plate editor.

Returns

    The readOnly state of the editor.

useEditorMounted

Get the editor's isMounted state.

Parameters

Collapse all

    The ID of the plate editor.

Returns

    The isMounted state of the editor.

useEditorSelection

Get the editor's selection. Memoized so it does not re-render if the range is the same.

Parameters

Collapse all

    The ID of the plate editor.

Returns

    The current selection in the editor.

useEditorVersion

Get the version of the editor value. That version is incremented on each editor change.

Parameters

Collapse all

    The ID of the plate editor.

Returns

    The current version of the editor value.

useSelectionVersion

Get the version of the editor selection. That version is incremented on each selection change (the range being different).

Parameters

Collapse all

    The ID of the plate editor.

Returns

    The current version of the editor selection.

useSelectionCollapsed

Returns whether the current selection is collapsed (i.e., the selection is a single point).

Returns

    A boolean value indicating if the selection is collapsed.

useSelectionExpanded

Returns whether the current selection is expanded (i.e., the selection has a non-zero range).

Returns

    A boolean value indicating if the selection is expanded.

useSelectionWithinBlock

Returns whether the current selection is within a single block.

Returns

    A boolean value indicating if the selection is within a single block.

useSelectionAcrossBlocks

Returns whether the current selection spans across multiple blocks.

Returns

    A boolean value indicating if the selection spans across multiple blocks.

useSelectionFragment

Returns the fragment of the current selection, optionally unwrapping structural nodes.

Parameters

Collapse all

    Options for getting the selection fragment.

Returns

    An array of TElement representing the fragment of the current selection. Returns an empty array if the selection is not expanded or if no fragment is found.

useSelectionFragmentProp

Returns a prop value derived from the current selection fragment.

Parameters

Collapse all

Returns

    A value derived from the fragment nodes, or undefined if no consistent value is found across the specified nodes.

Core plugins

DebugPlugin

Provides debugging capabilities with configurable log levels and error handling.

See Debugging for more details.

SlateNextPlugin

Extend core apis and improve default functionality.

DOMPlugin & ReactPlugin

Integrates React-specific functionality into the editor.

HistoryPlugin

Enables undo and redo functionality for the editor.

InlineVoidPlugin

Manages inline and void elements in the editor.

ParserPlugin

Handles parsing of content for the editor.

LengthPlugin

Enforces a maximum length for the editor content.

HtmlPlugin

Enables HTML serialization and deserialization.

AstPlugin

Handles Abstract Syntax Tree (AST) operations for the editor.

ParagraphPlugin

Provides paragraph formatting functionality.

EventEditorPlugin

Manages editor events such as focus and blur.

PlateApiPlugin

Provides the core API for Plate editor functionality.