UNPKG

@udecode/plate-core

Version:

The core of Plate – a plugin system for slate

892 lines (858 loc) 86.1 kB
export { DefaultElement, DefaultPlaceholder, Editable, RenderPlaceholderProps, Slate, useComposing, useFocused, useReadOnly, useSelected, withReact } from 'slate-react'; import * as React$1 from 'react'; import React__default from 'react'; import * as _udecode_slate from '@udecode/slate'; import { Value, Editor, EditorApi, EditorTransforms, TElement, Path, TText, NodeEntry, DecoratedRange, Descendant, ElementEntry, TRange, ValueOf, TSelection, TNode } from '@udecode/slate'; import { P as PluginConfig, a as SlatePlugin, j as ExtendEditor$1, ag as CorePlugin, A as AnyPluginConfig, q as BaseWithSlateOptions, o as InferPlugins, M as InferApi, V as InferTransforms, W as WithRequiredKey, n as BaseEditor, R as RenderElementProps, e as RenderLeafProps, t as BaseDeserializer, E as EditableProps, u as BaseHtmlDeserializer, v as BaseInjectProps, J as GetInjectNodePropsOptions, K as GetInjectNodePropsReturnType, Z as HandlerReturnType, l as ParserOptions, x as BasePlugin, Y as WithAnyKey, X as NodeComponent, y as BasePluginContext, Q as InferOptions, U as InferSelectors, f as AnySlatePlugin, ae as SlatePluginConfig, c as SlatePluginContext, D as BaseSerializer, F as BaseTransformOptions, ao as RenderElementFn, ap as RenderLeafFn } from '../withSlate-qYKZgnjZ.mjs'; import { UnionToIntersection, AnyObject, Deep2Partial, Nullable, Modify, UnknownObject } from '@udecode/utils'; import { HotkeysOptions, Keys, HotkeysEvent } from '@udecode/react-hotkeys'; import * as zustand_x from 'zustand-x'; import { TCreatedStoreType, TEqualityChecker } from 'zustand-x'; export { useStoreSelect, useStoreState, useStoreValue, useTracked, useTrackedStore } from 'zustand-x'; import * as jotai from 'jotai'; import { Atom } from 'jotai'; export { atom } from 'jotai'; import * as jotai_x from 'jotai-x'; import { JotaiStore } from 'jotai-x'; export { createAtomStore, useStoreAtomState, useStoreAtomValue, useStoreSetAtom } from 'jotai-x'; import 'is-hotkey'; import 'mutative'; declare const SlateReactExtensionPlugin: PlatePlugin<PluginConfig<"slateExtension", {}, { redecorate: () => void; }, { setValue: <V extends _udecode_slate.Value>(value?: V | string) => void; }, {}>>; declare const EventEditorPlugin: PlatePlugin<PluginConfig<"eventEditor", {}, {}, {}, {}>>; type EventEditorState = { /** Last editor id that has been blurred. */ blur: string | null; /** Editor id that is currently being focused. */ focus: string | null; /** Last editor id. */ last: string | null; }; /** Store where the keys are event names and the values are editor ids. */ declare const EventEditorStore: zustand_x.TStateApi<EventEditorState, [["zustand/mutative-x", never]], {}, {}>; declare const useEventEditorValue: { <K extends keyof EventEditorState>(key: K): EventEditorState[K]; <K extends never>(key: K, ...args: Parameters<{}[K]>): ReturnType<{}[K]>; (key: "state"): EventEditorState; <K extends keyof EventEditorState>(key: K, equalityFn?: zustand_x.TEqualityChecker<EventEditorState[K]> | undefined): EventEditorState[K]; <K extends never>(key: K, ...args: [...Parameters<{}[K]>, (zustand_x.TEqualityChecker<ReturnType<{}[K]>> | undefined)?]): ReturnType<{}[K]>; }; declare const getEventPlateId: (id?: string) => string; declare const FOCUS_EDITOR_EVENT = "focus-editor-event"; declare const BLUR_EDITOR_EVENT = "blur-editor-event"; declare const useFocusEditorEvents: ({ editorRef, onEditorBlur, onEditorFocus, }: { editorRef: PlateEditor | null; onEditorBlur?: () => void; onEditorFocus?: () => void; }) => void; declare const ParagraphPlugin: PlatePlugin<PluginConfig<"p", {}, {}, {}, {}>>; /** @see {@link withReact} */ declare const ReactPlugin: SlatePlugin<PluginConfig<"dom", {}, {}, { reset: (options: _udecode_slate.ResetOptions | undefined) => void; }, {}>>; declare const withPlateReact: ExtendEditor$1; type PlateCorePlugin = CorePlugin | typeof SlateReactExtensionPlugin; type WithPlateOptions<V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin> = BaseWithSlateOptions<P> & Pick<Partial<AnyPlatePlugin>, 'api' | 'decorate' | 'extendEditor' | 'handlers' | 'inject' | 'normalizeInitialValue' | 'options' | 'override' | 'priority' | 'render' | 'shortcuts' | 'transforms' | 'useHooks'> & { value?: ((editor: PlateEditor) => V) | V | string; rootPlugin?: (plugin: AnyPlatePlugin) => AnyPlatePlugin; }; /** * Applies Plate-specific enhancements to an editor instance with ReactPlugin. * * @see {@link createPlateEditor} for a higher-level React editor creation function. * @see {@link usePlateEditor} for a memoized version in React components. * @see {@link withSlate} for the non-React version of editor enhancement */ declare const withPlate: <V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin>(e: Editor, { plugins, ...options }?: WithPlateOptions<V, P>) => TPlateEditor<V, InferPlugins<P[]>>; type CreatePlateEditorOptions<V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin> = WithPlateOptions<V, P> & { /** * Initial editor to be extended with `withPlate`. * * @default createEditor() */ editor?: Editor; }; /** * Creates a fully configured Plate editor with optional customizations. * * @remarks * This function creates a Plate editor with the following enhancements and * configurations: * * 1. Editor Initialization: * * - Assigns a unique ID to the editor if not already present. * - Extend editor state properties. * * 2. Plugin System: * * - Integrates core plugins and user-provided plugins. * - Creates a root plugin that encapsulates all other plugins. * - Resolves plugins into editor.plugins, editor.pluginList. * * 3. Content Initialization: * * - Sets initial editor content if provided. * - Ensures the editor always has content by using a default factory if empty. * * 4. Selection Handling: * * - Applies initial selection if provided. * - Supports auto-selection at start or end of the document. * * 5. Normalization: * * - Performs initial value normalization. * - Optionally applies full editor normalization. * * 6. Extensibility: * * - Allows for deep customization through plugins and overrides. * - Supports custom editor types and configurations. * * The resulting editor is a fully-initialized Plate instance, ready for use * with Plate components and APIs, with all core functionalities and custom * plugins applied. * @example * const editor = createPlateEditor({ * plugins: [ParagraphPlugin, BoldPlugin], * override: { * components: { * [ParagraphPlugin.key]: CustomParagraphComponent, * }, * }, * }); * * @template V - The value type. * @template P - The plugins type. * @see {@link createSlateEditor} for a non-React version of editor creation. * * @see {@link usePlateEditor} for a memoized version, suitable for use in React components. * * @see {@link withPlate} for the underlying function that applies Plate enhancements to an editor. * * @see {@link withSlate} for a non-React version of editor enhancement. */ declare const createPlateEditor: <V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin>({ editor, ...options }?: CreatePlateEditorOptions<V, P>) => TPlateEditor<V, InferPlugins<P[]>>; type PlateEditor = { api: EditorApi & UnionToIntersection<InferApi<PlateCorePlugin>>; pluginList: AnyEditorPlatePlugin[]; plugins: Record<string, AnyEditorPlatePlugin>; shortcuts: Shortcuts; tf: EditorTransforms & UnionToIntersection<InferTransforms<PlateCorePlugin>>; transforms: EditorTransforms & UnionToIntersection<InferTransforms<PlateCorePlugin>>; getApi: <C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => PlateEditor['api'] & InferApi<C>; getPlugin: <C extends AnyPluginConfig = PluginConfig>(plugin: WithRequiredKey<C>) => C extends { node: any; } ? C : EditorPlatePlugin<C>; getTransforms: <C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => PlateEditor['tf'] & InferTransforms<C>; uid?: string; } & BaseEditor; type TPlateEditor<V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin> = PlateEditor & { api: EditorApi<V> & UnionToIntersection<InferApi<P | PlateCorePlugin>>; children: V; pluginList: P[]; plugins: { [K in P['key']]: Extract<P, { key: K; }>; }; tf: EditorTransforms<V> & UnionToIntersection<InferTransforms<P | PlateCorePlugin>>; transforms: EditorTransforms<V> & UnionToIntersection<InferTransforms<P | PlateCorePlugin>>; getApi: <C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => TPlateEditor<V>['api'] & InferApi<C>; getTransforms: <C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => TPlateEditor<V>['tf'] & InferTransforms<C>; }; /** Node props passed by Plate */ type PlateRenderNodeProps<C extends AnyPluginConfig = PluginConfig> = PlatePluginContext<C> & { className?: string; /** @see {@link NodeProps} */ nodeProps?: AnyObject; }; /** Element props passed by Plate */ type PlateRenderElementProps<N extends TElement = TElement, C extends AnyPluginConfig = PluginConfig> = PlateRenderNodeProps<C> & RenderElementProps<N> & { path: Path; }; /** Leaf props passed by Plate */ type PlateRenderLeafProps<N extends TText = TText, C extends AnyPluginConfig = PluginConfig> = PlateRenderNodeProps<C> & RenderLeafProps<N>; type AnyEditorPlatePlugin = EditorPlatePlugin<AnyPluginConfig>; type AnyPlatePlugin = PlatePlugin<AnyPluginConfig>; /** * Property used by Plate to decorate editor ranges. If the function returns * undefined then no ranges are modified. If the function returns an array the * returned ranges are merged with the ranges called by other plugins. */ type Decorate<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C> & { entry: NodeEntry; }) => DecoratedRange[] | undefined; type Deserializer<C extends AnyPluginConfig = PluginConfig> = BaseDeserializer & { parse?: (options: PlatePluginContext<C> & { element: any; }) => Partial<Descendant> | undefined | void; query?: (options: PlatePluginContext<C> & { element: any; }) => boolean; }; type EditableSiblingComponent = (editableProps: EditableProps) => React__default.ReactElement<any> | null; type EditorPlatePlugin<C extends AnyPluginConfig = PluginConfig> = Omit<PlatePlugin<C>, keyof PlatePluginMethods | 'override' | 'plugins'>; /** Plate plugin overriding the `editor` methods. Naming convention is `with*`. */ type ExtendEditor<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C>) => PlateEditor; type ExtendEditorApi<C extends AnyPluginConfig = PluginConfig, EA = {}> = (ctx: PlatePluginContext<C>) => EA & Deep2Partial<EditorApi> & { [K in keyof InferApi<C>]?: InferApi<C>[K] extends (...args: any[]) => any ? (...args: Parameters<InferApi<C>[K]>) => ReturnType<InferApi<C>[K]> : InferApi<C>[K] extends Record<string, (...args: any[]) => any> ? { [N in keyof InferApi<C>[K]]?: (...args: Parameters<InferApi<C>[K][N]>) => ReturnType<InferApi<C>[K][N]>; } : never; }; type ExtendEditorTransforms<C extends AnyPluginConfig = PluginConfig, ET = {}> = (ctx: PlatePluginContext<C>) => ET & Deep2Partial<EditorTransforms> & { [K in keyof InferTransforms<C>]?: InferTransforms<C>[K] extends (...args: any[]) => any ? (...args: Parameters<InferTransforms<C>[K]>) => ReturnType<InferTransforms<C>[K]> : InferTransforms<C>[K] extends Record<string, (...args: any[]) => any> ? { [N in keyof InferTransforms<C>[K]]?: (...args: Parameters<InferTransforms<C>[K][N]>) => ReturnType<InferTransforms<C>[K][N]>; } : never; }; type HtmlDeserializer<C extends AnyPluginConfig = PluginConfig> = BaseHtmlDeserializer & { parse?: (options: PlatePluginContext<C> & { element: HTMLElement; node: AnyObject; }) => Partial<Descendant> | undefined | void; query?: (options: PlatePluginContext<C> & { element: HTMLElement; }) => boolean; }; type HtmlReactSerializer<C extends AnyPluginConfig = PluginConfig> = { parse?: React__default.FC<PlateRenderElementProps<TElement, C> & PlateRenderLeafProps<TText, C>>; query?: (options: PlateRenderElementProps) => boolean; }; type HtmlSerializer<C extends AnyPluginConfig = PluginConfig> = { parse?: (options: PlatePluginContext<C> & { node: Descendant; }) => string; query?: (options: PlatePluginContext<C> & { node: Descendant; }) => boolean; }; type InferConfig<P> = P extends PlatePlugin<infer C> | SlatePlugin<infer C> ? C : never; /** Properties used by Plate to inject props into any {@link NodeComponent}. */ type InjectNodeProps<C extends AnyPluginConfig = PluginConfig> = BaseInjectProps & { /** Whether to inject the props. If true, overrides all other checks. */ query?: (options: NonNullable<NonNullable<InjectNodeProps>> & PlatePluginContext<C> & { nodeProps: GetInjectNodePropsOptions; }) => boolean; /** * Transform the className. * * @default clsx(className, classNames[value]) */ transformClassName?: (options: TransformOptions<C>) => any; /** * Transform the node value for the style or className. * * @default nodeValue */ transformNodeValue?: (options: TransformOptions<C>) => any; /** Transform the injected props. */ transformProps?: (options: TransformOptions<C> & { props: GetInjectNodePropsReturnType; }) => AnyObject | undefined; /** * Transform the style. * * @default { ...style, [styleKey]: value } */ transformStyle?: (options: TransformOptions<C>) => CSSStyleDeclaration; }; /** * Property used by Plate to override node `component` props. If function, its * returning value will be shallow merged to the old props, with the old props * as parameter. If object, its value will be shallow merged to the old props. */ type NodeProps<C extends AnyPluginConfig = PluginConfig> = ((props: PlateRenderElementProps<TElement, C> & PlateRenderLeafProps<TText, C>) => AnyObject | undefined) | AnyObject; /** @deprecated Use {@link RenderNodeWrapper} instead. */ type NodeWrapperComponent<C extends AnyPluginConfig = PluginConfig> = (props: NodeWrapperComponentProps<C>) => NodeWrapperComponentReturnType<C>; /** @deprecated Use {@link RenderNodeWrapperProps} instead. */ interface NodeWrapperComponentProps<C extends AnyPluginConfig = PluginConfig> extends PlateRenderElementProps<TElement, C> { key: string; } /** @deprecated Use {@link RenderNodeWrapperFunction} instead. */ type NodeWrapperComponentReturnType<C extends AnyPluginConfig = PluginConfig> = React__default.FC<PlateRenderElementProps<TElement, C>> | undefined; type NormalizeInitialValue<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C> & { value: Value; }) => void; /** * Function called whenever a change occurs in the editor. Return `false` to * prevent calling the next plugin handler. * * @see {@link SlatePropsOnChange} */ type OnChange<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C> & { value: Value; }) => HandlerReturnType; type OverrideEditor<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C>) => { api?: Deep2Partial<EditorApi> & { [K in keyof InferApi<C>]?: InferApi<C>[K] extends (...args: any[]) => any ? (...args: Parameters<InferApi<C>[K]>) => ReturnType<InferApi<C>[K]> : InferApi<C>[K] extends Record<string, (...args: any[]) => any> ? { [N in keyof InferApi<C>[K]]?: (...args: Parameters<InferApi<C>[K][N]>) => ReturnType<InferApi<C>[K][N]>; } : never; }; transforms?: Deep2Partial<EditorTransforms> & { [K in keyof InferTransforms<C>]?: InferTransforms<C>[K] extends (...args: any[]) => any ? (...args: Parameters<InferTransforms<C>[K]>) => ReturnType<InferTransforms<C>[K]> : InferTransforms<C>[K] extends Record<string, (...args: any[]) => any> ? { [N in keyof InferTransforms<C>[K]]?: (...args: Parameters<InferTransforms<C>[K][N]>) => ReturnType<InferTransforms<C>[K][N]>; } : never; }; }; /** * Used by parser plugins like html to deserialize inserted data to a slate * fragment. The fragment will be inserted to the editor if not empty. */ type Parser<C extends AnyPluginConfig = PluginConfig> = { /** Format to get data. Example data types are text/plain and text/uri-list. */ format?: string[] | string; mimeTypes?: string[]; /** Deserialize data to fragment */ deserialize?: (options: ParserOptions & PlatePluginContext<C>) => Descendant[] | undefined; /** * Function called on `editor.tf.insertData` just before * `editor.tf.insertFragment`. Default: if the block above the selection is * empty and the first fragment node type is not inline, set the selected node * type to the first fragment node type. * * @returns If true, the next handlers will be skipped. */ preInsert?: (options: ParserOptions & PlatePluginContext<C> & { fragment: Descendant[]; }) => HandlerReturnType; /** Query to skip this plugin. */ query?: (options: ParserOptions & PlatePluginContext<C>) => boolean; /** Transform the inserted data. */ transformData?: (options: ParserOptions & PlatePluginContext<C>) => string; /** Transform the fragment to insert. */ transformFragment?: (options: ParserOptions & PlatePluginContext<C> & { fragment: Descendant[]; }) => Descendant[]; }; /** The `PlatePlugin` interface is a React interface for all plugins. */ type PlatePlugin<C extends AnyPluginConfig = PluginConfig> = BasePlugin<C> & Nullable<{ /** @see {@link Decorate} */ decorate?: Decorate<WithAnyKey<C>>; /** @see {@link ExtendEditor} */ extendEditor?: ExtendEditor<WithAnyKey<C>>; /** Normalize initial value before passing it into the editor. */ normalizeInitialValue?: NormalizeInitialValue<WithAnyKey<C>>; /** @see {@link UseHooks} */ useHooks?: UseHooks<WithAnyKey<C>>; }> & PlatePluginMethods<C> & { /** * Handlers called whenever the corresponding event occurs in the editor. * Event handlers can return a boolean flag to specify whether the event * can be treated as being handled. If it returns `true`, the next * handlers will not be called. */ handlers: Nullable<DOMHandlers<WithAnyKey<C>> & { /** @see {@link OnChange} */ onChange?: OnChange<WithAnyKey<C>>; }>; /** Plugin injection. */ inject: Nullable<{ nodeProps?: InjectNodeProps<WithAnyKey<C>>; /** * Property that can be used by a plugin to allow other plugins to * inject code. For example, if multiple plugins have defined * `inject.editor.tf.insertData.transformData` for `key=HtmlPlugin.key`, * `insertData` plugin will call all of these `transformData` for * `HtmlPlugin.key` plugin. Differs from `override.plugins` as this is * not overriding any plugin. */ plugins?: Record<string, Partial<EditorPlatePlugin<AnyPluginConfig>>>; /** * A function that returns a plugin config to be injected into other * plugins `inject.plugins` specified by targetPlugins. */ targetPluginToInject?: (ctx: PlatePluginContext<C> & { targetPlugin: string; }) => Partial<PlatePlugin<AnyPluginConfig>>; }>; node: { /** @see {@link NodeProps} */ props?: NodeProps<WithAnyKey<C>>; }; override: { /** Replace plugin {@link NodeComponent} by key. */ components?: Record<string, NodeComponent>; /** Extend {@link PlatePlugin} by key. */ plugins?: Record<string, Partial<EditorPlatePlugin<AnyPluginConfig>>>; }; /** @see {@link Parser} */ parser: Nullable<Parser<WithAnyKey<C>>>; parsers: (Record<string, { /** @see {@link Deserializer} */ deserializer?: Deserializer<WithAnyKey<C>>; /** @see {@link Serializer} */ serializer?: Serializer<WithAnyKey<C>>; }> & { html?: never; htmlReact?: never; }) | { html?: Nullable<{ /** @see {@link HtmlDeserializer} */ deserializer?: HtmlDeserializer<WithAnyKey<C>>; /** @see {@link HtmlSerializer} */ serializer?: HtmlSerializer<WithAnyKey<C>>; }>; htmlReact?: Nullable<{ /** Function to deserialize HTML to Slate nodes using React. */ serializer?: HtmlReactSerializer<WithAnyKey<C>>; }>; }; render: Nullable<{ /** * When other plugins' `node` components are rendered, this function can * return an optional wrapper function that turns a `node`'s props to a * wrapper React node as its parent. Useful for wrapping or decorating * nodes with additional UI elements. * * NOTE: The function can run React hooks. NOTE: Do not run React hooks * in the wrapper function. It is not equivalent to a React component. */ aboveNodes?: RenderNodeWrapper<WithAnyKey<C>>; /** * Renders a component after the `Editable` component. This is the last * render position within the editor structure. */ afterEditable?: EditableSiblingComponent; /** Renders a component before the `Editable` component. */ beforeEditable?: EditableSiblingComponent; /** * When other plugins' `node` components are rendered, this function can * return an optional wrapper function that turns a `node`'s props to a * wrapper React node. The wrapper node is the `node`'s child and its * original children's parent. Useful for wrapping or decorating nodes * with additional UI elements. * * NOTE: The function can run React hooks. NOTE: Do not run React hooks * in the wrapper function. It is not equivalent to a React component. */ belowNodes?: RenderNodeWrapper<WithAnyKey<C>>; /** @see {@link NodeComponent} */ node?: NodeComponent; /** * Function to render content below the root element but above its * children. Similar to belowNodes but renders directly in the element * rather than wrapping. Multiple plugins can provide this, and all * their content will be rendered in sequence. * * NOTE: This is implemented in PlateElement (@udecode/plate-utils), not * in plate-core. */ belowRootNodes?: (props: PlateRenderElementProps<TElement, C>) => React__default.ReactNode; }>; /** @see {@link Shortcuts} */ shortcuts: Shortcuts; useOptionsStore: TCreatedStoreType<C['options'], [ ['zustand/mutative-x', never] ]>; }; type PlatePluginConfig$2<K extends string = any, O = {}, A = {}, T = {}, S = {}, EO = {}, EA = {}, ET = {}, ES = {}> = Partial<Omit<PlatePlugin<PluginConfig<K, Partial<O>, A, T, S>>, keyof PlatePluginMethods | 'api' | 'node' | 'optionsStore' | 'transforms' | 'useOptionsStore'> & { api: EA; node: Partial<PlatePlugin<PluginConfig<K, O, A, T, S>>['node']>; options: EO; selectors: ES; transforms: ET; }>; type PlatePluginContext<C extends AnyPluginConfig = PluginConfig, E extends PlateEditor = PlateEditor> = BasePluginContext<C> & { editor: E; plugin: EditorPlatePlugin<C>; }; type PlatePluginMethods<C extends AnyPluginConfig = PluginConfig> = { __apiExtensions: ((ctx: PlatePluginContext<AnyPluginConfig>) => any)[]; __configuration: ((ctx: PlatePluginContext<AnyPluginConfig>) => any) | null; __extensions: ((ctx: PlatePluginContext<AnyPluginConfig>) => any)[]; __selectorExtensions: ((ctx: PlatePluginContext<AnyPluginConfig>) => any)[]; clone: () => PlatePlugin<C>; configure: (config: ((ctx: PlatePluginContext<C>) => PlatePluginConfig$2<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, InferSelectors<C>>) | PlatePluginConfig$2<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, InferSelectors<C>>) => PlatePlugin<C>; configurePlugin: <P extends AnyPlatePlugin | AnySlatePlugin>(plugin: Partial<P>, config: (P extends AnyPlatePlugin ? PlatePluginConfig$2<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>> : SlatePluginConfig<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>>) | ((ctx: P extends AnyPlatePlugin ? PlatePluginContext<P> : SlatePluginContext<P>) => P extends AnyPlatePlugin ? PlatePluginConfig$2<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>> : SlatePluginConfig<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>>)) => PlatePlugin<C>; extend: <EO = {}, EA = {}, ET = {}, ES = {}>(extendConfig: ((ctx: PlatePluginContext<C>) => PlatePluginConfig$2<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, InferSelectors<C>, EO, EA, ET, ES>) | PlatePluginConfig$2<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, InferSelectors<C>, EO, EA, ET, ES>) => PlatePlugin<PluginConfig<C['key'], EO & InferOptions<C>, EA & InferApi<C>, ET & InferTransforms<C>, InferSelectors<C>>>; extendApi: <EA extends Record<string, (...args: any[]) => any> = Record<string, never>>(extension: (ctx: PlatePluginContext<C>) => EA) => PlatePlugin<PluginConfig<C['key'], InferOptions<C>, InferApi<C> & Record<C['key'], EA>, InferTransforms<C>, InferSelectors<C>>>; /** * Extends the plugin's API with new methods or nested objects. * * This method allows you to add new functionality to the plugin's API or * extend existing ones. You can add top-level methods, nested objects with * methods, or extend existing nested objects. The types of existing methods * and nested objects are preserved, while new ones are inferred. * * @remarks * - New methods can be added at the top level or within nested objects. * - Existing methods can be overridden, but their parameter and return types * must match the original. * - When extending nested objects, you don't need to specify all existing * properties; they will be preserved. * - Only one level of nesting is supported for API objects. * * @example * ```typescript * const extendedPlugin = basePlugin.extendEditorApi(({ plugin }) => ({ * newMethod: (param: string) => param.length, * existingMethod: (n) => n * 2, // Must match original signature * nested: { * newNestedMethod: () => 'new nested method', * }, * })); * ```; * * @template EA - The type of the extended API, inferred from the returned * object. * @param extendedApi - A function that returns an object with the new or * extended API methods. * @returns A new instance of the plugin with the extended API. */ extendEditorApi: <EA extends Record<string, ((...args: any[]) => any) | Record<string, (...args: any[]) => any>> = Record<string, never>>(extension: ExtendEditorApi<C, EA>) => PlatePlugin<PluginConfig<C['key'], InferOptions<C>, { [K in keyof (EA & InferApi<C>)]: (EA & InferApi<C>)[K] extends (...args: any[]) => any ? (EA & InferApi<C>)[K] : { [N in keyof (EA & InferApi<C>)[K]]: (EA & InferApi<C>)[K][N]; }; }, InferTransforms<C>, InferSelectors<C>>>; extendEditorTransforms: <ET extends Record<string, ((...args: any[]) => any) | Record<string, (...args: any[]) => any>> = Record<string, never>>(extension: ExtendEditorTransforms<C, ET>) => PlatePlugin<PluginConfig<C['key'], InferOptions<C>, InferApi<C>, { [K in keyof (ET & InferTransforms<C>)]: (ET & InferTransforms<C>)[K] extends (...args: any[]) => any ? (ET & InferTransforms<C>)[K] : { [N in keyof (ET & InferTransforms<C>)[K]]: (ET & InferTransforms<C>)[K][N]; }; }, InferSelectors<C>>>; extendPlugin: <P extends AnyPlatePlugin | AnySlatePlugin, EO = {}, EA = {}, ET = {}>(plugin: Partial<P>, extendConfig: (P extends AnyPlatePlugin ? PlatePluginConfig$2<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>, EO, EA, ET> : SlatePluginConfig<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>, EO, EA, ET>) | ((ctx: P extends AnyPlatePlugin ? PlatePluginContext<P> : SlatePluginContext<P>) => P extends AnyPlatePlugin ? PlatePluginConfig$2<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>, EO, EA, ET> : SlatePluginConfig<any, InferOptions<P>, InferApi<P>, InferTransforms<P>, InferSelectors<P>, EO, EA, ET>)) => PlatePlugin<C>; extendSelectors: <ES extends Record<string, (...args: any[]) => any> = Record<string, never>>(extension: (ctx: PlatePluginContext<C>) => ES) => PlatePlugin<PluginConfig<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, ES & InferSelectors<C>>>; extendTransforms: <ET extends Record<string, (...args: any[]) => any> = Record<string, never>>(extension: (ctx: PlatePluginContext<C>) => ET) => PlatePlugin<PluginConfig<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C> & Record<C['key'], ET>, InferSelectors<C>>>; overrideEditor: (override: OverrideEditor<C>) => PlatePlugin<C>; /** * Set {@link NodeComponent} for the plugin. * * @param component {@link NodeComponent}. * @returns A new instance of the plugin with the updated * {@link NodeComponent}. */ withComponent: (component: NodeComponent) => PlatePlugin<C>; __resolved?: boolean; }; type PlatePlugins = AnyPlatePlugin[]; type RenderNodeWrapper<C extends AnyPluginConfig = PluginConfig> = (props: RenderNodeWrapperProps<C>) => RenderNodeWrapperFunction; type RenderNodeWrapperFunction = ((elementProps: PlateRenderElementProps) => React__default.ReactNode) | undefined; interface RenderNodeWrapperProps<C extends AnyPluginConfig = PluginConfig> extends PlateRenderElementProps<TElement, C> { key: string; } type Serializer<C extends AnyPluginConfig = PluginConfig> = BaseSerializer & { parser?: (options: PlatePluginContext<C> & { node: Descendant; }) => any; query?: (options: PlatePluginContext<C> & { node: Descendant; }) => boolean; }; type Shortcut = HotkeysOptions & { keys?: Keys; priority?: number; handler?: (ctx: { editor: PlateEditor; event: KeyboardEvent; eventDetails: HotkeysEvent; }) => void; }; type Shortcuts = Record<string, Shortcut | null>; type TransformOptions<C extends AnyPluginConfig = PluginConfig> = BaseTransformOptions & PlatePluginContext<C>; /** Hook called when the editor is initialized. */ type UseHooks<C extends AnyPluginConfig = PluginConfig> = (ctx: PlatePluginContext<C>) => void; type DOMHandler<C extends AnyPluginConfig = PluginConfig, EV = {}> = (ctx: PlatePluginContext<C> & { event: EV; }) => HandlerReturnType; interface DOMHandlers<C extends AnyPluginConfig = PluginConfig> { onAbort?: DOMHandler<C, React__default.SyntheticEvent>; onAbortCapture?: DOMHandler<C, React__default.SyntheticEvent>; onAnimationEnd?: DOMHandler<C, React__default.AnimationEvent>; onAnimationEndCapture?: DOMHandler<C, React__default.AnimationEvent>; onAnimationIteration?: DOMHandler<C, React__default.AnimationEvent>; onAnimationIterationCapture?: DOMHandler<C, React__default.AnimationEvent>; onAnimationStart?: DOMHandler<C, React__default.AnimationEvent>; onAnimationStartCapture?: DOMHandler<C, React__default.AnimationEvent>; onAuxClick?: DOMHandler<C, React__default.MouseEvent>; onAuxClickCapture?: DOMHandler<C, React__default.MouseEvent>; onBeforeInput?: DOMHandler<C, React__default.FormEvent>; onBeforeInputCapture?: DOMHandler<C, React__default.FormEvent>; onBlur?: DOMHandler<C, React__default.FocusEvent>; onBlurCapture?: DOMHandler<C, React__default.FocusEvent>; onCanPlay?: DOMHandler<C, React__default.SyntheticEvent>; onCanPlayCapture?: DOMHandler<C, React__default.SyntheticEvent>; onCanPlayThrough?: DOMHandler<C, React__default.SyntheticEvent>; onCanPlayThroughCapture?: DOMHandler<C, React__default.SyntheticEvent>; onClick?: DOMHandler<C, React__default.MouseEvent>; onClickCapture?: DOMHandler<C, React__default.MouseEvent>; onCompositionEnd?: DOMHandler<C, React__default.CompositionEvent>; onCompositionEndCapture?: DOMHandler<C, React__default.CompositionEvent>; onCompositionStart?: DOMHandler<C, React__default.CompositionEvent>; onCompositionStartCapture?: DOMHandler<C, React__default.CompositionEvent>; onCompositionUpdate?: DOMHandler<C, React__default.CompositionEvent>; onCompositionUpdateCapture?: DOMHandler<C, React__default.CompositionEvent>; onContextMenu?: DOMHandler<C, React__default.MouseEvent>; onContextMenuCapture?: DOMHandler<C, React__default.MouseEvent>; onCopy?: DOMHandler<C, React__default.ClipboardEvent>; onCopyCapture?: DOMHandler<C, React__default.ClipboardEvent>; onCut?: DOMHandler<C, React__default.ClipboardEvent>; onCutCapture?: DOMHandler<C, React__default.ClipboardEvent>; onDOMBeforeInput?: DOMHandler<C, Event>; onDoubleClick?: DOMHandler<C, React__default.MouseEvent>; onDoubleClickCapture?: DOMHandler<C, React__default.MouseEvent>; onDrag?: DOMHandler<C, React__default.DragEvent>; onDragCapture?: DOMHandler<C, React__default.DragEvent>; onDragEnd?: DOMHandler<C, React__default.DragEvent>; onDragEndCapture?: DOMHandler<C, React__default.DragEvent>; onDragEnter?: DOMHandler<C, React__default.DragEvent>; onDragEnterCapture?: DOMHandler<C, React__default.DragEvent>; onDragExit?: DOMHandler<C, React__default.DragEvent>; onDragExitCapture?: DOMHandler<C, React__default.DragEvent>; onDragLeave?: DOMHandler<C, React__default.DragEvent>; onDragLeaveCapture?: DOMHandler<C, React__default.DragEvent>; onDragOver?: DOMHandler<C, React__default.DragEvent>; onDragOverCapture?: DOMHandler<C, React__default.DragEvent>; onDragStart?: DOMHandler<C, React__default.DragEvent>; onDragStartCapture?: DOMHandler<C, React__default.DragEvent>; onDrop?: DOMHandler<C, React__default.DragEvent>; onDropCapture?: DOMHandler<C, React__default.DragEvent>; onDurationChange?: DOMHandler<C, React__default.SyntheticEvent>; onDurationChangeCapture?: DOMHandler<C, React__default.SyntheticEvent>; onEmptied?: DOMHandler<C, React__default.SyntheticEvent>; onEmptiedCapture?: DOMHandler<C, React__default.SyntheticEvent>; onEncrypted?: DOMHandler<C, React__default.SyntheticEvent>; onEncryptedCapture?: DOMHandler<C, React__default.SyntheticEvent>; onEnded?: DOMHandler<C, React__default.SyntheticEvent>; onEndedCapture?: DOMHandler<C, React__default.SyntheticEvent>; onFocus?: DOMHandler<C, React__default.FocusEvent>; onFocusCapture?: DOMHandler<C, React__default.FocusEvent>; onGotPointerCapture?: DOMHandler<C, React__default.PointerEvent>; onGotPointerCaptureCapture?: DOMHandler<C, React__default.PointerEvent>; onInput?: DOMHandler<C, React__default.FormEvent>; onInputCapture?: DOMHandler<C, React__default.FormEvent>; onInvalid?: DOMHandler<C, React__default.FormEvent>; onInvalidCapture?: DOMHandler<C, React__default.FormEvent>; onKeyDown?: DOMHandler<C, React__default.KeyboardEvent>; onKeyDownCapture?: DOMHandler<C, React__default.KeyboardEvent>; onKeyPress?: DOMHandler<C, React__default.KeyboardEvent>; onKeyPressCapture?: DOMHandler<C, React__default.KeyboardEvent>; onKeyUp?: DOMHandler<C, React__default.KeyboardEvent>; onKeyUpCapture?: DOMHandler<C, React__default.KeyboardEvent>; onLoad?: DOMHandler<C, React__default.SyntheticEvent>; onLoadCapture?: DOMHandler<C, React__default.SyntheticEvent>; onLoadedData?: DOMHandler<C, React__default.SyntheticEvent>; onLoadedDataCapture?: DOMHandler<C, React__default.SyntheticEvent>; onLoadedMetadata?: DOMHandler<C, React__default.SyntheticEvent>; onLoadedMetadataCapture?: DOMHandler<C, React__default.SyntheticEvent>; onLoadStart?: DOMHandler<C, React__default.SyntheticEvent>; onLoadStartCapture?: DOMHandler<C, React__default.SyntheticEvent>; onLostPointerCapture?: DOMHandler<C, React__default.PointerEvent>; onLostPointerCaptureCapture?: DOMHandler<C, React__default.PointerEvent>; onMouseDown?: DOMHandler<C, React__default.MouseEvent>; onMouseDownCapture?: DOMHandler<C, React__default.MouseEvent>; onMouseEnter?: DOMHandler<C, React__default.MouseEvent>; onMouseLeave?: DOMHandler<C, React__default.MouseEvent>; onMouseMove?: DOMHandler<C, React__default.MouseEvent>; onMouseMoveCapture?: DOMHandler<C, React__default.MouseEvent>; onMouseOut?: DOMHandler<C, React__default.MouseEvent>; onMouseOutCapture?: DOMHandler<C, React__default.MouseEvent>; onMouseOver?: DOMHandler<C, React__default.MouseEvent>; onMouseOverCapture?: DOMHandler<C, React__default.MouseEvent>; onMouseUp?: DOMHandler<C, React__default.MouseEvent>; onMouseUpCapture?: DOMHandler<C, React__default.MouseEvent>; onPaste?: DOMHandler<C, React__default.ClipboardEvent>; onPasteCapture?: DOMHandler<C, React__default.ClipboardEvent>; onPause?: DOMHandler<C, React__default.SyntheticEvent>; onPauseCapture?: DOMHandler<C, React__default.SyntheticEvent>; onPlay?: DOMHandler<C, React__default.SyntheticEvent>; onPlayCapture?: DOMHandler<C, React__default.SyntheticEvent>; onPlaying?: DOMHandler<C, React__default.SyntheticEvent>; onPlayingCapture?: DOMHandler<C, React__default.SyntheticEvent>; onPointerCancel?: DOMHandler<C, React__default.PointerEvent>; onPointerCancelCapture?: DOMHandler<C, React__default.PointerEvent>; onPointerDown?: DOMHandler<C, React__default.PointerEvent>; onPointerDownCapture?: DOMHandler<C, React__default.PointerEvent>; onPointerEnter?: DOMHandler<C, React__default.PointerEvent>; onPointerLeave?: DOMHandler<C, React__default.PointerEvent>; onPointerMove?: DOMHandler<C, React__default.PointerEvent>; onPointerMoveCapture?: DOMHandler<C, React__default.PointerEvent>; onPointerOut?: DOMHandler<C, React__default.PointerEvent>; onPointerOutCapture?: DOMHandler<C, React__default.PointerEvent>; onPointerOver?: DOMHandler<C, React__default.PointerEvent>; onPointerOverCapture?: DOMHandler<C, React__default.PointerEvent>; onPointerUp?: DOMHandler<C, React__default.PointerEvent>; onPointerUpCapture?: DOMHandler<C, React__default.PointerEvent>; onProgress?: DOMHandler<C, React__default.SyntheticEvent>; onProgressCapture?: DOMHandler<C, React__default.SyntheticEvent>; onRateChange?: DOMHandler<C, React__default.SyntheticEvent>; onRateChangeCapture?: DOMHandler<C, React__default.SyntheticEvent>; onReset?: DOMHandler<C, React__default.FormEvent>; onResetCapture?: DOMHandler<C, React__default.FormEvent>; onScroll?: DOMHandler<C, React__default.UIEvent>; onScrollCapture?: DOMHandler<C, React__default.UIEvent>; onSeeked?: DOMHandler<C, React__default.SyntheticEvent>; onSeekedCapture?: DOMHandler<C, React__default.SyntheticEvent>; onSeeking?: DOMHandler<C, React__default.SyntheticEvent>; onSeekingCapture?: DOMHandler<C, React__default.SyntheticEvent>; onSelect?: DOMHandler<C, React__default.SyntheticEvent>; onSelectCapture?: DOMHandler<C, React__default.SyntheticEvent>; onStalled?: DOMHandler<C, React__default.SyntheticEvent>; onStalledCapture?: DOMHandler<C, React__default.SyntheticEvent>; onSubmit?: DOMHandler<C, React__default.FormEvent>; onSubmitCapture?: DOMHandler<C, React__default.FormEvent>; onSuspend?: DOMHandler<C, React__default.SyntheticEvent>; onSuspendCapture?: DOMHandler<C, React__default.SyntheticEvent>; onTimeUpdate?: DOMHandler<C, React__default.SyntheticEvent>; onTimeUpdateCapture?: DOMHandler<C, React__default.SyntheticEvent>; onTouchCancel?: DOMHandler<C, React__default.TouchEvent>; onTouchCancelCapture?: DOMHandler<C, React__default.TouchEvent>; onTouchEnd?: DOMHandler<C, React__default.TouchEvent>; onTouchEndCapture?: DOMHandler<C, React__default.TouchEvent>; onTouchMove?: DOMHandler<C, React__default.TouchEvent>; onTouchMoveCapture?: DOMHandler<C, React__default.TouchEvent>; onTouchStart?: DOMHandler<C, React__default.TouchEvent>; onTouchStartCapture?: DOMHandler<C, React__default.TouchEvent>; onTransitionEnd?: DOMHandler<C, React__default.TransitionEvent>; onTransitionEndCapture?: DOMHandler<C, React__default.TransitionEvent>; onVolumeChange?: DOMHandler<C, React__default.SyntheticEvent>; onVolumeChangeCapture?: DOMHandler<C, React__default.SyntheticEvent>; onWaiting?: DOMHandler<C, React__default.SyntheticEvent>; onWaitingCapture?: DOMHandler<C, React__default.SyntheticEvent>; onWheel?: DOMHandler<C, React__default.WheelEvent>; onWheelCapture?: DOMHandler<C, React__default.WheelEvent>; } type KeyboardHandler<C extends AnyPluginConfig = PluginConfig> = DOMHandler<C, React__default.KeyboardEvent>; type PlatePluginConfig$1<K extends string = any, O = {}, A = {}, T = {}, S = {}> = Omit<Partial<Modify<PlatePlugin<PluginConfig<K, O, A, T, S>>, { node: Partial<PlatePlugin<PluginConfig<K, O, A, T, S>>['node']>; }>>, keyof PlatePluginMethods | 'optionsStore' | 'useOptionsStore'>; type TPlatePluginConfig<C extends AnyPluginConfig = PluginConfig> = Omit<Partial<Modify<PlatePlugin<C>, { node: Partial<PlatePlugin<C>['node']>; }>>, keyof PlatePluginMethods | 'optionsStore' | 'useOptionsStore'>; declare const createPlatePlugin: <K extends string = any, O = {}, A = {}, T = {}, S = {}>(config?: ((editor: PlateEditor) => PlatePluginConfig$1<K, O, A, T, S>) | PlatePluginConfig$1<K, O, A, T, S>) => PlatePlugin<PluginConfig<K, O, A, T, S>>; /** * Explicitly typed version of `createPlatePlugin`. * * @remarks * While `createPlatePlugin` uses type inference, this function requires an * explicit type parameter. Use this when you need precise control over the * plugin's type structure or when type inference doesn't provide the desired * result. */ declare function createTPlatePlugin<C extends AnyPluginConfig = PluginConfig>(config?: ((editor: PlateEditor) => TPlatePluginConfig<C>) | TPlatePluginConfig<C>): PlatePlugin<C>; declare const getPlateCorePlugins: () => (PlatePlugin<PluginConfig<"slateExtension", {}, { redecorate: () => void; }, { setValue: <V extends _udecode_slate.Value>(value?: V | string) => void; }, {}>> | PlatePlugin<PluginConfig<"eventEditor", {}, {}, {}, {}>> | PlatePlugin<PluginConfig<"p", {}, {}, {}, {}>> | SlatePlugin<PluginConfig<"dom", {}, {}, { reset: (options: _udecode_slate.ResetOptions | undefined) => void; }, {}>>)[]; /** * A memoized version of createPlateEditor for use in React components. * * @param {CreatePlateEditorOptions} options - Configuration options for * creating the Plate editor. * @param {React.DependencyList} [deps=[]] - Additional dependencies for the * useMemo hook, in addition to `options.id`. Default is `[]` * @see {@link createPlateEditor} for detailed information on React editor creation and configuration. * @see {@link createSlateEditor} for a non-React version of editor creation. * @see {@link withPlate} for the underlying React-specific enhancement function. */ declare function usePlateEditor<V extends Value = Value, P extends AnyPluginConfig = PlateCorePlugin, TEnabled extends boolean | undefined = undefined>(options?: CreatePlateEditorOptions<V, P> & { enabled?: TEnabled; }, deps?: React__default.DependencyList): TEnabled extends false ? null : TEnabled extends true | undefined ? TPlateEditor<V, P> : TPlateEditor<V, P> | null; declare function getEditorPlugin<P extends AnyPluginConfig | PlatePlugin<AnyPluginConfig>>(editor: PlateEditor, plugin: WithRequiredKey<P>): PlatePluginContext<InferConfig<P> extends never ? P : InferConfig<P>>; /** Get editor plugin by key or plugin object. */ declare function getPlugin<C extends AnyPluginConfig = PluginConfig>(editor: PlateEditor, plugin: WithRequiredKey<C>): C extends { node: any; } ? C : PlatePlugin<C>; declare const omitPluginContext: <T extends PlatePluginContext<AnyPlatePlugin>>(ctx: T) => Omit<T, "api" | "type" | "setOptions" | "tf" | "getOption" | "getOptions" | "setOption" | "editor" | "plugin">; type PlatePluginConfig<C extends AnyPluginConfig, EO = {}, EA = {}, ET = {}, ES = {}> = Omit<Partial<PlatePlugin<PluginConfig<C['key'], EO & InferOptions<C>, EA & InferApi<C>, ET & InferTransforms<C>, ES & InferSelectors<C>>>>, keyof PlatePluginMethods | 'api' | 'node' | 'options' | 'transforms'> & { api?: EA & Partial<InferApi<C>>; node?: Partial<PlatePlugin<C>['node']>; options?: EO & Partial<InferOptions<C>>; selectors?: ES & Partial<InferSelectors<C>>; transforms?: ET & Partial<InferTransforms<C>>; }; /** * Extends a SlatePlugin to create a React PlatePlugin. * * @remarks * This function transforms a SlatePlugin into a React PlatePlugin, allowing for * React-specific functionality to be added. * @param basePlugin - The base SlatePlugin to be extended. * @param extendConfig - 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. */ declare function toPlatePlugin<C extends AnyPluginConfig, EO = {}, EA = {}, ET = {}, ES = {}>(basePlugin: SlatePlugin<C>, extendConfig?: ((ctx: PlatePluginContext<C>) => PlatePluginConfig<C, EO, EA, ET>) | PlatePluginConfig<C, EO, EA, ET>): PlatePlugin<PluginConfig<C['key'], EO & InferOptions<C>, EA & InferApi<C>, ET & InferTransforms<C>, ES & InferSelectors<C>>>; type ExtendPluginConfig<C extends AnyPluginConfig = PluginConfig> = Omit<Partial<PlatePlugin<PluginConfig<C['key'], Partial<InferOptions<C>>, Partial<InferApi<C>>, Partial<InferTransforms<C>>>>>, keyof PlatePluginMethods>; /** * Explicitly typed version of {@link toPlatePlugin}. * * @remarks * This function requires explicit type parameters for both the base plugin * configuration and the extension configuration. Use this when you need * precise control over the plugin's type structure or when type inference * doesn't provide the desired result. * @typeParam C - The type of the extension configuration for the PlatePlugin * (required). * @typeParam TContext - The type of the base SlatePlugin configuration * (optional). */ declare function toTPlatePlugin<C extends AnyPluginConfig = PluginConfig, TContext extends AnyPluginConfig = AnyPluginConfig>(basePlugin: SlatePlugin<TContext>, extendConfig?: ((ctx: PlatePluginContext<TContext>) => ExtendPluginConfig<C>) | ExtendPluginConfig<C>): PlatePlugin<PluginConfig<C['key'], InferOptions<C>, InferApi<C>, InferTransforms<C>, InferSelectors<C>>>; type DefaultLeafProps = { leafToAttributes?: (leaf: TText) => any; } & PlateRenderLeafProps & React__default.HTMLAttributes<HTMLSpanElement>; declare function DefaultLeaf(props: DefaultLeafProps): React__default.JSX.Element; declare function EditorHotkeysEffect({ id, editableRef, }: { editableRef: React__default.RefObject<HTMLDivElement | null>; id?: string; }): React__default.JSX.Element; declare const EditorMethodsEffect: ({ id }: { id?: string; }) => null; declare function EditorRefPluginEffect({ id, plugin, }: { plugin: AnyEditorPlatePlugin; id?: string; }): null; declare function EditorRefEffect({ id }: { id?: string; }): React__default.JSX.Element; declare const EditorStateEffect: React__default.MemoExoticComponent<() => null>; /** * Get the element by plugin key. If no element is found in the context, it will * return an empty object. */ declare const useElement: <T extends TElement = TElement>(pluginKey?: string) => T; interface UseElementSelectorOptions<T> { key?: string; equalityFn?: (a: T, b: T) => boolean; } declare const useElementSelector: <T>(selector: <N extends TElement>(state: NodeEntry<N>, prev?: T) => T, deps: React__default.DependencyList, { key, equalityFn, }?: UseElementSelectorOptions<T>) => T; declare const SCOPE_ELEMENT = "element"; type ElementStoreState = { element: TElement; entry: ElementEntry; path: Path; }; declare const ElementProvider: React$1.FC<jotai_x.ProviderProps<{ element: TElement; entry: ElementEntry; path: Path; }>>; declare const elementStore: jotai_x.StoreApi<ElementStoreState, object, "element">; declare const useElementStore: jotai_x.UseStoreApi<ElementStoreState, object>; /** Get the memoized path of the closest element. */ declare const usePath: (pluginKey?: string) => Path; /** Get last event editor id: focus, blur or last. */ declare const useEventPlateId: (id?: string) => string; type PlateChangeKey = 'versionDecorate' | 'versionEditor' | 'versionSelection' | 'versionValue'; type PlateStoreState<E extends PlateEditor = PlateEditor> = Nullable<{ decorate: NonNullable<(options: { editor: E; entry: NodeEntry; }) => TRange[]>; /** Whether `Editable` is rendered so slate DOM is resolvable. */ isMounted: boolean; /** * Whether the editor is primary. If no editor is active, then PlateController * will use the first-mounted primary editor. * * @default true */ primary: boolean; readOnly: boolean; renderElement: NonNulla