@beyondwork/docx-react-component 1.0.1 → 1.0.2

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.
Files changed (172) hide show
  1. package/README.md +44 -104
  2. package/package.json +76 -46
  3. package/src/README.md +85 -0
  4. package/src/api/README.md +22 -0
  5. package/src/api/public-types.ts +525 -0
  6. package/src/compare/diff-engine.ts +530 -0
  7. package/src/compare/export-redlines.ts +162 -0
  8. package/src/compare/snapshot.ts +37 -0
  9. package/src/component-inventory.md +99 -0
  10. package/src/core/README.md +10 -0
  11. package/src/core/commands/README.md +3 -0
  12. package/src/core/commands/formatting-commands.ts +161 -0
  13. package/src/core/commands/image-commands.ts +144 -0
  14. package/src/core/commands/index.ts +1013 -0
  15. package/src/core/commands/list-commands.ts +370 -0
  16. package/src/core/commands/review-commands.ts +108 -0
  17. package/src/core/commands/text-commands.ts +119 -0
  18. package/src/core/schema/README.md +3 -0
  19. package/src/core/schema/text-schema.ts +512 -0
  20. package/src/core/selection/README.md +3 -0
  21. package/src/core/selection/mapping.ts +238 -0
  22. package/src/core/selection/review-anchors.ts +94 -0
  23. package/src/core/state/README.md +3 -0
  24. package/src/core/state/editor-state.ts +580 -0
  25. package/src/core/state/text-transaction.ts +276 -0
  26. package/src/formats/xlsx/io/parse-shared-strings.ts +41 -0
  27. package/src/formats/xlsx/io/parse-sheet.ts +289 -0
  28. package/src/formats/xlsx/io/parse-styles.ts +57 -0
  29. package/src/formats/xlsx/io/parse-workbook.ts +75 -0
  30. package/src/formats/xlsx/io/xlsx-session.ts +306 -0
  31. package/src/formats/xlsx/model/cell.ts +189 -0
  32. package/src/formats/xlsx/model/sheet.ts +244 -0
  33. package/src/formats/xlsx/model/styles.ts +118 -0
  34. package/src/formats/xlsx/model/workbook.ts +449 -0
  35. package/src/index.ts +45 -0
  36. package/src/io/README.md +10 -0
  37. package/src/io/docx-session.ts +1763 -0
  38. package/src/io/export/README.md +3 -0
  39. package/src/io/export/export-session.ts +165 -0
  40. package/src/io/export/minimal-docx.ts +115 -0
  41. package/src/io/export/reattach-preserved-parts.ts +54 -0
  42. package/src/io/export/serialize-comments.ts +876 -0
  43. package/src/io/export/serialize-footnotes.ts +217 -0
  44. package/src/io/export/serialize-headers-footers.ts +200 -0
  45. package/src/io/export/serialize-main-document.ts +982 -0
  46. package/src/io/export/serialize-numbering.ts +97 -0
  47. package/src/io/export/serialize-revisions.ts +389 -0
  48. package/src/io/export/serialize-runtime-revisions.ts +265 -0
  49. package/src/io/export/serialize-tables.ts +147 -0
  50. package/src/io/export/split-review-boundaries.ts +194 -0
  51. package/src/io/normalize/README.md +3 -0
  52. package/src/io/normalize/normalize-text.ts +437 -0
  53. package/src/io/ooxml/README.md +3 -0
  54. package/src/io/ooxml/parse-comments.ts +779 -0
  55. package/src/io/ooxml/parse-complex-content.ts +287 -0
  56. package/src/io/ooxml/parse-fields.ts +438 -0
  57. package/src/io/ooxml/parse-footnotes.ts +403 -0
  58. package/src/io/ooxml/parse-headers-footers.ts +483 -0
  59. package/src/io/ooxml/parse-inline-media.ts +431 -0
  60. package/src/io/ooxml/parse-main-document.ts +1846 -0
  61. package/src/io/ooxml/parse-numbering.ts +425 -0
  62. package/src/io/ooxml/parse-revisions.ts +658 -0
  63. package/src/io/ooxml/parse-shapes.ts +271 -0
  64. package/src/io/ooxml/parse-tables.ts +568 -0
  65. package/src/io/ooxml/parse-theme.ts +314 -0
  66. package/src/io/ooxml/part-manifest.ts +136 -0
  67. package/src/io/ooxml/revision-boundaries.ts +351 -0
  68. package/src/io/opc/README.md +3 -0
  69. package/src/io/opc/corrupt-package.ts +166 -0
  70. package/src/io/opc/docx-package.ts +74 -0
  71. package/src/io/opc/package-reader.ts +320 -0
  72. package/src/io/opc/package-writer.ts +273 -0
  73. package/src/legal/bookmarks.ts +196 -0
  74. package/src/legal/cross-references.ts +356 -0
  75. package/src/legal/defined-terms.ts +203 -0
  76. package/src/model/README.md +3 -0
  77. package/src/model/canonical-document.ts +1911 -0
  78. package/src/model/cds-1.0.0.ts +196 -0
  79. package/src/model/snapshot.ts +393 -0
  80. package/src/preservation/README.md +3 -0
  81. package/src/preservation/markup-compatibility.ts +48 -0
  82. package/src/preservation/opaque-fragment-store.ts +89 -0
  83. package/src/preservation/opaque-region.ts +233 -0
  84. package/src/preservation/package-preservation.ts +120 -0
  85. package/src/preservation/preserved-part-manifest.ts +56 -0
  86. package/src/preservation/relationship-retention.ts +57 -0
  87. package/src/preservation/store.ts +185 -0
  88. package/src/review/README.md +16 -0
  89. package/src/review/store/README.md +3 -0
  90. package/src/review/store/comment-anchors.ts +70 -0
  91. package/src/review/store/comment-remapping.ts +154 -0
  92. package/src/review/store/comment-store.ts +331 -0
  93. package/src/review/store/comment-thread.ts +109 -0
  94. package/src/review/store/revision-actions.ts +394 -0
  95. package/src/review/store/revision-store.ts +303 -0
  96. package/src/review/store/revision-types.ts +168 -0
  97. package/src/review/store/runtime-comment-store.ts +43 -0
  98. package/src/runtime/README.md +3 -0
  99. package/src/runtime/ai-action-policy.ts +764 -0
  100. package/src/runtime/document-runtime.ts +967 -0
  101. package/src/runtime/read-only-diagnostics-runtime.ts +232 -0
  102. package/src/runtime/review-runtime.ts +44 -0
  103. package/src/runtime/revision-runtime.ts +107 -0
  104. package/src/runtime/session-capabilities.ts +138 -0
  105. package/src/runtime/surface-projection.ts +570 -0
  106. package/src/runtime/table-commands.ts +87 -0
  107. package/src/runtime/table-schema.ts +140 -0
  108. package/src/runtime/virtualized-rendering.ts +258 -0
  109. package/src/ui/README.md +30 -0
  110. package/src/ui/WordReviewEditor.tsx +1504 -0
  111. package/src/ui/comments/README.md +3 -0
  112. package/src/ui/compatibility/README.md +3 -0
  113. package/src/ui/editor-surface/README.md +3 -0
  114. package/src/ui/headless/comment-decoration-model.ts +124 -0
  115. package/src/ui/headless/revision-decoration-model.ts +128 -0
  116. package/src/ui/headless/selection-helpers.ts +34 -0
  117. package/src/ui/headless/use-editor-keyboard.ts +98 -0
  118. package/src/ui/review/README.md +3 -0
  119. package/src/ui/shared/revision-filters.ts +31 -0
  120. package/src/ui/status/README.md +3 -0
  121. package/src/ui/theme/README.md +3 -0
  122. package/src/ui/toolbar/README.md +3 -0
  123. package/src/ui-tailwind/chrome/tw-alert-banner.tsx +48 -0
  124. package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +44 -0
  125. package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +58 -0
  126. package/src/ui-tailwind/chrome/use-before-unload.ts +20 -0
  127. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +139 -0
  128. package/src/ui-tailwind/editor-surface/pm-decorations.ts +98 -0
  129. package/src/ui-tailwind/editor-surface/pm-position-map.ts +123 -0
  130. package/src/ui-tailwind/editor-surface/pm-schema.ts +452 -0
  131. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +327 -0
  132. package/src/ui-tailwind/editor-surface/search-plugin.ts +157 -0
  133. package/src/ui-tailwind/editor-surface/tw-caret.tsx +12 -0
  134. package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +150 -0
  135. package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +118 -0
  136. package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +52 -0
  137. package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +151 -0
  138. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +215 -0
  139. package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +111 -0
  140. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +122 -0
  141. package/src/ui-tailwind/index.ts +61 -0
  142. package/src/ui-tailwind/review/tw-comment-sidebar.tsx +276 -0
  143. package/src/ui-tailwind/review/tw-health-panel.tsx +120 -0
  144. package/src/ui-tailwind/review/tw-review-rail.tsx +120 -0
  145. package/src/ui-tailwind/review/tw-revision-sidebar.tsx +164 -0
  146. package/src/ui-tailwind/status/tw-status-bar.tsx +58 -0
  147. package/src/ui-tailwind/theme/editor-theme.css +190 -0
  148. package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +48 -0
  149. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +231 -0
  150. package/src/ui-tailwind/tw-review-workspace.tsx +140 -0
  151. package/src/validation/README.md +3 -0
  152. package/src/validation/compatibility-engine.ts +317 -0
  153. package/src/validation/compatibility-report.ts +160 -0
  154. package/src/validation/diagnostics.ts +203 -0
  155. package/src/validation/import-diagnostics.ts +128 -0
  156. package/src/validation/low-priority-word-surfaces.ts +373 -0
  157. package/dist/chunk-32W6IVQE.js +0 -7725
  158. package/dist/chunk-32W6IVQE.js.map +0 -1
  159. package/dist/index.cjs +0 -23722
  160. package/dist/index.cjs.map +0 -1
  161. package/dist/index.d.cts +0 -7
  162. package/dist/index.d.ts +0 -7
  163. package/dist/index.js +0 -16011
  164. package/dist/index.js.map +0 -1
  165. package/dist/public-types-DqCURAz8.d.cts +0 -1152
  166. package/dist/public-types-DqCURAz8.d.ts +0 -1152
  167. package/dist/tailwind.cjs +0 -8295
  168. package/dist/tailwind.cjs.map +0 -1
  169. package/dist/tailwind.d.cts +0 -323
  170. package/dist/tailwind.d.ts +0 -323
  171. package/dist/tailwind.js +0 -553
  172. package/dist/tailwind.js.map +0 -1
@@ -0,0 +1,525 @@
1
+ import type { PersistedEditorSnapshot as RuntimePersistedEditorSnapshot } from "../core/state/editor-state.ts";
2
+
3
+ export type ExternalDocumentSource =
4
+ | {
5
+ kind: "docx";
6
+ bytes: Uint8Array | ArrayBuffer;
7
+ sourceLabel?: string;
8
+ }
9
+ | {
10
+ kind: "snapshot";
11
+ snapshot: PersistedEditorSnapshot;
12
+ sourceLabel?: string;
13
+ };
14
+
15
+ export interface EditorUser {
16
+ userId: string;
17
+ displayName: string;
18
+ email?: string;
19
+ avatarUrl?: string;
20
+ }
21
+
22
+ export type EditorAnchorProjection =
23
+ | {
24
+ kind: "range";
25
+ from: number;
26
+ to: number;
27
+ assoc: {
28
+ start: -1 | 1;
29
+ end: -1 | 1;
30
+ };
31
+ }
32
+ | {
33
+ kind: "node";
34
+ at: number;
35
+ assoc: -1 | 1;
36
+ }
37
+ | {
38
+ kind: "detached";
39
+ lastKnownRange: {
40
+ from: number;
41
+ to: number;
42
+ };
43
+ reason: "deleted" | "invalidatedByStructureChange" | "importAmbiguity";
44
+ };
45
+
46
+ export interface SelectionSnapshot {
47
+ anchor: number;
48
+ head: number;
49
+ isCollapsed: boolean;
50
+ activeRange: EditorAnchorProjection;
51
+ }
52
+
53
+ export interface DocumentStats {
54
+ storyLength: number;
55
+ commentCount: number;
56
+ revisionCount: number;
57
+ opaqueFragmentCount: number;
58
+ }
59
+
60
+ export interface CommentSidebarSnapshot {
61
+ activeCommentId?: string;
62
+ openCommentIds: string[];
63
+ resolvedCommentIds: string[];
64
+ detachedCommentIds: string[];
65
+ totalCount: number;
66
+ threads: CommentSidebarThreadSnapshot[];
67
+ }
68
+
69
+ export interface CommentSidebarThreadEntrySnapshot {
70
+ entryId: string;
71
+ authorId: string;
72
+ body: string;
73
+ createdAt: string;
74
+ }
75
+
76
+ export interface CommentSidebarThreadSnapshot {
77
+ commentId: string;
78
+ status: "open" | "resolved" | "detached";
79
+ anchor: EditorAnchorProjection;
80
+ excerpt: string;
81
+ entryCount: number;
82
+ entries: CommentSidebarThreadEntrySnapshot[];
83
+ createdAt: string;
84
+ createdBy: string;
85
+ warningCount: number;
86
+ anchorLabel: string;
87
+ isActive: boolean;
88
+ resolvedAt?: string;
89
+ resolvedBy?: string;
90
+ }
91
+
92
+ export interface TrackedChangeEntrySnapshot {
93
+ revisionId: string;
94
+ kind: "insertion" | "deletion" | "formatting" | "move" | "property-change";
95
+ label: string;
96
+ status: "active" | "accepted" | "rejected" | "detached";
97
+ actionability: "actionable" | "preserve-only";
98
+ importedRevisionForm?:
99
+ | "run-insertion"
100
+ | "run-deletion"
101
+ | "paragraph-insertion"
102
+ | "paragraph-deletion";
103
+ anchor: EditorAnchorProjection;
104
+ anchorLabel: string;
105
+ createdAt: string;
106
+ authorId: string;
107
+ warningCount: number;
108
+ canAccept: boolean;
109
+ canReject: boolean;
110
+ preserveOnlyReason?: string;
111
+ excerpt?: string;
112
+ detail?: string;
113
+ }
114
+
115
+ export interface TrackedChangesSnapshot {
116
+ pendingChangeIds: string[];
117
+ acceptedChangeIds: string[];
118
+ rejectedChangeIds: string[];
119
+ detachedChangeIds: string[];
120
+ actionableChangeIds: string[];
121
+ preserveOnlyChangeIds: string[];
122
+ totalCount: number;
123
+ revisions: TrackedChangeEntrySnapshot[];
124
+ }
125
+
126
+ export type SurfaceTextMark =
127
+ | "bold"
128
+ | "italic"
129
+ | "underline"
130
+ | "strikethrough";
131
+
132
+ export type SurfaceInlineSegment =
133
+ | {
134
+ segmentId: string;
135
+ kind: "text";
136
+ from: number;
137
+ to: number;
138
+ text: string;
139
+ marks?: SurfaceTextMark[];
140
+ hyperlinkHref?: string;
141
+ }
142
+ | {
143
+ segmentId: string;
144
+ kind: "tab" | "hard_break";
145
+ from: number;
146
+ to: number;
147
+ hyperlinkHref?: string;
148
+ }
149
+ | {
150
+ segmentId: string;
151
+ kind: "image";
152
+ from: number;
153
+ to: number;
154
+ mediaId: string;
155
+ altText?: string;
156
+ state: "editable" | "missing";
157
+ display?: "inline" | "floating";
158
+ detail?: string;
159
+ }
160
+ | {
161
+ segmentId: string;
162
+ kind: "opaque_inline";
163
+ from: number;
164
+ to: number;
165
+ fragmentId: string;
166
+ warningId: string;
167
+ label: string;
168
+ detail: string;
169
+ state: "locked-preserve-only";
170
+ };
171
+
172
+ export interface SurfaceTableCellSnapshot {
173
+ gridSpan: number;
174
+ verticalMerge: "restart" | "continue" | null;
175
+ colspan: number;
176
+ rowspan: number;
177
+ content: SurfaceBlockSnapshot[];
178
+ }
179
+
180
+ export interface SurfaceTableRowSnapshot {
181
+ cells: SurfaceTableCellSnapshot[];
182
+ }
183
+
184
+ export type SurfaceBlockSnapshot =
185
+ | {
186
+ blockId: string;
187
+ kind: "paragraph";
188
+ from: number;
189
+ to: number;
190
+ styleId?: string;
191
+ numbering?: {
192
+ numberingInstanceId: string;
193
+ level: number;
194
+ };
195
+ segments: SurfaceInlineSegment[];
196
+ }
197
+ | {
198
+ blockId: string;
199
+ kind: "table";
200
+ from: number;
201
+ to: number;
202
+ styleId?: string;
203
+ gridColumns: number[];
204
+ rows: SurfaceTableRowSnapshot[];
205
+ }
206
+ | {
207
+ blockId: string;
208
+ kind: "sdt_block";
209
+ from: number;
210
+ to: number;
211
+ sdtType?: string;
212
+ alias?: string;
213
+ tag?: string;
214
+ lock?: string;
215
+ children: SurfaceBlockSnapshot[];
216
+ }
217
+ | {
218
+ blockId: string;
219
+ kind: "opaque_block";
220
+ from: number;
221
+ to: number;
222
+ fragmentId: string;
223
+ warningId: string;
224
+ label: string;
225
+ detail: string;
226
+ state: "locked-preserve-only";
227
+ };
228
+
229
+ export interface EditorSurfaceSnapshot {
230
+ storySize: number;
231
+ plainText: string;
232
+ blocks: SurfaceBlockSnapshot[];
233
+ lockedFragmentIds: string[];
234
+ }
235
+
236
+ export type EditorWarningCode =
237
+ | "unsupported_ooxml_preserved"
238
+ | "unsupported_ooxml_locked"
239
+ | "import_normalized"
240
+ | "export_roundtrip_risk"
241
+ | "comment_anchor_detached"
242
+ | "revision_anchor_detached"
243
+ | "large_document_degraded"
244
+ | "font_substitution"
245
+ | "image_missing";
246
+
247
+ export interface EditorWarning {
248
+ warningId: string;
249
+ code: EditorWarningCode;
250
+ severity: "info" | "warning";
251
+ message: string;
252
+ source:
253
+ | "import"
254
+ | "runtime"
255
+ | "review"
256
+ | "preservation"
257
+ | "validation"
258
+ | "export";
259
+ affectedAnchor?: EditorAnchorProjection;
260
+ featureEntryId?: string;
261
+ details?: Record<string, unknown>;
262
+ }
263
+
264
+ export type EditorErrorCode =
265
+ | "import_failed"
266
+ | "export_failed"
267
+ | "package_corrupt"
268
+ | "validation_failed"
269
+ | "datastore_failed"
270
+ | "internal_invariant";
271
+
272
+ export interface EditorError {
273
+ errorId: string;
274
+ code: EditorErrorCode;
275
+ message: string;
276
+ isFatal: boolean;
277
+ source: "import" | "runtime" | "validation" | "datastore" | "export";
278
+ details?: Record<string, unknown>;
279
+ }
280
+
281
+ export type CompatibilityFeatureClass =
282
+ | "supported-roundtrip"
283
+ | "preserve-only"
284
+ | "unsupported-fatal";
285
+
286
+ export interface CompatibilityFeatureEntry {
287
+ featureEntryId: string;
288
+ featureKey: string;
289
+ featureClass: CompatibilityFeatureClass;
290
+ message: string;
291
+ affectedAnchor?: EditorAnchorProjection;
292
+ details?: Record<string, unknown>;
293
+ }
294
+
295
+ export interface CompatibilityReport {
296
+ reportVersion: "compatibility-report/1";
297
+ generatedAt: string;
298
+ blockExport: boolean;
299
+ featureEntries: CompatibilityFeatureEntry[];
300
+ warnings: EditorWarning[];
301
+ errors: EditorError[];
302
+ }
303
+
304
+ export interface CompatibilityPanelSnapshot {
305
+ blockExport: boolean;
306
+ blockExportReasons: string[];
307
+ warningCount: number;
308
+ errorCount: number;
309
+ featureEntries: CompatibilityFeatureEntry[];
310
+ }
311
+
312
+ export interface CommandStateSnapshot {
313
+ canUndo: boolean;
314
+ canRedo: boolean;
315
+ readOnly: boolean;
316
+ }
317
+
318
+ export interface RuntimeRenderSnapshot {
319
+ documentId: string;
320
+ sessionId: string;
321
+ sourceLabel?: string;
322
+ revisionToken: string;
323
+ isReady: boolean;
324
+ isDirty: boolean;
325
+ readOnly: boolean;
326
+ selection: SelectionSnapshot;
327
+ documentStats: DocumentStats;
328
+ comments: CommentSidebarSnapshot;
329
+ trackedChanges: TrackedChangesSnapshot;
330
+ compatibility: CompatibilityPanelSnapshot;
331
+ warnings: EditorWarning[];
332
+ fatalError?: EditorError;
333
+ commandState: CommandStateSnapshot;
334
+ surface?: EditorSurfaceSnapshot;
335
+ }
336
+
337
+ export interface PersistedEditorSnapshot {
338
+ snapshotVersion: RuntimePersistedEditorSnapshot["snapshotVersion"];
339
+ schemaVersion: RuntimePersistedEditorSnapshot["schemaVersion"];
340
+ documentId: string;
341
+ docId: string;
342
+ createdAt: string;
343
+ updatedAt: string;
344
+ savedAt: string;
345
+ editorBuild: string;
346
+ canonicalDocument: RuntimePersistedEditorSnapshot["canonicalDocument"];
347
+ compatibility: CompatibilityReport;
348
+ warningLog: EditorWarning[];
349
+ }
350
+
351
+ export interface AddCommentParams {
352
+ anchor?: EditorAnchorProjection;
353
+ body?: string;
354
+ authorId?: string;
355
+ }
356
+
357
+ export interface ExportDocxOptions {
358
+ fileName?: string;
359
+ reason?: string;
360
+ }
361
+
362
+ export interface ExportResult {
363
+ bytes: Uint8Array;
364
+ mimeType: string;
365
+ fileName: string;
366
+ }
367
+
368
+ export type AutosaveState =
369
+ | { status: "idle" }
370
+ | { status: "saving" }
371
+ | { status: "saved"; savedAt: string }
372
+ | { status: "error"; error: EditorError };
373
+
374
+ export interface AutosaveConfig {
375
+ enabled?: boolean;
376
+ debounceMs?: number;
377
+ }
378
+
379
+ export type WordReviewEditorEvent =
380
+ | {
381
+ type: "ready";
382
+ documentId: string;
383
+ sessionId: string;
384
+ source: "docx" | "snapshot" | "datastore" | "canonical";
385
+ stats: DocumentStats;
386
+ compatibility: CompatibilityReport;
387
+ }
388
+ | {
389
+ type: "dirty_changed";
390
+ documentId: string;
391
+ isDirty: boolean;
392
+ }
393
+ | {
394
+ type: "selection_changed";
395
+ documentId: string;
396
+ selection: SelectionSnapshot;
397
+ }
398
+ | {
399
+ type: "comment_added";
400
+ documentId: string;
401
+ commentId: string;
402
+ anchor: EditorAnchorProjection;
403
+ }
404
+ | {
405
+ type: "comment_resolved";
406
+ documentId: string;
407
+ commentId: string;
408
+ }
409
+ | {
410
+ type: "change_accepted";
411
+ documentId: string;
412
+ changeId: string;
413
+ }
414
+ | {
415
+ type: "change_rejected";
416
+ documentId: string;
417
+ changeId: string;
418
+ }
419
+ | {
420
+ type: "warning_added";
421
+ documentId: string;
422
+ warning: EditorWarning;
423
+ }
424
+ | {
425
+ type: "warning_cleared";
426
+ documentId: string;
427
+ warningId: string;
428
+ code: EditorWarningCode;
429
+ }
430
+ | {
431
+ type: "error";
432
+ documentId: string;
433
+ error: EditorError;
434
+ }
435
+ | {
436
+ type: "autosave_state";
437
+ documentId: string;
438
+ state: AutosaveState;
439
+ }
440
+ | {
441
+ type: "snapshot_saved";
442
+ documentId: string;
443
+ snapshot: PersistedEditorSnapshot;
444
+ isAutosave: boolean;
445
+ }
446
+ | {
447
+ type: "export_completed";
448
+ documentId: string;
449
+ result: ExportResult;
450
+ };
451
+
452
+ export interface LoadResult {
453
+ source?: ExternalDocumentSource;
454
+ }
455
+
456
+ export interface SaveSnapshotParams {
457
+ documentId: string;
458
+ snapshot: PersistedEditorSnapshot;
459
+ isAutosave: boolean;
460
+ }
461
+
462
+ export interface SaveSnapshotResult {
463
+ savedAt: string;
464
+ }
465
+
466
+ export interface SaveExportParams {
467
+ documentId: string;
468
+ result: ExportResult;
469
+ }
470
+
471
+ export interface SaveExportResult {
472
+ savedAt: string;
473
+ }
474
+
475
+ export interface EditorTelemetryEvent {
476
+ type: string;
477
+ documentId: string;
478
+ detail?: Record<string, unknown>;
479
+ }
480
+
481
+ export interface EditorDatastoreAdapter {
482
+ load(params: { documentId: string }): Promise<LoadResult>;
483
+ saveSnapshot(params: SaveSnapshotParams): Promise<SaveSnapshotResult>;
484
+ saveExport(params: SaveExportParams): Promise<SaveExportResult>;
485
+ logEvent?(event: EditorTelemetryEvent): void;
486
+ }
487
+
488
+ export interface WordReviewEditorRef {
489
+ focus(): void;
490
+ blur(): void;
491
+ undo(): void;
492
+ redo(): void;
493
+ addComment(params: AddCommentParams): string;
494
+ openComment(commentId: string): void;
495
+ resolveComment(commentId: string): void;
496
+ reopenComment(commentId: string): void;
497
+ addCommentReply(commentId: string, body: string): void;
498
+ editCommentBody(commentId: string, body: string): void;
499
+ acceptChange(changeId: string): void;
500
+ rejectChange(changeId: string): void;
501
+ acceptAllChanges(): void;
502
+ rejectAllChanges(): void;
503
+ exportDocx(options?: ExportDocxOptions): Promise<ExportResult>;
504
+ getSnapshot(): PersistedEditorSnapshot;
505
+ getCompatibilityReport(): CompatibilityReport;
506
+ getWarnings(): EditorWarning[];
507
+ }
508
+
509
+ export interface WordReviewEditorProps {
510
+ documentId: string;
511
+ currentUser: EditorUser;
512
+ initialDocx?: Uint8Array | ArrayBuffer;
513
+ initialSnapshot?: PersistedEditorSnapshot;
514
+ initialSourceLabel?: string;
515
+ externalDocumentRevision?: string;
516
+ externalDocSource?: ExternalDocumentSource;
517
+ readOnly?: boolean;
518
+ reviewMode?: "editing" | "review";
519
+ markupDisplay?: "clean" | "simple" | "all";
520
+ datastore?: EditorDatastoreAdapter;
521
+ autosave?: AutosaveConfig;
522
+ onEvent?: (event: WordReviewEditorEvent) => void;
523
+ onWarning?: (warning: EditorWarning) => void;
524
+ onError?: (error: EditorError) => void;
525
+ }