@beyondwork/docx-react-component 1.0.109 → 1.0.111

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 (59) hide show
  1. package/package.json +1 -1
  2. package/src/api/public-types.ts +3 -0
  3. package/src/model/layout/page-graph-types.ts +33 -0
  4. package/src/model/layout/runtime-page-graph-types.ts +25 -0
  5. package/src/runtime/document-runtime.ts +46 -0
  6. package/src/runtime/geometry/adjacent-geometry-intake.ts +820 -15
  7. package/src/runtime/geometry/caret-geometry.ts +219 -7
  8. package/src/runtime/geometry/geometry-index.ts +52 -12
  9. package/src/runtime/geometry/object-handles.ts +42 -1
  10. package/src/runtime/layout/index.ts +3 -0
  11. package/src/runtime/layout/inert-layout-facet.ts +13 -0
  12. package/src/runtime/layout/layout-engine-instance.ts +233 -4
  13. package/src/runtime/layout/layout-engine-version.ts +47 -2
  14. package/src/runtime/layout/layout-facet-types.ts +3 -0
  15. package/src/runtime/layout/page-graph.ts +88 -7
  16. package/src/runtime/layout/paginated-layout-engine.ts +34 -0
  17. package/src/runtime/layout/project-block-fragments.ts +144 -1
  18. package/src/runtime/layout/public-facet.ts +228 -9
  19. package/src/runtime/layout/resolve-page-previews.ts +46 -8
  20. package/src/runtime/scopes/adjacent-geometry-evidence.ts +456 -0
  21. package/src/runtime/scopes/compile-scope-bundle.ts +8 -0
  22. package/src/runtime/scopes/evidence.ts +16 -0
  23. package/src/runtime/scopes/index.ts +13 -0
  24. package/src/runtime/scopes/semantic-scope-types.ts +67 -0
  25. package/src/ui-tailwind/chrome-overlay/tw-table-split-row-carry-overlay.tsx +62 -0
  26. package/src/ui-tailwind/debug/layer11-consumer-readiness.ts +104 -0
  27. package/src/ui-tailwind/editor-surface/pm-page-break-decorations.ts +50 -5
  28. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +27 -0
  29. package/src/ui-tailwind/page-stack/tw-page-chrome-entry.tsx +62 -0
  30. package/src/ui-tailwind/page-stack/tw-page-stack-chrome-layer.tsx +1 -0
  31. package/src/README.md +0 -85
  32. package/src/api/README.md +0 -26
  33. package/src/api/v3/README.md +0 -91
  34. package/src/component-inventory.md +0 -99
  35. package/src/core/README.md +0 -10
  36. package/src/core/commands/README.md +0 -3
  37. package/src/core/schema/README.md +0 -3
  38. package/src/core/selection/README.md +0 -3
  39. package/src/core/state/README.md +0 -3
  40. package/src/io/README.md +0 -10
  41. package/src/io/export/README.md +0 -3
  42. package/src/io/normalize/README.md +0 -3
  43. package/src/io/ooxml/README.md +0 -3
  44. package/src/io/opc/README.md +0 -3
  45. package/src/model/README.md +0 -3
  46. package/src/preservation/README.md +0 -3
  47. package/src/review/README.md +0 -16
  48. package/src/review/store/README.md +0 -3
  49. package/src/runtime/README.md +0 -3
  50. package/src/ui/README.md +0 -30
  51. package/src/ui/comments/README.md +0 -3
  52. package/src/ui/compatibility/README.md +0 -3
  53. package/src/ui/editor-surface/README.md +0 -3
  54. package/src/ui/review/README.md +0 -3
  55. package/src/ui/status/README.md +0 -3
  56. package/src/ui/theme/README.md +0 -3
  57. package/src/ui/toolbar/README.md +0 -3
  58. package/src/ui-tailwind/debug/README.md +0 -22
  59. package/src/validation/README.md +0 -3
@@ -1,91 +0,0 @@
1
- # `src/api/v3/` — End-state public API surface
2
-
3
- > **@endStateApi v3** — the canonical Beyond Work build-team contract.
4
- > Do NOT treat this as a rename of `WordReviewEditorRef`. It is a
5
- > separate, additive API that mirrors the target architecture in
6
- > [`docs/architecture/00-overview.md`](../../../docs/architecture/00-overview.md)
7
- > (Runtime API + AI API split per §9 + §10).
8
-
9
- ## What this directory is
10
-
11
- - The shape every new Beyond Work consumer builds against, today.
12
- - Each function carries `ApiV3FnMetadata` declaring
13
- `status: "mock" | "partial" | "live-with-adapter" | "live"`, its
14
- target layer, UX intent, and agent metadata.
15
- - Every UX-visible function emits one `UxResponse` event on the
16
- `api` telemetry channel per invocation so the future debug UX
17
- (Phase Q) and agent-facing audit can observe it identically in
18
- mock and live modes.
19
-
20
- ### Four-status taxonomy (Phase P')
21
-
22
- | Status | Meaning |
23
- |---|---|
24
- | `mock` | No live path attempted; returns a `mockPayload(...)` / `mockArray(...)` carrying `__mock: true`. |
25
- | `partial` | Live path attempted; falls back to a mock-shaped payload when the runtime cannot satisfy it. `mockShape` is required. |
26
- | `live-with-adapter` | Delegates to a real runtime/facet method through a nontrivial adapter or composition layer. `mockShape` optional. |
27
- | `live` | Direct delegation to a single runtime/facet method. `mockShape` is forbidden. |
28
-
29
- The current distribution (as reported by the authoritative
30
- `test/runtime/debug/api-contract.test.ts` runner) is `9 live / 18
31
- live-with-adapter / 1 partial / 7 mock / 35 total`. See the Changelog
32
- in [`docs/reference/public-api.md`](../../../docs/reference/public-api.md)
33
- for the latest entry.
34
-
35
- ## What this directory is NOT
36
-
37
- - NOT a re-export of the existing `WordReviewEditorRef`. The two CI
38
- guards `scripts/ci-check-api-v3-no-ref-reexport.mjs` and
39
- `scripts/ci-check-api-v3-metadata.mjs` enforce this. Adding a
40
- convenience re-export of a ref method trips the guard.
41
- - NOT the place for internal runtime refactoring (`src/session/`,
42
- `src/runtime/formatting/`, etc.). That work lands behind this
43
- surface — v3 stays stable while internals move.
44
- - NOT a sandbox. `status: "live"` functions MUST parity-match the
45
- underlying runtime behavior (asserted in per-family tests).
46
-
47
- ## Consumers
48
-
49
- - **Beyond Work build team** (canonical). Import via
50
- `import { createApiV3 } from "@beyondwork/docx-react-component/api/v3"`.
51
- - **Debug UX (Phase Q)**. Uses `UxResponse` events to render mock-or-live
52
- visualizations.
53
- - **Phase D runners** (Layer-level validators). Use `createApiV3` as the
54
- single entry point so runners don't depend on internal runtime shape.
55
-
56
- ## Graduating a function's status
57
-
58
- The intended progression is `mock → partial → live-with-adapter → live`.
59
- Skipping a stage is allowed when justified, but each flip requires
60
- evidence:
61
-
62
- 1. Implement the live path (delegate to the appropriate runtime
63
- facet or layer extractor). For `live-with-adapter`, write the
64
- adapter/composition in the family file; for `live`, the body
65
- must be a single delegation call.
66
- 2. Add a validator log entry under `services/debug/docs/` with the
67
- new evidence.
68
- 3. Update the function's `<fnName>Metadata.liveEvidence` field to
69
- point at the log + the commit SHA; update `mockShape` per the
70
- taxonomy rules above (required for `mock` and `partial`, optional
71
- for `live-with-adapter`, forbidden for `live`).
72
- 4. Update the per-family test's parity assertion and the matching
73
- inline `// @endStateApi — <status>.` comment on the function
74
- body so the status-drift canary stays green.
75
-
76
- Silent flips — changing `status` without updating `liveEvidence` or
77
- the inline annotation — are a review-time reject.
78
-
79
- ## Canonical reference doc
80
-
81
- [`docs/reference/public-api.md`](../../../docs/reference/public-api.md).
82
- That's the URL the BW team bookmarks. This README is the in-repo
83
- maintainer-facing companion.
84
-
85
- ## Phase Q (debug UX refactor) dependency
86
-
87
- Phase Q ships a runtime-embedded debug UX (`src/ui-tailwind/debug/**`)
88
- that subscribes to the `UxResponse` event stream emitted from this
89
- directory. Phase Q does NOT re-import the existing harness debug
90
- panel — it renders against `UxResponse` + `runtime.debug.getSnapshot`
91
- directly. See the Phase P plan for the full Phase Q spec.
@@ -1,99 +0,0 @@
1
- # Component Inventory
2
-
3
- This file is the source-owned inventory for the major subsystems in the active docx implementation.
4
-
5
- Wave 0 established the scaffold and ownership boundaries. Wave 1 froze the contract surface for the editor-side components listed below. That promotion does not claim implementation completeness; it means the subsystem boundaries, contract artifacts, and proof expectations are now explicit enough for later docx waves to build against without reopening the architecture.
6
-
7
- This inventory does not yet track:
8
-
9
- - shared OOXML platform extraction as a separate source area
10
- - a future xlsx runtime inventory
11
- - future pdf work
12
-
13
- ## Inventory Table
14
-
15
- | Component | Current target | Primary paths | Scope in this repo phase | Contract and proof surfaces |
16
- | --- | --- | --- | --- | --- |
17
- | `canonical-document-model` | `contract-frozen` | `src/model/`, `src/api/` | Versioned canonical envelope, persisted snapshot shape, migration boundary, document metadata ownership | `docs/plans/waves/specs/wave-1-component-boundaries.md`, `docs/plans/waves/specs/wave-1-runtime-contracts.md`, schema docs, canonical JSON examples, model tests |
18
- | `command-and-transaction-runtime` | `contract-frozen` | `src/core/`, `src/runtime/` | Deterministic commands, transactions, mapping, selection semantics, runtime mutation boundary | `docs/plans/waves/specs/wave-1-component-boundaries.md`, `docs/plans/waves/specs/wave-1-runtime-contracts.md`, command tests, mapping tests, state-transition proofs |
19
- | `comments-and-anchor-mapping` | `contract-frozen` | `src/review/`, `src/core/selection/` | Comment threads, anchor remapping, review selectors, edit-safe anchor mapping policy | `docs/plans/waves/specs/wave-1-review-and-ui-contracts.md`, `docs/plans/waves/specs/wave-1-runtime-contracts.md`, anchor remap tests, threaded comment fixtures, review model docs |
20
- | `tracked-changes-and-review-actions` | `contract-frozen` | `src/review/`, `src/ui/review/` | Revision records, display modes, accept/reject boundaries, review-oriented commands | `docs/plans/waves/specs/wave-1-review-and-ui-contracts.md`, revision fixtures, accept/reject tests, review-state mapping tests |
21
- | `docx-import-and-normalization` | `contract-frozen` | `src/io/opc/`, `src/io/ooxml/`, `src/io/normalize/` | OPC opening, WordprocessingML parsing, normalization into canonical state, support classification inputs | `docs/plans/waves/specs/wave-1-ooxml-contracts.md`, `.docx` import fixtures, normalization tests, supported-feature mapping docs |
22
- | `docx-export-and-serialization` | `contract-frozen` | `src/io/export/`, `src/io/opc/` | Regenerated OOXML parts, package writing, relationship integrity, supported-feature serialization | `docs/plans/waves/specs/wave-1-ooxml-contracts.md`, round-trip fixtures, export validation tests, serializer docs |
23
- | `unsupported-ooxml-preservation` | `contract-frozen` | `src/preservation/`, `src/io/` | Opaque fragment capture, untouched package-part retention, reattachment policy, locked editing regions | `docs/plans/waves/specs/wave-1-ooxml-contracts.md`, preservation fixtures, fragment retention tests, export reattachment tests |
24
- | `compatibility-and-word-validation` | `contract-frozen` | `src/validation/`, `src/ui/compatibility/`, `services/openxml-validator/` | Editor-side compatibility reporting, support classification, export-risk reporting, validator-service integration boundary | `docs/plans/waves/specs/wave-1-ooxml-contracts.md`, `docs/plans/waves/specs/wave-1-review-and-ui-contracts.md`, feature matrix, compatibility tests, Word reopen evidence |
25
- | `react-editor-ui` | `contract-frozen` | `src/ui-tailwind/`, `src/ui/headless/`, `src/runtime/`, `src/api/` | Tailwind-based React shell with Radix UI primitives. Headless logic in `src/ui/headless/`. Legacy inline-CSSProperties components removed. | `docs/plans/waves/specs/wave-1-review-and-ui-contracts.md`, component tests, selection behavior checks, review-surface checks, token and theme checks |
26
-
27
- ## Boundary Notes
28
-
29
- ### Canonical data stays outside React
30
-
31
- - `src/model/`, `src/core/`, `src/review/`, `src/io/`, `src/preservation/`, and `src/validation/` should remain framework-light and serializable.
32
- - The DOM is a rendering target, not canonical state.
33
-
34
- ### Runtime is the mutation choke point
35
-
36
- - UI surfaces call into `src/runtime/`.
37
- - Commands and transactions are owned by `src/core/`.
38
- - Review actions remain explicit state transitions rather than implicit UI side effects.
39
-
40
- ### DOCX handling is package-first
41
-
42
- - `src/io/opc/` owns ZIP/package and relationship handling.
43
- - `src/io/ooxml/` owns WordprocessingML parsing.
44
- - `src/preservation/` owns unsupported-content retention and untouched package parts.
45
-
46
- ### Broader repo work is planned, not landed
47
-
48
- - The repo now documents a target source layout under `src/platform/` and `src/formats/*`, but this file still inventories the landed docx-first tree.
49
- - Shared platform and xlsx architecture are currently defined in docs, not in source ownership tables here.
50
-
51
- ### Review semantics are first-class
52
-
53
- - Comments and tracked changes are not annotations layered loosely on top of text rendering.
54
- - Anchors and revisions must stay mappable through edits and export.
55
-
56
- ## Service-Backed Wave 0 Components
57
-
58
- The following components have a higher Wave 0 target because they already have repo-landed scaffolds:
59
-
60
- | Component | Wave 0 target | Primary paths | Landed scaffold evidence |
61
- | --- | --- | --- | --- |
62
- | `railway-test-harness` | `repo-landed` | `services/react-word-editor/` | Next.js service package, layout shell, harness dashboard stub, Dockerfile, Railway-oriented README |
63
- | `openxml-sdk-validator-service` | `repo-landed` | `services/openxml-validator/` | .NET 8 minimal API, `GET /health`, `POST /validate`, Dockerfile, SDK-backed validation README |
64
-
65
- ## Out Of Scope For Wave 0
66
-
67
- - No canonical schema implementation yet
68
- - No command engine implementation yet
69
- - No comment or revision persistence yet
70
- - No OOXML transformer or serializer yet
71
- - No production `WordReviewEditor` React runtime yet
72
- - No live Railway persistence or private networking integration yet
73
-
74
- Those surfaces move in later waves. This inventory only establishes where they belong and what proof each promotion will require.
75
-
76
- ## Contract Freeze References
77
-
78
- Wave 1 froze the owned architecture in the following durable spec set:
79
-
80
- - `docs/plans/waves/design/wave-1-a1.md`
81
- - `docs/plans/waves/specs/wave-1-component-boundaries.md`
82
- - `docs/plans/waves/specs/wave-1-runtime-contracts.md`
83
- - `docs/plans/waves/specs/wave-1-ooxml-contracts.md`
84
- - `docs/plans/waves/specs/wave-1-review-and-ui-contracts.md`
85
-
86
- ## Future Source Direction
87
-
88
- Target broader layout:
89
-
90
- ```text
91
- src/
92
- platform/
93
- formats/
94
- docx/
95
- xlsx/
96
- pdf/
97
- ```
98
-
99
- That future layout is a planning direction only. Do not treat it as a landed source move until the actual implementation is reorganized.
@@ -1,10 +0,0 @@
1
- # Core
2
-
3
- Commands, transactions, selection, mapping, schema, and deterministic state transitions belong here.
4
-
5
- Key subdirectories:
6
-
7
- - `schema/`
8
- - `state/`
9
- - `commands/`
10
- - `selection/`
@@ -1,3 +0,0 @@
1
- # Core Commands
2
-
3
- Command handlers, transaction builders, and editor mutation policies belong here.
@@ -1,3 +0,0 @@
1
- # Core Schema
2
-
3
- Canonical node, mark, and attribute definitions belong here.
@@ -1,3 +0,0 @@
1
- # Core Selection
2
-
3
- Selections, ranges, position mapping, and anchor remapping helpers belong here.
@@ -1,3 +0,0 @@
1
- # Core State
2
-
3
- Canonical state containers, selectors, and structural invariants belong here.
package/src/io/README.md DELETED
@@ -1,10 +0,0 @@
1
- # IO
2
-
3
- OPC package handling, OOXML parsing, normalization, and serialization belong here.
4
-
5
- Key subdirectories:
6
-
7
- - `opc/`
8
- - `ooxml/`
9
- - `normalize/`
10
- - `export/`
@@ -1,3 +0,0 @@
1
- # IO Export
2
-
3
- OOXML serialization, part regeneration, and package writing helpers belong here.
@@ -1,3 +0,0 @@
1
- # IO Normalize
2
-
3
- Normalization from OOXML structures into canonical state belongs here.
@@ -1,3 +0,0 @@
1
- # IO OOXML
2
-
3
- WordprocessingML parsing and intermediate OOXML structures belong here.
@@ -1,3 +0,0 @@
1
- # IO OPC
2
-
3
- Open Packaging Conventions package reading, part enumeration, and relationship handling belong here.
@@ -1,3 +0,0 @@
1
- # Model
2
-
3
- Canonical document envelope types, schema versions, persisted snapshots, and migration contracts belong here.
@@ -1,3 +0,0 @@
1
- # Preservation
2
-
3
- Unsupported OOXML capture, retention, untouched package-part preservation, and export reattachment logic belong here.
@@ -1,16 +0,0 @@
1
- # Review
2
-
3
- Comments, anchors, revisions, remap helpers, and accept/reject behavior belong here.
4
-
5
- Frozen Wave 1 contract:
6
-
7
- - comments and revisions live in the canonical `review` store, not in the content tree
8
- - review anchors use canonical position ranges or detached-anchor payloads, never DOM paths
9
- - all review mutations flow through runtime commands and transactions
10
- - detached comments or revisions remain addressable with reason metadata; they are not silently dropped
11
- - v1 authoring is limited to single-paragraph comments, thread replies, tracked insertions, tracked deletions, and accept/reject flows
12
- - preserve-only review structures such as multi-paragraph editable comment ranges, unlinked move revisions, and unsupported structural list/table revisions stay locked and warning-backed
13
-
14
- Key subdirectories:
15
-
16
- - `store/`
@@ -1,3 +0,0 @@
1
- # Review Store
2
-
3
- Comment threads, revision records, review selectors, and accept/reject state belong here.
@@ -1,3 +0,0 @@
1
- # Runtime
2
-
3
- The document controller and coordination between canonical state, review state, UI state, preservation, validation, and IO belong here.
package/src/ui/README.md DELETED
@@ -1,30 +0,0 @@
1
- # UI
2
-
3
- This directory contains the public entry point and shared headless logic for the editor UI.
4
-
5
- ## Entry Point
6
-
7
- `WordReviewEditor.tsx` is the public component. It bridges the `DocumentRuntime` to the Tailwind rendering layer in `src/ui-tailwind/`.
8
-
9
- ## Headless Logic
10
-
11
- `headless/` contains pure, framework-free utilities shared across implementations:
12
-
13
- - `use-editor-keyboard.ts` — Keyboard event handler factory
14
- - `comment-decoration-model.ts` — Comment anchor → highlight class computation
15
- - `revision-decoration-model.ts` — Revision anchor → highlight class computation
16
- - `selection-helpers.ts` — Selection snapshot utilities
17
-
18
- ## Session Capabilities
19
-
20
- `src/runtime/session-capabilities.ts` derives all UI control states from `RuntimeRenderSnapshot`. The `deriveCapabilities(snapshot, reviewMode)` function is called on every render in `WordReviewEditor.tsx` and the result is passed to the workspace components.
21
-
22
- ## Shared Utilities
23
-
24
- `shared/revision-filters.ts` — Shared revision filtering and empty state helpers.
25
-
26
- ## Rendering
27
-
28
- All visual rendering is in `src/ui-tailwind/`. See `docs/reference/word-review-editor-frontend-architecture.md` for the canonical architecture.
29
-
30
- Legacy inline-CSSProperties components have been removed.
@@ -1,3 +0,0 @@
1
- # Comments UI
2
-
3
- Comment markers, thread navigation, and sidebar thread views belong here.
@@ -1,3 +0,0 @@
1
- # Compatibility UI
2
-
3
- Compatibility reports, preserve-only warnings, and unsupported-content summaries belong here.
@@ -1,3 +0,0 @@
1
- # Editor Surface
2
-
3
- The editable document canvas, overlays, and selection-aware rendering belong here.
@@ -1,3 +0,0 @@
1
- # Review UI
2
-
3
- Tracked-change display modes, review navigation, and accept/reject surfaces belong here.
@@ -1,3 +0,0 @@
1
- # Status UI
2
-
3
- Dirty state, autosave state, import/export progress, and validation status surfaces belong here.
@@ -1,3 +0,0 @@
1
- # Theme
2
-
3
- Design tokens, CSS variable mapping, and host-theme integration belong here.
@@ -1,3 +0,0 @@
1
- # Toolbar
2
-
3
- The compact command toolbar and contextual editor controls belong here.
@@ -1,22 +0,0 @@
1
- # Debug UX (internal only)
2
-
3
- Runtime debug chrome is not a production API surface. `WordReviewEditor` does
4
- not expose a `debugMode` prop, `api.ui.debug.attach()` is a hard-disabled
5
- runtime API call, and `ChromePosture.debugMode` is production-forced to
6
- `"off"`.
7
-
8
- The supported local diagnostic surface is the mounted runtime REPL keyboard
9
- shortcut. Open it with `Cmd/Ctrl+Alt+P`; its `Agent layer view` shares the
10
- L01-L11 layer map with the harness debug pane, including `Alt+1`...`Alt+9`,
11
- `Alt+0`, and `Alt+-` navigation plus snippets that evaluate against
12
- `runtime`/`ref`. These components remain in the tree for internal harness/story
13
- experiments only; do not wire them into `WordReviewEditor` or public API paths.
14
-
15
- ## Files
16
-
17
- | File | Purpose |
18
- |---|---|
19
- | `tw-debug-top-bar.tsx` | Internal minimal top bar for harness/story experiments |
20
- | `tw-debug-overlay.tsx` | Internal overlay rendering `DebugInspectorSnapshot` sections |
21
- | `tw-debug-repl.tsx` | Legacy placeholder; production diagnostics use `tw-runtime-repl-dialog.tsx` |
22
- | `tw-debug-event-tail.tsx` | Tail of the last N events on active telemetry channels |
@@ -1,3 +0,0 @@
1
- # Validation
2
-
3
- Compatibility checks, round-trip validation, support classification, and Word reopen evidence helpers belong here.