@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
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createSearchPlugin,
5
5
  performSearch,
6
6
  searchPluginKey
7
- } from "./chunk-IQ2VJEF6.js";
7
+ } from "./chunk-QNGJRZ2D.js";
8
8
  import {
9
9
  CODE_METADATA_TABLE,
10
10
  KNOWN_DIAGNOSTIC_CODES,
@@ -26,7 +26,7 @@ import {
26
26
  splitListParagraph,
27
27
  toggleBulletedList,
28
28
  toggleNumberedList
29
- } from "./chunk-KD5K5XIA.js";
29
+ } from "./chunk-UHQOUTAX.js";
30
30
  import {
31
31
  applyParagraphStyleToDocument
32
32
  } from "./chunk-6EXNNAO6.js";
@@ -37,15 +37,15 @@ import {
37
37
  setSectionPageNumberingAtSectionIndex,
38
38
  updateSectionLayoutAtSectionIndex
39
39
  } from "./chunk-M6XR534O.js";
40
- import "./chunk-2ZWFQ74R.js";
40
+ import "./chunk-OBCP6VTG.js";
41
41
  import {
42
42
  createRuntimeCollabSync,
43
43
  createRuntimeCommandAppliedBridge
44
- } from "./chunk-WDNEPRFW.js";
44
+ } from "./chunk-ICX54W4U.js";
45
45
  import {
46
46
  insertPageBreak,
47
47
  insertTable
48
- } from "./chunk-FXGQM2JB.js";
48
+ } from "./chunk-3OFSP2IX.js";
49
49
  import {
50
50
  getFormattingStateFromRenderSnapshot
51
51
  } from "./chunk-Y4XZCMCS.js";
@@ -53,13 +53,13 @@ import {
53
53
  insertImage,
54
54
  repositionFloatingImage,
55
55
  resizeImage
56
- } from "./chunk-5RNMPLXU.js";
57
- import "./chunk-U5BSQXF4.js";
56
+ } from "./chunk-37SEJQ3G.js";
57
+ import "./chunk-3OHVK2D6.js";
58
58
  import {
59
59
  getTableStructureContext,
60
60
  tableStructureActionHandleForTarget
61
- } from "./chunk-BBB4GSDB.js";
62
- import "./chunk-MUEN2WOG.js";
61
+ } from "./chunk-XVFENXLK.js";
62
+ import "./chunk-ZKSDVHGH.js";
63
63
  import {
64
64
  OverlayAnchorBridgeProvider,
65
65
  PAGE_CHROME_DEFAULTS,
@@ -84,7 +84,7 @@ import {
84
84
  resolveSelectionToolRegistry,
85
85
  shouldRenderAbsoluteFloatingImageInPageOverlay,
86
86
  shouldRenderSelectionToolKind
87
- } from "./chunk-KHZNNBTN.js";
87
+ } from "./chunk-QFU7ZOAD.js";
88
88
  import {
89
89
  PREDICTED_LANE_COUNTERS,
90
90
  createInertGeometryFacet,
@@ -92,7 +92,7 @@ import {
92
92
  incrementInvalidationCounter,
93
93
  recordPerfSample,
94
94
  startPerfProbe
95
- } from "./chunk-WVZX4NYG.js";
95
+ } from "./chunk-GZW2ERUO.js";
96
96
  import {
97
97
  composeSeriesColor,
98
98
  computeStructuralHash,
@@ -106,22 +106,22 @@ import {
106
106
  resolveColor,
107
107
  tryReadLaycacheEnvelope,
108
108
  writeEnvelopeToOpcPackage
109
- } from "./chunk-FIGWJ43K.js";
109
+ } from "./chunk-IT2DK3A7.js";
110
110
  import {
111
111
  findTextMatches,
112
112
  parseCanonicalFragmentFromWordML,
113
113
  searchDocument
114
- } from "./chunk-MPYYBRVN.js";
114
+ } from "./chunk-PCXTMEGY.js";
115
115
  import {
116
116
  clearLocalCursorState,
117
117
  getCursorColorForUser,
118
118
  getRemoteCursorStates,
119
119
  setLocalCursorState
120
- } from "./chunk-XC56YLIS.js";
120
+ } from "./chunk-C2LWJ4CZ.js";
121
121
  import {
122
122
  resolveChromePreset,
123
123
  resolveChromeVisibilityForPreset
124
- } from "./chunk-VCL5MJMZ.js";
124
+ } from "./chunk-GON2DNTE.js";
125
125
  import {
126
126
  CAPABILITY_BY_ID,
127
127
  ISSUE_METADATA_ID,
@@ -137,33 +137,33 @@ import {
137
137
  deriveCapabilities,
138
138
  sanitizeMarkdown,
139
139
  sha256Hex
140
- } from "./chunk-TMQGWF7R.js";
140
+ } from "./chunk-G3B2OBCZ.js";
141
141
  import "./chunk-KFCQYZXR.js";
142
- import "./chunk-4ZNQFWFM.js";
142
+ import "./chunk-QIO6V46H.js";
143
143
  import {
144
144
  createEditorSurfaceSnapshot,
145
145
  getStoryBlocks,
146
146
  replaceStoryBlocks,
147
147
  stableChartId
148
- } from "./chunk-AUQDC5BD.js";
149
- import "./chunk-VDIUVT46.js";
148
+ } from "./chunk-3TUQCHYT.js";
149
+ import "./chunk-CX42VC67.js";
150
150
  import {
151
151
  createDefaultCanonicalDocument,
152
152
  createSelectionSnapshot
153
- } from "./chunk-FLNQY74K.js";
153
+ } from "./chunk-OYGMRRR7.js";
154
154
  import {
155
155
  DocxSession,
156
156
  SessionNotOpenError,
157
157
  SessionNotWiredError,
158
158
  isReopenBarrier
159
- } from "./chunk-BM5NSDII.js";
159
+ } from "./chunk-S4ANOS2M.js";
160
160
  import {
161
161
  createHmacSigner,
162
162
  createHmacVerifier,
163
163
  loadDocxSessionSync,
164
164
  signWorkflowPayloadXml,
165
165
  verifyWorkflowPayloadXml
166
- } from "./chunk-KCHEAX4Z.js";
166
+ } from "./chunk-EMDH4IQN.js";
167
167
  import {
168
168
  EDITOR_SESSION_STATE_VERSION,
169
169
  assertEditorSessionState,
@@ -172,8 +172,8 @@ import {
172
172
  editorSessionStateFromPersistedSnapshot,
173
173
  persistedSnapshotFromEditorSessionState,
174
174
  validateEditorSessionState
175
- } from "./chunk-327AIUXL.js";
176
- import "./chunk-NQZUGMLW.js";
175
+ } from "./chunk-UWDWGQH5.js";
176
+ import "./chunk-TMU7JMXX.js";
177
177
  import {
178
178
  decodePersistedSourcePackageBytes,
179
179
  hasValidPersistedSourcePackageDigest
@@ -185,7 +185,7 @@ import {
185
185
  collectEditableTargetRefs,
186
186
  createHeaderFooterStoryKey,
187
187
  createNoteStoryKey
188
- } from "./chunk-AQA7OZ2R.js";
188
+ } from "./chunk-TFSXOIAI.js";
189
189
  import {
190
190
  readOpcPackage
191
191
  } from "./chunk-OL2UEHRP.js";
@@ -197,8 +197,9 @@ import {
197
197
  import "./chunk-UTL65BUI.js";
198
198
  import "./chunk-UFVDIR2C.js";
199
199
  import {
200
- createCanonicalDocumentId
201
- } from "./chunk-4JNUMMM7.js";
200
+ createCanonicalDocumentId,
201
+ createPublicRangeAnchor
202
+ } from "./chunk-PGGPPZ65.js";
202
203
  import {
203
204
  stableStringify
204
205
  } from "./chunk-DNXYUIIS.js";
@@ -1806,7 +1807,7 @@ function TwNavigationCommandBar(props) {
1806
1807
  onClick: () => props.onGoToGroupChange(group.id),
1807
1808
  className: [
1808
1809
  "inline-flex h-7 items-center gap-1 rounded-md border px-2 text-[length:var(--text-xs)] font-medium transition-colors focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus)]",
1809
- selected ? "border-[var(--color-border-accent)] bg-[var(--color-accent-soft)] text-[var(--color-accent-primary)]" : "border-border bg-canvas text-secondary hover:bg-hover hover:text-primary"
1810
+ selected ? "border-[var(--color-border-accent)] bg-[var(--color-bg-elevated)] text-[var(--color-accent-primary)]" : "border-border bg-canvas text-secondary hover:bg-hover hover:text-primary"
1810
1811
  ].join(" "),
1811
1812
  children: [
1812
1813
  /* @__PURE__ */ jsx(Target, { className: "h-3 w-3", "aria-hidden": "true" }),
@@ -6376,32 +6377,44 @@ function buildPositionMap(surface) {
6376
6377
  const protectedInlineEntries = [];
6377
6378
  const pmDocSize = walkBlocks(surface.blocks, 1, entries, protectedInlineEntries, { rootLevel: true });
6378
6379
  const runtimeStorySize = surface.storySize;
6379
- return {
6380
- runtimeToPm(runtimePos) {
6381
- const firstEditable = entries.find((entry) => entry.editable !== false);
6382
- if (runtimePos <= 0) {
6383
- return firstEditable?.pmStart ?? 1;
6380
+ const runtimeToPm = (runtimePos) => {
6381
+ const firstEditable = entries.find(isRuntimeRestorableEntry);
6382
+ if (runtimePos <= 0) {
6383
+ return firstEditable?.pmStart ?? 1;
6384
+ }
6385
+ if (runtimePos >= runtimeStorySize) {
6386
+ return lastRestorableEntry(entries)?.pmEnd ?? pmDocSize - 1;
6387
+ }
6388
+ let previous = null;
6389
+ for (const entry of entries) {
6390
+ if (!isRuntimeRestorableEntry(entry)) {
6391
+ continue;
6384
6392
  }
6385
- if (runtimePos >= runtimeStorySize) {
6386
- return lastEditableEntry(entries)?.pmEnd ?? pmDocSize - 1;
6393
+ if (entry.runtimeStart === entry.runtimeEnd && runtimePos === entry.runtimeStart) {
6394
+ return entry.pmStart;
6387
6395
  }
6388
- let previous = null;
6389
- for (const entry of entries) {
6390
- if (entry.editable === false) {
6391
- continue;
6392
- }
6393
- if (entry.runtimeStart === entry.runtimeEnd && runtimePos === entry.runtimeStart) {
6394
- return entry.pmStart;
6395
- }
6396
- if (runtimePos >= entry.runtimeStart && runtimePos < entry.runtimeEnd) {
6397
- return entry.pmStart + (runtimePos - entry.runtimeStart);
6398
- }
6399
- if (runtimePos < entry.runtimeStart) {
6400
- return nearestRuntimeGapPm(runtimePos, previous, entry);
6401
- }
6402
- previous = entry;
6396
+ if (runtimePos >= entry.runtimeStart && runtimePos < entry.runtimeEnd) {
6397
+ return entry.pmStart + (runtimePos - entry.runtimeStart);
6403
6398
  }
6404
- return lastEditableEntry(entries)?.pmEnd ?? 1;
6399
+ if (runtimePos < entry.runtimeStart) {
6400
+ return nearestRuntimeGapPm(runtimePos, previous, entry);
6401
+ }
6402
+ previous = entry;
6403
+ }
6404
+ return lastRestorableEntry(entries)?.pmEnd ?? 1;
6405
+ };
6406
+ return {
6407
+ runtimeToPm,
6408
+ runtimeToPmWithContext(input) {
6409
+ const targetEntry = input.editableTarget ? findRestorableEntryForTarget(entries, input.editableTarget) : void 0;
6410
+ if (targetEntry) {
6411
+ return pmForRuntimeInTargetEntry(targetEntry, input.runtimePos, protectedInlineEntries);
6412
+ }
6413
+ const inertTargetEntry = input.editableTarget ? findInertEntryForTarget(entries, input.editableTarget) : void 0;
6414
+ if (inertTargetEntry) {
6415
+ return pmForRuntimeInTargetEntry(inertTargetEntry, input.runtimePos, protectedInlineEntries);
6416
+ }
6417
+ return runtimeToPm(input.runtimePos);
6405
6418
  },
6406
6419
  pmToRuntime(pmPos) {
6407
6420
  return resolvePmPosition(entries, protectedInlineEntries, pmDocSize, runtimeStorySize, pmPos).runtimePos;
@@ -6421,6 +6434,12 @@ function resolvePmPosition(entries, protectedInlineEntries, pmDocSize, runtimeSt
6421
6434
  if (protectedEntry) {
6422
6435
  return contextForEntry(protectedEntry, pmPos);
6423
6436
  }
6437
+ const exactStartEntry = entries.find(
6438
+ (entry) => pmPos === entry.pmStart && isRuntimeRestorableEntry(entry)
6439
+ );
6440
+ if (exactStartEntry) {
6441
+ return contextForEntry(exactStartEntry, pmPos);
6442
+ }
6424
6443
  if (pmPos <= 1) {
6425
6444
  const first = entries[0];
6426
6445
  if (first && pmPos >= first.pmStart && pmPos <= first.pmEnd) {
@@ -6465,11 +6484,15 @@ function resolvePmPosition(entries, protectedInlineEntries, pmDocSize, runtimeSt
6465
6484
  }
6466
6485
  function contextForEntry(entry, pmPos) {
6467
6486
  const pmDelta = Math.max(0, pmPos - entry.pmStart);
6487
+ const runtimeStart = entry.dispatchRuntimeStart ?? entry.runtimeStart;
6488
+ const runtimeEnd = entry.dispatchRuntimeEnd ?? entry.runtimeEnd;
6489
+ const runtimeDelta = Math.min(pmDelta, Math.max(0, runtimeEnd - runtimeStart));
6490
+ const editableTarget = entry.dispatchEditableTarget ?? entry.editableTarget;
6468
6491
  return {
6469
- runtimePos: entry.runtimeStart + pmDelta,
6492
+ runtimePos: runtimeStart + runtimeDelta,
6470
6493
  editable: entry.editable !== false,
6471
6494
  textTarget: entry.editable === false ? void 0 : entry.textTarget,
6472
- editableTarget: entry.editable === false ? void 0 : entry.editableTarget
6495
+ editableTarget: entry.editable === false ? void 0 : editableTarget
6473
6496
  };
6474
6497
  }
6475
6498
  function isEditablePmRange(entries, protectedInlineEntries, pmDocSize, runtimeStorySize, from, to) {
@@ -6489,7 +6512,22 @@ function isEditablePmRange(entries, protectedInlineEntries, pmDocSize, runtimeSt
6489
6512
  return true;
6490
6513
  }
6491
6514
  function protectedInlineEntryAtPm(protectedInlineEntries, pmPos) {
6492
- return protectedInlineEntries.find((entry) => pmPos >= entry.pmStart && pmPos < entry.pmEnd);
6515
+ return protectedInlineEntries.find((entry) => pmPos > entry.pmStart && pmPos < entry.pmEnd);
6516
+ }
6517
+ function pmForRuntimeInTargetEntry(entry, runtimePos, protectedInlineEntries) {
6518
+ const runtimeDelta = Math.max(
6519
+ 0,
6520
+ Math.min(runtimePos - entry.runtimeStart, entry.runtimeEnd - entry.runtimeStart)
6521
+ );
6522
+ let pmPos = entry.pmStart + runtimeDelta;
6523
+ for (const protectedEntry of protectedInlineEntries) {
6524
+ if (protectedEntry.pmEnd <= entry.pmStart) continue;
6525
+ if (protectedEntry.pmStart > entry.pmEnd) break;
6526
+ if (pmPos > protectedEntry.pmStart && pmPos < protectedEntry.pmEnd) {
6527
+ pmPos = Math.min(entry.pmEnd, protectedEntry.pmEnd);
6528
+ }
6529
+ }
6530
+ return pmPos;
6493
6531
  }
6494
6532
  function pmRangeTouchesEntry(start, end, entry) {
6495
6533
  if (start === end) {
@@ -6505,10 +6543,13 @@ function nearestRuntimeGapPm(runtimePos, previous, next) {
6505
6543
  const distanceToNext = Math.abs(next.runtimeStart - runtimePos);
6506
6544
  return distanceToPrevious <= distanceToNext ? previous.pmEnd : next.pmStart;
6507
6545
  }
6508
- function lastEditableEntry(entries) {
6546
+ function isRuntimeRestorableEntry(entry) {
6547
+ return entry.editable !== false && entry.restorable !== false;
6548
+ }
6549
+ function lastRestorableEntry(entries) {
6509
6550
  for (let index = entries.length - 1; index >= 0; index -= 1) {
6510
6551
  const entry = entries[index];
6511
- if (entry.editable !== false) {
6552
+ if (isRuntimeRestorableEntry(entry)) {
6512
6553
  return entry;
6513
6554
  }
6514
6555
  }
@@ -6546,7 +6587,7 @@ function walkBlocks(blocks, pmCursor, entries, protectedInlineEntries, context)
6546
6587
  pmEnd: pmContentStart + runtimeLength,
6547
6588
  editable,
6548
6589
  insideTable: context.insideTable === true || context.tableCell !== void 0,
6549
- editableTarget: editable ? block.editableTarget : void 0,
6590
+ editableTarget: block.editableTarget,
6550
6591
  textTarget: editable && tableCell ? {
6551
6592
  kind: "table-paragraph",
6552
6593
  tableBlockIndex: tableCell.tableBlockIndex,
@@ -6652,6 +6693,33 @@ function hasEditableTargetInBlocks(blocks) {
6652
6693
  }
6653
6694
  return false;
6654
6695
  }
6696
+ function findInertEntryForTarget(entries, target) {
6697
+ if (!isSyntheticLayoutContinuationTarget(target)) {
6698
+ return void 0;
6699
+ }
6700
+ return entries.find((entry) => {
6701
+ const candidate = entry.editableTarget;
6702
+ return entry.editable === false && candidate?.targetKey === target.targetKey && candidate.storyKey === target.storyKey && candidate.blockPath === target.blockPath && candidate.leafPath === target.leafPath && candidate.kind === target.kind;
6703
+ });
6704
+ }
6705
+ function findRestorableEntryForTarget(entries, target) {
6706
+ if ("editableOwner" in target && target.editableOwner && isSyntheticLayoutContinuationTarget(target)) {
6707
+ return findRestorableEntryForOwner(entries, target.editableOwner);
6708
+ }
6709
+ return entries.find((entry) => {
6710
+ const candidate = entry.editableTarget;
6711
+ return isRuntimeRestorableEntry(entry) && candidate?.targetKey === target.targetKey && candidate.storyKey === target.storyKey && candidate.blockPath === target.blockPath && candidate.leafPath === target.leafPath && candidate.kind === target.kind;
6712
+ });
6713
+ }
6714
+ function findRestorableEntryForOwner(entries, owner) {
6715
+ return entries.find((entry) => {
6716
+ const candidate = entry.editableTarget;
6717
+ return isRuntimeRestorableEntry(entry) && candidate?.targetKey === owner.targetKey && candidate.storyKey === owner.storyKey && candidate.blockPath === owner.blockPath && candidate.leafPath === owner.leafPath && candidate.kind === owner.kind && candidate.commandFamily === owner.commandFamily;
6718
+ });
6719
+ }
6720
+ function isSyntheticLayoutContinuationTarget(target) {
6721
+ return target.commandFamily === "text-leaf" && target.table?.operationScope === "text" && target.table.verticalMerge === "continue" && target.posture.blockers.includes("synthetic-layout-cell");
6722
+ }
6655
6723
  function tableCellFromEditableTarget(target) {
6656
6724
  if (target?.kind !== "table-cell-paragraph-text" && target?.kind !== "nested-table-cell-paragraph-text" && target?.kind !== "sdt-table-cell-paragraph-text") {
6657
6725
  return void 0;
@@ -6806,8 +6874,12 @@ function createPMStateFromSnapshot(surface, selection, plugins, mediaPreviews =
6806
6874
  return { state, positionMap };
6807
6875
  }
6808
6876
  function createPMSelectionFromSnapshot(doc, positionMap, selection) {
6809
- const pmAnchor = clamp(positionMap.runtimeToPm(selection.anchor), 1, positionMap.pmDocSize - 1);
6810
- const pmHead = clamp(positionMap.runtimeToPm(selection.head), 1, positionMap.pmDocSize - 1);
6877
+ const mapRuntimeToPm = (runtimePos) => positionMap.runtimeToPmWithContext?.({
6878
+ runtimePos,
6879
+ ...selection.editableTarget ? { editableTarget: selection.editableTarget } : {}
6880
+ }) ?? positionMap.runtimeToPm(runtimePos);
6881
+ const pmAnchor = clamp(mapRuntimeToPm(selection.anchor), 1, positionMap.pmDocSize - 1);
6882
+ const pmHead = clamp(mapRuntimeToPm(selection.head), 1, positionMap.pmDocSize - 1);
6811
6883
  try {
6812
6884
  if (selection.activeRange.kind === "node") {
6813
6885
  const pmNodePos = clamp(pmAnchor - 1, 0, positionMap.pmDocSize - 2);
@@ -7603,7 +7675,7 @@ function createSelectionSyncPlugin(callbacks) {
7603
7675
  return;
7604
7676
  }
7605
7677
  callbacks.onSelectionChange(
7606
- createNodeSelectionSnapshot(context.runtimePos, 1)
7678
+ createNodeSelectionSnapshot(context.runtimePos, 1, context.editableTarget)
7607
7679
  );
7608
7680
  return;
7609
7681
  }
@@ -7613,8 +7685,12 @@ function createSelectionSyncPlugin(callbacks) {
7613
7685
  if (anchorContext.editable === false || headContext.editable === false) {
7614
7686
  return;
7615
7687
  }
7688
+ const editableTarget = resolveSelectionEditableTarget(
7689
+ anchorContext.editableTarget,
7690
+ headContext.editableTarget
7691
+ );
7616
7692
  callbacks.onSelectionChange(
7617
- createSelectionSnapshot2(anchorContext.runtimePos, headContext.runtimePos)
7693
+ createSelectionSnapshot2(anchorContext.runtimePos, headContext.runtimePos, editableTarget)
7618
7694
  );
7619
7695
  }
7620
7696
  }
@@ -7622,6 +7698,10 @@ function createSelectionSyncPlugin(callbacks) {
7622
7698
  }
7623
7699
  });
7624
7700
  }
7701
+ function resolveSelectionEditableTarget(anchorTarget, headTarget) {
7702
+ if (!anchorTarget || !headTarget) return void 0;
7703
+ return anchorTarget.targetKey === headTarget.targetKey ? anchorTarget : void 0;
7704
+ }
7625
7705
  function createCommandBridgePlugins(callbacks, options) {
7626
7706
  let isComposing = false;
7627
7707
  let pendingCompositionText = null;
@@ -8665,6 +8745,76 @@ function createLocalEditSessionState(options) {
8665
8745
  };
8666
8746
  }
8667
8747
 
8748
+ // src/ui-tailwind/editor-surface/predicted-position-map.ts
8749
+ function createPredictedPositionMap(canonical, pendingOps) {
8750
+ if (pendingOps.length === 0) return canonical;
8751
+ function opsBefore(runtimePos) {
8752
+ let delta = 0;
8753
+ for (const op of pendingOps) {
8754
+ if (op.fromRuntime <= runtimePos) {
8755
+ delta += opSizeDelta(op);
8756
+ }
8757
+ }
8758
+ return delta;
8759
+ }
8760
+ return {
8761
+ runtimeToPm(runtimePos) {
8762
+ return canonical.runtimeToPm(runtimePos) + opsBefore(runtimePos);
8763
+ },
8764
+ pmToRuntime(pmPos) {
8765
+ return this.pmToRuntimeWithContext(pmPos).runtimePos;
8766
+ },
8767
+ pmToRuntimeWithContext(pmPos) {
8768
+ let adjusted = pmPos;
8769
+ for (const op of pendingOps) {
8770
+ const opPmStart = canonical.runtimeToPm(op.fromRuntime);
8771
+ if (adjusted > opPmStart) {
8772
+ adjusted -= opSizeDelta(op);
8773
+ }
8774
+ }
8775
+ return canonical.pmToRuntimeWithContext(Math.max(1, adjusted));
8776
+ },
8777
+ ...canonical.isPmRangeEditable ? {
8778
+ isPmRangeEditable(fromPm, toPm) {
8779
+ const fromRuntime = this.pmToRuntimeWithContext(fromPm);
8780
+ const toRuntime = this.pmToRuntimeWithContext(toPm);
8781
+ if (fromRuntime.editable === false || toRuntime.editable === false) return false;
8782
+ const canonicalFrom = canonical.runtimeToPm(fromRuntime.runtimePos);
8783
+ const canonicalTo = canonical.runtimeToPm(toRuntime.runtimePos);
8784
+ return canonical.isPmRangeEditable(canonicalFrom, canonicalTo);
8785
+ }
8786
+ } : {},
8787
+ get pmDocSize() {
8788
+ return canonical.pmDocSize + totalDelta(pendingOps);
8789
+ },
8790
+ get runtimeStorySize() {
8791
+ return canonical.runtimeStorySize + totalDelta(pendingOps);
8792
+ }
8793
+ };
8794
+ }
8795
+ function totalDelta(pendingOps) {
8796
+ let delta = 0;
8797
+ for (const op of pendingOps) {
8798
+ delta += opSizeDelta(op);
8799
+ }
8800
+ return delta;
8801
+ }
8802
+ function opSizeDelta(op) {
8803
+ switch (op.intent.kind) {
8804
+ case "text.insert":
8805
+ return op.intent.text.length;
8806
+ case "text.delete-backward":
8807
+ case "text.delete-forward":
8808
+ return -(op.toRuntime - op.fromRuntime);
8809
+ case "paragraph.split":
8810
+ return 2;
8811
+ case "text.insert-hard-break":
8812
+ return 1;
8813
+ default:
8814
+ return 0;
8815
+ }
8816
+ }
8817
+
8668
8818
  // src/ui-tailwind/editor-surface/predicted-tx-gate.ts
8669
8819
  import { Plugin as Plugin4, PluginKey as PluginKey3 } from "prosemirror-state";
8670
8820
  var PREDICTED_META_KEY = "bounded-local-first/predicted";
@@ -8732,6 +8882,15 @@ function createFastTextEditLane(options) {
8732
8882
  fromContext.editableTarget,
8733
8883
  toContext.editableTarget
8734
8884
  );
8885
+ if (!editableTarget) {
8886
+ return;
8887
+ }
8888
+ const predictedSelection = predictedSelectionForIntent(
8889
+ intent,
8890
+ fromRuntime,
8891
+ toRuntime,
8892
+ editableTarget
8893
+ );
8735
8894
  const debugEntry = pushLaneDebug({
8736
8895
  opId,
8737
8896
  intent: intent.kind,
@@ -8802,6 +8961,7 @@ function createFastTextEditLane(options) {
8802
8961
  newRevisionToken: ack.newRevisionToken
8803
8962
  });
8804
8963
  incrementInvalidationCounter(PREDICTED_LANE_COUNTERS.equivalent);
8964
+ publishLocalEquivalentEffects(ack, op, predictedSelection);
8805
8965
  options.onEquivalentAck(ack);
8806
8966
  return;
8807
8967
  case "adjusted":
@@ -8838,6 +8998,11 @@ function createFastTextEditLane(options) {
8838
8998
  options.suppressSelectionSync?.(false);
8839
8999
  }
8840
9000
  }
9001
+ function publishLocalEquivalentEffects(ack, op, selection) {
9002
+ if (getTextCommandRefreshClass(ack) !== "local-text-equivalent") return;
9003
+ options.onLocalEquivalentOp?.(op);
9004
+ options.onPredictedSelectionChange?.(selection);
9005
+ }
8841
9006
  function restorePreImage(view, pre) {
8842
9007
  view.updateState(pre.preState);
8843
9008
  }
@@ -8873,6 +9038,35 @@ function createFastTextEditLane(options) {
8873
9038
  }
8874
9039
  };
8875
9040
  }
9041
+ function predictedSelectionForIntent(intent, fromRuntime, toRuntime, editableTarget) {
9042
+ const from = Math.min(fromRuntime, toRuntime);
9043
+ const to = Math.max(fromRuntime, toRuntime);
9044
+ let anchor = from;
9045
+ switch (intent.kind) {
9046
+ case "text.insert":
9047
+ anchor = from + intent.text.length;
9048
+ break;
9049
+ case "text.insert-hard-break":
9050
+ anchor = from + 1;
9051
+ break;
9052
+ case "text.delete-backward":
9053
+ anchor = from === to ? Math.max(0, from - 1) : from;
9054
+ break;
9055
+ case "text.delete-forward":
9056
+ anchor = from;
9057
+ break;
9058
+ case "paragraph.split":
9059
+ anchor = from;
9060
+ break;
9061
+ }
9062
+ return {
9063
+ anchor,
9064
+ head: anchor,
9065
+ isCollapsed: true,
9066
+ activeRange: createPublicRangeAnchor(anchor, anchor),
9067
+ editableTarget
9068
+ };
9069
+ }
8876
9070
  function pushLaneDebug(entry) {
8877
9071
  if (typeof window === "undefined") return null;
8878
9072
  const buffer = window.__DOCX_LANE_DEBUG__;
@@ -12816,9 +13010,11 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
12816
13010
  const documentBuildKeyRef = useRef5(null);
12817
13011
  const decorationBuildKeyRef = useRef5(null);
12818
13012
  const suppressSelectionEchoRef = useRef5(false);
13013
+ const lastSelectionTargetRef = useRef5(null);
12819
13014
  const sessionRef = useRef5(null);
12820
13015
  const laneRef = useRef5(null);
12821
13016
  const equivalentAckLedgerRef = useRef5(/* @__PURE__ */ new Map());
13017
+ const localEquivalentOpsRef = useRef5([]);
12822
13018
  const pendingRebuildScrollAnchorRef = useRef5(null);
12823
13019
  const lastBuiltStoryRef = useRef5(null);
12824
13020
  const snapshotRef = useRef5(snapshot);
@@ -12828,6 +13024,11 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
12828
13024
  () => scopeTagRegistryFactoryProp ? scopeTagRegistryFactoryProp() : createScopeTagRegistry(),
12829
13025
  [scopeTagRegistryFactoryProp]
12830
13026
  );
13027
+ const readPositionMap = useCallback2(() => {
13028
+ const canonical = positionMapRef.current;
13029
+ if (!canonical) return null;
13030
+ return createPredictedPositionMap(canonical, localEquivalentOpsRef.current);
13031
+ }, []);
12831
13032
  callbacksRef.current = {
12832
13033
  onInsertText: (text) => {
12833
13034
  pendingTypingProbeRef.current = startPerfProbe("typing");
@@ -12865,11 +13066,12 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
12865
13066
  },
12866
13067
  onSelectionChange: (sel) => {
12867
13068
  pendingSelectionProbeRef.current = startPerfProbe("selection");
13069
+ lastSelectionTargetRef.current = sel.editableTarget ? { anchor: sel.anchor, head: sel.head, editableTarget: sel.editableTarget } : null;
12868
13070
  props.onSelectionChange?.(
12869
13071
  snapshot.activeStory.kind === "main" ? sel : { ...sel, storyTarget: snapshot.activeStory }
12870
13072
  );
12871
13073
  },
12872
- getPositionMap: () => positionMapRef.current,
13074
+ getPositionMap: readPositionMap,
12873
13075
  isSelectionSyncSuppressed: () => suppressSelectionEchoRef.current,
12874
13076
  // Phase D.1 — forward contextmenu events to the host-supplied
12875
13077
  // chrome controller. Delegates through a ref-indirect so handler
@@ -13028,7 +13230,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13028
13230
  // returned by each plugin's `props.decorations`.
13029
13231
  createRuntimeDecorationPlugin()
13030
13232
  ];
13031
- }, [props.awareness, props.onCommentActivated, props.onRevisionActivated, props.onRevisionHovered]);
13233
+ }, [props.awareness, props.onCommentActivated, props.onRevisionActivated, props.onRevisionHovered, readPositionMap]);
13032
13234
  const applyDecorationProps = useCallback2(
13033
13235
  (view, positionMap) => {
13034
13236
  const inputs = {
@@ -13092,6 +13294,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13092
13294
  return () => {
13093
13295
  sessionRef.current = null;
13094
13296
  laneRef.current = null;
13297
+ localEquivalentOpsRef.current = [];
13095
13298
  };
13096
13299
  }, []);
13097
13300
  useEffect4(() => {
@@ -13120,6 +13323,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13120
13323
  if (!props.dispatchRuntimeCommand || !sessionRef.current) {
13121
13324
  laneRef.current = null;
13122
13325
  equivalentAckLedgerRef.current.clear();
13326
+ localEquivalentOpsRef.current = [];
13123
13327
  pendingRebuildScrollAnchorRef.current = null;
13124
13328
  return;
13125
13329
  }
@@ -13127,7 +13331,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13127
13331
  laneRef.current = createFastTextEditLane({
13128
13332
  session: sessionRef.current,
13129
13333
  getView: () => viewRef.current,
13130
- getPositionMap: () => positionMapRef.current,
13334
+ getPositionMap: readPositionMap,
13131
13335
  dispatchRuntimeCommand: props.dispatchRuntimeCommand,
13132
13336
  probe: {
13133
13337
  markPredicted(opId) {
@@ -13157,6 +13361,12 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13157
13361
  toRuntime
13158
13362
  );
13159
13363
  },
13364
+ onLocalEquivalentOp: (op) => {
13365
+ localEquivalentOpsRef.current = [...localEquivalentOpsRef.current, op];
13366
+ },
13367
+ onPredictedSelectionChange: (selection) => {
13368
+ callbacksRef.current?.onSelectionChange(selection);
13369
+ },
13160
13370
  onEquivalentAck: (ack) => {
13161
13371
  pendingRebuildScrollAnchorRef.current = null;
13162
13372
  if (ack.opId && ack.newRevisionToken && getTextCommandRefreshClass(ack) === "local-text-equivalent") {
@@ -13164,21 +13374,25 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13164
13374
  return;
13165
13375
  }
13166
13376
  equivalentAckLedgerRef.current.clear();
13377
+ localEquivalentOpsRef.current = [];
13167
13378
  },
13168
13379
  onAdjustedAck: (ack) => {
13169
13380
  equivalentAckLedgerRef.current.clear();
13381
+ localEquivalentOpsRef.current = [];
13170
13382
  pendingRebuildScrollAnchorRef.current = getTextCommandRefreshClass(ack) === "surface-only" ? "bounded-same-story" : null;
13171
13383
  },
13172
13384
  onRejectedAck: () => {
13173
13385
  equivalentAckLedgerRef.current.clear();
13386
+ localEquivalentOpsRef.current = [];
13174
13387
  pendingRebuildScrollAnchorRef.current = null;
13175
13388
  },
13176
13389
  onStructuralDivergence: () => {
13177
13390
  equivalentAckLedgerRef.current.clear();
13391
+ localEquivalentOpsRef.current = [];
13178
13392
  pendingRebuildScrollAnchorRef.current = null;
13179
13393
  }
13180
13394
  });
13181
- }, [props.dispatchRuntimeCommand, scopeTagRegistry]);
13395
+ }, [props.dispatchRuntimeCommand, readPositionMap, scopeTagRegistry]);
13182
13396
  useEffect4(() => {
13183
13397
  if (!mountRef.current || !surface) return;
13184
13398
  if (viewRef.current && documentBuildKeyRef.current === documentBuildKey) {
@@ -13191,6 +13405,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13191
13405
  documentBuildKeyRef.current = documentBuildKey;
13192
13406
  applyDecorationProps(viewRef.current, positionMapRef.current);
13193
13407
  equivalentAckLedgerRef.current.delete(snapshot.revisionToken);
13408
+ localEquivalentOpsRef.current = [];
13194
13409
  pendingRebuildScrollAnchorRef.current = null;
13195
13410
  lastBuiltStoryRef.current = snapshot.activeStory;
13196
13411
  if (pendingTypingProbeRef.current) {
@@ -13208,6 +13423,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13208
13423
  props.isPageWorkspace
13209
13424
  );
13210
13425
  positionMapRef.current = positionMap;
13426
+ localEquivalentOpsRef.current = [];
13211
13427
  recordPerfSample("pm.rebuild");
13212
13428
  incrementInvalidationCounter("pm.laneA.rebuilds");
13213
13429
  let appliedDecorationProps = false;
@@ -13298,10 +13514,14 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13298
13514
  if (!view || !surface || !positionMap) {
13299
13515
  return;
13300
13516
  }
13517
+ const selectionWithTarget = selectionWithLastMountedTarget(
13518
+ snapshot.selection,
13519
+ lastSelectionTargetRef.current
13520
+ );
13301
13521
  const nextSelection = createPMSelectionFromSnapshot(
13302
13522
  view.state.doc,
13303
13523
  positionMap,
13304
- snapshot.selection
13524
+ selectionWithTarget
13305
13525
  );
13306
13526
  if (view.state.selection.eq(nextSelection)) {
13307
13527
  return;
@@ -13584,6 +13804,18 @@ function createWorkflowMetadataSignature(metadata) {
13584
13804
  ].join(":")
13585
13805
  ).join("|");
13586
13806
  }
13807
+ function selectionWithLastMountedTarget(selection, lastSelectionTarget) {
13808
+ if (selection.editableTarget) {
13809
+ return selection;
13810
+ }
13811
+ if (lastSelectionTarget && selection.anchor === lastSelectionTarget.anchor && selection.head === lastSelectionTarget.head) {
13812
+ return {
13813
+ ...selection,
13814
+ editableTarget: lastSelectionTarget.editableTarget
13815
+ };
13816
+ }
13817
+ return selection;
13818
+ }
13587
13819
  function serializeAnchorSignature(anchor) {
13588
13820
  if (!anchor) {
13589
13821
  return "";
@@ -15385,7 +15617,7 @@ var WordReviewEditor = forwardRef3(
15385
15617
  undo: () => activeRuntime.undo(),
15386
15618
  redo: () => activeRuntime.redo(),
15387
15619
  replaceText: (text, target, formatting) => activeRuntime.replaceText(text, target, formatting),
15388
- insertFragment: (fragment, target) => activeRuntime.insertFragment(fragment, target),
15620
+ insertFragment: (fragment, target, editContext) => activeRuntime.insertFragment(fragment, target, editContext),
15389
15621
  copy: (target) => activeRuntime.copy(target),
15390
15622
  cut: (target) => activeRuntime.cut(target),
15391
15623
  getClipboardBuffer: () => activeRuntime.getClipboardBuffer(),