@beyondwork/docx-react-component 1.0.131 → 1.0.133

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 (100) hide show
  1. package/dist/api/public-types.cjs +837 -224
  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 +5 -3
  5. package/dist/api/v3.cjs +9679 -7492
  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-BMtONpgf.d.cts → canonical-document-CfZIc-fC.d.cts} +1 -1
  10. package/dist/{canonical-document-BMtONpgf.d.ts → canonical-document-CfZIc-fC.d.ts} +1 -1
  11. package/dist/{chunk-7G5GR3VV.js → chunk-224TSMEB.js} +635 -89
  12. package/dist/{chunk-YLL7MF5C.js → chunk-3JEE5RJU.js} +103 -135
  13. package/dist/{chunk-35RHOE6I.js → chunk-57HTKX3P.js} +10 -1162
  14. package/dist/{chunk-A66ZVUAT.js → chunk-5KTJKTNE.js} +236 -10
  15. package/dist/{chunk-THVM6EP5.js → chunk-CVSD3UNK.js} +1322 -102
  16. package/dist/{chunk-VRKK2CSZ.js → chunk-EFEW7BTT.js} +2 -2
  17. package/dist/{chunk-KNHMXKC6.js → chunk-INLRCC4N.js} +2 -2
  18. package/dist/{chunk-HYHCRMR7.js → chunk-KL4TZSZV.js} +1 -1
  19. package/dist/{chunk-T5YYFDZB.js → chunk-MQ5GAJ54.js} +68 -39
  20. package/dist/{chunk-CI2TD3T4.js → chunk-NJFKPDNG.js} +216 -2
  21. package/dist/{chunk-WZDKNF37.js → chunk-OTRVGNZQ.js} +2934 -1815
  22. package/dist/{chunk-4YCWECLZ.js → chunk-PZIEOEJZ.js} +1 -1
  23. package/dist/{chunk-PHMWH23E.js → chunk-QTRJLKR2.js} +1 -1
  24. package/dist/{chunk-QXKQPUOM.js → chunk-REFHJ2FN.js} +3 -3
  25. package/dist/{chunk-ZVC23LKV.js → chunk-RP76USJE.js} +1 -1
  26. package/dist/{chunk-3YCQM2RV.js → chunk-S3PEKX6H.js} +249 -45
  27. package/dist/{chunk-M7YRJX6V.js → chunk-T66OS7MN.js} +8 -3
  28. package/dist/{chunk-DGA7M77X.js → chunk-V2JF42SI.js} +2 -2
  29. package/dist/{chunk-Q7Y57KOK.js → chunk-WDDFU2N2.js} +2 -2
  30. package/dist/{chunk-A3GSNB4G.js → chunk-XBQFDBXE.js} +147 -13
  31. package/dist/{chunk-6TBLDBCL.js → chunk-ZFCZ7XXH.js} +1 -1
  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 +344 -20
  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 +344 -20
  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 +411 -58
  49. package/dist/core/commands/text-commands.d.cts +13 -2
  50. package/dist/core/commands/text-commands.d.ts +13 -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 +7199 -4004
  57. package/dist/index.d.cts +5 -5
  58. package/dist/index.d.ts +5 -5
  59. package/dist/index.js +814 -120
  60. package/dist/io/docx-session.cjs +7 -2
  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.d.cts +1 -1
  65. package/dist/legal.d.ts +1 -1
  66. package/dist/legal.js +3 -3
  67. package/dist/{loader-DiY_ZgKl.d.cts → loader-B2H99237.d.cts} +3 -3
  68. package/dist/{loader-B-aL5HGD.d.ts → loader-DfTjqVwn.d.ts} +3 -3
  69. package/dist/{public-types-gvubspUI.d.cts → public-types-B5lOUIrP.d.ts} +930 -338
  70. package/dist/{public-types-DyqnxxO9.d.ts → public-types-S8gTYwKo.d.cts} +930 -338
  71. package/dist/public-types.cjs +837 -224
  72. package/dist/public-types.d.cts +2 -2
  73. package/dist/public-types.d.ts +2 -2
  74. package/dist/public-types.js +5 -3
  75. package/dist/runtime/collab.d.cts +3 -3
  76. package/dist/runtime/collab.d.ts +3 -3
  77. package/dist/runtime/document-runtime.cjs +1403 -438
  78. package/dist/runtime/document-runtime.d.cts +2 -2
  79. package/dist/runtime/document-runtime.d.ts +2 -2
  80. package/dist/runtime/document-runtime.js +14 -14
  81. package/dist/{session-CDB0hohT.d.ts → session-CBDIOYXA.d.ts} +3 -3
  82. package/dist/{session-BUN6B-Vj.d.cts → session-CR2A1hGZ.d.cts} +3 -3
  83. package/dist/session.cjs +7 -2
  84. package/dist/session.d.cts +5 -5
  85. package/dist/session.d.ts +5 -5
  86. package/dist/session.js +5 -5
  87. package/dist/tailwind.cjs +905 -322
  88. package/dist/tailwind.d.cts +2 -2
  89. package/dist/tailwind.d.ts +2 -2
  90. package/dist/tailwind.js +7 -7
  91. package/dist/{types-VWH6CRvG.d.ts → types-B-90ywjU.d.ts} +2 -2
  92. package/dist/{types-C4bz3kDU.d.cts → types-yty2K-hk.d.cts} +2 -2
  93. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
  94. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
  95. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  96. package/dist/ui-tailwind.cjs +905 -322
  97. package/dist/ui-tailwind.d.cts +4 -3
  98. package/dist/ui-tailwind.d.ts +4 -3
  99. package/dist/ui-tailwind.js +7 -7
  100. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createSearchPlugin,
5
5
  performSearch,
6
6
  searchPluginKey
7
- } from "./chunk-6TBLDBCL.js";
7
+ } from "./chunk-ZFCZ7XXH.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-YLL7MF5C.js";
29
+ } from "./chunk-3JEE5RJU.js";
30
30
  import {
31
31
  applyParagraphStyleToDocument
32
32
  } from "./chunk-6EXNNAO6.js";
@@ -37,7 +37,7 @@ import {
37
37
  setSectionPageNumberingAtSectionIndex,
38
38
  updateSectionLayoutAtSectionIndex
39
39
  } from "./chunk-M6XR534O.js";
40
- import "./chunk-ZVC23LKV.js";
40
+ import "./chunk-RP76USJE.js";
41
41
  import {
42
42
  createRuntimeCollabSync,
43
43
  createRuntimeCommandAppliedBridge
@@ -45,7 +45,7 @@ import {
45
45
  import {
46
46
  insertPageBreak,
47
47
  insertTable
48
- } from "./chunk-QXKQPUOM.js";
48
+ } from "./chunk-REFHJ2FN.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-KNHMXKC6.js";
57
- import "./chunk-T5YYFDZB.js";
56
+ } from "./chunk-INLRCC4N.js";
57
+ import "./chunk-MQ5GAJ54.js";
58
58
  import {
59
59
  getTableStructureContext,
60
60
  tableStructureActionHandleForTarget
61
- } from "./chunk-Q7Y57KOK.js";
62
- import "./chunk-PHMWH23E.js";
61
+ } from "./chunk-WDDFU2N2.js";
62
+ import "./chunk-QTRJLKR2.js";
63
63
  import {
64
64
  MOUNTED_SURFACE_VIEWPORT_BLOCK_THRESHOLD,
65
65
  OverlayAnchorBridgeProvider,
@@ -83,18 +83,15 @@ import {
83
83
  resolveScopedChromePolicy,
84
84
  resolveScrollTopForAnchor,
85
85
  resolveSelectionToolRegistry,
86
+ sanitizeNumberingPictureBulletSrc,
86
87
  shouldRenderAbsoluteFloatingImageInPageOverlay,
87
88
  shouldRenderSelectionToolKind,
88
- shouldUseMountedSurfaceViewportCulling
89
- } from "./chunk-3YCQM2RV.js";
89
+ shouldUseMountedSurfaceViewportCulling,
90
+ useLayoutFacetRenderSignal
91
+ } from "./chunk-S3PEKX6H.js";
90
92
  import {
91
- PREDICTED_LANE_COUNTERS,
92
- createInertGeometryFacet,
93
- finishPerfProbe,
94
- incrementInvalidationCounter,
95
- recordPerfSample,
96
- startPerfProbe
97
- } from "./chunk-35RHOE6I.js";
93
+ createInertGeometryFacet
94
+ } from "./chunk-57HTKX3P.js";
98
95
  import {
99
96
  composeSeriesColor,
100
97
  computeStructuralHash,
@@ -108,12 +105,12 @@ import {
108
105
  resolveColor,
109
106
  tryReadLaycacheEnvelope,
110
107
  writeEnvelopeToOpcPackage
111
- } from "./chunk-WZDKNF37.js";
108
+ } from "./chunk-OTRVGNZQ.js";
112
109
  import {
113
110
  findTextMatches,
114
111
  parseCanonicalFragmentFromWordML,
115
112
  searchDocument
116
- } from "./chunk-7G5GR3VV.js";
113
+ } from "./chunk-224TSMEB.js";
117
114
  import {
118
115
  clearLocalCursorState,
119
116
  getCursorColorForUser,
@@ -123,23 +120,29 @@ import {
123
120
  import {
124
121
  resolveChromePreset,
125
122
  resolveChromeVisibilityForPreset
126
- } from "./chunk-CI2TD3T4.js";
123
+ } from "./chunk-NJFKPDNG.js";
127
124
  import {
128
125
  CAPABILITY_BY_ID,
129
126
  ISSUE_METADATA_ID,
130
127
  LAYCACHE_SCHEMA_VERSION,
131
128
  LAYOUT_ENGINE_VERSION,
132
129
  MetadataResolverMissingError,
130
+ PREDICTED_LANE_COUNTERS,
133
131
  REVIEW_ACTION_METADATA_ID,
134
132
  buildPagePreviewMaps,
135
133
  createEditorViewStateSnapshot,
136
134
  createLayoutEngine,
135
+ createPagePatchPlan,
137
136
  createScopeTagRegistry,
138
137
  createViewState,
139
138
  deriveCapabilities,
139
+ finishPerfProbe,
140
+ incrementInvalidationCounter,
141
+ recordPerfSample,
140
142
  sanitizeMarkdown,
141
- sha256Hex
142
- } from "./chunk-THVM6EP5.js";
143
+ sha256Hex,
144
+ startPerfProbe
145
+ } from "./chunk-CVSD3UNK.js";
143
146
  import "./chunk-OVLZQ6FZ.js";
144
147
  import "./chunk-QIO6V46H.js";
145
148
  import {
@@ -147,7 +150,7 @@ import {
147
150
  getStoryBlocks,
148
151
  replaceStoryBlocks,
149
152
  stableChartId
150
- } from "./chunk-A3GSNB4G.js";
153
+ } from "./chunk-XBQFDBXE.js";
151
154
  import "./chunk-SYQWQ6FE.js";
152
155
  import {
153
156
  createDefaultCanonicalDocument,
@@ -158,14 +161,14 @@ import {
158
161
  SessionNotOpenError,
159
162
  SessionNotWiredError,
160
163
  isReopenBarrier
161
- } from "./chunk-DGA7M77X.js";
164
+ } from "./chunk-V2JF42SI.js";
162
165
  import {
163
166
  createHmacSigner,
164
167
  createHmacVerifier,
165
168
  loadDocxSessionSync,
166
169
  signWorkflowPayloadXml,
167
170
  verifyWorkflowPayloadXml
168
- } from "./chunk-VRKK2CSZ.js";
171
+ } from "./chunk-EFEW7BTT.js";
169
172
  import {
170
173
  EDITOR_SESSION_STATE_VERSION,
171
174
  assertEditorSessionState,
@@ -174,8 +177,8 @@ import {
174
177
  editorSessionStateFromPersistedSnapshot,
175
178
  persistedSnapshotFromEditorSessionState,
176
179
  validateEditorSessionState
177
- } from "./chunk-4YCWECLZ.js";
178
- import "./chunk-M7YRJX6V.js";
180
+ } from "./chunk-PZIEOEJZ.js";
181
+ import "./chunk-T66OS7MN.js";
179
182
  import {
180
183
  decodePersistedSourcePackageBytes,
181
184
  hasValidPersistedSourcePackageDigest
@@ -187,7 +190,7 @@ import {
187
190
  collectEditableTargetRefs,
188
191
  createHeaderFooterStoryKey,
189
192
  createNoteStoryKey
190
- } from "./chunk-A66ZVUAT.js";
193
+ } from "./chunk-5KTJKTNE.js";
191
194
  import {
192
195
  readOpcPackage
193
196
  } from "./chunk-WUDSNHWF.js";
@@ -325,6 +328,9 @@ function applyListAwareTextCommand(context, command, deps) {
325
328
  if (!paragraphContext.atParagraphStart || !context.localSnapshot.selection.isCollapsed) {
326
329
  return null;
327
330
  }
331
+ if (shouldRouteListBoundaryJoinThroughTextCommand(context, paragraphContext)) {
332
+ return null;
333
+ }
328
334
  const result = backspaceAtListStart(
329
335
  context.localDocument,
330
336
  paragraphContext.paragraphIndex,
@@ -365,6 +371,39 @@ function listCommandTargetOptions(context, paragraphContext) {
365
371
  }
366
372
  return { editableTargets: [paragraphContext.paragraph.editableTarget] };
367
373
  }
374
+ function shouldRouteListBoundaryJoinThroughTextCommand(context, paragraphContext) {
375
+ const currentNumbering = paragraphContext.paragraph.numbering;
376
+ const currentTarget = paragraphContext.paragraph.editableTarget;
377
+ if (context.activeStory.kind !== "main" || !currentNumbering || currentNumbering.level > 0 || currentTarget?.listAddress?.operationScope !== "list-text") {
378
+ return false;
379
+ }
380
+ const paragraphs = collectSurfaceParagraphs(context.localSnapshot.surface?.blocks ?? []);
381
+ const previous = paragraphs[paragraphContext.paragraphIndex - 1];
382
+ const previousNumbering = previous?.numbering;
383
+ return Boolean(
384
+ previousNumbering && previousNumbering.numberingInstanceId === currentNumbering.numberingInstanceId && previousNumbering.level === currentNumbering.level
385
+ );
386
+ }
387
+ function collectSurfaceParagraphs(blocks, output = []) {
388
+ for (const block of blocks) {
389
+ if (block.kind === "paragraph") {
390
+ output.push(block);
391
+ continue;
392
+ }
393
+ if (block.kind === "table") {
394
+ for (const row of block.rows) {
395
+ for (const cell of row.cells) {
396
+ collectSurfaceParagraphs(cell.content, output);
397
+ }
398
+ }
399
+ continue;
400
+ }
401
+ if (block.kind === "sdt_block") {
402
+ collectSurfaceParagraphs(block.children, output);
403
+ }
404
+ }
405
+ return output;
406
+ }
368
407
  function createListMutationResult(result, selection, deps) {
369
408
  return {
370
409
  changed: result.affectedParagraphIndexes.length > 0,
@@ -401,13 +440,23 @@ function dispatchTextCommand(runtime, command, deps) {
401
440
  }
402
441
  switch (command.type) {
403
442
  case "insert-text":
404
- runtime.applyActiveStoryTextCommand({ type: "text.insert", text: command.text });
443
+ runtime.applyActiveStoryTextCommand({
444
+ type: "text.insert",
445
+ text: command.text,
446
+ ...mountedListTextTarget(context, deps)
447
+ });
405
448
  return;
406
449
  case "delete-backward":
407
- runtime.applyActiveStoryTextCommand({ type: "text.delete-backward" });
450
+ runtime.applyActiveStoryTextCommand({
451
+ type: "text.delete-backward",
452
+ ...mountedListTextTarget(context, deps)
453
+ });
408
454
  return;
409
455
  case "delete-forward":
410
- runtime.applyActiveStoryTextCommand({ type: "text.delete-forward" });
456
+ runtime.applyActiveStoryTextCommand({
457
+ type: "text.delete-forward",
458
+ ...mountedListTextTarget(context, deps)
459
+ });
411
460
  return;
412
461
  case "insert-tab":
413
462
  runtime.applyActiveStoryTextCommand({ type: "text.insert-tab" });
@@ -416,13 +465,30 @@ function dispatchTextCommand(runtime, command, deps) {
416
465
  runtime.applyActiveStoryTextCommand({ type: "text.outdent-tab" });
417
466
  return;
418
467
  case "insert-hard-break":
419
- runtime.applyActiveStoryTextCommand({ type: "text.insert-hard-break" });
468
+ runtime.applyActiveStoryTextCommand({
469
+ type: "text.insert-hard-break",
470
+ ...mountedListTextTarget(context, deps)
471
+ });
420
472
  return;
421
473
  case "split-paragraph":
422
- runtime.applyActiveStoryTextCommand({ type: "paragraph.split" });
474
+ runtime.applyActiveStoryTextCommand({
475
+ type: "paragraph.split",
476
+ ...mountedListTextTarget(context, deps)
477
+ });
423
478
  return;
424
479
  }
425
480
  }
481
+ function mountedListTextTarget(context, deps) {
482
+ const selectionTarget = context.localSnapshot.selection.editableTarget;
483
+ if (selectionTarget?.listAddress?.operationScope === "list-text") {
484
+ return { editableTarget: selectionTarget };
485
+ }
486
+ const paragraphTarget = deps.resolveActiveParagraphContext(context.localSnapshot)?.paragraph.editableTarget;
487
+ if (paragraphTarget?.listAddress?.operationScope === "list-text") {
488
+ return { editableTarget: paragraphTarget };
489
+ }
490
+ return {};
491
+ }
426
492
  function getMountedTextCommandName(command) {
427
493
  switch (command.type) {
428
494
  case "insert-text":
@@ -5331,7 +5397,7 @@ var editorSchema = new Schema({
5331
5397
  if (typeof numberingMarkerStartTwips === "number") {
5332
5398
  attrs["data-numbering-marker-start-twips"] = String(numberingMarkerStartTwips);
5333
5399
  }
5334
- const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth;
5400
+ const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth ?? node.attrs.indentHanging;
5335
5401
  if (typeof _numberingMarkerWidthTwips === "number" && _numberingMarkerWidthTwips > 0) {
5336
5402
  attrs["data-numbering-marker-width-twips"] = String(
5337
5403
  _numberingMarkerWidthTwips
@@ -5347,7 +5413,9 @@ var editorSchema = new Schema({
5347
5413
  const numberingMarkerWidth = node.attrs.numberingMarkerWidth;
5348
5414
  const numberingMarkerStart = node.attrs.numberingMarkerStart;
5349
5415
  const numberingMarkerJustification = node.attrs.numberingMarkerJustification;
5350
- const numberingPicBulletSrc = node.attrs.numberingPicBulletSrc;
5416
+ const numberingPicBulletSrc = sanitizeNumberingPictureBulletSrc(
5417
+ node.attrs.numberingPicBulletSrc
5418
+ );
5351
5419
  const children = [];
5352
5420
  if (pageBreak) {
5353
5421
  attrs["data-page-break-before"] = "true";
@@ -5403,6 +5471,7 @@ var editorSchema = new Schema({
5403
5471
  {
5404
5472
  class: baseClasses.join(" "),
5405
5473
  contenteditable: "false",
5474
+ "data-numbering-marker": "true",
5406
5475
  "data-numbering-prefix": numberingPicBulletSrc ? "" : numberingPrefix ?? "",
5407
5476
  ...typeof numberingLevel === "number" ? { "data-numbering-level": String(numberingLevel) } : {},
5408
5477
  ...numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {},
@@ -5774,13 +5843,17 @@ var editorSchema = new Schema({
5774
5843
  },
5775
5844
  toDOM(node) {
5776
5845
  const refreshStatus = node.attrs.refreshStatus;
5846
+ const fieldTarget = node.attrs.fieldTarget;
5777
5847
  const statusClass = refreshStatus === "current" ? "text-blue-700 bg-blue-50 border-blue-200" : refreshStatus === "unresolvable" ? "text-amber-800 bg-amber-50 border-amber-200" : "text-slate-700 bg-slate-50 border-slate-200";
5778
5848
  return [
5779
5849
  "span",
5780
5850
  {
5781
5851
  class: `inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs border ${statusClass}`,
5782
5852
  "data-node-type": "field_ref_atom",
5853
+ "data-generated-field": "true",
5783
5854
  "data-field-family": node.attrs.fieldFamily,
5855
+ ...fieldTarget ? { "data-field-target": fieldTarget } : {},
5856
+ "data-field-refresh-status": refreshStatus,
5784
5857
  title: node.attrs.instruction
5785
5858
  },
5786
5859
  node.attrs.label || "Field"
@@ -6937,6 +7010,28 @@ function paragraphNeighborDigest(p) {
6937
7010
  function paragraphExternalKey(prev, next, mediaPreviewsId, showUnsupportedObjectPreviews, renderAbsoluteFloatingObjectsInPageOverlay) {
6938
7011
  return `p|${paragraphNeighborDigest(prev)}|${paragraphNeighborDigest(next)}|m${mediaPreviewsId}|${showUnsupportedObjectPreviews ? 1 : 0}|${renderAbsoluteFloatingObjectsInPageOverlay ? 1 : 0}`;
6939
7012
  }
7013
+ function topLevelBlockExternalKey(input) {
7014
+ const common = `m${input.mediaPreviewsId}|${input.showUnsupportedObjectPreviews ? 1 : 0}|${input.renderAbsoluteFloatingObjectsInPageOverlay ? 1 : 0}`;
7015
+ if (input.block.kind === "paragraph") {
7016
+ return paragraphExternalKey(
7017
+ input.previousParagraph,
7018
+ input.nextParagraph,
7019
+ input.mediaPreviewsId,
7020
+ input.showUnsupportedObjectPreviews,
7021
+ input.renderAbsoluteFloatingObjectsInPageOverlay
7022
+ );
7023
+ }
7024
+ if (input.block.kind === "table") {
7025
+ return `t|${common}`;
7026
+ }
7027
+ if (input.block.kind === "sdt_block") {
7028
+ return `sdt|${common}`;
7029
+ }
7030
+ if (input.block.kind === "opaque_block") {
7031
+ return `opaque|${input.showUnsupportedObjectPreviews ? 1 : 0}`;
7032
+ }
7033
+ return null;
7034
+ }
6940
7035
  function cacheLookup(blockRef, externalKey) {
6941
7036
  const bucket = pmNodeCache.get(blockRef);
6942
7037
  if (!bucket) return null;
@@ -7103,69 +7198,77 @@ function buildPMBlocks(blocks, mediaPreviews, showUnsupportedObjectPreviews, ren
7103
7198
  const nextBlock = blocks[index + 1];
7104
7199
  const previousParagraph = previousBlock?.kind === "paragraph" ? previousBlock : null;
7105
7200
  const nextParagraph = nextBlock?.kind === "paragraph" ? nextBlock : null;
7106
- if (block.kind === "paragraph") {
7107
- const ref = blockRefs?.[index] ?? null;
7108
- if (ref !== null) {
7109
- const extKey = paragraphExternalKey(
7110
- previousParagraph,
7111
- nextParagraph,
7112
- mediaId,
7113
- showUnsupportedObjectPreviews,
7114
- renderAbsoluteFloatingObjectsInPageOverlay
7115
- );
7116
- const cached = cacheLookup(ref, extKey);
7117
- if (cached) {
7118
- identityCacheHits += 1;
7119
- nodes.push(cached);
7120
- continue;
7121
- }
7122
- identityCacheMisses += 1;
7123
- const built = buildParagraph(
7124
- block,
7125
- previousParagraph,
7126
- nextParagraph,
7127
- mediaPreviews,
7128
- showUnsupportedObjectPreviews,
7129
- renderAbsoluteFloatingObjectsInPageOverlay
7130
- );
7131
- cacheStore(ref, extKey, built);
7132
- nodes.push(built);
7201
+ const ref = blockRefs?.[index] ?? null;
7202
+ const externalKey = ref === null ? null : topLevelBlockExternalKey({
7203
+ block,
7204
+ previousParagraph,
7205
+ nextParagraph,
7206
+ mediaPreviewsId: mediaId,
7207
+ showUnsupportedObjectPreviews,
7208
+ renderAbsoluteFloatingObjectsInPageOverlay
7209
+ });
7210
+ if (ref !== null && externalKey !== null) {
7211
+ const cached = cacheLookup(ref, externalKey);
7212
+ if (cached) {
7213
+ identityCacheHits += 1;
7214
+ nodes.push(cached);
7133
7215
  continue;
7134
7216
  }
7135
- nodes.push(
7136
- buildParagraph(
7137
- block,
7138
- previousParagraph,
7139
- nextParagraph,
7140
- mediaPreviews,
7141
- showUnsupportedObjectPreviews,
7142
- renderAbsoluteFloatingObjectsInPageOverlay
7143
- )
7144
- );
7145
- } else if (block.kind === "table") {
7146
- nodes.push(
7147
- buildTable(
7148
- block,
7149
- mediaPreviews,
7150
- showUnsupportedObjectPreviews,
7151
- renderAbsoluteFloatingObjectsInPageOverlay
7152
- )
7153
- );
7154
- } else if (block.kind === "sdt_block") {
7155
- nodes.push(
7156
- buildSdtBlock(
7157
- block,
7158
- mediaPreviews,
7159
- showUnsupportedObjectPreviews,
7160
- renderAbsoluteFloatingObjectsInPageOverlay
7161
- )
7217
+ identityCacheMisses += 1;
7218
+ const built = buildPMBlock(
7219
+ block,
7220
+ previousParagraph,
7221
+ nextParagraph,
7222
+ mediaPreviews,
7223
+ showUnsupportedObjectPreviews,
7224
+ renderAbsoluteFloatingObjectsInPageOverlay
7162
7225
  );
7163
- } else {
7164
- nodes.push(buildOpaqueBlock(block, showUnsupportedObjectPreviews));
7226
+ cacheStore(ref, externalKey, built);
7227
+ nodes.push(built);
7228
+ continue;
7165
7229
  }
7230
+ nodes.push(
7231
+ buildPMBlock(
7232
+ block,
7233
+ previousParagraph,
7234
+ nextParagraph,
7235
+ mediaPreviews,
7236
+ showUnsupportedObjectPreviews,
7237
+ renderAbsoluteFloatingObjectsInPageOverlay
7238
+ )
7239
+ );
7166
7240
  }
7167
7241
  return nodes;
7168
7242
  }
7243
+ function buildPMBlock(block, previousParagraph, nextParagraph, mediaPreviews, showUnsupportedObjectPreviews, renderAbsoluteFloatingObjectsInPageOverlay) {
7244
+ if (block.kind === "paragraph") {
7245
+ return buildParagraph(
7246
+ block,
7247
+ previousParagraph,
7248
+ nextParagraph,
7249
+ mediaPreviews,
7250
+ showUnsupportedObjectPreviews,
7251
+ renderAbsoluteFloatingObjectsInPageOverlay
7252
+ );
7253
+ }
7254
+ if (block.kind === "table") {
7255
+ return buildTable(
7256
+ block,
7257
+ mediaPreviews,
7258
+ showUnsupportedObjectPreviews,
7259
+ renderAbsoluteFloatingObjectsInPageOverlay
7260
+ );
7261
+ }
7262
+ if (block.kind === "sdt_block") {
7263
+ return buildSdtBlock(
7264
+ block,
7265
+ mediaPreviews,
7266
+ showUnsupportedObjectPreviews,
7267
+ renderAbsoluteFloatingObjectsInPageOverlay
7268
+ );
7269
+ }
7270
+ return buildOpaqueBlock(block, showUnsupportedObjectPreviews);
7271
+ }
7169
7272
  function buildParagraph(block, previousParagraph, nextParagraph, mediaPreviews, showUnsupportedObjectPreviews, renderAbsoluteFloatingObjectsInPageOverlay) {
7170
7273
  const content = [];
7171
7274
  const paragraphLayout = resolveParagraphLayout(block);
@@ -7242,7 +7345,7 @@ function buildParagraph(block, previousParagraph, nextParagraph, mediaPreviews,
7242
7345
  numberingPicBulletSrc: (() => {
7243
7346
  const mediaId = block.resolvedNumbering?.picBulletMediaId;
7244
7347
  if (!mediaId) return null;
7245
- return mediaPreviews[mediaId]?.src ?? null;
7348
+ return sanitizeNumberingPictureBulletSrc(mediaPreviews[mediaId]?.src);
7246
7349
  })(),
7247
7350
  shadingFill: block.shading?.fill ?? cascade?.shading?.fill ?? null,
7248
7351
  borderTop: block.borders?.top ?? cascadeBorders?.top ?? null,
@@ -7792,9 +7895,9 @@ function resolveDropSelectionFromCoordinates(view, event) {
7792
7895
  if (selection.eq(view.state.selection)) return;
7793
7896
  view.dispatch(view.state.tr.setSelection(selection));
7794
7897
  }
7795
- function applyPasteSegmentsToCallbacks(segments, callbacks) {
7898
+ function applyPasteSegmentsToCallbacks(segments, callbacks, context) {
7796
7899
  if (callbacks.onPastePlainTextFragment && callbacks.shouldPastePlainTextAsFragment?.() !== false && segments.some((seg) => seg.kind === "split") && segments.some((seg) => seg.kind === "text" && seg.value.length > 0)) {
7797
- callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments));
7900
+ callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments), context);
7798
7901
  return;
7799
7902
  }
7800
7903
  for (const seg of segments) {
@@ -7864,6 +7967,34 @@ function applyContextMenuEvent(callbacks, event) {
7864
7967
  return false;
7865
7968
  }
7866
7969
  }
7970
+ function elementFromEventTarget(target) {
7971
+ if (!target) return null;
7972
+ const maybeElement = target;
7973
+ if (typeof maybeElement.closest === "function") return maybeElement;
7974
+ const maybeNode = target;
7975
+ return maybeNode.parentElement ?? null;
7976
+ }
7977
+ function applyNumberingMarkerClick(view, event) {
7978
+ const targetElement = elementFromEventTarget(event.target);
7979
+ const marker = targetElement?.closest('[data-numbering-marker="true"]');
7980
+ if (!marker) return false;
7981
+ const paragraph = marker.closest('p[data-numbered="true"]');
7982
+ if (!paragraph) return false;
7983
+ const content = paragraph.querySelector(".pm-paragraph-content");
7984
+ if (!content) return false;
7985
+ let contentStart;
7986
+ try {
7987
+ contentStart = view.posAtDOM(content, 0);
7988
+ } catch {
7989
+ return false;
7990
+ }
7991
+ const docSize = view.state.doc.content.size;
7992
+ const boundedStart = Math.max(0, Math.min(contentStart, docSize));
7993
+ const selection = TextSelection2.near(view.state.doc.resolve(boundedStart), 1);
7994
+ event.preventDefault();
7995
+ view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
7996
+ return true;
7997
+ }
7867
7998
  var bridgeKey = new PluginKey("command-bridge");
7868
7999
  function createSelectionSyncPlugin(callbacks) {
7869
8000
  return new Plugin({
@@ -8001,6 +8132,9 @@ function createCommandBridgePlugins(callbacks, options) {
8001
8132
  // behavior (back-compat).
8002
8133
  contextmenu(_view, event) {
8003
8134
  return applyContextMenuEvent(callbacks, event);
8135
+ },
8136
+ click(view, event) {
8137
+ return applyNumberingMarkerClick(view, event);
8004
8138
  }
8005
8139
  },
8006
8140
  handleTextInput(_view, _from, _to, text) {
@@ -8027,10 +8161,12 @@ function createCommandBridgePlugins(callbacks, options) {
8027
8161
  // through to Tier A so the user isn't left with a silent no-op.
8028
8162
  handlePaste(_view, event) {
8029
8163
  if (isComposing) return true;
8030
- if (!isPmEditTargetEditable(_view.state, callbacks.getPositionMap())) {
8164
+ const positionMap = callbacks.getPositionMap();
8165
+ if (!isPmEditTargetEditable(_view.state, positionMap)) {
8031
8166
  callbacks.onBlockedInput?.("paste", NON_EDITABLE_INPUT_MESSAGE);
8032
8167
  return true;
8033
8168
  }
8169
+ const editableTarget = resolveCurrentEditableTarget(_view.state, positionMap);
8034
8170
  const clipboard = event.clipboardData;
8035
8171
  if (!clipboard) {
8036
8172
  callbacks.onBlockedInput?.("paste", "Clipboard data was not available.");
@@ -8052,7 +8188,11 @@ function createCommandBridgePlugins(callbacks, options) {
8052
8188
  if (wordml) {
8053
8189
  const parsed = options.pasteFragmentParser.parseWordML(wordml);
8054
8190
  if (parsed.ok && parsed.fragment.blocks.length > 0) {
8055
- callbacks.onPasteFragment({ fragment: parsed.fragment, source: "wordml" });
8191
+ callbacks.onPasteFragment({
8192
+ fragment: parsed.fragment,
8193
+ source: "wordml",
8194
+ ...editableTarget ? { editableTarget } : {}
8195
+ });
8056
8196
  return true;
8057
8197
  }
8058
8198
  }
@@ -8062,7 +8202,11 @@ function createCommandBridgePlugins(callbacks, options) {
8062
8202
  if (htmlPayload && htmlPayload.trim().length > 0) {
8063
8203
  const parsed = options.pasteFragmentParser.parseHtml(htmlPayload);
8064
8204
  if (parsed.ok && parsed.fragment.blocks.length > 0) {
8065
- callbacks.onPasteFragment({ fragment: parsed.fragment, source: "html" });
8205
+ callbacks.onPasteFragment({
8206
+ fragment: parsed.fragment,
8207
+ source: "html",
8208
+ ...editableTarget ? { editableTarget } : {}
8209
+ });
8066
8210
  return true;
8067
8211
  }
8068
8212
  }
@@ -8076,7 +8220,11 @@ function createCommandBridgePlugins(callbacks, options) {
8076
8220
  return true;
8077
8221
  }
8078
8222
  const segments = extractPlainTextSegments(plain);
8079
- applyPasteSegmentsToCallbacks(segments, callbacks);
8223
+ applyPasteSegmentsToCallbacks(
8224
+ segments,
8225
+ callbacks,
8226
+ editableTarget ? { editableTarget } : void 0
8227
+ );
8080
8228
  callbacks.onPasteApplied?.({
8081
8229
  segmentCount: segments.length,
8082
8230
  charCount: totalTextCharCount(segments),
@@ -8137,7 +8285,11 @@ function createCommandBridgePlugins(callbacks, options) {
8137
8285
  return true;
8138
8286
  }
8139
8287
  const segments = extractPlainTextSegments(plain);
8140
- applyPasteSegmentsToCallbacks(segments, callbacks);
8288
+ applyPasteSegmentsToCallbacks(
8289
+ segments,
8290
+ callbacks,
8291
+ editableTarget ? { editableTarget } : void 0
8292
+ );
8141
8293
  callbacks.onPasteApplied?.({
8142
8294
  segmentCount: segments.length,
8143
8295
  charCount: totalTextCharCount(segments),
@@ -9674,6 +9826,7 @@ function createSurfaceDecorationKey(input) {
9674
9826
  showTrackedChanges: input.showTrackedChanges,
9675
9827
  suggestionsEnabled: input.suggestionsEnabled ?? false,
9676
9828
  canEdit: input.canEdit,
9829
+ pageBreakRevision: input.pageBreakRevision ?? 0,
9677
9830
  activeCommentId: input.activeCommentId ?? null,
9678
9831
  activeRevisionId: input.activeRevisionId ?? null,
9679
9832
  workflowScopeSignature: input.workflowScopeSignature ?? null,
@@ -9686,6 +9839,375 @@ function createSurfaceDecorationKey(input) {
9686
9839
  });
9687
9840
  }
9688
9841
 
9842
+ // src/ui-tailwind/editor-surface/pm-page-body-patch.ts
9843
+ function resolvePmPageBodyPatchPlan(input) {
9844
+ const membershipChangedPageIds = [
9845
+ ...input.patchPlan.addedPages,
9846
+ ...input.patchPlan.removedPages
9847
+ ];
9848
+ if (membershipChangedPageIds.length > 0 && input.currentDoc.childCount !== input.nextDoc.childCount) {
9849
+ return {
9850
+ status: "fallback",
9851
+ reason: "page-membership-change",
9852
+ pageIds: membershipChangedPageIds
9853
+ };
9854
+ }
9855
+ if (input.currentDoc.childCount !== input.previousSurface.blocks.length || input.nextDoc.childCount !== input.nextSurface.blocks.length) {
9856
+ return {
9857
+ status: "fallback",
9858
+ reason: "doc-child-count-mismatch",
9859
+ pageIds: input.realization.patchPageIds
9860
+ };
9861
+ }
9862
+ const changedEntriesByPageId = new Map(
9863
+ input.patchPlan.changedPages.map((entry) => [entry.pageId, entry])
9864
+ );
9865
+ const rawSpans = [];
9866
+ const skippedPageIds = [];
9867
+ for (const pageId of input.realization.patchPageIds) {
9868
+ const entry = changedEntriesByPageId.get(pageId);
9869
+ if (!entry || !entry.regionChanges.includes("body") || entry.fragmentChanges.length === 0) {
9870
+ skippedPageIds.push(pageId);
9871
+ continue;
9872
+ }
9873
+ const previousPage = input.previousFrame.pages.find((page) => page.page.pageId === pageId);
9874
+ const nextPage = input.nextFrame.pages.find((page) => page.page.pageId === pageId);
9875
+ if (!previousPage || !nextPage) {
9876
+ return { status: "fallback", reason: "page-not-found", pageIds: [pageId] };
9877
+ }
9878
+ const previousRange = findBlockIndexRangeForPage(
9879
+ input.previousSurface.blocks,
9880
+ previousPage.page
9881
+ );
9882
+ const nextRange = findBlockIndexRangeForPage(input.nextSurface.blocks, nextPage.page);
9883
+ if (!previousRange || !nextRange) {
9884
+ return {
9885
+ status: "fallback",
9886
+ reason: "page-has-no-block-range",
9887
+ pageIds: [pageId]
9888
+ };
9889
+ }
9890
+ const nestedSpan = resolveNestedPatchSpan({
9891
+ pageId,
9892
+ changedFragmentIds: entry.fragmentChanges,
9893
+ previousSurface: input.previousSurface,
9894
+ nextSurface: input.nextSurface,
9895
+ currentDoc: input.currentDoc,
9896
+ nextDoc: input.nextDoc,
9897
+ previousRange,
9898
+ nextRange
9899
+ });
9900
+ if (nestedSpan.status === "fallback") {
9901
+ return {
9902
+ status: "fallback",
9903
+ reason: nestedSpan.reason,
9904
+ pageIds: [pageId]
9905
+ };
9906
+ }
9907
+ if (nestedSpan.status === "nested") {
9908
+ rawSpans.push(nestedSpan.span);
9909
+ continue;
9910
+ }
9911
+ const topLevelSpans = resolveTopLevelFragmentPatchSpans({
9912
+ pageId,
9913
+ changedFragmentIds: entry.fragmentChanges,
9914
+ previousSurface: input.previousSurface,
9915
+ nextSurface: input.nextSurface,
9916
+ previousRange,
9917
+ nextRange
9918
+ });
9919
+ rawSpans.push(
9920
+ ...topLevelSpans ?? [
9921
+ {
9922
+ pageIds: [pageId],
9923
+ fromBlockIndex: previousRange.first,
9924
+ toBlockIndex: previousRange.last + 1,
9925
+ nextFromBlockIndex: nextRange.first,
9926
+ nextToBlockIndex: nextRange.last + 1
9927
+ }
9928
+ ]
9929
+ );
9930
+ }
9931
+ if (rawSpans.length === 0) {
9932
+ if (membershipChangedPageIds.length > 0 && !input.currentDoc.eq(input.nextDoc)) {
9933
+ return {
9934
+ status: "fallback",
9935
+ reason: "page-membership-change",
9936
+ pageIds: membershipChangedPageIds
9937
+ };
9938
+ }
9939
+ return {
9940
+ status: "fallback",
9941
+ reason: "no-body-fragment-changes",
9942
+ pageIds: skippedPageIds
9943
+ };
9944
+ }
9945
+ const spans = mergePatchSpans(rawSpans).map((span) => ({
9946
+ ...span,
9947
+ fromPm: span.fromPm ?? topLevelPositionForBlockIndex(input.currentDoc, span.fromBlockIndex),
9948
+ toPm: span.toPm ?? topLevelPositionForBlockIndex(input.currentDoc, span.toBlockIndex),
9949
+ nextFromPm: span.nextFromPm ?? topLevelPositionForBlockIndex(input.nextDoc, span.nextFromBlockIndex),
9950
+ nextToPm: span.nextToPm ?? topLevelPositionForBlockIndex(input.nextDoc, span.nextToBlockIndex)
9951
+ }));
9952
+ const selection = input.currentSelection;
9953
+ if (selection) {
9954
+ const intersecting = spans.find(
9955
+ (span) => selectionIntersectsSpan(selection, span.fromPm, span.toPm)
9956
+ );
9957
+ if (intersecting) {
9958
+ return {
9959
+ status: "fallback",
9960
+ reason: "selection-intersects-replacement",
9961
+ pageIds: intersecting.pageIds
9962
+ };
9963
+ }
9964
+ }
9965
+ return {
9966
+ status: "patch",
9967
+ spans,
9968
+ skippedPageIds,
9969
+ replacedBlockCount: spans.reduce(
9970
+ (total, span) => total + (span.replacedBlockCount ?? span.toBlockIndex - span.fromBlockIndex),
9971
+ 0
9972
+ )
9973
+ };
9974
+ }
9975
+ function resolveNestedPatchSpan(input) {
9976
+ if (input.previousRange.first !== input.previousRange.last || input.nextRange.first !== input.nextRange.last || input.previousRange.first !== input.nextRange.first) {
9977
+ return { status: "top-level" };
9978
+ }
9979
+ const topIndex = input.previousRange.first;
9980
+ const previousTop = input.previousSurface.blocks[topIndex];
9981
+ const nextTop = input.nextSurface.blocks[topIndex];
9982
+ if (!previousTop || !nextTop || previousTop.kind !== nextTop.kind) {
9983
+ return { status: "top-level" };
9984
+ }
9985
+ if (previousTop.kind !== "table" && previousTop.kind !== "sdt_block") {
9986
+ return { status: "top-level" };
9987
+ }
9988
+ const changedIds = input.changedFragmentIds.filter(
9989
+ (id) => id !== "<added>" && id !== "<removed>"
9990
+ );
9991
+ if (changedIds.length !== input.changedFragmentIds.length) {
9992
+ return { status: "top-level" };
9993
+ }
9994
+ if (changedIds.includes(previousTop.blockId) || changedIds.includes(nextTop.blockId)) {
9995
+ return { status: "top-level" };
9996
+ }
9997
+ if (changedIds.length === 0) {
9998
+ return { status: "top-level" };
9999
+ }
10000
+ const previousLocated = changedIds.map(
10001
+ (id) => findNestedBlockSpanById(input.previousSurface.blocks, input.currentDoc, id)
10002
+ );
10003
+ const nextLocated = changedIds.map(
10004
+ (id) => findNestedBlockSpanById(input.nextSurface.blocks, input.nextDoc, id)
10005
+ );
10006
+ if (previousLocated.some((span) => !span) || nextLocated.some((span) => !span)) {
10007
+ return { status: "fallback", reason: "nested-span-unavailable" };
10008
+ }
10009
+ if (previousLocated.some(isUnpatchableVerticalMergeContinuationSpan) || nextLocated.some(isUnpatchableVerticalMergeContinuationSpan)) {
10010
+ return { status: "fallback", reason: "split-row-continuation" };
10011
+ }
10012
+ const previousSpans = previousLocated;
10013
+ const nextSpans = nextLocated;
10014
+ const previousKinds = new Set(previousSpans.map((span) => span.block.kind));
10015
+ const nextKinds = new Set(nextSpans.map((span) => span.block.kind));
10016
+ if (previousKinds.size !== nextKinds.size || [...previousKinds].some((kind) => !nextKinds.has(kind))) {
10017
+ return { status: "fallback", reason: "nested-span-unavailable" };
10018
+ }
10019
+ return {
10020
+ status: "nested",
10021
+ span: {
10022
+ pageIds: [input.pageId],
10023
+ fromBlockIndex: topIndex,
10024
+ toBlockIndex: topIndex + 1,
10025
+ nextFromBlockIndex: topIndex,
10026
+ nextToBlockIndex: topIndex + 1,
10027
+ fromPm: Math.min(...previousSpans.map((span) => span.fromPm)),
10028
+ toPm: Math.max(...previousSpans.map((span) => span.toPm)),
10029
+ nextFromPm: Math.min(...nextSpans.map((span) => span.fromPm)),
10030
+ nextToPm: Math.max(...nextSpans.map((span) => span.toPm)),
10031
+ replacedBlockCount: previousSpans.length
10032
+ }
10033
+ };
10034
+ }
10035
+ function isUnpatchableVerticalMergeContinuationSpan(span) {
10036
+ return Boolean(
10037
+ span?.insideVerticalMergeContinuation && span.fromPm >= span.toPm
10038
+ );
10039
+ }
10040
+ function resolveTopLevelFragmentPatchSpans(input) {
10041
+ const changedIds = uniqueStableFragmentIds(input.changedFragmentIds);
10042
+ if (changedIds.length !== input.changedFragmentIds.length || changedIds.length === 0) {
10043
+ return null;
10044
+ }
10045
+ const spans = [];
10046
+ for (const blockId of changedIds) {
10047
+ const previousIndex = findTopLevelBlockIndexById(
10048
+ input.previousSurface.blocks,
10049
+ input.previousRange,
10050
+ blockId
10051
+ );
10052
+ const nextIndex = findTopLevelBlockIndexById(
10053
+ input.nextSurface.blocks,
10054
+ input.nextRange,
10055
+ blockId
10056
+ );
10057
+ if (previousIndex === null || nextIndex === null) {
10058
+ return null;
10059
+ }
10060
+ const previousBlock = input.previousSurface.blocks[previousIndex];
10061
+ const nextBlock = input.nextSurface.blocks[nextIndex];
10062
+ if (!previousBlock || !nextBlock || previousBlock.kind !== nextBlock.kind) {
10063
+ return null;
10064
+ }
10065
+ spans.push({
10066
+ pageIds: [input.pageId],
10067
+ fromBlockIndex: previousIndex,
10068
+ toBlockIndex: previousIndex + 1,
10069
+ nextFromBlockIndex: nextIndex,
10070
+ nextToBlockIndex: nextIndex + 1,
10071
+ replacedBlockCount: 1
10072
+ });
10073
+ }
10074
+ return spans;
10075
+ }
10076
+ function uniqueStableFragmentIds(ids) {
10077
+ const result = [];
10078
+ const seen = /* @__PURE__ */ new Set();
10079
+ for (const id of ids) {
10080
+ if (id === "<added>" || id === "<removed>") continue;
10081
+ if (seen.has(id)) continue;
10082
+ seen.add(id);
10083
+ result.push(id);
10084
+ }
10085
+ return result;
10086
+ }
10087
+ function findTopLevelBlockIndexById(blocks, range, blockId) {
10088
+ for (let index = range.first; index <= range.last; index += 1) {
10089
+ if (blocks[index]?.blockId === blockId) return index;
10090
+ }
10091
+ return null;
10092
+ }
10093
+ function findNestedBlockSpanById(blocks, doc, blockId) {
10094
+ return findBlockSpanByIdInContainer({
10095
+ blocks,
10096
+ containerNode: doc,
10097
+ contentStartPm: 1,
10098
+ blockId,
10099
+ allowCurrentLevelMatch: false,
10100
+ insideVerticalMergeContinuation: false
10101
+ });
10102
+ }
10103
+ function findBlockSpanByIdInContainer(input) {
10104
+ let cursor = input.contentStartPm;
10105
+ for (let blockIndex = 0; blockIndex < input.blocks.length; blockIndex += 1) {
10106
+ const block = input.blocks[blockIndex];
10107
+ const childNode = input.containerNode.child(blockIndex);
10108
+ const fromPm = cursor;
10109
+ const toPm = fromPm + childNode.nodeSize;
10110
+ if (input.allowCurrentLevelMatch && block.blockId === input.blockId) {
10111
+ return {
10112
+ fromPm,
10113
+ toPm,
10114
+ blockIndex,
10115
+ block,
10116
+ insideVerticalMergeContinuation: input.insideVerticalMergeContinuation
10117
+ };
10118
+ }
10119
+ if (block.kind === "sdt_block") {
10120
+ const found = findBlockSpanByIdInContainer({
10121
+ blocks: block.children,
10122
+ containerNode: childNode,
10123
+ contentStartPm: fromPm + 1,
10124
+ blockId: input.blockId,
10125
+ allowCurrentLevelMatch: true,
10126
+ insideVerticalMergeContinuation: input.insideVerticalMergeContinuation
10127
+ });
10128
+ if (found) return found;
10129
+ } else if (block.kind === "table") {
10130
+ const found = findBlockSpanByIdInTable({
10131
+ table: block,
10132
+ tableNode: childNode,
10133
+ tableStartPm: fromPm,
10134
+ blockId: input.blockId
10135
+ });
10136
+ if (found) return found;
10137
+ }
10138
+ cursor = toPm;
10139
+ }
10140
+ return null;
10141
+ }
10142
+ function findBlockSpanByIdInTable(input) {
10143
+ let rowCursor = input.tableStartPm + 1;
10144
+ for (let rowIndex = 0; rowIndex < input.table.rows.length; rowIndex += 1) {
10145
+ const row = input.table.rows[rowIndex];
10146
+ const rowNode = input.tableNode.child(rowIndex);
10147
+ let cellCursor = rowCursor + 1;
10148
+ for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
10149
+ const cell = row.cells[cellIndex];
10150
+ const cellNode = rowNode.child(cellIndex);
10151
+ const found = findBlockSpanByIdInContainer({
10152
+ blocks: cell.content,
10153
+ containerNode: cellNode,
10154
+ contentStartPm: cellCursor + 1,
10155
+ blockId: input.blockId,
10156
+ allowCurrentLevelMatch: true,
10157
+ insideVerticalMergeContinuation: cell.verticalMerge === "continue"
10158
+ });
10159
+ if (found) return found;
10160
+ cellCursor += cellNode.nodeSize;
10161
+ }
10162
+ rowCursor += rowNode.nodeSize;
10163
+ }
10164
+ return null;
10165
+ }
10166
+ function mergePatchSpans(spans) {
10167
+ const sorted = [...spans].sort((a, b) => a.fromBlockIndex - b.fromBlockIndex);
10168
+ const merged = [];
10169
+ for (const span of sorted) {
10170
+ const previous = merged[merged.length - 1];
10171
+ if (previous && span.fromBlockIndex <= previous.toBlockIndex && span.nextFromBlockIndex <= previous.nextToBlockIndex) {
10172
+ previous.toBlockIndex = Math.max(previous.toBlockIndex, span.toBlockIndex);
10173
+ previous.nextToBlockIndex = Math.max(
10174
+ previous.nextToBlockIndex,
10175
+ span.nextToBlockIndex
10176
+ );
10177
+ previous.fromPm = minDefined(previous.fromPm, span.fromPm);
10178
+ previous.toPm = maxDefined(previous.toPm, span.toPm);
10179
+ previous.nextFromPm = minDefined(previous.nextFromPm, span.nextFromPm);
10180
+ previous.nextToPm = maxDefined(previous.nextToPm, span.nextToPm);
10181
+ previous.replacedBlockCount = (previous.replacedBlockCount ?? previous.toBlockIndex - previous.fromBlockIndex) + (span.replacedBlockCount ?? span.toBlockIndex - span.fromBlockIndex);
10182
+ previous.pageIds = [...previous.pageIds, ...span.pageIds];
10183
+ continue;
10184
+ }
10185
+ merged.push({ ...span });
10186
+ }
10187
+ return merged;
10188
+ }
10189
+ function minDefined(left, right) {
10190
+ if (left === void 0) return right;
10191
+ if (right === void 0) return left;
10192
+ return Math.min(left, right);
10193
+ }
10194
+ function maxDefined(left, right) {
10195
+ if (left === void 0) return right;
10196
+ if (right === void 0) return left;
10197
+ return Math.max(left, right);
10198
+ }
10199
+ function topLevelPositionForBlockIndex(doc, blockIndex) {
10200
+ const clamped = Math.max(0, Math.min(blockIndex, doc.childCount));
10201
+ let pos = 1;
10202
+ for (let index = 0; index < clamped; index += 1) {
10203
+ pos += doc.child(index).nodeSize;
10204
+ }
10205
+ return pos;
10206
+ }
10207
+ function selectionIntersectsSpan(selection, from, to) {
10208
+ return selection.to > from && selection.from < to;
10209
+ }
10210
+
9689
10211
  // src/ui-tailwind/editor-surface/tw-table-node-view.tsx
9690
10212
  var TABLE_LAYOUT_SYNC_EVENT = "pm-table-layout-sync";
9691
10213
  function readRowPadding(node, side) {
@@ -13135,6 +13657,57 @@ var chartNodeViews = {
13135
13657
  chart_atom: (node) => new ChartNodeViewInstance(node)
13136
13658
  };
13137
13659
 
13660
+ // src/ui-tailwind/page-stack/page-patch-realization.ts
13661
+ function resolvePagePatchRealization(input) {
13662
+ const { patchPlan, mountedPageIds, desiredMountedPageIds } = input;
13663
+ const mounted = new Set(mountedPageIds);
13664
+ const desiredPageIds = desiredMountedPageIds ?? null;
13665
+ const desired = desiredPageIds ? new Set(desiredPageIds) : null;
13666
+ const planMounts = desiredPageIds ? desiredPageIds.filter((pageId) => !mounted.has(pageId)) : patchPlan.mountChanges.mountPageIds;
13667
+ const planUnmounts = desired ? mountedPageIds.filter((pageId) => !desired.has(pageId)) : patchPlan.mountChanges.unmountPageIds;
13668
+ const mountPageIds = uniquePageIds(planMounts);
13669
+ const unmountPageIds = uniquePageIds(planUnmounts);
13670
+ const finalMounted = resolveFinalMountedPageIds({
13671
+ mountedPageIds,
13672
+ mountPageIds,
13673
+ unmountPageIds
13674
+ });
13675
+ const changedFragmentIdsByPageId = {};
13676
+ for (const entry of patchPlan.changedPages) {
13677
+ changedFragmentIdsByPageId[entry.pageId] = entry.fragmentChanges;
13678
+ }
13679
+ const patchPageIds = patchPlan.changedPages.map((entry) => entry.pageId).filter((pageId) => finalMounted.has(pageId));
13680
+ const preservePageIds = patchPlan.unchangedPages.filter(
13681
+ (pageId) => mounted.has(pageId) && finalMounted.has(pageId)
13682
+ );
13683
+ const skippedUnchangedPageIds = patchPlan.unchangedPages.filter(
13684
+ (pageId) => !finalMounted.has(pageId)
13685
+ );
13686
+ return {
13687
+ layoutRevision: patchPlan.layoutRevision,
13688
+ geometryRevision: patchPlan.geometryRevision,
13689
+ preservePageIds: uniquePageIds(preservePageIds),
13690
+ patchPageIds: uniquePageIds(patchPageIds),
13691
+ mountPageIds,
13692
+ unmountPageIds,
13693
+ skippedUnchangedPageIds: uniquePageIds(skippedUnchangedPageIds),
13694
+ changedFragmentIdsByPageId
13695
+ };
13696
+ }
13697
+ function resolveFinalMountedPageIds(input) {
13698
+ const finalMounted = new Set(input.mountedPageIds);
13699
+ for (const pageId of input.unmountPageIds) {
13700
+ finalMounted.delete(pageId);
13701
+ }
13702
+ for (const pageId of input.mountPageIds) {
13703
+ finalMounted.add(pageId);
13704
+ }
13705
+ return finalMounted;
13706
+ }
13707
+ function uniquePageIds(pageIds) {
13708
+ return [...new Set(pageIds)];
13709
+ }
13710
+
13138
13711
  // src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx
13139
13712
  import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
13140
13713
  var BOUNDED_TYPING_SCROLL_RESTORE_MAX_DELTA_PX = 256;
@@ -13144,6 +13717,62 @@ function shouldPreserveScrollAnchorForRebuild(options) {
13144
13717
  if (!options.previousStory) return false;
13145
13718
  return storyTargetsEqual(options.previousStory, options.nextStory);
13146
13719
  }
13720
+ function pageIdsFromRenderFrame(frame) {
13721
+ return frame.pages.map((page) => page.page.pageId);
13722
+ }
13723
+ function resolvePageBodyPatchForMountedState(input) {
13724
+ if (!input.previousSurface) {
13725
+ return { status: "fallback", reason: "previous-surface-missing" };
13726
+ }
13727
+ if (!input.previousFrame) {
13728
+ return { status: "fallback", reason: "previous-frame-missing" };
13729
+ }
13730
+ if (!input.nextFrame) {
13731
+ return { status: "fallback", reason: "next-frame-missing" };
13732
+ }
13733
+ if (input.previousPlugins !== input.plugins) {
13734
+ return { status: "fallback", reason: "plugin-set-changed" };
13735
+ }
13736
+ const patchPlan = createPagePatchPlan(input.previousFrame, input.nextFrame, void 0, {
13737
+ mountedPageIds: pageIdsFromRenderFrame(input.previousFrame),
13738
+ requestedMountPageIds: pageIdsFromRenderFrame(input.nextFrame)
13739
+ });
13740
+ const realization = resolvePagePatchRealization({
13741
+ patchPlan,
13742
+ mountedPageIds: pageIdsFromRenderFrame(input.previousFrame),
13743
+ desiredMountedPageIds: pageIdsFromRenderFrame(input.nextFrame)
13744
+ });
13745
+ const bodyPatch = resolvePmPageBodyPatchPlan({
13746
+ patchPlan,
13747
+ realization,
13748
+ previousFrame: input.previousFrame,
13749
+ nextFrame: input.nextFrame,
13750
+ previousSurface: input.previousSurface,
13751
+ nextSurface: input.nextSurface,
13752
+ currentDoc: input.view.state.doc,
13753
+ nextDoc: input.nextState.doc,
13754
+ currentSelection: input.view.state.selection
13755
+ });
13756
+ if (bodyPatch.status !== "patch") {
13757
+ if (bodyPatch.reason === "no-body-fragment-changes") {
13758
+ return { status: "skip", reason: bodyPatch.reason };
13759
+ }
13760
+ return { status: "fallback", reason: bodyPatch.reason };
13761
+ }
13762
+ return { status: "patch", plan: bodyPatch };
13763
+ }
13764
+ function applyPageBodyPatchToState(view, nextDoc, plan) {
13765
+ let tr = view.state.tr;
13766
+ const spans = [...plan.spans].sort((a, b) => b.fromPm - a.fromPm);
13767
+ for (const span of spans) {
13768
+ tr = tr.replace(
13769
+ span.fromPm,
13770
+ span.toPm,
13771
+ nextDoc.slice(span.nextFromPm, span.nextToPm)
13772
+ );
13773
+ }
13774
+ return view.state.apply(tr);
13775
+ }
13147
13776
  function buildPageBreakDecorationsFromProps(geometryFacet, isMainStory, positionMap, posture, canonicalDocument, dimensions = {}, surfaceBlocks) {
13148
13777
  if (!geometryFacet || !isMainStory) return [];
13149
13778
  const frame = geometryFacet.getRenderFrame();
@@ -13263,6 +13892,9 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13263
13892
  const localEquivalentOpsRef = useRef5([]);
13264
13893
  const pendingRebuildScrollAnchorRef = useRef5(null);
13265
13894
  const lastBuiltStoryRef = useRef5(null);
13895
+ const lastBuiltSurfaceRef = useRef5(null);
13896
+ const lastRenderFrameRef = useRef5(null);
13897
+ const lastPluginsRef = useRef5(null);
13266
13898
  const snapshotRef = useRef5(snapshot);
13267
13899
  snapshotRef.current = snapshot;
13268
13900
  const scopeTagRegistryFactoryProp = props.scopeTagRegistryFactory;
@@ -13300,8 +13932,12 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13300
13932
  onPasteFragment: (meta) => {
13301
13933
  props.onPasteFragment?.(meta);
13302
13934
  },
13303
- onPastePlainTextFragment: (fragment) => {
13304
- props.onPasteFragment?.({ fragment, source: "plain-text" });
13935
+ onPastePlainTextFragment: (fragment, context) => {
13936
+ props.onPasteFragment?.({
13937
+ fragment,
13938
+ source: "plain-text",
13939
+ ...context?.editableTarget ? { editableTarget: context.editableTarget } : {}
13940
+ });
13305
13941
  },
13306
13942
  shouldPastePlainTextAsFragment: () => snapshotRef.current.documentMode !== "suggesting",
13307
13943
  onPasteImage: (meta) => {
@@ -13358,6 +13994,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13358
13994
  showTrackedChanges,
13359
13995
  suggestionsEnabled,
13360
13996
  canEdit,
13997
+ pageBreakRevision: props.pageBreakRevision,
13361
13998
  activeCommentId: snapshot.comments.activeCommentId,
13362
13999
  activeRevisionId: props.activeRevisionId,
13363
14000
  workflowScopeSignature: createWorkflowScopeSignature(props.workflowScopes),
@@ -13379,6 +14016,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13379
14016
  props.activeWorkflowWorkItemId,
13380
14017
  props.activeWorkflowScopeIds,
13381
14018
  props.workflowScopes,
14019
+ props.pageBreakRevision,
13382
14020
  showTrackedChanges,
13383
14021
  suggestionsEnabled,
13384
14022
  snapshot.comments.activeCommentId
@@ -13441,7 +14079,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13441
14079
  onBlockedInput: (command, message) => callbacksRef.current?.onBlockedInput?.(command, message),
13442
14080
  onPasteApplied: (meta) => callbacksRef.current?.onPasteApplied?.(meta),
13443
14081
  onPasteFragment: (meta) => callbacksRef.current?.onPasteFragment?.(meta),
13444
- onPastePlainTextFragment: (fragment) => callbacksRef.current?.onPastePlainTextFragment?.(fragment),
14082
+ onPastePlainTextFragment: (fragment, context) => callbacksRef.current?.onPastePlainTextFragment?.(fragment, context),
13445
14083
  shouldPastePlainTextAsFragment: () => callbacksRef.current?.shouldPastePlainTextAsFragment?.() ?? true,
13446
14084
  onPasteImage: (meta) => callbacksRef.current?.onPasteImage?.(meta),
13447
14085
  onDropFragment: (meta) => callbacksRef.current?.onDropFragment?.(meta),
@@ -13527,6 +14165,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13527
14165
  props.workflowMetadata,
13528
14166
  props.workflowCandidates,
13529
14167
  props.workflowScopes,
14168
+ props.pageBreakRevision,
13530
14169
  revisionDisplayByOffset,
13531
14170
  revisionModel,
13532
14171
  showTrackedChanges,
@@ -13642,6 +14281,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13642
14281
  useEffect4(() => {
13643
14282
  if (!mountRef.current || !surface) return;
13644
14283
  if (viewRef.current && documentBuildKeyRef.current === documentBuildKey) {
14284
+ incrementInvalidationCounter("pm.rebuild.skip.documentBuildKey");
13645
14285
  pendingRebuildScrollAnchorRef.current = null;
13646
14286
  return;
13647
14287
  }
@@ -13650,10 +14290,14 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13650
14290
  positionMapRef.current = buildPositionMap(surface);
13651
14291
  documentBuildKeyRef.current = documentBuildKey;
13652
14292
  applyDecorationProps(viewRef.current, positionMapRef.current);
14293
+ incrementInvalidationCounter("pm.rebuild.skip.equivalentAck");
13653
14294
  equivalentAckLedgerRef.current.delete(snapshot.revisionToken);
13654
14295
  localEquivalentOpsRef.current = [];
13655
14296
  pendingRebuildScrollAnchorRef.current = null;
13656
14297
  lastBuiltStoryRef.current = snapshot.activeStory;
14298
+ lastBuiltSurfaceRef.current = surface;
14299
+ lastRenderFrameRef.current = snapshot.activeStory.kind === "main" ? props.geometryFacet?.getRenderFrame() ?? null : null;
14300
+ lastPluginsRef.current = plugins;
13657
14301
  if (pendingTypingProbeRef.current) {
13658
14302
  finishPerfProbe(pendingTypingProbeRef.current);
13659
14303
  pendingTypingProbeRef.current = null;
@@ -13692,23 +14336,49 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13692
14336
  previousStory: lastBuiltStoryRef.current,
13693
14337
  nextStory: snapshot.activeStory
13694
14338
  });
13695
- replaceStatePreservingPosition(
13696
- {
13697
- view,
13698
- geometryFacet: props.geometryFacet,
13699
- suppressionRef: suppressSelectionEchoRef,
13700
- preserveScrollAnchor,
13701
- maxScrollDeltaPx: BOUNDED_TYPING_SCROLL_RESTORE_MAX_DELTA_PX,
13702
- afterUpdateState: () => {
13703
- applyDecorationProps(view, positionMap);
13704
- appliedDecorationProps = true;
13705
- }
13706
- },
13707
- state
13708
- );
14339
+ const pageBodyPatch = resolvePageBodyPatchForMountedState({
14340
+ view,
14341
+ nextState: state,
14342
+ previousSurface: lastBuiltSurfaceRef.current,
14343
+ nextSurface: surface,
14344
+ previousFrame: lastRenderFrameRef.current,
14345
+ nextFrame: snapshot.activeStory.kind === "main" ? props.geometryFacet?.getRenderFrame() ?? null : null,
14346
+ plugins,
14347
+ previousPlugins: lastPluginsRef.current
14348
+ });
14349
+ const replacementState = pageBodyPatch.status === "patch" ? applyPageBodyPatchToState(view, state.doc, pageBodyPatch.plan) : state;
14350
+ if (pageBodyPatch.status === "skip") {
14351
+ applyDecorationProps(view, positionMap);
14352
+ appliedDecorationProps = true;
14353
+ } else {
14354
+ replaceStatePreservingPosition(
14355
+ {
14356
+ view,
14357
+ geometryFacet: props.geometryFacet,
14358
+ suppressionRef: suppressSelectionEchoRef,
14359
+ preserveScrollAnchor,
14360
+ maxScrollDeltaPx: BOUNDED_TYPING_SCROLL_RESTORE_MAX_DELTA_PX,
14361
+ afterUpdateState: () => {
14362
+ applyDecorationProps(view, positionMap);
14363
+ appliedDecorationProps = true;
14364
+ }
14365
+ },
14366
+ replacementState
14367
+ );
14368
+ }
14369
+ if (pageBodyPatch.status === "patch") {
14370
+ incrementInvalidationCounter("pm.pagePatch.body");
14371
+ } else if (pageBodyPatch.status === "skip") {
14372
+ incrementInvalidationCounter(`pm.pagePatch.skip.${pageBodyPatch.reason}`);
14373
+ } else if (pageBodyPatch.reason) {
14374
+ incrementInvalidationCounter(`pm.pagePatch.fallback.${pageBodyPatch.reason}`);
14375
+ }
13709
14376
  }
13710
14377
  documentBuildKeyRef.current = documentBuildKey;
13711
14378
  lastBuiltStoryRef.current = snapshot.activeStory;
14379
+ lastBuiltSurfaceRef.current = surface;
14380
+ lastRenderFrameRef.current = snapshot.activeStory.kind === "main" ? props.geometryFacet?.getRenderFrame() ?? null : null;
14381
+ lastPluginsRef.current = plugins;
13712
14382
  if (!appliedDecorationProps) {
13713
14383
  applyDecorationProps(viewRef.current, positionMap);
13714
14384
  }
@@ -13728,7 +14398,8 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13728
14398
  surface,
13729
14399
  snapshot.selection,
13730
14400
  plugins,
13731
- props.mediaPreviews
14401
+ props.mediaPreviews,
14402
+ props.geometryFacet
13732
14403
  ]);
13733
14404
  useEffect4(() => {
13734
14405
  const view = viewRef.current;
@@ -15186,6 +15857,15 @@ function deriveShellPinnedSurfaces(chromePreset, chromeOptions) {
15186
15857
  import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
15187
15858
  var EMU_PER_CSS_PX = 9525;
15188
15859
  var nextObjectDragSessionId = 0;
15860
+ function preferListTextEditableTarget(primary, fallback) {
15861
+ if (primary?.listAddress?.operationScope === "list-text") {
15862
+ return primary;
15863
+ }
15864
+ if (fallback?.listAddress?.operationScope === "list-text") {
15865
+ return fallback;
15866
+ }
15867
+ return primary ?? fallback;
15868
+ }
15189
15869
  function createMountedObjectDragSession(runtime, input) {
15190
15870
  nextObjectDragSessionId += 1;
15191
15871
  const sessionId = `object-drag-${nextObjectDragSessionId}`;
@@ -15448,6 +16128,7 @@ var WordReviewEditor = forwardRef3(
15448
16128
  lastSavedRevisionTokenRef,
15449
16129
  runtimeViewStateSeedRef
15450
16130
  } = useEditorRuntimeBoundary(props);
16131
+ const pageBreakRevision = useLayoutFacetRenderSignal(activeRuntime.layout);
15451
16132
  const shellUiStateRef = useRef7({
15452
16133
  hostPosture: {},
15453
16134
  chromePresetInput: { chromePreset: "advanced" }
@@ -17457,7 +18138,10 @@ var WordReviewEditor = forwardRef3(
17457
18138
  // auto-bracketing in insertFragment + our explicit startAction around
17458
18139
  // the delete, so the undo history sees a single atomic action.
17459
18140
  onDropFragment: (meta) => {
17460
- const dropEditableTarget = meta.editableTarget ?? activeRuntime.getRenderSnapshot().selection.editableTarget;
18141
+ const dropEditableTarget = preferListTextEditableTarget(
18142
+ meta.editableTarget,
18143
+ activeRuntime.getRenderSnapshot().selection.editableTarget
18144
+ );
17461
18145
  if (meta.effect === "move" && meta.sourceRange) {
17462
18146
  activeRuntime.startAction("drag-move");
17463
18147
  try {
@@ -17468,7 +18152,10 @@ var WordReviewEditor = forwardRef3(
17468
18152
  assoc: { start: -1, end: 1 }
17469
18153
  });
17470
18154
  const currentEditableTarget = activeRuntime.getRenderSnapshot().selection.editableTarget;
17471
- const editableTarget = currentEditableTarget?.targetKey === dropEditableTarget?.targetKey ? currentEditableTarget : dropEditableTarget;
18155
+ const editableTarget = preferListTextEditableTarget(
18156
+ currentEditableTarget?.targetKey === dropEditableTarget?.targetKey ? currentEditableTarget : void 0,
18157
+ dropEditableTarget
18158
+ );
17472
18159
  activeRuntime.insertFragment(
17473
18160
  meta.fragment,
17474
18161
  void 0,
@@ -17507,7 +18194,10 @@ var WordReviewEditor = forwardRef3(
17507
18194
  // insertFragment auto-bracket (R.5.a Phase 2) makes the paste a
17508
18195
  // single-undo action.
17509
18196
  onPasteFragment: (meta) => {
17510
- const editableTarget = activeRuntime.getRenderSnapshot().selection.editableTarget;
18197
+ const editableTarget = preferListTextEditableTarget(
18198
+ meta.editableTarget,
18199
+ activeRuntime.getRenderSnapshot().selection.editableTarget
18200
+ );
17511
18201
  activeRuntime.insertFragment(
17512
18202
  meta.fragment,
17513
18203
  void 0,
@@ -17860,6 +18550,9 @@ var WordReviewEditor = forwardRef3(
17860
18550
  onDeleteTable: commands.onDeleteTable,
17861
18551
  onMergeCells: commands.onMergeCells,
17862
18552
  onSplitCell: commands.onSplitCell,
18553
+ onUpdateFields: () => {
18554
+ activeRuntime.updateFields();
18555
+ },
17863
18556
  onAskAgentForSelection: () => {
17864
18557
  const { selection } = snapshot;
17865
18558
  onEventRef.current?.({
@@ -17931,6 +18624,7 @@ var WordReviewEditor = forwardRef3(
17931
18624
  pageChromeHeaderBandPx: isPageWorkspace ? 32 : 0,
17932
18625
  pageChromeFooterBandPx: isPageWorkspace ? 32 : 0,
17933
18626
  pageChromeInterGapPx: PAGE_CHROME_DEFAULTS.interGapPx,
18627
+ pageBreakRevision,
17934
18628
  onOpenHeaderStoryForPage: (pageIndex) => openStoryForPage(activeRuntime, pageIndex, "header"),
17935
18629
  onOpenFooterStoryForPage: (pageIndex) => openStoryForPage(activeRuntime, pageIndex, "footer"),
17936
18630
  onCommentActivated: (commentId) => {