@beyondwork/docx-react-component 1.0.21 → 1.0.23

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 (33) hide show
  1. package/README.md +763 -38
  2. package/package.json +25 -36
  3. package/src/api/public-types.ts +66 -1
  4. package/src/core/commands/index.ts +574 -5
  5. package/src/index.ts +5 -0
  6. package/src/io/docx-session.ts +181 -2
  7. package/src/io/export/serialize-main-document.ts +21 -1
  8. package/src/io/normalize/normalize-text.ts +4 -0
  9. package/src/io/ooxml/parse-main-document.ts +88 -7
  10. package/src/model/canonical-document.ts +22 -0
  11. package/src/review/store/revision-store.ts +1 -0
  12. package/src/review/store/revision-types.ts +2 -0
  13. package/src/runtime/document-runtime.ts +503 -51
  14. package/src/runtime/session-capabilities.ts +6 -5
  15. package/src/runtime/surface-projection.ts +2 -0
  16. package/src/runtime/table-schema.ts +2 -0
  17. package/src/runtime/workflow-markup.ts +5 -1
  18. package/src/ui/WordReviewEditor.tsx +661 -132
  19. package/src/ui/editor-runtime-boundary.ts +10 -1
  20. package/src/ui/editor-shell-view.tsx +8 -0
  21. package/src/ui/editor-surface-controller.tsx +5 -0
  22. package/src/ui/headless/selection-toolbar-model.ts +12 -0
  23. package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +139 -0
  24. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +6 -0
  25. package/src/ui-tailwind/editor-surface/pm-decorations.ts +44 -16
  26. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +2 -0
  27. package/src/ui-tailwind/editor-surface/surface-build-keys.ts +4 -0
  28. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +127 -10
  29. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +82 -1
  30. package/src/ui-tailwind/status/tw-status-bar.tsx +4 -1
  31. package/src/ui-tailwind/theme/editor-theme.css +10 -0
  32. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +21 -5
  33. package/src/ui-tailwind/tw-review-workspace.tsx +110 -32
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@beyondwork/docx-react-component",
3
3
  "publisher": "beyondwork",
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "description": "Embeddable React Word (docx) editor with review, comments, tracked changes, and round-trip OOXML fidelity.",
6
- "packageManager": "pnpm@10.30.3",
7
6
  "type": "module",
8
7
  "sideEffects": [
9
8
  "**/*.css"
@@ -89,30 +88,6 @@
89
88
  "./ui-tailwind/theme/editor-theme.css": "./src/ui-tailwind/theme/editor-theme.css"
90
89
  },
91
90
  "types": "./src/index.ts",
92
- "scripts": {
93
- "build": "tsup",
94
- "test": "bash scripts/run-workspace-tests.sh",
95
- "test:repo": "node scripts/run-repo-tests.mjs core",
96
- "test:repo:all": "node scripts/run-repo-tests.mjs all",
97
- "test:repo:optional": "node scripts/run-repo-tests.mjs optional",
98
- "test:wcag-audit": "node scripts/run-repo-tests.mjs wcag-audit",
99
- "test:harness": "pnpm --filter @docx-react-component/react-word-editor-harness test",
100
- "lint": "pnpm run lint:no-authored-js && pnpm run lint:docs-contracts && pnpm run lint:tsgo && pnpm run lint:tsgo:harness",
101
- "lint:docs-contracts": "bash scripts/check-reference-load-contract.sh",
102
- "lint:no-authored-js": "bash scripts/check-no-authored-js.sh",
103
- "lint:tsgo": "tsgo --noEmit -p tsconfig.build.json",
104
- "lint:tsgo:harness": "pnpm --filter @docx-react-component/react-word-editor-harness lint:tsgo",
105
- "context7:api-check": "bash scripts/context7-export-env.sh run bash scripts/context7-api-check.sh",
106
- "wave:doctor": "bash scripts/context7-export-env.sh run pnpm exec wave doctor --json",
107
- "wave:dry-run": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main --dry-run --no-dashboard",
108
- "wave:launch": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main",
109
- "wave:launch:managed": "bash scripts/wave-launch.sh",
110
- "wave:status": "bash scripts/wave-status.sh",
111
- "wave:watch": "bash scripts/wave-watch.sh --follow",
112
- "wave:dashboard:current": "bash scripts/wave-dashboard-attach.sh current",
113
- "wave:dashboard:global": "bash scripts/wave-dashboard-attach.sh global",
114
- "harness:dev": "pnpm --filter @docx-react-component/react-word-editor-harness dev"
115
- },
116
91
  "keywords": [
117
92
  "docx",
118
93
  "word",
@@ -175,14 +150,28 @@
175
150
  "tsup": "^8.3.0",
176
151
  "tsx": "^4.21.0"
177
152
  },
178
- "pnpm": {
179
- "onlyBuiltDependencies": [
180
- "esbuild",
181
- "sharp"
182
- ],
183
- "overrides": {
184
- "react": "19.2.4",
185
- "react-dom": "19.2.4"
186
- }
153
+ "scripts": {
154
+ "build": "tsup",
155
+ "test": "bash scripts/run-workspace-tests.sh",
156
+ "test:repo": "node scripts/run-repo-tests.mjs core",
157
+ "test:repo:all": "node scripts/run-repo-tests.mjs all",
158
+ "test:repo:optional": "node scripts/run-repo-tests.mjs optional",
159
+ "test:wcag-audit": "node scripts/run-repo-tests.mjs wcag-audit",
160
+ "test:harness": "pnpm --filter @docx-react-component/react-word-editor-harness test",
161
+ "lint": "pnpm run lint:no-authored-js && pnpm run lint:docs-contracts && pnpm run lint:tsgo && pnpm run lint:tsgo:harness",
162
+ "lint:docs-contracts": "bash scripts/check-reference-load-contract.sh",
163
+ "lint:no-authored-js": "bash scripts/check-no-authored-js.sh",
164
+ "lint:tsgo": "tsgo --noEmit -p tsconfig.build.json",
165
+ "lint:tsgo:harness": "pnpm --filter @docx-react-component/react-word-editor-harness lint:tsgo",
166
+ "context7:api-check": "bash scripts/context7-export-env.sh run bash scripts/context7-api-check.sh",
167
+ "wave:doctor": "bash scripts/context7-export-env.sh run pnpm exec wave doctor --json",
168
+ "wave:dry-run": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main --dry-run --no-dashboard",
169
+ "wave:launch": "bash scripts/context7-export-env.sh run pnpm exec wave launch --lane main",
170
+ "wave:launch:managed": "bash scripts/wave-launch.sh",
171
+ "wave:status": "bash scripts/wave-status.sh",
172
+ "wave:watch": "bash scripts/wave-watch.sh --follow",
173
+ "wave:dashboard:current": "bash scripts/wave-dashboard-attach.sh current",
174
+ "wave:dashboard:global": "bash scripts/wave-dashboard-attach.sh global",
175
+ "harness:dev": "pnpm --filter @docx-react-component/react-word-editor-harness dev"
187
176
  }
188
- }
177
+ }
@@ -235,6 +235,7 @@ export interface TrackedChangeEntrySnapshot {
235
235
  label: string;
236
236
  status: "active" | "accepted" | "rejected" | "detached";
237
237
  actionability: "actionable" | "preserve-only";
238
+ storyTarget?: EditorStoryTarget;
238
239
  importedRevisionForm?:
239
240
  | "run-insertion"
240
241
  | "run-deletion"
@@ -552,6 +553,8 @@ export interface SurfaceTableCellSnapshot {
552
553
 
553
554
  export interface SurfaceTableRowSnapshot {
554
555
  cells: SurfaceTableCellSnapshot[];
556
+ gridBefore?: number;
557
+ gridAfter?: number;
555
558
  height?: number;
556
559
  heightRule?: "auto" | "atLeast" | "exact";
557
560
  isHeader?: boolean;
@@ -954,7 +957,8 @@ export interface WorkflowBlockedCommandReason {
954
957
  | "document_read_only"
955
958
  | "document_viewing_mode"
956
959
  | "protected_range"
957
- | "unsupported_surface";
960
+ | "unsupported_surface"
961
+ | "suggesting_unsupported";
958
962
  message: string;
959
963
  scopeId?: string;
960
964
  workItemId?: string;
@@ -971,7 +975,13 @@ export interface WorkflowScopeSnapshot {
971
975
  blockedReasons: WorkflowBlockedCommandReason[];
972
976
  }
973
977
 
978
+ export type EffectiveSelectionMode = WorkflowScopeMode | "blocked";
979
+
974
980
  export interface InteractionGuardSnapshot {
981
+ effectiveMode: EffectiveSelectionMode;
982
+ matchedScopeId?: string;
983
+ matchedScopeMode?: WorkflowScopeMode;
984
+ disabledReason?: string;
975
985
  blockedReasons: WorkflowBlockedCommandReason[];
976
986
  }
977
987
 
@@ -1064,6 +1074,36 @@ export interface WorkflowMarkupSnapshot {
1064
1074
  opaqueFragments: WorkflowOpaqueFragmentMarkup[];
1065
1075
  }
1066
1076
 
1077
+ export type HostAnnotationKind =
1078
+ | "note"
1079
+ | "scope_hint"
1080
+ | "readonly_marker"
1081
+ | "suggestion"
1082
+ | "warning";
1083
+
1084
+ export interface HostAnnotationItem {
1085
+ annotationId: string;
1086
+ kind: HostAnnotationKind;
1087
+ label: string;
1088
+ anchor: EditorAnchorProjection;
1089
+ storyTarget?: EditorStoryTarget;
1090
+ detail?: string;
1091
+ scopeMode?: WorkflowScopeMode;
1092
+ severity?: "low" | "medium" | "high";
1093
+ workItemId?: string;
1094
+ provenance: "host";
1095
+ }
1096
+
1097
+ export interface HostAnnotationOverlay {
1098
+ overlayVersion: "host-annotation-overlay/1";
1099
+ annotations: HostAnnotationItem[];
1100
+ }
1101
+
1102
+ export interface HostAnnotationSnapshot {
1103
+ totalCount: number;
1104
+ annotations: HostAnnotationItem[];
1105
+ }
1106
+
1067
1107
  export interface WorkflowCandidateRangeOptions {
1068
1108
  kinds?: WorkflowMarkupKind[];
1069
1109
  includeDetached?: boolean;
@@ -1177,6 +1217,17 @@ export type WordReviewEditorEvent =
1177
1217
  documentId: string;
1178
1218
  activeWorkItemId: string | null;
1179
1219
  }
1220
+ | {
1221
+ type: "host_annotation_overlay_changed";
1222
+ documentId: string;
1223
+ snapshot: HostAnnotationSnapshot;
1224
+ }
1225
+ | {
1226
+ type: "change_authored";
1227
+ documentId: string;
1228
+ changeId: string;
1229
+ kind: "insertion" | "deletion";
1230
+ }
1180
1231
  | {
1181
1232
  type: "command_blocked";
1182
1233
  documentId: string;
@@ -1327,6 +1378,9 @@ export interface WordReviewEditorRef {
1327
1378
  getWorkflowScopeSnapshot(): WorkflowScopeSnapshot | null;
1328
1379
  getInteractionGuardSnapshot(): InteractionGuardSnapshot;
1329
1380
  getWorkflowMarkupSnapshot(): WorkflowMarkupSnapshot;
1381
+ setHostAnnotationOverlay(overlay: HostAnnotationOverlay): void;
1382
+ clearHostAnnotationOverlay(): void;
1383
+ getHostAnnotationSnapshot(): HostAnnotationSnapshot;
1330
1384
  getWorkflowCandidateRanges(options?: WorkflowCandidateRangeOptions): WorkflowCandidateRange[];
1331
1385
  replaceWorkflowMarkupText(markupId: string, text: string): void;
1332
1386
  }
@@ -1346,6 +1400,7 @@ export interface WordReviewEditorProps {
1346
1400
  reviewMode?: "editing" | "review";
1347
1401
  markupDisplay?: "clean" | "simple" | "all";
1348
1402
  showReviewPanel?: boolean;
1403
+ chromeVisibility?: Partial<WordReviewEditorChromeVisibility>;
1349
1404
  hostAdapter?: EditorHostAdapter;
1350
1405
  datastore?: EditorDatastoreAdapter;
1351
1406
  autosave?: AutosaveConfig;
@@ -1353,3 +1408,13 @@ export interface WordReviewEditorProps {
1353
1408
  onWarning?: (warning: EditorWarning) => void;
1354
1409
  onError?: (error: EditorError) => void;
1355
1410
  }
1411
+
1412
+ export interface WordReviewEditorChromeVisibility {
1413
+ toolbar: boolean;
1414
+ alerts: boolean;
1415
+ selectionOverlay: boolean;
1416
+ contextToolbars: boolean;
1417
+ pageChrome: boolean;
1418
+ statusBar: boolean;
1419
+ reviewRail: boolean;
1420
+ }