@beyondwork/docx-react-component 1.0.120 → 1.0.122

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
@@ -3,17 +3,17 @@ import {
3
3
  PAGE_STACK_GAP_PX,
4
4
  defaultChromeReservations,
5
5
  resolveDefaultZoom
6
- } from "./chunk-TMQGWF7R.js";
6
+ } from "./chunk-G3B2OBCZ.js";
7
7
  import {
8
8
  storyTargetKey
9
- } from "./chunk-AUQDC5BD.js";
9
+ } from "./chunk-3TUQCHYT.js";
10
10
  import {
11
11
  MAIN_STORY_KEY,
12
12
  collectCanonicalLayoutInputs,
13
13
  collectStoryBlockContexts,
14
14
  createHeaderFooterStoryKey,
15
15
  createNoteStoryKey
16
- } from "./chunk-AQA7OZ2R.js";
16
+ } from "./chunk-TFSXOIAI.js";
17
17
  import {
18
18
  MAIN_STORY_TARGET
19
19
  } from "./chunk-M2HUK3KF.js";
@@ -590,23 +590,20 @@ function buildBodyRegion(page, pageTopPx, zoom, activeStory, facet) {
590
590
  if (fragment.regionKind !== "body") continue;
591
591
  const fragmentHeightTwips = fragment.heightTwips > 0 ? fragment.heightTwips : totalFragmentHeight === 0 ? bodyHeightTwips / Math.max(1, fragments.length) : 0;
592
592
  const blockHeightPx = fragmentHeightTwips * zoom.pxPerTwip;
593
- const blockFrame = {
593
+ const fallbackBlockFrame = {
594
594
  leftPx: regionFrame.leftPx,
595
595
  topPx: blockY,
596
596
  widthPx: regionFrame.widthPx,
597
597
  heightPx: blockHeightPx
598
598
  };
599
599
  const blockLines = bodyLineBoxes.filter((box) => box.fragmentId === fragment.fragmentId).map((box) => {
600
- const lineTopPx = pageTopPx + (bodyTopTwips + box.baselineTwips) * zoom.pxPerTwip;
601
- const lineFrame = {
602
- leftPx: regionFrame.leftPx,
603
- topPx: lineTopPx,
604
- widthPx: Math.min(
605
- regionFrame.widthPx,
606
- box.widthTwips * zoom.pxPerTwip
607
- ),
608
- heightPx: box.heightTwips * zoom.pxPerTwip
609
- };
600
+ const lineFrame = lineFrameFromPublicBox(
601
+ box,
602
+ regionFrame,
603
+ pageTopPx,
604
+ bodyTopTwips,
605
+ zoom
606
+ );
610
607
  const anchors = [
611
608
  {
612
609
  runtimeOffset: fragment.from,
@@ -622,6 +619,11 @@ function buildBodyRegion(page, pageTopPx, zoom, activeStory, facet) {
622
619
  };
623
620
  });
624
621
  const kind = classifyBlockKind(fragment.blockId);
622
+ const blockFrame = blockFrameFromLineFacts(
623
+ fallbackBlockFrame,
624
+ kind,
625
+ blockLines
626
+ );
625
627
  const tablePlan = kind === "table" ? facet.getTableRenderPlan(fragment.blockId, page.pageIndex) : void 0;
626
628
  blocks.push({
627
629
  fragment,
@@ -631,7 +633,7 @@ function buildBodyRegion(page, pageTopPx, zoom, activeStory, facet) {
631
633
  blockDecorations: [],
632
634
  ...tablePlan !== void 0 ? { tablePlan } : {}
633
635
  });
634
- blockY += blockHeightPx;
636
+ blockY = Math.max(blockY + blockHeightPx, blockFrame.topPx + blockFrame.heightPx);
635
637
  }
636
638
  return {
637
639
  storyTarget: activeStory,
@@ -640,6 +642,56 @@ function buildBodyRegion(page, pageTopPx, zoom, activeStory, facet) {
640
642
  blocks
641
643
  };
642
644
  }
645
+ function lineFrameFromPublicBox(box, regionFrame, pageTopPx, bodyTopTwips, zoom) {
646
+ if (box.rectTwips) {
647
+ return projectPageTwipsRectToFrame(box.rectTwips, pageTopPx, zoom);
648
+ }
649
+ const lineTopPx = pageTopPx + (bodyTopTwips + box.baselineTwips) * zoom.pxPerTwip;
650
+ return {
651
+ leftPx: regionFrame.leftPx,
652
+ topPx: lineTopPx,
653
+ widthPx: Math.min(
654
+ regionFrame.widthPx,
655
+ box.widthTwips * zoom.pxPerTwip
656
+ ),
657
+ heightPx: box.heightTwips * zoom.pxPerTwip
658
+ };
659
+ }
660
+ function projectPageTwipsRectToFrame(rect, pageTopPx, zoom) {
661
+ return {
662
+ leftPx: rect.xTwips * zoom.pxPerTwip,
663
+ topPx: pageTopPx + rect.yTwips * zoom.pxPerTwip,
664
+ widthPx: rect.widthTwips * zoom.pxPerTwip,
665
+ heightPx: rect.heightTwips * zoom.pxPerTwip
666
+ };
667
+ }
668
+ function blockFrameFromLineFacts(fallback, kind, lines) {
669
+ const union = unionRenderLineFrames(lines);
670
+ if (!union) return fallback;
671
+ if (kind === "paragraph") return union;
672
+ if (fallback.widthPx <= 0 || fallback.heightPx <= 0) return union;
673
+ return fallback;
674
+ }
675
+ function unionRenderLineFrames(lines) {
676
+ let left = Number.POSITIVE_INFINITY;
677
+ let top = Number.POSITIVE_INFINITY;
678
+ let right = Number.NEGATIVE_INFINITY;
679
+ let bottom = Number.NEGATIVE_INFINITY;
680
+ for (const line of lines) {
681
+ if (line.frame.widthPx <= 0 || line.frame.heightPx <= 0) continue;
682
+ left = Math.min(left, line.frame.leftPx);
683
+ top = Math.min(top, line.frame.topPx);
684
+ right = Math.max(right, line.frame.leftPx + line.frame.widthPx);
685
+ bottom = Math.max(bottom, line.frame.topPx + line.frame.heightPx);
686
+ }
687
+ if (!Number.isFinite(left) || !Number.isFinite(top)) return null;
688
+ return {
689
+ leftPx: left,
690
+ topPx: top,
691
+ widthPx: Math.max(0, right - left),
692
+ heightPx: Math.max(0, bottom - top)
693
+ };
694
+ }
643
695
  function buildHeaderFooterRegion(page, pageTopPx, zoom, kind, storyTarget, facet) {
644
696
  const layout = page.layout;
645
697
  const fallbackWidthTwips = layout.pageWidth - layout.marginLeft - layout.marginRight;
@@ -1369,6 +1421,7 @@ function projectGeometryIndexFromFrame(frame, options) {
1369
1421
  const replacementEnvelopes = [];
1370
1422
  const objectHandleEntries = /* @__PURE__ */ new Map();
1371
1423
  const projectedBlocksByStory = /* @__PURE__ */ new Map();
1424
+ const projectedCommandTargetsByKey = /* @__PURE__ */ new Map();
1372
1425
  const precision = createPrecisionCounts();
1373
1426
  const pageMaterialization = createPageMaterializationCounts();
1374
1427
  const pageFrameCompleteness = createPageFrameCompletenessCounts();
@@ -1522,6 +1575,7 @@ function projectGeometryIndexFromFrame(frame, options) {
1522
1575
  storyKey: storyKey2,
1523
1576
  entries: semanticEntries,
1524
1577
  projectedBlocksByStory,
1578
+ projectedCommandTargetsByKey,
1525
1579
  precision,
1526
1580
  frameCompleteness: pageMetadata.frameCompleteness,
1527
1581
  layoutDivergenceIds: pageMetadata.layoutDivergenceIds,
@@ -1573,7 +1627,9 @@ function projectGeometryIndexFromFrame(frame, options) {
1573
1627
  });
1574
1628
  editableTargetCount = appendEditableTargetSemanticEntries({
1575
1629
  identities,
1630
+ unavailableAnchor: resolveEditableTargetUnavailableAnchor(frame, pages),
1576
1631
  projectedBlocksByStory,
1632
+ projectedCommandTargetsByKey,
1577
1633
  entries: semanticEntries,
1578
1634
  precision
1579
1635
  });
@@ -1789,6 +1845,7 @@ function appendBlockSemanticEntries(input) {
1789
1845
  storyKey: storyKey2,
1790
1846
  entries,
1791
1847
  projectedBlocksByStory,
1848
+ projectedCommandTargetsByKey,
1792
1849
  precision,
1793
1850
  frameCompleteness,
1794
1851
  layoutDivergenceIds,
@@ -1816,6 +1873,7 @@ function appendBlockSemanticEntries(input) {
1816
1873
  block,
1817
1874
  sourceIdentity: sliceIdentity,
1818
1875
  entries,
1876
+ projectedCommandTargetsByKey,
1819
1877
  precision,
1820
1878
  frameCompleteness,
1821
1879
  layoutDivergenceIds,
@@ -1996,6 +2054,7 @@ function appendFragmentLayoutObjectSemanticEntries(input) {
1996
2054
  block,
1997
2055
  sourceIdentity,
1998
2056
  entries,
2057
+ projectedCommandTargetsByKey,
1999
2058
  precision,
2000
2059
  frameCompleteness,
2001
2060
  layoutDivergenceIds,
@@ -2003,25 +2062,80 @@ function appendFragmentLayoutObjectSemanticEntries(input) {
2003
2062
  } = input;
2004
2063
  const layoutObject = block.fragment.layoutObject;
2005
2064
  if (!layoutObject) return;
2065
+ recordFragmentCommandTargetFacts({
2066
+ base,
2067
+ block,
2068
+ layoutObject,
2069
+ sourceIdentity,
2070
+ projectedCommandTargetsByKey
2071
+ });
2006
2072
  if (layoutObject.kind === "field-region") {
2007
- entries.push({
2008
- ...base,
2009
- entryId: `semantic:field-region:${base.sliceId}`,
2010
- kind: "field-region",
2011
- layoutObjectId: layoutObject.objectId,
2012
- ...layoutObject.fieldFamilies !== void 0 ? { fieldFamilies: [...layoutObject.fieldFamilies] } : {},
2013
- rect: {
2014
- ...toGeometryRect(block.frame),
2015
- precision: "within-tolerance"
2016
- },
2017
- status: "realized",
2018
- precision: "within-tolerance",
2019
- frameCompleteness,
2020
- ...layoutDivergenceIds.length > 0 ? { layoutDivergenceIds } : {},
2021
- ...layoutDivergenceObjectIds.length > 0 ? { layoutDivergenceObjectIds } : {},
2022
- ...sourceIdentity ? { sourceIdentity } : {}
2023
- });
2024
- recordPrecision(precision, "within-tolerance");
2073
+ const fieldRegions = layoutObject.fieldRegions ?? [];
2074
+ if (fieldRegions.length === 0) {
2075
+ entries.push({
2076
+ ...base,
2077
+ entryId: `semantic:field-region:${base.sliceId}`,
2078
+ kind: "field-region",
2079
+ layoutObjectId: layoutObject.objectId,
2080
+ ...layoutObject.fieldFamilies !== void 0 ? { fieldFamilies: [...layoutObject.fieldFamilies] } : {},
2081
+ rect: {
2082
+ ...toGeometryRect(block.frame),
2083
+ precision: "within-tolerance"
2084
+ },
2085
+ status: "realized",
2086
+ precision: "within-tolerance",
2087
+ frameCompleteness,
2088
+ ...layoutDivergenceIds.length > 0 ? { layoutDivergenceIds } : {},
2089
+ ...layoutDivergenceObjectIds.length > 0 ? { layoutDivergenceObjectIds } : {},
2090
+ ...sourceIdentity ? { sourceIdentity } : {}
2091
+ });
2092
+ recordPrecision(precision, "within-tolerance");
2093
+ }
2094
+ for (const fieldRegion of fieldRegions) {
2095
+ const fieldSourceIdentity = fieldRegionSourceIdentity(
2096
+ fieldRegion,
2097
+ sourceIdentity
2098
+ );
2099
+ entries.push({
2100
+ ...base,
2101
+ entryId: `semantic:field-region:${base.sliceId}:${fieldRegion.fieldRegionId}`,
2102
+ kind: "field-region",
2103
+ layoutObjectId: fieldRegion.fieldRegionId,
2104
+ fieldFamilies: [fieldRegion.fieldFamily],
2105
+ fieldRegionId: fieldRegion.regionId,
2106
+ canonicalFieldId: fieldRegion.canonicalFieldId,
2107
+ fieldRegionKind: fieldRegion.regionKind,
2108
+ rect: {
2109
+ ...toGeometryRect(block.frame),
2110
+ precision: "within-tolerance"
2111
+ },
2112
+ status: "realized",
2113
+ precision: "within-tolerance",
2114
+ frameCompleteness,
2115
+ ...layoutDivergenceIds.length > 0 ? { layoutDivergenceIds } : {},
2116
+ ...layoutDivergenceObjectIds.length > 0 ? { layoutDivergenceObjectIds } : {},
2117
+ sourceIdentity: fieldSourceIdentity
2118
+ });
2119
+ recordProjectedCommandTarget(projectedCommandTargetsByKey, {
2120
+ targetKey: `${fieldRegion.storyKey}:field-region:${fieldRegion.regionId}:refresh`,
2121
+ pageId: base.pageId,
2122
+ pageIndex: base.pageIndex,
2123
+ regionId: base.regionId,
2124
+ regionKind: base.regionKind,
2125
+ sliceId: base.sliceId,
2126
+ blockId: base.blockId,
2127
+ fragmentId: base.fragmentId,
2128
+ blockPath: sourceIdentity?.blockPath,
2129
+ rect: {
2130
+ ...toGeometryRect(block.frame),
2131
+ precision: "within-tolerance"
2132
+ },
2133
+ status: "realized",
2134
+ precision: "within-tolerance",
2135
+ sourceIdentity: fieldSourceIdentity
2136
+ });
2137
+ recordPrecision(precision, "within-tolerance");
2138
+ }
2025
2139
  return;
2026
2140
  }
2027
2141
  if (layoutObject.kind === "numbered-paragraph") {
@@ -2040,6 +2154,92 @@ function appendFragmentLayoutObjectSemanticEntries(input) {
2040
2154
  recordPrecision(precision, markerProjection.precision);
2041
2155
  }
2042
2156
  }
2157
+ function recordFragmentCommandTargetFacts(input) {
2158
+ const {
2159
+ base,
2160
+ block,
2161
+ layoutObject,
2162
+ sourceIdentity,
2163
+ projectedCommandTargetsByKey
2164
+ } = input;
2165
+ for (const hyperlink of layoutObject.hyperlinks ?? []) {
2166
+ const hyperlinkIdentity = hyperlinkSourceIdentity(
2167
+ hyperlink,
2168
+ sourceIdentity
2169
+ );
2170
+ recordProjectedCommandTarget(projectedCommandTargetsByKey, {
2171
+ targetKey: hyperlink.targetKey,
2172
+ pageId: base.pageId,
2173
+ pageIndex: base.pageIndex,
2174
+ regionId: base.regionId,
2175
+ regionKind: base.regionKind,
2176
+ sliceId: base.sliceId,
2177
+ blockId: base.blockId,
2178
+ fragmentId: base.fragmentId,
2179
+ blockPath: sourceIdentity?.blockPath,
2180
+ rect: {
2181
+ ...toGeometryRect(block.frame),
2182
+ precision: "within-tolerance"
2183
+ },
2184
+ status: "realized",
2185
+ precision: "within-tolerance",
2186
+ sourceIdentity: hyperlinkIdentity
2187
+ });
2188
+ }
2189
+ for (const bookmarkRange of layoutObject.bookmarkRanges ?? []) {
2190
+ if (!bookmarkRange.contentRangeTargetKey) continue;
2191
+ const bookmarkIdentity = bookmarkRangeSourceIdentity(
2192
+ bookmarkRange,
2193
+ sourceIdentity
2194
+ );
2195
+ recordProjectedCommandTarget(projectedCommandTargetsByKey, {
2196
+ targetKey: bookmarkRange.contentRangeTargetKey,
2197
+ pageId: base.pageId,
2198
+ pageIndex: base.pageIndex,
2199
+ regionId: base.regionId,
2200
+ regionKind: base.regionKind,
2201
+ sliceId: base.sliceId,
2202
+ blockId: base.blockId,
2203
+ fragmentId: base.fragmentId,
2204
+ blockPath: sourceIdentity?.blockPath,
2205
+ rect: {
2206
+ ...toGeometryRect(block.frame),
2207
+ precision: "within-tolerance"
2208
+ },
2209
+ status: "realized",
2210
+ precision: "within-tolerance",
2211
+ sourceIdentity: bookmarkIdentity
2212
+ });
2213
+ }
2214
+ }
2215
+ function fieldRegionSourceIdentity(fact, fallback) {
2216
+ return {
2217
+ storyKey: fact.storyKey,
2218
+ ...fallback?.blockPath ? { blockPath: fallback.blockPath } : {},
2219
+ ...fact.sourcePath ? { inlinePath: fact.sourcePath } : {},
2220
+ ...fact.sourceRef !== void 0 ? { sourceRef: fact.sourceRef } : {},
2221
+ joinKind: "block-scoped"
2222
+ };
2223
+ }
2224
+ function hyperlinkSourceIdentity(fact, fallback) {
2225
+ return {
2226
+ storyKey: fact.storyKey,
2227
+ ...fallback?.blockPath ? { blockPath: fallback.blockPath } : {},
2228
+ inlinePath: fact.blockPath,
2229
+ ...fact.sourceRef !== void 0 ? { sourceRef: fact.sourceRef } : {},
2230
+ joinKind: "block-scoped"
2231
+ };
2232
+ }
2233
+ function bookmarkRangeSourceIdentity(fact, fallback) {
2234
+ return {
2235
+ storyKey: fact.storyKey,
2236
+ ...fallback?.blockPath ? { blockPath: fallback.blockPath } : {},
2237
+ ...fact.rangeKey !== void 0 ? { scopeKey: fact.rangeKey } : {},
2238
+ scopeId: fact.bookmarkId,
2239
+ ...fact.sourceRef !== void 0 ? { sourceRef: fact.sourceRef } : {},
2240
+ joinKind: "block-scoped"
2241
+ };
2242
+ }
2043
2243
  function resolveNumberingMarkerProjection(block) {
2044
2244
  const metadata = resolveNumberingMarkerProjectionMetadata(block);
2045
2245
  const blockFrame = block.frame;
@@ -2104,7 +2304,7 @@ function countBlockSemanticEntries(block) {
2104
2304
  const counts = createPrecisionCounts();
2105
2305
  const layoutObject = block.fragment.layoutObject;
2106
2306
  if (layoutObject?.kind === "field-region") {
2107
- counts["within-tolerance"] += 1;
2307
+ counts["within-tolerance"] += layoutObject.fieldRegions?.length || 1;
2108
2308
  } else if (layoutObject?.kind === "numbered-paragraph") {
2109
2309
  counts[resolveNumberingMarkerProjectionMetadata(block).precision] += 1;
2110
2310
  }
@@ -2351,6 +2551,14 @@ function createIdentityLookup(options) {
2351
2551
  anchorsByStoryBlockId.set(key, [anchor]);
2352
2552
  }
2353
2553
  }
2554
+ const fieldRegionBlockPathByTargetKey = /* @__PURE__ */ new Map();
2555
+ for (const region of layoutInputs.fieldRegions) {
2556
+ const blockPath = topLevelBlockPath(region.sourcePath ?? "") ?? defaultStoryBlockPath(region.storyKey, region.paragraphIndex);
2557
+ fieldRegionBlockPathByTargetKey.set(
2558
+ `${region.storyKey}:field-region:${region.regionId}:refresh`,
2559
+ blockPath
2560
+ );
2561
+ }
2354
2562
  return {
2355
2563
  storyKeyForTarget(target) {
2356
2564
  return resolveCanonicalStoryKeyForTarget(target, storyKeys);
@@ -2382,6 +2590,9 @@ function createIdentityLookup(options) {
2382
2590
  objectAnchors(storyKey2, blockId) {
2383
2591
  return anchorsByStoryBlockId.get(storyBlockKey(storyKey2, blockId)) ?? [];
2384
2592
  },
2593
+ fieldRegionBlockPath(targetKey) {
2594
+ return fieldRegionBlockPathByTargetKey.get(targetKey);
2595
+ },
2385
2596
  blockIdForPath(storyKey2, blockPath) {
2386
2597
  return blockIdByPath.get(storyPathKey(storyKey2, blockPath));
2387
2598
  },
@@ -2405,14 +2616,28 @@ function appendCanonicalObjectHandleEntries(input) {
2405
2616
  )) {
2406
2617
  if (anchor.hidden === true) continue;
2407
2618
  const exactObjectRect = frame.anchorIndex.byObjectId(anchor.objectKey);
2408
- const rect = exactObjectRect ?? block.frame;
2409
- const entryPrecision = exactObjectRect ? "within-tolerance" : "heuristic";
2410
- const status = exactObjectRect ? "realized" : "requires-rehydration";
2619
+ const modeledObjectRect = exactObjectRect === null ? resolveCanonicalTextboxObjectFrame(page, anchor) : null;
2620
+ const objectFrame = exactObjectRect ?? modeledObjectRect;
2621
+ const rect = objectFrame ?? block.frame;
2622
+ const entryPrecision = objectFrame ? "within-tolerance" : "heuristic";
2623
+ const status = objectFrame ? "realized" : "requires-rehydration";
2624
+ const objectUnavailableReason = objectFrame ? void 0 : "object-anchor-geometry-missing";
2411
2625
  const handleRects = buildObjectHandleRectsFromRect(rect, entryPrecision);
2626
+ const objectRect = objectFrame !== null ? { ...toGeometryRect(objectFrame), precision: entryPrecision } : void 0;
2627
+ const sourceIdentity = anchorSourceIdentity(
2628
+ anchor,
2629
+ objectFrame ? "direct" : "block-scoped"
2630
+ );
2412
2631
  const existing = entries.get(anchor.objectKey);
2413
2632
  if (existing) {
2414
2633
  appendUnique(existing.pageIds, page.page.pageId);
2415
2634
  existing.rects.push(...handleRects);
2635
+ if (objectRect && !existing.objectRect) {
2636
+ existing.objectRect = objectRect;
2637
+ }
2638
+ if (objectUnavailableReason) {
2639
+ existing.objectUnavailableReason = objectUnavailableReason;
2640
+ }
2416
2641
  appendDivergenceIdsForObject(
2417
2642
  existing,
2418
2643
  input.page,
@@ -2421,25 +2646,68 @@ function appendCanonicalObjectHandleEntries(input) {
2421
2646
  if (existing.precision !== "heuristic" && entryPrecision === "heuristic") {
2422
2647
  existing.precision = "heuristic";
2423
2648
  existing.status = "requires-rehydration";
2424
- existing.sourceIdentity = anchorSourceIdentity(anchor, "block-scoped");
2649
+ existing.sourceIdentity = sourceIdentity;
2425
2650
  }
2426
2651
  continue;
2427
2652
  }
2428
2653
  entries.set(anchor.objectKey, {
2429
2654
  objectId: anchor.objectKey,
2430
2655
  pageIds: [page.page.pageId],
2656
+ ...objectRect ? { objectRect } : {},
2431
2657
  rects: [...handleRects],
2432
2658
  status,
2433
2659
  precision: entryPrecision,
2660
+ ...objectUnavailableReason ? { objectUnavailableReason } : {},
2434
2661
  ...layoutDivergenceIdsForObject(input.page, anchor.objectKey),
2435
- sourceIdentity: anchorSourceIdentity(
2436
- anchor,
2437
- exactObjectRect ? "direct" : "block-scoped"
2438
- )
2662
+ sourceIdentity
2439
2663
  });
2440
2664
  recordPrecision(precision, entryPrecision);
2441
2665
  }
2442
2666
  }
2667
+ var EMUS_PER_TWIP = 635;
2668
+ function resolveCanonicalTextboxObjectFrame(page, anchor) {
2669
+ if (anchor.objectKind !== "textbox" || anchor.display !== "floating" || !anchor.extent) {
2670
+ return null;
2671
+ }
2672
+ const region = page.page.regions.body;
2673
+ const widthTwips = Math.max(0, anchor.extent.widthEmu / EMUS_PER_TWIP);
2674
+ const heightTwips = Math.max(0, anchor.extent.heightEmu / EMUS_PER_TWIP);
2675
+ if (widthTwips <= 0 || heightTwips <= 0) return null;
2676
+ const regionXTwips = region.rectTwips?.xTwips ?? page.page.layout.marginLeft + page.page.layout.gutter;
2677
+ const regionYTwips = region.rectTwips?.yTwips ?? page.page.layout.marginTop;
2678
+ const xTwips = resolveCanonicalAnchorAxisTwips(
2679
+ regionXTwips,
2680
+ region.widthTwips,
2681
+ widthTwips,
2682
+ anchor.positionH?.align,
2683
+ anchor.positionH?.offset
2684
+ );
2685
+ const yTwips = resolveCanonicalAnchorAxisTwips(
2686
+ regionYTwips,
2687
+ region.heightTwips,
2688
+ heightTwips,
2689
+ anchor.positionV?.align,
2690
+ anchor.positionV?.offset
2691
+ );
2692
+ return pageLocalObjectAnchorFrame(page, {
2693
+ xTwips,
2694
+ yTwips,
2695
+ widthTwips,
2696
+ heightTwips
2697
+ });
2698
+ }
2699
+ function resolveCanonicalAnchorAxisTwips(originTwips, spanTwips, objectSpanTwips, align, offsetEmu) {
2700
+ if (typeof offsetEmu === "number") {
2701
+ return originTwips + offsetEmu / EMUS_PER_TWIP;
2702
+ }
2703
+ if (align === "center" || align === "ctr") {
2704
+ return originTwips + Math.max(0, spanTwips - objectSpanTwips) / 2;
2705
+ }
2706
+ if (align === "right" || align === "bottom") {
2707
+ return originTwips + Math.max(0, spanTwips - objectSpanTwips);
2708
+ }
2709
+ return originTwips;
2710
+ }
2443
2711
  function appendPageLocalObjectHandleEntries(input) {
2444
2712
  const { page, entries, precision, divergenceIdsByObjectId } = input;
2445
2713
  const stories = page.page.frame?.pageLocalStories ?? [];
@@ -2466,6 +2734,12 @@ function appendPageLocalObjectHandleEntries(input) {
2466
2734
  if (existing) {
2467
2735
  appendUnique(existing.pageIds, page.page.pageId);
2468
2736
  existing.rects.push(...handleRects);
2737
+ if (!existing.objectRect) {
2738
+ existing.objectRect = {
2739
+ ...toGeometryRect(objectFrame),
2740
+ precision: entryPrecision
2741
+ };
2742
+ }
2469
2743
  appendDivergenceIds(existing, divergenceIdsByObjectId.get(object.objectId));
2470
2744
  if (existing.precision !== "heuristic" && entryPrecision === "heuristic") {
2471
2745
  existing.precision = "heuristic";
@@ -2477,6 +2751,10 @@ function appendPageLocalObjectHandleEntries(input) {
2477
2751
  entries.set(object.objectId, {
2478
2752
  objectId: object.objectId,
2479
2753
  pageIds: [page.page.pageId],
2754
+ objectRect: {
2755
+ ...toGeometryRect(objectFrame),
2756
+ precision: entryPrecision
2757
+ },
2480
2758
  rects: [...handleRects],
2481
2759
  status: entryStatus,
2482
2760
  precision: entryPrecision,
@@ -2514,9 +2792,11 @@ function finalizeObjectHandleEntries(entries) {
2514
2792
  return Array.from(entries.values()).map((entry) => ({
2515
2793
  objectId: entry.objectId,
2516
2794
  pageIds: entry.pageIds,
2795
+ ...entry.objectRect ? { objectRect: entry.objectRect } : {},
2517
2796
  rects: entry.rects,
2518
2797
  status: entry.status,
2519
2798
  precision: entry.precision,
2799
+ ...entry.objectUnavailableReason ? { objectUnavailableReason: entry.objectUnavailableReason } : {},
2520
2800
  ...entry.layoutDivergenceIds && entry.layoutDivergenceIds.length > 0 ? { layoutDivergenceIds: [...entry.layoutDivergenceIds] } : {},
2521
2801
  ...entry.sourceIdentity ? { sourceIdentity: entry.sourceIdentity } : {}
2522
2802
  }));
@@ -2537,6 +2817,14 @@ function resolveCanonicalStoryKeyForTarget(target, storyKeys) {
2537
2817
  }
2538
2818
  return exact;
2539
2819
  }
2820
+ function recordProjectedCommandTarget(targetsByKey, target) {
2821
+ const list = targetsByKey.get(target.targetKey);
2822
+ if (list) {
2823
+ list.push(target);
2824
+ } else {
2825
+ targetsByKey.set(target.targetKey, [target]);
2826
+ }
2827
+ }
2540
2828
  function recordProjectedScopeBlock(blocksByStory, block) {
2541
2829
  const list = blocksByStory.get(block.storyKey);
2542
2830
  if (list) {
@@ -2604,10 +2892,18 @@ function appendScopeReplacementEnvelopeEntries(input) {
2604
2892
  }
2605
2893
  }
2606
2894
  function appendEditableTargetSemanticEntries(input) {
2607
- const { identities, projectedBlocksByStory, entries, precision } = input;
2895
+ const {
2896
+ identities,
2897
+ unavailableAnchor,
2898
+ projectedBlocksByStory,
2899
+ projectedCommandTargetsByKey,
2900
+ entries,
2901
+ precision
2902
+ } = input;
2608
2903
  if (!identities) return 0;
2609
2904
  let count = 0;
2610
2905
  for (const target of identities.editableTargetInputs()) {
2906
+ attachEditableTargetProvenanceToSemanticEntries(target, entries);
2611
2907
  const tableGeometryEntries = resolveEditableTargetTableGeometryEntries(
2612
2908
  target,
2613
2909
  entries
@@ -2636,12 +2932,34 @@ function appendEditableTargetSemanticEntries(input) {
2636
2932
  }
2637
2933
  continue;
2638
2934
  }
2935
+ const projectedCommandTargets = projectedCommandTargetsByKey.get(target.targetKey) ?? [];
2936
+ if (projectedCommandTargets.length > 0) {
2937
+ for (const commandTarget of projectedCommandTargets) {
2938
+ entries.push(editableTargetEntryFromCommandTarget(target, commandTarget));
2939
+ recordPrecision(precision, commandTarget.precision);
2940
+ count += 1;
2941
+ }
2942
+ continue;
2943
+ }
2639
2944
  const projectedBlock = resolveEditableTargetProjectedBlock(
2640
2945
  target,
2641
2946
  identities
2642
2947
  );
2643
- if (!projectedBlock) continue;
2948
+ if (!projectedBlock) {
2949
+ if (!unavailableAnchor) continue;
2950
+ entries.push(
2951
+ unavailableEditableTargetEntryFromAnchor(
2952
+ target,
2953
+ unavailableAnchor,
2954
+ unavailableReasonForEditableTarget(target)
2955
+ )
2956
+ );
2957
+ recordPrecision(precision, "heuristic");
2958
+ count += 1;
2959
+ continue;
2960
+ }
2644
2961
  const projectedBlocks = projectedBlocksByStory.get(target.storyKey) ?? [];
2962
+ let projected = false;
2645
2963
  for (const block of projectedBlocks) {
2646
2964
  if (block.blockId !== projectedBlock.blockId || block.blockPath !== projectedBlock.blockPath) {
2647
2965
  continue;
@@ -2661,11 +2979,21 @@ function appendEditableTargetSemanticEntries(input) {
2661
2979
  editableTargetEditability: target.editability,
2662
2980
  editableTargetBlockers: target.posture.blockers,
2663
2981
  editableTargetLeafPath: target.leafPath,
2982
+ ...editableTargetProvenance(target),
2983
+ ...target.editableOwner ? {
2984
+ editableTargetOwnerKey: target.editableOwner.targetKey,
2985
+ editableTargetOwnerReason: target.editableOwner.reason,
2986
+ ...target.editableOwner.canonicalAddress ? {
2987
+ editableTargetOwnerCanonicalAddress: target.editableOwner.canonicalAddress
2988
+ } : {}
2989
+ } : {},
2664
2990
  rect: { ...block.rect, precision: "within-tolerance" },
2665
2991
  status: "realized",
2666
2992
  precision: "within-tolerance",
2667
2993
  sourceIdentity: {
2994
+ ...target.sourceRef !== void 0 ? { sourceRef: target.sourceRef } : {},
2668
2995
  storyKey: target.storyKey,
2996
+ ...tableTargetSourceIdentity(target.table),
2669
2997
  blockPath: projectedBlock.blockPath,
2670
2998
  inlinePath: target.blockPath === projectedBlock.blockPath ? target.leafPath : target.blockPath,
2671
2999
  editPosture: target.editability,
@@ -2674,10 +3002,61 @@ function appendEditableTargetSemanticEntries(input) {
2674
3002
  });
2675
3003
  recordPrecision(precision, "within-tolerance");
2676
3004
  count += 1;
3005
+ projected = true;
3006
+ }
3007
+ if (!projected && unavailableAnchor) {
3008
+ entries.push(
3009
+ unavailableEditableTargetEntryFromAnchor(
3010
+ target,
3011
+ unavailableAnchor,
3012
+ unavailableReasonForEditableTarget(target)
3013
+ )
3014
+ );
3015
+ recordPrecision(precision, "heuristic");
3016
+ count += 1;
2677
3017
  }
2678
3018
  }
2679
3019
  return count;
2680
3020
  }
3021
+ function resolveEditableTargetUnavailableAnchor(frame, pages) {
3022
+ const projectedPage = pages[0];
3023
+ if (projectedPage) {
3024
+ return {
3025
+ pageId: projectedPage.pageId,
3026
+ pageIndex: projectedPage.pageIndex,
3027
+ rect: zeroGeometryRectAt(projectedPage.rect),
3028
+ frameCompleteness: projectedPage.frameCompleteness
3029
+ };
3030
+ }
3031
+ const framePage = frame.pages[0];
3032
+ if (!framePage) return null;
3033
+ const metadata = pageFrameMetadata(framePage);
3034
+ return {
3035
+ pageId: framePage.page.pageId,
3036
+ pageIndex: framePage.page.pageIndex,
3037
+ rect: zeroGeometryRectAt(toGeometryRect(framePage.frame)),
3038
+ frameCompleteness: metadata.frameCompleteness
3039
+ };
3040
+ }
3041
+ function zeroGeometryRectAt(rect) {
3042
+ return {
3043
+ leftPx: rect.leftPx,
3044
+ topPx: rect.topPx,
3045
+ widthPx: 0,
3046
+ heightPx: 0,
3047
+ space: rect.space,
3048
+ precision: "heuristic"
3049
+ };
3050
+ }
3051
+ function unavailableReasonForEditableTarget(target) {
3052
+ if (target.commandFamily === "table-structure" || target.table) {
3053
+ return "editable-target-table-geometry-missing";
3054
+ }
3055
+ if (target.commandFamily === "field" || target.commandFamily === "link-bookmark") {
3056
+ return "editable-target-command-geometry-missing";
3057
+ }
3058
+ return "editable-target-block-geometry-missing";
3059
+ }
2681
3060
  function resolveEditableTargetTableGeometryEntries(target, entries) {
2682
3061
  if (target.commandFamily !== "table-structure" || !target.table) return [];
2683
3062
  const table = target.table;
@@ -2725,21 +3104,64 @@ function editableTargetEntryFromGeometryEntry(target, geometryEntry) {
2725
3104
  editableTargetEditability: target.editability,
2726
3105
  editableTargetBlockers: target.posture.blockers,
2727
3106
  editableTargetLeafPath: target.leafPath,
3107
+ ...editableTargetProvenance(target),
3108
+ ...target.editableOwner ? {
3109
+ editableTargetOwnerKey: target.editableOwner.targetKey,
3110
+ editableTargetOwnerReason: target.editableOwner.reason,
3111
+ ...target.editableOwner.canonicalAddress ? {
3112
+ editableTargetOwnerCanonicalAddress: target.editableOwner.canonicalAddress
3113
+ } : {}
3114
+ } : {},
2728
3115
  rect: { ...geometryEntry.rect },
2729
3116
  status: geometryEntry.status,
2730
3117
  precision: geometryEntry.precision,
2731
3118
  ...geometryEntry.frameCompleteness ? { frameCompleteness: geometryEntry.frameCompleteness } : {},
2732
3119
  sourceIdentity: {
3120
+ ...target.sourceRef !== void 0 ? { sourceRef: target.sourceRef } : {},
2733
3121
  ...geometryEntry.sourceIdentity ?? {
2734
3122
  storyKey: target.storyKey,
2735
3123
  blockPath: target.blockPath,
2736
3124
  joinKind: "block-scoped"
2737
3125
  },
3126
+ ...tableTargetSourceIdentity(target.table),
2738
3127
  inlinePath: target.leafPath,
2739
3128
  editPosture: target.editability
2740
3129
  }
2741
3130
  };
2742
3131
  }
3132
+ function editableTargetEntryFromCommandTarget(target, commandTarget) {
3133
+ return {
3134
+ entryId: `semantic:editable-target:${target.targetKey}:${commandTarget.pageId}:${commandTarget.fragmentId ?? commandTarget.blockId}`,
3135
+ kind: "editable-target",
3136
+ pageId: commandTarget.pageId,
3137
+ pageIndex: commandTarget.pageIndex,
3138
+ ...commandTarget.regionId ? { regionId: commandTarget.regionId } : {},
3139
+ ...commandTarget.regionKind ? { regionKind: commandTarget.regionKind } : {},
3140
+ ...commandTarget.sliceId ? { sliceId: commandTarget.sliceId } : {},
3141
+ blockId: commandTarget.blockId,
3142
+ ...commandTarget.fragmentId ? { fragmentId: commandTarget.fragmentId } : {},
3143
+ editableTargetKey: target.targetKey,
3144
+ editableTargetKind: target.kind,
3145
+ editableTargetCommandFamily: target.commandFamily,
3146
+ editableTargetEditability: target.editability,
3147
+ editableTargetBlockers: target.posture.blockers,
3148
+ editableTargetLeafPath: target.leafPath,
3149
+ ...editableTargetProvenance(target),
3150
+ rect: { ...commandTarget.rect },
3151
+ status: commandTarget.status,
3152
+ precision: commandTarget.precision,
3153
+ sourceIdentity: {
3154
+ ...target.sourceRef !== void 0 ? { sourceRef: target.sourceRef } : {},
3155
+ ...commandTarget.sourceIdentity ?? {
3156
+ storyKey: target.storyKey,
3157
+ blockPath: commandTarget.blockPath ?? target.blockPath,
3158
+ joinKind: "block-scoped"
3159
+ },
3160
+ inlinePath: commandTarget.blockPath && target.blockPath !== commandTarget.blockPath ? target.blockPath : target.leafPath,
3161
+ editPosture: target.editability
3162
+ }
3163
+ };
3164
+ }
2743
3165
  function unavailableEditableTargetEntryFromTableFrame(target, tableFrame) {
2744
3166
  const table = target.table;
2745
3167
  return {
@@ -2761,6 +3183,14 @@ function unavailableEditableTargetEntryFromTableFrame(target, tableFrame) {
2761
3183
  editableTargetEditability: target.editability,
2762
3184
  editableTargetBlockers: target.posture.blockers,
2763
3185
  editableTargetLeafPath: target.leafPath,
3186
+ ...editableTargetProvenance(target),
3187
+ ...target.editableOwner ? {
3188
+ editableTargetOwnerKey: target.editableOwner.targetKey,
3189
+ editableTargetOwnerReason: target.editableOwner.reason,
3190
+ ...target.editableOwner.canonicalAddress ? {
3191
+ editableTargetOwnerCanonicalAddress: target.editableOwner.canonicalAddress
3192
+ } : {}
3193
+ } : {},
2764
3194
  rect: {
2765
3195
  leftPx: tableFrame.rect.leftPx,
2766
3196
  topPx: tableFrame.rect.topPx,
@@ -2771,18 +3201,91 @@ function unavailableEditableTargetEntryFromTableFrame(target, tableFrame) {
2771
3201
  },
2772
3202
  status: "unavailable",
2773
3203
  precision: "heuristic",
3204
+ editableTargetUnavailableReason: "editable-target-table-geometry-missing",
2774
3205
  ...tableFrame.frameCompleteness ? { frameCompleteness: tableFrame.frameCompleteness } : {},
2775
3206
  sourceIdentity: {
3207
+ ...target.sourceRef !== void 0 ? { sourceRef: target.sourceRef } : {},
2776
3208
  ...tableFrame.sourceIdentity ?? {
2777
3209
  storyKey: target.storyKey,
2778
3210
  blockPath: target.table?.tablePath ?? target.blockPath,
2779
3211
  joinKind: "block-scoped"
2780
3212
  },
3213
+ ...tableTargetSourceIdentity(target.table),
2781
3214
  inlinePath: target.leafPath,
2782
3215
  editPosture: target.editability
2783
3216
  }
2784
3217
  };
2785
3218
  }
3219
+ function unavailableEditableTargetEntryFromAnchor(target, anchor, reason) {
3220
+ return {
3221
+ entryId: `semantic:editable-target:${target.targetKey}:${anchor.pageId}:unavailable`,
3222
+ kind: "editable-target",
3223
+ pageId: anchor.pageId,
3224
+ pageIndex: anchor.pageIndex,
3225
+ editableTargetKey: target.targetKey,
3226
+ editableTargetKind: target.kind,
3227
+ editableTargetCommandFamily: target.commandFamily,
3228
+ editableTargetEditability: target.editability,
3229
+ editableTargetBlockers: target.posture.blockers,
3230
+ editableTargetLeafPath: target.leafPath,
3231
+ ...editableTargetProvenance(target),
3232
+ ...target.editableOwner ? {
3233
+ editableTargetOwnerKey: target.editableOwner.targetKey,
3234
+ editableTargetOwnerReason: target.editableOwner.reason,
3235
+ ...target.editableOwner.canonicalAddress ? {
3236
+ editableTargetOwnerCanonicalAddress: target.editableOwner.canonicalAddress
3237
+ } : {}
3238
+ } : {},
3239
+ rect: anchor.rect,
3240
+ status: "unavailable",
3241
+ precision: "heuristic",
3242
+ editableTargetUnavailableReason: reason,
3243
+ ...anchor.frameCompleteness ? { frameCompleteness: anchor.frameCompleteness } : {},
3244
+ sourceIdentity: {
3245
+ ...target.sourceRef !== void 0 ? { sourceRef: target.sourceRef } : {},
3246
+ storyKey: target.storyKey,
3247
+ ...tableTargetSourceIdentity(target.table),
3248
+ blockPath: target.table?.tablePath ?? target.blockPath,
3249
+ inlinePath: target.leafPath,
3250
+ editPosture: target.editability,
3251
+ joinKind: "block-scoped"
3252
+ }
3253
+ };
3254
+ }
3255
+ function tableTargetSourceIdentity(table) {
3256
+ if (!table) return {};
3257
+ return {
3258
+ tableKey: table.tableKey,
3259
+ ...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
3260
+ ...table.rowSourceRef !== void 0 ? { rowSourceRef: table.rowSourceRef } : {},
3261
+ ...table.cellSourceRef !== void 0 ? { cellSourceRef: table.cellSourceRef } : {}
3262
+ };
3263
+ }
3264
+ function editableTargetProvenance(target) {
3265
+ return {
3266
+ ...target.canonicalAddress ? { editableTargetCanonicalAddress: target.canonicalAddress } : {},
3267
+ ...target.editableOwner?.canonicalAddress ? {
3268
+ editableTargetOwnerCanonicalAddress: target.editableOwner.canonicalAddress
3269
+ } : {}
3270
+ };
3271
+ }
3272
+ function attachEditableTargetProvenanceToSemanticEntries(target, entries) {
3273
+ const provenance = editableTargetProvenance(target);
3274
+ for (const entry of entries) {
3275
+ if (entry.kind === "numbering-marker") {
3276
+ if (target.commandFamily !== "text-leaf" || entry.sourceIdentity?.storyKey !== target.storyKey || entry.sourceIdentity?.blockPath !== target.blockPath) {
3277
+ continue;
3278
+ }
3279
+ entry.editableTargetKey = target.targetKey;
3280
+ entry.editableTargetKind = target.kind;
3281
+ entry.editableTargetCommandFamily = target.commandFamily;
3282
+ entry.editableTargetEditability = target.editability;
3283
+ entry.editableTargetBlockers = target.posture.blockers;
3284
+ entry.editableTargetLeafPath = target.leafPath;
3285
+ Object.assign(entry, provenance);
3286
+ }
3287
+ }
3288
+ }
2786
3289
  function resolveEditableTargetProjectedBlock(target, identities) {
2787
3290
  const directBlockId = identities.blockIdForPath(
2788
3291
  target.storyKey,
@@ -2791,7 +3294,35 @@ function resolveEditableTargetProjectedBlock(target, identities) {
2791
3294
  if (directBlockId) {
2792
3295
  return { blockId: directBlockId, blockPath: target.blockPath };
2793
3296
  }
2794
- if (target.kind !== "hyperlink-text") return null;
3297
+ const fieldRegionBlockPath = fieldRegionSourceBlockPath(target);
3298
+ if (fieldRegionBlockPath) {
3299
+ const fieldRegionBlockId = identities.blockIdForPath(
3300
+ target.storyKey,
3301
+ fieldRegionBlockPath
3302
+ );
3303
+ if (fieldRegionBlockId) {
3304
+ return {
3305
+ blockId: fieldRegionBlockId,
3306
+ blockPath: fieldRegionBlockPath
3307
+ };
3308
+ }
3309
+ }
3310
+ const modeledFieldRegionBlockPath = identities.fieldRegionBlockPath(
3311
+ target.targetKey
3312
+ );
3313
+ if (modeledFieldRegionBlockPath) {
3314
+ const fieldRegionBlockId = identities.blockIdForPath(
3315
+ target.storyKey,
3316
+ modeledFieldRegionBlockPath
3317
+ );
3318
+ if (fieldRegionBlockId) {
3319
+ return {
3320
+ blockId: fieldRegionBlockId,
3321
+ blockPath: modeledFieldRegionBlockPath
3322
+ };
3323
+ }
3324
+ }
3325
+ if (!shouldProjectInlineTargetFromEnclosingBlock(target)) return null;
2795
3326
  const enclosingBlockPath = enclosingBlockPathForInlineTarget(target.blockPath);
2796
3327
  if (!enclosingBlockPath) return null;
2797
3328
  const enclosingBlockId = identities.blockIdForPath(
@@ -2800,10 +3331,29 @@ function resolveEditableTargetProjectedBlock(target, identities) {
2800
3331
  );
2801
3332
  return enclosingBlockId ? { blockId: enclosingBlockId, blockPath: enclosingBlockPath } : null;
2802
3333
  }
3334
+ function fieldRegionSourceBlockPath(target) {
3335
+ if (target.kind !== "field-region-refresh" && target.kind !== "toc-region-refresh") {
3336
+ return null;
3337
+ }
3338
+ const sourcePath = target.field?.sourcePath;
3339
+ if (!sourcePath) return null;
3340
+ return enclosingBlockPathForInlineTarget(sourcePath) ?? topLevelBlockPath(sourcePath);
3341
+ }
3342
+ function shouldProjectInlineTargetFromEnclosingBlock(target) {
3343
+ return target.kind === "hyperlink-text" || target.kind === "field-result-text" || target.kind === "bookmark-anchor" || target.commandFamily === "link-bookmark";
3344
+ }
2803
3345
  function enclosingBlockPathForInlineTarget(path) {
2804
3346
  const inlineAt = path.indexOf("/inline");
2805
3347
  return inlineAt > 0 ? path.slice(0, inlineAt) : null;
2806
3348
  }
3349
+ function topLevelBlockPath(path) {
3350
+ const match = /^(.*\/block\[\d+\])(?:\/|$)/u.exec(path);
3351
+ return match?.[1] ?? null;
3352
+ }
3353
+ function defaultStoryBlockPath(storyKey2, paragraphIndex) {
3354
+ const base = storyKey2 === MAIN_STORY_KEY ? MAIN_STORY_KEY : storyKey2;
3355
+ return `${base}/block[${paragraphIndex}]`;
3356
+ }
2807
3357
  function projectScopeReplacementEnvelopeEntry(scope, identities, storyBlocks) {
2808
3358
  const startBlockId = scope.start ? identities.blockIdForPath(scope.storyKey, scope.start.blockPath) : void 0;
2809
3359
  const endBlockId = scope.end ? identities.blockIdForPath(scope.storyKey, scope.end.blockPath) : void 0;
@@ -2900,6 +3450,7 @@ function anchorSourceIdentity(anchor, joinKind) {
2900
3450
  inlinePath: anchor.inlinePath,
2901
3451
  objectKind: anchor.objectKind,
2902
3452
  editPosture: anchor.editPosture,
3453
+ ...anchor.sourceRef !== void 0 ? { sourceRef: anchor.sourceRef } : {},
2903
3454
  joinKind
2904
3455
  };
2905
3456
  }
@@ -2913,6 +3464,7 @@ function tableSourceIdentity(table) {
2913
3464
  storyKey: table.storyKey,
2914
3465
  blockPath: table.blockPath,
2915
3466
  tableKey: table.tableKey,
3467
+ ...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
2916
3468
  joinKind: "direct"
2917
3469
  };
2918
3470
  }
@@ -2920,7 +3472,8 @@ function tableRowSourceIdentity(table, rowIndex) {
2920
3472
  const row = table.rows.find((entry) => entry.rowIndex === rowIndex);
2921
3473
  return {
2922
3474
  ...tableSourceIdentity(table),
2923
- ...row ? { rowKey: row.rowKey } : {}
3475
+ ...row ? { rowKey: row.rowKey } : {},
3476
+ ...row?.sourceRef !== void 0 ? { rowSourceRef: row.sourceRef } : {}
2924
3477
  };
2925
3478
  }
2926
3479
  function tableCellSourceIdentity(table, rowIndex, gridColumnStart) {
@@ -2928,7 +3481,8 @@ function tableCellSourceIdentity(table, rowIndex, gridColumnStart) {
2928
3481
  const cell = findCanonicalCellByGridColumn(row, gridColumnStart);
2929
3482
  return {
2930
3483
  ...tableRowSourceIdentity(table, rowIndex),
2931
- ...cell ? { cellKey: cell.cellKey } : {}
3484
+ ...cell ? { cellKey: cell.cellKey } : {},
3485
+ ...cell?.sourceRef !== void 0 ? { cellSourceRef: cell.sourceRef } : {}
2932
3486
  };
2933
3487
  }
2934
3488
  function findCanonicalCellByGridColumn(row, gridColumnStart) {