import type { DataTAny, DataTType, JsonSchema } from '@react-page/editor'; import type { ReactNode } from 'react'; import type { Editor, Node } from 'slate'; import type { Data } from '../types'; import type { Translations } from './translations'; export interface PluginButtonProps { translations?: Partial; } export declare type SlatePluginControls = { pluginConfig: SlateBasePluginDefinition; open: boolean; close: () => void; isActive: boolean; cancelLabel?: string; submitLabel?: string; removeLabel?: string; data: T | undefined; add: (p: { data?: T; text?: string | null; }) => void; remove: () => void; shouldInsertWithText: boolean; getInitialData?: () => T; } & PluginButtonProps; /** * controls where you can provide a custom component to render the controls. */ export declare type CustomControlsDef = { Component: React.ComponentType>; type: 'custom'; }; /** * autoform control type automatically generates a form for you. */ export declare type AutoformControlsDef = { /** * a JSONSchema. this will auto-generate a form for the plugin */ schema?: DataT extends DataTType ? JsonSchema : unknown; /** * autoform type automatically generates a form for you. */ type: 'autoform'; }; /** * All available type of controls */ export declare type ControlsDef = AutoformControlsDef | CustomControlsDef; export declare type SlateBasePluginDefinition = { /** define a hotkey to toggle this plugin **/ hotKey?: string; /** * the controls of the plugin if it has data. * You can use a schema based "autoform" type (recomended) or pass a custom component (using "custom" type) */ controls?: ControlsDef; /** * icon of this plugin in the toolbar */ icon?: JSX.Element; /** * label / title of this plugin */ label?: string; /** * whether to show this plugin the hover toolbar */ addHoverButton: boolean; /** * whether to show this plugin in the bottom toolbar */ addToolbarButton: boolean; /** * defines the initial data when an element is added */ getInitialData?: () => T; isDisabled?: (editor: Editor) => Promise; onKeyDown?: (e: React.KeyboardEvent, editor: Editor, next: any) => void; customAdd?: (editor: Editor) => void | Promise; customRemove?: (editor: Editor) => void | Promise; }; export declare type SlateNodeBasePluginDefinition = { object: SlateNodeObjectType; } & SlateBasePluginDefinition; export declare type SlateNodeObjectType = 'inline' | 'block' | 'mark'; export declare type SlateDataPluginDefinition = SlateNodeBasePluginDefinition & { dataMatches: (data: T) => boolean; /** * if defined these properties will be removed from data when plugin gets disabled */ properties?: T extends Record ? Array : Array; }; export declare type SlateCustomPluginDefinition = SlateBasePluginDefinition & Record; export declare type MapLike = { get(key: K): T[K]; }; declare type ObjectProps = { object: 'block'; replaceWithDefaultOnRemove?: boolean; isVoid?: boolean; }; declare type InlineProps = { object: 'inline'; addExtraSpace?: boolean; isVoid?: boolean; }; declare type MarkProps = { object: 'mark'; }; declare type NoInfer = [T][T extends any ? 0 : never]; declare type SlateComponentPluginComponent = keyof JSX.IntrinsicElements | React.ComponentType; /** * the style that can be passed directly to the rendered html element */ style?: React.CSSProperties; /** * className to pass to the renderd html element */ className?: string; /** * raw child nodes. Usefull in certain niche cases */ childNodes: Node[]; /** * hook that returns true if the current element is focused */ useFocused: () => boolean; /** * hook that returns true if the current element is selected */ useSelected: () => boolean; /** * @returns the current text content as an array. Usefull in some advanced use cases */ getTextContents: () => string[]; /** * the childrens should be rendered in non-void plugins */ children: ReactNode; } & T>>; export declare type SlateComponentPluginDefinition = SlateNodeBasePluginDefinition & { /** * a unique type (id) for the this component */ type: string; /** * pass a function that receives the data and returns the style that is passed to the Component */ getStyle?: (data: T) => React.CSSProperties; /** * defines how this element can be created by pasted html */ deserialize?: { /** * html tag name */ tagName: string; /** * pass a function that receives the html element and returns data found in that element */ getData?: (el: HTMLElement) => T | void; }; Component: SlateComponentPluginComponent; } & (ObjectProps | InlineProps | MarkProps); export declare type SlatePluginDefinition = (SlateComponentPluginDefinition & { pluginType: 'component'; }) | (SlateDataPluginDefinition & { pluginType: 'data'; }) | (SlateCustomPluginDefinition & { pluginType: 'custom'; }); export {}; //# sourceMappingURL=slatePluginDefinitions.d.ts.map