@beyondwork/docx-react-component 1.0.124 → 1.0.126

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 (101) hide show
  1. package/dist/api/public-types.cjs +147 -35
  2. package/dist/api/public-types.d.cts +2 -2
  3. package/dist/api/public-types.d.ts +2 -2
  4. package/dist/api/public-types.js +3 -3
  5. package/dist/api/v3.cjs +796 -102
  6. package/dist/api/v3.d.cts +3 -3
  7. package/dist/api/v3.d.ts +3 -3
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{canonical-document-CG2TgAzj.d.cts → canonical-document-CXCFCbAz.d.cts} +2 -0
  10. package/dist/{canonical-document-CG2TgAzj.d.ts → canonical-document-CXCFCbAz.d.ts} +2 -0
  11. package/dist/{chunk-PFYUJU3Q.js → chunk-2QL5DAKF.js} +98 -43
  12. package/dist/{chunk-4IPEZYQX.js → chunk-4EENH4FG.js} +1 -1
  13. package/dist/{chunk-BOHHIVQ2.js → chunk-4G3OS2H6.js} +3 -3
  14. package/dist/{chunk-A74Y5NE4.js → chunk-4YJVRIUB.js} +52 -21
  15. package/dist/{chunk-FNWKE74J.js → chunk-5DGKFNQT.js} +5 -1
  16. package/dist/{chunk-RSYN6FTS.js → chunk-6F5QW44A.js} +2 -2
  17. package/dist/{chunk-ZMRO6P3A.js → chunk-6IGWPAR4.js} +505 -44
  18. package/dist/{chunk-KOHQFZMM.js → chunk-BYSRJ4FE.js} +1 -1
  19. package/dist/{chunk-H6IL5ABU.js → chunk-CXSYRB37.js} +64 -20
  20. package/dist/{chunk-32ZAOQ54.js → chunk-D5HYZQTG.js} +1 -1
  21. package/dist/{chunk-TY4DIJO3.js → chunk-ESJ2MES5.js} +1 -1
  22. package/dist/{chunk-Q76XPPTA.js → chunk-FPRWV54X.js} +101 -14
  23. package/dist/{chunk-MPH4ZQS4.js → chunk-GL7XRYBY.js} +624 -87
  24. package/dist/{chunk-IR7QV2BX.js → chunk-KV435YXO.js} +2 -2
  25. package/dist/{chunk-N4VIXI2Z.js → chunk-MWSBGJQO.js} +137 -18
  26. package/dist/{chunk-7PC6XUNO.js → chunk-TQDQU2E3.js} +2 -2
  27. package/dist/{chunk-4B74ETJI.js → chunk-V6XVZFFH.js} +2 -2
  28. package/dist/{chunk-NAMAWCXN.js → chunk-YD2JE54B.js} +1 -1
  29. package/dist/{chunk-ZRHLLPSJ.js → chunk-YHZHPXDB.js} +85 -18
  30. package/dist/{chunk-HXHQA4BU.js → chunk-YIYM4ZAP.js} +1 -1
  31. package/dist/{chunk-LGWNN3L2.js → chunk-ZDOAUP3V.js} +2 -2
  32. package/dist/compare.d.cts +1 -1
  33. package/dist/compare.d.ts +1 -1
  34. package/dist/core/commands/formatting-commands.d.cts +2 -2
  35. package/dist/core/commands/formatting-commands.d.ts +2 -2
  36. package/dist/core/commands/image-commands.cjs +65 -20
  37. package/dist/core/commands/image-commands.d.cts +2 -2
  38. package/dist/core/commands/image-commands.d.ts +2 -2
  39. package/dist/core/commands/image-commands.js +5 -5
  40. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  41. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  42. package/dist/core/commands/style-commands.d.cts +2 -2
  43. package/dist/core/commands/style-commands.d.ts +2 -2
  44. package/dist/core/commands/table-structure-commands.cjs +65 -20
  45. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  46. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  47. package/dist/core/commands/table-structure-commands.js +4 -4
  48. package/dist/core/commands/text-commands.cjs +66 -21
  49. package/dist/core/commands/text-commands.d.cts +2 -2
  50. package/dist/core/commands/text-commands.d.ts +2 -2
  51. package/dist/core/commands/text-commands.js +5 -5
  52. package/dist/core/selection/mapping.d.cts +2 -2
  53. package/dist/core/selection/mapping.d.ts +2 -2
  54. package/dist/core/state/editor-state.d.cts +2 -2
  55. package/dist/core/state/editor-state.d.ts +2 -2
  56. package/dist/index.cjs +1677 -240
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +62 -25
  60. package/dist/io/docx-session.cjs +51 -20
  61. package/dist/io/docx-session.d.cts +4 -4
  62. package/dist/io/docx-session.d.ts +4 -4
  63. package/dist/io/docx-session.js +4 -4
  64. package/dist/legal.cjs +36 -12
  65. package/dist/legal.d.cts +1 -1
  66. package/dist/legal.d.ts +1 -1
  67. package/dist/legal.js +3 -3
  68. package/dist/{loader-D9y4ZRjj.d.ts → loader-CS9-9KFa.d.ts} +3 -3
  69. package/dist/{loader-D9KCtj4m.d.cts → loader-OoWJ1_17.d.cts} +3 -3
  70. package/dist/{public-types-CNnMHZM9.d.ts → public-types-BP3vqJR5.d.cts} +157 -11
  71. package/dist/{public-types-DajNGKV4.d.cts → public-types-DdcHqcow.d.ts} +157 -11
  72. package/dist/public-types.cjs +147 -35
  73. package/dist/public-types.d.cts +2 -2
  74. package/dist/public-types.d.ts +2 -2
  75. package/dist/public-types.js +3 -3
  76. package/dist/runtime/collab.d.cts +3 -3
  77. package/dist/runtime/collab.d.ts +3 -3
  78. package/dist/runtime/document-runtime.cjs +945 -134
  79. package/dist/runtime/document-runtime.d.cts +2 -2
  80. package/dist/runtime/document-runtime.d.ts +2 -2
  81. package/dist/runtime/document-runtime.js +14 -14
  82. package/dist/{session-DyQGlryH.d.cts → session-Cq-fzx3B.d.cts} +3 -3
  83. package/dist/{session-DEmaOEjA.d.ts → session-DyFQt8Ph.d.ts} +3 -3
  84. package/dist/session.cjs +51 -20
  85. package/dist/session.d.cts +5 -5
  86. package/dist/session.d.ts +5 -5
  87. package/dist/session.js +5 -5
  88. package/dist/tailwind.cjs +238 -73
  89. package/dist/tailwind.d.cts +2 -2
  90. package/dist/tailwind.d.ts +2 -2
  91. package/dist/tailwind.js +7 -7
  92. package/dist/{types-CxE1aZiv.d.cts → types-Bg7D-GD3.d.cts} +2 -2
  93. package/dist/{types-DjJNaE9c.d.ts → types-bJAgMq1M.d.ts} +2 -2
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  96. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  97. package/dist/ui-tailwind.cjs +238 -73
  98. package/dist/ui-tailwind.d.cts +3 -3
  99. package/dist/ui-tailwind.d.ts +3 -3
  100. package/dist/ui-tailwind.js +7 -7
  101. package/package.json +1 -1
@@ -7968,7 +7968,7 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
7968
7968
  context: { storyKey, insideSdt: contentControl !== void 0 },
7969
7969
  ...tableTarget
7970
7970
  }) : void 0;
7971
- const listAddress = tableIdentity === void 0 && paragraph.numbering !== void 0 ? createCanonicalAddress({
7971
+ const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
7972
7972
  addressKind: "list-item-text",
7973
7973
  storyKey,
7974
7974
  staleCheckKind: "paragraph",
@@ -8002,6 +8002,7 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
8002
8002
  ...contentControl !== void 0 ? { contentControl } : {},
8003
8003
  ...tableIdentity !== void 0 ? { table: tableIdentity } : {},
8004
8004
  ...editableOwner !== void 0 ? { editableOwner } : {},
8005
+ ...listAddress !== void 0 ? { listAddress } : {},
8005
8006
  ...tableIdentity !== void 0 ? {
8006
8007
  canonicalAddress: createTableTargetCanonicalAddress(
8007
8008
  tableIdentity,
@@ -10305,6 +10306,7 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
10305
10306
  );
10306
10307
  const runProperties = override?.runProperties ?? base?.runProperties;
10307
10308
  const restartAfterLevel = override?.restartAfterLevel ?? base?.restartAfterLevel;
10309
+ const picBulletId = override?.picBulletId ?? base?.picBulletId;
10308
10310
  return {
10309
10311
  level,
10310
10312
  format,
@@ -10315,7 +10317,8 @@ function mergeLevelDefinition(base, override, startOverride, fallbackLevel) {
10315
10317
  ...override?.suffix ?? base?.suffix ? { suffix: override?.suffix ?? base?.suffix } : {},
10316
10318
  ...paragraphGeometry ? { paragraphGeometry } : {},
10317
10319
  ...runProperties ? { runProperties } : {},
10318
- ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {}
10320
+ ...restartAfterLevel !== void 0 ? { restartAfterLevel } : {},
10321
+ ...picBulletId !== void 0 ? { picBulletId } : {}
10319
10322
  };
10320
10323
  }
10321
10324
  function withDefaultStartAt(level) {
@@ -10443,7 +10446,7 @@ function resolveHangingWidth(indentation) {
10443
10446
  // src/runtime/formatting/numbering/prefix.ts
10444
10447
  function createNumberingPrefixResolver(catalog) {
10445
10448
  const sequenceStates = /* @__PURE__ */ new Map();
10446
- function resolveInternal(numbering, paragraph) {
10449
+ function resolveInternal(numbering, paragraph, options = {}) {
10447
10450
  const resolved = resolveNumberingDefinitionSet(
10448
10451
  catalog,
10449
10452
  paragraph?.numbering ?? numbering,
@@ -10456,29 +10459,44 @@ function createNumberingPrefixResolver(catalog) {
10456
10459
  if (!resolvedNumbering) {
10457
10460
  return null;
10458
10461
  }
10459
- const sequenceState = getSequenceState(sequenceStates, resolvedNumbering.numberingInstanceId);
10460
- advanceSequence(sequenceState, resolved.effectiveLevel.level, resolved.effectiveLevels);
10462
+ const advance = options.advance !== false;
10463
+ const sequenceState = getSequenceState(
10464
+ sequenceStates,
10465
+ resolvedNumbering.numberingInstanceId,
10466
+ { create: advance }
10467
+ );
10468
+ if (!sequenceState) {
10469
+ return null;
10470
+ }
10471
+ const workingState = advance ? sequenceState : cloneSequenceState(sequenceState);
10472
+ advanceSequence(workingState, resolved.effectiveLevel.level, resolved.effectiveLevels);
10473
+ const currentCounter = workingState.counters[resolved.effectiveLevel.level];
10461
10474
  const effectiveLevelDefs = resolved.effectiveLevel.isLegalNumbering ? new Map(
10462
10475
  Array.from(resolved.effectiveLevels.entries()).map(([level, definition]) => [
10463
10476
  level,
10464
10477
  { ...definition, format: "decimal" }
10465
10478
  ])
10466
10479
  ) : resolved.effectiveLevels;
10480
+ const picBulletId = resolved.effectiveLevel.picBulletId;
10467
10481
  const text = renderLevelText(
10468
10482
  resolved.effectiveLevel.text,
10469
- sequenceState.counters,
10483
+ workingState.counters,
10470
10484
  effectiveLevelDefs
10471
10485
  );
10472
- if (resolved.effectiveLevel.format !== "none" && text === null) {
10486
+ if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
10473
10487
  return null;
10474
10488
  }
10475
10489
  const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
10476
- const picBulletId = resolved.effectiveLevel.picBulletId;
10490
+ const formatPosture = getNumberingFormatPosture(
10491
+ resolved.effectiveLevel.format,
10492
+ currentCounter
10493
+ );
10477
10494
  const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
10478
10495
  return {
10479
10496
  text: visibleText,
10480
10497
  level: resolved.effectiveLevel.level,
10481
10498
  format: resolved.effectiveLevel.format,
10499
+ ...formatPosture !== void 0 ? { formatPosture } : {},
10482
10500
  startAt: resolved.effectiveLevel.startAt ?? DEFAULT_NUMBERING_START_AT,
10483
10501
  ...resolved.effectiveLevel.suffix ? { suffix: resolved.effectiveLevel.suffix } : {},
10484
10502
  ...resolved.effectiveLevel.paragraphStyleId ? { paragraphStyleId: resolved.effectiveLevel.paragraphStyleId } : {},
@@ -10489,23 +10507,26 @@ function createNumberingPrefixResolver(catalog) {
10489
10507
  };
10490
10508
  }
10491
10509
  return {
10492
- resolve(numbering) {
10493
- const result = resolveInternal(numbering);
10510
+ resolve(numbering, options) {
10511
+ const result = resolveInternal(numbering, void 0, options);
10494
10512
  return result?.text ?? null;
10495
10513
  },
10496
- resolveDetailed(numbering, paragraph) {
10497
- return resolveInternal(numbering, paragraph);
10514
+ resolveDetailed(numbering, paragraph, options) {
10515
+ return resolveInternal(numbering, paragraph, options);
10498
10516
  },
10499
- resolveParagraph(paragraph) {
10500
- return resolveInternal(paragraph.numbering, paragraph);
10517
+ resolveParagraph(paragraph, options) {
10518
+ return resolveInternal(paragraph.numbering, paragraph, options);
10501
10519
  }
10502
10520
  };
10503
10521
  }
10504
- function getSequenceState(states, numberingInstanceId) {
10522
+ function getSequenceState(states, numberingInstanceId, options = { create: true }) {
10505
10523
  const existing = states.get(numberingInstanceId);
10506
10524
  if (existing) {
10507
10525
  return existing;
10508
10526
  }
10527
+ if (options.create === false) {
10528
+ return { counters: [], lastLevel: null };
10529
+ }
10509
10530
  const created = {
10510
10531
  counters: [],
10511
10532
  lastLevel: null
@@ -10513,6 +10534,12 @@ function getSequenceState(states, numberingInstanceId) {
10513
10534
  states.set(numberingInstanceId, created);
10514
10535
  return created;
10515
10536
  }
10537
+ function cloneSequenceState(state) {
10538
+ return {
10539
+ counters: [...state.counters],
10540
+ lastLevel: state.lastLevel
10541
+ };
10542
+ }
10516
10543
  function advanceSequence(state, currentLevel, levelDefinitions) {
10517
10544
  for (let level = currentLevel + 1; level < state.counters.length; level += 1) {
10518
10545
  if (shouldResetDeeperLevel(level, currentLevel, levelDefinitions)) {
@@ -10544,6 +10571,25 @@ function shouldResetDeeperLevel(level, triggeringLevel, levelDefinitions) {
10544
10571
  function getLevelStartAt(level, levelDefinitions) {
10545
10572
  return levelDefinitions.get(level)?.startAt ?? DEFAULT_NUMBERING_START_AT;
10546
10573
  }
10574
+ function getNumberingFormatPosture(format, value) {
10575
+ if (!isSupportedNumberingFormat(format)) {
10576
+ return {
10577
+ status: "approximated",
10578
+ requestedFormat: format,
10579
+ renderedFormat: "decimal",
10580
+ reason: "unsupported-numbering-format-decimal-fallback"
10581
+ };
10582
+ }
10583
+ if (value !== void 0 && ((format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
10584
+ return {
10585
+ status: "approximated",
10586
+ requestedFormat: format,
10587
+ renderedFormat: "decimal",
10588
+ reason: "numbering-format-range-decimal-fallback"
10589
+ };
10590
+ }
10591
+ return void 0;
10592
+ }
10547
10593
  function renderLevelText(text, counters, levelDefinitions) {
10548
10594
  if (!text) {
10549
10595
  return null;
@@ -11386,6 +11432,7 @@ function toNumberingLayoutInput(numbering) {
11386
11432
  associatedTabStops: toLayoutTabStops(numbering.geometry.tabStops, "numbering"),
11387
11433
  level: numbering.level,
11388
11434
  format: numbering.format,
11435
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
11389
11436
  startAt: numbering.startAt,
11390
11437
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
11391
11438
  ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
@@ -11615,13 +11662,10 @@ var FormattingContextImpl = class {
11615
11662
  const effectiveNumbering = this.resolveEffectiveParagraphNumbering(para);
11616
11663
  if (!effectiveNumbering) return null;
11617
11664
  if (!emitGeometry) {
11618
- if (advance) this.numbering.resolve(effectiveNumbering);
11665
+ this.numbering.resolve(effectiveNumbering, { advance });
11619
11666
  return null;
11620
11667
  }
11621
- if (!advance) {
11622
- console.warn("[formatting-context] resolveParagraphNumbering({advance:false}) is not supported; counter always advances");
11623
- }
11624
- return this.numbering.resolveDetailed(effectiveNumbering, para);
11668
+ return this.numbering.resolveDetailed(effectiveNumbering, para, { advance });
11625
11669
  }
11626
11670
  resolveNumberingLayoutInput(para, options = {}) {
11627
11671
  return toNumberingLayoutInput(this.resolveParagraphNumbering(para, options));
@@ -13815,6 +13859,7 @@ function toSurfaceResolvedNumbering(numbering) {
13815
13859
  return {
13816
13860
  level: numbering.level,
13817
13861
  format: numbering.format,
13862
+ ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
13818
13863
  ...numbering.text !== null ? { text: numbering.text } : {},
13819
13864
  startAt: numbering.startAt,
13820
13865
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
@@ -18095,8 +18140,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
18095
18140
  const perPageCounter = /* @__PURE__ */ new Map();
18096
18141
  const fieldRegionsByParagraphIndex = buildFieldRegionsByParagraphIndex(fieldRegions);
18097
18142
  const generatedTargets = buildGeneratedTargets(editableTargets);
18143
+ const numberingTargets = buildNumberingTargets(editableTargets);
18098
18144
  const bookmarkRanges = buildBookmarkRanges(editableTargets);
18099
- const numberingByParagraphIndex = buildNumberingByParagraphIndex(numberingInputs);
18145
+ const numberingIndex = buildNumberingInputIndex(numberingInputs);
18100
18146
  const pushFragment = (pageIndex, fragment) => {
18101
18147
  const existing = byPage.get(pageIndex);
18102
18148
  if (existing) {
@@ -18132,8 +18178,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
18132
18178
  },
18133
18179
  fieldRegionsByParagraphIndex,
18134
18180
  generatedTargets,
18181
+ numberingTargets,
18135
18182
  bookmarkRanges,
18136
- numberingByParagraphIndex,
18183
+ numberingIndex,
18137
18184
  blockPath
18138
18185
  );
18139
18186
  continue;
@@ -18154,8 +18201,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
18154
18201
  },
18155
18202
  fieldRegionsByParagraphIndex,
18156
18203
  generatedTargets,
18204
+ numberingTargets,
18157
18205
  bookmarkRanges,
18158
- numberingByParagraphIndex,
18206
+ numberingIndex,
18159
18207
  blockPath
18160
18208
  );
18161
18209
  continue;
@@ -18187,8 +18235,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
18187
18235
  paginationRole: "whole",
18188
18236
  fieldRegionsByParagraphIndex,
18189
18237
  generatedTargets,
18238
+ numberingTargets,
18190
18239
  bookmarkRanges,
18191
- numberingByParagraphIndex,
18240
+ numberingIndex,
18192
18241
  blockPath
18193
18242
  }),
18194
18243
  ...columnIndex !== void 0 ? { columnIndex } : {}
@@ -18335,7 +18384,7 @@ function buildRunAnchorsForLine(input) {
18335
18384
  }
18336
18385
  return anchors;
18337
18386
  }
18338
- function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
18387
+ function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], numberingTargets = [], bookmarkRanges = [], numberingIndex = EMPTY_NUMBERING_INPUT_INDEX, blockPath) {
18339
18388
  for (let i = 0; i < slices.length; i += 1) {
18340
18389
  const slice = slices[i];
18341
18390
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromLines(slice.lineRange);
@@ -18360,8 +18409,9 @@ function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex =
18360
18409
  paginationRole: slice.lineRange.from > 0 ? "continuation" : "slice",
18361
18410
  fieldRegionsByParagraphIndex,
18362
18411
  generatedTargets,
18412
+ numberingTargets,
18363
18413
  bookmarkRanges,
18364
- numberingByParagraphIndex,
18414
+ numberingIndex,
18365
18415
  blockPath
18366
18416
  })
18367
18417
  };
@@ -18382,7 +18432,7 @@ function estimateSliceHeightFromLines(lineRange) {
18382
18432
  const lines = Math.max(0, lineRange.to - lineRange.from);
18383
18433
  return lines * 240;
18384
18434
  }
18385
- function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
18435
+ function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], numberingTargets = [], bookmarkRanges = [], numberingIndex = EMPTY_NUMBERING_INPUT_INDEX, blockPath) {
18386
18436
  for (let i = 0; i < slices.length; i += 1) {
18387
18437
  const slice = slices[i];
18388
18438
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromRows(slice.rowRange);
@@ -18406,8 +18456,9 @@ function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /*
18406
18456
  paginationRole: slice.rowRange.from > 0 ? "continuation" : "slice",
18407
18457
  fieldRegionsByParagraphIndex,
18408
18458
  generatedTargets,
18459
+ numberingTargets,
18409
18460
  bookmarkRanges,
18410
- numberingByParagraphIndex,
18461
+ numberingIndex,
18411
18462
  blockPath
18412
18463
  }),
18413
18464
  ...slice.columnIndex !== void 0 ? { columnIndex: slice.columnIndex } : {}
@@ -18481,7 +18532,8 @@ function buildFragmentLayoutObject(input) {
18481
18532
  const numberingRows = collectNumberingLayoutFactsForBlock(
18482
18533
  input.block,
18483
18534
  input.blockPath,
18484
- input.numberingByParagraphIndex
18535
+ input.numberingIndex,
18536
+ input.numberingTargets
18485
18537
  );
18486
18538
  const numbering = input.block.kind === "paragraph" ? numberingRows[0] : void 0;
18487
18539
  const fieldRegions = collectFieldRegionLayoutFacts(
@@ -18652,6 +18704,11 @@ function buildGeneratedTargets(targets) {
18652
18704
  (target) => target.kind === "field-result-text" || target.kind === "hyperlink-text" || target.kind === "hyperlink-destination" || target.kind === "bookmark-anchor" || target.kind === "bookmark-content-range"
18653
18705
  );
18654
18706
  }
18707
+ function buildNumberingTargets(targets) {
18708
+ return targets.filter(
18709
+ (target) => target.listAddress !== void 0 || target.canonicalAddress?.addressKind === "list-item-text"
18710
+ );
18711
+ }
18655
18712
  function buildBookmarkRanges(targets) {
18656
18713
  const anchors = /* @__PURE__ */ new Map();
18657
18714
  const contentRanges = /* @__PURE__ */ new Map();
@@ -18699,14 +18756,27 @@ function buildBookmarkRanges(targets) {
18699
18756
  }
18700
18757
  return ranges;
18701
18758
  }
18702
- function buildNumberingByParagraphIndex(numberingInputs) {
18759
+ var EMPTY_NUMBERING_INPUT_INDEX = {
18760
+ byNumberingKey: /* @__PURE__ */ new Map(),
18761
+ byBlockPath: /* @__PURE__ */ new Map(),
18762
+ byParagraphIndex: /* @__PURE__ */ new Map()
18763
+ };
18764
+ function buildNumberingInputIndex(numberingInputs) {
18765
+ const byNumberingKey = /* @__PURE__ */ new Map();
18766
+ const byBlockPath = /* @__PURE__ */ new Map();
18703
18767
  const byParagraph = /* @__PURE__ */ new Map();
18704
18768
  for (const input of numberingInputs) {
18769
+ if (!byNumberingKey.has(input.numberingKey)) {
18770
+ byNumberingKey.set(input.numberingKey, input);
18771
+ }
18772
+ if (!byBlockPath.has(input.blockPath)) {
18773
+ byBlockPath.set(input.blockPath, input);
18774
+ }
18705
18775
  if (!byParagraph.has(input.paragraphIndex)) {
18706
18776
  byParagraph.set(input.paragraphIndex, input);
18707
18777
  }
18708
18778
  }
18709
- return byParagraph;
18779
+ return { byNumberingKey, byBlockPath, byParagraphIndex: byParagraph };
18710
18780
  }
18711
18781
  function collectBookmarkRangeLayoutFacts(fragmentId, blockPath, bookmarkRanges) {
18712
18782
  if (!blockPath || !bookmarkRanges || bookmarkRanges.length === 0) return [];
@@ -18787,6 +18857,7 @@ function collectNumberingLayoutFacts(block) {
18787
18857
  ...block.numbering?.numberingInstanceId !== void 0 ? { numberingInstanceId: block.numbering.numberingInstanceId } : {},
18788
18858
  ...block.numbering?.level !== void 0 ? { level: block.numbering.level } : {},
18789
18859
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
18860
+ ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
18790
18861
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
18791
18862
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
18792
18863
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
@@ -18814,15 +18885,21 @@ function collectNumberingLayoutFacts(block) {
18814
18885
  } : {}
18815
18886
  };
18816
18887
  }
18817
- function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagraphIndex) {
18888
+ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingIndex, numberingTargets = []) {
18818
18889
  const rows = [];
18819
18890
  const seen = /* @__PURE__ */ new Set();
18820
18891
  visitParagraphBlocks(block, (paragraph, context) => {
18821
18892
  const numbering = collectNumberingLayoutFacts(paragraph);
18822
18893
  if (!numbering) return;
18823
18894
  const paragraphIndex = parseParagraphBlockIndex(paragraph.blockId);
18824
- const canonical = paragraphIndex !== void 0 ? numberingByParagraphIndex?.get(paragraphIndex) : void 0;
18825
18895
  const numberingKey = context.path !== void 0 ? `main:${context.path}:numbering` : void 0;
18896
+ const canonical = lookupNumberingInput(
18897
+ numberingIndex,
18898
+ numberingKey,
18899
+ context.path,
18900
+ paragraphIndex
18901
+ );
18902
+ const target = findNumberingTarget(numberingTargets, context.path);
18826
18903
  const numberingLayoutId = numberingKey ?? [
18827
18904
  "numbering",
18828
18905
  paragraph.blockId,
@@ -18831,6 +18908,7 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
18831
18908
  ].join(":");
18832
18909
  if (seen.has(numberingLayoutId)) return;
18833
18910
  seen.add(numberingLayoutId);
18911
+ const unavailableReasons = collectNumberingUnavailableReasons(numbering, canonical);
18834
18912
  rows.push({
18835
18913
  numberingLayoutId,
18836
18914
  ...numberingKey !== void 0 ? { numberingKey } : {},
@@ -18838,6 +18916,10 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
18838
18916
  ...canonical?.blockPath !== void 0 ? { sourceBlockPath: canonical.blockPath } : context.path !== void 0 ? { sourceBlockPath: context.path } : {},
18839
18917
  sourceBlockId: paragraph.blockId,
18840
18918
  ...paragraphIndex !== void 0 ? { paragraphIndex } : {},
18919
+ ...target?.targetKey !== void 0 ? { targetKey: target.targetKey } : {},
18920
+ ...target?.kind !== void 0 ? { targetKind: target.kind } : {},
18921
+ ...target?.canonicalAddress?.addressKey !== void 0 ? { canonicalAddressKey: target.canonicalAddress.addressKey } : {},
18922
+ ...target?.listAddress?.addressKey !== void 0 ? { listAddressKey: target.listAddress.addressKey } : {},
18841
18923
  ...canonical?.sourceRef !== void 0 ? { sourceRef: { ...canonical.sourceRef } } : {},
18842
18924
  ...canonical?.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...canonical.numberingSourceRef } } : {},
18843
18925
  ...canonical?.numberingOrigin !== void 0 ? { numberingOrigin: canonical.numberingOrigin } : {},
@@ -18845,11 +18927,41 @@ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagr
18845
18927
  ...canonical?.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...canonical.numberingInstanceSourceRef } } : {},
18846
18928
  ...canonical?.abstractNumberingId !== void 0 ? { abstractNumberingId: canonical.abstractNumberingId } : {},
18847
18929
  ...canonical?.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...canonical.abstractNumberingSourceRef } } : {},
18848
- ...numbering
18930
+ ...numbering,
18931
+ ...unavailableReasons.length > 0 ? { unavailableReasons } : {}
18849
18932
  });
18850
18933
  }, blockPath);
18851
18934
  return rows;
18852
18935
  }
18936
+ function findNumberingTarget(numberingTargets, blockPath) {
18937
+ if (blockPath === void 0) return void 0;
18938
+ return numberingTargets.find((target) => target.blockPath === blockPath);
18939
+ }
18940
+ function lookupNumberingInput(numberingIndex, numberingKey, blockPath, paragraphIndex) {
18941
+ if (!numberingIndex) return void 0;
18942
+ if (numberingKey !== void 0) {
18943
+ const byKey = numberingIndex.byNumberingKey.get(numberingKey);
18944
+ if (byKey !== void 0) return byKey;
18945
+ }
18946
+ if (blockPath !== void 0) {
18947
+ const byPath = numberingIndex.byBlockPath.get(blockPath);
18948
+ if (byPath !== void 0) return byPath;
18949
+ }
18950
+ return paragraphIndex !== void 0 ? numberingIndex.byParagraphIndex.get(paragraphIndex) : void 0;
18951
+ }
18952
+ function collectNumberingUnavailableReasons(numbering, canonical) {
18953
+ const reasons = [];
18954
+ if (canonical === void 0) {
18955
+ reasons.push("canonical-numbering-input-missing");
18956
+ }
18957
+ if (numbering.markerLane === void 0) {
18958
+ reasons.push("numbering-marker-lane-unavailable");
18959
+ }
18960
+ if (numbering.textColumn === void 0) {
18961
+ reasons.push("numbering-text-column-unavailable");
18962
+ }
18963
+ return reasons;
18964
+ }
18853
18965
  function findPageIndexForOffset(pages, offset) {
18854
18966
  for (let i = 0; i < pages.length; i += 1) {
18855
18967
  const page = pages[i];
@@ -19226,7 +19338,7 @@ function createEmpiricalProvider() {
19226
19338
  }
19227
19339
 
19228
19340
  // src/runtime/layout/layout-engine-version.ts
19229
- var LAYOUT_ENGINE_VERSION = 87;
19341
+ var LAYOUT_ENGINE_VERSION = 88;
19230
19342
 
19231
19343
  // src/runtime/layout/layout-engine-instance.ts
19232
19344
  var FULL_VIEWPORT_WINDOW_KEY = "full";
@@ -30823,26 +30935,42 @@ function resolveTopBarCommentAvailability(input) {
30823
30935
 
30824
30936
  // src/ui-tailwind/review-workspace/use-status-bar-page-facts.ts
30825
30937
  var import_react36 = require("react");
30826
- function useStatusBarPageFacts(options) {
30827
- const { layoutFacet, selectionPosition, activeStory, renderFrameRevision } = options;
30828
- return (0, import_react36.useMemo)(() => {
30829
- const facet = layoutFacet;
30830
- if (!facet) {
30831
- return {
30832
- displayPageNumber: null,
30833
- pageCount: null,
30834
- measurementFidelity: void 0
30835
- };
30836
- }
30837
- const pageRef = facet.getPageForOffset(selectionPosition, activeStory);
30838
- const displayPageNumber = pageRef !== null && typeof pageRef.pageIndex === "number" ? facet.getDisplayPageNumber(pageRef.pageIndex) ?? pageRef.pageIndex + 1 : null;
30839
- const pageCount = facet.getPageCount();
30938
+ function resolveStatusBarPageFacts(options) {
30939
+ const { layoutFacet: facet, selectionPosition, activeStory, viewportPageIndexRange } = options;
30940
+ if (!facet) {
30840
30941
  return {
30841
- displayPageNumber,
30842
- pageCount,
30843
- measurementFidelity: facet.getMeasurementFidelity()
30942
+ displayPageNumber: null,
30943
+ pageCount: null,
30944
+ measurementFidelity: void 0
30844
30945
  };
30845
- }, [layoutFacet, selectionPosition, activeStory, renderFrameRevision]);
30946
+ }
30947
+ const pageCount = facet.getPageCount();
30948
+ const viewportPageIndex = viewportPageIndexRange && viewportPageIndexRange.start >= 0 && viewportPageIndexRange.start < pageCount ? viewportPageIndexRange.start : null;
30949
+ const pageRef = viewportPageIndex !== null ? { pageIndex: viewportPageIndex } : facet.getPageForOffset(selectionPosition, activeStory);
30950
+ const displayPageNumber = normalizeStatusDisplayPageNumber(
30951
+ pageRef !== null && typeof pageRef.pageIndex === "number" ? facet.getDisplayPageNumber(pageRef.pageIndex) : null,
30952
+ pageRef !== null && typeof pageRef.pageIndex === "number" ? pageRef.pageIndex : null
30953
+ );
30954
+ return {
30955
+ displayPageNumber,
30956
+ pageCount,
30957
+ measurementFidelity: facet.getMeasurementFidelity()
30958
+ };
30959
+ }
30960
+ function normalizeStatusDisplayPageNumber(displayPageNumber, pageIndex) {
30961
+ if (pageIndex === null) return null;
30962
+ return typeof displayPageNumber === "number" && displayPageNumber > 0 ? displayPageNumber : pageIndex + 1;
30963
+ }
30964
+ function useStatusBarPageFacts(options) {
30965
+ const { layoutFacet, selectionPosition, activeStory, renderFrameRevision, viewportPageIndexRange } = options;
30966
+ return (0, import_react36.useMemo)(() => {
30967
+ return resolveStatusBarPageFacts({
30968
+ layoutFacet,
30969
+ selectionPosition,
30970
+ activeStory,
30971
+ viewportPageIndexRange
30972
+ });
30973
+ }, [layoutFacet, selectionPosition, activeStory, viewportPageIndexRange, renderFrameRevision]);
30846
30974
  }
30847
30975
 
30848
30976
  // src/ui-tailwind/review-workspace/use-grabbed-segment-offsets.ts
@@ -31470,6 +31598,12 @@ function readCompatibilityScopeCardFromWorkflowFacet(workflowFacet, scopeId) {
31470
31598
  // src/ui-tailwind/review-workspace/use-page-markers.ts
31471
31599
  var import_react43 = require("react");
31472
31600
 
31601
+ // src/api/mounted-surface-residency.ts
31602
+ var MOUNTED_SURFACE_VIEWPORT_BLOCK_THRESHOLD = 250;
31603
+ function shouldUseMountedSurfaceViewportCulling(totalBlockCount) {
31604
+ return totalBlockCount > MOUNTED_SURFACE_VIEWPORT_BLOCK_THRESHOLD;
31605
+ }
31606
+
31473
31607
  // src/ui-tailwind/page-stack/use-visible-block-range.ts
31474
31608
  var React38 = __toESM(require("react"), 1);
31475
31609
  var ESTIMATED_BLOCKS_PER_PAGE_FALLBACK = 50;
@@ -31850,7 +31984,7 @@ function pageMarkersEqual(a, b) {
31850
31984
  }
31851
31985
  return true;
31852
31986
  }
31853
- function useGeometryVisiblePageIndexRange(input) {
31987
+ function useGeometryVisiblePageIndexRanges(input) {
31854
31988
  const {
31855
31989
  scrollRoot,
31856
31990
  geometryFacet,
@@ -31860,10 +31994,12 @@ function useGeometryVisiblePageIndexRange(input) {
31860
31994
  renderFrameRevision,
31861
31995
  viewportScale
31862
31996
  } = input;
31863
- const [range, setRange] = (0, import_react43.useState)(null);
31997
+ const [ranges, setRanges] = (0, import_react43.useState)({ visiblePageIndexRange: null, viewportPageIndexRange: null });
31864
31998
  (0, import_react43.useEffect)(() => {
31865
31999
  if (!scrollRoot || !geometryFacet) {
31866
- setRange((prev) => prev === null ? prev : null);
32000
+ setRanges(
32001
+ (prev) => prev.visiblePageIndexRange === null && prev.viewportPageIndexRange === null ? prev : { visiblePageIndexRange: null, viewportPageIndexRange: null }
32002
+ );
31867
32003
  return void 0;
31868
32004
  }
31869
32005
  const runtime = scrollRoot.ownerDocument?.defaultView;
@@ -31873,7 +32009,7 @@ function useGeometryVisiblePageIndexRange(input) {
31873
32009
  if (disposed) return;
31874
32010
  const pageCount = layoutFacet?.getPageCount() ?? pageMarkerCount;
31875
32011
  const scale = typeof viewportScale === "number" && Number.isFinite(viewportScale) && viewportScale > 0 ? viewportScale : 1;
31876
- const next = resolveVisiblePageIndexRangeFromViewport({
32012
+ const nextVisible = resolveVisiblePageIndexRangeFromViewport({
31877
32013
  pageCount,
31878
32014
  viewportTopPx: scrollRoot.scrollTop / scale,
31879
32015
  viewportHeightPx: scrollRoot.clientHeight / scale,
@@ -31883,7 +32019,22 @@ function useGeometryVisiblePageIndexRange(input) {
31883
32019
  return page ? page.frame : null;
31884
32020
  }
31885
32021
  });
31886
- setRange((prev) => pageRangeEqual(prev, next) ? prev : next);
32022
+ const nextViewport = resolveVisiblePageIndexRangeFromViewport({
32023
+ pageCount,
32024
+ viewportTopPx: scrollRoot.scrollTop / scale,
32025
+ viewportHeightPx: scrollRoot.clientHeight / scale,
32026
+ overscanPages: 0,
32027
+ getPageFrame: (pageIndex) => {
32028
+ const page = geometryFacet.getPage(pageIndex);
32029
+ return page ? page.frame : null;
32030
+ }
32031
+ });
32032
+ setRanges(
32033
+ (prev) => pageRangeEqual(prev.visiblePageIndexRange, nextVisible) && pageRangeEqual(prev.viewportPageIndexRange, nextViewport) ? prev : {
32034
+ visiblePageIndexRange: nextVisible,
32035
+ viewportPageIndexRange: nextViewport
32036
+ }
32037
+ );
31887
32038
  };
31888
32039
  const schedule = () => {
31889
32040
  if (disposed || rafHandle !== null) return;
@@ -31920,7 +32071,7 @@ function useGeometryVisiblePageIndexRange(input) {
31920
32071
  scrollRoot,
31921
32072
  viewportScale
31922
32073
  ]);
31923
- return range;
32074
+ return ranges;
31924
32075
  }
31925
32076
  function shouldUseCompatibilityPageMarkerScan(input) {
31926
32077
  return !input.geometryFacet || !input.layoutFacet;
@@ -32021,7 +32172,11 @@ function usePageMarkers(options) {
32021
32172
  pageMarkers,
32022
32173
  overscanPages
32023
32174
  });
32024
- const geometryVisiblePageIndexRange = useGeometryVisiblePageIndexRange({
32175
+ const markerViewportPageIndexRange = useVisiblePageIndexRange({
32176
+ pageMarkers,
32177
+ overscanPages: 0
32178
+ });
32179
+ const geometryPageIndexRanges = useGeometryVisiblePageIndexRanges({
32025
32180
  scrollRoot: pageStackScrollRoot,
32026
32181
  geometryFacet,
32027
32182
  layoutFacet,
@@ -32030,7 +32185,8 @@ function usePageMarkers(options) {
32030
32185
  renderFrameRevision,
32031
32186
  viewportScale
32032
32187
  });
32033
- const visiblePageIndexRange = geometryVisiblePageIndexRange ?? markerVisiblePageIndexRange;
32188
+ const visiblePageIndexRange = geometryPageIndexRanges.visiblePageIndexRange ?? markerVisiblePageIndexRange;
32189
+ const viewportPageIndexRange = geometryPageIndexRanges.viewportPageIndexRange ?? markerViewportPageIndexRange;
32034
32190
  const visibleBlockRangesFromPageOffsets = (0, import_react43.useMemo)(
32035
32191
  () => visiblePageIndexRange && layoutFacet ? resolveVisibleBlockRangesFromPageOffsets({
32036
32192
  blocks: snapshot.surface?.blocks ?? [],
@@ -32066,9 +32222,11 @@ function usePageMarkers(options) {
32066
32222
  ]
32067
32223
  );
32068
32224
  const visibleBlockRanges = visibleBlockRangesFromPageOffsets ?? visibleBlockRangesFromPageRange ?? markerVisibleBlockRanges;
32225
+ const totalBlockCount = snapshot.surface?.blocks.length ?? 0;
32226
+ const shouldCullSurface = shouldUseMountedSurfaceViewportCulling(totalBlockCount);
32069
32227
  const visibleRangesKey = (0, import_react43.useMemo)(
32070
- () => visibleBlockRanges.map((r) => `${r.start}:${r.end}`).join("|"),
32071
- [visibleBlockRanges]
32228
+ () => shouldCullSurface ? visibleBlockRanges.map((r) => `${r.start}:${r.end}`).join("|") : "full",
32229
+ [shouldCullSurface, visibleBlockRanges]
32072
32230
  );
32073
32231
  (0, import_react43.useEffect)(() => {
32074
32232
  if (!layoutFacet) return;
@@ -32077,13 +32235,19 @@ function usePageMarkers(options) {
32077
32235
  layoutFacet.requestViewportRefresh();
32078
32236
  return;
32079
32237
  }
32238
+ if (!shouldCullSurface) {
32239
+ layoutFacet.setVisibleBlockRanges([]);
32240
+ layoutFacet.requestViewportRefresh();
32241
+ return;
32242
+ }
32080
32243
  layoutFacet.setVisibleBlockRanges(visibleBlockRanges);
32081
32244
  layoutFacet.requestViewportRefresh();
32082
- }, [layoutFacet, visibleRangesKey]);
32245
+ }, [layoutFacet, shouldCullSurface, visibleRangesKey]);
32083
32246
  return {
32084
32247
  pageMarkers,
32085
32248
  visibleBlockRanges,
32086
- visiblePageIndexRange: VIEWPORT_CULLING_ENABLED ? visiblePageIndexRange : null
32249
+ visiblePageIndexRange: VIEWPORT_CULLING_ENABLED ? visiblePageIndexRange : null,
32250
+ viewportPageIndexRange: VIEWPORT_CULLING_ENABLED ? viewportPageIndexRange : null
32087
32251
  };
32088
32252
  }
32089
32253
 
@@ -32686,11 +32850,20 @@ function TwReviewWorkspace(inputProps) {
32686
32850
  selectionToolbarRootRef
32687
32851
  });
32688
32852
  const activePage = props.documentNavigation?.pages[props.documentNavigation.activePageIndex] ?? null;
32853
+ const { visiblePageIndexRange, viewportPageIndexRange } = usePageMarkers({
32854
+ pageStackScrollRoot,
32855
+ snapshot,
32856
+ layoutFacet: props.layoutFacet,
32857
+ geometryFacet: props.geometryFacet,
32858
+ renderFrameRevision,
32859
+ viewportScale: zoomScale
32860
+ });
32689
32861
  const grabbedSegmentOffsets = useGrabbedSegmentOffsets(snapshot);
32690
32862
  const statusBarPageFacts = useStatusBarPageFacts({
32691
32863
  layoutFacet: props.layoutFacet,
32692
32864
  selectionPosition,
32693
32865
  activeStory: snapshot.activeStory,
32866
+ viewportPageIndexRange,
32694
32867
  renderFrameRevision
32695
32868
  });
32696
32869
  const hidePageBorderForActiveEditing = isPageWorkspace && snapshot.activeStory.kind === "main" && shouldHidePageBorderForSelection(viewState.selection);
@@ -32716,14 +32889,6 @@ function TwReviewWorkspace(inputProps) {
32716
32889
  });
32717
32890
  const suppressFloatingToolDuringEditorInput = viewState.editorRole === "editor" && viewState.selection.isCollapsed;
32718
32891
  const shouldRenderFloatingSelectionTool = chromeVisibility.selectionOverlay && gatedSelectionTool && !suppressFloatingToolDuringEditorInput && shouldRenderSelectionToolKind(scopedChromePolicy, gatedSelectionTool.kind);
32719
- const { visiblePageIndexRange } = usePageMarkers({
32720
- pageStackScrollRoot,
32721
- snapshot,
32722
- layoutFacet: props.layoutFacet,
32723
- geometryFacet: props.geometryFacet,
32724
- renderFrameRevision,
32725
- viewportScale: zoomScale
32726
- });
32727
32892
  const { dismissSelectionToolbar, runWithSelectionToolbarDismiss } = useWorkspaceSideEffects({
32728
32893
  layoutFacet: props.layoutFacet,
32729
32894
  activeParagraphLayout,