@beyondwork/docx-react-component 1.0.122 → 1.0.123

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 (102) hide show
  1. package/dist/api/public-types.cjs +318 -32
  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 +349 -62
  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-ByIqTd4s.d.cts → canonical-document-CG2TgAzj.d.cts} +1 -1
  10. package/dist/{canonical-document-ByIqTd4s.d.ts → canonical-document-CG2TgAzj.d.ts} +1 -1
  11. package/dist/{chunk-B4YHWFE3.js → chunk-32ZAOQ54.js} +1 -1
  12. package/dist/{chunk-QNGJRZ2D.js → chunk-4IPEZYQX.js} +1 -1
  13. package/dist/{chunk-3OFSP2IX.js → chunk-BOHHIVQ2.js} +3 -3
  14. package/dist/{chunk-EMDH4IQN.js → chunk-E5IBDE5E.js} +4 -3
  15. package/dist/{chunk-TFSXOIAI.js → chunk-FNWKE74J.js} +43 -3
  16. package/dist/{chunk-IT2DK3A7.js → chunk-H2YQKA55.js} +9 -7
  17. package/dist/{chunk-3TUQCHYT.js → chunk-H6IL5ABU.js} +47 -7
  18. package/dist/{chunk-GON2DNTE.js → chunk-HXHQA4BU.js} +1 -1
  19. package/dist/{chunk-3OHVK2D6.js → chunk-IR7QV2BX.js} +17 -1
  20. package/dist/{chunk-ZKSDVHGH.js → chunk-KOHQFZMM.js} +1 -1
  21. package/dist/{chunk-XVFENXLK.js → chunk-LGWNN3L2.js} +2 -2
  22. package/dist/{chunk-TMU7JMXX.js → chunk-MB7RJBSN.js} +9 -21
  23. package/dist/{chunk-UWDWGQH5.js → chunk-ML4A4WUN.js} +1 -1
  24. package/dist/{chunk-GZW2ERUO.js → chunk-N4VIXI2Z.js} +3 -3
  25. package/dist/{chunk-S4ANOS2M.js → chunk-NNPVA5VL.js} +2 -2
  26. package/dist/{chunk-QFU7ZOAD.js → chunk-PFYUJU3Q.js} +176 -36
  27. package/dist/{chunk-37SEJQ3G.js → chunk-RSYN6FTS.js} +2 -2
  28. package/dist/{chunk-OBCP6VTG.js → chunk-RWERZWHR.js} +1 -1
  29. package/dist/{chunk-UHQOUTAX.js → chunk-SGSJ4DQA.js} +377 -50
  30. package/dist/{chunk-PCXTMEGY.js → chunk-UHJLCPLU.js} +24 -14
  31. package/dist/{chunk-G3B2OBCZ.js → chunk-ZRHLLPSJ.js} +271 -26
  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 +50 -9
  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 +50 -9
  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 -9
  49. package/dist/core/commands/text-commands.d.cts +3 -2
  50. package/dist/core/commands/text-commands.d.ts +3 -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 +1196 -197
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +278 -85
  60. package/dist/io/docx-session.cjs +10 -21
  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 +8 -20
  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-BF8ju_LK.d.ts → loader-D9KCtj4m.d.cts} +4 -22
  69. package/dist/{loader-g54WRvj1.d.cts → loader-D9y4ZRjj.d.ts} +4 -22
  70. package/dist/{public-types-Dl1jiWjk.d.ts → public-types-CNnMHZM9.d.ts} +263 -213
  71. package/dist/{public-types-D_y4Ptcj.d.cts → public-types-DajNGKV4.d.cts} +263 -213
  72. package/dist/public-types.cjs +318 -32
  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 +752 -77
  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-C1EPAkcI.d.ts → session-DEmaOEjA.d.ts} +3 -3
  83. package/dist/{session-D15QOO0Q.d.cts → session-DyQGlryH.d.cts} +3 -3
  84. package/dist/session.cjs +12 -618
  85. package/dist/session.d.cts +5 -5
  86. package/dist/session.d.ts +5 -5
  87. package/dist/session.js +7 -9
  88. package/dist/tailwind.cjs +489 -63
  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-BoSRp2Vg.d.cts → types-CxE1aZiv.d.cts} +2 -2
  93. package/dist/{types-DEvRwq9C.d.ts → types-DjJNaE9c.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/theme/tokens.css +387 -0
  98. package/dist/ui-tailwind.cjs +489 -63
  99. package/dist/ui-tailwind.d.cts +3 -3
  100. package/dist/ui-tailwind.d.ts +3 -3
  101. package/dist/ui-tailwind.js +7 -7
  102. package/package.json +7 -3
@@ -7,27 +7,27 @@ import {
7
7
  resolveSectionForStoryTarget,
8
8
  searchSecondaryStories,
9
9
  searchSurfaceBlocks
10
- } from "./chunk-G3B2OBCZ.js";
10
+ } from "./chunk-ZRHLLPSJ.js";
11
11
  import {
12
12
  createEditorSurfaceSnapshot,
13
13
  createFormattingContext,
14
14
  resolveTableStyleResolution
15
- } from "./chunk-3TUQCHYT.js";
15
+ } from "./chunk-H6IL5ABU.js";
16
16
  import {
17
17
  createSelectionSnapshot
18
18
  } from "./chunk-OYGMRRR7.js";
19
19
  import {
20
20
  normalizeParsedTextDocument
21
- } from "./chunk-UWDWGQH5.js";
21
+ } from "./chunk-ML4A4WUN.js";
22
22
  import {
23
23
  buildFieldRegistry,
24
24
  parseMainDocumentXml,
25
25
  parseTocLevelRange
26
- } from "./chunk-TMU7JMXX.js";
26
+ } from "./chunk-MB7RJBSN.js";
27
27
  import {
28
28
  collectEditableTargetRefs,
29
29
  validateEditableTargetRef
30
- } from "./chunk-TFSXOIAI.js";
30
+ } from "./chunk-FNWKE74J.js";
31
31
  import {
32
32
  serializeMainDocument
33
33
  } from "./chunk-EB6M3GE6.js";
@@ -4475,7 +4475,7 @@ function deriveScopeEditableTargetEvidence(document, scope, entry, options = {})
4475
4475
  facts.push(projectWorkflowBlockerFact(fact));
4476
4476
  factsByTargetKey.set(fact.targetKey, facts);
4477
4477
  }
4478
- const entries = collectEditableTargetRefs(document).map((target) => {
4478
+ const entries = collectEditableTargetRefs(document, options.editableTargetCache).map((target) => {
4479
4479
  const relation = relationForTarget(target, scope, entry);
4480
4480
  if (!relation) return null;
4481
4481
  const workflowBlockers = Object.freeze(
@@ -5454,7 +5454,8 @@ function composeEvidence(inputs) {
5454
5454
  scope,
5455
5455
  entry,
5456
5456
  {
5457
- ...inputs.editableTargetBlockerFacts ? { workflowBlockerFacts: inputs.editableTargetBlockerFacts } : {}
5457
+ ...inputs.editableTargetBlockerFacts ? { workflowBlockerFacts: inputs.editableTargetBlockerFacts } : {},
5458
+ ...inputs.editableTargetCache ? { editableTargetCache: inputs.editableTargetCache } : {}
5458
5459
  }
5459
5460
  ) : void 0;
5460
5461
  const contentControls = deriveScopeContentControlEvidence(document, selfRange);
@@ -5543,7 +5544,8 @@ function compileScopeBundle(scope, inputs) {
5543
5544
  ...inputs.layout ? { layout: inputs.layout } : {},
5544
5545
  ...inputs.adjacentGeometry ? { adjacentGeometry: inputs.adjacentGeometry } : {},
5545
5546
  ...inputs.tableCellTextRange ? { tableCellTextRange: inputs.tableCellTextRange } : {},
5546
- ...inputs.editableTargetBlockerFacts ? { editableTargetBlockerFacts: inputs.editableTargetBlockerFacts } : {}
5547
+ ...inputs.editableTargetBlockerFacts ? { editableTargetBlockerFacts: inputs.editableTargetBlockerFacts } : {},
5548
+ ...inputs.editableTargetCache ? { editableTargetCache: inputs.editableTargetCache } : {}
5547
5549
  });
5548
5550
  return {
5549
5551
  scope,
@@ -7178,7 +7180,7 @@ function createScopeCompilerService(runtime) {
7178
7180
  const interactionGuard = runtime.getInteractionGuardSnapshot?.();
7179
7181
  const activeStory = runtime.getActiveStory?.();
7180
7182
  const editableTargetBlockerFacts = deriveWorkflowEditableTargetBlockerFacts({
7181
- targets: collectEditableTargetRefs(document),
7183
+ targets: collectEditableTargetRefs(document, runtime.getEditableTargetCache?.()),
7182
7184
  ...interactionGuard ? { guard: interactionGuard } : {},
7183
7185
  ...runtime.getProtectionSnapshot ? { protectionSnapshot: runtime.getProtectionSnapshot() } : {},
7184
7186
  ...activeStory ? { activeStoryKey: storyKeyForEditableTarget(activeStory) } : {}
@@ -7189,6 +7191,7 @@ function createScopeCompilerService(runtime) {
7189
7191
  runtime.getRenderSnapshot?.()
7190
7192
  )
7191
7193
  }) : void 0;
7194
+ const editableTargetCache = runtime.getEditableTargetCache?.();
7192
7195
  return compileScopeBundleById(scopeId, {
7193
7196
  document,
7194
7197
  ...overlay ? { overlay } : {},
@@ -7198,7 +7201,8 @@ function createScopeCompilerService(runtime) {
7198
7201
  editableTargetBlockerFacts,
7199
7202
  ...runtime.geometry ? { geometry: runtime.geometry } : {},
7200
7203
  ...layout ? { layout } : {},
7201
- tableCellTextRange
7204
+ tableCellTextRange,
7205
+ ...editableTargetCache ? { editableTargetCache } : {}
7202
7206
  });
7203
7207
  },
7204
7208
  buildReplacementScope(targetHandle, input) {
@@ -7835,7 +7839,7 @@ function resolveEditableTextTarget(input) {
7835
7839
  "Editable target ref does not belong to the active story."
7836
7840
  );
7837
7841
  }
7838
- const currentTargets = collectEditableTargetRefs(input.document);
7842
+ const currentTargets = collectEditableTargetRefs(input.document, input.editableTargetCache);
7839
7843
  const current = currentTargets.find(
7840
7844
  (candidate) => candidate.targetKey === input.target.targetKey
7841
7845
  );
@@ -7944,7 +7948,7 @@ function resolveEditableCommandTarget(input) {
7944
7948
  `Editable target kind "${input.target.kind}" is not supported by this command.`
7945
7949
  );
7946
7950
  }
7947
- const currentTargets = collectEditableTargetRefs(input.document);
7951
+ const currentTargets = collectEditableTargetRefs(input.document, input.editableTargetCache);
7948
7952
  const current = currentTargets.find(
7949
7953
  (candidate) => candidate.targetKey === input.target?.targetKey
7950
7954
  );
@@ -8019,7 +8023,13 @@ function rejectCommand(code, message) {
8019
8023
  };
8020
8024
  }
8021
8025
  function sameResolvedTarget2(left, right) {
8022
- return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.targetTextLength === right.staleCheck.targetTextLength && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && left.staleCheck.wordParaId === right.staleCheck.wordParaId && left.staleCheck.wordTextId === right.staleCheck.wordTextId && jsonStable(left.staleCheck.sourceRef) === jsonStable(right.staleCheck.sourceRef) && jsonStable(left.sourceRef) === jsonStable(right.sourceRef) && jsonStable(left.table) === jsonStable(right.table) && jsonStable(left.editableOwner) === jsonStable(right.editableOwner);
8026
+ return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && sameTextTargetStaleCheck(left, right) && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.targetTextLength === right.staleCheck.targetTextLength && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && left.staleCheck.wordParaId === right.staleCheck.wordParaId && left.staleCheck.wordTextId === right.staleCheck.wordTextId && jsonStable(left.staleCheck.sourceRef) === jsonStable(right.staleCheck.sourceRef) && jsonStable(left.sourceRef) === jsonStable(right.sourceRef) && jsonStable(left.table) === jsonStable(right.table) && jsonStable(left.editableOwner) === jsonStable(right.editableOwner);
8027
+ }
8028
+ function sameTextTargetStaleCheck(left, right) {
8029
+ if (left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength) {
8030
+ return true;
8031
+ }
8032
+ return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
8023
8033
  }
8024
8034
  function locateTargetRange(document, surface, target) {
8025
8035
  if (target.kind === "hyperlink-text") {
@@ -8338,7 +8348,7 @@ function resolveEditableTableStructureTarget(input) {
8338
8348
  `Editable target is not editable${input.target.posture.blockers.length > 0 ? `: ${input.target.posture.blockers.join(", ")}` : "."}`
8339
8349
  );
8340
8350
  }
8341
- const current = collectEditableTargetRefs(input.document).find(
8351
+ const current = collectEditableTargetRefs(input.document, input.editableTargetCache).find(
8342
8352
  (candidate) => candidate.targetKey === input.target?.targetKey
8343
8353
  );
8344
8354
  if (!current) {
@@ -18,13 +18,13 @@ import {
18
18
  resolveSectionVariants,
19
19
  sectionSupportsStoryTarget,
20
20
  storyTargetKey
21
- } from "./chunk-3TUQCHYT.js";
21
+ } from "./chunk-H6IL5ABU.js";
22
22
  import {
23
23
  createSelectionSnapshot
24
24
  } from "./chunk-OYGMRRR7.js";
25
25
  import {
26
26
  collectCanonicalLayoutInputs
27
- } from "./chunk-TFSXOIAI.js";
27
+ } from "./chunk-FNWKE74J.js";
28
28
  import {
29
29
  MAIN_STORY_TARGET,
30
30
  createDetachedAnchor,
@@ -3957,6 +3957,7 @@ function buildPageGraph(inputOrPages, sectionsArg, storiesArg) {
3957
3957
  regions,
3958
3958
  divergences: frameDivergences,
3959
3959
  subParts: input.subParts,
3960
+ anchors: input.anchors,
3960
3961
  pageFieldCounts
3961
3962
  });
3962
3963
  const divergences = builtFrame.divergences;
@@ -4123,6 +4124,7 @@ function buildPageFrame(input) {
4123
4124
  stories: input.stories,
4124
4125
  regions,
4125
4126
  subParts: input.subParts,
4127
+ anchors: input.anchors,
4126
4128
  pageFieldCounts: input.pageFieldCounts
4127
4129
  });
4128
4130
  const divergences = [...input.divergences, ...pageLocalStoryResult.divergences];
@@ -4160,6 +4162,7 @@ function buildPageLocalStoryInstances(input) {
4160
4162
  input.stories.header,
4161
4163
  input.regions.header,
4162
4164
  findHeaderFooterPart(input.subParts?.headers, input.stories.header),
4165
+ input.anchors,
4163
4166
  input.pageFieldCounts
4164
4167
  );
4165
4168
  instances.push(built.instance);
@@ -4176,6 +4179,7 @@ function buildPageLocalStoryInstances(input) {
4176
4179
  input.stories.footer,
4177
4180
  input.regions.footer,
4178
4181
  findHeaderFooterPart(input.subParts?.footers, input.stories.footer),
4182
+ input.anchors,
4179
4183
  input.pageFieldCounts
4180
4184
  );
4181
4185
  instances.push(built.instance);
@@ -4183,7 +4187,7 @@ function buildPageLocalStoryInstances(input) {
4183
4187
  }
4184
4188
  return { instances, divergences };
4185
4189
  }
4186
- function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, pageFieldCounts) {
4190
+ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, anchors, pageFieldCounts) {
4187
4191
  const measuredFrameHeightTwips = region?.heightTwips ?? 0;
4188
4192
  const sectionPart = target.sectionIndex === void 0 ? "section-unknown" : `section-${target.sectionIndex}`;
4189
4193
  const instanceId = `${frameId}:${target.kind}:${target.variant}:${target.relationshipId}`;
@@ -4204,7 +4208,9 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
4204
4208
  kind: target.kind,
4205
4209
  variant: target.variant,
4206
4210
  relationshipId: target.relationshipId,
4207
- region
4211
+ region,
4212
+ storyBasePath: `${target.kind}:${source.partPath ?? `word/${target.kind}${target.relationshipId}.xml`}`,
4213
+ anchorsByInlinePath: buildAnchorsByInlinePath(anchors)
4208
4214
  }) : { objects: [], divergences: [] };
4209
4215
  const signature = buildPageLocalStorySignature({
4210
4216
  kind: target.kind,
@@ -4258,6 +4264,23 @@ function buildPageLocalStorySignature(input) {
4258
4264
  object.anchorRectTwips?.yTwips ?? "",
4259
4265
  object.anchorRectTwips?.widthTwips ?? "",
4260
4266
  object.anchorRectTwips?.heightTwips ?? "",
4267
+ object.textBoxBody?.bodyKey ?? "",
4268
+ object.textBoxBody?.status ?? "",
4269
+ object.textBoxBody?.unavailableReason ?? "",
4270
+ object.textBoxBody?.contentRectTwips?.xTwips ?? "",
4271
+ object.textBoxBody?.contentRectTwips?.yTwips ?? "",
4272
+ object.textBoxBody?.contentRectTwips?.widthTwips ?? "",
4273
+ object.textBoxBody?.contentRectTwips?.heightTwips ?? "",
4274
+ object.textBoxBody?.paragraphs.map(
4275
+ (paragraph) => [
4276
+ paragraph.paragraphKey,
4277
+ paragraph.rectTwips?.xTwips ?? "",
4278
+ paragraph.rectTwips?.yTwips ?? "",
4279
+ paragraph.rectTwips?.widthTwips ?? "",
4280
+ paragraph.rectTwips?.heightTwips ?? "",
4281
+ paragraph.unavailableReason ?? ""
4282
+ ].join("/")
4283
+ ).join(",") ?? "",
4261
4284
  object.relationshipIds?.join(",") ?? "",
4262
4285
  object.mediaIds?.join(",") ?? "",
4263
4286
  object.wrapMode ?? "",
@@ -4402,6 +4425,10 @@ function truncatePageLocalStoryPreview(text) {
4402
4425
  if (text.length <= MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS) return text;
4403
4426
  return `${text.slice(0, MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
4404
4427
  }
4428
+ function buildAnchorsByInlinePath(anchors) {
4429
+ if (!anchors || anchors.length === 0) return void 0;
4430
+ return new Map(anchors.map((anchor) => [anchor.inlinePath, anchor]));
4431
+ }
4405
4432
  function collectStoryAnchoredObjects(blocks, context) {
4406
4433
  const objects = [];
4407
4434
  const divergences = [];
@@ -4445,26 +4472,45 @@ function collectStoryAnchoredObjects(blocks, context) {
4445
4472
  });
4446
4473
  ordinal += 1;
4447
4474
  };
4448
- const visitBlock = (block) => {
4475
+ const visitBlocks = (blocksToVisit, basePath) => {
4476
+ for (let blockIndex = 0; blockIndex < blocksToVisit.length; blockIndex += 1) {
4477
+ const block = blocksToVisit[blockIndex];
4478
+ if (!block) continue;
4479
+ visitBlock(block, `${basePath}/block[${blockIndex}]`);
4480
+ }
4481
+ };
4482
+ const visitBlock = (block, blockPath) => {
4449
4483
  switch (block.type) {
4450
4484
  case "paragraph":
4451
- for (const child of block.children) visitInline(child);
4485
+ visitInlines(block.children, blockPath, `${blockPath}/inline`);
4452
4486
  break;
4453
4487
  case "table":
4454
- for (const row of block.rows) {
4455
- for (const cell of row.cells) {
4456
- for (const child of cell.children) visitBlock(child);
4488
+ for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
4489
+ const row = block.rows[rowIndex];
4490
+ if (!row) continue;
4491
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
4492
+ const cell = row.cells[cellIndex];
4493
+ if (!cell) continue;
4494
+ visitBlocks(cell.children, `${blockPath}/row[${rowIndex}]/cell[${cellIndex}]`);
4457
4495
  }
4458
4496
  }
4459
4497
  break;
4460
4498
  case "sdt":
4461
- for (const child of block.children) visitBlock(child);
4499
+ case "custom_xml":
4500
+ visitBlocks(block.children, blockPath);
4462
4501
  break;
4463
4502
  default:
4464
4503
  break;
4465
4504
  }
4466
4505
  };
4467
- const visitInline = (inline) => {
4506
+ const visitInlines = (inlines, blockPath, basePath) => {
4507
+ for (let inlineIndex = 0; inlineIndex < inlines.length; inlineIndex += 1) {
4508
+ const inline = inlines[inlineIndex];
4509
+ if (!inline) continue;
4510
+ visitInline(inline, blockPath, `${basePath}[${inlineIndex}]`);
4511
+ }
4512
+ };
4513
+ const visitInline = (inline, blockPath, inlinePath) => {
4468
4514
  switch (inline.type) {
4469
4515
  case "image": {
4470
4516
  pushObject({
@@ -4485,17 +4531,27 @@ function collectStoryAnchoredObjects(blocks, context) {
4485
4531
  inline.anchor.extent.widthEmu,
4486
4532
  inline.anchor.extent.heightEmu
4487
4533
  );
4534
+ const anchorRectTwips = resolveObjectAnchorRectTwips(
4535
+ context.region,
4536
+ extentTwips,
4537
+ inline.anchor.positionH,
4538
+ inline.anchor.positionV
4539
+ );
4540
+ const canonicalAnchor = context.anchorsByInlinePath?.get(inlinePath);
4541
+ const textBoxBody = buildDrawingFrameTextBoxBodyFacts(
4542
+ inline,
4543
+ canonicalAnchor,
4544
+ inlinePath,
4545
+ display,
4546
+ anchorRectTwips
4547
+ );
4488
4548
  pushObject({
4489
4549
  objectId: getDrawingFrameObjectId(inline, context.storyKey, ordinal),
4490
4550
  sourceType: "drawing-frame",
4491
4551
  display,
4492
4552
  extentTwips,
4493
- anchorRectTwips: resolveObjectAnchorRectTwips(
4494
- context.region,
4495
- extentTwips,
4496
- inline.anchor.positionH,
4497
- inline.anchor.positionV
4498
- ),
4553
+ anchorRectTwips,
4554
+ ...textBoxBody ? { textBoxBody } : {},
4499
4555
  ...relationshipIds.length > 0 ? { relationshipIds } : {},
4500
4556
  ...inline.content.type === "picture" && inline.content.mediaId ? { mediaIds: [inline.content.mediaId] } : {},
4501
4557
  preserveOnly: Boolean(preserveHint),
@@ -4503,7 +4559,7 @@ function collectStoryAnchoredObjects(blocks, context) {
4503
4559
  wrapMode: inline.anchor.wrapMode
4504
4560
  });
4505
4561
  if (inline.content.type === "shape") {
4506
- for (const child of inline.content.txbxBlocks ?? []) visitBlock(child);
4562
+ visitBlocks(inline.content.txbxBlocks ?? [], `${inlinePath}/txbx`);
4507
4563
  }
4508
4564
  break;
4509
4565
  }
@@ -4530,10 +4586,11 @@ function collectStoryAnchoredObjects(blocks, context) {
4530
4586
  } : {},
4531
4587
  ...preserveHint?.relationshipIds ? { relationshipIds: [...preserveHint.relationshipIds] } : {},
4532
4588
  preserveOnly: Boolean(preserveHint),
4533
- ...preserveHint ? { preserveHint } : {}
4589
+ ...preserveHint ? { preserveHint } : {},
4590
+ ...inline.type === "vml_shape" && inline.text ? { textBoxBody: buildUnsupportedVmlTextBoxFacts(inline, inlinePath) } : {}
4534
4591
  });
4535
4592
  if (inline.type === "shape") {
4536
- for (const child of inline.txbxBlocks ?? []) visitBlock(child);
4593
+ visitBlocks(inline.txbxBlocks ?? [], `${inlinePath}/txbx`);
4537
4594
  }
4538
4595
  break;
4539
4596
  }
@@ -4555,16 +4612,16 @@ function collectStoryAnchoredObjects(blocks, context) {
4555
4612
  });
4556
4613
  break;
4557
4614
  case "field":
4558
- for (const child of inline.children) visitInline(child);
4615
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
4559
4616
  break;
4560
4617
  case "hyperlink":
4561
- for (const child of inline.children) visitInline(child);
4618
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
4562
4619
  break;
4563
4620
  default:
4564
4621
  break;
4565
4622
  }
4566
4623
  };
4567
- for (const block of blocks) visitBlock(block);
4624
+ visitBlocks(blocks, context.storyBasePath);
4568
4625
  return { objects, divergences };
4569
4626
  }
4570
4627
  function getDrawingFramePreserveHint(inline) {
@@ -4572,6 +4629,170 @@ function getDrawingFramePreserveHint(inline) {
4572
4629
  if (content.type === "picture") return void 0;
4573
4630
  return content.preserveOnlyObject;
4574
4631
  }
4632
+ function buildDrawingFrameTextBoxBodyFacts(inline, canonicalAnchor, inlinePath, display, anchorRectTwips) {
4633
+ if (inline.content.type !== "shape") return void 0;
4634
+ const content = inline.content;
4635
+ const canonicalBody = canonicalAnchor?.textBoxBody;
4636
+ const hasTextBoxContent = Boolean(
4637
+ canonicalBody || content.isTextBox || content.textBoxBody || content.txbxBlocks?.length
4638
+ );
4639
+ if (!hasTextBoxContent) return void 0;
4640
+ if (!canonicalBody) {
4641
+ return unavailableTextBoxBodyFacts(
4642
+ `${canonicalAnchor?.objectKey ?? inlinePath}:txbx`,
4643
+ "unmodeled-txbx-blocks",
4644
+ content.textBoxBody,
4645
+ content.txbxBlocks?.length ?? 0,
4646
+ countParagraphBlocks(content.txbxBlocks ?? []),
4647
+ 0
4648
+ );
4649
+ }
4650
+ if (display !== "floating") {
4651
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "inline-textbox");
4652
+ }
4653
+ if (!anchorRectTwips) {
4654
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-anchor-rect");
4655
+ }
4656
+ if (canonicalBody.status !== "modeled") {
4657
+ return unavailableTextBoxBodyFactsFromCanonical(
4658
+ canonicalBody,
4659
+ normalizeTextBoxBodyUnavailableReason(canonicalBody.unavailableReason)
4660
+ );
4661
+ }
4662
+ const bodyInsetsTwips = textBoxInsetsTwips(canonicalBody.bodyProperties);
4663
+ if (!bodyInsetsTwips) {
4664
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-body-insets");
4665
+ }
4666
+ const contentRectTwips = rect(
4667
+ anchorRectTwips.xTwips + bodyInsetsTwips.leftTwips,
4668
+ anchorRectTwips.yTwips + bodyInsetsTwips.topTwips,
4669
+ Math.max(0, anchorRectTwips.widthTwips - bodyInsetsTwips.leftTwips - bodyInsetsTwips.rightTwips),
4670
+ Math.max(0, anchorRectTwips.heightTwips - bodyInsetsTwips.topTwips - bodyInsetsTwips.bottomTwips)
4671
+ );
4672
+ return {
4673
+ bodyKey: canonicalBody.bodyKey,
4674
+ status: "modeled",
4675
+ ...canonicalBody.bodyProperties ? { bodyProperties: { ...canonicalBody.bodyProperties } } : {},
4676
+ bodyInsetsTwips,
4677
+ contentRectTwips,
4678
+ blockCount: canonicalBody.blockCount,
4679
+ paragraphCount: canonicalBody.paragraphCount,
4680
+ unsupportedBlockCount: canonicalBody.unsupportedBlockCount,
4681
+ paragraphs: buildTextBoxParagraphFacts(canonicalBody, contentRectTwips)
4682
+ };
4683
+ }
4684
+ function unavailableTextBoxBodyFactsFromCanonical(body, reason) {
4685
+ return {
4686
+ bodyKey: body.bodyKey,
4687
+ status: body.status === "preserve-only" ? "preserve-only" : "unavailable",
4688
+ unavailableReason: reason,
4689
+ ...body.bodyProperties ? { bodyProperties: { ...body.bodyProperties } } : {},
4690
+ blockCount: body.blockCount,
4691
+ paragraphCount: body.paragraphCount,
4692
+ unsupportedBlockCount: body.unsupportedBlockCount,
4693
+ paragraphs: body.paragraphs.map((paragraph) => ({
4694
+ paragraphKey: paragraph.paragraphKey,
4695
+ blockPath: paragraph.blockPath,
4696
+ blockIndex: paragraph.blockIndex,
4697
+ unavailableReason: reason,
4698
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
4699
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
4700
+ textLength: paragraph.textLength,
4701
+ runCount: paragraph.runCount
4702
+ }))
4703
+ };
4704
+ }
4705
+ function unavailableTextBoxBodyFacts(bodyKey, reason, bodyProperties, blockCount, paragraphCount, unsupportedBlockCount) {
4706
+ return {
4707
+ bodyKey,
4708
+ status: "unavailable",
4709
+ unavailableReason: reason,
4710
+ ...bodyProperties ? { bodyProperties: { ...bodyProperties } } : {},
4711
+ blockCount,
4712
+ paragraphCount,
4713
+ unsupportedBlockCount,
4714
+ paragraphs: []
4715
+ };
4716
+ }
4717
+ function buildUnsupportedVmlTextBoxFacts(inline, inlinePath) {
4718
+ const hasText = Boolean(inline.text?.length);
4719
+ return {
4720
+ bodyKey: `${inline.preserveOnlyObject?.sourceId ?? inlinePath}:vml-textbox`,
4721
+ status: "unavailable",
4722
+ unavailableReason: "unsupported-vml-textbox",
4723
+ blockCount: hasText ? 1 : 0,
4724
+ paragraphCount: hasText ? 1 : 0,
4725
+ unsupportedBlockCount: hasText ? 1 : 0,
4726
+ paragraphs: []
4727
+ };
4728
+ }
4729
+ function buildTextBoxParagraphFacts(body, contentRectTwips) {
4730
+ const paragraphCount = body.paragraphs.length;
4731
+ if (paragraphCount === 0) return [];
4732
+ const baseHeight = Math.floor(contentRectTwips.heightTwips / paragraphCount);
4733
+ return body.paragraphs.map((paragraph, index) => {
4734
+ const yTwips = contentRectTwips.yTwips + baseHeight * index;
4735
+ const heightTwips = index === paragraphCount - 1 ? Math.max(0, contentRectTwips.yTwips + contentRectTwips.heightTwips - yTwips) : Math.max(0, baseHeight);
4736
+ return {
4737
+ paragraphKey: paragraph.paragraphKey,
4738
+ blockPath: paragraph.blockPath,
4739
+ blockIndex: paragraph.blockIndex,
4740
+ rectTwips: rect(
4741
+ contentRectTwips.xTwips,
4742
+ yTwips,
4743
+ contentRectTwips.widthTwips,
4744
+ heightTwips
4745
+ ),
4746
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
4747
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
4748
+ textLength: paragraph.textLength,
4749
+ runCount: paragraph.runCount
4750
+ };
4751
+ });
4752
+ }
4753
+ function textBoxInsetsTwips(bodyProperties) {
4754
+ if (!bodyProperties || bodyProperties.insetLeftEmu === void 0 || bodyProperties.insetTopEmu === void 0 || bodyProperties.insetRightEmu === void 0 || bodyProperties.insetBottomEmu === void 0) {
4755
+ return void 0;
4756
+ }
4757
+ return {
4758
+ leftTwips: Math.max(0, Math.round(bodyProperties.insetLeftEmu / EMUS_PER_TWIP)),
4759
+ topTwips: Math.max(0, Math.round(bodyProperties.insetTopEmu / EMUS_PER_TWIP)),
4760
+ rightTwips: Math.max(0, Math.round(bodyProperties.insetRightEmu / EMUS_PER_TWIP)),
4761
+ bottomTwips: Math.max(0, Math.round(bodyProperties.insetBottomEmu / EMUS_PER_TWIP))
4762
+ };
4763
+ }
4764
+ function normalizeTextBoxBodyUnavailableReason(reason) {
4765
+ switch (reason) {
4766
+ case "txbx-blocks-unavailable":
4767
+ case "empty-body":
4768
+ case "unsupported-content":
4769
+ return reason;
4770
+ default:
4771
+ return "unmodeled-txbx-blocks";
4772
+ }
4773
+ }
4774
+ function countParagraphBlocks(blocks) {
4775
+ let count = 0;
4776
+ const visit = (block) => {
4777
+ if (block.type === "paragraph") {
4778
+ count += 1;
4779
+ return;
4780
+ }
4781
+ if (block.type === "table") {
4782
+ for (const row of block.rows) {
4783
+ for (const cell of row.cells) {
4784
+ for (const child of cell.children) visit(child);
4785
+ }
4786
+ }
4787
+ return;
4788
+ }
4789
+ if (block.type === "sdt" || block.type === "custom_xml") {
4790
+ for (const child of block.children) visit(child);
4791
+ }
4792
+ };
4793
+ for (const block of blocks) visit(block);
4794
+ return count;
4795
+ }
4575
4796
  function collectDrawingRelationshipIds(inline) {
4576
4797
  const content = inline.content;
4577
4798
  if (content.type === "picture") return [content.blipRef];
@@ -4900,12 +5121,34 @@ function freezePageFrame(frame) {
4900
5121
  for (const story of frame.pageLocalStories) {
4901
5122
  Object.freeze(story.resolvedFields);
4902
5123
  Object.freeze(story.previewParts);
5124
+ for (const object of story.anchoredObjects) {
5125
+ freezeStoryAnchoredObject(object);
5126
+ }
4903
5127
  Object.freeze(story.anchoredObjects);
4904
5128
  Object.freeze(story);
4905
5129
  }
4906
5130
  Object.freeze(frame.pageLocalStories);
4907
5131
  Object.freeze(frame);
4908
5132
  }
5133
+ function freezeStoryAnchoredObject(object) {
5134
+ if (object.extentTwips) Object.freeze(object.extentTwips);
5135
+ if (object.anchorRectTwips) Object.freeze(object.anchorRectTwips);
5136
+ if (object.relationshipIds) Object.freeze(object.relationshipIds);
5137
+ if (object.mediaIds) Object.freeze(object.mediaIds);
5138
+ if (object.textBoxBody) {
5139
+ if (object.textBoxBody.bodyProperties) Object.freeze(object.textBoxBody.bodyProperties);
5140
+ if (object.textBoxBody.bodyInsetsTwips) Object.freeze(object.textBoxBody.bodyInsetsTwips);
5141
+ if (object.textBoxBody.contentRectTwips) Object.freeze(object.textBoxBody.contentRectTwips);
5142
+ for (const paragraph of object.textBoxBody.paragraphs) {
5143
+ if (paragraph.rectTwips) Object.freeze(paragraph.rectTwips);
5144
+ Object.freeze(paragraph);
5145
+ }
5146
+ Object.freeze(object.textBoxBody.paragraphs);
5147
+ Object.freeze(object.textBoxBody);
5148
+ }
5149
+ Object.freeze(object.divergenceIds);
5150
+ Object.freeze(object);
5151
+ }
4909
5152
  function normalizePageLocalStoryFieldsForPages(pages) {
4910
5153
  const pageFieldCounts = buildPageFieldCounts(pages);
4911
5154
  return pages.map((page) => {
@@ -6244,7 +6487,7 @@ async function createCanvasProvider(fontLoader) {
6244
6487
 
6245
6488
  // src/runtime/layout/layout-engine-version.ts
6246
6489
  var LAYOUT_ENGINE_VERSION = 87;
6247
- var LAYCACHE_SCHEMA_VERSION = 10;
6490
+ var LAYCACHE_SCHEMA_VERSION = 11;
6248
6491
 
6249
6492
  // src/runtime/layout/layout-engine-instance.ts
6250
6493
  var FULL_VIEWPORT_WINDOW_KEY = "full";
@@ -6590,7 +6833,8 @@ function createLayoutEngine(options = {}) {
6590
6833
  fragmentsByPageIndex,
6591
6834
  lineBoxesByPageIndex,
6592
6835
  noteAllocationsByPageIndex: pageStack.noteAllocationsByPageIndex,
6593
- subParts: document2.subParts
6836
+ subParts: document2.subParts,
6837
+ anchors: layoutInputs.anchors
6594
6838
  });
6595
6839
  const graph = applyViewportWindowMaterialization(
6596
6840
  measuredGraph,
@@ -6725,7 +6969,8 @@ function createLayoutEngine(options = {}) {
6725
6969
  fragmentsByPageIndex: freshFragmentsByPageIndex,
6726
6970
  lineBoxesByPageIndex: freshLineBoxesByPageIndex,
6727
6971
  noteAllocationsByPageIndex: freshResult.noteAllocationsByPageIndex,
6728
- subParts: document2.subParts
6972
+ subParts: document2.subParts,
6973
+ anchors: layoutInputs.anchors
6729
6974
  });
6730
6975
  const freshNodes = freshGraph.pages;
6731
6976
  const splicedGraph = spliceGraph(priorGraph, freshNodes, firstDirty, convergedTailStart);
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocument, B as BlockNode } from './canonical-document-ByIqTd4s.cjs';
1
+ import { C as CanonicalDocument, B as BlockNode } from './canonical-document-CG2TgAzj.cjs';
2
2
 
3
3
  type OpcCompressionMethod = "store" | "deflate";
4
4
  type OpcSurfaceKind = "content" | "relationships" | "content-types";
package/dist/compare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocument, B as BlockNode } from './canonical-document-ByIqTd4s.js';
1
+ import { C as CanonicalDocument, B as BlockNode } from './canonical-document-CG2TgAzj.js';
2
2
 
3
3
  type OpcCompressionMethod = "store" | "deflate";
4
4
  type OpcSurfaceKind = "content" | "relationships" | "content-types";
@@ -1,7 +1,7 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-D_y4Ptcj.cjs';
4
- import '../../canonical-document-ByIqTd4s.cjs';
3
+ export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-DajNGKV4.cjs';
4
+ import '../../canonical-document-CG2TgAzj.cjs';
5
5
  import 'react';
6
6
  import 'yjs';
7
7
  import 'y-protocols/awareness';
@@ -1,7 +1,7 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-Dl1jiWjk.js';
4
- import '../../canonical-document-ByIqTd4s.js';
3
+ export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-CNnMHZM9.js';
4
+ import '../../canonical-document-CG2TgAzj.js';
5
5
  import 'react';
6
6
  import 'yjs';
7
7
  import 'y-protocols/awareness';