import { Schema } from 'prosemirror-model'; import { NodeDiff, NodeInfo } from './generic-diffing'; import { AttributesDiff } from './attributes-diffing'; /** * Raw comment data used for diffing comment content and metadata. */ export interface CommentInput { /** Primary comment identifier when available. */ commentId?: string; /** Imported comment identifier used as a fallback. */ importedId?: string; /** Alternate identifier used by some integrations. */ id?: string; /** ProseMirror-compatible JSON for the comment body (expected to be a paragraph node). */ textJson?: unknown; /** Structured ProseMirror-like nodes used by imported DOCX comments. */ elements?: unknown; /** Additional comment metadata fields. */ [key: string]: unknown; } /** * Normalized token representation for a single comment. */ export interface CommentToken { /** Resolved identifier for the comment. */ commentId: string; /** Original comment payload. */ commentJSON: CommentInput; /** Parsed comment body content when available. */ content: NodeInfo | null; } /** * Base shape shared by every comment diff payload. */ export interface CommentDiffBase { /** Change type for this comment. */ action: Action; /** Node type identifier for comment diffs. */ nodeType: 'comment'; /** Resolved comment identifier (importedId → id → commentId). */ commentId: string; } /** * Diff payload describing an added comment. */ export type CommentAddedDiff = CommentDiffBase<'added'> & { /** Serialized comment payload inserted into the document. */ commentJSON: CommentInput; /** Plain-text representation of the comment body. */ text: string; }; /** * Diff payload describing a deleted comment. */ export type CommentDeletedDiff = CommentDiffBase<'deleted'> & { /** Serialized comment payload removed from the document. */ commentJSON: CommentInput; /** Plain-text representation of the removed comment body. */ oldText: string; }; /** * Diff payload describing a modified comment. */ export type CommentModifiedDiff = CommentDiffBase<'modified'> & { /** Serialized comment payload before the change. */ oldCommentJSON: CommentInput; /** Serialized comment payload after the change. */ newCommentJSON: CommentInput; /** Plain-text content before the change. */ oldText: string; /** Plain-text content after the change. */ newText: string; /** Node-level diff for the comment body content. */ contentDiff: NodeDiff[]; /** Attribute-level diff for comment metadata. */ attrsDiff: AttributesDiff | null; }; /** * Union of every diff variant the comment diffing logic can produce. */ export type CommentDiff = CommentAddedDiff | CommentDeletedDiff | CommentModifiedDiff; /** * Comment attributes ignored during metadata diffing and snapshot canonicalization. * * `trackedChangeParentId` is runtime-coupled to tracked-change mark ids, which * may be regenerated between imports of the same DOCX. `documentId`, `fileId`, * and `selection` are non-semantic ownership/runtime fields that must be * stripped before fingerprinting comment state. */ export declare const COMMENT_ATTRS_DIFF_IGNORED_KEYS: string[]; /** * Builds normalized tokens for diffing comment content. * * @param comments Comment payloads to normalize. * @param schema Schema used to build ProseMirror nodes from comment JSON. * @returns Normalized comment tokens. */ export declare function buildCommentTokens(comments: CommentInput[], schema: Schema): CommentToken[]; /** * Computes diffs between two comment lists. * * @param oldComments Previous comment list. * @param newComments Updated comment list. * @param schema Schema used to parse comment bodies. * @returns Comment diff payloads. */ export declare function diffComments(oldComments: CommentInput[], newComments: CommentInput[], schema: Schema): CommentDiff[]; /** * Compares two comment tokens to determine if they represent the same comment. * * @param oldToken Comment token from the old list. * @param newToken Comment token from the new list. * @returns True when comment ids match. */ export declare function commentComparator(oldToken: CommentToken, newToken: CommentToken): boolean; /** * Determines whether equal comment tokens should still be treated as modified. * * @param oldToken Comment token from the old list. * @param newToken Comment token from the new list. * @returns True when content or metadata differs. */ export declare function shouldProcessEqualAsModification(oldToken: CommentToken, newToken: CommentToken): boolean; /** * Determines whether delete/insert pairs should be treated as modifications. * * @returns False because comment ids are treated as stable identities. */ export declare function canTreatAsModification(): boolean; /** * Builds a normalized payload describing a comment addition. * * @param comment Comment token being added. * @returns Diff payload for the added comment. */ export declare function buildAddedCommentDiff(comment: CommentToken): CommentAddedDiff; /** * Builds a normalized payload describing a comment deletion. * * @param comment Comment token being deleted. * @returns Diff payload for the deleted comment. */ export declare function buildDeletedCommentDiff(comment: CommentToken): CommentDeletedDiff; /** * Builds the payload for a comment modification, including inline diffs when possible. * * @param oldComment Comment token from the old list. * @param newComment Comment token from the new list. * @returns Diff payload or null when no changes exist. */ export declare function buildModifiedCommentDiff(oldComment: CommentToken, newComment: CommentToken): CommentModifiedDiff | null; /** * Resolves a stable comment identifier from a comment payload. * * @param comment Comment payload to inspect. * @returns Resolved comment id or null when unavailable. */ export declare function resolveCommentId(comment: CommentInput): string | null; //# sourceMappingURL=comment-diffing.d.ts.map