@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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beyondwork/docx-react-component",
3
3
  "publisher": "beyondwork",
4
- "version": "1.0.109",
4
+ "version": "1.0.111",
5
5
  "description": "Embeddable React Word (docx) editor with review, comments, tracked changes, and round-trip OOXML fidelity.",
6
6
  "type": "module",
7
7
  "sideEffects": [
@@ -177,6 +177,7 @@ export type {
177
177
  PublicBlockMeasurement,
178
178
  PublicFieldDirtinessReport,
179
179
  PublicLineBox,
180
+ PublicLineRunAnchor,
180
181
  PublicLayoutDivergence,
181
182
  PublicMeasurementFidelity,
182
183
  PublicNoteAllocation,
@@ -184,9 +185,11 @@ export type {
184
185
  PublicPageFrame,
185
186
  PublicPageLocalStoryInstance,
186
187
  PublicPageNode,
188
+ PublicPagePaginationTelemetry,
187
189
  PublicPageRegion,
188
190
  PublicPageRegions,
189
191
  PublicPageSpan,
192
+ PublicPaginationTelemetry,
190
193
  PublicRegionBlock,
191
194
  PublicRegionKind,
192
195
  PublicResolvedPageStories,
@@ -189,6 +189,12 @@ export interface RuntimeStoryAnchoredObject {
189
189
  widthTwips: number;
190
190
  heightTwips: number;
191
191
  };
192
+ /**
193
+ * Page/frame-local object bbox in twips when L04 can place the object from
194
+ * canonical anchor metadata. This is semantic layout placement, not a
195
+ * rendered pixel bbox; L05 owns projection to px/object handles.
196
+ */
197
+ anchorRectTwips?: RuntimeTwipsRect;
192
198
  relationshipIds?: readonly string[];
193
199
  mediaIds?: readonly string[];
194
200
  preserveOnly: boolean;
@@ -444,10 +450,37 @@ export interface RuntimeLineBox {
444
450
  lineIndex: number;
445
451
  /** Baseline twips from the region's origin. */
446
452
  baselineTwips: number;
453
+ /** Page-local baseline twips from the physical page top. */
454
+ baselinePageYTwips?: number;
447
455
  /** Line height twips. */
448
456
  heightTwips: number;
449
457
  /** Approximate inline width consumed on this line. */
450
458
  widthTwips: number;
459
+ /** Page-local twips rect for the line box. */
460
+ rectTwips?: RuntimeTwipsRect;
461
+ /** Dominant paragraph direction for this line. */
462
+ direction?: "ltr" | "rtl";
463
+ /**
464
+ * Per-run/page-local anchor estimates for caret/selection projection. These
465
+ * are produced from L04 line breaking + run ids, not Word/UIA rectangles.
466
+ */
467
+ runAnchors?: readonly RuntimeLineRunAnchor[];
468
+ }
469
+
470
+ export interface RuntimeLineRunAnchor {
471
+ anchorId: string;
472
+ runId: string;
473
+ segmentId: string;
474
+ blockId: string;
475
+ fragmentId: string;
476
+ lineIndex: number;
477
+ direction: "ltr" | "rtl";
478
+ baselinePageYTwips: number;
479
+ lineRectTwips: RuntimeTwipsRect;
480
+ firstGlyphRectTwips: RuntimeTwipsRect;
481
+ lastGlyphRectTwips: RuntimeTwipsRect;
482
+ runRectTwips: RuntimeTwipsRect;
483
+ precision: "layout-estimate";
451
484
  }
452
485
 
453
486
  export interface RuntimeNoteAllocation {
@@ -56,6 +56,26 @@ export interface RuntimePageGraph {
56
56
  sections: ResolvedDocumentSection[];
57
57
  /** Total non-blank page count. */
58
58
  contentPageCount: number;
59
+ /**
60
+ * Lazy-pagination status for this graph. Absent/`complete` means every
61
+ * returned page has been paginated. `viewport-window` means some page nodes
62
+ * are placeholders with `materialization: "unpaginated"`.
63
+ */
64
+ materialization?: RuntimePageGraphMaterialization;
65
+ }
66
+
67
+ export type RuntimePageMaterialization = "paginated" | "unpaginated";
68
+
69
+ export interface RuntimePageGraphMaterialization {
70
+ kind: "complete" | "viewport-window";
71
+ requestedWindow?: RuntimePageWindowRange;
72
+ paginatedRange?: RuntimePageWindowRange;
73
+ estimatedPageCount?: number;
74
+ }
75
+
76
+ export interface RuntimePageWindowRange {
77
+ startPageIndex: number;
78
+ endPageIndex: number;
59
79
  }
60
80
 
61
81
  export interface RuntimePageNode {
@@ -83,6 +103,11 @@ export interface RuntimePageNode {
83
103
  noteAllocations: RuntimeNoteAllocation[];
84
104
  /** Whether this page is a blank filler (from even/odd page breaks). */
85
105
  isBlankFiller: boolean;
106
+ /**
107
+ * Whether L04 actually paginated this page. Windowed graph reads keep
108
+ * placeholder nodes for pages that exist but have not been measured yet.
109
+ */
110
+ materialization?: RuntimePageMaterialization;
86
111
  }
87
112
 
88
113
  export interface BuildPageGraphInput {
@@ -231,6 +231,7 @@ import {
231
231
  setActiveLayoutWarningEmitter,
232
232
  type DocxFontLoader,
233
233
  type LayoutEngineInstance,
234
+ type LayoutEngineQueryInput,
234
235
  type LayoutFacet,
235
236
  type LayoutMeasurementProvider,
236
237
  type WordReviewEditorLayoutFacet,
@@ -1409,6 +1410,7 @@ export function createDocumentRuntime(
1409
1410
  workspaceMode: viewState.workspaceMode,
1410
1411
  zoomLevel: viewState.zoomLevel,
1411
1412
  },
1413
+ viewportPageWindow: getViewportPageWindow(),
1412
1414
  }),
1413
1415
  canonicalDocument: () => state.document,
1414
1416
  renderKernel: () => renderKernelRef,
@@ -1463,6 +1465,50 @@ export function createDocumentRuntime(
1463
1465
  let viewportRangesKey: string = serializeViewportRanges(null);
1464
1466
  const EDITING_CORRIDOR_BLOCK_RADIUS = 8;
1465
1467
  const EDITING_CORRIDOR_MIN_BLOCKS = 24;
1468
+ const VIEWPORT_PAGE_WINDOW_BLOCKS_PER_PAGE = 50;
1469
+ const VIEWPORT_PAGE_WINDOW_BUFFER_PAGES = 0;
1470
+
1471
+ function getViewportPageWindow(): LayoutEngineQueryInput["viewportPageWindow"] | undefined {
1472
+ if (!viewportBlockRanges || viewportBlockRanges.length === 0) return undefined;
1473
+
1474
+ const blockCount = state.document.content.children.length;
1475
+ if (blockCount <= 0) return undefined;
1476
+
1477
+ let startBlock = Number.POSITIVE_INFINITY;
1478
+ let endBlockInclusive = -1;
1479
+ for (const range of viewportBlockRanges) {
1480
+ const start = Math.max(0, Math.min(blockCount, Math.floor(range.start)));
1481
+ const endExclusive = Math.max(
1482
+ start,
1483
+ Math.min(blockCount, Math.floor(range.end)),
1484
+ );
1485
+ if (endExclusive <= start) continue;
1486
+ startBlock = Math.min(startBlock, start);
1487
+ endBlockInclusive = Math.max(endBlockInclusive, endExclusive - 1);
1488
+ }
1489
+
1490
+ if (!Number.isFinite(startBlock) || endBlockInclusive < 0) return undefined;
1491
+
1492
+ const startPageIndex = Math.max(
1493
+ 0,
1494
+ Math.floor(startBlock / VIEWPORT_PAGE_WINDOW_BLOCKS_PER_PAGE),
1495
+ );
1496
+ const endPageIndex = Math.max(
1497
+ startPageIndex,
1498
+ Math.floor(endBlockInclusive / VIEWPORT_PAGE_WINDOW_BLOCKS_PER_PAGE),
1499
+ );
1500
+ const estimatedPageCount = Math.max(
1501
+ endPageIndex + 1,
1502
+ Math.ceil(blockCount / VIEWPORT_PAGE_WINDOW_BLOCKS_PER_PAGE),
1503
+ );
1504
+
1505
+ return {
1506
+ startPageIndex,
1507
+ endPageIndex,
1508
+ bufferPages: VIEWPORT_PAGE_WINDOW_BUFFER_PAGES,
1509
+ estimatedPageCount,
1510
+ };
1511
+ }
1466
1512
 
1467
1513
  function applyViewportRanges(
1468
1514
  incoming: readonly { start: number; end: number }[] | null,