@beyondwork/docx-react-component 1.0.28 → 1.0.30
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/package.json +26 -37
- package/src/api/public-types.ts +531 -0
- package/src/api/session-state.ts +2 -0
- package/src/core/commands/index.ts +201 -79
- package/src/core/commands/table-structure-commands.ts +138 -5
- package/src/core/state/text-transaction.ts +370 -3
- package/src/index.ts +41 -0
- package/src/io/docx-session.ts +318 -25
- package/src/io/export/serialize-footnotes.ts +41 -46
- package/src/io/export/serialize-headers-footers.ts +36 -40
- package/src/io/export/serialize-main-document.ts +55 -89
- package/src/io/export/serialize-numbering.ts +104 -4
- package/src/io/export/serialize-runtime-revisions.ts +196 -2
- package/src/io/export/split-story-blocks-for-runtime-revisions.ts +252 -0
- package/src/io/export/table-properties-xml.ts +318 -0
- package/src/io/normalize/normalize-text.ts +34 -3
- package/src/io/ooxml/parse-comments.ts +6 -0
- package/src/io/ooxml/parse-footnotes.ts +69 -13
- package/src/io/ooxml/parse-headers-footers.ts +54 -11
- package/src/io/ooxml/parse-main-document.ts +112 -42
- package/src/io/ooxml/parse-numbering.ts +341 -26
- package/src/io/ooxml/parse-revisions.ts +118 -4
- package/src/io/ooxml/parse-styles.ts +176 -0
- package/src/io/ooxml/parse-tables.ts +34 -25
- package/src/io/ooxml/revision-boundaries.ts +127 -3
- package/src/io/ooxml/workflow-payload.ts +544 -0
- package/src/model/canonical-document.ts +91 -1
- package/src/model/snapshot.ts +112 -1
- package/src/preservation/store.ts +73 -3
- package/src/review/store/comment-store.ts +19 -1
- package/src/review/store/revision-actions.ts +29 -0
- package/src/review/store/revision-store.ts +12 -1
- package/src/review/store/revision-types.ts +11 -0
- package/src/runtime/context-analytics.ts +824 -0
- package/src/runtime/document-locations.ts +521 -0
- package/src/runtime/document-navigation.ts +14 -1
- package/src/runtime/document-outline.ts +440 -0
- package/src/runtime/document-runtime.ts +941 -45
- package/src/runtime/event-refresh-hints.ts +137 -0
- package/src/runtime/numbering-prefix.ts +67 -39
- package/src/runtime/page-layout-estimation.ts +100 -7
- package/src/runtime/resolved-numbering-geometry.ts +293 -0
- package/src/runtime/session-capabilities.ts +2 -2
- package/src/runtime/suggestions-snapshot.ts +137 -0
- package/src/runtime/surface-projection.ts +223 -27
- package/src/runtime/table-style-resolver.ts +409 -0
- package/src/runtime/view-state.ts +17 -1
- package/src/runtime/workflow-markup.ts +54 -14
- package/src/ui/WordReviewEditor.tsx +1269 -87
- package/src/ui/editor-command-bag.ts +7 -0
- package/src/ui/editor-runtime-boundary.ts +111 -10
- package/src/ui/editor-shell-view.tsx +17 -15
- package/src/ui/editor-surface-controller.tsx +5 -0
- package/src/ui/headless/selection-tool-context.ts +19 -0
- package/src/ui/headless/selection-tool-resolver.ts +752 -0
- package/src/ui/headless/selection-tool-types.ts +129 -0
- package/src/ui/headless/selection-toolbar-model.ts +10 -33
- package/src/ui/runtime-shortcut-dispatch.ts +365 -0
- package/src/ui-tailwind/chrome/chrome-preset-model.ts +107 -0
- package/src/ui-tailwind/chrome/chrome-preset-toolbar.tsx +15 -0
- package/src/ui-tailwind/chrome/review-queue-bar.tsx +97 -0
- package/src/ui-tailwind/chrome/tw-context-analytics-summary.tsx +122 -0
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +1 -9
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +1 -5
- package/src/ui-tailwind/chrome/tw-page-ruler.tsx +8 -29
- package/src/ui-tailwind/chrome/tw-selection-tool-blocked.tsx +23 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-comment.tsx +35 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-formatting.tsx +37 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +298 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +116 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-suggestion.tsx +29 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-workflow.tsx +27 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +3 -3
- package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +3 -3
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +86 -14
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +57 -52
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +36 -52
- package/src/ui-tailwind/editor-surface/pm-schema.ts +56 -5
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +87 -24
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +4 -0
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +135 -32
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +74 -7
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +17 -17
- package/src/ui-tailwind/review/tw-review-rail.tsx +19 -17
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +10 -10
- package/src/ui-tailwind/status/tw-status-bar.tsx +10 -6
- package/src/ui-tailwind/theme/editor-theme.css +58 -40
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +4 -4
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +250 -181
- package/src/ui-tailwind/tw-review-workspace.tsx +323 -280
- package/src/validation/compatibility-engine.ts +246 -2
- package/src/validation/docx-comment-proof.ts +24 -11
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type TextStory,
|
|
12
12
|
} from "../schema/text-schema.ts";
|
|
13
13
|
import { createEditorSurfaceSnapshot } from "../../runtime/surface-projection.ts";
|
|
14
|
-
import type { DocumentRootNode, ParagraphNode, TableNode } from "../../model/canonical-document.ts";
|
|
14
|
+
import type { DocumentRootNode, ParagraphNode, SdtNode, TableNode } from "../../model/canonical-document.ts";
|
|
15
15
|
|
|
16
16
|
export type TextInsertion =
|
|
17
17
|
| {
|
|
@@ -72,6 +72,26 @@ export function applyTextTransaction(
|
|
|
72
72
|
timestamp: string;
|
|
73
73
|
},
|
|
74
74
|
): TextTransactionResult {
|
|
75
|
+
const topLevelParagraphResult = tryApplyTopLevelParagraphTransaction(
|
|
76
|
+
document,
|
|
77
|
+
selection,
|
|
78
|
+
intent,
|
|
79
|
+
options,
|
|
80
|
+
);
|
|
81
|
+
if (topLevelParagraphResult) {
|
|
82
|
+
return topLevelParagraphResult;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const sdtScopedResult = tryApplyTopLevelSdtParagraphTransaction(
|
|
86
|
+
document,
|
|
87
|
+
selection,
|
|
88
|
+
intent,
|
|
89
|
+
options,
|
|
90
|
+
);
|
|
91
|
+
if (sdtScopedResult) {
|
|
92
|
+
return sdtScopedResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
75
95
|
const tableScopedResult = tryApplyTableParagraphTransaction(
|
|
76
96
|
document,
|
|
77
97
|
selection,
|
|
@@ -159,7 +179,6 @@ function tryApplyTableParagraphTransaction(
|
|
|
159
179
|
"Text transactions inside table structures are only supported when the selection stays within one paragraph-backed table cell.",
|
|
160
180
|
);
|
|
161
181
|
}
|
|
162
|
-
|
|
163
182
|
const localDocument: CanonicalDocumentEnvelope = {
|
|
164
183
|
...document,
|
|
165
184
|
content: {
|
|
@@ -171,7 +190,12 @@ function tryApplyTableParagraphTransaction(
|
|
|
171
190
|
selection.anchor - scope.paragraphStart,
|
|
172
191
|
selection.head - scope.paragraphStart,
|
|
173
192
|
);
|
|
174
|
-
const localResult = applyLinearTextTransaction(
|
|
193
|
+
const localResult = applyLinearTextTransaction(
|
|
194
|
+
localDocument,
|
|
195
|
+
localSelection,
|
|
196
|
+
localizeTextTransactionIntent(intent, scope.paragraphStart),
|
|
197
|
+
options,
|
|
198
|
+
);
|
|
175
199
|
const nextParagraphBlocks = (localResult.document.content as DocumentRootNode).children;
|
|
176
200
|
const nextRoot: DocumentRootNode = {
|
|
177
201
|
...scope.root,
|
|
@@ -232,6 +256,138 @@ function tryApplyTableParagraphTransaction(
|
|
|
232
256
|
};
|
|
233
257
|
}
|
|
234
258
|
|
|
259
|
+
function tryApplyTopLevelSdtParagraphTransaction(
|
|
260
|
+
document: CanonicalDocumentEnvelope,
|
|
261
|
+
selection: SelectionSnapshot,
|
|
262
|
+
intent: TextTransactionIntent,
|
|
263
|
+
options: {
|
|
264
|
+
timestamp: string;
|
|
265
|
+
},
|
|
266
|
+
): TextTransactionResult | null {
|
|
267
|
+
const scope = resolveTopLevelSdtParagraphScope(document, selection);
|
|
268
|
+
if (!scope) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const localDocument: CanonicalDocumentEnvelope = {
|
|
273
|
+
...document,
|
|
274
|
+
content: {
|
|
275
|
+
type: "doc",
|
|
276
|
+
children: [scope.paragraph],
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
const localSelection = createSelectionSnapshot(
|
|
280
|
+
selection.anchor - scope.paragraphStart,
|
|
281
|
+
selection.head - scope.paragraphStart,
|
|
282
|
+
);
|
|
283
|
+
const localResult = applyLinearTextTransaction(
|
|
284
|
+
localDocument,
|
|
285
|
+
localSelection,
|
|
286
|
+
localizeTextTransactionIntent(intent, scope.paragraphStart),
|
|
287
|
+
options,
|
|
288
|
+
);
|
|
289
|
+
const nextParagraphBlocks = (localResult.document.content as DocumentRootNode).children;
|
|
290
|
+
const nextRoot: DocumentRootNode = {
|
|
291
|
+
...scope.root,
|
|
292
|
+
children: scope.root.children.map((child, blockIndex) => {
|
|
293
|
+
if (blockIndex !== scope.blockIndex) {
|
|
294
|
+
return child;
|
|
295
|
+
}
|
|
296
|
+
return replaceParagraphInSdt(child as SdtNode, scope.childPath, nextParagraphBlocks);
|
|
297
|
+
}),
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
document: {
|
|
302
|
+
...document,
|
|
303
|
+
updatedAt: options.timestamp,
|
|
304
|
+
content: nextRoot,
|
|
305
|
+
},
|
|
306
|
+
selection: createSelectionSnapshot(
|
|
307
|
+
localResult.selection.anchor + scope.paragraphStart,
|
|
308
|
+
localResult.selection.head + scope.paragraphStart,
|
|
309
|
+
),
|
|
310
|
+
mapping: {
|
|
311
|
+
...localResult.mapping,
|
|
312
|
+
steps: localResult.mapping.steps.map((step) => ({
|
|
313
|
+
...step,
|
|
314
|
+
from: step.from + scope.paragraphStart,
|
|
315
|
+
to: step.to + scope.paragraphStart,
|
|
316
|
+
})),
|
|
317
|
+
},
|
|
318
|
+
storyText: localResult.storyText,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function tryApplyTopLevelParagraphTransaction(
|
|
323
|
+
document: CanonicalDocumentEnvelope,
|
|
324
|
+
selection: SelectionSnapshot,
|
|
325
|
+
intent: TextTransactionIntent,
|
|
326
|
+
options: {
|
|
327
|
+
timestamp: string;
|
|
328
|
+
},
|
|
329
|
+
): TextTransactionResult | null {
|
|
330
|
+
const scope = resolveTopLevelParagraphScope(document, selection);
|
|
331
|
+
if (!scope) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
if (
|
|
335
|
+
selection.isCollapsed &&
|
|
336
|
+
((intent.type === "delete_backward" && selection.anchor === scope.paragraphStart) ||
|
|
337
|
+
(intent.type === "delete_forward" && selection.anchor === scope.paragraphEnd))
|
|
338
|
+
) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const localDocument: CanonicalDocumentEnvelope = {
|
|
343
|
+
...document,
|
|
344
|
+
content: {
|
|
345
|
+
type: "doc",
|
|
346
|
+
children: [scope.paragraph],
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
const localSelection = createSelectionSnapshot(
|
|
350
|
+
selection.anchor - scope.paragraphStart,
|
|
351
|
+
selection.head - scope.paragraphStart,
|
|
352
|
+
);
|
|
353
|
+
const localResult = applyLinearTextTransaction(
|
|
354
|
+
localDocument,
|
|
355
|
+
localSelection,
|
|
356
|
+
localizeTextTransactionIntent(intent, scope.paragraphStart),
|
|
357
|
+
options,
|
|
358
|
+
);
|
|
359
|
+
const nextParagraphBlocks = (localResult.document.content as DocumentRootNode).children;
|
|
360
|
+
const nextRoot: DocumentRootNode = {
|
|
361
|
+
...scope.root,
|
|
362
|
+
children: [
|
|
363
|
+
...scope.root.children.slice(0, scope.blockIndex),
|
|
364
|
+
...nextParagraphBlocks,
|
|
365
|
+
...scope.root.children.slice(scope.blockIndex + 1),
|
|
366
|
+
],
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
document: {
|
|
371
|
+
...document,
|
|
372
|
+
updatedAt: options.timestamp,
|
|
373
|
+
content: nextRoot,
|
|
374
|
+
},
|
|
375
|
+
selection: createSelectionSnapshot(
|
|
376
|
+
localResult.selection.anchor + scope.paragraphStart,
|
|
377
|
+
localResult.selection.head + scope.paragraphStart,
|
|
378
|
+
),
|
|
379
|
+
mapping: {
|
|
380
|
+
...localResult.mapping,
|
|
381
|
+
steps: localResult.mapping.steps.map((step) => ({
|
|
382
|
+
...step,
|
|
383
|
+
from: step.from + scope.paragraphStart,
|
|
384
|
+
to: step.to + scope.paragraphStart,
|
|
385
|
+
})),
|
|
386
|
+
},
|
|
387
|
+
storyText: localResult.storyText,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
235
391
|
function resolveTableParagraphScope(
|
|
236
392
|
document: CanonicalDocumentEnvelope,
|
|
237
393
|
selection: SelectionSnapshot,
|
|
@@ -327,6 +483,200 @@ function resolveTableParagraphScope(
|
|
|
327
483
|
return null;
|
|
328
484
|
}
|
|
329
485
|
|
|
486
|
+
function resolveTopLevelParagraphScope(
|
|
487
|
+
document: CanonicalDocumentEnvelope,
|
|
488
|
+
selection: SelectionSnapshot,
|
|
489
|
+
):
|
|
490
|
+
| {
|
|
491
|
+
root: DocumentRootNode;
|
|
492
|
+
blockIndex: number;
|
|
493
|
+
paragraph: ParagraphNode;
|
|
494
|
+
paragraphStart: number;
|
|
495
|
+
paragraphEnd: number;
|
|
496
|
+
}
|
|
497
|
+
| null {
|
|
498
|
+
const root = document.content as DocumentRootNode;
|
|
499
|
+
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const surface = createEditorSurfaceSnapshot(document, selection);
|
|
504
|
+
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
505
|
+
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
506
|
+
|
|
507
|
+
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
508
|
+
const block = root.children[blockIndex];
|
|
509
|
+
const surfaceBlock = surface.blocks[blockIndex];
|
|
510
|
+
if (block?.type !== "paragraph" || surfaceBlock?.kind !== "paragraph") {
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
const insideParagraph = selectionFallsWithinSurfaceRange(
|
|
515
|
+
selectionFrom,
|
|
516
|
+
selectionTo,
|
|
517
|
+
surfaceBlock.from,
|
|
518
|
+
surfaceBlock.to,
|
|
519
|
+
);
|
|
520
|
+
const isCollapsedParagraphTailBeforeTable =
|
|
521
|
+
selectionFrom === selectionTo &&
|
|
522
|
+
selectionFrom === surfaceBlock.to &&
|
|
523
|
+
root.children[blockIndex + 1]?.type === "table";
|
|
524
|
+
if (!insideParagraph && !isCollapsedParagraphTailBeforeTable) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return {
|
|
529
|
+
root,
|
|
530
|
+
blockIndex,
|
|
531
|
+
paragraph: block,
|
|
532
|
+
paragraphStart: surfaceBlock.from,
|
|
533
|
+
paragraphEnd: surfaceBlock.to,
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function resolveTopLevelSdtParagraphScope(
|
|
541
|
+
document: CanonicalDocumentEnvelope,
|
|
542
|
+
selection: SelectionSnapshot,
|
|
543
|
+
):
|
|
544
|
+
| {
|
|
545
|
+
root: DocumentRootNode;
|
|
546
|
+
blockIndex: number;
|
|
547
|
+
childPath: number[];
|
|
548
|
+
paragraph: ParagraphNode;
|
|
549
|
+
paragraphStart: number;
|
|
550
|
+
}
|
|
551
|
+
| null {
|
|
552
|
+
const root = document.content as DocumentRootNode;
|
|
553
|
+
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const surface = createEditorSurfaceSnapshot(document, selection);
|
|
558
|
+
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
559
|
+
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
560
|
+
|
|
561
|
+
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
562
|
+
const block = root.children[blockIndex];
|
|
563
|
+
const surfaceBlock = surface.blocks[blockIndex];
|
|
564
|
+
if (block?.type !== "sdt" || surfaceBlock?.kind !== "sdt_block") {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const nested = resolveParagraphInSdtChildren(
|
|
569
|
+
block.children,
|
|
570
|
+
surfaceBlock.children,
|
|
571
|
+
selectionFrom,
|
|
572
|
+
selectionTo,
|
|
573
|
+
[],
|
|
574
|
+
);
|
|
575
|
+
if (nested) {
|
|
576
|
+
return {
|
|
577
|
+
root,
|
|
578
|
+
blockIndex,
|
|
579
|
+
childPath: nested.childPath,
|
|
580
|
+
paragraph: nested.paragraph,
|
|
581
|
+
paragraphStart: nested.paragraphStart,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function resolveParagraphInSdtChildren(
|
|
590
|
+
blocks: readonly DocumentRootNode["children"][number][],
|
|
591
|
+
surfaceBlocks: readonly {
|
|
592
|
+
kind: string;
|
|
593
|
+
from: number;
|
|
594
|
+
to: number;
|
|
595
|
+
children?: readonly { kind: string; from: number; to: number; children?: readonly unknown[] }[];
|
|
596
|
+
}[],
|
|
597
|
+
selectionFrom: number,
|
|
598
|
+
selectionTo: number,
|
|
599
|
+
path: number[],
|
|
600
|
+
):
|
|
601
|
+
| {
|
|
602
|
+
childPath: number[];
|
|
603
|
+
paragraph: ParagraphNode;
|
|
604
|
+
paragraphStart: number;
|
|
605
|
+
}
|
|
606
|
+
| null {
|
|
607
|
+
for (let index = 0; index < Math.min(blocks.length, surfaceBlocks.length); index += 1) {
|
|
608
|
+
const block = blocks[index];
|
|
609
|
+
const surfaceBlock = surfaceBlocks[index];
|
|
610
|
+
if (!block || !surfaceBlock) {
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (block.type === "paragraph" && surfaceBlock.kind === "paragraph") {
|
|
615
|
+
const insideParagraph = selectionFallsWithinSurfaceRange(
|
|
616
|
+
selectionFrom,
|
|
617
|
+
selectionTo,
|
|
618
|
+
surfaceBlock.from,
|
|
619
|
+
surfaceBlock.to,
|
|
620
|
+
);
|
|
621
|
+
if (insideParagraph) {
|
|
622
|
+
return {
|
|
623
|
+
childPath: [...path, index],
|
|
624
|
+
paragraph: block,
|
|
625
|
+
paragraphStart: surfaceBlock.from,
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (block.type === "sdt" && surfaceBlock.kind === "sdt_block") {
|
|
632
|
+
const nested = resolveParagraphInSdtChildren(
|
|
633
|
+
block.children,
|
|
634
|
+
(surfaceBlock.children ?? []) as {
|
|
635
|
+
kind: string;
|
|
636
|
+
from: number;
|
|
637
|
+
to: number;
|
|
638
|
+
children?: readonly { kind: string; from: number; to: number; children?: readonly unknown[] }[];
|
|
639
|
+
}[],
|
|
640
|
+
selectionFrom,
|
|
641
|
+
selectionTo,
|
|
642
|
+
[...path, index],
|
|
643
|
+
);
|
|
644
|
+
if (nested) {
|
|
645
|
+
return nested;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function replaceParagraphInSdt(
|
|
654
|
+
sdt: SdtNode,
|
|
655
|
+
childPath: number[],
|
|
656
|
+
nextParagraphBlocks: DocumentRootNode["children"],
|
|
657
|
+
): SdtNode {
|
|
658
|
+
if (childPath.length === 0) {
|
|
659
|
+
return sdt;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const [childIndex, ...restPath] = childPath;
|
|
663
|
+
return {
|
|
664
|
+
...sdt,
|
|
665
|
+
children: sdt.children.map((child, index) => {
|
|
666
|
+
if (index !== childIndex) {
|
|
667
|
+
return child;
|
|
668
|
+
}
|
|
669
|
+
if (restPath.length === 0) {
|
|
670
|
+
return nextParagraphBlocks[0] ?? child;
|
|
671
|
+
}
|
|
672
|
+
if (child.type === "sdt") {
|
|
673
|
+
return replaceParagraphInSdt(child, restPath, nextParagraphBlocks);
|
|
674
|
+
}
|
|
675
|
+
return child;
|
|
676
|
+
}),
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
330
680
|
function selectionFallsWithinSurfaceRange(
|
|
331
681
|
selectionFrom: number,
|
|
332
682
|
selectionTo: number,
|
|
@@ -396,6 +746,23 @@ function resolveRange(
|
|
|
396
746
|
};
|
|
397
747
|
}
|
|
398
748
|
|
|
749
|
+
function localizeTextTransactionIntent(
|
|
750
|
+
intent: TextTransactionIntent,
|
|
751
|
+
offset: number,
|
|
752
|
+
): TextTransactionIntent {
|
|
753
|
+
if (intent.type !== "replace" || !intent.range) {
|
|
754
|
+
return intent;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return {
|
|
758
|
+
...intent,
|
|
759
|
+
range: {
|
|
760
|
+
from: intent.range.from - offset,
|
|
761
|
+
to: intent.range.to - offset,
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
399
766
|
function createInsertionUnits(
|
|
400
767
|
intent: TextTransactionIntent,
|
|
401
768
|
story: TextStory,
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type {
|
|
|
11
11
|
EditorSessionState,
|
|
12
12
|
EditorHostAdapter,
|
|
13
13
|
WordReviewEditorProps,
|
|
14
|
+
WordReviewEditorChromePreset,
|
|
15
|
+
WordReviewEditorChromeOptions,
|
|
14
16
|
WordReviewEditorChromeVisibility,
|
|
15
17
|
WordReviewEditorRef,
|
|
16
18
|
EditorUser,
|
|
@@ -50,11 +52,27 @@ export type {
|
|
|
50
52
|
CommentSidebarThreadEntrySnapshot,
|
|
51
53
|
TrackedChangesSnapshot,
|
|
52
54
|
TrackedChangeEntrySnapshot,
|
|
55
|
+
SuggestionsSnapshot,
|
|
56
|
+
SuggestionEntrySnapshot,
|
|
53
57
|
StyleCatalogSnapshot,
|
|
54
58
|
StyleCatalogEntrySnapshot,
|
|
55
59
|
DocumentNavigationSnapshot,
|
|
56
60
|
DocumentPageSnapshot,
|
|
57
61
|
DocumentHeadingSnapshot,
|
|
62
|
+
DocumentLocationSource,
|
|
63
|
+
DocumentLocationSnapshot,
|
|
64
|
+
RestorePointCheckpointType,
|
|
65
|
+
RestorePointSnapshot,
|
|
66
|
+
RestoreResult,
|
|
67
|
+
DocumentOutlineHeadingSnapshot,
|
|
68
|
+
DocumentOutlineSnapshot,
|
|
69
|
+
TocEntrySnapshot,
|
|
70
|
+
TocSnapshot,
|
|
71
|
+
DocumentSectionSnapshot,
|
|
72
|
+
SnapshotRefreshInvalidateTarget,
|
|
73
|
+
SnapshotRefreshStaleTarget,
|
|
74
|
+
SnapshotRefreshChangeKind,
|
|
75
|
+
SnapshotRefreshHints,
|
|
58
76
|
AddCommentParams,
|
|
59
77
|
ExportDocxOptions,
|
|
60
78
|
ExportResult,
|
|
@@ -80,12 +98,17 @@ export type {
|
|
|
80
98
|
WorkflowScope,
|
|
81
99
|
WorkflowWorkItem,
|
|
82
100
|
WorkflowOverlay,
|
|
101
|
+
WorkflowMetadataPersistence,
|
|
102
|
+
WorkflowMetadataDefinition,
|
|
103
|
+
WorkflowMetadataEntry,
|
|
104
|
+
WorkflowMetadataSnapshot,
|
|
83
105
|
WorkflowBlockedCommandReason,
|
|
84
106
|
WorkflowScopeSnapshot,
|
|
85
107
|
InteractionGuardSnapshot,
|
|
86
108
|
WorkflowMarkupKind,
|
|
87
109
|
WorkflowMarkupBase,
|
|
88
110
|
WorkflowHighlightMarkup,
|
|
111
|
+
WorkflowMetadataMarkup,
|
|
89
112
|
WorkflowCommentMarkup,
|
|
90
113
|
WorkflowRevisionMarkup,
|
|
91
114
|
WorkflowFieldMarkup,
|
|
@@ -98,4 +121,22 @@ export type {
|
|
|
98
121
|
HostAnnotationItem,
|
|
99
122
|
HostAnnotationOverlay,
|
|
100
123
|
HostAnnotationSnapshot,
|
|
124
|
+
ReviewQueueItem,
|
|
125
|
+
ReviewQueueItemKind,
|
|
126
|
+
ReviewQueueSnapshot,
|
|
127
|
+
DocumentTextToken,
|
|
128
|
+
StoryTextStreamSnapshot,
|
|
129
|
+
DocumentChunkKind,
|
|
130
|
+
DocumentChunkSnapshot,
|
|
131
|
+
ReviewWorkItemSnapshot,
|
|
132
|
+
ReviewWorkSnapshot,
|
|
133
|
+
RuntimeContextAnalyticsScopeKind,
|
|
134
|
+
RuntimeContextAnalyticsQuery,
|
|
135
|
+
RuntimeContextAnalyticsBadge,
|
|
136
|
+
RuntimeContextAnalyticsActionHint,
|
|
137
|
+
RuntimeContextAnalyticsCounts,
|
|
138
|
+
RuntimeContextAnalyticsState,
|
|
139
|
+
RuntimeContextAnalyticsUnavailableField,
|
|
140
|
+
RuntimeContextAnalyticsProvenance,
|
|
141
|
+
RuntimeContextAnalyticsSnapshot,
|
|
101
142
|
} from "./api/public-types.ts";
|