@beyondwork/docx-react-component 1.0.120 → 1.0.121

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 (116) hide show
  1. package/README.md +1 -0
  2. package/dist/api/public-types.cjs +1713 -55
  3. package/dist/api/public-types.d.cts +2 -2
  4. package/dist/api/public-types.d.ts +2 -2
  5. package/dist/api/public-types.js +6 -6
  6. package/dist/api/v3.cjs +4958 -406
  7. package/dist/api/v3.d.cts +3 -3
  8. package/dist/api/v3.d.ts +3 -3
  9. package/dist/api/v3.js +14 -14
  10. package/dist/{canonical-document-fNawStsc.d.cts → canonical-document-ByIqTd4s.d.cts} +9 -1
  11. package/dist/{canonical-document-fNawStsc.d.ts → canonical-document-ByIqTd4s.d.ts} +9 -1
  12. package/dist/{chunk-5RNMPLXU.js → chunk-37SEJQ3G.js} +4 -4
  13. package/dist/{chunk-FXGQM2JB.js → chunk-3OFSP2IX.js} +11 -5
  14. package/dist/{chunk-U5BSQXF4.js → chunk-3OHVK2D6.js} +70 -12
  15. package/dist/{chunk-AUQDC5BD.js → chunk-3TUQCHYT.js} +101 -2
  16. package/dist/{chunk-SJSMYEMU.js → chunk-B4YHWFE3.js} +3 -3
  17. package/dist/{chunk-XC56YLIS.js → chunk-C2LWJ4CZ.js} +4 -0
  18. package/dist/{chunk-VDIUVT46.js → chunk-CX42VC67.js} +1 -1
  19. package/dist/{chunk-KCHEAX4Z.js → chunk-EMDH4IQN.js} +148 -70
  20. package/dist/{chunk-TMQGWF7R.js → chunk-G3B2OBCZ.js} +352 -17
  21. package/dist/{chunk-VCL5MJMZ.js → chunk-GON2DNTE.js} +149 -28
  22. package/dist/{chunk-WVZX4NYG.js → chunk-GZW2ERUO.js} +601 -47
  23. package/dist/{chunk-WDNEPRFW.js → chunk-ICX54W4U.js} +1 -1
  24. package/dist/{chunk-FIGWJ43K.js → chunk-IT2DK3A7.js} +1883 -90
  25. package/dist/{chunk-2ZWFQ74R.js → chunk-OBCP6VTG.js} +1 -1
  26. package/dist/{chunk-FLNQY74K.js → chunk-OYGMRRR7.js} +1 -1
  27. package/dist/{chunk-MPYYBRVN.js → chunk-PCXTMEGY.js} +782 -124
  28. package/dist/{chunk-4JNUMMM7.js → chunk-PGGPPZ65.js} +17 -2
  29. package/dist/{chunk-KHZNNBTN.js → chunk-QFU7ZOAD.js} +43 -39
  30. package/dist/{chunk-4ZNQFWFM.js → chunk-QIO6V46H.js} +84 -4
  31. package/dist/{chunk-IQ2VJEF6.js → chunk-QNGJRZ2D.js} +1 -1
  32. package/dist/{chunk-BM5NSDII.js → chunk-S4ANOS2M.js} +2 -2
  33. package/dist/{chunk-AQA7OZ2R.js → chunk-TFSXOIAI.js} +959 -43
  34. package/dist/{chunk-NQZUGMLW.js → chunk-TMU7JMXX.js} +184 -32
  35. package/dist/{chunk-KD5K5XIA.js → chunk-UHQOUTAX.js} +568 -88
  36. package/dist/{chunk-327AIUXL.js → chunk-UWDWGQH5.js} +11 -4
  37. package/dist/{chunk-BBB4GSDB.js → chunk-XVFENXLK.js} +2 -2
  38. package/dist/{chunk-MUEN2WOG.js → chunk-ZKSDVHGH.js} +6 -3
  39. package/dist/compare.cjs +17 -2
  40. package/dist/compare.d.cts +1 -1
  41. package/dist/compare.d.ts +1 -1
  42. package/dist/compare.js +3 -3
  43. package/dist/core/commands/formatting-commands.d.cts +2 -2
  44. package/dist/core/commands/formatting-commands.d.ts +2 -2
  45. package/dist/core/commands/image-commands.cjs +814 -45
  46. package/dist/core/commands/image-commands.d.cts +2 -2
  47. package/dist/core/commands/image-commands.d.ts +2 -2
  48. package/dist/core/commands/image-commands.js +8 -8
  49. package/dist/core/commands/section-layout-commands.d.cts +2 -2
  50. package/dist/core/commands/section-layout-commands.d.ts +2 -2
  51. package/dist/core/commands/style-commands.d.cts +2 -2
  52. package/dist/core/commands/style-commands.d.ts +2 -2
  53. package/dist/core/commands/table-structure-commands.cjs +750 -42
  54. package/dist/core/commands/table-structure-commands.d.cts +2 -2
  55. package/dist/core/commands/table-structure-commands.d.ts +2 -2
  56. package/dist/core/commands/table-structure-commands.js +6 -6
  57. package/dist/core/commands/text-commands.cjs +910 -57
  58. package/dist/core/commands/text-commands.d.cts +2 -2
  59. package/dist/core/commands/text-commands.d.ts +2 -2
  60. package/dist/core/commands/text-commands.js +8 -8
  61. package/dist/core/selection/mapping.d.cts +2 -2
  62. package/dist/core/selection/mapping.d.ts +2 -2
  63. package/dist/core/state/editor-state.cjs +17 -2
  64. package/dist/core/state/editor-state.d.cts +2 -2
  65. package/dist/core/state/editor-state.d.ts +2 -2
  66. package/dist/core/state/editor-state.js +2 -2
  67. package/dist/index.cjs +6203 -625
  68. package/dist/index.d.cts +5 -5
  69. package/dist/index.d.ts +5 -5
  70. package/dist/index.js +299 -67
  71. package/dist/io/docx-session.cjs +354 -102
  72. package/dist/io/docx-session.d.cts +4 -4
  73. package/dist/io/docx-session.d.ts +4 -4
  74. package/dist/io/docx-session.js +5 -5
  75. package/dist/legal.cjs +183 -31
  76. package/dist/legal.d.cts +1 -1
  77. package/dist/legal.d.ts +1 -1
  78. package/dist/legal.js +3 -3
  79. package/dist/{loader-CaohrhNl.d.ts → loader-BF8ju_LK.d.ts} +22 -4
  80. package/dist/{loader-BpCyGnZl.d.cts → loader-g54WRvj1.d.cts} +22 -4
  81. package/dist/{public-types-Dpch9JG0.d.cts → public-types-D_y4Ptcj.d.cts} +747 -21
  82. package/dist/{public-types-C948HNVF.d.ts → public-types-Dl1jiWjk.d.ts} +747 -21
  83. package/dist/public-types.cjs +1713 -55
  84. package/dist/public-types.d.cts +2 -2
  85. package/dist/public-types.d.ts +2 -2
  86. package/dist/public-types.js +6 -6
  87. package/dist/runtime/collab.cjs +4 -0
  88. package/dist/runtime/collab.d.cts +3 -3
  89. package/dist/runtime/collab.d.ts +3 -3
  90. package/dist/runtime/collab.js +2 -2
  91. package/dist/runtime/document-runtime.cjs +3699 -507
  92. package/dist/runtime/document-runtime.d.cts +2 -2
  93. package/dist/runtime/document-runtime.d.ts +2 -2
  94. package/dist/runtime/document-runtime.js +18 -18
  95. package/dist/{session-Dqg17V3s.d.ts → session-C1EPAkcI.d.ts} +3 -3
  96. package/dist/{session-BlXE5zxz.d.cts → session-D15QOO0Q.d.cts} +3 -3
  97. package/dist/session.cjs +951 -104
  98. package/dist/session.d.cts +5 -5
  99. package/dist/session.d.ts +5 -5
  100. package/dist/session.js +10 -8
  101. package/dist/tailwind.cjs +1752 -91
  102. package/dist/tailwind.d.cts +2 -2
  103. package/dist/tailwind.d.ts +2 -2
  104. package/dist/tailwind.js +10 -10
  105. package/dist/{types-C9vZVpKy.d.cts → types-BoSRp2Vg.d.cts} +2 -2
  106. package/dist/{types-B1tlF1bq.d.ts → types-DEvRwq9C.d.ts} +2 -2
  107. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  108. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  109. package/dist/ui-tailwind/editor-surface/search-plugin.js +7 -7
  110. package/dist/ui-tailwind/theme/editor-theme.css +5 -5
  111. package/dist/ui-tailwind.cjs +1752 -91
  112. package/dist/ui-tailwind.d.cts +8 -8
  113. package/dist/ui-tailwind.d.ts +8 -8
  114. package/dist/ui-tailwind.js +10 -10
  115. package/package.json +17 -5
  116. package/dist/ui-tailwind/theme/tokens.css +0 -382
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-KFCQYZXR.js";
10
10
  import {
11
11
  parseTextStory
12
- } from "./chunk-4ZNQFWFM.js";
12
+ } from "./chunk-QIO6V46H.js";
13
13
  import {
14
14
  createEditorSurfaceSnapshot,
15
15
  formatPageNumber,
@@ -18,13 +18,13 @@ import {
18
18
  resolveSectionVariants,
19
19
  sectionSupportsStoryTarget,
20
20
  storyTargetKey
21
- } from "./chunk-AUQDC5BD.js";
21
+ } from "./chunk-3TUQCHYT.js";
22
22
  import {
23
23
  createSelectionSnapshot
24
- } from "./chunk-FLNQY74K.js";
24
+ } from "./chunk-OYGMRRR7.js";
25
25
  import {
26
- collectCanonicalFieldRegionIdentities
27
- } from "./chunk-AQA7OZ2R.js";
26
+ collectCanonicalLayoutInputs
27
+ } from "./chunk-TFSXOIAI.js";
28
28
  import {
29
29
  MAIN_STORY_TARGET,
30
30
  createDetachedAnchor,
@@ -3883,6 +3883,7 @@ var PAGE_INSTANCE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
3883
3883
  "NUMPAGES",
3884
3884
  "SECTIONPAGES"
3885
3885
  ]);
3886
+ var MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS = 140;
3886
3887
  var EMUS_PER_TWIP = 635;
3887
3888
  function buildPageGraph(inputOrPages, sectionsArg, storiesArg) {
3888
3889
  const input = Array.isArray(inputOrPages) ? {
@@ -4195,6 +4196,8 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
4195
4196
  layout,
4196
4197
  pageFieldCounts
4197
4198
  }) : [];
4199
+ const previewParts = source ? collectPageLocalStoryPreviewParts(source.blocks, storyKey) : [];
4200
+ const previewText = renderPageLocalStoryPreviewText(previewParts, resolvedFields);
4198
4201
  const objectLedger = source ? collectStoryAnchoredObjects(source.blocks, {
4199
4202
  frameId,
4200
4203
  storyKey,
@@ -4209,6 +4212,7 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
4209
4212
  relationshipId: target.relationshipId,
4210
4213
  sectionPart,
4211
4214
  measuredFrameHeightTwips,
4215
+ previewText,
4212
4216
  resolvedFields,
4213
4217
  anchoredObjects: objectLedger.objects
4214
4218
  });
@@ -4222,6 +4226,8 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
4222
4226
  relationshipId: target.relationshipId,
4223
4227
  ...target.sectionIndex === void 0 ? {} : { sectionIndex: target.sectionIndex },
4224
4228
  resolvedFields,
4229
+ previewText,
4230
+ previewParts,
4225
4231
  anchoredObjects: objectLedger.objects,
4226
4232
  measuredFrameHeightTwips,
4227
4233
  signature
@@ -4237,6 +4243,7 @@ function buildPageLocalStorySignature(input) {
4237
4243
  input.relationshipId,
4238
4244
  input.sectionPart,
4239
4245
  input.measuredFrameHeightTwips,
4246
+ input.previewText,
4240
4247
  ...input.resolvedFields.map(
4241
4248
  (field) => [field.fieldId, field.family, field.displayText].join(":")
4242
4249
  ),
@@ -4327,6 +4334,74 @@ function collectResolvedStoryFields(blocks, context) {
4327
4334
  for (const block of blocks) visitBlock(block);
4328
4335
  return fields;
4329
4336
  }
4337
+ function collectPageLocalStoryPreviewParts(blocks, storyKey) {
4338
+ const parts = [];
4339
+ let pageFieldOrdinal = 0;
4340
+ const visitBlock = (block) => {
4341
+ switch (block.type) {
4342
+ case "paragraph":
4343
+ for (const child of block.children) visitInline(child);
4344
+ parts.push({ kind: "text", text: " " });
4345
+ break;
4346
+ case "table":
4347
+ for (const row of block.rows) {
4348
+ for (const cell of row.cells) {
4349
+ for (const childBlock of cell.children) visitBlock(childBlock);
4350
+ }
4351
+ }
4352
+ break;
4353
+ case "sdt":
4354
+ for (const child of block.children) visitBlock(child);
4355
+ break;
4356
+ default:
4357
+ break;
4358
+ }
4359
+ };
4360
+ const visitInline = (inline) => {
4361
+ switch (inline.type) {
4362
+ case "text":
4363
+ parts.push({ kind: "text", text: inline.text });
4364
+ break;
4365
+ case "tab":
4366
+ case "hard_break":
4367
+ parts.push({ kind: "text", text: " " });
4368
+ break;
4369
+ case "field": {
4370
+ const family = inline.fieldFamily ?? classifyFieldInstructionLocal2(inline.instruction);
4371
+ const fallbackText = flattenInline2(inline.children);
4372
+ if (PAGE_INSTANCE_FIELD_FAMILIES.has(family)) {
4373
+ parts.push({
4374
+ kind: "field",
4375
+ fieldId: `${storyKey}:field-${pageFieldOrdinal}:${family}`,
4376
+ fallbackText
4377
+ });
4378
+ pageFieldOrdinal += 1;
4379
+ } else {
4380
+ parts.push({ kind: "text", text: fallbackText });
4381
+ }
4382
+ break;
4383
+ }
4384
+ case "hyperlink":
4385
+ for (const child of inline.children) visitInline(child);
4386
+ break;
4387
+ default:
4388
+ break;
4389
+ }
4390
+ };
4391
+ for (const block of blocks) visitBlock(block);
4392
+ return parts;
4393
+ }
4394
+ function renderPageLocalStoryPreviewText(parts, resolvedFields) {
4395
+ const fieldsById = new Map(resolvedFields.map((field) => [field.fieldId, field]));
4396
+ const text = parts.map(
4397
+ (part) => part.kind === "field" ? fieldsById.get(part.fieldId)?.displayText ?? part.fallbackText : part.text
4398
+ ).join("").replace(/\s+/g, " ").trim();
4399
+ return truncatePageLocalStoryPreview(text);
4400
+ }
4401
+ function truncatePageLocalStoryPreview(text) {
4402
+ if (text.length <= MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS) return text;
4403
+ return `${text.slice(0, MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
4404
+ }
4330
4405
  function collectStoryAnchoredObjects(blocks, context) {
4331
4406
  const objects = [];
4332
4407
  const divergences = [];
@@ -4727,6 +4802,7 @@ function freezeRuntimePageGraph(graph) {
4727
4802
  for (const page of graph.pages) {
4728
4803
  freezePageNode(page);
4729
4804
  }
4805
+ for (const fragment of graph.fragments) freezeBlockFragment(fragment);
4730
4806
  Object.freeze(graph.pages);
4731
4807
  Object.freeze(graph.fragments);
4732
4808
  Object.freeze(graph.anchors);
@@ -4741,6 +4817,64 @@ function freezePageNode(page) {
4741
4817
  Object.freeze(page.noteAllocations);
4742
4818
  Object.freeze(page);
4743
4819
  }
4820
+ function freezeBlockFragment(fragment) {
4821
+ if (fragment.layoutObject) {
4822
+ Object.freeze(fragment.layoutObject.measuredExtentTwips);
4823
+ if (fragment.layoutObject.fieldFamilies) Object.freeze(fragment.layoutObject.fieldFamilies);
4824
+ if (fragment.layoutObject.fieldRegions) {
4825
+ for (const region of fragment.layoutObject.fieldRegions) {
4826
+ if (region.resultRange) Object.freeze(region.resultRange);
4827
+ if (region.sourceRef) Object.freeze(region.sourceRef);
4828
+ if (region.fieldEvidence?.sourceRef) Object.freeze(region.fieldEvidence.sourceRef);
4829
+ if (region.fieldEvidence) Object.freeze(region.fieldEvidence);
4830
+ Object.freeze(region);
4831
+ }
4832
+ Object.freeze(fragment.layoutObject.fieldRegions);
4833
+ }
4834
+ if (fragment.layoutObject.bookmarkRanges) {
4835
+ for (const range of fragment.layoutObject.bookmarkRanges) {
4836
+ if (range.sourceRef) Object.freeze(range.sourceRef);
4837
+ if (range.startSourceRef) Object.freeze(range.startSourceRef);
4838
+ if (range.endSourceRef) Object.freeze(range.endSourceRef);
4839
+ Object.freeze(range);
4840
+ }
4841
+ Object.freeze(fragment.layoutObject.bookmarkRanges);
4842
+ }
4843
+ if (fragment.layoutObject.hyperlinks) {
4844
+ for (const hyperlink of fragment.layoutObject.hyperlinks) {
4845
+ if (hyperlink.sourceRef) Object.freeze(hyperlink.sourceRef);
4846
+ Object.freeze(hyperlink);
4847
+ }
4848
+ Object.freeze(fragment.layoutObject.hyperlinks);
4849
+ }
4850
+ if (fragment.layoutObject.numbering) freezeNumberingLayoutFacts(fragment.layoutObject.numbering);
4851
+ if (fragment.layoutObject.numberingRows) {
4852
+ for (const numbering of fragment.layoutObject.numberingRows) {
4853
+ freezeNumberingLayoutFacts(numbering);
4854
+ }
4855
+ Object.freeze(fragment.layoutObject.numberingRows);
4856
+ }
4857
+ Object.freeze(fragment.layoutObject);
4858
+ }
4859
+ if (fragment.paragraphLineRange) Object.freeze(fragment.paragraphLineRange);
4860
+ if (fragment.tableRowRange) Object.freeze(fragment.tableRowRange);
4861
+ if (fragment.continuation) Object.freeze(fragment.continuation);
4862
+ Object.freeze(fragment);
4863
+ }
4864
+ function freezeNumberingLayoutFacts(numbering) {
4865
+ if (!numbering) return;
4866
+ if (numbering.sourceRef) Object.freeze(numbering.sourceRef);
4867
+ if (numbering.numberingSourceRef) Object.freeze(numbering.numberingSourceRef);
4868
+ if (numbering.numberingInstanceSourceRef) Object.freeze(numbering.numberingInstanceSourceRef);
4869
+ if (numbering.abstractNumberingSourceRef) Object.freeze(numbering.abstractNumberingSourceRef);
4870
+ if (numbering.markerLane) Object.freeze(numbering.markerLane);
4871
+ if (numbering.textColumn) Object.freeze(numbering.textColumn);
4872
+ if (numbering.tabStops) {
4873
+ for (const tab of numbering.tabStops) Object.freeze(tab);
4874
+ Object.freeze(numbering.tabStops);
4875
+ }
4876
+ Object.freeze(numbering);
4877
+ }
4744
4878
  function freezePageRegions(regions) {
4745
4879
  freezePageRegion(regions.body);
4746
4880
  if (regions.header) freezePageRegion(regions.header);
@@ -4763,6 +4897,12 @@ function freezePageRegion(region) {
4763
4897
  function freezePageFrame(frame) {
4764
4898
  Object.freeze(frame.physicalBoundsTwips);
4765
4899
  Object.freeze(frame.divergenceIds);
4900
+ for (const story of frame.pageLocalStories) {
4901
+ Object.freeze(story.resolvedFields);
4902
+ Object.freeze(story.previewParts);
4903
+ Object.freeze(story.anchoredObjects);
4904
+ Object.freeze(story);
4905
+ }
4766
4906
  Object.freeze(frame.pageLocalStories);
4767
4907
  Object.freeze(frame);
4768
4908
  }
@@ -4796,16 +4936,22 @@ function normalizePageLocalStoryFieldsForPages(pages) {
4796
4936
  return { ...field, displayText };
4797
4937
  });
4798
4938
  if (!storyChanged) return story;
4939
+ const previewText = renderPageLocalStoryPreviewText(
4940
+ story.previewParts,
4941
+ resolvedFields
4942
+ );
4799
4943
  const sectionPart = story.sectionIndex === void 0 ? "section-unknown" : `section-${story.sectionIndex}`;
4800
4944
  return {
4801
4945
  ...story,
4802
4946
  resolvedFields,
4947
+ previewText,
4803
4948
  signature: buildPageLocalStorySignature({
4804
4949
  kind: story.kind,
4805
4950
  variant: story.variant,
4806
4951
  relationshipId: story.relationshipId,
4807
4952
  sectionPart,
4808
4953
  measuredFrameHeightTwips: story.measuredFrameHeightTwips,
4954
+ previewText,
4809
4955
  resolvedFields,
4810
4956
  anchoredObjects: story.anchoredObjects
4811
4957
  })
@@ -4935,10 +5081,13 @@ function collectSplitRowCarryForPage(ranges, pageRangeIndex) {
4935
5081
  }
4936
5082
 
4937
5083
  // src/runtime/layout/project-block-fragments.ts
4938
- function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlockIdByPageIndex, fragmentMeasurementsByPageIndex, fieldRegions = []) {
5084
+ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlockIdByPageIndex, fragmentMeasurementsByPageIndex, fieldRegions = [], editableTargets = [], numberingInputs = []) {
4939
5085
  const byPage = /* @__PURE__ */ new Map();
4940
5086
  const perPageCounter = /* @__PURE__ */ new Map();
4941
5087
  const fieldRegionsByParagraphIndex = buildFieldRegionsByParagraphIndex(fieldRegions);
5088
+ const generatedTargets = buildGeneratedTargets(editableTargets);
5089
+ const bookmarkRanges = buildBookmarkRanges(editableTargets);
5090
+ const numberingByParagraphIndex = buildNumberingByParagraphIndex(numberingInputs);
4942
5091
  const pushFragment = (pageIndex, fragment) => {
4943
5092
  const existing = byPage.get(pageIndex);
4944
5093
  if (existing) {
@@ -4973,6 +5122,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
4973
5122
  });
4974
5123
  },
4975
5124
  fieldRegionsByParagraphIndex,
5125
+ generatedTargets,
5126
+ bookmarkRanges,
5127
+ numberingByParagraphIndex,
4976
5128
  blockPath
4977
5129
  );
4978
5130
  continue;
@@ -4992,6 +5144,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
4992
5144
  });
4993
5145
  },
4994
5146
  fieldRegionsByParagraphIndex,
5147
+ generatedTargets,
5148
+ bookmarkRanges,
5149
+ numberingByParagraphIndex,
4995
5150
  blockPath
4996
5151
  );
4997
5152
  continue;
@@ -5022,6 +5177,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
5022
5177
  widthTwips,
5023
5178
  paginationRole: "whole",
5024
5179
  fieldRegionsByParagraphIndex,
5180
+ generatedTargets,
5181
+ bookmarkRanges,
5182
+ numberingByParagraphIndex,
5025
5183
  blockPath
5026
5184
  }),
5027
5185
  ...columnIndex !== void 0 ? { columnIndex } : {}
@@ -5168,7 +5326,7 @@ function buildRunAnchorsForLine(input) {
5168
5326
  }
5169
5327
  return anchors;
5170
5328
  }
5171
- function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
5329
+ function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
5172
5330
  for (let i = 0; i < slices.length; i += 1) {
5173
5331
  const slice = slices[i];
5174
5332
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromLines(slice.lineRange);
@@ -5192,6 +5350,9 @@ function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex =
5192
5350
  widthTwips: slice.widthTwips,
5193
5351
  paginationRole: slice.lineRange.from > 0 ? "continuation" : "slice",
5194
5352
  fieldRegionsByParagraphIndex,
5353
+ generatedTargets,
5354
+ bookmarkRanges,
5355
+ numberingByParagraphIndex,
5195
5356
  blockPath
5196
5357
  })
5197
5358
  };
@@ -5212,7 +5373,7 @@ function estimateSliceHeightFromLines(lineRange) {
5212
5373
  const lines = Math.max(0, lineRange.to - lineRange.from);
5213
5374
  return lines * 240;
5214
5375
  }
5215
- function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
5376
+ function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
5216
5377
  for (let i = 0; i < slices.length; i += 1) {
5217
5378
  const slice = slices[i];
5218
5379
  const heightTwips = slice.heightTwips ?? estimateSliceHeightFromRows(slice.rowRange);
@@ -5235,6 +5396,9 @@ function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /*
5235
5396
  heightTwips,
5236
5397
  paginationRole: slice.rowRange.from > 0 ? "continuation" : "slice",
5237
5398
  fieldRegionsByParagraphIndex,
5399
+ generatedTargets,
5400
+ bookmarkRanges,
5401
+ numberingByParagraphIndex,
5238
5402
  blockPath
5239
5403
  }),
5240
5404
  ...slice.columnIndex !== void 0 ? { columnIndex: slice.columnIndex } : {}
@@ -5305,13 +5469,27 @@ function estimateSliceHeightFromRows(rowRange) {
5305
5469
  function buildFragmentLayoutObject(input) {
5306
5470
  const fieldFamilies = collectFieldFamilies(input.block);
5307
5471
  const kind = resolveFragmentLayoutObjectKind(input.block, fieldFamilies);
5308
- const numberingRows = collectNumberingLayoutFactsForBlock(input.block, input.blockPath);
5472
+ const numberingRows = collectNumberingLayoutFactsForBlock(
5473
+ input.block,
5474
+ input.blockPath,
5475
+ input.numberingByParagraphIndex
5476
+ );
5309
5477
  const numbering = input.block.kind === "paragraph" ? numberingRows[0] : void 0;
5310
5478
  const fieldRegions = collectFieldRegionLayoutFacts(
5311
5479
  input.block,
5312
5480
  input.fragmentId,
5313
5481
  input.fieldRegionsByParagraphIndex
5314
5482
  );
5483
+ const bookmarkRanges = collectBookmarkRangeLayoutFacts(
5484
+ input.fragmentId,
5485
+ input.blockPath,
5486
+ input.bookmarkRanges
5487
+ );
5488
+ const hyperlinks = collectHyperlinkLayoutFacts(
5489
+ input.fragmentId,
5490
+ input.blockPath,
5491
+ input.generatedTargets
5492
+ );
5315
5493
  return {
5316
5494
  objectId: `${kind}:${input.fragmentId}`,
5317
5495
  kind,
@@ -5323,6 +5501,8 @@ function buildFragmentLayoutObject(input) {
5323
5501
  },
5324
5502
  ...fieldFamilies.length > 0 ? { fieldFamilies } : {},
5325
5503
  ...fieldRegions.length > 0 ? { fieldRegions } : {},
5504
+ ...bookmarkRanges.length > 0 ? { bookmarkRanges } : {},
5505
+ ...hyperlinks.length > 0 ? { hyperlinks } : {},
5326
5506
  ...numbering ? { numbering } : {},
5327
5507
  ...numberingRows.length > 0 ? { numberingRows } : {}
5328
5508
  };
@@ -5437,6 +5617,18 @@ function toRuntimeFieldRegionLayoutFacts(region, fieldRegionId) {
5437
5617
  paragraphIndex: region.paragraphIndex,
5438
5618
  fieldFamily: region.fieldFamily,
5439
5619
  refreshStatus: region.refreshStatus,
5620
+ ...region.tocId !== void 0 ? { tocId: region.tocId } : {},
5621
+ ...region.sourcePath !== void 0 ? { sourcePath: region.sourcePath } : {},
5622
+ ...region.parentKind !== void 0 ? { parentKind: region.parentKind } : {},
5623
+ ...region.resultRange !== void 0 ? {
5624
+ resultRange: {
5625
+ fromParagraphIndex: region.resultRange.fromParagraphIndex,
5626
+ toParagraphIndex: region.resultRange.toParagraphIndex
5627
+ }
5628
+ } : {},
5629
+ ...region.status !== void 0 ? { status: region.status } : {},
5630
+ ...region.cachedEntryCount !== void 0 ? { cachedEntryCount: region.cachedEntryCount } : {},
5631
+ ...region.generatedEntryCount !== void 0 ? { generatedEntryCount: region.generatedEntryCount } : {},
5440
5632
  ...region.sourceRef !== void 0 ? { sourceRef: { ...region.sourceRef } } : {},
5441
5633
  ...region.fieldEvidence !== void 0 ? {
5442
5634
  fieldEvidence: {
@@ -5446,6 +5638,134 @@ function toRuntimeFieldRegionLayoutFacts(region, fieldRegionId) {
5446
5638
  } : {}
5447
5639
  };
5448
5640
  }
5641
+ function buildGeneratedTargets(targets) {
5642
+ return targets.filter(
5643
+ (target) => target.kind === "field-result-text" || target.kind === "hyperlink-text" || target.kind === "hyperlink-destination" || target.kind === "bookmark-anchor" || target.kind === "bookmark-content-range"
5644
+ );
5645
+ }
5646
+ function buildBookmarkRanges(targets) {
5647
+ const anchors = /* @__PURE__ */ new Map();
5648
+ const contentRanges = /* @__PURE__ */ new Map();
5649
+ for (const target of targets) {
5650
+ const bookmarkId = target.link?.bookmarkId;
5651
+ if (!bookmarkId) continue;
5652
+ const key = `${target.storyKey}:${bookmarkId}`;
5653
+ if (target.kind === "bookmark-content-range") {
5654
+ contentRanges.set(key, target);
5655
+ continue;
5656
+ }
5657
+ if (target.kind !== "bookmark-anchor") continue;
5658
+ const entry = anchors.get(key) ?? {};
5659
+ if (target.targetKey.includes(":bookmark:start:")) entry.start = target;
5660
+ else if (target.targetKey.includes(":bookmark:end:")) entry.end = target;
5661
+ anchors.set(key, entry);
5662
+ }
5663
+ const ranges = [];
5664
+ for (const [key, pair] of anchors) {
5665
+ if (!pair.start || !pair.end) continue;
5666
+ const startBlockPath = topLevelBlockPath(pair.start.blockPath);
5667
+ const endBlockPath = topLevelBlockPath(pair.end.blockPath);
5668
+ const startBlockIndex = parseTopLevelBlockIndex(startBlockPath);
5669
+ const endBlockIndex = parseTopLevelBlockIndex(endBlockPath);
5670
+ if (startBlockPath === void 0 || endBlockPath === void 0 || startBlockIndex === void 0 || endBlockIndex === void 0) {
5671
+ continue;
5672
+ }
5673
+ const contentRange = contentRanges.get(key);
5674
+ ranges.push({
5675
+ bookmarkId: pair.start.link?.bookmarkId ?? pair.end.link?.bookmarkId ?? key,
5676
+ ...pair.start.link?.bookmarkName !== void 0 ? { bookmarkName: pair.start.link.bookmarkName } : {},
5677
+ storyKey: pair.start.storyKey,
5678
+ ...contentRange?.link?.rangeKey !== void 0 ? { rangeKey: contentRange.link.rangeKey } : {},
5679
+ ...contentRange?.targetKey !== void 0 ? { contentRangeTargetKey: contentRange.targetKey } : {},
5680
+ startTargetKey: pair.start.targetKey,
5681
+ endTargetKey: pair.end.targetKey,
5682
+ startBlockPath,
5683
+ endBlockPath,
5684
+ startBlockIndex,
5685
+ endBlockIndex,
5686
+ ...cloneRuntimeSourceRef(contentRange?.sourceRef ?? pair.start.sourceRef) !== void 0 ? { sourceRef: cloneRuntimeSourceRef(contentRange?.sourceRef ?? pair.start.sourceRef) } : {},
5687
+ ...cloneRuntimeSourceRef(pair.start.sourceRef) !== void 0 ? { startSourceRef: cloneRuntimeSourceRef(pair.start.sourceRef) } : {},
5688
+ ...cloneRuntimeSourceRef(pair.end.sourceRef) !== void 0 ? { endSourceRef: cloneRuntimeSourceRef(pair.end.sourceRef) } : {}
5689
+ });
5690
+ }
5691
+ return ranges;
5692
+ }
5693
+ function buildNumberingByParagraphIndex(numberingInputs) {
5694
+ const byParagraph = /* @__PURE__ */ new Map();
5695
+ for (const input of numberingInputs) {
5696
+ if (!byParagraph.has(input.paragraphIndex)) {
5697
+ byParagraph.set(input.paragraphIndex, input);
5698
+ }
5699
+ }
5700
+ return byParagraph;
5701
+ }
5702
+ function collectBookmarkRangeLayoutFacts(fragmentId, blockPath, bookmarkRanges) {
5703
+ if (!blockPath || !bookmarkRanges || bookmarkRanges.length === 0) return [];
5704
+ const blockIndex = parseTopLevelBlockIndex(blockPath);
5705
+ if (blockIndex === void 0) return [];
5706
+ const facts = [];
5707
+ for (const range of bookmarkRanges) {
5708
+ const from = Math.min(range.startBlockIndex, range.endBlockIndex);
5709
+ const to = Math.max(range.startBlockIndex, range.endBlockIndex);
5710
+ if (blockIndex < from || blockIndex > to) continue;
5711
+ const startsHere = blockIndex === range.startBlockIndex;
5712
+ const endsHere = blockIndex === range.endBlockIndex;
5713
+ facts.push({
5714
+ bookmarkRangeId: `bookmark-range:${range.storyKey}:${range.bookmarkId}:${fragmentId}`,
5715
+ bookmarkId: range.bookmarkId,
5716
+ ...range.bookmarkName !== void 0 ? { bookmarkName: range.bookmarkName } : {},
5717
+ storyKey: range.storyKey,
5718
+ rangeRole: startsHere && endsHere ? "whole" : startsHere ? "start" : endsHere ? "end" : "inside",
5719
+ startBlockPath: range.startBlockPath,
5720
+ endBlockPath: range.endBlockPath,
5721
+ ...range.rangeKey !== void 0 ? { rangeKey: range.rangeKey } : {},
5722
+ ...range.contentRangeTargetKey !== void 0 ? { contentRangeTargetKey: range.contentRangeTargetKey } : {},
5723
+ ...range.startTargetKey !== void 0 ? { startTargetKey: range.startTargetKey } : {},
5724
+ ...range.endTargetKey !== void 0 ? { endTargetKey: range.endTargetKey } : {},
5725
+ ...range.sourceRef !== void 0 ? { sourceRef: { ...range.sourceRef } } : {},
5726
+ ...range.startSourceRef !== void 0 ? { startSourceRef: { ...range.startSourceRef } } : {},
5727
+ ...range.endSourceRef !== void 0 ? { endSourceRef: { ...range.endSourceRef } } : {}
5728
+ });
5729
+ }
5730
+ return facts;
5731
+ }
5732
+ function collectHyperlinkLayoutFacts(fragmentId, blockPath, targets) {
5733
+ if (!blockPath || !targets || targets.length === 0) return [];
5734
+ const facts = [];
5735
+ for (const target of targets) {
5736
+ if (target.kind !== "hyperlink-text" && target.kind !== "hyperlink-destination") continue;
5737
+ if (!pathParticipatesInBlock(target.blockPath, blockPath)) continue;
5738
+ const href = target.link?.href;
5739
+ facts.push({
5740
+ hyperlinkLayoutId: `hyperlink:${target.targetKey}:${fragmentId}`,
5741
+ targetKey: target.targetKey,
5742
+ storyKey: target.storyKey,
5743
+ blockPath: target.blockPath,
5744
+ leafPath: target.leafPath,
5745
+ role: target.kind === "hyperlink-text" ? "display-text" : "destination",
5746
+ ...href !== void 0 ? { href } : {},
5747
+ ...target.link?.destinationKind !== void 0 ? { destinationKind: target.link.destinationKind } : href?.startsWith("#") ? { destinationKind: "internal-anchor" } : href !== void 0 ? { destinationKind: "external" } : {},
5748
+ ...target.link?.bookmarkName !== void 0 ? { targetBookmarkName: target.link.bookmarkName } : href?.startsWith("#") && href.length > 1 ? { targetBookmarkName: href.slice(1) } : {},
5749
+ ...cloneRuntimeSourceRef(target.sourceRef) !== void 0 ? { sourceRef: cloneRuntimeSourceRef(target.sourceRef) } : {}
5750
+ });
5751
+ }
5752
+ return facts;
5753
+ }
5754
+ function pathParticipatesInBlock(targetPath, blockPath) {
5755
+ return targetPath === blockPath || targetPath.startsWith(`${blockPath}/`);
5756
+ }
5757
+ function topLevelBlockPath(path) {
5758
+ const match = /^(main\/block\[\d+\])(?:\/|$)/u.exec(path);
5759
+ return match?.[1];
5760
+ }
5761
+ function parseTopLevelBlockIndex(path) {
5762
+ if (!path) return void 0;
5763
+ const match = /^main\/block\[(\d+)\]$/u.exec(path);
5764
+ return match ? Number(match[1]) : void 0;
5765
+ }
5766
+ function cloneRuntimeSourceRef(sourceRef) {
5767
+ return sourceRef !== void 0 ? { ...sourceRef } : void 0;
5768
+ }
5449
5769
  function collectNumberingLayoutFacts(block) {
5450
5770
  if (block.kind !== "paragraph") return void 0;
5451
5771
  if (!block.numbering && !block.resolvedNumbering && block.numberingPrefix === void 0) {
@@ -5485,13 +5805,14 @@ function collectNumberingLayoutFacts(block) {
5485
5805
  } : {}
5486
5806
  };
5487
5807
  }
5488
- function collectNumberingLayoutFactsForBlock(block, blockPath) {
5808
+ function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagraphIndex) {
5489
5809
  const rows = [];
5490
5810
  const seen = /* @__PURE__ */ new Set();
5491
5811
  visitParagraphBlocks(block, (paragraph, context) => {
5492
5812
  const numbering = collectNumberingLayoutFacts(paragraph);
5493
5813
  if (!numbering) return;
5494
5814
  const paragraphIndex = parseParagraphBlockIndex(paragraph.blockId);
5815
+ const canonical = paragraphIndex !== void 0 ? numberingByParagraphIndex?.get(paragraphIndex) : void 0;
5495
5816
  const numberingKey = context.path !== void 0 ? `main:${context.path}:numbering` : void 0;
5496
5817
  const numberingLayoutId = numberingKey ?? [
5497
5818
  "numbering",
@@ -5504,9 +5825,17 @@ function collectNumberingLayoutFactsForBlock(block, blockPath) {
5504
5825
  rows.push({
5505
5826
  numberingLayoutId,
5506
5827
  ...numberingKey !== void 0 ? { numberingKey } : {},
5507
- ...context.path !== void 0 ? { sourceBlockPath: context.path } : {},
5828
+ ...canonical?.storyKey !== void 0 ? { storyKey: canonical.storyKey } : {},
5829
+ ...canonical?.blockPath !== void 0 ? { sourceBlockPath: canonical.blockPath } : context.path !== void 0 ? { sourceBlockPath: context.path } : {},
5508
5830
  sourceBlockId: paragraph.blockId,
5509
5831
  ...paragraphIndex !== void 0 ? { paragraphIndex } : {},
5832
+ ...canonical?.sourceRef !== void 0 ? { sourceRef: { ...canonical.sourceRef } } : {},
5833
+ ...canonical?.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...canonical.numberingSourceRef } } : {},
5834
+ ...canonical?.numberingOrigin !== void 0 ? { numberingOrigin: canonical.numberingOrigin } : {},
5835
+ ...canonical?.paragraphStyleId !== void 0 ? { paragraphStyleId: canonical.paragraphStyleId } : {},
5836
+ ...canonical?.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...canonical.numberingInstanceSourceRef } } : {},
5837
+ ...canonical?.abstractNumberingId !== void 0 ? { abstractNumberingId: canonical.abstractNumberingId } : {},
5838
+ ...canonical?.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...canonical.abstractNumberingSourceRef } } : {},
5510
5839
  ...numbering
5511
5840
  });
5512
5841
  }, blockPath);
@@ -5914,8 +6243,8 @@ async function createCanvasProvider(fontLoader) {
5914
6243
  }
5915
6244
 
5916
6245
  // src/runtime/layout/layout-engine-version.ts
5917
- var LAYOUT_ENGINE_VERSION = 96;
5918
- var LAYCACHE_SCHEMA_VERSION = 8;
6246
+ var LAYOUT_ENGINE_VERSION = 87;
6247
+ var LAYCACHE_SCHEMA_VERSION = 10;
5919
6248
 
5920
6249
  // src/runtime/layout/layout-engine-instance.ts
5921
6250
  var FULL_VIEWPORT_WINDOW_KEY = "full";
@@ -6222,7 +6551,8 @@ function createLayoutEngine(options = {}) {
6222
6551
  MAIN_STORY_TARGET
6223
6552
  );
6224
6553
  const sections = buildResolvedSections(document2);
6225
- const fieldRegions = collectCanonicalFieldRegionIdentities(document2);
6554
+ const layoutInputs = collectCanonicalLayoutInputs(document2);
6555
+ const fieldRegions = layoutInputs.fieldRegions;
6226
6556
  const pageStack = buildPageStackWithSplits(
6227
6557
  document2,
6228
6558
  sections,
@@ -6238,7 +6568,9 @@ function createLayoutEngine(options = {}) {
6238
6568
  pageStack.splits,
6239
6569
  pageStack.columnByBlockIdByPageIndex,
6240
6570
  pageStack.fragmentMeasurementsByPageIndex,
6241
- fieldRegions
6571
+ fieldRegions,
6572
+ layoutInputs.editableTargets,
6573
+ layoutInputs.numbering
6242
6574
  );
6243
6575
  const lineBoxesByPageIndex = projectLineBoxesForPageFragments(
6244
6576
  pages,
@@ -6362,14 +6694,17 @@ function createLayoutEngine(options = {}) {
6362
6694
  const freshSnapshotsToRebuild = freshSnapshots.slice(0, convergenceIndex);
6363
6695
  const convergedTailStart = convergenceIndex < freshSnapshots.length ? firstDirty + convergenceIndex : void 0;
6364
6696
  const freshStories = resolvePageStories(freshSnapshotsToRebuild);
6365
- const fieldRegions = collectCanonicalFieldRegionIdentities(document2);
6697
+ const layoutInputs = collectCanonicalLayoutInputs(document2);
6698
+ const fieldRegions = layoutInputs.fieldRegions;
6366
6699
  const freshBodyFragmentsByPageIndex = projectSurfaceBlocksToPageFragments(
6367
6700
  mainSurface,
6368
6701
  freshSnapshotsToRebuild,
6369
6702
  freshResult.splits,
6370
6703
  freshResult.columnByBlockIdByPageIndex,
6371
6704
  freshResult.fragmentMeasurementsByPageIndex,
6372
- fieldRegions
6705
+ fieldRegions,
6706
+ layoutInputs.editableTargets,
6707
+ layoutInputs.numbering
6373
6708
  );
6374
6709
  const freshLineBoxesByPageIndex = projectLineBoxesForPageFragments(
6375
6710
  freshSnapshotsToRebuild,