@beyondwork/docx-react-component 1.0.132 → 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 (94) hide show
  1. package/dist/api/public-types.cjs +158 -67
  2. package/dist/api/public-types.d.cts +1 -1
  3. package/dist/api/public-types.d.ts +1 -1
  4. package/dist/api/public-types.js +3 -3
  5. package/dist/api/v3.cjs +9326 -7478
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{chunk-XYTWOJII.js → chunk-224TSMEB.js} +635 -89
  10. package/dist/{chunk-43JAPM2F.js → chunk-3JEE5RJU.js} +92 -131
  11. package/dist/{chunk-UP2KDOYE.js → chunk-57HTKX3P.js} +6 -2
  12. package/dist/{chunk-RYMMKOFI.js → chunk-5KTJKTNE.js} +32 -0
  13. package/dist/{chunk-LPLJZJT2.js → chunk-CVSD3UNK.js} +128 -69
  14. package/dist/{chunk-JVTDBX67.js → chunk-EFEW7BTT.js} +2 -2
  15. package/dist/{chunk-UFPBYJMA.js → chunk-INLRCC4N.js} +2 -2
  16. package/dist/{chunk-6736GA6J.js → chunk-KL4TZSZV.js} +1 -1
  17. package/dist/{chunk-N5FTU4HZ.js → chunk-MQ5GAJ54.js} +68 -39
  18. package/dist/{chunk-W2I47J2Q.js → chunk-NJFKPDNG.js} +216 -2
  19. package/dist/{chunk-YUHNDEV5.js → chunk-OTRVGNZQ.js} +2934 -1815
  20. package/dist/{chunk-4HGFJ6Z2.js → chunk-PZIEOEJZ.js} +1 -1
  21. package/dist/{chunk-C5LXKR54.js → chunk-QTRJLKR2.js} +1 -1
  22. package/dist/{chunk-SZ6BJA4Q.js → chunk-REFHJ2FN.js} +3 -3
  23. package/dist/{chunk-ZDYGRO2Z.js → chunk-RP76USJE.js} +1 -1
  24. package/dist/{chunk-QUTVR72L.js → chunk-S3PEKX6H.js} +246 -43
  25. package/dist/{chunk-RBWJHRNP.js → chunk-T66OS7MN.js} +8 -3
  26. package/dist/{chunk-ALWXYGXP.js → chunk-V2JF42SI.js} +2 -2
  27. package/dist/{chunk-6TLZ6CMP.js → chunk-WDDFU2N2.js} +2 -2
  28. package/dist/{chunk-U3UMKA7B.js → chunk-XBQFDBXE.js} +1 -1
  29. package/dist/{chunk-CDEZGLQ3.js → chunk-ZFCZ7XXH.js} +1 -1
  30. package/dist/core/commands/formatting-commands.d.cts +1 -1
  31. package/dist/core/commands/formatting-commands.d.ts +1 -1
  32. package/dist/core/commands/image-commands.cjs +32 -0
  33. package/dist/core/commands/image-commands.d.cts +1 -1
  34. package/dist/core/commands/image-commands.d.ts +1 -1
  35. package/dist/core/commands/image-commands.js +5 -5
  36. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  37. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  38. package/dist/core/commands/style-commands.d.cts +1 -1
  39. package/dist/core/commands/style-commands.d.ts +1 -1
  40. package/dist/core/commands/table-structure-commands.cjs +32 -0
  41. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  42. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  43. package/dist/core/commands/table-structure-commands.js +4 -4
  44. package/dist/core/commands/text-commands.cjs +99 -38
  45. package/dist/core/commands/text-commands.d.cts +12 -1
  46. package/dist/core/commands/text-commands.d.ts +12 -1
  47. package/dist/core/commands/text-commands.js +5 -5
  48. package/dist/core/selection/mapping.d.cts +1 -1
  49. package/dist/core/selection/mapping.d.ts +1 -1
  50. package/dist/core/state/editor-state.d.cts +1 -1
  51. package/dist/core/state/editor-state.d.ts +1 -1
  52. package/dist/index.cjs +4827 -2434
  53. package/dist/index.d.cts +4 -4
  54. package/dist/index.d.ts +4 -4
  55. package/dist/index.js +292 -53
  56. package/dist/io/docx-session.cjs +7 -2
  57. package/dist/io/docx-session.d.cts +3 -3
  58. package/dist/io/docx-session.d.ts +3 -3
  59. package/dist/io/docx-session.js +4 -4
  60. package/dist/legal.js +3 -3
  61. package/dist/{loader-MAa8VpzW.d.cts → loader-B2H99237.d.cts} +2 -2
  62. package/dist/{loader-CfpeEPAa.d.ts → loader-DfTjqVwn.d.ts} +2 -2
  63. package/dist/{public-types-Cjs8glST.d.ts → public-types-B5lOUIrP.d.ts} +689 -232
  64. package/dist/{public-types-KBS6JnOs.d.cts → public-types-S8gTYwKo.d.cts} +689 -232
  65. package/dist/public-types.cjs +158 -67
  66. package/dist/public-types.d.cts +1 -1
  67. package/dist/public-types.d.ts +1 -1
  68. package/dist/public-types.js +3 -3
  69. package/dist/runtime/collab.d.cts +2 -2
  70. package/dist/runtime/collab.d.ts +2 -2
  71. package/dist/runtime/document-runtime.cjs +1032 -416
  72. package/dist/runtime/document-runtime.d.cts +1 -1
  73. package/dist/runtime/document-runtime.d.ts +1 -1
  74. package/dist/runtime/document-runtime.js +14 -14
  75. package/dist/{session-CkoH8FoY.d.ts → session-CBDIOYXA.d.ts} +2 -2
  76. package/dist/{session-wwe0Gib-.d.cts → session-CR2A1hGZ.d.cts} +2 -2
  77. package/dist/session.cjs +7 -2
  78. package/dist/session.d.cts +4 -4
  79. package/dist/session.d.ts +4 -4
  80. package/dist/session.js +5 -5
  81. package/dist/tailwind.cjs +398 -105
  82. package/dist/tailwind.d.cts +1 -1
  83. package/dist/tailwind.d.ts +1 -1
  84. package/dist/tailwind.js +7 -7
  85. package/dist/{types-CH7NWqVL.d.ts → types-B-90ywjU.d.ts} +1 -1
  86. package/dist/{types-B3SGRW0w.d.cts → types-yty2K-hk.d.cts} +1 -1
  87. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  88. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  89. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  90. package/dist/ui-tailwind.cjs +398 -105
  91. package/dist/ui-tailwind.d.cts +3 -2
  92. package/dist/ui-tailwind.d.ts +3 -2
  93. package/dist/ui-tailwind.js +7 -7
  94. 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-CDEZGLQ3.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-43JAPM2F.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-ZDYGRO2Z.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-SZ6BJA4Q.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-UFPBYJMA.js";
57
- import "./chunk-N5FTU4HZ.js";
56
+ } from "./chunk-INLRCC4N.js";
57
+ import "./chunk-MQ5GAJ54.js";
58
58
  import {
59
59
  getTableStructureContext,
60
60
  tableStructureActionHandleForTarget
61
- } from "./chunk-6TLZ6CMP.js";
62
- import "./chunk-C5LXKR54.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,14 +83,15 @@ import {
83
83
  resolveScopedChromePolicy,
84
84
  resolveScrollTopForAnchor,
85
85
  resolveSelectionToolRegistry,
86
+ sanitizeNumberingPictureBulletSrc,
86
87
  shouldRenderAbsoluteFloatingImageInPageOverlay,
87
88
  shouldRenderSelectionToolKind,
88
89
  shouldUseMountedSurfaceViewportCulling,
89
90
  useLayoutFacetRenderSignal
90
- } from "./chunk-QUTVR72L.js";
91
+ } from "./chunk-S3PEKX6H.js";
91
92
  import {
92
93
  createInertGeometryFacet
93
- } from "./chunk-UP2KDOYE.js";
94
+ } from "./chunk-57HTKX3P.js";
94
95
  import {
95
96
  composeSeriesColor,
96
97
  computeStructuralHash,
@@ -104,12 +105,12 @@ import {
104
105
  resolveColor,
105
106
  tryReadLaycacheEnvelope,
106
107
  writeEnvelopeToOpcPackage
107
- } from "./chunk-YUHNDEV5.js";
108
+ } from "./chunk-OTRVGNZQ.js";
108
109
  import {
109
110
  findTextMatches,
110
111
  parseCanonicalFragmentFromWordML,
111
112
  searchDocument
112
- } from "./chunk-XYTWOJII.js";
113
+ } from "./chunk-224TSMEB.js";
113
114
  import {
114
115
  clearLocalCursorState,
115
116
  getCursorColorForUser,
@@ -119,7 +120,7 @@ import {
119
120
  import {
120
121
  resolveChromePreset,
121
122
  resolveChromeVisibilityForPreset
122
- } from "./chunk-W2I47J2Q.js";
123
+ } from "./chunk-NJFKPDNG.js";
123
124
  import {
124
125
  CAPABILITY_BY_ID,
125
126
  ISSUE_METADATA_ID,
@@ -141,7 +142,7 @@ import {
141
142
  sanitizeMarkdown,
142
143
  sha256Hex,
143
144
  startPerfProbe
144
- } from "./chunk-LPLJZJT2.js";
145
+ } from "./chunk-CVSD3UNK.js";
145
146
  import "./chunk-OVLZQ6FZ.js";
146
147
  import "./chunk-QIO6V46H.js";
147
148
  import {
@@ -149,7 +150,7 @@ import {
149
150
  getStoryBlocks,
150
151
  replaceStoryBlocks,
151
152
  stableChartId
152
- } from "./chunk-U3UMKA7B.js";
153
+ } from "./chunk-XBQFDBXE.js";
153
154
  import "./chunk-SYQWQ6FE.js";
154
155
  import {
155
156
  createDefaultCanonicalDocument,
@@ -160,14 +161,14 @@ import {
160
161
  SessionNotOpenError,
161
162
  SessionNotWiredError,
162
163
  isReopenBarrier
163
- } from "./chunk-ALWXYGXP.js";
164
+ } from "./chunk-V2JF42SI.js";
164
165
  import {
165
166
  createHmacSigner,
166
167
  createHmacVerifier,
167
168
  loadDocxSessionSync,
168
169
  signWorkflowPayloadXml,
169
170
  verifyWorkflowPayloadXml
170
- } from "./chunk-JVTDBX67.js";
171
+ } from "./chunk-EFEW7BTT.js";
171
172
  import {
172
173
  EDITOR_SESSION_STATE_VERSION,
173
174
  assertEditorSessionState,
@@ -176,8 +177,8 @@ import {
176
177
  editorSessionStateFromPersistedSnapshot,
177
178
  persistedSnapshotFromEditorSessionState,
178
179
  validateEditorSessionState
179
- } from "./chunk-4HGFJ6Z2.js";
180
- import "./chunk-RBWJHRNP.js";
180
+ } from "./chunk-PZIEOEJZ.js";
181
+ import "./chunk-T66OS7MN.js";
181
182
  import {
182
183
  decodePersistedSourcePackageBytes,
183
184
  hasValidPersistedSourcePackageDigest
@@ -189,7 +190,7 @@ import {
189
190
  collectEditableTargetRefs,
190
191
  createHeaderFooterStoryKey,
191
192
  createNoteStoryKey
192
- } from "./chunk-RYMMKOFI.js";
193
+ } from "./chunk-5KTJKTNE.js";
193
194
  import {
194
195
  readOpcPackage
195
196
  } from "./chunk-WUDSNHWF.js";
@@ -327,6 +328,9 @@ function applyListAwareTextCommand(context, command, deps) {
327
328
  if (!paragraphContext.atParagraphStart || !context.localSnapshot.selection.isCollapsed) {
328
329
  return null;
329
330
  }
331
+ if (shouldRouteListBoundaryJoinThroughTextCommand(context, paragraphContext)) {
332
+ return null;
333
+ }
330
334
  const result = backspaceAtListStart(
331
335
  context.localDocument,
332
336
  paragraphContext.paragraphIndex,
@@ -367,6 +371,39 @@ function listCommandTargetOptions(context, paragraphContext) {
367
371
  }
368
372
  return { editableTargets: [paragraphContext.paragraph.editableTarget] };
369
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
+ }
370
407
  function createListMutationResult(result, selection, deps) {
371
408
  return {
372
409
  changed: result.affectedParagraphIndexes.length > 0,
@@ -403,13 +440,23 @@ function dispatchTextCommand(runtime, command, deps) {
403
440
  }
404
441
  switch (command.type) {
405
442
  case "insert-text":
406
- runtime.applyActiveStoryTextCommand({ type: "text.insert", text: command.text });
443
+ runtime.applyActiveStoryTextCommand({
444
+ type: "text.insert",
445
+ text: command.text,
446
+ ...mountedListTextTarget(context, deps)
447
+ });
407
448
  return;
408
449
  case "delete-backward":
409
- runtime.applyActiveStoryTextCommand({ type: "text.delete-backward" });
450
+ runtime.applyActiveStoryTextCommand({
451
+ type: "text.delete-backward",
452
+ ...mountedListTextTarget(context, deps)
453
+ });
410
454
  return;
411
455
  case "delete-forward":
412
- runtime.applyActiveStoryTextCommand({ type: "text.delete-forward" });
456
+ runtime.applyActiveStoryTextCommand({
457
+ type: "text.delete-forward",
458
+ ...mountedListTextTarget(context, deps)
459
+ });
413
460
  return;
414
461
  case "insert-tab":
415
462
  runtime.applyActiveStoryTextCommand({ type: "text.insert-tab" });
@@ -418,13 +465,30 @@ function dispatchTextCommand(runtime, command, deps) {
418
465
  runtime.applyActiveStoryTextCommand({ type: "text.outdent-tab" });
419
466
  return;
420
467
  case "insert-hard-break":
421
- runtime.applyActiveStoryTextCommand({ type: "text.insert-hard-break" });
468
+ runtime.applyActiveStoryTextCommand({
469
+ type: "text.insert-hard-break",
470
+ ...mountedListTextTarget(context, deps)
471
+ });
422
472
  return;
423
473
  case "split-paragraph":
424
- runtime.applyActiveStoryTextCommand({ type: "paragraph.split" });
474
+ runtime.applyActiveStoryTextCommand({
475
+ type: "paragraph.split",
476
+ ...mountedListTextTarget(context, deps)
477
+ });
425
478
  return;
426
479
  }
427
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
+ }
428
492
  function getMountedTextCommandName(command) {
429
493
  switch (command.type) {
430
494
  case "insert-text":
@@ -5333,7 +5397,7 @@ var editorSchema = new Schema({
5333
5397
  if (typeof numberingMarkerStartTwips === "number") {
5334
5398
  attrs["data-numbering-marker-start-twips"] = String(numberingMarkerStartTwips);
5335
5399
  }
5336
- const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth;
5400
+ const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth ?? node.attrs.indentHanging;
5337
5401
  if (typeof _numberingMarkerWidthTwips === "number" && _numberingMarkerWidthTwips > 0) {
5338
5402
  attrs["data-numbering-marker-width-twips"] = String(
5339
5403
  _numberingMarkerWidthTwips
@@ -5349,7 +5413,9 @@ var editorSchema = new Schema({
5349
5413
  const numberingMarkerWidth = node.attrs.numberingMarkerWidth;
5350
5414
  const numberingMarkerStart = node.attrs.numberingMarkerStart;
5351
5415
  const numberingMarkerJustification = node.attrs.numberingMarkerJustification;
5352
- const numberingPicBulletSrc = node.attrs.numberingPicBulletSrc;
5416
+ const numberingPicBulletSrc = sanitizeNumberingPictureBulletSrc(
5417
+ node.attrs.numberingPicBulletSrc
5418
+ );
5353
5419
  const children = [];
5354
5420
  if (pageBreak) {
5355
5421
  attrs["data-page-break-before"] = "true";
@@ -5405,6 +5471,7 @@ var editorSchema = new Schema({
5405
5471
  {
5406
5472
  class: baseClasses.join(" "),
5407
5473
  contenteditable: "false",
5474
+ "data-numbering-marker": "true",
5408
5475
  "data-numbering-prefix": numberingPicBulletSrc ? "" : numberingPrefix ?? "",
5409
5476
  ...typeof numberingLevel === "number" ? { "data-numbering-level": String(numberingLevel) } : {},
5410
5477
  ...numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {},
@@ -5776,13 +5843,17 @@ var editorSchema = new Schema({
5776
5843
  },
5777
5844
  toDOM(node) {
5778
5845
  const refreshStatus = node.attrs.refreshStatus;
5846
+ const fieldTarget = node.attrs.fieldTarget;
5779
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";
5780
5848
  return [
5781
5849
  "span",
5782
5850
  {
5783
5851
  class: `inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs border ${statusClass}`,
5784
5852
  "data-node-type": "field_ref_atom",
5853
+ "data-generated-field": "true",
5785
5854
  "data-field-family": node.attrs.fieldFamily,
5855
+ ...fieldTarget ? { "data-field-target": fieldTarget } : {},
5856
+ "data-field-refresh-status": refreshStatus,
5786
5857
  title: node.attrs.instruction
5787
5858
  },
5788
5859
  node.attrs.label || "Field"
@@ -7274,7 +7345,7 @@ function buildParagraph(block, previousParagraph, nextParagraph, mediaPreviews,
7274
7345
  numberingPicBulletSrc: (() => {
7275
7346
  const mediaId = block.resolvedNumbering?.picBulletMediaId;
7276
7347
  if (!mediaId) return null;
7277
- return mediaPreviews[mediaId]?.src ?? null;
7348
+ return sanitizeNumberingPictureBulletSrc(mediaPreviews[mediaId]?.src);
7278
7349
  })(),
7279
7350
  shadingFill: block.shading?.fill ?? cascade?.shading?.fill ?? null,
7280
7351
  borderTop: block.borders?.top ?? cascadeBorders?.top ?? null,
@@ -7824,9 +7895,9 @@ function resolveDropSelectionFromCoordinates(view, event) {
7824
7895
  if (selection.eq(view.state.selection)) return;
7825
7896
  view.dispatch(view.state.tr.setSelection(selection));
7826
7897
  }
7827
- function applyPasteSegmentsToCallbacks(segments, callbacks) {
7898
+ function applyPasteSegmentsToCallbacks(segments, callbacks, context) {
7828
7899
  if (callbacks.onPastePlainTextFragment && callbacks.shouldPastePlainTextAsFragment?.() !== false && segments.some((seg) => seg.kind === "split") && segments.some((seg) => seg.kind === "text" && seg.value.length > 0)) {
7829
- callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments));
7900
+ callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments), context);
7830
7901
  return;
7831
7902
  }
7832
7903
  for (const seg of segments) {
@@ -7896,6 +7967,34 @@ function applyContextMenuEvent(callbacks, event) {
7896
7967
  return false;
7897
7968
  }
7898
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
+ }
7899
7998
  var bridgeKey = new PluginKey("command-bridge");
7900
7999
  function createSelectionSyncPlugin(callbacks) {
7901
8000
  return new Plugin({
@@ -8033,6 +8132,9 @@ function createCommandBridgePlugins(callbacks, options) {
8033
8132
  // behavior (back-compat).
8034
8133
  contextmenu(_view, event) {
8035
8134
  return applyContextMenuEvent(callbacks, event);
8135
+ },
8136
+ click(view, event) {
8137
+ return applyNumberingMarkerClick(view, event);
8036
8138
  }
8037
8139
  },
8038
8140
  handleTextInput(_view, _from, _to, text) {
@@ -8059,10 +8161,12 @@ function createCommandBridgePlugins(callbacks, options) {
8059
8161
  // through to Tier A so the user isn't left with a silent no-op.
8060
8162
  handlePaste(_view, event) {
8061
8163
  if (isComposing) return true;
8062
- if (!isPmEditTargetEditable(_view.state, callbacks.getPositionMap())) {
8164
+ const positionMap = callbacks.getPositionMap();
8165
+ if (!isPmEditTargetEditable(_view.state, positionMap)) {
8063
8166
  callbacks.onBlockedInput?.("paste", NON_EDITABLE_INPUT_MESSAGE);
8064
8167
  return true;
8065
8168
  }
8169
+ const editableTarget = resolveCurrentEditableTarget(_view.state, positionMap);
8066
8170
  const clipboard = event.clipboardData;
8067
8171
  if (!clipboard) {
8068
8172
  callbacks.onBlockedInput?.("paste", "Clipboard data was not available.");
@@ -8084,7 +8188,11 @@ function createCommandBridgePlugins(callbacks, options) {
8084
8188
  if (wordml) {
8085
8189
  const parsed = options.pasteFragmentParser.parseWordML(wordml);
8086
8190
  if (parsed.ok && parsed.fragment.blocks.length > 0) {
8087
- callbacks.onPasteFragment({ fragment: parsed.fragment, source: "wordml" });
8191
+ callbacks.onPasteFragment({
8192
+ fragment: parsed.fragment,
8193
+ source: "wordml",
8194
+ ...editableTarget ? { editableTarget } : {}
8195
+ });
8088
8196
  return true;
8089
8197
  }
8090
8198
  }
@@ -8094,7 +8202,11 @@ function createCommandBridgePlugins(callbacks, options) {
8094
8202
  if (htmlPayload && htmlPayload.trim().length > 0) {
8095
8203
  const parsed = options.pasteFragmentParser.parseHtml(htmlPayload);
8096
8204
  if (parsed.ok && parsed.fragment.blocks.length > 0) {
8097
- callbacks.onPasteFragment({ fragment: parsed.fragment, source: "html" });
8205
+ callbacks.onPasteFragment({
8206
+ fragment: parsed.fragment,
8207
+ source: "html",
8208
+ ...editableTarget ? { editableTarget } : {}
8209
+ });
8098
8210
  return true;
8099
8211
  }
8100
8212
  }
@@ -8108,7 +8220,11 @@ function createCommandBridgePlugins(callbacks, options) {
8108
8220
  return true;
8109
8221
  }
8110
8222
  const segments = extractPlainTextSegments(plain);
8111
- applyPasteSegmentsToCallbacks(segments, callbacks);
8223
+ applyPasteSegmentsToCallbacks(
8224
+ segments,
8225
+ callbacks,
8226
+ editableTarget ? { editableTarget } : void 0
8227
+ );
8112
8228
  callbacks.onPasteApplied?.({
8113
8229
  segmentCount: segments.length,
8114
8230
  charCount: totalTextCharCount(segments),
@@ -8169,7 +8285,11 @@ function createCommandBridgePlugins(callbacks, options) {
8169
8285
  return true;
8170
8286
  }
8171
8287
  const segments = extractPlainTextSegments(plain);
8172
- applyPasteSegmentsToCallbacks(segments, callbacks);
8288
+ applyPasteSegmentsToCallbacks(
8289
+ segments,
8290
+ callbacks,
8291
+ editableTarget ? { editableTarget } : void 0
8292
+ );
8173
8293
  callbacks.onPasteApplied?.({
8174
8294
  segmentCount: segments.length,
8175
8295
  charCount: totalTextCharCount(segments),
@@ -9721,11 +9841,15 @@ function createSurfaceDecorationKey(input) {
9721
9841
 
9722
9842
  // src/ui-tailwind/editor-surface/pm-page-body-patch.ts
9723
9843
  function resolvePmPageBodyPatchPlan(input) {
9724
- if (input.patchPlan.addedPages.length > 0 || input.patchPlan.removedPages.length > 0) {
9844
+ const membershipChangedPageIds = [
9845
+ ...input.patchPlan.addedPages,
9846
+ ...input.patchPlan.removedPages
9847
+ ];
9848
+ if (membershipChangedPageIds.length > 0 && input.currentDoc.childCount !== input.nextDoc.childCount) {
9725
9849
  return {
9726
9850
  status: "fallback",
9727
9851
  reason: "page-membership-change",
9728
- pageIds: [...input.patchPlan.addedPages, ...input.patchPlan.removedPages]
9852
+ pageIds: membershipChangedPageIds
9729
9853
  };
9730
9854
  }
9731
9855
  if (input.currentDoc.childCount !== input.previousSurface.blocks.length || input.nextDoc.childCount !== input.nextSurface.blocks.length) {
@@ -9780,17 +9904,38 @@ function resolvePmPageBodyPatchPlan(input) {
9780
9904
  pageIds: [pageId]
9781
9905
  };
9782
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
+ });
9783
9919
  rawSpans.push(
9784
- nestedSpan.status === "nested" ? nestedSpan.span : {
9785
- pageIds: [pageId],
9786
- fromBlockIndex: previousRange.first,
9787
- toBlockIndex: previousRange.last + 1,
9788
- nextFromBlockIndex: nextRange.first,
9789
- nextToBlockIndex: nextRange.last + 1
9790
- }
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
+ ]
9791
9929
  );
9792
9930
  }
9793
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
+ }
9794
9939
  return {
9795
9940
  status: "fallback",
9796
9941
  reason: "no-body-fragment-changes",
@@ -9861,7 +10006,7 @@ function resolveNestedPatchSpan(input) {
9861
10006
  if (previousLocated.some((span) => !span) || nextLocated.some((span) => !span)) {
9862
10007
  return { status: "fallback", reason: "nested-span-unavailable" };
9863
10008
  }
9864
- if (previousLocated.some((span) => span?.insideVerticalMergeContinuation) || nextLocated.some((span) => span?.insideVerticalMergeContinuation)) {
10009
+ if (previousLocated.some(isUnpatchableVerticalMergeContinuationSpan) || nextLocated.some(isUnpatchableVerticalMergeContinuationSpan)) {
9865
10010
  return { status: "fallback", reason: "split-row-continuation" };
9866
10011
  }
9867
10012
  const previousSpans = previousLocated;
@@ -9887,6 +10032,64 @@ function resolveNestedPatchSpan(input) {
9887
10032
  }
9888
10033
  };
9889
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
+ }
9890
10093
  function findNestedBlockSpanById(blocks, doc, blockId) {
9891
10094
  return findBlockSpanByIdInContainer({
9892
10095
  blocks,
@@ -13518,8 +13721,17 @@ function pageIdsFromRenderFrame(frame) {
13518
13721
  return frame.pages.map((page) => page.page.pageId);
13519
13722
  }
13520
13723
  function resolvePageBodyPatchForMountedState(input) {
13521
- if (!input.previousSurface || !input.previousFrame || !input.nextFrame || input.previousPlugins !== input.plugins) {
13522
- return { status: "fallback" };
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" };
13523
13735
  }
13524
13736
  const patchPlan = createPagePatchPlan(input.previousFrame, input.nextFrame, void 0, {
13525
13737
  mountedPageIds: pageIdsFromRenderFrame(input.previousFrame),
@@ -13720,8 +13932,12 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13720
13932
  onPasteFragment: (meta) => {
13721
13933
  props.onPasteFragment?.(meta);
13722
13934
  },
13723
- onPastePlainTextFragment: (fragment) => {
13724
- 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
+ });
13725
13941
  },
13726
13942
  shouldPastePlainTextAsFragment: () => snapshotRef.current.documentMode !== "suggesting",
13727
13943
  onPasteImage: (meta) => {
@@ -13863,7 +14079,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
13863
14079
  onBlockedInput: (command, message) => callbacksRef.current?.onBlockedInput?.(command, message),
13864
14080
  onPasteApplied: (meta) => callbacksRef.current?.onPasteApplied?.(meta),
13865
14081
  onPasteFragment: (meta) => callbacksRef.current?.onPasteFragment?.(meta),
13866
- onPastePlainTextFragment: (fragment) => callbacksRef.current?.onPastePlainTextFragment?.(fragment),
14082
+ onPastePlainTextFragment: (fragment, context) => callbacksRef.current?.onPastePlainTextFragment?.(fragment, context),
13867
14083
  shouldPastePlainTextAsFragment: () => callbacksRef.current?.shouldPastePlainTextAsFragment?.() ?? true,
13868
14084
  onPasteImage: (meta) => callbacksRef.current?.onPasteImage?.(meta),
13869
14085
  onDropFragment: (meta) => callbacksRef.current?.onDropFragment?.(meta),
@@ -14065,6 +14281,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
14065
14281
  useEffect4(() => {
14066
14282
  if (!mountRef.current || !surface) return;
14067
14283
  if (viewRef.current && documentBuildKeyRef.current === documentBuildKey) {
14284
+ incrementInvalidationCounter("pm.rebuild.skip.documentBuildKey");
14068
14285
  pendingRebuildScrollAnchorRef.current = null;
14069
14286
  return;
14070
14287
  }
@@ -14073,6 +14290,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
14073
14290
  positionMapRef.current = buildPositionMap(surface);
14074
14291
  documentBuildKeyRef.current = documentBuildKey;
14075
14292
  applyDecorationProps(viewRef.current, positionMapRef.current);
14293
+ incrementInvalidationCounter("pm.rebuild.skip.equivalentAck");
14076
14294
  equivalentAckLedgerRef.current.delete(snapshot.revisionToken);
14077
14295
  localEquivalentOpsRef.current = [];
14078
14296
  pendingRebuildScrollAnchorRef.current = null;
@@ -15639,6 +15857,15 @@ function deriveShellPinnedSurfaces(chromePreset, chromeOptions) {
15639
15857
  import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
15640
15858
  var EMU_PER_CSS_PX = 9525;
15641
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
+ }
15642
15869
  function createMountedObjectDragSession(runtime, input) {
15643
15870
  nextObjectDragSessionId += 1;
15644
15871
  const sessionId = `object-drag-${nextObjectDragSessionId}`;
@@ -17911,7 +18138,10 @@ var WordReviewEditor = forwardRef3(
17911
18138
  // auto-bracketing in insertFragment + our explicit startAction around
17912
18139
  // the delete, so the undo history sees a single atomic action.
17913
18140
  onDropFragment: (meta) => {
17914
- const dropEditableTarget = meta.editableTarget ?? activeRuntime.getRenderSnapshot().selection.editableTarget;
18141
+ const dropEditableTarget = preferListTextEditableTarget(
18142
+ meta.editableTarget,
18143
+ activeRuntime.getRenderSnapshot().selection.editableTarget
18144
+ );
17915
18145
  if (meta.effect === "move" && meta.sourceRange) {
17916
18146
  activeRuntime.startAction("drag-move");
17917
18147
  try {
@@ -17922,7 +18152,10 @@ var WordReviewEditor = forwardRef3(
17922
18152
  assoc: { start: -1, end: 1 }
17923
18153
  });
17924
18154
  const currentEditableTarget = activeRuntime.getRenderSnapshot().selection.editableTarget;
17925
- const editableTarget = currentEditableTarget?.targetKey === dropEditableTarget?.targetKey ? currentEditableTarget : dropEditableTarget;
18155
+ const editableTarget = preferListTextEditableTarget(
18156
+ currentEditableTarget?.targetKey === dropEditableTarget?.targetKey ? currentEditableTarget : void 0,
18157
+ dropEditableTarget
18158
+ );
17926
18159
  activeRuntime.insertFragment(
17927
18160
  meta.fragment,
17928
18161
  void 0,
@@ -17961,7 +18194,10 @@ var WordReviewEditor = forwardRef3(
17961
18194
  // insertFragment auto-bracket (R.5.a Phase 2) makes the paste a
17962
18195
  // single-undo action.
17963
18196
  onPasteFragment: (meta) => {
17964
- const editableTarget = activeRuntime.getRenderSnapshot().selection.editableTarget;
18197
+ const editableTarget = preferListTextEditableTarget(
18198
+ meta.editableTarget,
18199
+ activeRuntime.getRenderSnapshot().selection.editableTarget
18200
+ );
17965
18201
  activeRuntime.insertFragment(
17966
18202
  meta.fragment,
17967
18203
  void 0,
@@ -18314,6 +18550,9 @@ var WordReviewEditor = forwardRef3(
18314
18550
  onDeleteTable: commands.onDeleteTable,
18315
18551
  onMergeCells: commands.onMergeCells,
18316
18552
  onSplitCell: commands.onSplitCell,
18553
+ onUpdateFields: () => {
18554
+ activeRuntime.updateFields();
18555
+ },
18317
18556
  onAskAgentForSelection: () => {
18318
18557
  const { selection } = snapshot;
18319
18558
  onEventRef.current?.({