import React$1, { JSX } from 'react'; import * as _udecode_slate from '@udecode/slate'; import { TElement, TText, LeafPosition, NodeEntry, TRange, Editor, DOMRange, Path, DecoratedRange, Value, EditorApi, EditorTransforms, Descendant, ScrollIntoViewOptions, Operation, TSelection, EditorAboveOptions, QueryNodeOptions, EditorBase } from '@udecode/slate'; import { AnyObject, UnknownObject, Nullable, Deep2Partial, OmitFirst, UnionToIntersection } from '@udecode/utils'; import { Draft } from 'mutative'; import { TStateApi } from 'zustand-x'; import { KeyboardEventLike } from 'is-hotkey'; /** If true, the next handlers will be skipped. */ type HandlerReturnType = boolean | void; type RenderElementFn = (props: RenderElementProps) => React$1.ReactElement; interface RenderElementProps { attributes: { 'data-slate-node': 'element'; ref: any; className?: string; 'data-slate-inline'?: true; 'data-slate-void'?: true; dir?: 'rtl'; style?: React$1.CSSProperties; }; children: any; element: N; } type RenderLeafFn = (props: RenderLeafProps) => React.ReactElement; interface RenderLeafProps { attributes: { className?: string; 'data-slate-leaf'?: true; style?: React.CSSProperties; }; children: any; leaf: N; text: N; /** * The position of the leaf within the Text node, only present when the text * node is split by decorations. */ leafPosition?: LeafPosition; } type RenderTextFn = (props: RenderTextProps) => React$1.ReactElement; interface RenderTextProps { /** The text node being rendered. */ text: N; /** The children (leaves) rendered within this text node. */ children: any; /** * HTML attributes to be spread onto the rendered container element. Includes * `data-slate-node="text"` and `ref`. */ attributes: { 'data-slate-node': 'text'; ref: any; className?: string; style?: React$1.CSSProperties; }; } /** `EditableProps` are passed to the component. */ type EditableProps = { as?: React.ElementType; disableDefaultStyles?: boolean; placeholder?: string; readOnly?: boolean; renderElement?: RenderElementFn; renderLeaf?: RenderLeafFn; renderText?: RenderTextFn; role?: string; style?: React.CSSProperties; decorate?: (entry: NodeEntry) => TRange[]; renderPlaceholder?: (props: { attributes: { contentEditable: boolean; 'data-slate-placeholder': boolean; ref: React.RefCallback; style: React.CSSProperties; dir?: 'rtl'; }; children: any; }) => JSX.Element; scrollSelectionIntoView?: (editor: Editor, domRange: DOMRange) => void; onDOMBeforeInput?: (event: InputEvent) => void; } & React.TextareaHTMLAttributes; type BoxStaticProps = React.ComponentProps<'div'> & { as?: React.ElementType; }; type SlateRenderElementProps = SlateRenderNodeProps & RenderElementProps; type SlateRenderLeafProps = SlateRenderNodeProps & RenderLeafProps; type SlateRenderNodeProps = SlatePluginContext & { attributes?: AnyObject; className?: string; /** @see {@link NodeProps} */ nodeProps?: AnyObject; }; type SlateRenderTextProps = SlateRenderNodeProps & RenderTextProps; declare const useNodeAttributes: (props: any, ref?: any) => any; type SlateElementProps = SlateNodeProps & RenderElementProps & { path: Path; } & DeprecatedNodeProps; type DeprecatedNodeProps = { /** * @deprecated Optional class to be merged with `attributes.className`. * @default undefined */ className?: string; /** * @deprecated Optional style to be merged with `attributes.style` * @default undefined */ style?: React$1.CSSProperties; }; type SlateNodeProps = SlatePluginContext & { /** * Optional ref to be merged with `attributes.ref` * * @default undefined */ ref?: any; }; type SlateHTMLProps = SlateNodeProps & { /** HTML attributes to pass to the underlying HTML element */ attributes: React$1.PropsWithoutRef & UnknownObject; as?: T; /** Class to be merged with `attributes.className` */ className?: string; /** Style to be merged with `attributes.style` */ style?: React$1.CSSProperties; }; type StyledSlateElementProps = Omit, keyof DeprecatedNodeProps> & SlateHTMLProps; declare const SlateElement: (props: StyledSlateElementProps) => React$1.ReactElement; type SlateTextProps = SlateNodeProps & RenderTextProps & DeprecatedNodeProps; type StyledSlateTextProps = Omit, keyof DeprecatedNodeProps> & SlateHTMLProps; declare const SlateText: (props: StyledSlateTextProps) => React$1.ReactElement; type SlateLeafProps = SlateNodeProps & RenderLeafProps & DeprecatedNodeProps & { inset?: boolean; }; type StyledSlateLeafProps = Omit, keyof DeprecatedNodeProps> & SlateHTMLProps; declare const SlateLeaf: ({ className, ...props }: StyledSlateLeafProps) => React$1.ReactElement; type AnyEditorPlugin = EditorPlugin; type AnySlatePlugin = SlatePlugin; /** * 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 = (ctx: SlatePluginContext & { entry: NodeEntry; }) => DecoratedRange[] | undefined; type Deserializer = BaseDeserializer & { parse?: (options: AnyObject & SlatePluginContext & { element: any; }) => Partial | undefined | void; query?: (options: AnyObject & SlatePluginContext & { element: any; }) => boolean; }; type EditorPlugin = Omit, keyof SlatePluginMethods | 'override' | 'plugins'>; /** Plate plugin overriding the `editor` methods. Naming convention is `with*`. */ type ExtendEditor = (ctx: SlatePluginContext) => SlateEditor; type ExtendEditorApi = (ctx: SlatePluginContext) => EA & Deep2Partial & { [K in keyof InferApi]?: InferApi[K] extends (...args: any[]) => any ? (...args: Parameters[K]>) => ReturnType[K]> : InferApi[K] extends Record any> ? { [N in keyof InferApi[K]]?: (...args: Parameters[K][N]>) => ReturnType[K][N]>; } : never; }; type ExtendEditorTransforms = (ctx: SlatePluginContext) => EA & Deep2Partial & { [K in keyof InferTransforms]?: InferTransforms[K] extends (...args: any[]) => any ? (...args: Parameters[K]>) => ReturnType[K]> : InferTransforms[K] extends Record any> ? { [N in keyof InferTransforms[K]]?: (...args: Parameters[K][N]>) => ReturnType[K][N]>; } : never; }; type HtmlDeserializer = BaseHtmlDeserializer & { /** * Whether to disable the default node props parsing logic. By default, all * data-slate-* attributes will be parsed into node props. * * @default false */ disableDefaultNodeProps?: boolean; parse?: (options: SlatePluginContext & { element: HTMLElement; node: AnyObject; }) => Partial | undefined | void; query?: (options: SlatePluginContext & { element: HTMLElement; }) => boolean; toNodeProps?: (options: SlatePluginContext & { element: HTMLElement; }) => Partial | undefined | void; }; type HtmlSerializer = BaseSerializer & { parse?: (options: SlatePluginContext & { node: Descendant; }) => string; query?: (options: SlatePluginContext & { node: Descendant; }) => boolean; }; type InferConfig

= P extends SlatePlugin ? C : never; type InjectNodeProps = BaseInjectProps & { query?: (options: NonNullable> & SlatePluginContext & { nodeProps: GetInjectNodePropsOptions; }) => boolean; transformClassName?: (options: TransformOptions) => any; transformNodeValue?: (options: TransformOptions) => any; transformProps?: (options: TransformOptions & { props: GetInjectNodePropsReturnType; }) => AnyObject | undefined; transformStyle?: (options: TransformOptions) => CSSStyleDeclaration; }; type LeafStaticProps = ((props: SlateRenderLeafProps) => AnyObject | undefined) | AnyObject; type NodeStaticProps = ((props: SlateRenderElementProps & SlateRenderLeafProps) => AnyObject | undefined) | AnyObject; /** @deprecated Use {@link RenderStaticNodeWrapper} instead. */ type NodeStaticWrapperComponent = (props: NodeStaticWrapperComponentProps) => NodeStaticWrapperComponentReturnType; /** @deprecated Use {@link RenderStaticNodeWrapperProps} instead. */ interface NodeStaticWrapperComponentProps extends SlateRenderElementProps { key: string; } /** @deprecated Use {@link RenderStaticNodeWrapperFunction} instead. */ type NodeStaticWrapperComponentReturnType = React.FC> | undefined; type NormalizeInitialValue = (ctx: SlatePluginContext & { value: Value; }) => void; type OverrideEditor = (ctx: SlatePluginContext) => { api?: Deep2Partial & { [K in keyof InferApi]?: InferApi[K] extends (...args: any[]) => any ? (...args: Parameters[K]>) => ReturnType[K]> : InferApi[K] extends Record any> ? { [N in keyof InferApi[K]]?: (...args: Parameters[K][N]>) => ReturnType[K][N]>; } : never; }; transforms?: Deep2Partial & { [K in keyof InferTransforms]?: InferTransforms[K] extends (...args: any[]) => any ? (...args: Parameters[K]>) => ReturnType[K]> : InferTransforms[K] extends Record any> ? { [N in keyof InferTransforms[K]]?: (...args: Parameters[K][N]>) => ReturnType[K][N]>; } : never; }; }; type Parser = { format?: string[] | string; mimeTypes?: string[]; deserialize?: (options: ParserOptions & SlatePluginContext) => Descendant[] | undefined; preInsert?: (options: ParserOptions & SlatePluginContext & { fragment: Descendant[]; }) => HandlerReturnType; query?: (options: ParserOptions & SlatePluginContext) => boolean; transformData?: (options: ParserOptions & SlatePluginContext) => string; transformFragment?: (options: ParserOptions & SlatePluginContext & { fragment: Descendant[]; }) => Descendant[]; }; type PartialEditorPlugin = Omit>, 'node'> & { node?: Partial['node']>; }; type RenderStaticNodeWrapper = (props: RenderStaticNodeWrapperProps) => RenderStaticNodeWrapperFunction; type RenderStaticNodeWrapperFunction = ((hocProps: SlateRenderElementProps) => React.ReactNode) | undefined; interface RenderStaticNodeWrapperProps extends SlateRenderElementProps { key: string; } type Serializer = BaseSerializer & { parse?: (options: AnyObject & SlatePluginContext & { node: Descendant; }) => any; query?: (options: AnyObject & SlatePluginContext & { node: Descendant; }) => boolean; }; /** The `PlatePlugin` interface is a base interface for all plugins. */ type SlatePlugin = BasePlugin & Nullable<{ decorate?: Decorate>; extendEditor?: ExtendEditor>; normalizeInitialValue?: NormalizeInitialValue>; }> & SlatePluginMethods & { handlers: Nullable<{}>; inject: Nullable<{ nodeProps?: InjectNodeProps>; plugins?: Record>; targetPluginToInject?: (ctx: SlatePluginContext & { targetPlugin: string; }) => Partial>; }>; node: { /** Override `data-slate-leaf` element attributes */ leafProps?: LeafStaticProps>; /** Override node attributes */ props?: NodeStaticProps>; /** Override `data-slate-node="text"` element attributes */ textProps?: TextStaticProps>; }; override: { components?: NodeComponents; plugins?: Record>; }; parser: Nullable>>; parsers: (Record>; serializer?: Serializer>; }> & { html?: never; }) | { html?: Nullable<{ deserializer?: HtmlDeserializer>; serializer?: HtmlSerializer>; }>; }; /** * Recursive plugin support to allow having multiple plugins in a single * plugin. Plate eventually flattens all the plugins into the editor. */ plugins: any[]; 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?: RenderStaticNodeWrapper>; /** * 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?: RenderStaticNodeWrapper>; /** Renders a component above the main Slate component, as its sibling. */ aboveSlate?: () => React.ReactElement | null; /** Renders a component after the main editor container. */ afterContainer?: () => React.ReactElement | null; /** * Renders a component after the `Editable` component. This is the last * render position within the editor structure. */ afterEditable?: () => React.ReactElement | null; /** Renders a component before the main editor container. */ beforeContainer?: () => React.ReactElement | null; /** Renders a component before the `Editable` component. */ beforeEditable?: () => React.ReactElement | null; /** * 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. */ belowRootNodes?: (props: SlateElementProps) => React.ReactNode; }>; rules: { /** * Function to determine if this plugin's rules should apply to a node. * Used to override behavior based on node properties beyond just type * matching. * * Example: List plugin sets `match: ({ node }) => !!node.listStyleType` * to override paragraph behavior when the paragraph is a list item. * * @default type === node.type */ match?: (options: { node: TElement; path: Path; rule: MatchRules; } & SlatePluginContext) => boolean; }; /** * Keyboard shortcuts configuration mapping shortcut names to their key * combinations and handlers. Each shortcut can link to a transform * method, an API method, or use a custom handler function. */ shortcuts: Partial[C['key']], keyof InferTransforms[C['key']]> | keyof InferTransforms[C['key']], SlateShortcut | null>>; }; type SlatePluginConfig = Partial, A, T, S>>, keyof SlatePluginMethods | 'api' | 'node' | 'optionsStore' | 'transforms'> & { api: EA; node: Partial; options: EO; selectors: ES; transforms: ET; }>; type SlatePluginContext = BasePluginContext & { editor: SlateEditor; plugin: EditorPlugin; }; type SlatePluginMethods = { __apiExtensions: ((ctx: SlatePluginContext) => any)[]; __configuration: ((ctx: SlatePluginContext) => any) | null; __extensions: ((ctx: SlatePluginContext) => any)[]; __selectorExtensions: ((ctx: SlatePluginContext) => any)[]; clone: () => SlatePlugin; configure: (config: ((ctx: SlatePluginContext) => SlatePluginConfig, InferApi, InferTransforms, InferSelectors>) | SlatePluginConfig, InferApi, InferTransforms, InferSelectors>) => SlatePlugin; configurePlugin:

(plugin: Partial

, config: ((ctx: SlatePluginContext

) => SlatePluginConfig, InferApi

, InferTransforms

, InferSelectors

>) | SlatePluginConfig, InferApi

, InferTransforms

, InferSelectors

>) => SlatePlugin; extend: (extendConfig: ((ctx: SlatePluginContext) => SlatePluginConfig, InferApi, InferTransforms, InferSelectors, EO, EA, ET, ES>) | SlatePluginConfig, InferApi, InferTransforms, InferSelectors, EO, EA, ET, ES>) => SlatePlugin, EA & InferApi, ET & InferTransforms, ES & InferSelectors>>; extendApi: any> = Record>(extension: (ctx: SlatePluginContext) => EA) => SlatePlugin, InferApi & Record, InferTransforms, InferSelectors>>; extendEditorApi: any) | Record any>> = Record>(extension: ExtendEditorApi) => SlatePlugin, { [K in keyof (EA & InferApi)]: (EA & InferApi)[K] extends (...args: any[]) => any ? (EA & InferApi)[K] : { [N in keyof (EA & InferApi)[K]]: (EA & InferApi)[K][N]; }; }, InferTransforms, InferSelectors>>; extendEditorTransforms: any) | Record any>> = Record>(extension: ExtendEditorTransforms) => SlatePlugin, InferApi, { [K in keyof (ET & InferTransforms)]: (ET & InferTransforms)[K] extends (...args: any[]) => any ? (ET & InferTransforms)[K] : { [N in keyof (ET & InferTransforms)[K]]: (ET & InferTransforms)[K][N]; }; }, InferSelectors>>; extendPlugin:

(plugin: Partial

, extendConfig: ((ctx: SlatePluginContext

) => SlatePluginConfig, InferApi

, InferTransforms

, InferSelectors

, EO, EA, ET, ES>) | SlatePluginConfig, InferApi

, InferTransforms

, InferSelectors

, EO, EA, ET, ES>) => SlatePlugin; extendSelectors: any> = Record>(extension: (ctx: SlatePluginContext) => ES) => SlatePlugin, InferApi, InferTransforms, ES & InferSelectors>>; extendTransforms: any> = Record>(extension: (ctx: SlatePluginContext) => ET) => SlatePlugin, InferApi, InferTransforms & Record, InferSelectors>>; overrideEditor: (override: OverrideEditor) => SlatePlugin; /** Returns a new instance of the plugin with the component. */ withComponent: (component: NodeComponent) => SlatePlugin; __resolved?: boolean; }; type SlatePlugins = AnySlatePlugin[]; type TextStaticProps = ((props: SlateRenderTextProps) => AnyObject | undefined) | AnyObject; type TransformOptions = BaseTransformOptions & SlatePluginContext; type SlateShortcut = { keys?: (({} & string)[][] | readonly string[] | string) | null; delimiter?: string; description?: string; document?: Document; enabled?: Trigger; enableOnContentEditable?: boolean; enableOnFormTags?: boolean; ignoreEventWhenPrevented?: boolean; ignoreModifiers?: boolean; keydown?: boolean; keyup?: boolean; preventDefault?: Trigger; priority?: number; scopes?: readonly string[] | string; splitKey?: string; useKey?: boolean; handler?: (ctx: { editor: SlateEditor; event: KeyboardEvent; eventDetails: any; }) => boolean | void; ignoreEventWhen?: (e: KeyboardEvent) => boolean; }; type Trigger = ((keyboardEvent: KeyboardEvent, hotkeysEvent: any) => boolean) | boolean; type ElementAffinity = { affinity: 'backward' | 'forward'; at: Path; type: string; }; type AffinityConfig = PluginConfig<'affinity'>; declare const AffinityPlugin: SlatePlugin; interface WithAutoScrollOptions { mode?: ScrollMode; operations?: AutoScrollOperationsMap; scrollOptions?: ScrollIntoViewOptions; } declare const withScrolling: (editor: SlateEditor, fn: () => void, options?: WithAutoScrollOptions) => void; declare const AUTO_SCROLL: WeakMap; type AutoScrollOperationsMap = Partial>; type DomConfig = PluginConfig<'dom', { /** Choose the first or last matching operation as the scroll target */ scrollMode?: ScrollMode; /** * Operations map; false to disable an operation, true or undefined to * enable */ scrollOperations?: AutoScrollOperationsMap; /** Options passed to scrollIntoView */ scrollOptions?: ScrollIntoViewOptions; }>; /** Mode for picking target op when multiple enabled */ type ScrollMode = 'first' | 'last'; /** * Placeholder plugin for DOM interaction, that could be replaced with * ReactPlugin. */ declare const DOMPlugin: SlatePlugin boolean; }, { withScrolling: (fn: () => void, options?: WithAutoScrollOptions | undefined) => void; }, {}>>; type InitOptions = { autoSelect?: boolean | 'end' | 'start'; selection?: TSelection; shouldNormalizeEditor?: boolean; value?: any; }; declare const init: (editor: SlateEditor, { autoSelect, selection, shouldNormalizeEditor, value }: InitOptions) => Promise; type InsertExitBreakOptions = { match?: EditorAboveOptions['match']; reverse?: boolean; }; /** * Exits the current block structure by creating a new block next to the * appropriate ancestor. * * This function automatically determines the exit point by finding the first * ancestor that doesn't have strict sibling constraints (`isStrictSiblings: * false`), allowing standard text blocks to be inserted as siblings. * * For example: * * - In `column_group > column > codeblock > codeline`, exits after `codeblock`, * then after `column_group` * - In `table > tr > td > p`, exits after `table` */ declare const insertExitBreak: (editor: SlateEditor, { match, reverse }?: InsertExitBreakOptions) => true | undefined; /** * Reset the current block to a paragraph, removing all properties except id and * type. */ declare const resetBlock: (editor: SlateEditor, { at }?: { at?: Path; }) => true | undefined; declare const setValue: (editor: SlateEditor, value?: V | string) => void; type SlateExtensionConfig = PluginConfig<'slateExtension', {}, {}, { init: OmitFirst; insertExitBreak: OmitFirst; resetBlock: OmitFirst; setValue: OmitFirst; }>; /** Opinionated extension of slate default behavior. */ declare const SlateExtensionPlugin: SlatePlugin Promise; insertExitBreak: (args_0?: InsertExitBreakOptions | undefined) => true | undefined; resetBlock: (args_0?: { at?: _udecode_slate.Path; } | undefined) => true | undefined; setValue: (value?: string | _udecode_slate.Value | undefined) => void; }, {}>>; type DebugErrorType = (string & {}) | 'DEFAULT' | 'OPTION_UNDEFINED' | 'OVERRIDE_MISSING' | 'PLUGIN_DEPENDENCY_MISSING' | 'PLUGIN_MISSING' | 'USE_CREATE_PLUGIN' | 'USE_ELEMENT_CONTEXT'; type LogLevel = 'error' | 'info' | 'log' | 'warn'; declare class PlateError extends Error { type: DebugErrorType; constructor(message: string, type?: DebugErrorType); } declare const DebugPlugin: SlatePlugin void>>; logLevel: LogLevel; throwErrors: boolean; }, { debug: { error: (message: string | unknown, type?: DebugErrorType, details?: any) => void; info: (message: string, type?: DebugErrorType, details?: any) => void; log: (message: string, type?: DebugErrorType, details?: any) => void; warn: (message: string, type?: DebugErrorType, details?: any) => void; }; }, {}, {}>>; type NodeIdConfig = PluginConfig<'nodeId', { /** * By default, when a node inserted using editor.tf.insertNode(s) has an id, * it will be used instead of the id generator, except if it already exists * in the document. Set this option to true to disable this behavior. */ disableInsertOverrides?: boolean; /** * Filter inline `Element` nodes. * * @default true */ filterInline?: boolean; /** * Filter `Text` nodes. * * @default true */ filterText?: boolean; /** * Node key to store the id. * * @default 'id' */ idKey?: string; /** * Normalize initial value. If false, normalize only the first and last node * are missing id. To disable this behavior, use `NodeIdPlugin.configure({ * normalizeInitialValue: null })`. * * @default false */ normalizeInitialValue?: boolean; /** * Reuse ids on undo/redo and copy/pasting if not existing in the document. * This is disabled by default to avoid duplicate ids across documents. * * @default false */ reuseId?: boolean; /** * A function that generates and returns a unique ID. * * @default () => nanoid(10) */ idCreator?: () => any; } & QueryNodeOptions>; /** @see {@link withNodeId} */ declare const NodeIdPlugin: SlatePlugin; type CorePlugin = ReturnType[number]; type GetCorePluginsOptions = { /** Enable mark/element affinity. */ affinity?: boolean; /** Specifies the maximum number of characters allowed in the editor. */ maxLength?: number; /** Configure the node id plugin. */ nodeId?: NodeIdConfig['options'] | boolean; /** Override the core plugins using the same key. */ plugins?: AnyPluginConfig[]; }; declare const getCorePlugins: ({ affinity, maxLength, nodeId, plugins, }: GetCorePluginsOptions) => (SlatePlugin | SlatePlugin Promise; insertExitBreak: (args_0?: InsertExitBreakOptions | undefined) => true | undefined; resetBlock: (args_0?: { at?: _udecode_slate.Path; } | undefined) => true | undefined; setValue: (value?: string | _udecode_slate.Value | undefined) => void; }, {}>> | SlatePlugin boolean; }, { withScrolling: (fn: () => void, options?: WithAutoScrollOptions | undefined) => void; }, {}>> | SlatePlugin> | SlatePlugin> | SlatePlugin> | SlatePlugin | SlatePlugin _udecode_slate.Descendant[]; }>, {}, {}>> | SlatePlugin> | SlatePlugin | SlatePlugin | SlatePlugin>)[]; type CorePluginTransforms = SlateExtensionConfig['transforms']; type CorePluginApi = SlateExtensionConfig['api']; type DebugConfig = PluginConfig<'debug', { isProduction: boolean; logger: Partial>; logLevel: LogLevel; throwErrors: boolean; }, { debug: { error: (message: string | unknown, type?: DebugErrorType, details?: any) => void; info: (message: string, type?: DebugErrorType, details?: any) => void; log: (message: string, type?: DebugErrorType, details?: any) => void; warn: (message: string, type?: DebugErrorType, details?: any) => void; }; }>; type LengthConfig = PluginConfig<'length', { maxLength: number; }>; type LogFunction = (message: string, type?: DebugErrorType, details?: any) => void; type ParagraphConfig = PluginConfig<'p'>; declare const BaseParagraphPlugin: SlatePlugin>; type AnyPluginConfig = { key: any; api: any; options: any; selectors: any; transforms: any; }; type BaseDeserializer = AnyObject & { /** * Deserialize an element. Overrides plugin.isElement. * * @default plugin.isElement */ isElement?: boolean; /** * Deserialize a leaf. Overrides plugin.isLeaf. * * @default plugin.isLeaf */ isLeaf?: boolean; }; type BaseHtmlDeserializer = BaseDeserializer & { /** List of HTML attribute names to store their values in `node.attributes`. */ attributeNames?: string[]; rules?: { /** * Deserialize an element: * * - If this option (string) is in the element attribute names. * - If this option (object) values match the element attributes. */ validAttribute?: Record | string; /** Valid element `className`. */ validClassName?: string; /** Valid element `nodeName`. Set '*' to allow any node name. */ validNodeName?: string[] | string; /** * Valid element style values. Can be a list of string (only one match is * needed). */ validStyle?: Partial>; }[]; /** Whether or not to include deserialized children on this node */ withoutChildren?: boolean; }; type BaseInjectProps = { /** * Object whose keys are node values and values are classNames which will be * extended. */ classNames?: AnyObject; /** * Default node value. The node key would be unset if the node value = * defaultNodeValue. */ defaultNodeValue?: any; /** Node key to map to the styles. */ nodeKey?: string; /** * Style key to override. * * @default nodeKey */ styleKey?: keyof CSSStyleDeclaration; /** List of supported node values. */ validNodeValues?: any[]; }; type BasePlugin = { /** Unique identifier for this plugin. */ key: C['key']; /** API methods provided by this plugin. */ api: InferApi; /** * An array of plugin keys that this plugin depends on. These plugins will be * loaded before this plugin. */ dependencies: string[]; inject: Nullable<{ /** Plugin keys of elements to exclude the children from */ excludeBelowPlugins?: string[]; /** Plugin keys of elements to exclude */ excludePlugins?: string[]; /** Whether to filter blocks */ isBlock?: boolean; /** Whether to filter elements */ isElement?: boolean; /** Whether to filter leaves */ isLeaf?: boolean; /** Filter nodes with path above this level. */ maxLevel?: number; /** * Plugin keys used by {@link InjectNodeProps} and the targetPluginToInject * function. For plugin injection by key, use the inject.plugins property. * * @default [ParagraphPlugin.key] */ targetPlugins?: string[]; }>; /** Node-specific configuration for this plugin. */ node: BasePluginNode; /** Extended properties used by any plugin as options. */ options: InferOptions; /** Store for managing plugin options. */ optionsStore: TStateApi; override: { /** Enable or disable plugins */ enabled?: Partial>; }; /** * Defines the order in which plugins are registered and executed. * * Plugins with higher priority values are registered and executed before * those with lower values. This affects two main aspects: * * 1. Plugin Order: Plugins with higher priority will be added to the editor * earlier. * 2. Execution Order: For operations that involve multiple plugins (e.g., editor * methods), plugins with higher priority will be processed first. * * @default 100 */ priority: number; render: Nullable<{ /** * Renders a component above the `Editable` component but within the `Slate` * wrapper. Useful for adding UI elements that should appear above the * editable area. */ aboveEditable?: React.FC<{ children: React.ReactNode; }>; /** * Renders a component above the `Slate` wrapper. This is the outermost * render position in the editor structure. */ aboveSlate?: React.FC<{ children: React.ReactNode; }>; /** * Specifies the HTML tag name to use when rendering the node component. * Only used when no custom `component` is provided for the plugin. * * @default 'div' for elements, 'span' for leaves */ as?: keyof HTMLElementTagNameMap; /** * Renders a component below leaf nodes when `isLeaf: true` and * `isDecoration: false`. Use `render.node` instead when `isDecoration: * true`. */ leaf?: NodeComponent; /** * Renders a component for: * * - Elements nodes if `isElement: true` * - Below text nodes if `isLeaf: true` and `isDecoration: false` * - Below leaf if `isLeaf: true` and `isDecoration: true` */ node?: NodeComponent; }>; rules: { /** * Defines actions on insert break based on block state. * * - `'default'`: Default behavior * - `'exit'`: Exit the current block * - `'reset'`: Reset block to default paragraph type * - `'lineBreak'`: Insert newline character * - `'deleteExit'`: Delete backward then exit */ break?: BreakRules; /** * Defines actions on delete based on block state. * * - `'default'`: Default behavior * - `'reset'`: Reset block to default paragraph type */ delete?: DeleteRules; /** Defines the behavior of merging nodes. */ merge?: MergeRules; /** Defines the behavior of normalizing nodes. */ normalize?: NormalizeRules; /** Defines the behavior of selection. */ selection?: SelectionRules; }; /** Selectors for the plugin. */ selectors: InferSelectors; /** Transforms (state-modifying operations) that can be applied to the editor. */ transforms: InferTransforms; /** * Configures edit-only behavior for various plugin functionalities. * * - If `true` (boolean): * * - `render`, `handlers`, and `inject.nodeProps` are active only when the * editor is NOT read-only. * - If an object ({@link EditOnlyConfig}): Allows fine-grained control: * * - `render`: Edit-only by default (true if not specified). Set to `false` to * always be active. * - `handlers`: Edit-only by default (true if not specified). Set to `false` to * always be active. * - `inject` (for `inject.nodeProps`): Edit-only by default (true if not * specified). Set to `false` to always be active. * - `normalizeInitialValue`: NOT edit-only by default (false if not specified). * Set to `true` to make it edit-only. */ editOnly?: EditOnlyConfig | boolean; /** * Enables or disables the plugin. Used by Plate to determine if the plugin * should be used. */ enabled?: boolean; }; type BasePluginContext = { api: C['api'] & EditorApi & CorePluginApi; setOptions: { (options: (state: Draft>>) => void): void; (options: Partial>): void; }; tf: C['transforms'] & EditorTransforms & CorePluginTransforms; type: string; getOption: | keyof InferSelectors | 'state'>(key: K, ...args: K extends keyof InferSelectors ? Parameters[K]> : unknown[]) => K extends 'state' ? InferOptions : K extends keyof InferSelectors ? ReturnType[K]> : K extends keyof InferOptions ? InferOptions[K] : never; getOptions: () => InferOptions; setOption: >(optionKey: K, value: InferOptions[K]) => void; }; type BasePluginNode = { /** * Specifies the type identifier for this plugin's nodes. * * For elements (when {@link isElement} is `true`): * * - The {@link NodeComponent} will be used for any node where `node.type === * type`. * * For leaves/marks (when {@link isLeaf} is `true`): * * - The {@link NodeComponent} will be used for any leaf where `node[type] === * true`. * * This property is crucial for Plate to correctly match nodes to their * respective plugins. * * @default plugin.key */ type: string; component?: NodeComponent | null; /** * Controls which (if any) attribute names in the `attributes` property of an * element will be passed as `nodeProps` to the {@link NodeComponent}, and * subsequently rendered as DOM attributes. * * WARNING: If used improperly, this property WILL make your application * vulnerable to cross-site scripting (XSS) or information exposure attacks. * * For example, if the `href` attribute is allowed and the component passes * `nodeProps` to an `` element, then attackers can direct users to open a * document containing a malicious link element: * * { type: 'link', url: 'https://safesite.com/', attributes: { href: * 'javascript:alert("xss")' }, children: [{ text: 'Click me' }], } * * The same is true of the `src` attribute when passed to certain HTML * elements, such as `