import { Node as PMNode } from 'prosemirror-model'; import { ParagraphDiff, ParagraphNodeInfo } from './paragraph-diffing'; import { AttributesDiff } from './attributes-diffing'; type NodeJSON = ReturnType; /** * Minimal node metadata extracted during document traversal. */ export type BaseNodeInfo = { /** ProseMirror node reference. */ node: PMNode; /** Absolute position of the node in the document. */ pos: number; /** Depth of the node within the document tree. */ depth: number; }; /** * Union describing every node processed by the generic diff. */ export type NodeInfo = BaseNodeInfo | ParagraphNodeInfo; interface NodeDiffBase { /** Change type for this node. */ action: Action; /** ProseMirror node type name. */ nodeType: string; /** Anchor position in the old document for replaying diffs. */ pos: number; } /** * Diff payload describing an inserted non-paragraph node. */ interface NodeAddedDiff extends NodeDiffBase<'added'> { /** Serialized node payload inserted into the document. */ nodeJSON: NodeJSON; } /** * Diff payload describing a deleted non-paragraph node. */ interface NodeDeletedDiff extends NodeDiffBase<'deleted'> { /** Serialized node payload removed from the document. */ nodeJSON: NodeJSON; } /** * Diff payload describing an attribute-only change on non-paragraph nodes. */ interface NodeModifiedDiff extends NodeDiffBase<'modified'> { /** Serialized node payload before the change. */ oldNodeJSON: NodeJSON; /** Serialized node payload after the change. */ newNodeJSON: NodeJSON; /** Attribute-level diff for the node. */ attrsDiff: AttributesDiff; } /** * Union of every diff type emitted by the generic diffing layer. */ export type NodeDiff = ParagraphDiff | NodeAddedDiff | NodeDeletedDiff | NodeModifiedDiff; /** * Produces a sequence diff between two normalized node lists. * * @param oldNodes Normalized nodes from the old document. * @param newNodes Normalized nodes from the new document. * @returns List of node diffs describing the changes. */ export declare function diffNodes(oldNodes: NodeInfo[], newNodes: NodeInfo[]): NodeDiff[]; /** * Traverses a ProseMirror document and converts paragraphs to richer node info objects. */ export declare function normalizeNodes(pmDoc: PMNode): NodeInfo[]; export {}; //# sourceMappingURL=generic-diffing.d.ts.map