import { BaseEditor, BaseElement, BaseRange } from 'slate'; import { HistoryEditor } from 'slate-history'; import { ReactEditor, RenderElementProps } from 'slate-react'; import { TdNode as TableCellNode, TableCustomElement, TableNode, TrNode as TableRowNode } from './editor/elements/Table'; export type { TableCellNode, TableNode, TableRowNode }; type Align = 'left' | 'center' | 'right'; export interface DetailedSettings { row: number; col: number; rowSpan: number; colSpan: number; } export type CodeNode> = { contextProps?: T; type: 'code'; otherProps?: { className?: string; language?: string; render?: boolean; mergeCells?: Array<{ row: number; col: number; rowSpan: number; colSpan: number; }>; frontmatter?: boolean; config?: Record[]; } & T; children: [{ text: string; }]; language?: string; render?: boolean; frontmatter?: boolean; h?: number; value: string; katex?: boolean; isConfig?: boolean; }; export type ParagraphNode> = { contextProps?: T; otherProps?: T; type: 'paragraph'; align?: Align; children: BaseElement['children']; h?: number; }; export type FootnoteDefinitionNode> = { contextProps?: T; identifier: string; otherProps?: T; url?: string; value?: string; type: 'footnoteDefinition'; children: BaseElement['children']; h?: number; }; export type CardNode = { type: 'card'; children: (CardBeforeNode | CardAfterNode | T)[]; }; export type CardBeforeNode = { type: 'card-before'; children: BaseElement['children']; }; export type CardAfterNode = { type: 'card-after'; children: BaseElement['children']; }; export type BlockQuoteNode> = { contextProps?: T; otherProps?: T; type: 'blockquote'; children: (BlockQuoteNode | ParagraphNode)[]; }; export type ListNode> = { contextProps?: T; otherProps?: T; type: 'list'; children: ListItemNode[]; order?: boolean; start?: number; task?: boolean; finished?: boolean; h?: number; }; export type ChartTypeConfig> = { contextProps?: T; otherProps?: T; chartType: string; x?: string; y?: string; [key: string]: any; }; export type ChartNode> = { contextProps?: T; type: 'chart'; children: BaseElement['children']; otherProps?: { showSource?: boolean; config: ChartTypeConfig | ChartTypeConfig[]; columns: { title: string; dataIndex: string; key: string; }[]; dataSource: any[]; } & T; }; export type ListItemNode> = { contextProps?: T; otherProps?: T; type: 'list-item'; children: BaseElement['children']; checked?: boolean; mentions: { id: string; name: string; }[]; id: string; }; export type HeadNode> = { contextProps?: T; otherProps?: T; type: 'head'; children: BaseElement['children']; level: number; h?: number; align?: Align; }; export type HrNode> = { contextProps?: T; otherProps?: T; type: 'hr'; children: undefined; }; export type BreakNode> = { contextProps?: T; otherProps?: T; type: 'break'; children: BaseElement['children']; }; export type MediaNode> = { contextProps?: T; otherProps?: T; type: 'media'; url?: string; alt: string; downloadUrl?: string; finished?: boolean; height?: number; width?: number; docId?: string; block?: boolean; hash?: string; h?: number; children: BaseElement['children']; align?: 'left' | 'right'; mediaType?: string; controls?: boolean; autoplay?: boolean; loop?: boolean; muted?: boolean; poster?: string; }; export type LinkCardNode> = { otherProps?: T; contextProps?: T; type: 'link-card'; url?: string; icon?: string; description?: string; title?: string; name?: string; alt: string; finished?: boolean; children: BaseElement['children']; }; export type AttachNode> = { contextProps?: T; otherProps?: T; type: 'attach'; name: string; size: number; url: string; children: BaseElement['children']; }; export type SchemaNode> = { contextProps?: T; type: 'schema' | 'apaasify'; otherProps?: { language?: string; render?: boolean; frontmatter?: boolean; } & T; children: [text: string]; value: Record | Record[]; language?: string; render?: boolean; frontmatter?: boolean; h?: number; }; export type Elements> = CodeNode | FootnoteDefinitionNode | SchemaNode<{ valueType: string; } & T> | ParagraphNode | BlockQuoteNode | ListNode | ListItemNode | HeadNode | HrNode | MediaNode | BreakNode | ChartNode | AttachNode | LinkCardNode | CardNode | CardBeforeNode | CardAfterNode | TableCustomElement; export type CustomLeaf> = { contextProps?: T; otherProps?: T; bold?: boolean | null; identifier?: string; code?: boolean | null; tag?: boolean | null; italic?: boolean | null; strikethrough?: boolean | null; color?: string; highColor?: string; url?: string; text?: string; current?: boolean | null; html?: string; fnc?: boolean; fnd?: boolean; comment?: boolean; selection?: BaseRange; id?: string; data?: Record; }; export type NodeTypes = T['type']; export type MapValue = T extends Map ? I : T extends WeakMap ? I : unknown; declare module 'slate' { interface BaseElement { align?: Align; } interface BaseRange { color?: string; current?: boolean; } interface CustomTypes { Editor: BaseEditor & ReactEditor & HistoryEditor; Element: Elements & BaseElement; Text: CustomLeaf; } } export type InlineKatexNode = { type: 'inline-katex'; value: string; children: BaseElement['children']; }; export interface ElementProps extends RenderElementProps { element: T; }