@beyondwork/docx-react-component 1.0.0 → 1.0.1
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/dist/chunk-32W6IVQE.js +7725 -0
- package/dist/chunk-32W6IVQE.js.map +1 -0
- package/dist/index.cjs +23722 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +16011 -0
- package/dist/index.js.map +1 -0
- package/dist/public-types-DqCURAz8.d.cts +1152 -0
- package/dist/public-types-DqCURAz8.d.ts +1152 -0
- package/dist/tailwind.cjs +8295 -0
- package/dist/tailwind.cjs.map +1 -0
- package/dist/tailwind.d.cts +323 -0
- package/dist/tailwind.d.ts +323 -0
- package/dist/tailwind.js +553 -0
- package/dist/tailwind.js.map +1 -0
- package/package.json +52 -31
- package/.codex/config.toml +0 -5
- package/.corepack/v1/pnpm/10.30.3/.corepack +0 -1
- package/.corepack/v1/pnpm/10.30.3/LICENSE +0 -22
- package/.corepack/v1/pnpm/10.30.3/README.md +0 -240
- package/.corepack/v1/pnpm/10.30.3/dist/node-gyp-bin/node-gyp +0 -6
- package/.corepack/v1/pnpm/10.30.3/dist/node-gyp-bin/node-gyp.cmd +0 -5
- package/.corepack/v1/pnpm/10.30.3/dist/pnpm.cjs +0 -195400
- package/.corepack/v1/pnpm/10.30.3/dist/pnpmrc +0 -2
- package/.corepack/v1/pnpm/10.30.3/dist/reflink.darwin-arm64-2HJ4WGO6.node +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/reflink.darwin-x64-3G3H6IW4.node +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/reflink.win32-arm64-msvc-Q6BARPPB.node +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/reflink.win32-x64-msvc-J2TZHRQI.node +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/templates/completion.bash +0 -31
- package/.corepack/v1/pnpm/10.30.3/dist/templates/completion.fish +0 -22
- package/.corepack/v1/pnpm/10.30.3/dist/templates/completion.ps1 +0 -193
- package/.corepack/v1/pnpm/10.30.3/dist/templates/completion.zsh +0 -27
- package/.corepack/v1/pnpm/10.30.3/dist/vendor/fastlist-0.3.0-x64.exe +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/vendor/fastlist-0.3.0-x86.exe +0 -0
- package/.corepack/v1/pnpm/10.30.3/dist/worker.js +0 -10119
- package/.corepack/v1/pnpm/10.30.3/package.json +0 -192
- package/.cursor/mcp.json +0 -7
- package/.github/workflows/ci.yml +0 -35
- package/.mcp.json +0 -7
- package/.openclaw/workspace-state.json +0 -4
- package/.pnpmrc.json +0 -1
- package/.wave-launch.sh +0 -7
- package/.workspace-marker +0 -1
- package/AGENTS.md +0 -78
- package/CHANGELOG.md +0 -177
- package/DESIGN.md +0 -929
- package/HEARTBEAT.md +0 -7
- package/IDENTITY.md +0 -23
- package/SOUL.md +0 -36
- package/TOOLS.md +0 -40
- package/USER.md +0 -17
- package/docs/README.md +0 -107
- package/docs/agents/wave-cont-eval-role.md +0 -36
- package/docs/agents/wave-cont-qa-role.md +0 -52
- package/docs/agents/wave-deploy-verifier-role.md +0 -34
- package/docs/agents/wave-design-role.md +0 -47
- package/docs/agents/wave-documentation-role.md +0 -34
- package/docs/agents/wave-infra-role.md +0 -34
- package/docs/agents/wave-integration-role.md +0 -37
- package/docs/agents/wave-launcher-role.md +0 -41
- package/docs/agents/wave-orchestrator-role.md +0 -52
- package/docs/agents/wave-planner-role.md +0 -39
- package/docs/agents/wave-security-role.md +0 -40
- package/docs/architecture/docx/README.md +0 -10
- package/docs/architecture/future/README.md +0 -8
- package/docs/architecture/ooxml-upgrade-analysis.md +0 -134
- package/docs/architecture/platform/shared-openxml-editor-platform.md +0 -153
- package/docs/architecture/xlsx/canonical-workbook-model-and-commands.md +0 -187
- package/docs/architecture/xlsx/spreadsheet-editor-frontend-architecture.md +0 -150
- package/docs/comment-redline-overview.md +0 -350
- package/docs/concepts/context7-vs-skills.md +0 -118
- package/docs/concepts/operating-modes.md +0 -91
- package/docs/concepts/runtime-agnostic-orchestration.md +0 -111
- package/docs/concepts/what-is-a-wave.md +0 -217
- package/docs/context7/bundles.json +0 -222
- package/docs/context7/planner-agent/README.md +0 -28
- package/docs/context7/planner-agent/manifest.json +0 -83
- package/docs/context7/planner-agent/papers/cooperbench-why-coding-agents-cannot-be-your-teammates-yet.md +0 -3283
- package/docs/context7/planner-agent/papers/dova-deliberation-first-multi-agent-orchestration-for-autonomous-research-automation.md +0 -1699
- package/docs/context7/planner-agent/papers/dpbench-large-language-models-struggle-with-simultaneous-coordination.md +0 -2251
- package/docs/context7/planner-agent/papers/incremental-planning-to-control-a-blackboard-based-problem-solver.md +0 -1729
- package/docs/context7/planner-agent/papers/silo-bench-a-scalable-environment-for-evaluating-distributed-coordination-in-multi-agent-llm-systems.md +0 -3747
- package/docs/context7/planner-agent/papers/todoevolve-learning-to-architect-agent-planning-systems.md +0 -1675
- package/docs/context7/planner-agent/papers/verified-multi-agent-orchestration-a-plan-execute-verify-replan-framework-for-complex-query-resolution.md +0 -1173
- package/docs/context7/planner-agent/papers/why-do-multi-agent-llm-systems-fail.md +0 -5211
- package/docs/context7/planner-agent/topics/planning-and-orchestration.md +0 -24
- package/docs/evals/arm-templates/README.md +0 -13
- package/docs/evals/arm-templates/full-wave.json +0 -15
- package/docs/evals/arm-templates/single-agent.json +0 -15
- package/docs/evals/benchmark-catalog.json +0 -670
- package/docs/evals/cases/README.md +0 -47
- package/docs/evals/cases/wave-blackboard-inbox-targeting.json +0 -73
- package/docs/evals/cases/wave-contradiction-conflict.json +0 -104
- package/docs/evals/cases/wave-expert-routing-preservation.json +0 -69
- package/docs/evals/cases/wave-hidden-profile-private-evidence.json +0 -81
- package/docs/evals/cases/wave-premature-closure-guard.json +0 -71
- package/docs/evals/cases/wave-silo-cross-agent-state.json +0 -77
- package/docs/evals/cases/wave-simultaneous-lockstep.json +0 -92
- package/docs/evals/external-benchmarks.json +0 -85
- package/docs/evals/external-command-config.sample.json +0 -9
- package/docs/evals/external-command-config.swe-bench-pro.json +0 -8
- package/docs/evals/pilots/README.md +0 -47
- package/docs/evals/pilots/swe-bench-pro-public-full-wave-review-10.json +0 -64
- package/docs/evals/pilots/swe-bench-pro-public-pilot.json +0 -111
- package/docs/evals/wave-benchmark-program.md +0 -302
- package/docs/guides/planner.md +0 -220
- package/docs/guides/recommendations-0.8.9.md +0 -133
- package/docs/guides/signal-wrappers.md +0 -165
- package/docs/guides/terminal-surfaces.md +0 -96
- package/docs/image copy.png +0 -0
- package/docs/image.png +0 -0
- package/docs/images/image.png +0 -0
- package/docs/legal-feedback-architecture.md +0 -498
- package/docs/plans/component-cutover-matrix.json +0 -1072
- package/docs/plans/component-cutover-matrix.md +0 -307
- package/docs/plans/context7-wave-orchestrator.md +0 -155
- package/docs/plans/current-state.md +0 -198
- package/docs/plans/docx/README.md +0 -9
- package/docs/plans/examples/wave-benchmark-improvement.md +0 -108
- package/docs/plans/examples/wave-example-live-proof.md +0 -435
- package/docs/plans/master-plan.md +0 -224
- package/docs/plans/migration.md +0 -538
- package/docs/plans/operations/README.md +0 -7
- package/docs/plans/operations/wave-10-word-certification.md +0 -87
- package/docs/plans/operations/wave-8-railway-staging.md +0 -153
- package/docs/plans/operations/wave-9-manual-certification.md +0 -73
- package/docs/plans/platform/README.md +0 -9
- package/docs/plans/reference/legal-checklist-coverage.md +0 -258
- package/docs/plans/wave-orchestrator.md +0 -423
- package/docs/plans/waves/README.md +0 -75
- package/docs/plans/waves/completed/wave-0.md +0 -195
- package/docs/plans/waves/completed/wave-1.md +0 -379
- package/docs/plans/waves/completed/wave-10.md +0 -670
- package/docs/plans/waves/completed/wave-11.md +0 -335
- package/docs/plans/waves/completed/wave-12.md +0 -417
- package/docs/plans/waves/completed/wave-13.md +0 -316
- package/docs/plans/waves/completed/wave-14.md +0 -319
- package/docs/plans/waves/completed/wave-15.md +0 -321
- package/docs/plans/waves/completed/wave-16.md +0 -316
- package/docs/plans/waves/completed/wave-17.md +0 -331
- package/docs/plans/waves/completed/wave-18.md +0 -328
- package/docs/plans/waves/completed/wave-2.md +0 -438
- package/docs/plans/waves/completed/wave-3.md +0 -435
- package/docs/plans/waves/completed/wave-4.md +0 -430
- package/docs/plans/waves/completed/wave-5.md +0 -430
- package/docs/plans/waves/completed/wave-6.md +0 -430
- package/docs/plans/waves/completed/wave-7.md +0 -526
- package/docs/plans/waves/completed/wave-8.md +0 -596
- package/docs/plans/waves/completed/wave-9.md +0 -552
- package/docs/plans/waves/deferred/README.md +0 -14
- package/docs/plans/waves/deferred/encrypted-intake-contracts.md +0 -282
- package/docs/plans/waves/deferred/legal-feedback-wave-expansion.md +0 -308
- package/docs/plans/waves/deferred/wave-encrypted-intake.md +0 -451
- package/docs/plans/waves/design/README.md +0 -5
- package/docs/plans/waves/design/wave-1-a1.md +0 -309
- package/docs/plans/waves/reviews/README.md +0 -5
- package/docs/plans/waves/reviews/wave-0-cont-qa.md +0 -151
- package/docs/plans/waves/reviews/wave-1-cont-qa.md +0 -46
- package/docs/plans/waves/reviews/wave-10-accessibility-and-design.md +0 -51
- package/docs/plans/waves/reviews/wave-10-cont-qa.md +0 -24
- package/docs/plans/waves/reviews/wave-10-dashboard-proof.md +0 -46
- package/docs/plans/waves/reviews/wave-10-performance-signoff.md +0 -55
- package/docs/plans/waves/reviews/wave-10-regression-proof.md +0 -23
- package/docs/plans/waves/reviews/wave-10-release-audit.md +0 -31
- package/docs/plans/waves/reviews/wave-10-service-proof.md +0 -83
- package/docs/plans/waves/reviews/wave-10-word-certification.md +0 -31
- package/docs/plans/waves/reviews/wave-18-ai-contract-closure.md +0 -277
- package/docs/plans/waves/reviews/wave-18-cont-qa.md +0 -255
- package/docs/plans/waves/reviews/wave-18-parity-proof.md +0 -271
- package/docs/plans/waves/reviews/wave-19-cont-qa.md +0 -59
- package/docs/plans/waves/reviews/wave-2-cont-qa.md +0 -72
- package/docs/plans/waves/reviews/wave-20-cont-qa.md +0 -60
- package/docs/plans/waves/reviews/wave-25-cont-qa.md +0 -48
- package/docs/plans/waves/reviews/wave-28-cont-qa.md +0 -46
- package/docs/plans/waves/reviews/wave-29-cont-qa.md +0 -53
- package/docs/plans/waves/reviews/wave-3-cont-qa.md +0 -53
- package/docs/plans/waves/reviews/wave-3-core-proof.md +0 -77
- package/docs/plans/waves/reviews/wave-3-validator-proof.md +0 -73
- package/docs/plans/waves/reviews/wave-32-cont-qa.md +0 -43
- package/docs/plans/waves/reviews/wave-33-cont-qa.md +0 -526
- package/docs/plans/waves/reviews/wave-34-cont-qa.md +0 -100
- package/docs/plans/waves/reviews/wave-35-cont-qa.md +0 -145
- package/docs/plans/waves/reviews/wave-4-cont-qa.md +0 -47
- package/docs/plans/waves/reviews/wave-4-structure-proof.md +0 -69
- package/docs/plans/waves/reviews/wave-5-comment-proof.md +0 -158
- package/docs/plans/waves/reviews/wave-5-cont-qa.md +0 -68
- package/docs/plans/waves/reviews/wave-6-cont-qa.md +0 -416
- package/docs/plans/waves/reviews/wave-6-redline-proof.md +0 -130
- package/docs/plans/waves/reviews/wave-7-cont-qa.md +0 -82
- package/docs/plans/waves/reviews/wave-7-ooxml-compliance.md +0 -85
- package/docs/plans/waves/reviews/wave-7-preservation-proof.md +0 -119
- package/docs/plans/waves/reviews/wave-7-trust-ux.md +0 -87
- package/docs/plans/waves/reviews/wave-8-accessibility-and-design.md +0 -128
- package/docs/plans/waves/reviews/wave-8-cont-qa.md +0 -92
- package/docs/plans/waves/reviews/wave-8-live-proof.md +0 -140
- package/docs/plans/waves/reviews/wave-8-security.md +0 -47
- package/docs/plans/waves/reviews/wave-9-editor-embedding.md +0 -39
- package/docs/plans/waves/reviews/wave-9-fixture-runner.md +0 -56
- package/docs/plans/waves/reviews/wave-9-live-proof.md +0 -105
- package/docs/plans/waves/reviews/wave-9-usability-and-performance.md +0 -152
- package/docs/plans/waves/specs/README.md +0 -5
- package/docs/plans/waves/specs/wave-1-component-boundaries.md +0 -322
- package/docs/plans/waves/specs/wave-1-ooxml-contracts.md +0 -323
- package/docs/plans/waves/specs/wave-1-review-and-ui-contracts.md +0 -339
- package/docs/plans/waves/specs/wave-1-runtime-contracts.md +0 -509
- package/docs/plans/waves/wave-19.md +0 -341
- package/docs/plans/waves/wave-20.md +0 -308
- package/docs/plans/waves/wave-21.md +0 -289
- package/docs/plans/waves/wave-22.md +0 -221
- package/docs/plans/waves/wave-23.md +0 -295
- package/docs/plans/waves/wave-24.md +0 -286
- package/docs/plans/waves/wave-25.md +0 -313
- package/docs/plans/waves/wave-26.md +0 -300
- package/docs/plans/waves/wave-27.md +0 -299
- package/docs/plans/waves/wave-28.md +0 -368
- package/docs/plans/waves/wave-29.md +0 -303
- package/docs/plans/waves/wave-30.md +0 -307
- package/docs/plans/waves/wave-31.md +0 -231
- package/docs/plans/waves/wave-32.md +0 -152
- package/docs/plans/waves/wave-33.md +0 -147
- package/docs/plans/waves/wave-34.md +0 -148
- package/docs/plans/waves/wave-35.md +0 -141
- package/docs/plans/waves/wave-36.md +0 -146
- package/docs/plans/xlsx/README.md +0 -14
- package/docs/plans/xlsx/xlsx-fixture-corpus-and-certification-plan.md +0 -126
- package/docs/reference/cli-reference.md +0 -600
- package/docs/reference/coordination-and-closure.md +0 -487
- package/docs/reference/deep-research-report (15).md +0 -25
- package/docs/reference/docx/README.md +0 -10
- package/docs/reference/legal-checklist.md +0 -445
- package/docs/reference/live-proof-waves.md +0 -199
- package/docs/reference/ooxml-compliance.md +0 -129
- package/docs/reference/ooxml-feature-parity-matrix.md +0 -172
- package/docs/reference/platform/shared-ooxml-platform-guidance.md +0 -77
- package/docs/reference/prototype-agent-prompt-legal-fidelity.md +0 -155
- package/docs/reference/public-api.md +0 -456
- package/docs/reference/repository-guidance.md +0 -58
- package/docs/reference/runtime-config/README.md +0 -182
- package/docs/reference/runtime-config/claude.md +0 -110
- package/docs/reference/runtime-config/codex.md +0 -82
- package/docs/reference/runtime-config/opencode.md +0 -93
- package/docs/reference/sample-waves.md +0 -105
- package/docs/reference/skills.md +0 -237
- package/docs/reference/templates/AGENTS.md +0 -78
- package/docs/reference/templates/HEARTBEAT.md +0 -7
- package/docs/reference/templates/IDENTITY.md +0 -23
- package/docs/reference/templates/SOUL.md +0 -36
- package/docs/reference/templates/TOOLS.md +0 -40
- package/docs/reference/templates/USER.md +0 -17
- package/docs/reference/wave-control.md +0 -184
- package/docs/reference/wave-planning-lessons.md +0 -167
- package/docs/reference/word-review-editor-frontend-architecture.md +0 -479
- package/docs/reference/word-review-editor-ux-guide.md +0 -253
- package/docs/reference/xlsx/xlsx-ooxml-compliance.md +0 -137
- package/docs/research/agent-context-sources.md +0 -178
- package/docs/research/coordination-failure-review.md +0 -290
- package/docs/research/docx-react-component/Canonical Document Schema Specification for a React-based Word-compatible Editor.md +0 -2317
- package/docs/research/docx-react-component/Feature Compatibility Matrix for a React Word Compatible Legal Editor v1.md +0 -219
- package/docs/research/docx-react-component/React Component Architecture and Front-End Structure Specification for a Word-Compatible Legal Review Editor.md +0 -1112
- package/docs/research/docx-react-component/document_compatibility_and_testing_spec.md +0 -751
- package/docs/research/xlsx/raw/README.md +0 -13
- package/docs/roadmap.md +0 -174
- package/docs/superpowers/plans/2026-03-28-harness-control-bar.md +0 -677
- package/docs/superpowers/specs/2026-03-28-harness-control-bar-design.md +0 -274
- package/docs/xlsx-react/README.md +0 -38
- package/docs/xlsx-react/agent-llm-interaction-layer-docx-xlsx.md +0 -621
- package/docs/xlsx-react/canonical-workbook-model-and-commands.md +0 -948
- package/docs/xlsx-react/shared-openxml-editor-platform-docx-xlsx.md +0 -228
- package/docs/xlsx-react/spreadsheet-editor-component-architecture.md +0 -809
- package/docs/xlsx-react/spreadsheet-editor-frontend-architecture.md +0 -537
- package/docs/xlsx-react/spreadsheet-editor-ux-guide.md +0 -520
- package/docs/xlsx-react/xlsx-editor-research-pack.md +0 -871
- package/docs/xlsx-react/xlsx-fixture-corpus-and-certification-plan.md +0 -436
- package/docs/xlsx-react/xlsx-ooxml-compliance.md +0 -320
- package/examples/README.md +0 -16
- package/memory/MEMORY.md +0 -24
- package/pnpm-workspace.yaml +0 -4
- package/scripts/check-no-authored-js.sh +0 -13
- package/scripts/context7-api-check.sh +0 -65
- package/scripts/context7-export-env.sh +0 -42
- package/scripts/run-context7-mcp.sh +0 -8
- package/scripts/run-workspace-tests.sh +0 -15
- package/scripts/start-wave-10-local.sh +0 -189
- package/scripts/wave-agent-attach.sh +0 -47
- package/scripts/wave-auto-answer.sh +0 -118
- package/scripts/wave-dashboard-attach.sh +0 -13
- package/scripts/wave-launch.sh +0 -273
- package/scripts/wave-overnight-supervisor.sh +0 -145
- package/scripts/wave-status.sh +0 -379
- package/scripts/wave-watch.sh +0 -231
- package/services/README.md +0 -17
- package/services/openxml-validator/Dockerfile +0 -29
- package/services/openxml-validator/OpenXmlValidator.Api.csproj +0 -12
- package/services/openxml-validator/Program.cs +0 -436
- package/services/openxml-validator/README.md +0 -152
- package/services/openxml-validator/railway.json +0 -16
- package/services/react-word-editor/.tmp-a4/src/api/public-types.ts +0 -318
- package/services/react-word-editor/.tmp-a4/src/ui/WordReviewEditor.tsx +0 -1302
- package/services/react-word-editor/.tmp-a4/src/ui/editor-surface/editor-surface.tsx +0 -546
- package/services/react-word-editor/.tmp-a4/test/ui/word-review-editor.test.tsx +0 -146
- package/services/react-word-editor/.tmp-a4-build/src/api/public-types.js +0 -2
- package/services/react-word-editor/.tmp-a4-build/src/ui/WordReviewEditor.js +0 -818
- package/services/react-word-editor/.tmp-a4-build/src/ui/editor-surface/editor-surface.js +0 -229
- package/services/react-word-editor/.tmp-a4-build/test/ui/word-review-editor.test.js +0 -121
- package/services/react-word-editor/.tmp-wave-4-a3-tsconfig.json +0 -21
- package/services/react-word-editor/.tmp-wave-4-a3-tsconfig.tsbuildinfo +0 -1
- package/services/react-word-editor/Dockerfile +0 -26
- package/services/react-word-editor/README.md +0 -254
- package/services/react-word-editor/app/api/certification/route.ts +0 -79
- package/services/react-word-editor/app/api/demo-sessions/route.ts +0 -109
- package/services/react-word-editor/app/api/deploy-health/route.ts +0 -23
- package/services/react-word-editor/app/api/exports/[exportId]/route.ts +0 -34
- package/services/react-word-editor/app/api/exports/route.ts +0 -81
- package/services/react-word-editor/app/api/fixtures/[fixtureId]/run/route.ts +0 -100
- package/services/react-word-editor/app/api/health/route.ts +0 -70
- package/services/react-word-editor/app/api/runs/[runId]/route.ts +0 -36
- package/services/react-word-editor/app/api/scenarios/[scenarioId]/run/route.ts +0 -85
- package/services/react-word-editor/app/api/sessions/[sessionId]/route.ts +0 -199
- package/services/react-word-editor/app/api/sessions/[sessionId]/source/route.ts +0 -45
- package/services/react-word-editor/app/api/uploads/route.ts +0 -70
- package/services/react-word-editor/app/api/validate/route.ts +0 -310
- package/services/react-word-editor/app/certification/[runId]/page.tsx +0 -14
- package/services/react-word-editor/app/certification/page.tsx +0 -32
- package/services/react-word-editor/app/dashboard/page.tsx +0 -7
- package/services/react-word-editor/app/demo/page.tsx +0 -30
- package/services/react-word-editor/app/demo/prototype-client.tsx +0 -1080
- package/services/react-word-editor/app/editor/[sessionId]/page.tsx +0 -33
- package/services/react-word-editor/app/fixtures/page.tsx +0 -7
- package/services/react-word-editor/app/globals.css +0 -121
- package/services/react-word-editor/app/layout.tsx +0 -32
- package/services/react-word-editor/app/page.tsx +0 -30
- package/services/react-word-editor/app/runs/[runId]/page.tsx +0 -34
- package/services/react-word-editor/app/wave-10-word-review/page.tsx +0 -7
- package/services/react-word-editor/components/harness-control-bar.tsx +0 -289
- package/services/react-word-editor/components/harness-editor-session-client.tsx +0 -1214
- package/services/react-word-editor/components/harness-workspace-page.tsx +0 -715
- package/services/react-word-editor/components/reduced-motion-toggle.tsx +0 -79
- package/services/react-word-editor/components/workspace-certification-panel.tsx +0 -307
- package/services/react-word-editor/lib/certification-bundle.ts +0 -796
- package/services/react-word-editor/lib/certification-store.ts +0 -661
- package/services/react-word-editor/lib/demo-fixtures.test.mjs +0 -195
- package/services/react-word-editor/lib/demo-fixtures.ts +0 -1519
- package/services/react-word-editor/lib/editor-session-summary.test.mjs +0 -68
- package/services/react-word-editor/lib/editor-session-summary.ts +0 -14
- package/services/react-word-editor/lib/editor-session.ts +0 -228
- package/services/react-word-editor/lib/exports-route.test.mjs +0 -32
- package/services/react-word-editor/lib/harness-client.ts +0 -347
- package/services/react-word-editor/lib/harness-config.json +0 -30
- package/services/react-word-editor/lib/harness-config.test.mjs +0 -31
- package/services/react-word-editor/lib/harness-config.ts +0 -21
- package/services/react-word-editor/lib/harness-editor-datastore.test.mjs +0 -220
- package/services/react-word-editor/lib/harness-editor-datastore.ts +0 -161
- package/services/react-word-editor/lib/private-mode.test.mjs +0 -42
- package/services/react-word-editor/lib/private-mode.ts +0 -61
- package/services/react-word-editor/lib/regression-report.test.mjs +0 -352
- package/services/react-word-editor/lib/regression-report.ts +0 -896
- package/services/react-word-editor/lib/run-artifacts.ts +0 -934
- package/services/react-word-editor/lib/run-history.ts +0 -755
- package/services/react-word-editor/lib/scenario-artifacts.test.mjs +0 -41
- package/services/react-word-editor/lib/scenario-artifacts.ts +0 -44
- package/services/react-word-editor/lib/storage.ts +0 -953
- package/services/react-word-editor/lib/validator-client.test.mjs +0 -54
- package/services/react-word-editor/lib/validator-client.ts +0 -95
- package/services/react-word-editor/lib/workspace-navigation.ts +0 -79
- package/services/react-word-editor/middleware.ts +0 -35
- package/services/react-word-editor/next-env.d.ts +0 -6
- package/services/react-word-editor/next.config.mjs +0 -15
- package/services/react-word-editor/package.json +0 -38
- package/services/react-word-editor/postcss.config.mjs +0 -8
- package/services/react-word-editor/railway.json +0 -21
- package/services/react-word-editor/scripts/wave-10-certification.mjs +0 -101
- package/services/react-word-editor/scripts/wave-9-live-usability-pilot.mjs +0 -911
- package/services/react-word-editor/tsconfig.json +0 -39
- package/services/react-word-editor/tsconfig.tsbuildinfo +0 -1
- package/skills/README.md +0 -48
- package/skills/domain-docx-compatibility/SKILL.md +0 -44
- package/skills/domain-docx-compatibility/skill.json +0 -19
- package/skills/domain-editor-architecture/SKILL.md +0 -49
- package/skills/domain-editor-architecture/skill.json +0 -19
- package/skills/domain-legal-review/SKILL.md +0 -39
- package/skills/domain-legal-review/skill.json +0 -19
- package/skills/provider-aws/SKILL.md +0 -117
- package/skills/provider-aws/adapters/claude.md +0 -1
- package/skills/provider-aws/adapters/codex.md +0 -1
- package/skills/provider-aws/references/service-verification.md +0 -39
- package/skills/provider-aws/skill.json +0 -54
- package/skills/provider-custom-deploy/SKILL.md +0 -64
- package/skills/provider-custom-deploy/skill.json +0 -50
- package/skills/provider-docker-compose/SKILL.md +0 -96
- package/skills/provider-docker-compose/adapters/local.md +0 -1
- package/skills/provider-docker-compose/skill.json +0 -53
- package/skills/provider-github-release/SKILL.md +0 -121
- package/skills/provider-github-release/adapters/claude.md +0 -1
- package/skills/provider-github-release/adapters/codex.md +0 -1
- package/skills/provider-github-release/skill.json +0 -55
- package/skills/provider-kubernetes/SKILL.md +0 -143
- package/skills/provider-kubernetes/adapters/claude.md +0 -1
- package/skills/provider-kubernetes/adapters/codex.md +0 -1
- package/skills/provider-kubernetes/references/kubectl-patterns.md +0 -58
- package/skills/provider-kubernetes/skill.json +0 -52
- package/skills/provider-railway/SKILL.md +0 -123
- package/skills/provider-railway/adapters/claude.md +0 -1
- package/skills/provider-railway/adapters/codex.md +0 -1
- package/skills/provider-railway/adapters/local.md +0 -1
- package/skills/provider-railway/adapters/opencode.md +0 -1
- package/skills/provider-railway/references/verification-commands.md +0 -39
- package/skills/provider-railway/skill.json +0 -71
- package/skills/provider-ssh-manual/SKILL.md +0 -97
- package/skills/provider-ssh-manual/skill.json +0 -54
- package/skills/repo-coding-rules/SKILL.md +0 -55
- package/skills/repo-coding-rules/skill.json +0 -34
- package/skills/role-cont-eval/SKILL.md +0 -91
- package/skills/role-cont-eval/adapters/codex.md +0 -1
- package/skills/role-cont-eval/skill.json +0 -36
- package/skills/role-cont-qa/SKILL.md +0 -100
- package/skills/role-cont-qa/adapters/claude.md +0 -1
- package/skills/role-cont-qa/skill.json +0 -36
- package/skills/role-deploy/SKILL.md +0 -97
- package/skills/role-deploy/skill.json +0 -36
- package/skills/role-design/SKILL.md +0 -50
- package/skills/role-design/skill.json +0 -36
- package/skills/role-documentation/SKILL.md +0 -76
- package/skills/role-documentation/skill.json +0 -36
- package/skills/role-implementation/SKILL.md +0 -45
- package/skills/role-implementation/skill.json +0 -36
- package/skills/role-infra/SKILL.md +0 -81
- package/skills/role-infra/skill.json +0 -36
- package/skills/role-integration/SKILL.md +0 -91
- package/skills/role-integration/skill.json +0 -36
- package/skills/role-planner/SKILL.md +0 -39
- package/skills/role-planner/skill.json +0 -21
- package/skills/role-research/SKILL.md +0 -65
- package/skills/role-research/skill.json +0 -36
- package/skills/role-security/SKILL.md +0 -60
- package/skills/role-security/skill.json +0 -36
- package/skills/runtime-claude/SKILL.md +0 -66
- package/skills/runtime-claude/skill.json +0 -36
- package/skills/runtime-codex/SKILL.md +0 -58
- package/skills/runtime-codex/skill.json +0 -36
- package/skills/runtime-local/SKILL.md +0 -46
- package/skills/runtime-local/skill.json +0 -36
- package/skills/runtime-opencode/SKILL.md +0 -58
- package/skills/runtime-opencode/skill.json +0 -36
- package/skills/signal-hygiene/SKILL.md +0 -51
- package/skills/signal-hygiene/skill.json +0 -20
- package/skills/tui-design/SKILL.md +0 -77
- package/skills/tui-design/references/tui-design.md +0 -259
- package/skills/tui-design/skill.json +0 -36
- package/skills/wave-core/SKILL.md +0 -141
- package/skills/wave-core/references/marker-syntax.md +0 -70
- package/skills/wave-core/skill.json +0 -35
- package/src/README.md +0 -85
- package/src/api/README.md +0 -22
- package/src/api/public-types.ts +0 -525
- package/src/component-inventory.md +0 -99
- package/src/core/README.md +0 -10
- package/src/core/commands/README.md +0 -3
- package/src/core/commands/formatting-commands.ts +0 -161
- package/src/core/commands/image-commands.ts +0 -144
- package/src/core/commands/index.ts +0 -1013
- package/src/core/commands/list-commands.ts +0 -370
- package/src/core/commands/review-commands.ts +0 -108
- package/src/core/commands/text-commands.ts +0 -119
- package/src/core/schema/README.md +0 -3
- package/src/core/schema/text-schema.ts +0 -512
- package/src/core/selection/README.md +0 -3
- package/src/core/selection/mapping.ts +0 -238
- package/src/core/selection/review-anchors.ts +0 -94
- package/src/core/state/README.md +0 -3
- package/src/core/state/editor-state.ts +0 -580
- package/src/core/state/text-transaction.ts +0 -276
- package/src/formats/xlsx/io/parse-shared-strings.ts +0 -41
- package/src/formats/xlsx/io/parse-sheet.ts +0 -289
- package/src/formats/xlsx/io/parse-styles.ts +0 -57
- package/src/formats/xlsx/io/parse-workbook.ts +0 -75
- package/src/formats/xlsx/io/xlsx-session.ts +0 -306
- package/src/formats/xlsx/model/cell.ts +0 -189
- package/src/formats/xlsx/model/sheet.ts +0 -244
- package/src/formats/xlsx/model/styles.ts +0 -118
- package/src/formats/xlsx/model/workbook.ts +0 -449
- package/src/io/README.md +0 -10
- package/src/io/docx-session.ts +0 -1763
- package/src/io/export/README.md +0 -3
- package/src/io/export/export-session.ts +0 -165
- package/src/io/export/minimal-docx.ts +0 -115
- package/src/io/export/reattach-preserved-parts.ts +0 -54
- package/src/io/export/serialize-comments.ts +0 -876
- package/src/io/export/serialize-footnotes.ts +0 -217
- package/src/io/export/serialize-headers-footers.ts +0 -200
- package/src/io/export/serialize-main-document.ts +0 -982
- package/src/io/export/serialize-numbering.ts +0 -97
- package/src/io/export/serialize-revisions.ts +0 -389
- package/src/io/export/serialize-runtime-revisions.ts +0 -265
- package/src/io/export/serialize-tables.ts +0 -147
- package/src/io/export/split-review-boundaries.ts +0 -194
- package/src/io/normalize/README.md +0 -3
- package/src/io/normalize/normalize-text.ts +0 -437
- package/src/io/ooxml/README.md +0 -3
- package/src/io/ooxml/parse-comments.ts +0 -779
- package/src/io/ooxml/parse-complex-content.ts +0 -287
- package/src/io/ooxml/parse-fields.ts +0 -438
- package/src/io/ooxml/parse-footnotes.ts +0 -403
- package/src/io/ooxml/parse-headers-footers.ts +0 -483
- package/src/io/ooxml/parse-inline-media.ts +0 -431
- package/src/io/ooxml/parse-main-document.ts +0 -1846
- package/src/io/ooxml/parse-numbering.ts +0 -425
- package/src/io/ooxml/parse-revisions.ts +0 -658
- package/src/io/ooxml/parse-shapes.ts +0 -271
- package/src/io/ooxml/parse-tables.ts +0 -568
- package/src/io/ooxml/parse-theme.ts +0 -314
- package/src/io/ooxml/part-manifest.ts +0 -136
- package/src/io/ooxml/revision-boundaries.ts +0 -351
- package/src/io/opc/README.md +0 -3
- package/src/io/opc/corrupt-package.ts +0 -166
- package/src/io/opc/docx-package.ts +0 -74
- package/src/io/opc/package-reader.ts +0 -320
- package/src/io/opc/package-writer.ts +0 -273
- package/src/model/README.md +0 -3
- package/src/model/canonical-document.ts +0 -1911
- package/src/model/cds-1.0.0.ts +0 -196
- package/src/model/snapshot.ts +0 -393
- package/src/preservation/README.md +0 -3
- package/src/preservation/markup-compatibility.ts +0 -48
- package/src/preservation/opaque-fragment-store.ts +0 -89
- package/src/preservation/opaque-region.ts +0 -233
- package/src/preservation/package-preservation.ts +0 -120
- package/src/preservation/preserved-part-manifest.ts +0 -56
- package/src/preservation/relationship-retention.ts +0 -57
- package/src/preservation/store.ts +0 -185
- package/src/review/README.md +0 -16
- package/src/review/store/README.md +0 -3
- package/src/review/store/comment-anchors.ts +0 -70
- package/src/review/store/comment-remapping.ts +0 -154
- package/src/review/store/comment-store.ts +0 -331
- package/src/review/store/comment-thread.ts +0 -109
- package/src/review/store/revision-actions.ts +0 -394
- package/src/review/store/revision-store.ts +0 -303
- package/src/review/store/revision-types.ts +0 -168
- package/src/review/store/runtime-comment-store.ts +0 -43
- package/src/runtime/README.md +0 -3
- package/src/runtime/ai-action-policy.ts +0 -764
- package/src/runtime/document-runtime.ts +0 -969
- package/src/runtime/read-only-diagnostics-runtime.ts +0 -232
- package/src/runtime/review-runtime.ts +0 -44
- package/src/runtime/revision-runtime.ts +0 -107
- package/src/runtime/session-capabilities.ts +0 -138
- package/src/runtime/surface-projection.ts +0 -570
- package/src/runtime/table-commands.ts +0 -84
- package/src/runtime/table-schema.ts +0 -125
- package/src/ui/README.md +0 -30
- package/src/ui/WordReviewEditor.tsx +0 -1283
- package/src/ui/comments/README.md +0 -3
- package/src/ui/compatibility/README.md +0 -3
- package/src/ui/editor-surface/README.md +0 -3
- package/src/ui/headless/comment-decoration-model.ts +0 -124
- package/src/ui/headless/revision-decoration-model.ts +0 -128
- package/src/ui/headless/selection-helpers.ts +0 -34
- package/src/ui/headless/use-editor-keyboard.ts +0 -98
- package/src/ui/review/README.md +0 -3
- package/src/ui/shared/revision-filters.ts +0 -31
- package/src/ui/status/README.md +0 -3
- package/src/ui/theme/README.md +0 -3
- package/src/ui/toolbar/README.md +0 -3
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +0 -48
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +0 -44
- package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +0 -58
- package/src/ui-tailwind/chrome/use-before-unload.ts +0 -20
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -139
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +0 -98
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +0 -123
- package/src/ui-tailwind/editor-surface/pm-schema.ts +0 -452
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +0 -327
- package/src/ui-tailwind/editor-surface/search-plugin.ts +0 -157
- package/src/ui-tailwind/editor-surface/tw-caret.tsx +0 -12
- package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +0 -150
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +0 -118
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +0 -52
- package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +0 -151
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +0 -215
- package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +0 -111
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -108
- package/src/ui-tailwind/index.ts +0 -61
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +0 -276
- package/src/ui-tailwind/review/tw-health-panel.tsx +0 -120
- package/src/ui-tailwind/review/tw-review-rail.tsx +0 -120
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +0 -164
- package/src/ui-tailwind/status/tw-status-bar.tsx +0 -58
- package/src/ui-tailwind/theme/editor-theme.css +0 -190
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +0 -48
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +0 -231
- package/src/ui-tailwind/tw-review-workspace.tsx +0 -140
- package/src/validation/README.md +0 -3
- package/src/validation/compatibility-engine.ts +0 -317
- package/src/validation/compatibility-report.ts +0 -160
- package/src/validation/diagnostics.ts +0 -203
- package/src/validation/import-diagnostics.ts +0 -128
- package/src/validation/low-priority-word-surfaces.ts +0 -373
- package/test/README.md +0 -16
- package/test/core/formatting-commands.test.ts +0 -285
- package/test/core/image-commands.test.ts +0 -298
- package/test/core/mapping.test.ts +0 -186
- package/test/core/text-commands.test.ts +0 -176
- package/test/fixtures/docx/F01-basic-contract.docx +0 -0
- package/test/fixtures/docx/F01-basic-contract.md +0 -33
- package/test/fixtures/docx/F02-headings-styles.docx +0 -0
- package/test/fixtures/docx/F02-headings-styles.md +0 -33
- package/test/fixtures/docx/F03-legal-outline-numbering.docx +0 -0
- package/test/fixtures/docx/F03-legal-outline-numbering.md +0 -34
- package/test/fixtures/docx/F04-restart-numbering-schedules.docx +0 -0
- package/test/fixtures/docx/F04-restart-numbering-schedules.md +0 -33
- package/test/fixtures/docx/F05-table-heavy-agreement.docx +0 -0
- package/test/fixtures/docx/F05-table-heavy-agreement.md +0 -34
- package/test/fixtures/docx/F06-merged-cells-signature-table.docx +0 -0
- package/test/fixtures/docx/F06-merged-cells-signature-table.md +0 -34
- package/test/fixtures/docx/F07-inline-images-exhibit.docx +0 -0
- package/test/fixtures/docx/F07-inline-images-exhibit.md +0 -34
- package/test/fixtures/docx/F08-hyperlinks.docx +0 -0
- package/test/fixtures/docx/F08-hyperlinks.md +0 -33
- package/test/fixtures/docx/F09-comments-single-paragraph.docx +0 -0
- package/test/fixtures/docx/F09-comments-single-paragraph.md +0 -33
- package/test/fixtures/docx/F10-threaded-comments-resolve.docx +0 -0
- package/test/fixtures/docx/F10-threaded-comments-resolve.md +0 -33
- package/test/fixtures/docx/F11-redlines-basic.docx +0 -0
- package/test/fixtures/docx/F11-redlines-basic.md +0 -33
- package/test/fixtures/docx/F12-redlines-paragraph-joins-splits.docx +0 -0
- package/test/fixtures/docx/F12-redlines-paragraph-joins-splits.md +0 -33
- package/test/fixtures/docx/F13-comments-on-deleted-text.docx +0 -0
- package/test/fixtures/docx/F13-comments-on-deleted-text.md +0 -33
- package/test/fixtures/docx/F14-revisions-in-tables-and-lists.docx +0 -0
- package/test/fixtures/docx/F14-revisions-in-tables-and-lists.md +0 -33
- package/test/fixtures/docx/F15-sections-headers-footers.docx +0 -0
- package/test/fixtures/docx/F15-sections-headers-footers.md +0 -33
- package/test/fixtures/docx/F16-footnotes-endnotes.docx +0 -0
- package/test/fixtures/docx/F16-footnotes-endnotes.md +0 -33
- package/test/fixtures/docx/F17-fields-and-toc.docx +0 -0
- package/test/fixtures/docx/F17-fields-and-toc.md +0 -33
- package/test/fixtures/docx/F18-content-controls-template.docx +0 -0
- package/test/fixtures/docx/F18-content-controls-template.md +0 -33
- package/test/fixtures/docx/F19-custom-xml-doc-assembly.docx +0 -0
- package/test/fixtures/docx/F19-custom-xml-doc-assembly.md +0 -35
- package/test/fixtures/docx/F20-unknown-ooxml-and-alternatecontent.docx +0 -0
- package/test/fixtures/docx/F20-unknown-ooxml-and-alternatecontent.md +0 -33
- package/test/fixtures/docx/F21-malformed-broken-docx.docx +0 -0
- package/test/fixtures/docx/F21-malformed-broken-docx.md +0 -33
- package/test/fixtures/docx/README.md +0 -74
- package/test/fixtures/docx/certification-manifest.json +0 -104
- package/test/fixtures/docx/fixtures.manifest.json +0 -196
- package/test/fixtures/encrypted-docx/README.md +0 -27
- package/test/fixtures/encrypted-docx/certification-manifest.json +0 -9
- package/test/fixtures/encrypted-docx/fixtures.manifest.json +0 -47
- package/test/fixtures/scenarios/docx/README.md +0 -25
- package/test/fixtures/scenarios/docx/S01-sow-template.docx +0 -0
- package/test/fixtures/scenarios/docx/S01-sow-template.md +0 -30
- package/test/fixtures/scenarios/docx/S02-bw-partner-user-licence-agreement-redlines.docx +0 -0
- package/test/fixtures/scenarios/docx/S02-bw-partner-user-licence-agreement-redlines.md +0 -32
- package/test/fixtures/scenarios/docx/scenario-manifest.json +0 -53
- package/test/formats/xlsx/io/xlsx-import.test.ts +0 -766
- package/test/formats/xlsx/model/workbook.test.ts +0 -669
- package/test/helpers/dom-setup.ts +0 -124
- package/test/io/comment-roundtrip.test.ts +0 -272
- package/test/io/complex-content-roundtrip.test.ts +0 -632
- package/test/io/docx-compatibility-regression.test.ts +0 -199
- package/test/io/docx-session.test.ts +0 -1495
- package/test/io/footnotes-roundtrip.test.ts +0 -318
- package/test/io/headers-footers-roundtrip.test.ts +0 -547
- package/test/io/numbering-roundtrip.test.ts +0 -234
- package/test/io/package-reader.test.ts +0 -199
- package/test/io/paragraph-properties-roundtrip.test.ts +0 -129
- package/test/io/preserved-package-roundtrip.test.ts +0 -365
- package/test/io/property-completeness.test.ts +0 -292
- package/test/io/revision-roundtrip.test.ts +0 -347
- package/test/io/structural-blocks.test.ts +0 -202
- package/test/io/table-media-roundtrip.test.ts +0 -448
- package/test/io/table-properties-roundtrip.test.ts +0 -569
- package/test/io/table-roundtrip.test.ts +0 -302
- package/test/io/text-roundtrip.test.ts +0 -344
- package/test/model/canonical-document.test.ts +0 -285
- package/test/preservation/opaque-fragment-store.test.ts +0 -121
- package/test/preservation/package-preservation.test.ts +0 -395
- package/test/preservation/store.test.ts +0 -84
- package/test/review/comment-remapping.test.ts +0 -220
- package/test/review/comment-store.test.ts +0 -180
- package/test/review/move-revisions.test.ts +0 -143
- package/test/review/property-change-revisions.test.ts +0 -225
- package/test/review/revision-actions.test.ts +0 -330
- package/test/review/revision-store.test.ts +0 -193
- package/test/runtime/session-capabilities.test.ts +0 -260
- package/test/runtime/table-commands.test.ts +0 -356
- package/test/runtime/table-schema.test.ts +0 -221
- package/test/runtime/tracked-changes-toggle.test.ts +0 -107
- package/test/ui/comment-review-surface.test.tsx +0 -114
- package/test/ui/reduced-motion-toggle.test.tsx +0 -137
- package/test/ui/word-review-editor.imported-scenarios.test.tsx +0 -169
- package/test/ui/word-review-editor.interaction.test.tsx +0 -1198
- package/test/ui/word-review-editor.test.js +0 -188
- package/test/ui/word-review-editor.test.tsx +0 -280
- package/test/ui-tailwind/search-plugin.test.ts +0 -286
- package/test/validation/compatibility-engine.test.ts +0 -336
- package/test/validation/compatibility-report.test.ts +0 -189
- package/test/validation/low-priority-word-surfaces.test.ts +0 -282
- package/test/validation/malformed-doc.test.ts +0 -113
- package/test-results/.last-run.json +0 -4
- package/wave.config.json +0 -406
|
@@ -1,1283 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useEffect,
|
|
4
|
-
useImperativeHandle,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
useSyncExternalStore,
|
|
9
|
-
} from "react";
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
AutosaveState,
|
|
13
|
-
EditorDatastoreAdapter,
|
|
14
|
-
CompatibilityReport,
|
|
15
|
-
EditorError,
|
|
16
|
-
EditorWarning,
|
|
17
|
-
ExportDocxOptions,
|
|
18
|
-
PersistedEditorSnapshot,
|
|
19
|
-
RuntimeRenderSnapshot,
|
|
20
|
-
SelectionSnapshot as PublicSelectionSnapshot,
|
|
21
|
-
ExportResult,
|
|
22
|
-
WordReviewEditorEvent,
|
|
23
|
-
WordReviewEditorProps,
|
|
24
|
-
WordReviewEditorRef,
|
|
25
|
-
} from "../api/public-types";
|
|
26
|
-
import {
|
|
27
|
-
createDetachedAnchor,
|
|
28
|
-
createNodeAnchor,
|
|
29
|
-
createRangeAnchor,
|
|
30
|
-
} from "../core/selection/mapping.ts";
|
|
31
|
-
import { createCanonicalDocumentId } from "../core/state/editor-state.ts";
|
|
32
|
-
import {
|
|
33
|
-
createDocumentRuntime,
|
|
34
|
-
type DocumentRuntime,
|
|
35
|
-
} from "../runtime/document-runtime.ts";
|
|
36
|
-
import { loadDocxEditorSession } from "../io/docx-session.ts";
|
|
37
|
-
import { exportSnapshotToMinimalDocx } from "../io/export/minimal-docx.ts";
|
|
38
|
-
import { DOCX_MIME_TYPE } from "../io/opc/docx-package.ts";
|
|
39
|
-
import { deriveCapabilities } from "../runtime/session-capabilities";
|
|
40
|
-
import { TwProseMirrorSurface } from "../ui-tailwind/editor-surface/tw-prosemirror-surface";
|
|
41
|
-
import { TwReviewWorkspace } from "../ui-tailwind/tw-review-workspace";
|
|
42
|
-
import type { ReviewRailTab } from "../ui-tailwind/review/tw-review-rail";
|
|
43
|
-
import type { ViewMode } from "../ui-tailwind/toolbar/tw-toolbar";
|
|
44
|
-
import type { MarkupDisplay } from "./headless/comment-decoration-model";
|
|
45
|
-
|
|
46
|
-
interface ResolvedSource {
|
|
47
|
-
source: "docx" | "snapshot" | "datastore";
|
|
48
|
-
sourceLabel?: string;
|
|
49
|
-
initialDocx?: Uint8Array | ArrayBuffer;
|
|
50
|
-
initialSnapshot?: PersistedEditorSnapshot;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface CreateRuntimeArgs {
|
|
54
|
-
documentId: string;
|
|
55
|
-
readOnly: boolean;
|
|
56
|
-
source: ResolvedSource;
|
|
57
|
-
datastore?: EditorDatastoreAdapter;
|
|
58
|
-
currentUserId?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface RuntimeLifecycleHandlers {
|
|
62
|
-
onEvent?: (event: WordReviewEditorEvent) => void;
|
|
63
|
-
onWarning?: (warning: EditorWarning) => void;
|
|
64
|
-
onError?: (error: EditorError) => void;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface WordReviewEditorRuntime extends DocumentRuntime {
|
|
68
|
-
getFatalError?(): EditorError | undefined;
|
|
69
|
-
dispose?(): void;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function __createWordReviewEditorRefBridge(
|
|
73
|
-
runtime: WordReviewEditorRuntime,
|
|
74
|
-
): WordReviewEditorRef {
|
|
75
|
-
return {
|
|
76
|
-
focus: () => runtime.focus(),
|
|
77
|
-
blur: () => runtime.blur(),
|
|
78
|
-
undo: () => runtime.undo(),
|
|
79
|
-
redo: () => runtime.redo(),
|
|
80
|
-
addComment: (params) => runtime.addComment(params),
|
|
81
|
-
openComment: (commentId) => runtime.openComment(commentId),
|
|
82
|
-
resolveComment: (commentId) => runtime.resolveComment(commentId),
|
|
83
|
-
reopenComment: (commentId) => runtime.reopenComment(commentId),
|
|
84
|
-
addCommentReply: (commentId, body) => runtime.addCommentReply(commentId, body),
|
|
85
|
-
editCommentBody: (commentId, body) => runtime.editCommentBody(commentId, body),
|
|
86
|
-
acceptChange: (changeId) => runtime.acceptChange(changeId),
|
|
87
|
-
rejectChange: (changeId) => runtime.rejectChange(changeId),
|
|
88
|
-
acceptAllChanges: () => runtime.acceptAllChanges(),
|
|
89
|
-
rejectAllChanges: () => runtime.rejectAllChanges(),
|
|
90
|
-
exportDocx: (options) => runtime.exportDocx(options),
|
|
91
|
-
getSnapshot: () => runtime.getPersistedSnapshot(),
|
|
92
|
-
getCompatibilityReport: () => runtime.getCompatibilityReport(),
|
|
93
|
-
getWarnings: () => runtime.getWarnings(),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function __resolveWordReviewEditorSource(
|
|
98
|
-
props: Pick<
|
|
99
|
-
WordReviewEditorProps,
|
|
100
|
-
| "documentId"
|
|
101
|
-
| "datastore"
|
|
102
|
-
| "externalDocSource"
|
|
103
|
-
| "initialDocx"
|
|
104
|
-
| "initialSnapshot"
|
|
105
|
-
| "initialSourceLabel"
|
|
106
|
-
>,
|
|
107
|
-
): Promise<ResolvedSource> {
|
|
108
|
-
const explicitInitialCount =
|
|
109
|
-
Number(Boolean(props.initialDocx)) + Number(Boolean(props.initialSnapshot));
|
|
110
|
-
if (explicitInitialCount > 1) {
|
|
111
|
-
throw new Error("Provide exactly one of initialDocx or initialSnapshot.");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (props.externalDocSource) {
|
|
115
|
-
return props.externalDocSource.kind === "docx"
|
|
116
|
-
? {
|
|
117
|
-
source: "docx",
|
|
118
|
-
initialDocx: props.externalDocSource.bytes,
|
|
119
|
-
sourceLabel: props.externalDocSource.sourceLabel,
|
|
120
|
-
}
|
|
121
|
-
: {
|
|
122
|
-
source: "snapshot",
|
|
123
|
-
initialSnapshot: props.externalDocSource.snapshot,
|
|
124
|
-
sourceLabel: props.externalDocSource.sourceLabel,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (props.initialSnapshot) {
|
|
129
|
-
return {
|
|
130
|
-
source: "snapshot",
|
|
131
|
-
initialSnapshot: props.initialSnapshot,
|
|
132
|
-
sourceLabel: props.initialSourceLabel,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (props.initialDocx) {
|
|
137
|
-
return {
|
|
138
|
-
source: "docx",
|
|
139
|
-
initialDocx: props.initialDocx,
|
|
140
|
-
sourceLabel: props.initialSourceLabel,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!props.datastore) {
|
|
145
|
-
throw new Error(
|
|
146
|
-
`WordReviewEditor ${props.documentId} needs initialDocx, initialSnapshot, or datastore.load().`,
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const loadResult = await props.datastore.load({
|
|
151
|
-
documentId: props.documentId,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (!loadResult.source) {
|
|
155
|
-
throw new Error(`Datastore did not return a loadable source for ${props.documentId}.`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return loadResult.source.kind === "docx"
|
|
159
|
-
? {
|
|
160
|
-
source: "datastore",
|
|
161
|
-
initialDocx: loadResult.source.bytes,
|
|
162
|
-
sourceLabel: loadResult.source.sourceLabel,
|
|
163
|
-
}
|
|
164
|
-
: {
|
|
165
|
-
source: "datastore",
|
|
166
|
-
initialSnapshot: loadResult.source.snapshot,
|
|
167
|
-
sourceLabel: loadResult.source.sourceLabel,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function __createFallbackRuntime(args: CreateRuntimeArgs): WordReviewEditorRuntime {
|
|
172
|
-
return createRuntime(args);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function createRuntime(
|
|
176
|
-
args: CreateRuntimeArgs,
|
|
177
|
-
handlers: RuntimeLifecycleHandlers = {},
|
|
178
|
-
): WordReviewEditorRuntime {
|
|
179
|
-
const docxSession = args.source.initialDocx
|
|
180
|
-
? loadDocxEditorSession({
|
|
181
|
-
documentId: args.documentId,
|
|
182
|
-
sourceLabel: args.source.sourceLabel,
|
|
183
|
-
bytes: args.source.initialDocx,
|
|
184
|
-
editorBuild: "dev",
|
|
185
|
-
})
|
|
186
|
-
: undefined;
|
|
187
|
-
const initialSnapshot =
|
|
188
|
-
args.source.initialSnapshot ??
|
|
189
|
-
docxSession?.initialSnapshot ??
|
|
190
|
-
createFallbackPersistedSnapshot(
|
|
191
|
-
args.documentId,
|
|
192
|
-
args.source.sourceLabel ?? "Generated shell snapshot",
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
return createDocumentRuntime({
|
|
196
|
-
documentId: args.documentId,
|
|
197
|
-
initialSnapshot,
|
|
198
|
-
sourceKind: args.source.source,
|
|
199
|
-
sourceLabel: args.source.sourceLabel,
|
|
200
|
-
readOnly: args.readOnly || docxSession?.readOnly,
|
|
201
|
-
editorBuild: initialSnapshot.editorBuild,
|
|
202
|
-
fatalError: docxSession?.fatalError,
|
|
203
|
-
exportDocx: async (snapshot, options) =>
|
|
204
|
-
docxSession
|
|
205
|
-
? docxSession.exportDocx(snapshot, options)
|
|
206
|
-
: {
|
|
207
|
-
bytes: exportSnapshotToMinimalDocx(snapshot),
|
|
208
|
-
mimeType: DOCX_MIME_TYPE,
|
|
209
|
-
fileName: options?.fileName ?? `${args.documentId}.docx`,
|
|
210
|
-
},
|
|
211
|
-
onWarning: handlers.onWarning,
|
|
212
|
-
onError: handlers.onError,
|
|
213
|
-
defaultAuthorId: args.currentUserId,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export const WordReviewEditor = forwardRef<WordReviewEditorRef, WordReviewEditorProps>(
|
|
218
|
-
function WordReviewEditor(props, ref) {
|
|
219
|
-
const {
|
|
220
|
-
currentUser,
|
|
221
|
-
datastore,
|
|
222
|
-
documentId,
|
|
223
|
-
externalDocSource,
|
|
224
|
-
externalDocumentRevision,
|
|
225
|
-
initialDocx,
|
|
226
|
-
initialSnapshot,
|
|
227
|
-
initialSourceLabel,
|
|
228
|
-
markupDisplay = "simple",
|
|
229
|
-
onError,
|
|
230
|
-
onEvent,
|
|
231
|
-
onWarning,
|
|
232
|
-
readOnly = false,
|
|
233
|
-
reviewMode = "review",
|
|
234
|
-
} = props;
|
|
235
|
-
|
|
236
|
-
const [runtime, setRuntime] = useState<WordReviewEditorRuntime | null>(null);
|
|
237
|
-
const [loadError, setLoadError] = useState<EditorError | null>(null);
|
|
238
|
-
const [viewMode, setViewMode] = useState<ViewMode>("canvas");
|
|
239
|
-
const liveMarkupDisplay: MarkupDisplay = viewMode === "document" ? "all" : "clean";
|
|
240
|
-
const [activeRailTab, setActiveRailTab] = useState<ReviewRailTab>("comments");
|
|
241
|
-
const [showTrackedChanges, setShowTrackedChanges] = useState(false);
|
|
242
|
-
const [activeRevisionId, setActiveRevisionId] = useState<string | undefined>();
|
|
243
|
-
const runtimeRef = useRef<WordReviewEditorRuntime | null>(null);
|
|
244
|
-
const autosaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
245
|
-
const lastSavedRevisionTokenRef = useRef<string | null>(null);
|
|
246
|
-
const datastoreRef = useRef(datastore);
|
|
247
|
-
const onEventRef = useRef(onEvent);
|
|
248
|
-
const onWarningRef = useRef(onWarning);
|
|
249
|
-
const onErrorRef = useRef(onError);
|
|
250
|
-
const initialSourceRef = useRef<{
|
|
251
|
-
documentId: string;
|
|
252
|
-
initialDocx?: Uint8Array | ArrayBuffer;
|
|
253
|
-
initialSnapshot?: PersistedEditorSnapshot;
|
|
254
|
-
initialSourceLabel?: string;
|
|
255
|
-
} | null>(null);
|
|
256
|
-
|
|
257
|
-
if (!initialSourceRef.current || initialSourceRef.current.documentId !== documentId) {
|
|
258
|
-
initialSourceRef.current = {
|
|
259
|
-
documentId,
|
|
260
|
-
initialDocx,
|
|
261
|
-
initialSnapshot,
|
|
262
|
-
initialSourceLabel,
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const stableInitialSource = initialSourceRef.current;
|
|
267
|
-
const sourceReloadKey = externalDocSource
|
|
268
|
-
? `external:${externalDocSource.kind}:${externalDocumentRevision ?? "static"}`
|
|
269
|
-
: stableInitialSource?.initialSnapshot
|
|
270
|
-
? "initial-snapshot"
|
|
271
|
-
: stableInitialSource?.initialDocx
|
|
272
|
-
? "initial-docx"
|
|
273
|
-
: "datastore";
|
|
274
|
-
|
|
275
|
-
useEffect(() => {
|
|
276
|
-
datastoreRef.current = datastore;
|
|
277
|
-
onEventRef.current = onEvent;
|
|
278
|
-
onWarningRef.current = onWarning;
|
|
279
|
-
onErrorRef.current = onError;
|
|
280
|
-
}, [datastore, onError, onEvent, onWarning]);
|
|
281
|
-
|
|
282
|
-
useEffect(() => {
|
|
283
|
-
let cancelled = false;
|
|
284
|
-
|
|
285
|
-
async function loadRuntime(): Promise<void> {
|
|
286
|
-
setLoadError(null);
|
|
287
|
-
|
|
288
|
-
try {
|
|
289
|
-
const source = await __resolveWordReviewEditorSource({
|
|
290
|
-
documentId,
|
|
291
|
-
datastore: datastoreRef.current,
|
|
292
|
-
externalDocSource,
|
|
293
|
-
initialDocx: stableInitialSource?.initialDocx,
|
|
294
|
-
initialSnapshot: stableInitialSource?.initialSnapshot,
|
|
295
|
-
initialSourceLabel: stableInitialSource?.initialSourceLabel,
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
if (cancelled) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
runtimeRef.current?.dispose?.();
|
|
303
|
-
const nextRuntime = createRuntime(
|
|
304
|
-
{
|
|
305
|
-
documentId,
|
|
306
|
-
readOnly,
|
|
307
|
-
source,
|
|
308
|
-
datastore: datastoreRef.current,
|
|
309
|
-
currentUserId: currentUser.userId,
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
onWarning: onWarningRef.current,
|
|
313
|
-
onError: onErrorRef.current,
|
|
314
|
-
},
|
|
315
|
-
);
|
|
316
|
-
emitEditorEvent({
|
|
317
|
-
datastore: datastoreRef.current,
|
|
318
|
-
onEvent: onEventRef.current,
|
|
319
|
-
event: createReadyEvent(nextRuntime, source.source),
|
|
320
|
-
});
|
|
321
|
-
runtimeRef.current = nextRuntime;
|
|
322
|
-
setRuntime(nextRuntime);
|
|
323
|
-
} catch (error) {
|
|
324
|
-
if (cancelled) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const normalized = normalizeEditorError(error);
|
|
329
|
-
setLoadError(normalized);
|
|
330
|
-
onErrorRef.current?.(normalized);
|
|
331
|
-
emitEditorEvent({
|
|
332
|
-
datastore: datastoreRef.current,
|
|
333
|
-
onEvent: onEventRef.current,
|
|
334
|
-
event: {
|
|
335
|
-
type: "error",
|
|
336
|
-
documentId,
|
|
337
|
-
error: normalized,
|
|
338
|
-
},
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
void loadRuntime();
|
|
344
|
-
|
|
345
|
-
return () => {
|
|
346
|
-
cancelled = true;
|
|
347
|
-
};
|
|
348
|
-
}, [
|
|
349
|
-
documentId,
|
|
350
|
-
readOnly,
|
|
351
|
-
sourceReloadKey,
|
|
352
|
-
]);
|
|
353
|
-
|
|
354
|
-
useEffect(() => {
|
|
355
|
-
if (!runtime?.subscribeToEvents) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return runtime.subscribeToEvents((event) => {
|
|
360
|
-
emitEditorEvent({
|
|
361
|
-
datastore: datastoreRef.current,
|
|
362
|
-
onEvent: onEventRef.current,
|
|
363
|
-
event,
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
}, [runtime]);
|
|
367
|
-
|
|
368
|
-
useEffect(() => {
|
|
369
|
-
return () => {
|
|
370
|
-
if (autosaveTimerRef.current) {
|
|
371
|
-
clearTimeout(autosaveTimerRef.current);
|
|
372
|
-
autosaveTimerRef.current = null;
|
|
373
|
-
}
|
|
374
|
-
runtimeRef.current?.dispose?.();
|
|
375
|
-
runtimeRef.current = null;
|
|
376
|
-
};
|
|
377
|
-
}, []);
|
|
378
|
-
|
|
379
|
-
const optimisticRuntime = useMemo(
|
|
380
|
-
() =>
|
|
381
|
-
__createFallbackRuntime({
|
|
382
|
-
documentId,
|
|
383
|
-
readOnly,
|
|
384
|
-
currentUserId: currentUser.userId,
|
|
385
|
-
source: {
|
|
386
|
-
source: "snapshot",
|
|
387
|
-
initialSnapshot:
|
|
388
|
-
initialSnapshot ?? createFallbackPersistedSnapshot(documentId, initialSourceLabel),
|
|
389
|
-
sourceLabel: guessSourceLabel(initialSourceLabel, initialSnapshot, externalDocSource),
|
|
390
|
-
},
|
|
391
|
-
datastore: datastoreRef.current,
|
|
392
|
-
}),
|
|
393
|
-
[
|
|
394
|
-
currentUser.userId,
|
|
395
|
-
documentId,
|
|
396
|
-
initialSnapshot,
|
|
397
|
-
initialSourceLabel,
|
|
398
|
-
readOnly,
|
|
399
|
-
externalDocSource?.kind,
|
|
400
|
-
externalDocSource?.sourceLabel,
|
|
401
|
-
],
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
const fallbackSnapshot = useMemo(
|
|
405
|
-
() =>
|
|
406
|
-
loadError
|
|
407
|
-
? createErrorSnapshot(documentId, loadError)
|
|
408
|
-
: createLoadingSnapshot(
|
|
409
|
-
documentId,
|
|
410
|
-
readOnly,
|
|
411
|
-
guessSourceLabel(initialSourceLabel, initialSnapshot, externalDocSource),
|
|
412
|
-
),
|
|
413
|
-
[
|
|
414
|
-
documentId,
|
|
415
|
-
externalDocSource,
|
|
416
|
-
initialSnapshot,
|
|
417
|
-
initialSourceLabel,
|
|
418
|
-
loadError,
|
|
419
|
-
readOnly,
|
|
420
|
-
],
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
const snapshot = useSyncExternalStore(
|
|
424
|
-
(listener) => runtime?.subscribe(listener) ?? (() => undefined),
|
|
425
|
-
() => runtime?.getRenderSnapshot() ?? fallbackSnapshot,
|
|
426
|
-
() => runtime?.getRenderSnapshot() ?? fallbackSnapshot,
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
const activeRuntime = runtime ?? optimisticRuntime;
|
|
430
|
-
|
|
431
|
-
useImperativeHandle(
|
|
432
|
-
ref,
|
|
433
|
-
() => ({
|
|
434
|
-
focus: () => activeRuntime.focus(),
|
|
435
|
-
blur: () => activeRuntime.blur(),
|
|
436
|
-
undo: () => activeRuntime.undo(),
|
|
437
|
-
redo: () => activeRuntime.redo(),
|
|
438
|
-
addComment: (params) =>
|
|
439
|
-
activeRuntime.addComment({
|
|
440
|
-
...params,
|
|
441
|
-
authorId: params.authorId ?? currentUser.userId,
|
|
442
|
-
}),
|
|
443
|
-
openComment: (commentId) => activeRuntime.openComment(commentId),
|
|
444
|
-
resolveComment: (commentId) => activeRuntime.resolveComment(commentId),
|
|
445
|
-
reopenComment: (commentId) => activeRuntime.reopenComment(commentId),
|
|
446
|
-
addCommentReply: (commentId, body) =>
|
|
447
|
-
activeRuntime.addCommentReply(commentId, body, currentUser.userId),
|
|
448
|
-
editCommentBody: (commentId, body) =>
|
|
449
|
-
activeRuntime.editCommentBody(commentId, body),
|
|
450
|
-
acceptChange: (changeId) => activeRuntime.acceptChange(changeId),
|
|
451
|
-
rejectChange: (changeId) => activeRuntime.rejectChange(changeId),
|
|
452
|
-
acceptAllChanges: () => activeRuntime.acceptAllChanges(),
|
|
453
|
-
rejectAllChanges: () => activeRuntime.rejectAllChanges(),
|
|
454
|
-
exportDocx: (options) =>
|
|
455
|
-
runtime
|
|
456
|
-
? persistAndExport({
|
|
457
|
-
datastore: datastoreRef.current,
|
|
458
|
-
documentId,
|
|
459
|
-
runtime,
|
|
460
|
-
onError: onErrorRef.current,
|
|
461
|
-
onEvent: onEventRef.current,
|
|
462
|
-
options,
|
|
463
|
-
lastSavedRevisionTokenRef,
|
|
464
|
-
autosaveTimerRef,
|
|
465
|
-
})
|
|
466
|
-
: rejectExportWhileLoading({
|
|
467
|
-
documentId,
|
|
468
|
-
datastore: datastoreRef.current,
|
|
469
|
-
onError: onErrorRef.current,
|
|
470
|
-
onEvent: onEventRef.current,
|
|
471
|
-
}),
|
|
472
|
-
getSnapshot: () => activeRuntime.getPersistedSnapshot(),
|
|
473
|
-
getCompatibilityReport: () => activeRuntime.getCompatibilityReport(),
|
|
474
|
-
getWarnings: () => activeRuntime.getWarnings(),
|
|
475
|
-
}),
|
|
476
|
-
[activeRuntime, currentUser.userId, documentId, runtime],
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
useEffect(() => {
|
|
480
|
-
if (!datastoreRef.current || props.autosave?.enabled === false || !runtime || readOnly) {
|
|
481
|
-
if (autosaveTimerRef.current) {
|
|
482
|
-
clearTimeout(autosaveTimerRef.current);
|
|
483
|
-
autosaveTimerRef.current = null;
|
|
484
|
-
}
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (!snapshot.isReady || !snapshot.isDirty) {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (lastSavedRevisionTokenRef.current === snapshot.revisionToken) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
if (autosaveTimerRef.current) {
|
|
497
|
-
clearTimeout(autosaveTimerRef.current);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
const debounceMs = props.autosave?.debounceMs ?? 800;
|
|
501
|
-
if (debounceMs <= 0) {
|
|
502
|
-
void persistSnapshot({
|
|
503
|
-
datastore: datastoreRef.current,
|
|
504
|
-
documentId,
|
|
505
|
-
runtime,
|
|
506
|
-
isAutosave: true,
|
|
507
|
-
onError: onErrorRef.current,
|
|
508
|
-
onEvent: onEventRef.current,
|
|
509
|
-
lastSavedRevisionTokenRef,
|
|
510
|
-
});
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
autosaveTimerRef.current = setTimeout(() => {
|
|
515
|
-
void persistSnapshot({
|
|
516
|
-
datastore: datastoreRef.current,
|
|
517
|
-
documentId,
|
|
518
|
-
runtime,
|
|
519
|
-
isAutosave: true,
|
|
520
|
-
onError: onErrorRef.current,
|
|
521
|
-
onEvent: onEventRef.current,
|
|
522
|
-
lastSavedRevisionTokenRef,
|
|
523
|
-
});
|
|
524
|
-
}, debounceMs);
|
|
525
|
-
|
|
526
|
-
return () => {
|
|
527
|
-
if (autosaveTimerRef.current) {
|
|
528
|
-
clearTimeout(autosaveTimerRef.current);
|
|
529
|
-
autosaveTimerRef.current = null;
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
}, [
|
|
533
|
-
documentId,
|
|
534
|
-
props.autosave?.debounceMs,
|
|
535
|
-
props.autosave?.enabled,
|
|
536
|
-
readOnly,
|
|
537
|
-
runtime,
|
|
538
|
-
snapshot.isDirty,
|
|
539
|
-
snapshot.isReady,
|
|
540
|
-
snapshot.revisionToken,
|
|
541
|
-
]);
|
|
542
|
-
|
|
543
|
-
// Auto-select the most relevant rail tab based on content.
|
|
544
|
-
// Health tab was moved to toolbar popover — rail has only comments/changes.
|
|
545
|
-
useEffect(() => {
|
|
546
|
-
if (
|
|
547
|
-
activeRailTab === "comments" &&
|
|
548
|
-
snapshot.comments.totalCount === 0 &&
|
|
549
|
-
snapshot.trackedChanges.totalCount > 0
|
|
550
|
-
) {
|
|
551
|
-
setActiveRailTab("changes");
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
}, [
|
|
555
|
-
activeRailTab,
|
|
556
|
-
loadError,
|
|
557
|
-
snapshot.comments.totalCount,
|
|
558
|
-
snapshot.compatibility.blockExport,
|
|
559
|
-
snapshot.fatalError,
|
|
560
|
-
snapshot.trackedChanges.totalCount,
|
|
561
|
-
]);
|
|
562
|
-
|
|
563
|
-
function focusAnchor(anchor: PublicSelectionSnapshot["activeRange"]): void {
|
|
564
|
-
if (anchor.kind === "detached") {
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
activeRuntime.dispatch({
|
|
569
|
-
type: "selection.set",
|
|
570
|
-
selection: toRuntimeSelectionSnapshot(createSelectionFromAnchor(anchor)),
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function addReviewComment(): void {
|
|
575
|
-
activeRuntime.addComment({
|
|
576
|
-
anchor: snapshot.selection.activeRange,
|
|
577
|
-
body: "New review comment",
|
|
578
|
-
authorId: currentUser.userId,
|
|
579
|
-
});
|
|
580
|
-
setActiveRailTab("comments");
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function exportCurrentDocument(): void {
|
|
584
|
-
void (runtime
|
|
585
|
-
? persistAndExport({
|
|
586
|
-
datastore: datastoreRef.current,
|
|
587
|
-
documentId,
|
|
588
|
-
runtime,
|
|
589
|
-
onError: onErrorRef.current,
|
|
590
|
-
onEvent: onEventRef.current,
|
|
591
|
-
lastSavedRevisionTokenRef,
|
|
592
|
-
autosaveTimerRef,
|
|
593
|
-
})
|
|
594
|
-
: rejectExportWhileLoading({
|
|
595
|
-
documentId,
|
|
596
|
-
datastore: datastoreRef.current,
|
|
597
|
-
onError: onErrorRef.current,
|
|
598
|
-
onEvent: onEventRef.current,
|
|
599
|
-
}));
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const selectionPreview = summarizeSelectionPreview(snapshot);
|
|
603
|
-
const capabilities = deriveCapabilities(snapshot, reviewMode);
|
|
604
|
-
|
|
605
|
-
const dispatchSelection = (selection: PublicSelectionSnapshot) =>
|
|
606
|
-
activeRuntime.dispatch({
|
|
607
|
-
type: "selection.set",
|
|
608
|
-
selection: toRuntimeSelectionSnapshot(selection),
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
const editorCallbacks = {
|
|
612
|
-
onFocus: () => activeRuntime.focus(),
|
|
613
|
-
onBlur: () => activeRuntime.blur(),
|
|
614
|
-
onSelectionChange: dispatchSelection,
|
|
615
|
-
onInsertText: (text: string) => activeRuntime.dispatch({ type: "text.insert", text }),
|
|
616
|
-
onDeleteBackward: () => activeRuntime.dispatch({ type: "text.delete-backward" }),
|
|
617
|
-
onDeleteForward: () => activeRuntime.dispatch({ type: "text.delete-forward" }),
|
|
618
|
-
onInsertTab: () => activeRuntime.dispatch({ type: "text.insert-tab" }),
|
|
619
|
-
onInsertHardBreak: () => activeRuntime.dispatch({ type: "text.insert-hard-break" }),
|
|
620
|
-
onSplitParagraph: () => activeRuntime.dispatch({ type: "paragraph.split" }),
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
const reviewCallbacks = {
|
|
624
|
-
onUndo: () => activeRuntime.undo(),
|
|
625
|
-
onRedo: () => activeRuntime.redo(),
|
|
626
|
-
onAddComment: addReviewComment,
|
|
627
|
-
onExport: exportCurrentDocument,
|
|
628
|
-
onOpenComment: (thread: typeof snapshot.comments.threads[number]) => {
|
|
629
|
-
activeRuntime.openComment(thread.commentId);
|
|
630
|
-
focusAnchor(thread.anchor);
|
|
631
|
-
setActiveRailTab("comments");
|
|
632
|
-
},
|
|
633
|
-
onResolveComment: (commentId: string) => {
|
|
634
|
-
activeRuntime.resolveComment(commentId);
|
|
635
|
-
setActiveRailTab("comments");
|
|
636
|
-
},
|
|
637
|
-
onReopenComment: (commentId: string) => {
|
|
638
|
-
activeRuntime.reopenComment(commentId);
|
|
639
|
-
setActiveRailTab("comments");
|
|
640
|
-
},
|
|
641
|
-
onAddReply: (commentId: string, body: string) => {
|
|
642
|
-
activeRuntime.addCommentReply(commentId, body, currentUser.userId);
|
|
643
|
-
},
|
|
644
|
-
onEditBody: (commentId: string, body: string) => {
|
|
645
|
-
activeRuntime.editCommentBody(commentId, body);
|
|
646
|
-
},
|
|
647
|
-
onOpenRevision: (revision: typeof snapshot.trackedChanges.revisions[number]) => {
|
|
648
|
-
setActiveRevisionId(revision.revisionId);
|
|
649
|
-
focusAnchor(revision.anchor);
|
|
650
|
-
setActiveRailTab("changes");
|
|
651
|
-
},
|
|
652
|
-
onAcceptRevision: (revisionId: string) => {
|
|
653
|
-
activeRuntime.acceptChange(revisionId);
|
|
654
|
-
setActiveRailTab("changes");
|
|
655
|
-
},
|
|
656
|
-
onRejectRevision: (revisionId: string) => {
|
|
657
|
-
activeRuntime.rejectChange(revisionId);
|
|
658
|
-
setActiveRailTab("changes");
|
|
659
|
-
},
|
|
660
|
-
onAcceptAllChanges: () => {
|
|
661
|
-
activeRuntime.acceptAllChanges();
|
|
662
|
-
setActiveRailTab("changes");
|
|
663
|
-
},
|
|
664
|
-
onRejectAllChanges: () => {
|
|
665
|
-
activeRuntime.rejectAllChanges();
|
|
666
|
-
setActiveRailTab("changes");
|
|
667
|
-
},
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
return (
|
|
671
|
-
<TwReviewWorkspace
|
|
672
|
-
snapshot={snapshot}
|
|
673
|
-
currentUserId={currentUser.userId}
|
|
674
|
-
capabilities={capabilities}
|
|
675
|
-
reviewMode={reviewMode}
|
|
676
|
-
viewMode={viewMode}
|
|
677
|
-
activeRailTab={activeRailTab}
|
|
678
|
-
activeCommentId={snapshot.comments.activeCommentId}
|
|
679
|
-
activeRevisionId={activeRevisionId}
|
|
680
|
-
showTrackedChanges={showTrackedChanges}
|
|
681
|
-
selectionPreview={selectionPreview}
|
|
682
|
-
onViewModeChange={setViewMode}
|
|
683
|
-
onActiveRailTabChange={setActiveRailTab}
|
|
684
|
-
onShowTrackedChangesChange={setShowTrackedChanges}
|
|
685
|
-
{...reviewCallbacks}
|
|
686
|
-
document={
|
|
687
|
-
<TwProseMirrorSurface
|
|
688
|
-
currentUser={currentUser}
|
|
689
|
-
snapshot={snapshot}
|
|
690
|
-
reviewMode={reviewMode}
|
|
691
|
-
markupDisplay={liveMarkupDisplay}
|
|
692
|
-
activeRevisionId={activeRevisionId}
|
|
693
|
-
showTrackedChanges={showTrackedChanges}
|
|
694
|
-
{...editorCallbacks}
|
|
695
|
-
onCommentActivated={(commentId) => {
|
|
696
|
-
activeRuntime.openComment(commentId);
|
|
697
|
-
setActiveRailTab("comments");
|
|
698
|
-
}}
|
|
699
|
-
onRevisionActivated={(revisionId) => {
|
|
700
|
-
setActiveRevisionId(revisionId);
|
|
701
|
-
setActiveRailTab("changes");
|
|
702
|
-
}}
|
|
703
|
-
/>
|
|
704
|
-
}
|
|
705
|
-
/>
|
|
706
|
-
);
|
|
707
|
-
},
|
|
708
|
-
);
|
|
709
|
-
|
|
710
|
-
function normalizeEditorError(error: unknown): EditorError {
|
|
711
|
-
if (
|
|
712
|
-
typeof error === "object" &&
|
|
713
|
-
error !== null &&
|
|
714
|
-
"errorId" in error &&
|
|
715
|
-
"code" in error &&
|
|
716
|
-
"message" in error
|
|
717
|
-
) {
|
|
718
|
-
return error as EditorError;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
return {
|
|
722
|
-
errorId: "word-review-editor-load",
|
|
723
|
-
code: "internal_invariant",
|
|
724
|
-
message: error instanceof Error ? error.message : "Unknown editor load failure.",
|
|
725
|
-
isFatal: true,
|
|
726
|
-
source: "runtime",
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function guessSourceLabel(
|
|
731
|
-
initialSourceLabel?: string,
|
|
732
|
-
initialSnapshot?: PersistedEditorSnapshot,
|
|
733
|
-
externalDocSource?: WordReviewEditorProps["externalDocSource"],
|
|
734
|
-
): string | undefined {
|
|
735
|
-
return (
|
|
736
|
-
externalDocSource?.sourceLabel ??
|
|
737
|
-
initialSourceLabel ??
|
|
738
|
-
initialSnapshot?.editorBuild ??
|
|
739
|
-
undefined
|
|
740
|
-
);
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
function createLoadingSnapshot(
|
|
744
|
-
documentId: string,
|
|
745
|
-
readOnly: boolean,
|
|
746
|
-
sourceLabel?: string,
|
|
747
|
-
): RuntimeRenderSnapshot {
|
|
748
|
-
return {
|
|
749
|
-
documentId,
|
|
750
|
-
sessionId: `${documentId}-loading`,
|
|
751
|
-
sourceLabel,
|
|
752
|
-
revisionToken: `${documentId}:loading`,
|
|
753
|
-
isReady: false,
|
|
754
|
-
isDirty: false,
|
|
755
|
-
readOnly,
|
|
756
|
-
selection: collapsedSelection(),
|
|
757
|
-
documentStats: {
|
|
758
|
-
storyLength: 0,
|
|
759
|
-
commentCount: 0,
|
|
760
|
-
revisionCount: 0,
|
|
761
|
-
opaqueFragmentCount: 0,
|
|
762
|
-
},
|
|
763
|
-
comments: {
|
|
764
|
-
openCommentIds: [],
|
|
765
|
-
resolvedCommentIds: [],
|
|
766
|
-
detachedCommentIds: [],
|
|
767
|
-
totalCount: 0,
|
|
768
|
-
threads: [],
|
|
769
|
-
},
|
|
770
|
-
trackedChanges: {
|
|
771
|
-
pendingChangeIds: [],
|
|
772
|
-
acceptedChangeIds: [],
|
|
773
|
-
rejectedChangeIds: [],
|
|
774
|
-
detachedChangeIds: [],
|
|
775
|
-
actionableChangeIds: [],
|
|
776
|
-
preserveOnlyChangeIds: [],
|
|
777
|
-
totalCount: 0,
|
|
778
|
-
revisions: [],
|
|
779
|
-
},
|
|
780
|
-
compatibility: {
|
|
781
|
-
blockExport: false,
|
|
782
|
-
blockExportReasons: [],
|
|
783
|
-
warningCount: 0,
|
|
784
|
-
errorCount: 0,
|
|
785
|
-
featureEntries: [],
|
|
786
|
-
},
|
|
787
|
-
warnings: [],
|
|
788
|
-
commandState: {
|
|
789
|
-
canUndo: false,
|
|
790
|
-
canRedo: false,
|
|
791
|
-
readOnly,
|
|
792
|
-
},
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
function createErrorSnapshot(documentId: string, error: EditorError): RuntimeRenderSnapshot {
|
|
797
|
-
return {
|
|
798
|
-
...createLoadingSnapshot(documentId, true),
|
|
799
|
-
isReady: true,
|
|
800
|
-
sessionId: `${documentId}-error`,
|
|
801
|
-
revisionToken: `${documentId}:error`,
|
|
802
|
-
compatibility: {
|
|
803
|
-
blockExport: true,
|
|
804
|
-
blockExportReasons: [error.message],
|
|
805
|
-
warningCount: 0,
|
|
806
|
-
errorCount: 1,
|
|
807
|
-
featureEntries: [],
|
|
808
|
-
},
|
|
809
|
-
fatalError: error,
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
async function persistAndExport(input: {
|
|
814
|
-
datastore?: EditorDatastoreAdapter;
|
|
815
|
-
documentId: string;
|
|
816
|
-
runtime: WordReviewEditorRuntime;
|
|
817
|
-
onError?: (error: EditorError) => void;
|
|
818
|
-
onEvent?: (event: WordReviewEditorEvent) => void;
|
|
819
|
-
options?: ExportDocxOptions;
|
|
820
|
-
lastSavedRevisionTokenRef: React.MutableRefObject<string | null>;
|
|
821
|
-
autosaveTimerRef: React.MutableRefObject<ReturnType<typeof setTimeout> | null>;
|
|
822
|
-
}): Promise<ExportResult> {
|
|
823
|
-
if (input.autosaveTimerRef.current) {
|
|
824
|
-
clearTimeout(input.autosaveTimerRef.current);
|
|
825
|
-
input.autosaveTimerRef.current = null;
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
await persistSnapshot({
|
|
829
|
-
datastore: input.datastore,
|
|
830
|
-
documentId: input.documentId,
|
|
831
|
-
runtime: input.runtime,
|
|
832
|
-
isAutosave: false,
|
|
833
|
-
onError: input.onError,
|
|
834
|
-
onEvent: input.onEvent,
|
|
835
|
-
lastSavedRevisionTokenRef: input.lastSavedRevisionTokenRef,
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
const result = await input.runtime.exportDocx(input.options);
|
|
839
|
-
|
|
840
|
-
if (!input.datastore) {
|
|
841
|
-
return result;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
try {
|
|
845
|
-
await input.datastore.saveExport({
|
|
846
|
-
documentId: input.documentId,
|
|
847
|
-
result,
|
|
848
|
-
});
|
|
849
|
-
} catch (error) {
|
|
850
|
-
const normalized = normalizeDatastoreError(error, {
|
|
851
|
-
message: "Export persisted bytes could not be stored.",
|
|
852
|
-
details: {
|
|
853
|
-
operation: "saveExport",
|
|
854
|
-
},
|
|
855
|
-
});
|
|
856
|
-
input.onError?.(normalized);
|
|
857
|
-
emitEditorEvent({
|
|
858
|
-
datastore: input.datastore,
|
|
859
|
-
onEvent: input.onEvent,
|
|
860
|
-
event: {
|
|
861
|
-
type: "error",
|
|
862
|
-
documentId: input.documentId,
|
|
863
|
-
error: normalized,
|
|
864
|
-
},
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
return result;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
function rejectExportWhileLoading(input: {
|
|
872
|
-
documentId: string;
|
|
873
|
-
datastore?: EditorDatastoreAdapter;
|
|
874
|
-
onError?: (error: EditorError) => void;
|
|
875
|
-
onEvent?: (event: WordReviewEditorEvent) => void;
|
|
876
|
-
}): Promise<never> {
|
|
877
|
-
const error: EditorError = {
|
|
878
|
-
errorId: "word-review-editor-loading-export",
|
|
879
|
-
code: "internal_invariant",
|
|
880
|
-
message: "WordReviewEditor is still loading and cannot export yet.",
|
|
881
|
-
isFatal: false,
|
|
882
|
-
source: "runtime",
|
|
883
|
-
};
|
|
884
|
-
input.onError?.(error);
|
|
885
|
-
emitEditorEvent({
|
|
886
|
-
datastore: input.datastore,
|
|
887
|
-
onEvent: input.onEvent,
|
|
888
|
-
event: {
|
|
889
|
-
type: "error",
|
|
890
|
-
documentId: input.documentId,
|
|
891
|
-
error,
|
|
892
|
-
},
|
|
893
|
-
});
|
|
894
|
-
return Promise.reject(error);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
async function persistSnapshot(input: {
|
|
898
|
-
datastore?: EditorDatastoreAdapter;
|
|
899
|
-
documentId: string;
|
|
900
|
-
runtime: WordReviewEditorRuntime;
|
|
901
|
-
isAutosave: boolean;
|
|
902
|
-
onError?: (error: EditorError) => void;
|
|
903
|
-
onEvent?: (event: WordReviewEditorEvent) => void;
|
|
904
|
-
lastSavedRevisionTokenRef: React.MutableRefObject<string | null>;
|
|
905
|
-
}): Promise<void> {
|
|
906
|
-
if (!input.datastore) {
|
|
907
|
-
return;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
const snapshot = input.runtime.getPersistedSnapshot();
|
|
911
|
-
const revisionToken = input.runtime.getRenderSnapshot().revisionToken;
|
|
912
|
-
|
|
913
|
-
if (input.isAutosave) {
|
|
914
|
-
emitEditorEvent({
|
|
915
|
-
datastore: input.datastore,
|
|
916
|
-
onEvent: input.onEvent,
|
|
917
|
-
event: {
|
|
918
|
-
type: "autosave_state",
|
|
919
|
-
documentId: input.documentId,
|
|
920
|
-
state: {
|
|
921
|
-
status: "saving",
|
|
922
|
-
} satisfies AutosaveState,
|
|
923
|
-
},
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
try {
|
|
928
|
-
const result = await input.datastore.saveSnapshot({
|
|
929
|
-
documentId: input.documentId,
|
|
930
|
-
snapshot,
|
|
931
|
-
isAutosave: input.isAutosave,
|
|
932
|
-
});
|
|
933
|
-
const savedSnapshot: PersistedEditorSnapshot = {
|
|
934
|
-
...snapshot,
|
|
935
|
-
savedAt: result.savedAt,
|
|
936
|
-
};
|
|
937
|
-
input.lastSavedRevisionTokenRef.current = revisionToken;
|
|
938
|
-
emitEditorEvent({
|
|
939
|
-
datastore: input.datastore,
|
|
940
|
-
onEvent: input.onEvent,
|
|
941
|
-
event: {
|
|
942
|
-
type: "snapshot_saved",
|
|
943
|
-
documentId: input.documentId,
|
|
944
|
-
snapshot: savedSnapshot,
|
|
945
|
-
isAutosave: input.isAutosave,
|
|
946
|
-
},
|
|
947
|
-
});
|
|
948
|
-
if (input.isAutosave) {
|
|
949
|
-
emitEditorEvent({
|
|
950
|
-
datastore: input.datastore,
|
|
951
|
-
onEvent: input.onEvent,
|
|
952
|
-
event: {
|
|
953
|
-
type: "autosave_state",
|
|
954
|
-
documentId: input.documentId,
|
|
955
|
-
state: {
|
|
956
|
-
status: "saved",
|
|
957
|
-
savedAt: result.savedAt,
|
|
958
|
-
} satisfies AutosaveState,
|
|
959
|
-
},
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
} catch (error) {
|
|
963
|
-
const normalized = normalizeDatastoreError(error, {
|
|
964
|
-
message: input.isAutosave
|
|
965
|
-
? "Autosave failed while storing the editor snapshot."
|
|
966
|
-
: "Snapshot save failed while preparing the export checkpoint.",
|
|
967
|
-
details: {
|
|
968
|
-
operation: "saveSnapshot",
|
|
969
|
-
isAutosave: input.isAutosave,
|
|
970
|
-
},
|
|
971
|
-
});
|
|
972
|
-
input.onError?.(normalized);
|
|
973
|
-
emitEditorEvent({
|
|
974
|
-
datastore: input.datastore,
|
|
975
|
-
onEvent: input.onEvent,
|
|
976
|
-
event: {
|
|
977
|
-
type: "error",
|
|
978
|
-
documentId: input.documentId,
|
|
979
|
-
error: normalized,
|
|
980
|
-
},
|
|
981
|
-
});
|
|
982
|
-
if (input.isAutosave) {
|
|
983
|
-
emitEditorEvent({
|
|
984
|
-
datastore: input.datastore,
|
|
985
|
-
onEvent: input.onEvent,
|
|
986
|
-
event: {
|
|
987
|
-
type: "autosave_state",
|
|
988
|
-
documentId: input.documentId,
|
|
989
|
-
state: {
|
|
990
|
-
status: "error",
|
|
991
|
-
error: normalized,
|
|
992
|
-
} satisfies AutosaveState,
|
|
993
|
-
},
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
if (!input.isAutosave) {
|
|
997
|
-
throw normalized;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
function emitEditorEvent(input: {
|
|
1003
|
-
datastore?: EditorDatastoreAdapter;
|
|
1004
|
-
onEvent?: (event: WordReviewEditorEvent) => void;
|
|
1005
|
-
event: WordReviewEditorEvent;
|
|
1006
|
-
}): void {
|
|
1007
|
-
input.onEvent?.(input.event);
|
|
1008
|
-
input.datastore?.logEvent?.({
|
|
1009
|
-
type: input.event.type,
|
|
1010
|
-
documentId: input.event.documentId,
|
|
1011
|
-
detail: summarizeEventDetail(input.event),
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
function summarizeEventDetail(
|
|
1016
|
-
event: WordReviewEditorEvent,
|
|
1017
|
-
): Record<string, unknown> | undefined {
|
|
1018
|
-
switch (event.type) {
|
|
1019
|
-
case "dirty_changed":
|
|
1020
|
-
return { isDirty: event.isDirty };
|
|
1021
|
-
case "comment_added":
|
|
1022
|
-
return { commentId: event.commentId };
|
|
1023
|
-
case "comment_resolved":
|
|
1024
|
-
return { commentId: event.commentId };
|
|
1025
|
-
case "change_accepted":
|
|
1026
|
-
case "change_rejected":
|
|
1027
|
-
return { changeId: event.changeId };
|
|
1028
|
-
case "warning_added":
|
|
1029
|
-
return { warningId: event.warning.warningId, code: event.warning.code };
|
|
1030
|
-
case "warning_cleared":
|
|
1031
|
-
return { warningId: event.warningId, code: event.code };
|
|
1032
|
-
case "error":
|
|
1033
|
-
return { errorId: event.error.errorId, code: event.error.code };
|
|
1034
|
-
case "autosave_state":
|
|
1035
|
-
return { status: event.state.status };
|
|
1036
|
-
case "snapshot_saved":
|
|
1037
|
-
return { isAutosave: event.isAutosave, savedAt: event.snapshot.savedAt };
|
|
1038
|
-
case "export_completed":
|
|
1039
|
-
return { fileName: event.result.fileName };
|
|
1040
|
-
case "selection_changed":
|
|
1041
|
-
return {
|
|
1042
|
-
anchor: event.selection.anchor,
|
|
1043
|
-
head: event.selection.head,
|
|
1044
|
-
};
|
|
1045
|
-
case "ready":
|
|
1046
|
-
return {
|
|
1047
|
-
source: event.source,
|
|
1048
|
-
blockExport: event.compatibility.blockExport,
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
function createReadyEvent(
|
|
1054
|
-
runtime: Pick<WordReviewEditorRuntime, "getCompatibilityReport" | "getRenderSnapshot">,
|
|
1055
|
-
source: "docx" | "snapshot" | "datastore" | "canonical",
|
|
1056
|
-
): Extract<WordReviewEditorEvent, { type: "ready" }> {
|
|
1057
|
-
const snapshot = runtime.getRenderSnapshot();
|
|
1058
|
-
return {
|
|
1059
|
-
type: "ready",
|
|
1060
|
-
documentId: snapshot.documentId,
|
|
1061
|
-
sessionId: snapshot.sessionId,
|
|
1062
|
-
source,
|
|
1063
|
-
stats: snapshot.documentStats,
|
|
1064
|
-
compatibility: runtime.getCompatibilityReport(),
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
function normalizeDatastoreError(
|
|
1069
|
-
error: unknown,
|
|
1070
|
-
fallback: {
|
|
1071
|
-
message: string;
|
|
1072
|
-
details?: Record<string, unknown>;
|
|
1073
|
-
},
|
|
1074
|
-
): EditorError {
|
|
1075
|
-
if (
|
|
1076
|
-
typeof error === "object" &&
|
|
1077
|
-
error !== null &&
|
|
1078
|
-
"errorId" in error &&
|
|
1079
|
-
"code" in error &&
|
|
1080
|
-
"message" in error
|
|
1081
|
-
) {
|
|
1082
|
-
return error as EditorError;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
return {
|
|
1086
|
-
errorId: "word-review-editor-datastore",
|
|
1087
|
-
code: "datastore_failed",
|
|
1088
|
-
message: error instanceof Error ? error.message : fallback.message,
|
|
1089
|
-
isFatal: false,
|
|
1090
|
-
source: "datastore",
|
|
1091
|
-
details: fallback.details,
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
function createFallbackSnapshot(args: CreateRuntimeArgs): RuntimeRenderSnapshot {
|
|
1096
|
-
const warnings = args.source.initialSnapshot?.warningLog ?? [];
|
|
1097
|
-
const compatibility = args.source.initialSnapshot?.compatibility ?? emptyCompatibilityReport();
|
|
1098
|
-
|
|
1099
|
-
return {
|
|
1100
|
-
...createLoadingSnapshot(args.documentId, args.readOnly, args.source.sourceLabel),
|
|
1101
|
-
sessionId: `${args.documentId}-session`,
|
|
1102
|
-
revisionToken: `${args.documentId}:0`,
|
|
1103
|
-
isReady: true,
|
|
1104
|
-
documentStats: {
|
|
1105
|
-
storyLength: estimateStoryLength(args.source.initialSnapshot),
|
|
1106
|
-
commentCount: 0,
|
|
1107
|
-
revisionCount: 0,
|
|
1108
|
-
opaqueFragmentCount: 0,
|
|
1109
|
-
},
|
|
1110
|
-
compatibility: {
|
|
1111
|
-
blockExport: compatibility.blockExport,
|
|
1112
|
-
blockExportReasons: [],
|
|
1113
|
-
warningCount: compatibility.warnings.length,
|
|
1114
|
-
errorCount: compatibility.errors.length,
|
|
1115
|
-
featureEntries: compatibility.featureEntries,
|
|
1116
|
-
},
|
|
1117
|
-
warnings,
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
function createFallbackPersistedSnapshot(
|
|
1122
|
-
documentId: string,
|
|
1123
|
-
label = "Generated shell snapshot",
|
|
1124
|
-
): PersistedEditorSnapshot {
|
|
1125
|
-
const docId = createCanonicalDocumentId(documentId);
|
|
1126
|
-
return {
|
|
1127
|
-
snapshotVersion: "persisted-editor-snapshot/1",
|
|
1128
|
-
schemaVersion: "cds/1.0.0",
|
|
1129
|
-
documentId,
|
|
1130
|
-
docId,
|
|
1131
|
-
createdAt: "1970-01-01T00:00:00.000Z",
|
|
1132
|
-
updatedAt: "1970-01-01T00:00:00.000Z",
|
|
1133
|
-
savedAt: "1970-01-01T00:00:00.000Z",
|
|
1134
|
-
editorBuild: label,
|
|
1135
|
-
canonicalDocument: {
|
|
1136
|
-
schemaVersion: "cds/1.0.0",
|
|
1137
|
-
docId,
|
|
1138
|
-
createdAt: "1970-01-01T00:00:00.000Z",
|
|
1139
|
-
updatedAt: "1970-01-01T00:00:00.000Z",
|
|
1140
|
-
metadata: {
|
|
1141
|
-
customProperties: {},
|
|
1142
|
-
},
|
|
1143
|
-
styles: {
|
|
1144
|
-
paragraphs: {},
|
|
1145
|
-
characters: {},
|
|
1146
|
-
tables: {},
|
|
1147
|
-
},
|
|
1148
|
-
numbering: {
|
|
1149
|
-
abstractDefinitions: {},
|
|
1150
|
-
instances: {},
|
|
1151
|
-
},
|
|
1152
|
-
media: {
|
|
1153
|
-
items: {},
|
|
1154
|
-
},
|
|
1155
|
-
content: {
|
|
1156
|
-
type: "doc",
|
|
1157
|
-
children: [{ type: "paragraph", children: [] }],
|
|
1158
|
-
},
|
|
1159
|
-
review: {
|
|
1160
|
-
comments: {},
|
|
1161
|
-
revisions: {},
|
|
1162
|
-
},
|
|
1163
|
-
preservation: {
|
|
1164
|
-
opaqueFragments: {},
|
|
1165
|
-
packageParts: {},
|
|
1166
|
-
},
|
|
1167
|
-
diagnostics: {
|
|
1168
|
-
warnings: [],
|
|
1169
|
-
errors: [],
|
|
1170
|
-
},
|
|
1171
|
-
},
|
|
1172
|
-
compatibility: emptyCompatibilityReport(),
|
|
1173
|
-
warningLog: [],
|
|
1174
|
-
};
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
function emptyCompatibilityReport(): CompatibilityReport {
|
|
1178
|
-
return {
|
|
1179
|
-
reportVersion: "compatibility-report/1",
|
|
1180
|
-
generatedAt: "1970-01-01T00:00:00.000Z",
|
|
1181
|
-
blockExport: false,
|
|
1182
|
-
featureEntries: [],
|
|
1183
|
-
warnings: [],
|
|
1184
|
-
errors: [],
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
function toRuntimeSelectionSnapshot(selection: PublicSelectionSnapshot) {
|
|
1189
|
-
return {
|
|
1190
|
-
anchor: selection.anchor,
|
|
1191
|
-
head: selection.head,
|
|
1192
|
-
isCollapsed: selection.isCollapsed,
|
|
1193
|
-
activeRange:
|
|
1194
|
-
selection.activeRange.kind === "range"
|
|
1195
|
-
? createRangeAnchor(
|
|
1196
|
-
selection.activeRange.from,
|
|
1197
|
-
selection.activeRange.to,
|
|
1198
|
-
selection.activeRange.assoc,
|
|
1199
|
-
)
|
|
1200
|
-
: selection.activeRange.kind === "node"
|
|
1201
|
-
? createNodeAnchor(selection.activeRange.at, selection.activeRange.assoc)
|
|
1202
|
-
: createDetachedAnchor(
|
|
1203
|
-
selection.activeRange.lastKnownRange,
|
|
1204
|
-
selection.activeRange.reason,
|
|
1205
|
-
),
|
|
1206
|
-
};
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
function createSelectionFromAnchor(
|
|
1210
|
-
anchor: PublicSelectionSnapshot["activeRange"],
|
|
1211
|
-
): PublicSelectionSnapshot {
|
|
1212
|
-
switch (anchor.kind) {
|
|
1213
|
-
case "range":
|
|
1214
|
-
return {
|
|
1215
|
-
anchor: anchor.from,
|
|
1216
|
-
head: anchor.to,
|
|
1217
|
-
isCollapsed: anchor.from === anchor.to,
|
|
1218
|
-
activeRange: anchor,
|
|
1219
|
-
};
|
|
1220
|
-
case "node":
|
|
1221
|
-
return {
|
|
1222
|
-
anchor: anchor.at,
|
|
1223
|
-
head: anchor.at,
|
|
1224
|
-
isCollapsed: true,
|
|
1225
|
-
activeRange: anchor,
|
|
1226
|
-
};
|
|
1227
|
-
case "detached":
|
|
1228
|
-
return {
|
|
1229
|
-
anchor: anchor.lastKnownRange.from,
|
|
1230
|
-
head: anchor.lastKnownRange.to,
|
|
1231
|
-
isCollapsed: anchor.lastKnownRange.from === anchor.lastKnownRange.to,
|
|
1232
|
-
activeRange: anchor,
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
function estimateStoryLength(snapshot?: PersistedEditorSnapshot): number {
|
|
1238
|
-
const content = snapshot?.canonicalDocument.content;
|
|
1239
|
-
return Array.isArray(content) ? content.length : 0;
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
function collapsedSelection(): RuntimeRenderSnapshot["selection"] {
|
|
1243
|
-
return {
|
|
1244
|
-
anchor: 0,
|
|
1245
|
-
head: 0,
|
|
1246
|
-
isCollapsed: true,
|
|
1247
|
-
activeRange: {
|
|
1248
|
-
kind: "range",
|
|
1249
|
-
from: 0,
|
|
1250
|
-
to: 0,
|
|
1251
|
-
assoc: {
|
|
1252
|
-
start: -1,
|
|
1253
|
-
end: 1,
|
|
1254
|
-
},
|
|
1255
|
-
},
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
function toUint8Array(bytes: Uint8Array | ArrayBuffer): Uint8Array {
|
|
1260
|
-
return bytes instanceof Uint8Array ? new Uint8Array(bytes) : new Uint8Array(bytes);
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
function summarizeSelectionPreview(snapshot: RuntimeRenderSnapshot): string | null {
|
|
1264
|
-
if (!snapshot.surface || snapshot.selection.isCollapsed) {
|
|
1265
|
-
return null;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
const range = snapshot.selection.activeRange;
|
|
1269
|
-
if (range.kind !== "range") {
|
|
1270
|
-
return "Selected range";
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
const preview = snapshot.surface.plainText
|
|
1274
|
-
.slice(range.from, range.to)
|
|
1275
|
-
.replace(/\s+/g, " ")
|
|
1276
|
-
.trim();
|
|
1277
|
-
|
|
1278
|
-
if (!preview) {
|
|
1279
|
-
return "Selected range";
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
return preview.length > 48 ? `${preview.slice(0, 45)}...` : preview;
|
|
1283
|
-
}
|