@beyondwork/docx-react-component 1.0.47 → 1.0.48

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 (53) hide show
  1. package/package.json +1 -1
  2. package/src/api/public-types.ts +115 -1
  3. package/src/compare/diff-engine.ts +4 -0
  4. package/src/core/commands/add-scope.ts +257 -0
  5. package/src/core/commands/formatting-commands.ts +2 -0
  6. package/src/core/schema/text-schema.ts +95 -1
  7. package/src/core/state/text-transaction.ts +17 -5
  8. package/src/io/chart-preview-resolver.ts +27 -0
  9. package/src/io/docx-session.ts +226 -38
  10. package/src/io/export/serialize-main-document.ts +37 -0
  11. package/src/io/export/serialize-settings.ts +421 -0
  12. package/src/io/export/serialize-styles.ts +10 -0
  13. package/src/io/normalize/normalize-text.ts +1 -0
  14. package/src/io/ooxml/chart/parse-axis.ts +277 -0
  15. package/src/io/ooxml/chart/parse-chart-space.ts +813 -0
  16. package/src/io/ooxml/chart/parse-series.ts +570 -0
  17. package/src/io/ooxml/chart/resolve-color.ts +251 -0
  18. package/src/io/ooxml/chart/types.ts +420 -0
  19. package/src/io/ooxml/parse-block-structure.ts +99 -0
  20. package/src/io/ooxml/parse-complex-content.ts +87 -2
  21. package/src/io/ooxml/parse-main-document.ts +115 -1
  22. package/src/io/ooxml/parse-scope-markers.ts +184 -0
  23. package/src/io/ooxml/parse-settings-blueprint.ts +349 -0
  24. package/src/io/ooxml/parse-settings.ts +97 -1
  25. package/src/io/ooxml/parse-styles.ts +65 -0
  26. package/src/io/ooxml/parse-theme.ts +2 -127
  27. package/src/io/ooxml/xml-attr-helpers.ts +59 -1
  28. package/src/io/ooxml/xml-parser.ts +142 -0
  29. package/src/model/canonical-document.ts +94 -0
  30. package/src/model/scope-markers.ts +144 -0
  31. package/src/runtime/collab/base-doc-fingerprint.ts +99 -0
  32. package/src/runtime/collab/checkpoint-election.ts +75 -0
  33. package/src/runtime/collab/checkpoint-scheduler.ts +204 -0
  34. package/src/runtime/collab/checkpoint-store.ts +115 -0
  35. package/src/runtime/collab/event-types.ts +27 -0
  36. package/src/runtime/collab/index.ts +22 -0
  37. package/src/runtime/collab/remote-cursor-awareness.ts +167 -0
  38. package/src/runtime/collab/runtime-collab-sync.ts +279 -0
  39. package/src/runtime/document-runtime.ts +214 -16
  40. package/src/runtime/editor-surface/capabilities.ts +63 -50
  41. package/src/runtime/layout/layout-engine-version.ts +8 -1
  42. package/src/runtime/prerender/cache-envelope.ts +19 -7
  43. package/src/runtime/prerender/cache-key.ts +25 -14
  44. package/src/runtime/prerender/canonical-document-hash.ts +63 -0
  45. package/src/runtime/prerender/customxml-cache.ts +211 -0
  46. package/src/runtime/prerender/customxml-probe.ts +78 -0
  47. package/src/runtime/prerender/prerender-document.ts +74 -7
  48. package/src/runtime/scope-resolver.ts +148 -0
  49. package/src/runtime/scope-tag-registry.ts +10 -0
  50. package/src/runtime/surface-projection.ts +8 -1
  51. package/src/ui/WordReviewEditor.tsx +30 -0
  52. package/src/ui/editor-runtime-boundary.ts +6 -1
  53. package/src/ui/runtime-shortcut-dispatch.ts +12 -7
@@ -494,6 +494,9 @@ export function __createWordReviewEditorRefBridge(
494
494
  deleteComment: (commentId) => {
495
495
  applyRuntimeDeleteComment(runtime, commentId);
496
496
  },
497
+ addScope: (params) => runtime.addScope(params),
498
+ getScope: (scopeId) => runtime.getScope(scopeId),
499
+ removeScope: (scopeId) => runtime.removeScope(scopeId),
497
500
  acceptChange: (changeId) => runtime.acceptChange(changeId),
498
501
  rejectChange: (changeId) => runtime.rejectChange(changeId),
499
502
  acceptAllChanges: () => runtime.acceptAllChanges(),
@@ -1042,6 +1045,12 @@ export const WordReviewEditor = forwardRef<WordReviewEditorRef, WordReviewEditor
1042
1045
  onFindRequested,
1043
1046
  onPrintRequested,
1044
1047
  onZoomRequested,
1048
+ onReplaceRequested,
1049
+ onGoToRequested,
1050
+ onSpellRequested,
1051
+ onThesaurusRequested,
1052
+ onExtendSelectionRequested,
1053
+ onLastEditRequested,
1045
1054
  readOnly = false,
1046
1055
  reviewMode = "review",
1047
1056
  suggestionsEnabled = false,
@@ -1477,6 +1486,9 @@ export const WordReviewEditor = forwardRef<WordReviewEditorRef, WordReviewEditor
1477
1486
  deleteComment: (commentId) => {
1478
1487
  applyRuntimeDeleteComment(activeRuntime, commentId);
1479
1488
  },
1489
+ addScope: (params) => activeRuntime.addScope(params),
1490
+ getScope: (scopeId) => activeRuntime.getScope(scopeId),
1491
+ removeScope: (scopeId) => activeRuntime.removeScope(scopeId),
1480
1492
  acceptChange: (changeId) => activeRuntime.acceptChange(changeId),
1481
1493
  rejectChange: (changeId) => activeRuntime.rejectChange(changeId),
1482
1494
  acceptAllChanges: () => activeRuntime.acceptAllChanges(),
@@ -2608,6 +2620,24 @@ export const WordReviewEditor = forwardRef<WordReviewEditorRef, WordReviewEditor
2608
2620
  shortcut.shortcut === "zoom-out" ? "out" : "reset";
2609
2621
  onZoomRequested(direction);
2610
2622
  handled = true;
2623
+ } else if (shortcut.shortcut === "replace" && onReplaceRequested) {
2624
+ onReplaceRequested({ selectionText: "", selectionRange: snapshot.selection });
2625
+ handled = true;
2626
+ } else if (shortcut.shortcut === "go-to" && onGoToRequested) {
2627
+ onGoToRequested({ selectionText: "", selectionRange: snapshot.selection });
2628
+ handled = true;
2629
+ } else if (shortcut.shortcut === "spell" && onSpellRequested) {
2630
+ onSpellRequested({ selectionText: "", selectionRange: snapshot.selection });
2631
+ handled = true;
2632
+ } else if (shortcut.shortcut === "thesaurus" && onThesaurusRequested) {
2633
+ onThesaurusRequested({ selectionText: "", selectionRange: snapshot.selection });
2634
+ handled = true;
2635
+ } else if (shortcut.shortcut === "extend-selection" && onExtendSelectionRequested) {
2636
+ onExtendSelectionRequested({ selectionText: "", selectionRange: snapshot.selection });
2637
+ handled = true;
2638
+ } else if (shortcut.shortcut === "last-edit" && onLastEditRequested) {
2639
+ onLastEditRequested({ selectionText: "", selectionRange: snapshot.selection });
2640
+ handled = true;
2611
2641
  }
2612
2642
  if (handled) {
2613
2643
  event.preventDefault();
@@ -900,6 +900,11 @@ function createLoadingRuntimeBridge(input: {
900
900
  throw createLoadingBoundaryError(input.snapshot.documentId, "comment");
901
901
  },
902
902
  editCommentBody: () => undefined,
903
+ addScope: () => {
904
+ throw createLoadingBoundaryError(input.snapshot.documentId, "scope");
905
+ },
906
+ getScope: () => null,
907
+ removeScope: () => undefined,
903
908
  acceptChange: () => undefined,
904
909
  rejectChange: () => undefined,
905
910
  acceptAllChanges: () => undefined,
@@ -1016,7 +1021,7 @@ function createLoadingRuntimeBridge(input: {
1016
1021
 
1017
1022
  function createLoadingBoundaryError(
1018
1023
  documentId: string,
1019
- target: "comment" | "session" | "snapshot" | "export",
1024
+ target: "comment" | "session" | "snapshot" | "export" | "scope",
1020
1025
  ): EditorError {
1021
1026
  return {
1022
1027
  errorId: `${documentId}-loading-${target}`,
@@ -23,7 +23,12 @@ export interface SurfaceShortcutContext {
23
23
 
24
24
  export type ShellShortcutResolution =
25
25
  | { kind: "none" }
26
- | { kind: "delegate"; shortcut: "find" | "print" | "zoom-in" | "zoom-out" | "zoom-reset" }
26
+ | { kind: "delegate"; shortcut:
27
+ | "find" | "print"
28
+ | "zoom-in" | "zoom-out" | "zoom-reset"
29
+ | "replace" | "go-to"
30
+ | "spell" | "thesaurus"
31
+ | "extend-selection" | "last-edit" }
27
32
  | { kind: "block"; command: string; reason: WorkflowBlockedCommandReason }
28
33
  | { kind: "history"; history: "undo" | "redo" }
29
34
  | { kind: "focus-region"; direction: 1 | -1 }
@@ -115,14 +120,14 @@ export function resolveShellShortcut(
115
120
  }
116
121
 
117
122
  if (isReplaceShortcut(input, key)) {
118
- return resolveBlockedCapability("replaceText");
123
+ return { kind: "delegate", shortcut: "replace" };
119
124
  }
120
125
 
121
126
  if (
122
127
  isGoToShortcut(input, key) ||
123
128
  (key === "f5" && !input.shiftKey)
124
129
  ) {
125
- return resolveBlockedCapability("goTo");
130
+ return { kind: "delegate", shortcut: "go-to" };
126
131
  }
127
132
 
128
133
  if (isModShiftShortcut(input, key, "e")) {
@@ -130,19 +135,19 @@ export function resolveShellShortcut(
130
135
  }
131
136
 
132
137
  if (key === "f7" && !input.shiftKey) {
133
- return resolveBlockedCapability("checkSpelling");
138
+ return { kind: "delegate", shortcut: "spell" };
134
139
  }
135
140
 
136
141
  if (key === "f7" && input.shiftKey) {
137
- return resolveBlockedCapability("openThesaurus");
142
+ return { kind: "delegate", shortcut: "thesaurus" };
138
143
  }
139
144
 
140
145
  if (key === "f8") {
141
- return resolveBlockedCapability("extendSelection");
146
+ return { kind: "delegate", shortcut: "extend-selection" };
142
147
  }
143
148
 
144
149
  if (key === "f5" && input.shiftKey) {
145
- return resolveBlockedCapability("lastEdit");
150
+ return { kind: "delegate", shortcut: "last-edit" };
146
151
  }
147
152
 
148
153
  return { kind: "none" };