import type { HTMLAttributes, ReactElement, ReactNode } from 'react';
import type { RenderElementProps, RenderLeafProps } from 'slate-react';
import type { SlateEditor, SlateElement, YooEditor, YooptaBlockBaseMeta, YooptaBlockData } from '../editor/types';
import type { EditorEventHandlers } from '../types/eventHandlers';
import type { HOTKEYS_TYPE } from '../utils/hotkeys';
export declare enum NodeType {
Block = "block",
Inline = "inline",
Void = "void",
InlineVoid = "inlineVoid"
}
export type PluginOptions = Partial<{
display?: {
title?: string;
description?: string;
icon?: ReactNode;
};
shortcuts?: string[];
HTMLAttributes?: HTMLAttributes;
} & T>;
export type RenderSlateElementProps = Omit & {
element: SlateElement;
};
export type PluginElementExtendRenderProps = RenderSlateElementProps & {
blockId: string;
HTMLAttributes?: HTMLAttributes;
};
export type PluginElementRenderProps = PluginElementExtendRenderProps;
export type PluginCustomEditorRenderProps = {
blockId: string;
};
export type PluginElementNodeType = 'block' | 'inline' | 'void' | 'inlineVoid';
export type PluginDefaultProps = {
nodeType?: PluginElementNodeType;
};
export type PluginElementProps = PluginDefaultProps & T;
export type PluginElement = {
render?: (props: PluginElementRenderProps) => JSX.Element;
props?: PluginElementProps;
asRoot?: boolean;
children?: TKeys[];
injectElementsFromPlugins?: string[];
rootPlugin?: string;
/**
* Placeholder text for this element when it's empty
* Only applies to leaf elements (elements without children)
*/
placeholder?: string;
};
export type PluginElementsMap = {
[key in TKeys]: PluginElement;
};
export type EventHandlers = {
[key in keyof EditorEventHandlers]: (editor: YooEditor, slate: SlateEditor, options: PluginEventHandlerOptions) => EditorEventHandlers[key] | void;
};
export type PluginEventHandlerOptions = {
hotkeys: HOTKEYS_TYPE;
defaultBlock: YooptaBlockData;
currentBlock: YooptaBlockData;
};
export type ElementPropsMap = Record>;
export type PluginDOMEvents = EventHandlers;
export type PluginLifeCycleEvents = {
beforeCreate?: (editor: YooEditor) => SlateElement;
onCreate?: (editor: YooEditor, blockId: string) => void;
onDestroy?: (editor: YooEditor, blockId: string) => void;
};
export type PluginInputElements> = {
[K in keyof TElementMap]: PluginElement, TElementMap[K]['props']>;
} | ReactElement;
export type Plugin, TPluginOptions = Record> = {
type: string;
extensions?: (slate: SlateEditor, editor: YooEditor, blockId: string) => SlateEditor;
commands?: Record any>;
elements: {
[K in keyof TElementMap]: PluginElement, TElementMap[K]['props']>;
};
events?: PluginDOMEvents;
lifecycle?: PluginLifeCycleEvents;
options?: PluginOptions;
parsers?: Partial>;
};
export type PluginParsers = {
deserialize?: PluginDeserializeParser;
serialize?: PluginSerializeParser;
};
export type PluginParserTypes = 'html' | 'markdown' | 'email';
export type PluginParserValues = 'deserialize' | 'serialize';
export type PluginSerializeParser = (element: SlateElement, content: string, blockMetaData?: YooptaBlockBaseMeta) => string;
export type PluginDeserializeParser = {
nodeNames: string[];
parse?: (el: HTMLElement, editor: YooEditor) => SlateElement | YooptaBlockData[] | void;
};
export type LeafFormats = {
[key in K]: V;
};
export type ExtendedLeaf = RenderLeafProps['leaf'] & LeafFormats & {
withPlaceholder?: boolean;
elementPlaceholder?: string;
};
export type YooptaMarkProps = {
children: RenderLeafProps['children'];
leaf: ExtendedLeaf;
};
export type ExtendedLeafProps = RenderLeafProps & {
leaf: ExtendedLeaf;
};
//# sourceMappingURL=types.d.ts.map