import { MaybeGetter } from './utilities/callOrGet.js'; import { NodeType, ParseRule, DOMOutputSpec, Node as PmNode } from 'prosemirror-model'; import { Plugin } from 'prosemirror-state'; import { NodeView, EditorView, Decoration, DecorationSource } from 'prosemirror-view'; import { InputRule } from './InputRule.js'; import { Editor } from './Editor.js'; import { Command } from './types/ChainedCommands.js'; import { AttributeSpec } from './Attribute.js'; /** * Configuration for Node extensions. * @template Options - Type for node options * @template Storage - Type for node storage * @template Attrs - Type for node attributes (optional, enables typed addAttributes) */ export interface NodeConfig = Record, Storage extends Record = Record, Attrs extends Record = Record> { /** The node name */ name: string; /** The node group */ group?: string; /** The node options */ options?: Options; /** Whether the node is an atom node */ atom?: boolean; /** Whether the node is draggable */ draggable?: boolean; /** Whether the node is isolating */ isolating?: boolean; /** Whether the node is defining */ defining?: boolean; /** Whether the node is a top-level node */ topNode?: boolean; /** The role of the node in a table */ tableRole?: string; /** ProseMirror string for what content this node accepts */ content?: MaybeGetter; /** The marks applied to this node */ marks?: string; /** Whether the node is an inline node */ inline?: boolean; /** Whether the node is selectable */ selectable?: boolean; /** The ProseMirror node type (set at runtime) */ type?: NodeType; /** The editor instance (set at runtime) */ editor?: Editor; /** The DOM parsing rules */ parseDOM?: MaybeGetter; /** The DOM rendering function - returns a DOMOutputSpec (allows mutable arrays for JS compatibility) */ renderDOM?: MaybeGetter; /** Function or object to add options to the node */ addOptions?: MaybeGetter; /** Function or object to add storage to the node */ addStorage?: MaybeGetter; /** * Function or object to add attributes to the node. * When Attrs generic is provided, attribute keys are validated against it. */ addAttributes?: MaybeGetter<{ [K in keyof Attrs]?: Partial; }>; /** Function or object to add commands to the node */ addCommands?: MaybeGetter>; /** Function or object to add helpers to the node */ addHelpers?: MaybeGetter unknown>>; /** Function or object to add shortcuts to the node */ addShortcuts?: MaybeGetter>; /** Function or object to add input rules to the node */ addInputRules?: MaybeGetter; /** Function to add a custom node view to the node */ addNodeView?: MaybeGetter<(props: { node: PmNode; view: EditorView; getPos: () => number | undefined; decorations: readonly Decoration[]; innerDecorations: DecorationSource; }) => NodeView | null>; /** Function to add ProseMirror plugins to the node */ addPmPlugins?: MaybeGetter; /** Function to extend the ProseMirror node schema */ extendNodeSchema?: MaybeGetter>; /** Additional config fields - use with caution */ [key: string]: unknown; } /** * Node class is used to create Node extensions. * @template Options - Type for node options * @template Storage - Type for node storage * @template Attrs - Type for node attributes (enables typed attribute access) */ export declare class Node = Record, Storage extends Record = Record, Attrs extends Record = Record> { type: NodeType | string; name: string; options: Options; group: string | undefined; atom: boolean | undefined; editor: Editor | undefined; storage: Storage; config: NodeConfig; /** * Type hint for the attributes this node uses. * Not used at runtime, but enables type inference. */ readonly __attrsType: Attrs; constructor(config: NodeConfig); /** * Factory method to construct a new Node extension. * @param config - The node configuration. * @returns A new Node instance. */ static create = Record, S extends Record = Record, A extends Record = Record>(config: NodeConfig): Node; } //# sourceMappingURL=Node.d.ts.map