@beyondwork/docx-react-component 1.0.122 → 1.0.124

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 +351 -56
  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-EMDH4IQN.js → chunk-4B74ETJI.js} +4 -3
  13. package/dist/{chunk-QNGJRZ2D.js → chunk-4IPEZYQX.js} +1 -1
  14. package/dist/{chunk-S4ANOS2M.js → chunk-7PC6XUNO.js} +2 -2
  15. package/dist/{chunk-TMU7JMXX.js → chunk-A74Y5NE4.js} +11 -15
  16. package/dist/{chunk-3OFSP2IX.js → chunk-BOHHIVQ2.js} +3 -3
  17. package/dist/{chunk-TFSXOIAI.js → chunk-FNWKE74J.js} +43 -3
  18. package/dist/{chunk-3TUQCHYT.js → chunk-H6IL5ABU.js} +47 -7
  19. package/dist/{chunk-GON2DNTE.js → chunk-HXHQA4BU.js} +1 -1
  20. package/dist/{chunk-3OHVK2D6.js → chunk-IR7QV2BX.js} +17 -1
  21. package/dist/{chunk-ZKSDVHGH.js → chunk-KOHQFZMM.js} +1 -1
  22. package/dist/{chunk-XVFENXLK.js → chunk-LGWNN3L2.js} +2 -2
  23. package/dist/{chunk-UHQOUTAX.js → chunk-MPH4ZQS4.js} +377 -50
  24. package/dist/{chunk-GZW2ERUO.js → chunk-N4VIXI2Z.js} +3 -3
  25. package/dist/{chunk-OBCP6VTG.js → chunk-NAMAWCXN.js} +1 -1
  26. package/dist/{chunk-QFU7ZOAD.js → chunk-PFYUJU3Q.js} +176 -36
  27. package/dist/{chunk-PCXTMEGY.js → chunk-Q76XPPTA.js} +24 -14
  28. package/dist/{chunk-37SEJQ3G.js → chunk-RSYN6FTS.js} +2 -2
  29. package/dist/{chunk-UWDWGQH5.js → chunk-TY4DIJO3.js} +1 -1
  30. package/dist/{chunk-IT2DK3A7.js → chunk-ZMRO6P3A.js} +9 -7
  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 +1198 -191
  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 +12 -15
  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 +10 -14
  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 +14 -612
  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
package/dist/api/v3.cjs CHANGED
@@ -12869,12 +12869,13 @@ function buildBlockCacheSignature(context, blockIndex) {
12869
12869
  owner?.targetKey ?? ""
12870
12870
  ].join("|");
12871
12871
  }
12872
- function collectEditableTargetsInBlocks(blocks, context, targets, cache) {
12872
+ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIndexOffset = 0) {
12873
12873
  for (let blockIndex = 0; blockIndex < blocks.length; blockIndex += 1) {
12874
12874
  const block = blocks[blockIndex];
12875
12875
  if (!block) continue;
12876
- const blockPath = `${context.basePath}/block[${blockIndex}]`;
12877
- const signature = cache !== void 0 ? buildBlockCacheSignature(context, blockIndex) : "";
12876
+ const absoluteBlockIndex = blockIndex + blockIndexOffset;
12877
+ const blockPath = `${context.basePath}/block[${absoluteBlockIndex}]`;
12878
+ const signature = cache !== void 0 ? buildBlockCacheSignature(context, absoluteBlockIndex) : "";
12878
12879
  if (cache !== void 0) {
12879
12880
  const cached = cache.get(block);
12880
12881
  if (cached !== void 0 && cached.blockPath === blockPath && cached.signature === signature) {
@@ -18404,7 +18405,7 @@ function resolveContentType(path, contentTypes) {
18404
18405
  // src/io/ooxml/parse-bookmark-references.ts
18405
18406
  var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
18406
18407
  var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
18407
- var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
18408
+ var FLD_SIMPLE_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*(?:\bw:instr|\binstr)\s*=\s*(["'])([\s\S]*?)\1/gi;
18408
18409
  var TOC_FIELD_RE = /\bTOC\b/;
18409
18410
  var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
18410
18411
  var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
@@ -18423,15 +18424,11 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18423
18424
  }
18424
18425
  INSTR_TEXT_RE.lastIndex = 0;
18425
18426
  while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
18426
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
18427
- retainAllToc = true;
18428
- }
18427
+ if (scanInstructionText(m[1] ?? "", retained)) retainAllToc = true;
18429
18428
  }
18430
- SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
18431
- while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
18432
- if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
18433
- retainAllToc = true;
18434
- }
18429
+ FLD_SIMPLE_INSTR_RE.lastIndex = 0;
18430
+ while ((m = FLD_SIMPLE_INSTR_RE.exec(documentXml)) !== null) {
18431
+ if (scanInstructionText(m[2] ?? "", retained)) retainAllToc = true;
18435
18432
  }
18436
18433
  retainRevisionBoundedBookmarks(documentXml, retained);
18437
18434
  return {
@@ -18440,11 +18437,11 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
18440
18437
  retainAll
18441
18438
  };
18442
18439
  }
18443
- function scanInstructionForRetainedBookmarks(instruction, retained) {
18444
- const hasTocField = TOC_FIELD_RE.test(instruction);
18440
+ function scanInstructionText(instrText, retained) {
18441
+ const hasTocField = TOC_FIELD_RE.test(instrText);
18445
18442
  REFLIKE_FIELD_RE.lastIndex = 0;
18446
18443
  let r;
18447
- while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
18444
+ while ((r = REFLIKE_FIELD_RE.exec(instrText)) !== null) {
18448
18445
  if (r[1]) retained.add(r[1]);
18449
18446
  }
18450
18447
  return hasTocField;
@@ -21952,7 +21949,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
21952
21949
  "FORMULA"
21953
21950
  ]);
21954
21951
  var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
21955
- var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
21952
+ var SIMPLE_FIELD_INSTR_RE = /\bw:instr="([^"]*)"/g;
21956
21953
  var COMPLEX_FIELD_TOKEN_RE = /<(?:\w+:)?fldChar\b[^>]*?(?:\w+:)?fldCharType="(begin|separate|end)"[^>]*?(?:\/>|>[\s\S]*?<\/(?:\w+:)?fldChar>)|<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu;
21957
21954
  function decodeXmlEntities5(text) {
21958
21955
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
@@ -21993,7 +21990,7 @@ function isSafeTableFieldInstruction(instruction) {
21993
21990
  }
21994
21991
  function tableRequiresOpaquePreservation(rawXml) {
21995
21992
  if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
21996
- const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
21993
+ const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE)].map(
21997
21994
  (match) => match[1] ?? ""
21998
21995
  );
21999
21996
  const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
@@ -27773,7 +27770,8 @@ function parseCommentDefinitions(commentsXml, extensions, durableIds) {
27773
27770
  const createdAt = normalizeImportedTimestamp2(
27774
27771
  readStringAttr(child, "w:date")
27775
27772
  );
27776
- const initials = readStringAttr(child, "w:initials");
27773
+ const rawInitials = readStringAttr(child, "w:initials");
27774
+ const initials = rawInitials !== void 0 && rawInitials.trim().length > 0 ? rawInitials : void 0;
27777
27775
  const paragraphNodes = child.children.filter(
27778
27776
  (node) => node.type === "element" && localName(node.name) === "p"
27779
27777
  );
@@ -32546,7 +32544,7 @@ async function computeStructuralHash(blocks) {
32546
32544
 
32547
32545
  // src/runtime/layout/layout-engine-version.ts
32548
32546
  var LAYOUT_ENGINE_VERSION = 87;
32549
- var LAYCACHE_SCHEMA_VERSION = 10;
32547
+ var LAYCACHE_SCHEMA_VERSION = 11;
32550
32548
 
32551
32549
  // src/runtime/prerender/customxml-cache.ts
32552
32550
  var LAYCACHE_NAMESPACE_NAME = "laycache";
@@ -34847,7 +34845,7 @@ function deriveScopeEditableTargetEvidence(document2, scope, entry, options = {}
34847
34845
  facts.push(projectWorkflowBlockerFact(fact));
34848
34846
  factsByTargetKey.set(fact.targetKey, facts);
34849
34847
  }
34850
- const entries = collectEditableTargetRefs(document2).map((target) => {
34848
+ const entries = collectEditableTargetRefs(document2, options.editableTargetCache).map((target) => {
34851
34849
  const relation = relationForTarget(target, scope, entry);
34852
34850
  if (!relation) return null;
34853
34851
  const workflowBlockers = Object.freeze(
@@ -40507,7 +40505,8 @@ function composeEvidence(inputs) {
40507
40505
  scope,
40508
40506
  entry,
40509
40507
  {
40510
- ...inputs.editableTargetBlockerFacts ? { workflowBlockerFacts: inputs.editableTargetBlockerFacts } : {}
40508
+ ...inputs.editableTargetBlockerFacts ? { workflowBlockerFacts: inputs.editableTargetBlockerFacts } : {},
40509
+ ...inputs.editableTargetCache ? { editableTargetCache: inputs.editableTargetCache } : {}
40511
40510
  }
40512
40511
  ) : void 0;
40513
40512
  const contentControls = deriveScopeContentControlEvidence(document2, selfRange);
@@ -40596,7 +40595,8 @@ function compileScopeBundle(scope, inputs) {
40596
40595
  ...inputs.layout ? { layout: inputs.layout } : {},
40597
40596
  ...inputs.adjacentGeometry ? { adjacentGeometry: inputs.adjacentGeometry } : {},
40598
40597
  ...inputs.tableCellTextRange ? { tableCellTextRange: inputs.tableCellTextRange } : {},
40599
- ...inputs.editableTargetBlockerFacts ? { editableTargetBlockerFacts: inputs.editableTargetBlockerFacts } : {}
40598
+ ...inputs.editableTargetBlockerFacts ? { editableTargetBlockerFacts: inputs.editableTargetBlockerFacts } : {},
40599
+ ...inputs.editableTargetCache ? { editableTargetCache: inputs.editableTargetCache } : {}
40600
40600
  });
40601
40601
  return {
40602
40602
  scope,
@@ -42585,7 +42585,7 @@ function createScopeCompilerService(runtime) {
42585
42585
  const interactionGuard = runtime.getInteractionGuardSnapshot?.();
42586
42586
  const activeStory = runtime.getActiveStory?.();
42587
42587
  const editableTargetBlockerFacts = deriveWorkflowEditableTargetBlockerFacts({
42588
- targets: collectEditableTargetRefs(document2),
42588
+ targets: collectEditableTargetRefs(document2, runtime.getEditableTargetCache?.()),
42589
42589
  ...interactionGuard ? { guard: interactionGuard } : {},
42590
42590
  ...runtime.getProtectionSnapshot ? { protectionSnapshot: runtime.getProtectionSnapshot() } : {},
42591
42591
  ...activeStory ? { activeStoryKey: storyKeyForEditableTarget(activeStory) } : {}
@@ -42596,6 +42596,7 @@ function createScopeCompilerService(runtime) {
42596
42596
  runtime.getRenderSnapshot?.()
42597
42597
  )
42598
42598
  }) : void 0;
42599
+ const editableTargetCache = runtime.getEditableTargetCache?.();
42599
42600
  return compileScopeBundleById(scopeId, {
42600
42601
  document: document2,
42601
42602
  ...overlay ? { overlay } : {},
@@ -42605,7 +42606,8 @@ function createScopeCompilerService(runtime) {
42605
42606
  editableTargetBlockerFacts,
42606
42607
  ...runtime.geometry ? { geometry: runtime.geometry } : {},
42607
42608
  ...layout ? { layout } : {},
42608
- tableCellTextRange
42609
+ tableCellTextRange,
42610
+ ...editableTargetCache ? { editableTargetCache } : {}
42609
42611
  });
42610
42612
  },
42611
42613
  buildReplacementScope(targetHandle, input) {
@@ -43938,6 +43940,8 @@ function toV3PageLocalStoryObject(object) {
43938
43940
  heightTwips: object.extentTwips.heightTwips
43939
43941
  }
43940
43942
  } : {},
43943
+ ...object.anchorRectTwips ? { anchorRectTwips: cloneRect2(object.anchorRectTwips) } : {},
43944
+ ...object.textBoxBody ? { textBoxBody: object.textBoxBody } : {},
43941
43945
  ...object.relationshipIds ? { relationshipIds: [...object.relationshipIds] } : {},
43942
43946
  ...object.mediaIds ? { mediaIds: [...object.mediaIds] } : {},
43943
43947
  preserveOnly: object.preserveOnly,
@@ -46481,6 +46485,8 @@ function createSurfaceBlock(block, document2, cursor, counters, formattingContex
46481
46485
  formattingContext,
46482
46486
  promoteSecondaryStoryTextBoxes,
46483
46487
  cullBuild,
46488
+ editableTargetsByBlockPath,
46489
+ blockPath,
46484
46490
  blockPath !== void 0 ? editableTargetsByBlockPath.get(blockPath) : void 0
46485
46491
  );
46486
46492
  }
@@ -46887,7 +46893,7 @@ function getRecursableSdtBlockedReasonCode(block) {
46887
46893
  ].filter(Boolean).join(" ").toLowerCase();
46888
46894
  return searchText.includes("table of contents") || /\btoc\b/u.test(searchText) ? "workflow_preserve_only" : null;
46889
46895
  }
46890
- function createParagraphBlock(paragraphIndex, paragraph, document2, start, formattingContext, promoteSecondaryStoryTextBoxes, cullBuild = false, editableTarget) {
46896
+ function createParagraphBlock(paragraphIndex, paragraph, document2, start, formattingContext, promoteSecondaryStoryTextBoxes, cullBuild = false, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH, blockPath, editableTarget) {
46891
46897
  const themeResolver = formattingContext.theme;
46892
46898
  const effectiveNumbering = formattingContext.resolveEffectiveParagraphNumbering(paragraph);
46893
46899
  let resolvedNumbering = null;
@@ -46952,6 +46958,8 @@ function createParagraphBlock(paragraphIndex, paragraph, document2, start, forma
46952
46958
  document2,
46953
46959
  cursor,
46954
46960
  promoteSecondaryStoryTextBoxes,
46961
+ blockPath !== void 0 ? `${blockPath}/inline[${childIndex}]` : void 0,
46962
+ editableTargetsByBlockPath,
46955
46963
  void 0,
46956
46964
  cullBuild,
46957
46965
  themeResolver,
@@ -47008,7 +47016,7 @@ function isVisibleTocResultInline(node) {
47008
47016
  return false;
47009
47017
  }
47010
47018
  }
47011
- function appendInlineSegments(paragraph, node, document2, start, promoteSecondaryStoryTextBoxes, hyperlinkHref, cullBuild = false, themeResolver, formattingContext) {
47019
+ function appendInlineSegments(paragraph, node, document2, start, promoteSecondaryStoryTextBoxes, inlinePath, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH, hyperlinkHref, cullBuild = false, themeResolver, formattingContext) {
47012
47020
  switch (node.type) {
47013
47021
  case "text": {
47014
47022
  const cloned = node.marks ? cloneMarks(node.marks) : { marks: [] };
@@ -47061,13 +47069,16 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
47061
47069
  return { nextCursor: start + 1, lockedFragmentIds: [] };
47062
47070
  case "hyperlink": {
47063
47071
  let cursor = start;
47064
- for (const child of node.children) {
47072
+ for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {
47073
+ const child = node.children[childIndex];
47065
47074
  const result = appendInlineSegments(
47066
47075
  paragraph,
47067
47076
  child,
47068
47077
  document2,
47069
47078
  cursor,
47070
47079
  promoteSecondaryStoryTextBoxes,
47080
+ inlinePath !== void 0 ? `${inlinePath}/child[${childIndex}]` : void 0,
47081
+ editableTargetsByBlockPath,
47071
47082
  node.href,
47072
47083
  cullBuild,
47073
47084
  themeResolver,
@@ -47126,6 +47137,33 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
47126
47137
  if (isMicrosoftSensitivityLabelShape(node)) {
47127
47138
  return { nextCursor: start + 1, lockedFragmentIds: [] };
47128
47139
  }
47140
+ if (node.isTextBox && node.txbxBlocks !== void 0) {
47141
+ const txbxTextSegment = extractTxbxFirstTextSegment(node.txbxBlocks);
47142
+ const txbxText = txbxTextSegment?.text ?? node.text;
47143
+ const txbxBody = surfaceTextBoxBodyFromShape(
47144
+ node,
47145
+ void 0,
47146
+ inlinePath,
47147
+ editableTargetsByBlockPath
47148
+ );
47149
+ paragraph.segments.push({
47150
+ segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
47151
+ kind: "shape",
47152
+ from: start,
47153
+ to: start + 1,
47154
+ label: "Text box",
47155
+ detail: createShapeDetail(node),
47156
+ ...node.geometry !== void 0 ? { geometry: node.geometry } : {},
47157
+ isTextBox: true,
47158
+ ...node.textBoxBody ? { textBoxBody: node.textBoxBody } : {},
47159
+ ...node.preserveOnlyObject ? { preserveOnlyObject: surfacePreserveOnlyObject(node.preserveOnlyObject) } : {},
47160
+ ...txbxText ? { txbxText } : {},
47161
+ ...txbxBody ? { txbxBody } : {},
47162
+ ...txbxTextSegment?.marks && txbxTextSegment.marks.length > 0 ? { txbxMarks: txbxTextSegment.marks } : {},
47163
+ ...txbxTextSegment?.markAttrs ? { txbxMarkAttrs: txbxTextSegment.markAttrs } : {}
47164
+ });
47165
+ return { nextCursor: start + 1, lockedFragmentIds: [] };
47166
+ }
47129
47167
  if (promoteSecondaryStoryTextBoxes && node.isTextBox && node.text) {
47130
47168
  return appendTextBoxSegment(
47131
47169
  paragraph,
@@ -47185,7 +47223,7 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
47185
47223
  const anchor = surfaceAnchorFromGeometry(node.anchor);
47186
47224
  const txbxTextSegment = c.isTextBox ? extractTxbxFirstTextSegment(c.txbxBlocks) : void 0;
47187
47225
  const txbxText = txbxTextSegment?.text ?? (c.isTextBox ? c.text : void 0);
47188
- const txbxBody = c.isTextBox ? surfaceTextBoxBodyFromShape(c, node.sourceRef) : void 0;
47226
+ const txbxBody = c.isTextBox ? surfaceTextBoxBodyFromShape(c, node.sourceRef, inlinePath, editableTargetsByBlockPath) : void 0;
47189
47227
  const surfaceFill = c.fill;
47190
47228
  paragraph.segments.push({
47191
47229
  segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
@@ -47362,13 +47400,16 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
47362
47400
  const refHyperlinkHref = (node.fieldFamily === "REF" || node.fieldFamily === "PAGEREF" || node.fieldFamily === "NOTEREF") && node.switches?.hyperlink === true && node.fieldTarget ? `#${node.fieldTarget}` : void 0;
47363
47401
  let cursor = start;
47364
47402
  const lockedIds = [];
47365
- for (const child of node.children) {
47403
+ for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {
47404
+ const child = node.children[childIndex];
47366
47405
  const result = appendInlineSegments(
47367
47406
  paragraph,
47368
47407
  child,
47369
47408
  document2,
47370
47409
  cursor,
47371
47410
  promoteSecondaryStoryTextBoxes,
47411
+ inlinePath !== void 0 ? `${inlinePath}/child[${childIndex}]` : void 0,
47412
+ editableTargetsByBlockPath,
47372
47413
  refHyperlinkHref ?? hyperlinkHref,
47373
47414
  cullBuild,
47374
47415
  themeResolver,
@@ -47615,7 +47656,7 @@ function extractTxbxFirstTextSegment(blocks) {
47615
47656
  }
47616
47657
  return void 0;
47617
47658
  }
47618
- function surfaceTextBoxBodyFromShape(shape, sourceRef) {
47659
+ function surfaceTextBoxBodyFromShape(shape, sourceRef, inlinePath, editableTargetsByBlockPath = EMPTY_EDITABLE_TARGETS_BY_BLOCK_PATH) {
47619
47660
  if (!shape.isTextBox && shape.txbxContentXml === void 0 && shape.txbxBlocks === void 0) {
47620
47661
  return void 0;
47621
47662
  }
@@ -47641,9 +47682,12 @@ function surfaceTextBoxBodyFromShape(shape, sourceRef) {
47641
47682
  (run, inlineIndex) => surfaceTextBoxRunFromLegacyRun(run, inlineIndex)
47642
47683
  ) ?? [];
47643
47684
  const text = runs.map((run) => run.text ?? "").join("");
47685
+ const blockPath = inlinePath !== void 0 ? `${inlinePath}/txbx/block[${blockIndex}]` : void 0;
47686
+ const editableTarget = blockPath !== void 0 ? editableTargetsByBlockPath.get(blockPath) : void 0;
47644
47687
  return [{
47645
47688
  ...block.sourceRef !== void 0 ? { sourceRef: block.sourceRef } : {},
47646
47689
  blockIndex,
47690
+ ...editableTarget !== void 0 ? { editableTarget } : {},
47647
47691
  text,
47648
47692
  textLength: Array.from(text).length,
47649
47693
  ...block.borders !== void 0 ? { borders: block.borders } : {},
@@ -50954,6 +50998,7 @@ function buildPageGraph(inputOrPages, sectionsArg, storiesArg) {
50954
50998
  regions,
50955
50999
  divergences: frameDivergences,
50956
51000
  subParts: input.subParts,
51001
+ anchors: input.anchors,
50957
51002
  pageFieldCounts
50958
51003
  });
50959
51004
  const divergences = builtFrame.divergences;
@@ -51120,6 +51165,7 @@ function buildPageFrame(input) {
51120
51165
  stories: input.stories,
51121
51166
  regions,
51122
51167
  subParts: input.subParts,
51168
+ anchors: input.anchors,
51123
51169
  pageFieldCounts: input.pageFieldCounts
51124
51170
  });
51125
51171
  const divergences = [...input.divergences, ...pageLocalStoryResult.divergences];
@@ -51157,6 +51203,7 @@ function buildPageLocalStoryInstances(input) {
51157
51203
  input.stories.header,
51158
51204
  input.regions.header,
51159
51205
  findHeaderFooterPart(input.subParts?.headers, input.stories.header),
51206
+ input.anchors,
51160
51207
  input.pageFieldCounts
51161
51208
  );
51162
51209
  instances.push(built.instance);
@@ -51173,6 +51220,7 @@ function buildPageLocalStoryInstances(input) {
51173
51220
  input.stories.footer,
51174
51221
  input.regions.footer,
51175
51222
  findHeaderFooterPart(input.subParts?.footers, input.stories.footer),
51223
+ input.anchors,
51176
51224
  input.pageFieldCounts
51177
51225
  );
51178
51226
  instances.push(built.instance);
@@ -51180,7 +51228,7 @@ function buildPageLocalStoryInstances(input) {
51180
51228
  }
51181
51229
  return { instances, divergences };
51182
51230
  }
51183
- function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, pageFieldCounts) {
51231
+ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, displayPageNumber, layout, target, region, source, anchors, pageFieldCounts) {
51184
51232
  const measuredFrameHeightTwips = region?.heightTwips ?? 0;
51185
51233
  const sectionPart = target.sectionIndex === void 0 ? "section-unknown" : `section-${target.sectionIndex}`;
51186
51234
  const instanceId = `${frameId}:${target.kind}:${target.variant}:${target.relationshipId}`;
@@ -51201,7 +51249,9 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
51201
51249
  kind: target.kind,
51202
51250
  variant: target.variant,
51203
51251
  relationshipId: target.relationshipId,
51204
- region
51252
+ region,
51253
+ storyBasePath: `${target.kind}:${source.partPath ?? `word/${target.kind}${target.relationshipId}.xml`}`,
51254
+ anchorsByInlinePath: buildAnchorsByInlinePath(anchors)
51205
51255
  }) : { objects: [], divergences: [] };
51206
51256
  const signature = buildPageLocalStorySignature({
51207
51257
  kind: target.kind,
@@ -51255,6 +51305,23 @@ function buildPageLocalStorySignature(input) {
51255
51305
  object.anchorRectTwips?.yTwips ?? "",
51256
51306
  object.anchorRectTwips?.widthTwips ?? "",
51257
51307
  object.anchorRectTwips?.heightTwips ?? "",
51308
+ object.textBoxBody?.bodyKey ?? "",
51309
+ object.textBoxBody?.status ?? "",
51310
+ object.textBoxBody?.unavailableReason ?? "",
51311
+ object.textBoxBody?.contentRectTwips?.xTwips ?? "",
51312
+ object.textBoxBody?.contentRectTwips?.yTwips ?? "",
51313
+ object.textBoxBody?.contentRectTwips?.widthTwips ?? "",
51314
+ object.textBoxBody?.contentRectTwips?.heightTwips ?? "",
51315
+ object.textBoxBody?.paragraphs.map(
51316
+ (paragraph) => [
51317
+ paragraph.paragraphKey,
51318
+ paragraph.rectTwips?.xTwips ?? "",
51319
+ paragraph.rectTwips?.yTwips ?? "",
51320
+ paragraph.rectTwips?.widthTwips ?? "",
51321
+ paragraph.rectTwips?.heightTwips ?? "",
51322
+ paragraph.unavailableReason ?? ""
51323
+ ].join("/")
51324
+ ).join(",") ?? "",
51258
51325
  object.relationshipIds?.join(",") ?? "",
51259
51326
  object.mediaIds?.join(",") ?? "",
51260
51327
  object.wrapMode ?? "",
@@ -51399,6 +51466,10 @@ function truncatePageLocalStoryPreview(text) {
51399
51466
  if (text.length <= MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS) return text;
51400
51467
  return `${text.slice(0, MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
51401
51468
  }
51469
+ function buildAnchorsByInlinePath(anchors) {
51470
+ if (!anchors || anchors.length === 0) return void 0;
51471
+ return new Map(anchors.map((anchor) => [anchor.inlinePath, anchor]));
51472
+ }
51402
51473
  function collectStoryAnchoredObjects(blocks, context) {
51403
51474
  const objects = [];
51404
51475
  const divergences = [];
@@ -51442,26 +51513,45 @@ function collectStoryAnchoredObjects(blocks, context) {
51442
51513
  });
51443
51514
  ordinal += 1;
51444
51515
  };
51445
- const visitBlock = (block) => {
51516
+ const visitBlocks = (blocksToVisit, basePath) => {
51517
+ for (let blockIndex = 0; blockIndex < blocksToVisit.length; blockIndex += 1) {
51518
+ const block = blocksToVisit[blockIndex];
51519
+ if (!block) continue;
51520
+ visitBlock(block, `${basePath}/block[${blockIndex}]`);
51521
+ }
51522
+ };
51523
+ const visitBlock = (block, blockPath) => {
51446
51524
  switch (block.type) {
51447
51525
  case "paragraph":
51448
- for (const child of block.children) visitInline(child);
51526
+ visitInlines(block.children, blockPath, `${blockPath}/inline`);
51449
51527
  break;
51450
51528
  case "table":
51451
- for (const row of block.rows) {
51452
- for (const cell of row.cells) {
51453
- for (const child of cell.children) visitBlock(child);
51529
+ for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
51530
+ const row = block.rows[rowIndex];
51531
+ if (!row) continue;
51532
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
51533
+ const cell = row.cells[cellIndex];
51534
+ if (!cell) continue;
51535
+ visitBlocks(cell.children, `${blockPath}/row[${rowIndex}]/cell[${cellIndex}]`);
51454
51536
  }
51455
51537
  }
51456
51538
  break;
51457
51539
  case "sdt":
51458
- for (const child of block.children) visitBlock(child);
51540
+ case "custom_xml":
51541
+ visitBlocks(block.children, blockPath);
51459
51542
  break;
51460
51543
  default:
51461
51544
  break;
51462
51545
  }
51463
51546
  };
51464
- const visitInline = (inline) => {
51547
+ const visitInlines = (inlines, blockPath, basePath) => {
51548
+ for (let inlineIndex = 0; inlineIndex < inlines.length; inlineIndex += 1) {
51549
+ const inline = inlines[inlineIndex];
51550
+ if (!inline) continue;
51551
+ visitInline(inline, blockPath, `${basePath}[${inlineIndex}]`);
51552
+ }
51553
+ };
51554
+ const visitInline = (inline, blockPath, inlinePath) => {
51465
51555
  switch (inline.type) {
51466
51556
  case "image": {
51467
51557
  pushObject({
@@ -51482,17 +51572,27 @@ function collectStoryAnchoredObjects(blocks, context) {
51482
51572
  inline.anchor.extent.widthEmu,
51483
51573
  inline.anchor.extent.heightEmu
51484
51574
  );
51575
+ const anchorRectTwips = resolveObjectAnchorRectTwips(
51576
+ context.region,
51577
+ extentTwips,
51578
+ inline.anchor.positionH,
51579
+ inline.anchor.positionV
51580
+ );
51581
+ const canonicalAnchor = context.anchorsByInlinePath?.get(inlinePath);
51582
+ const textBoxBody = buildDrawingFrameTextBoxBodyFacts(
51583
+ inline,
51584
+ canonicalAnchor,
51585
+ inlinePath,
51586
+ display,
51587
+ anchorRectTwips
51588
+ );
51485
51589
  pushObject({
51486
51590
  objectId: getDrawingFrameObjectId(inline, context.storyKey, ordinal),
51487
51591
  sourceType: "drawing-frame",
51488
51592
  display,
51489
51593
  extentTwips,
51490
- anchorRectTwips: resolveObjectAnchorRectTwips(
51491
- context.region,
51492
- extentTwips,
51493
- inline.anchor.positionH,
51494
- inline.anchor.positionV
51495
- ),
51594
+ anchorRectTwips,
51595
+ ...textBoxBody ? { textBoxBody } : {},
51496
51596
  ...relationshipIds.length > 0 ? { relationshipIds } : {},
51497
51597
  ...inline.content.type === "picture" && inline.content.mediaId ? { mediaIds: [inline.content.mediaId] } : {},
51498
51598
  preserveOnly: Boolean(preserveHint),
@@ -51500,7 +51600,7 @@ function collectStoryAnchoredObjects(blocks, context) {
51500
51600
  wrapMode: inline.anchor.wrapMode
51501
51601
  });
51502
51602
  if (inline.content.type === "shape") {
51503
- for (const child of inline.content.txbxBlocks ?? []) visitBlock(child);
51603
+ visitBlocks(inline.content.txbxBlocks ?? [], `${inlinePath}/txbx`);
51504
51604
  }
51505
51605
  break;
51506
51606
  }
@@ -51527,10 +51627,11 @@ function collectStoryAnchoredObjects(blocks, context) {
51527
51627
  } : {},
51528
51628
  ...preserveHint?.relationshipIds ? { relationshipIds: [...preserveHint.relationshipIds] } : {},
51529
51629
  preserveOnly: Boolean(preserveHint),
51530
- ...preserveHint ? { preserveHint } : {}
51630
+ ...preserveHint ? { preserveHint } : {},
51631
+ ...inline.type === "vml_shape" && inline.text ? { textBoxBody: buildUnsupportedVmlTextBoxFacts(inline, inlinePath) } : {}
51531
51632
  });
51532
51633
  if (inline.type === "shape") {
51533
- for (const child of inline.txbxBlocks ?? []) visitBlock(child);
51634
+ visitBlocks(inline.txbxBlocks ?? [], `${inlinePath}/txbx`);
51534
51635
  }
51535
51636
  break;
51536
51637
  }
@@ -51552,16 +51653,16 @@ function collectStoryAnchoredObjects(blocks, context) {
51552
51653
  });
51553
51654
  break;
51554
51655
  case "field":
51555
- for (const child of inline.children) visitInline(child);
51656
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
51556
51657
  break;
51557
51658
  case "hyperlink":
51558
- for (const child of inline.children) visitInline(child);
51659
+ visitInlines(inline.children, blockPath, `${inlinePath}/child`);
51559
51660
  break;
51560
51661
  default:
51561
51662
  break;
51562
51663
  }
51563
51664
  };
51564
- for (const block of blocks) visitBlock(block);
51665
+ visitBlocks(blocks, context.storyBasePath);
51565
51666
  return { objects, divergences };
51566
51667
  }
51567
51668
  function getDrawingFramePreserveHint(inline) {
@@ -51569,6 +51670,170 @@ function getDrawingFramePreserveHint(inline) {
51569
51670
  if (content.type === "picture") return void 0;
51570
51671
  return content.preserveOnlyObject;
51571
51672
  }
51673
+ function buildDrawingFrameTextBoxBodyFacts(inline, canonicalAnchor, inlinePath, display, anchorRectTwips) {
51674
+ if (inline.content.type !== "shape") return void 0;
51675
+ const content = inline.content;
51676
+ const canonicalBody = canonicalAnchor?.textBoxBody;
51677
+ const hasTextBoxContent = Boolean(
51678
+ canonicalBody || content.isTextBox || content.textBoxBody || content.txbxBlocks?.length
51679
+ );
51680
+ if (!hasTextBoxContent) return void 0;
51681
+ if (!canonicalBody) {
51682
+ return unavailableTextBoxBodyFacts(
51683
+ `${canonicalAnchor?.objectKey ?? inlinePath}:txbx`,
51684
+ "unmodeled-txbx-blocks",
51685
+ content.textBoxBody,
51686
+ content.txbxBlocks?.length ?? 0,
51687
+ countParagraphBlocks(content.txbxBlocks ?? []),
51688
+ 0
51689
+ );
51690
+ }
51691
+ if (display !== "floating") {
51692
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "inline-textbox");
51693
+ }
51694
+ if (!anchorRectTwips) {
51695
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-anchor-rect");
51696
+ }
51697
+ if (canonicalBody.status !== "modeled") {
51698
+ return unavailableTextBoxBodyFactsFromCanonical(
51699
+ canonicalBody,
51700
+ normalizeTextBoxBodyUnavailableReason(canonicalBody.unavailableReason)
51701
+ );
51702
+ }
51703
+ const bodyInsetsTwips = textBoxInsetsTwips(canonicalBody.bodyProperties);
51704
+ if (!bodyInsetsTwips) {
51705
+ return unavailableTextBoxBodyFactsFromCanonical(canonicalBody, "missing-body-insets");
51706
+ }
51707
+ const contentRectTwips = rect2(
51708
+ anchorRectTwips.xTwips + bodyInsetsTwips.leftTwips,
51709
+ anchorRectTwips.yTwips + bodyInsetsTwips.topTwips,
51710
+ Math.max(0, anchorRectTwips.widthTwips - bodyInsetsTwips.leftTwips - bodyInsetsTwips.rightTwips),
51711
+ Math.max(0, anchorRectTwips.heightTwips - bodyInsetsTwips.topTwips - bodyInsetsTwips.bottomTwips)
51712
+ );
51713
+ return {
51714
+ bodyKey: canonicalBody.bodyKey,
51715
+ status: "modeled",
51716
+ ...canonicalBody.bodyProperties ? { bodyProperties: { ...canonicalBody.bodyProperties } } : {},
51717
+ bodyInsetsTwips,
51718
+ contentRectTwips,
51719
+ blockCount: canonicalBody.blockCount,
51720
+ paragraphCount: canonicalBody.paragraphCount,
51721
+ unsupportedBlockCount: canonicalBody.unsupportedBlockCount,
51722
+ paragraphs: buildTextBoxParagraphFacts(canonicalBody, contentRectTwips)
51723
+ };
51724
+ }
51725
+ function unavailableTextBoxBodyFactsFromCanonical(body, reason) {
51726
+ return {
51727
+ bodyKey: body.bodyKey,
51728
+ status: body.status === "preserve-only" ? "preserve-only" : "unavailable",
51729
+ unavailableReason: reason,
51730
+ ...body.bodyProperties ? { bodyProperties: { ...body.bodyProperties } } : {},
51731
+ blockCount: body.blockCount,
51732
+ paragraphCount: body.paragraphCount,
51733
+ unsupportedBlockCount: body.unsupportedBlockCount,
51734
+ paragraphs: body.paragraphs.map((paragraph) => ({
51735
+ paragraphKey: paragraph.paragraphKey,
51736
+ blockPath: paragraph.blockPath,
51737
+ blockIndex: paragraph.blockIndex,
51738
+ unavailableReason: reason,
51739
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
51740
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
51741
+ textLength: paragraph.textLength,
51742
+ runCount: paragraph.runCount
51743
+ }))
51744
+ };
51745
+ }
51746
+ function unavailableTextBoxBodyFacts(bodyKey, reason, bodyProperties, blockCount, paragraphCount, unsupportedBlockCount) {
51747
+ return {
51748
+ bodyKey,
51749
+ status: "unavailable",
51750
+ unavailableReason: reason,
51751
+ ...bodyProperties ? { bodyProperties: { ...bodyProperties } } : {},
51752
+ blockCount,
51753
+ paragraphCount,
51754
+ unsupportedBlockCount,
51755
+ paragraphs: []
51756
+ };
51757
+ }
51758
+ function buildUnsupportedVmlTextBoxFacts(inline, inlinePath) {
51759
+ const hasText = Boolean(inline.text?.length);
51760
+ return {
51761
+ bodyKey: `${inline.preserveOnlyObject?.sourceId ?? inlinePath}:vml-textbox`,
51762
+ status: "unavailable",
51763
+ unavailableReason: "unsupported-vml-textbox",
51764
+ blockCount: hasText ? 1 : 0,
51765
+ paragraphCount: hasText ? 1 : 0,
51766
+ unsupportedBlockCount: hasText ? 1 : 0,
51767
+ paragraphs: []
51768
+ };
51769
+ }
51770
+ function buildTextBoxParagraphFacts(body, contentRectTwips) {
51771
+ const paragraphCount = body.paragraphs.length;
51772
+ if (paragraphCount === 0) return [];
51773
+ const baseHeight = Math.floor(contentRectTwips.heightTwips / paragraphCount);
51774
+ return body.paragraphs.map((paragraph, index) => {
51775
+ const yTwips = contentRectTwips.yTwips + baseHeight * index;
51776
+ const heightTwips = index === paragraphCount - 1 ? Math.max(0, contentRectTwips.yTwips + contentRectTwips.heightTwips - yTwips) : Math.max(0, baseHeight);
51777
+ return {
51778
+ paragraphKey: paragraph.paragraphKey,
51779
+ blockPath: paragraph.blockPath,
51780
+ blockIndex: paragraph.blockIndex,
51781
+ rectTwips: rect2(
51782
+ contentRectTwips.xTwips,
51783
+ yTwips,
51784
+ contentRectTwips.widthTwips,
51785
+ heightTwips
51786
+ ),
51787
+ ...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
51788
+ ...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
51789
+ textLength: paragraph.textLength,
51790
+ runCount: paragraph.runCount
51791
+ };
51792
+ });
51793
+ }
51794
+ function textBoxInsetsTwips(bodyProperties) {
51795
+ if (!bodyProperties || bodyProperties.insetLeftEmu === void 0 || bodyProperties.insetTopEmu === void 0 || bodyProperties.insetRightEmu === void 0 || bodyProperties.insetBottomEmu === void 0) {
51796
+ return void 0;
51797
+ }
51798
+ return {
51799
+ leftTwips: Math.max(0, Math.round(bodyProperties.insetLeftEmu / EMUS_PER_TWIP)),
51800
+ topTwips: Math.max(0, Math.round(bodyProperties.insetTopEmu / EMUS_PER_TWIP)),
51801
+ rightTwips: Math.max(0, Math.round(bodyProperties.insetRightEmu / EMUS_PER_TWIP)),
51802
+ bottomTwips: Math.max(0, Math.round(bodyProperties.insetBottomEmu / EMUS_PER_TWIP))
51803
+ };
51804
+ }
51805
+ function normalizeTextBoxBodyUnavailableReason(reason) {
51806
+ switch (reason) {
51807
+ case "txbx-blocks-unavailable":
51808
+ case "empty-body":
51809
+ case "unsupported-content":
51810
+ return reason;
51811
+ default:
51812
+ return "unmodeled-txbx-blocks";
51813
+ }
51814
+ }
51815
+ function countParagraphBlocks(blocks) {
51816
+ let count = 0;
51817
+ const visit = (block) => {
51818
+ if (block.type === "paragraph") {
51819
+ count += 1;
51820
+ return;
51821
+ }
51822
+ if (block.type === "table") {
51823
+ for (const row of block.rows) {
51824
+ for (const cell of row.cells) {
51825
+ for (const child of cell.children) visit(child);
51826
+ }
51827
+ }
51828
+ return;
51829
+ }
51830
+ if (block.type === "sdt" || block.type === "custom_xml") {
51831
+ for (const child of block.children) visit(child);
51832
+ }
51833
+ };
51834
+ for (const block of blocks) visit(block);
51835
+ return count;
51836
+ }
51572
51837
  function collectDrawingRelationshipIds(inline) {
51573
51838
  const content = inline.content;
51574
51839
  if (content.type === "picture") return [content.blipRef];
@@ -51897,12 +52162,34 @@ function freezePageFrame(frame) {
51897
52162
  for (const story of frame.pageLocalStories) {
51898
52163
  Object.freeze(story.resolvedFields);
51899
52164
  Object.freeze(story.previewParts);
52165
+ for (const object of story.anchoredObjects) {
52166
+ freezeStoryAnchoredObject(object);
52167
+ }
51900
52168
  Object.freeze(story.anchoredObjects);
51901
52169
  Object.freeze(story);
51902
52170
  }
51903
52171
  Object.freeze(frame.pageLocalStories);
51904
52172
  Object.freeze(frame);
51905
52173
  }
52174
+ function freezeStoryAnchoredObject(object) {
52175
+ if (object.extentTwips) Object.freeze(object.extentTwips);
52176
+ if (object.anchorRectTwips) Object.freeze(object.anchorRectTwips);
52177
+ if (object.relationshipIds) Object.freeze(object.relationshipIds);
52178
+ if (object.mediaIds) Object.freeze(object.mediaIds);
52179
+ if (object.textBoxBody) {
52180
+ if (object.textBoxBody.bodyProperties) Object.freeze(object.textBoxBody.bodyProperties);
52181
+ if (object.textBoxBody.bodyInsetsTwips) Object.freeze(object.textBoxBody.bodyInsetsTwips);
52182
+ if (object.textBoxBody.contentRectTwips) Object.freeze(object.textBoxBody.contentRectTwips);
52183
+ for (const paragraph of object.textBoxBody.paragraphs) {
52184
+ if (paragraph.rectTwips) Object.freeze(paragraph.rectTwips);
52185
+ Object.freeze(paragraph);
52186
+ }
52187
+ Object.freeze(object.textBoxBody.paragraphs);
52188
+ Object.freeze(object.textBoxBody);
52189
+ }
52190
+ Object.freeze(object.divergenceIds);
52191
+ Object.freeze(object);
52192
+ }
51906
52193
  function normalizePageLocalStoryFieldsForPages(pages) {
51907
52194
  const pageFieldCounts = buildPageFieldCounts(pages);
51908
52195
  return pages.map((page) => {
@@ -53534,7 +53821,8 @@ function createLayoutEngine(options = {}) {
53534
53821
  fragmentsByPageIndex,
53535
53822
  lineBoxesByPageIndex,
53536
53823
  noteAllocationsByPageIndex: pageStack.noteAllocationsByPageIndex,
53537
- subParts: document2.subParts
53824
+ subParts: document2.subParts,
53825
+ anchors: layoutInputs.anchors
53538
53826
  });
53539
53827
  const graph = applyViewportWindowMaterialization(
53540
53828
  measuredGraph,
@@ -53669,7 +53957,8 @@ function createLayoutEngine(options = {}) {
53669
53957
  fragmentsByPageIndex: freshFragmentsByPageIndex,
53670
53958
  lineBoxesByPageIndex: freshLineBoxesByPageIndex,
53671
53959
  noteAllocationsByPageIndex: freshResult.noteAllocationsByPageIndex,
53672
- subParts: document2.subParts
53960
+ subParts: document2.subParts,
53961
+ anchors: layoutInputs.anchors
53673
53962
  });
53674
53963
  const freshNodes = freshGraph.pages;
53675
53964
  const splicedGraph = spliceGraph(priorGraph, freshNodes, firstDirty, convergedTailStart);
@@ -56129,7 +56418,7 @@ function resolveEditableTextTarget(input) {
56129
56418
  "Editable target ref does not belong to the active story."
56130
56419
  );
56131
56420
  }
56132
- const currentTargets = collectEditableTargetRefs(input.document);
56421
+ const currentTargets = collectEditableTargetRefs(input.document, input.editableTargetCache);
56133
56422
  const current = currentTargets.find(
56134
56423
  (candidate) => candidate.targetKey === input.target.targetKey
56135
56424
  );
@@ -56230,7 +56519,13 @@ function reject(code, message) {
56230
56519
  };
56231
56520
  }
56232
56521
  function sameResolvedTarget2(left, right) {
56233
- 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);
56522
+ 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);
56523
+ }
56524
+ function sameTextTargetStaleCheck(left, right) {
56525
+ if (left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength) {
56526
+ return true;
56527
+ }
56528
+ return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
56234
56529
  }
56235
56530
  function locateTargetRange(document2, surface, target) {
56236
56531
  if (target.kind === "hyperlink-text") {
@@ -56549,7 +56844,7 @@ function resolveEditableTableStructureTarget(input) {
56549
56844
  `Editable target is not editable${input.target.posture.blockers.length > 0 ? `: ${input.target.posture.blockers.join(", ")}` : "."}`
56550
56845
  );
56551
56846
  }
56552
- const current = collectEditableTargetRefs(input.document).find(
56847
+ const current = collectEditableTargetRefs(input.document, input.editableTargetCache).find(
56553
56848
  (candidate) => candidate.targetKey === input.target?.targetKey
56554
56849
  );
56555
56850
  if (!current) {