docx-diff-editor 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/index.d.mts +355 -2
- package/dist/index.d.ts +355 -2
- package/dist/index.js +1624 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1612 -15
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +389 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,8 +6,10 @@ A React component for DOCX document comparison with track changes visualization.
|
|
|
6
6
|
|
|
7
7
|
- 📄 Compare two DOCX documents side by side
|
|
8
8
|
- 🔍 Character-level diff with track changes
|
|
9
|
+
- 📊 **Block-level diffing** for tables, lists, and images
|
|
9
10
|
- ✅ Accept/reject individual changes
|
|
10
11
|
- 🎨 Visual track changes (insert, delete, format)
|
|
12
|
+
- 📋 **Structural Changes Pane** for table rows, list items, images
|
|
11
13
|
- 🤖 Extract enriched change context for LLM processing
|
|
12
14
|
- 📤 Export merged document to DOCX
|
|
13
15
|
|
|
@@ -103,6 +105,9 @@ await editor.setSource({ type: 'doc', content: [...] });
|
|
|
103
105
|
| `className` | `string` | - | Container class |
|
|
104
106
|
| `toolbarClassName` | `string` | - | Toolbar container class |
|
|
105
107
|
| `editorClassName` | `string` | - | Editor container class |
|
|
108
|
+
| `structuralPanePosition` | `StructuralPanePosition` | `'bottom-right'` | Position of structural changes pane |
|
|
109
|
+
| `structuralPaneCollapsed` | `boolean` | `false` | Start with pane collapsed |
|
|
110
|
+
| `hideStructuralPane` | `boolean` | `false` | Hide structural changes pane entirely |
|
|
106
111
|
|
|
107
112
|
### Ref Methods
|
|
108
113
|
|
|
@@ -144,6 +149,9 @@ interface DocxDiffEditorRef {
|
|
|
144
149
|
|
|
145
150
|
// Set document core properties (partial update)
|
|
146
151
|
setProperties(properties: Partial<DocumentProperties>): Promise<boolean>;
|
|
152
|
+
|
|
153
|
+
// Parse HTML to ProseMirror JSON
|
|
154
|
+
parseHtml(html: string): Promise<ProseMirrorJSON>;
|
|
147
155
|
}
|
|
148
156
|
```
|
|
149
157
|
|
|
@@ -155,8 +163,10 @@ interface ComparisonResult {
|
|
|
155
163
|
insertions: number;
|
|
156
164
|
deletions: number;
|
|
157
165
|
formatChanges: number;
|
|
166
|
+
structuralChanges: number; // New: count of structural changes
|
|
158
167
|
summary: string[];
|
|
159
168
|
mergedJson: ProseMirrorJSON;
|
|
169
|
+
structuralChangeInfos: StructuralChangeInfo[]; // New: metadata for pane
|
|
160
170
|
}
|
|
161
171
|
```
|
|
162
172
|
|
|
@@ -244,6 +254,23 @@ await editorRef.current?.setProperties({
|
|
|
244
254
|
});
|
|
245
255
|
```
|
|
246
256
|
|
|
257
|
+
## Parsing HTML to JSON
|
|
258
|
+
|
|
259
|
+
Convert HTML strings to ProseMirror JSON without visible rendering:
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
// Using the ref method (requires editor to be initialized)
|
|
263
|
+
const json = await editorRef.current?.parseHtml('<h1>Title</h1><p>Content here</p>');
|
|
264
|
+
console.log(json); // { type: 'doc', content: [...] }
|
|
265
|
+
|
|
266
|
+
// Use with other methods
|
|
267
|
+
await editorRef.current?.updateContent(json);
|
|
268
|
+
|
|
269
|
+
// Or use the standalone function (requires SuperDoc class)
|
|
270
|
+
import { parseHtmlToJson } from 'docx-diff-editor';
|
|
271
|
+
const json = await parseHtmlToJson(htmlString, SuperDocClass);
|
|
272
|
+
```
|
|
273
|
+
|
|
247
274
|
## Customization
|
|
248
275
|
|
|
249
276
|
### CSS Variables
|
|
@@ -281,6 +308,54 @@ The component supports three types of track changes:
|
|
|
281
308
|
| **Delete** | Red strikethrough | Text removed |
|
|
282
309
|
| **Format** | Gold highlight | Formatting changed |
|
|
283
310
|
|
|
311
|
+
## Structural Changes Pane
|
|
312
|
+
|
|
313
|
+
When comparing documents with structural differences (tables, lists, images), a floating pane appears showing these changes with Accept/Reject controls.
|
|
314
|
+
|
|
315
|
+
### What's Detected
|
|
316
|
+
|
|
317
|
+
| Change Type | Description |
|
|
318
|
+
|-------------|-------------|
|
|
319
|
+
| **Table Rows** | Inserted or deleted rows |
|
|
320
|
+
| **Table Columns** | Added or removed columns |
|
|
321
|
+
| **List Items** | New or removed list items (including nested) |
|
|
322
|
+
| **Paragraphs** | Entire paragraphs added or deleted |
|
|
323
|
+
| **Images** | New or removed images |
|
|
324
|
+
|
|
325
|
+
### Pane Features
|
|
326
|
+
|
|
327
|
+
- **Floating Position**: Configurable position (`top-right`, `bottom-right`, `top-left`, `bottom-left`)
|
|
328
|
+
- **Collapsible**: Click header to minimize to just the title bar
|
|
329
|
+
- **Accept/Reject**: Per-change or bulk actions
|
|
330
|
+
- **Counter Badge**: Shows remaining changes
|
|
331
|
+
- **Auto-Hide**: Disappears when all changes are resolved
|
|
332
|
+
- **Bubble Sync**: Stays in sync when changes are accepted via SuperDoc's bubbles
|
|
333
|
+
|
|
334
|
+
### Configuration
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
<DocxDiffEditor
|
|
338
|
+
ref={editorRef}
|
|
339
|
+
structuralPanePosition="bottom-right" // Position of the pane
|
|
340
|
+
structuralPaneCollapsed={false} // Start expanded
|
|
341
|
+
hideStructuralPane={false} // Show the pane
|
|
342
|
+
/>
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Accessing Structural Changes Programmatically
|
|
346
|
+
|
|
347
|
+
```tsx
|
|
348
|
+
const result = await editorRef.current?.compareWith(newDocument);
|
|
349
|
+
|
|
350
|
+
// Get structural change count
|
|
351
|
+
console.log(`${result.structuralChanges} structural changes detected`);
|
|
352
|
+
|
|
353
|
+
// Access detailed info
|
|
354
|
+
result.structuralChangeInfos.forEach(change => {
|
|
355
|
+
console.log(`${change.type}: ${change.location} - ${change.preview}`);
|
|
356
|
+
});
|
|
357
|
+
```
|
|
358
|
+
|
|
284
359
|
## License
|
|
285
360
|
|
|
286
361
|
Apache 2.0
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import react__default from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Type definitions for DocxDiffEditor
|
|
@@ -54,6 +55,114 @@ interface DiffResult {
|
|
|
54
55
|
/** Human-readable summary */
|
|
55
56
|
summary: string[];
|
|
56
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Type of structural change
|
|
60
|
+
*/
|
|
61
|
+
type StructuralChangeType = 'rowInsert' | 'rowDelete' | 'columnInsert' | 'columnDelete' | 'paragraphInsert' | 'paragraphDelete' | 'listItemInsert' | 'listItemDelete' | 'imageInsert' | 'imageDelete' | 'attrChange';
|
|
62
|
+
/**
|
|
63
|
+
* A structural change (node added/removed/moved)
|
|
64
|
+
*/
|
|
65
|
+
interface StructuralChange {
|
|
66
|
+
/** Unique ID shared across all marks in this structural change */
|
|
67
|
+
id: string;
|
|
68
|
+
/** Type of structural change */
|
|
69
|
+
type: StructuralChangeType;
|
|
70
|
+
/** The node type affected (e.g., 'tableRow', 'paragraph', 'listItem') */
|
|
71
|
+
nodeType: string;
|
|
72
|
+
/** Path to the node in the document tree */
|
|
73
|
+
path: number[];
|
|
74
|
+
/** The affected node */
|
|
75
|
+
node: ProseMirrorJSON;
|
|
76
|
+
/** For moves: original path */
|
|
77
|
+
fromPath?: number[];
|
|
78
|
+
/** For moves: new path */
|
|
79
|
+
toPath?: number[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Single attribute difference
|
|
83
|
+
*/
|
|
84
|
+
interface AttrDiff {
|
|
85
|
+
/** Attribute key (e.g., "borders.top.color") */
|
|
86
|
+
key: string;
|
|
87
|
+
/** Value before the change */
|
|
88
|
+
before: unknown;
|
|
89
|
+
/** Value after the change */
|
|
90
|
+
after: unknown;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* An attribute change on a matched node
|
|
94
|
+
*/
|
|
95
|
+
interface AttributeChange {
|
|
96
|
+
/** Unique ID for this attribute change */
|
|
97
|
+
id: string;
|
|
98
|
+
/** The node type affected */
|
|
99
|
+
nodeType: string;
|
|
100
|
+
/** Path in original document */
|
|
101
|
+
pathA: number[];
|
|
102
|
+
/** Path in new document */
|
|
103
|
+
pathB: number[];
|
|
104
|
+
/** List of attribute differences */
|
|
105
|
+
changes: AttrDiff[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Record of matched nodes between documents
|
|
109
|
+
*/
|
|
110
|
+
interface NodeMatch {
|
|
111
|
+
/** Path in original document */
|
|
112
|
+
pathA: number[];
|
|
113
|
+
/** Path in new document */
|
|
114
|
+
pathB: number[];
|
|
115
|
+
/** Fingerprint used for matching */
|
|
116
|
+
fingerprint: string;
|
|
117
|
+
/** Similarity score (0.0 - 1.0) */
|
|
118
|
+
similarity: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Node with computed fingerprint (used in alignment)
|
|
122
|
+
*/
|
|
123
|
+
interface FingerprintedNode {
|
|
124
|
+
/** The original node */
|
|
125
|
+
node: ProseMirrorJSON;
|
|
126
|
+
/** Content-based fingerprint */
|
|
127
|
+
fingerprint: string;
|
|
128
|
+
/** Path in the document tree */
|
|
129
|
+
path: number[];
|
|
130
|
+
/** Child fingerprinted nodes */
|
|
131
|
+
children?: FingerprintedNode[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Extended diff result with structural awareness
|
|
135
|
+
*/
|
|
136
|
+
interface HybridDiffResult extends DiffResult {
|
|
137
|
+
/** Structural changes (rows, paragraphs, list items added/removed) */
|
|
138
|
+
structuralChanges: StructuralChange[];
|
|
139
|
+
/** Attribute changes on matched nodes */
|
|
140
|
+
attributeChanges: AttributeChange[];
|
|
141
|
+
/** Node matching information (for debugging) */
|
|
142
|
+
nodeMatches: NodeMatch[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Metadata for the Structural Changes Pane
|
|
146
|
+
* Generated during merge, stored in component state
|
|
147
|
+
*/
|
|
148
|
+
interface StructuralChangeInfo {
|
|
149
|
+
/** Shared ID across all marks in this structural change */
|
|
150
|
+
id: string;
|
|
151
|
+
/** Type of structural change */
|
|
152
|
+
type: StructuralChangeType;
|
|
153
|
+
/** The node type affected */
|
|
154
|
+
nodeType: string;
|
|
155
|
+
/** Human-readable location (e.g., "Table 1, Row 3") */
|
|
156
|
+
location: string;
|
|
157
|
+
/** Truncated content preview */
|
|
158
|
+
preview: string;
|
|
159
|
+
/** Author of the change */
|
|
160
|
+
author: TrackChangeAuthor;
|
|
161
|
+
/** ISO timestamp */
|
|
162
|
+
date: string;
|
|
163
|
+
/** For attribute changes, the specific diffs */
|
|
164
|
+
attrChanges?: AttrDiff[];
|
|
165
|
+
}
|
|
57
166
|
/**
|
|
58
167
|
* Result returned after comparing two documents
|
|
59
168
|
*/
|
|
@@ -66,20 +175,33 @@ interface ComparisonResult {
|
|
|
66
175
|
deletions: number;
|
|
67
176
|
/** Number of format changes */
|
|
68
177
|
formatChanges: number;
|
|
178
|
+
/** Number of structural changes (rows, paragraphs, etc.) */
|
|
179
|
+
structuralChanges: number;
|
|
69
180
|
/** Human-readable summary strings */
|
|
70
181
|
summary: string[];
|
|
71
182
|
/** The merged JSON document with track changes */
|
|
72
183
|
mergedJson: ProseMirrorJSON;
|
|
184
|
+
/** Metadata for structural changes (for the pane) */
|
|
185
|
+
structuralChangeInfos: StructuralChangeInfo[];
|
|
73
186
|
}
|
|
74
187
|
/**
|
|
75
188
|
* Location context for a change
|
|
76
189
|
*/
|
|
77
190
|
interface ChangeLocation {
|
|
78
|
-
nodeType: 'heading' | 'paragraph' | 'listItem' | 'tableCell' | 'unknown';
|
|
191
|
+
nodeType: 'heading' | 'paragraph' | 'listItem' | 'tableCell' | 'table' | 'image' | 'unknown';
|
|
79
192
|
headingLevel?: number;
|
|
80
193
|
paragraphIndex?: number;
|
|
81
194
|
sectionTitle?: string;
|
|
82
195
|
description: string;
|
|
196
|
+
/** Table coordinates (for table-related changes) */
|
|
197
|
+
tableCoords?: {
|
|
198
|
+
row: number;
|
|
199
|
+
column: number;
|
|
200
|
+
};
|
|
201
|
+
/** List item index */
|
|
202
|
+
listIndex?: number;
|
|
203
|
+
/** List nesting depth */
|
|
204
|
+
listDepth?: number;
|
|
83
205
|
}
|
|
84
206
|
/**
|
|
85
207
|
* Format change details
|
|
@@ -101,6 +223,20 @@ interface EnrichedChange {
|
|
|
101
223
|
charCount?: number;
|
|
102
224
|
/** The sentence or clause containing the change */
|
|
103
225
|
surroundingText?: string;
|
|
226
|
+
/** Structural change type (for block-level changes) */
|
|
227
|
+
structuralType?: StructuralChangeType;
|
|
228
|
+
/** Attribute changes (for attribute-only changes) */
|
|
229
|
+
attributeChanges?: AttrDiff[];
|
|
230
|
+
/** Table position (for table-related changes) */
|
|
231
|
+
tablePosition?: {
|
|
232
|
+
row: number;
|
|
233
|
+
column: number;
|
|
234
|
+
};
|
|
235
|
+
/** List position (for list-related changes) */
|
|
236
|
+
listPosition?: {
|
|
237
|
+
index: number;
|
|
238
|
+
depth: number;
|
|
239
|
+
};
|
|
104
240
|
}
|
|
105
241
|
/**
|
|
106
242
|
* Author information for track changes
|
|
@@ -153,6 +289,10 @@ interface DocumentInfo {
|
|
|
153
289
|
/** Page count */
|
|
154
290
|
pages: number;
|
|
155
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Position of the structural changes pane
|
|
294
|
+
*/
|
|
295
|
+
type StructuralPanePosition = 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left';
|
|
156
296
|
/**
|
|
157
297
|
* Props for DocxDiffEditor component
|
|
158
298
|
*/
|
|
@@ -181,6 +321,12 @@ interface DocxDiffEditorProps {
|
|
|
181
321
|
toolbarClassName?: string;
|
|
182
322
|
/** Editor container className */
|
|
183
323
|
editorClassName?: string;
|
|
324
|
+
/** Position of structural changes pane (default: 'bottom-right') */
|
|
325
|
+
structuralPanePosition?: StructuralPanePosition;
|
|
326
|
+
/** Start with pane collapsed (default: false) */
|
|
327
|
+
structuralPaneCollapsed?: boolean;
|
|
328
|
+
/** Hide structural changes pane entirely (default: false) */
|
|
329
|
+
hideStructuralPane?: boolean;
|
|
184
330
|
}
|
|
185
331
|
/**
|
|
186
332
|
* Ref methods exposed by DocxDiffEditor
|
|
@@ -216,6 +362,8 @@ interface DocxDiffEditorRef {
|
|
|
216
362
|
getProperties(): Promise<DocumentProperties | null>;
|
|
217
363
|
/** Set document core properties (partial update) */
|
|
218
364
|
setProperties(properties: Partial<DocumentProperties>): Promise<boolean>;
|
|
365
|
+
/** Parse HTML string to ProseMirror JSON (uses hidden SuperDoc instance) */
|
|
366
|
+
parseHtml(html: string): Promise<ProseMirrorJSON>;
|
|
219
367
|
}
|
|
220
368
|
|
|
221
369
|
/**
|
|
@@ -223,6 +371,38 @@ interface DocxDiffEditorRef {
|
|
|
223
371
|
*/
|
|
224
372
|
declare const DocxDiffEditor: react.ForwardRefExoticComponent<DocxDiffEditorProps & react.RefAttributes<DocxDiffEditorRef>>;
|
|
225
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Structural Changes Pane Component
|
|
376
|
+
*
|
|
377
|
+
* A floating, collapsible panel that displays structural changes
|
|
378
|
+
* (table rows, list items, images, etc.) with Accept/Reject controls.
|
|
379
|
+
*
|
|
380
|
+
* Uses SuperDoc's acceptTrackedChangeById/rejectTrackedChangeById commands
|
|
381
|
+
* to handle accept/reject actions.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
interface StructuralChangesPaneProps {
|
|
385
|
+
/** Array of structural changes to display */
|
|
386
|
+
changes: StructuralChangeInfo[];
|
|
387
|
+
/** Position of the pane */
|
|
388
|
+
position?: StructuralPanePosition;
|
|
389
|
+
/** Start collapsed? */
|
|
390
|
+
initiallyCollapsed?: boolean;
|
|
391
|
+
/** Callback when a change is accepted */
|
|
392
|
+
onAccept: (changeId: string) => void;
|
|
393
|
+
/** Callback when a change is rejected */
|
|
394
|
+
onReject: (changeId: string) => void;
|
|
395
|
+
/** Callback when Accept All is clicked */
|
|
396
|
+
onAcceptAll: () => void;
|
|
397
|
+
/** Callback when Reject All is clicked */
|
|
398
|
+
onRejectAll: () => void;
|
|
399
|
+
/** Callback when a change is clicked (for navigation) */
|
|
400
|
+
onNavigate?: (changeId: string) => void;
|
|
401
|
+
/** Callback when pane is dismissed */
|
|
402
|
+
onDismiss?: () => void;
|
|
403
|
+
}
|
|
404
|
+
declare const StructuralChangesPane: react__default.FC<StructuralChangesPaneProps>;
|
|
405
|
+
|
|
226
406
|
/**
|
|
227
407
|
* Content Resolver Service
|
|
228
408
|
* Detects content type and parses DOCX files to ProseMirror JSON.
|
|
@@ -242,6 +422,10 @@ declare function detectContentType(content: DocxContent): 'file' | 'html' | 'jso
|
|
|
242
422
|
* Validate that content looks like ProseMirror JSON
|
|
243
423
|
*/
|
|
244
424
|
declare function isProseMirrorJSON(content: unknown): boolean;
|
|
425
|
+
/**
|
|
426
|
+
* Parse an HTML string into ProseMirror JSON using a hidden SuperDoc instance.
|
|
427
|
+
*/
|
|
428
|
+
declare function parseHtmlToJson(html: string, SuperDoc: SuperDocConstructor): Promise<ProseMirrorJSON>;
|
|
245
429
|
/**
|
|
246
430
|
* Parse a DOCX File into ProseMirror JSON using a hidden SuperDoc instance.
|
|
247
431
|
*/
|
|
@@ -303,12 +487,181 @@ declare function createTrackFormatMark(before: ProseMirrorMark[], after: ProseMi
|
|
|
303
487
|
* Change Context Extractor
|
|
304
488
|
* Extracts enriched changes with semantic context from merged document.
|
|
305
489
|
* Provides surrounding text so the LLM can understand what the change is about.
|
|
490
|
+
*
|
|
491
|
+
* Updated to include structural change information (tables, lists, images).
|
|
306
492
|
*/
|
|
307
493
|
|
|
308
494
|
/**
|
|
309
495
|
* Main entry point - extract enriched changes from merged document
|
|
310
496
|
*/
|
|
311
497
|
declare function extractEnrichedChanges(mergedJson: ProseMirrorJSON): EnrichedChange[];
|
|
498
|
+
/**
|
|
499
|
+
* Extract enriched changes with structural change infos included.
|
|
500
|
+
* This merges inline text changes with structural change metadata.
|
|
501
|
+
*/
|
|
502
|
+
declare function extractEnrichedChangesWithStructural(mergedJson: ProseMirrorJSON, structuralInfos: StructuralChangeInfo[]): EnrichedChange[];
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Node Fingerprint Service
|
|
506
|
+
*
|
|
507
|
+
* Generates content-based fingerprints for ProseMirror nodes.
|
|
508
|
+
* Fingerprints are used to match nodes between documents during diffing.
|
|
509
|
+
*
|
|
510
|
+
* Key principle: Two nodes with the same content (ignoring styles/attrs)
|
|
511
|
+
* should produce the same or similar fingerprints.
|
|
512
|
+
*/
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Generate a fingerprint for a single node.
|
|
516
|
+
*
|
|
517
|
+
* Fingerprint format by node type:
|
|
518
|
+
* - text: "t:{hash}"
|
|
519
|
+
* - paragraph: "p:{hash}"
|
|
520
|
+
* - heading: "h{level}:{hash}"
|
|
521
|
+
* - table: "table:{rowCount}:{hash}"
|
|
522
|
+
* - tableRow: "tr:{cellCount}:{hash}"
|
|
523
|
+
* - tableCell: "tc:{hash}"
|
|
524
|
+
* - listItem: "li:{hash}"
|
|
525
|
+
* - image: "img:{srcHash}"
|
|
526
|
+
* - hardBreak: "br"
|
|
527
|
+
* - horizontalRule: "hr"
|
|
528
|
+
* - other: "{type}:{hash}"
|
|
529
|
+
*/
|
|
530
|
+
declare function generateFingerprint(node: ProseMirrorJSON): string;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Node Aligner Service
|
|
534
|
+
*
|
|
535
|
+
* Aligns nodes between two documents using fingerprints and LCS algorithm.
|
|
536
|
+
* Produces matched pairs, insertions, and deletions.
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Result of aligning two node sequences
|
|
541
|
+
*/
|
|
542
|
+
interface AlignmentResult {
|
|
543
|
+
/** Nodes that match between documents */
|
|
544
|
+
matched: NodeMatch[];
|
|
545
|
+
/** Nodes only in document A (deleted) */
|
|
546
|
+
deletions: FingerprintedNode[];
|
|
547
|
+
/** Nodes only in document B (inserted) */
|
|
548
|
+
insertions: FingerprintedNode[];
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Align top-level blocks between two documents.
|
|
552
|
+
*/
|
|
553
|
+
declare function alignDocuments(docA: ProseMirrorJSON, docB: ProseMirrorJSON): AlignmentResult;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Table Block Differ Service
|
|
557
|
+
*
|
|
558
|
+
* Specialized diffing logic for tables:
|
|
559
|
+
* - Row insertions/deletions
|
|
560
|
+
* - Column insertions/deletions
|
|
561
|
+
* - Cell-level content changes
|
|
562
|
+
* - Table/cell attribute changes
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Result of diffing two tables
|
|
567
|
+
*/
|
|
568
|
+
interface TableDiffResult {
|
|
569
|
+
/** Row-level structural changes */
|
|
570
|
+
rowChanges: StructuralChange[];
|
|
571
|
+
/** Column-level structural changes (detected from cell patterns) */
|
|
572
|
+
columnChanges: StructuralChange[];
|
|
573
|
+
/** Cell-level matches for content diffing */
|
|
574
|
+
cellMatches: NodeMatch[];
|
|
575
|
+
/** Attribute changes on the table itself */
|
|
576
|
+
tableAttrChanges: AttributeChange | null;
|
|
577
|
+
/** Attribute changes on cells */
|
|
578
|
+
cellAttrChanges: AttributeChange[];
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Diff two tables and return all detected changes.
|
|
582
|
+
*/
|
|
583
|
+
declare function diffTables(tableA: ProseMirrorJSON, tableB: ProseMirrorJSON, tablePathA: number[], tablePathB: number[]): TableDiffResult;
|
|
584
|
+
/**
|
|
585
|
+
* Check if a node is a table.
|
|
586
|
+
*/
|
|
587
|
+
declare function isTable(node: ProseMirrorJSON): boolean;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* List Block Differ Service
|
|
591
|
+
*
|
|
592
|
+
* Specialized diffing logic for lists:
|
|
593
|
+
* - List item insertions/deletions
|
|
594
|
+
* - List item reordering detection
|
|
595
|
+
* - Nested list handling
|
|
596
|
+
*/
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Result of diffing two lists
|
|
600
|
+
*/
|
|
601
|
+
interface ListDiffResult {
|
|
602
|
+
/** Item-level structural changes */
|
|
603
|
+
itemChanges: StructuralChange[];
|
|
604
|
+
/** Item matches for content diffing */
|
|
605
|
+
itemMatches: NodeMatch[];
|
|
606
|
+
/** Nested list changes (recursive) */
|
|
607
|
+
nestedChanges: ListDiffResult[];
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Check if a node is a list (ordered or unordered).
|
|
611
|
+
*/
|
|
612
|
+
declare function isList(node: ProseMirrorJSON): boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Diff two lists and return all detected changes.
|
|
615
|
+
*/
|
|
616
|
+
declare function diffLists(listA: ProseMirrorJSON, listB: ProseMirrorJSON, listPathA: number[], listPathB: number[], depth?: number): ListDiffResult;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Non-Text Node Differ Service
|
|
620
|
+
*
|
|
621
|
+
* Handles diffing of atomic non-text nodes:
|
|
622
|
+
* - Images
|
|
623
|
+
* - Horizontal rules
|
|
624
|
+
* - Page breaks
|
|
625
|
+
* - Embedded objects (equations, etc.)
|
|
626
|
+
*/
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Check if a node is an image.
|
|
630
|
+
*/
|
|
631
|
+
declare function isImage(node: ProseMirrorJSON): boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Check if a node is an atomic (non-text, leaf) node.
|
|
634
|
+
*/
|
|
635
|
+
declare function isAtomicNode(node: ProseMirrorJSON): boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Diff images between two documents.
|
|
638
|
+
*/
|
|
639
|
+
declare function diffImages(docA: ProseMirrorJSON, docB: ProseMirrorJSON): {
|
|
640
|
+
inserted: StructuralChange[];
|
|
641
|
+
deleted: StructuralChange[];
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Block Level Merger Service
|
|
646
|
+
*
|
|
647
|
+
* Handles merging of structural changes (tables, lists, images)
|
|
648
|
+
* with shared IDs for all marks within a structural change.
|
|
649
|
+
*
|
|
650
|
+
* This allows the Structural Changes Pane to accept/reject
|
|
651
|
+
* entire structural units (e.g., a whole table row) with a single action.
|
|
652
|
+
*/
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Process structural changes and generate marked blocks with shared IDs.
|
|
656
|
+
*/
|
|
657
|
+
declare function processStructuralChanges(docA: ProseMirrorNode, docB: ProseMirrorNode, author?: TrackChangeAuthor): {
|
|
658
|
+
changes: StructuralChange[];
|
|
659
|
+
infos: StructuralChangeInfo[];
|
|
660
|
+
};
|
|
661
|
+
/**
|
|
662
|
+
* Generate a summary of structural changes.
|
|
663
|
+
*/
|
|
664
|
+
declare function generateStructuralChangeSummary(infos: StructuralChangeInfo[]): string[];
|
|
312
665
|
|
|
313
666
|
/**
|
|
314
667
|
* Constants for DocxDiffEditor
|
|
@@ -363,4 +716,4 @@ declare function getBlankTemplateBlob(): Blob;
|
|
|
363
716
|
*/
|
|
364
717
|
declare function isValidDocxFile(file: File): boolean;
|
|
365
718
|
|
|
366
|
-
export { CSS_PREFIX, type ChangeLocation, type ComparisonResult, DEFAULT_AUTHOR, DEFAULT_SUPERDOC_USER, type DiffResult, type DiffSegment, type DocumentInfo, type DocumentProperties, type DocxContent, DocxDiffEditor, type DocxDiffEditorProps, type DocxDiffEditorRef, type EnrichedChange, type FormatChange, type FormatDetails, type ProseMirrorJSON, type ProseMirrorMark, type ProseMirrorNode, type TrackChangeAuthor, createTrackDeleteMark, createTrackFormatMark, createTrackInsertMark, DocxDiffEditor as default, detectContentType, diffDocuments, extractEnrichedChanges, getBlankTemplateBlob, getBlankTemplateFile, isProseMirrorJSON, isValidDocxFile, mergeDocuments, parseDocxFile };
|
|
719
|
+
export { type AttrDiff, type AttributeChange, CSS_PREFIX, type ChangeLocation, type ComparisonResult, DEFAULT_AUTHOR, DEFAULT_SUPERDOC_USER, type DiffResult, type DiffSegment, type DocumentInfo, type DocumentProperties, type DocxContent, DocxDiffEditor, type DocxDiffEditorProps, type DocxDiffEditorRef, type EnrichedChange, type FingerprintedNode, type FormatChange, type FormatDetails, type HybridDiffResult, type NodeMatch, type ProseMirrorJSON, type ProseMirrorMark, type ProseMirrorNode, type StructuralChange, type StructuralChangeInfo, type StructuralChangeType, StructuralChangesPane, type StructuralPanePosition, type TrackChangeAuthor, alignDocuments, createTrackDeleteMark, createTrackFormatMark, createTrackInsertMark, DocxDiffEditor as default, detectContentType, diffDocuments, diffImages, diffLists, diffTables, extractEnrichedChanges, extractEnrichedChangesWithStructural, generateFingerprint, generateStructuralChangeSummary, getBlankTemplateBlob, getBlankTemplateFile, isAtomicNode, isImage, isList, isProseMirrorJSON, isTable, isValidDocxFile, mergeDocuments, parseDocxFile, parseHtmlToJson, processStructuralChanges };
|