/** * DOCX Module - Document Comparison (Diff) * * Compares two DocxDocument models and returns a list of differences. * This is a text-level comparison — it compares paragraphs by their text content * and reports additions, deletions, and modifications. * * @example * ```ts * import { diffDocuments } from "excelts/word"; * * const changes = diffDocuments(oldDoc, newDoc); * console.log(changes.filter(c => c.type === "modified")); * ``` */ import type { DocxDocument } from "../types.js"; /** Type of change detected between two documents. */ export type DiffChangeType = "added" | "deleted" | "modified" | "unchanged"; /** A single diff entry representing a change between two documents. */ export interface DiffEntry { /** Type of change. */ readonly type: DiffChangeType; /** Paragraph index in the old document (undefined for "added"). */ readonly oldIndex?: number; /** Paragraph index in the new document (undefined for "deleted"). */ readonly newIndex?: number; /** Text content from old document. */ readonly oldText?: string; /** Text content from new document. */ readonly newText?: string; } /** Summary statistics for a diff result. */ export interface DiffSummary { /** Total number of paragraphs compared. */ readonly totalParagraphs: number; /** Number of unchanged paragraphs. */ readonly unchanged: number; /** Number of added paragraphs. */ readonly added: number; /** Number of deleted paragraphs. */ readonly deleted: number; /** Number of modified paragraphs. */ readonly modified: number; } /** Result of a document comparison. */ export interface DiffResult { /** Individual change entries. */ readonly entries: readonly DiffEntry[]; /** Summary statistics. */ readonly summary: DiffSummary; } /** * Compare two DocxDocuments and return a diff of their text content. * * Uses the Myers diff algorithm (LCS-based) for optimal minimal edit sequence. * * @param oldDoc - The original document. * @param newDoc - The modified document. * @returns DiffResult with entries and summary. */ export declare function diffDocuments(oldDoc: DocxDocument, newDoc: DocxDocument): DiffResult;