@beyondwork/docx-react-component 1.0.108 → 1.0.110

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beyondwork/docx-react-component",
3
3
  "publisher": "beyondwork",
4
- "version": "1.0.108",
4
+ "version": "1.0.110",
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": [
@@ -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,