@beyondwork/docx-react-component 1.0.134 → 1.0.135

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 (83) hide show
  1. package/dist/api/public-types.cjs +20 -2
  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 +2 -2
  5. package/dist/api/v3.cjs +20 -2
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +4 -4
  9. package/dist/{chunk-REFHJ2FN.js → chunk-2BNXARVO.js} +3 -3
  10. package/dist/{chunk-INLRCC4N.js → chunk-4CIHTMCH.js} +2 -2
  11. package/dist/{chunk-IJD6D7HU.js → chunk-5CCYF333.js} +2 -2
  12. package/dist/{chunk-MQ5GAJ54.js → chunk-BJXSMPHD.js} +1 -1
  13. package/dist/{chunk-ESEEWELA.js → chunk-EPFVMUKF.js} +3 -3
  14. package/dist/{chunk-XBQFDBXE.js → chunk-EZFF6GKF.js} +9 -2
  15. package/dist/{chunk-3YR47WTD.js → chunk-FGJTOFZY.js} +21 -9
  16. package/dist/{chunk-EBSI6VQX.js → chunk-GIFXKIM5.js} +181 -44
  17. package/dist/{chunk-74R5B2EZ.js → chunk-H4HI6RUE.js} +1 -1
  18. package/dist/{chunk-7Y6JCIK3.js → chunk-HWMPNLEF.js} +1 -1
  19. package/dist/{chunk-VA24T4EB.js → chunk-NEMOQ4QR.js} +1 -1
  20. package/dist/{chunk-O4EDZR44.js → chunk-P7XDEVS6.js} +12 -1
  21. package/dist/{chunk-QTRJLKR2.js → chunk-TSNK4ECL.js} +1 -1
  22. package/dist/{chunk-WDDFU2N2.js → chunk-UR2LW63N.js} +1 -1
  23. package/dist/core/commands/formatting-commands.d.cts +1 -1
  24. package/dist/core/commands/formatting-commands.d.ts +1 -1
  25. package/dist/core/commands/image-commands.cjs +9 -2
  26. package/dist/core/commands/image-commands.d.cts +1 -1
  27. package/dist/core/commands/image-commands.d.ts +1 -1
  28. package/dist/core/commands/image-commands.js +4 -4
  29. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  30. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  31. package/dist/core/commands/style-commands.d.cts +1 -1
  32. package/dist/core/commands/style-commands.d.ts +1 -1
  33. package/dist/core/commands/table-structure-commands.cjs +9 -2
  34. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  35. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  36. package/dist/core/commands/table-structure-commands.js +3 -3
  37. package/dist/core/commands/text-commands.cjs +9 -2
  38. package/dist/core/commands/text-commands.d.cts +1 -1
  39. package/dist/core/commands/text-commands.d.ts +1 -1
  40. package/dist/core/commands/text-commands.js +4 -4
  41. package/dist/core/selection/mapping.d.cts +1 -1
  42. package/dist/core/selection/mapping.d.ts +1 -1
  43. package/dist/core/state/editor-state.d.cts +1 -1
  44. package/dist/core/state/editor-state.d.ts +1 -1
  45. package/dist/index.cjs +212 -44
  46. package/dist/index.d.cts +4 -4
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.js +15 -14
  49. package/dist/io/docx-session.d.cts +3 -3
  50. package/dist/io/docx-session.d.ts +3 -3
  51. package/dist/{loader-CK3lZy4h.d.cts → loader-BQ7AB-0v.d.cts} +2 -2
  52. package/dist/{loader-CQXplstv.d.ts → loader-Cy6OYBfn.d.ts} +2 -2
  53. package/dist/{public-types-BR1SYK2F.d.cts → public-types-D31xKNGc.d.cts} +6 -0
  54. package/dist/{public-types-DXNZVKrS.d.ts → public-types-DqYt8GdP.d.ts} +6 -0
  55. package/dist/public-types.cjs +20 -2
  56. package/dist/public-types.d.cts +1 -1
  57. package/dist/public-types.d.ts +1 -1
  58. package/dist/public-types.js +2 -2
  59. package/dist/runtime/collab.d.cts +2 -2
  60. package/dist/runtime/collab.d.ts +2 -2
  61. package/dist/runtime/document-runtime.cjs +192 -37
  62. package/dist/runtime/document-runtime.d.cts +1 -1
  63. package/dist/runtime/document-runtime.d.ts +1 -1
  64. package/dist/runtime/document-runtime.js +10 -10
  65. package/dist/{session-CSbwkgII.d.cts → session-DA-F2fCw.d.cts} +2 -2
  66. package/dist/{session-C9UjrhJF.d.ts → session-DqL8H0oZ.d.ts} +2 -2
  67. package/dist/session.d.cts +4 -4
  68. package/dist/session.d.ts +4 -4
  69. package/dist/tailwind.cjs +27 -8
  70. package/dist/tailwind.d.cts +1 -1
  71. package/dist/tailwind.d.ts +1 -1
  72. package/dist/tailwind.js +5 -5
  73. package/dist/{types-CZtAueri.d.cts → types-B2y94n5t.d.cts} +1 -1
  74. package/dist/{types-RzkCXDNV.d.ts → types-SllbCtGs.d.ts} +1 -1
  75. package/dist/ui-tailwind/editor-surface/search-plugin.cjs +11 -0
  76. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  77. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  78. package/dist/ui-tailwind/editor-surface/search-plugin.js +3 -3
  79. package/dist/ui-tailwind.cjs +27 -8
  80. package/dist/ui-tailwind.d.cts +2 -2
  81. package/dist/ui-tailwind.d.ts +2 -2
  82. package/dist/ui-tailwind.js +5 -5
  83. package/package.json +1 -1
@@ -22,7 +22,7 @@ import {
22
22
  insertText,
23
23
  outdentParagraphAtSelection,
24
24
  splitParagraph
25
- } from "./chunk-REFHJ2FN.js";
25
+ } from "./chunk-2BNXARVO.js";
26
26
  import {
27
27
  applyFormattingOperationToDocument,
28
28
  applyTextMarkOperationToDocumentRange,
@@ -32,23 +32,23 @@ import {
32
32
  insertImage,
33
33
  repositionFloatingImage,
34
34
  resizeImage
35
- } from "./chunk-INLRCC4N.js";
35
+ } from "./chunk-4CIHTMCH.js";
36
36
  import {
37
37
  applyTextTransaction
38
- } from "./chunk-MQ5GAJ54.js";
38
+ } from "./chunk-BJXSMPHD.js";
39
39
  import {
40
40
  applyTableStructureOperationForEditableTarget,
41
41
  removeCellFromRow,
42
42
  removeTableRowPure
43
- } from "./chunk-WDDFU2N2.js";
43
+ } from "./chunk-UR2LW63N.js";
44
44
  import {
45
45
  resolveParagraphScope
46
- } from "./chunk-QTRJLKR2.js";
46
+ } from "./chunk-TSNK4ECL.js";
47
47
  import {
48
48
  buildGeometryDebugEntry,
49
49
  collectLineBoxesForRegion,
50
50
  createGeometryFacet
51
- } from "./chunk-74R5B2EZ.js";
51
+ } from "./chunk-H4HI6RUE.js";
52
52
  import {
53
53
  AI_ACTION_POLICIES,
54
54
  allocateNumberingInstance,
@@ -83,7 +83,7 @@ import {
83
83
  sameScopeParagraphPath,
84
84
  serializeFragmentToWordML,
85
85
  setStartOverride
86
- } from "./chunk-IJD6D7HU.js";
86
+ } from "./chunk-5CCYF333.js";
87
87
  import {
88
88
  ISSUE_METADATA_ID,
89
89
  LAYOUT_ENGINE_VERSION,
@@ -121,7 +121,7 @@ import {
121
121
  setWorkspaceMode,
122
122
  setZoomLevel,
123
123
  snapCommentAnchorAwayFromTable
124
- } from "./chunk-O4EDZR44.js";
124
+ } from "./chunk-P7XDEVS6.js";
125
125
  import {
126
126
  countLogicalPositions,
127
127
  createPlainText,
@@ -141,7 +141,7 @@ import {
141
141
  replaceStoryBlocks,
142
142
  resolvePageFieldDisplayText,
143
143
  storyTargetKey
144
- } from "./chunk-XBQFDBXE.js";
144
+ } from "./chunk-EZFF6GKF.js";
145
145
  import {
146
146
  createCommentSidebarProjection,
147
147
  createCommentStoreFromRuntimeComments
@@ -12800,6 +12800,36 @@ function createDocumentRuntime(options) {
12800
12800
  let viewportBlockRanges = null;
12801
12801
  let viewportRangesKey = serializeViewportRanges(viewportBlockRanges);
12802
12802
  let viewportBlocksPerPageEstimate = null;
12803
+ let fullSurfaceWarmupScheduled = false;
12804
+ let fullSurfaceWarmupCompleted = false;
12805
+ function scheduleFullSurfaceWarmupAfterCull() {
12806
+ if (fullSurfaceWarmupScheduled || fullSurfaceWarmupCompleted) return;
12807
+ fullSurfaceWarmupScheduled = true;
12808
+ perfCounters.increment("surface.fullSurfaceWarmup.scheduled");
12809
+ runOnIdle(() => {
12810
+ fullSurfaceWarmupScheduled = false;
12811
+ if (cachedFullSurface) {
12812
+ perfCounters.increment("surface.fullSurfaceWarmup.alreadyCached");
12813
+ fullSurfaceWarmupCompleted = true;
12814
+ return;
12815
+ }
12816
+ const t0 = performance.now();
12817
+ try {
12818
+ getCachedFullSurface(state.document, activeStory);
12819
+ fullSurfaceWarmupCompleted = true;
12820
+ perfCounters.increment("surface.fullSurfaceWarmup.committed");
12821
+ } catch (error) {
12822
+ perfCounters.increment("surface.fullSurfaceWarmup.failed");
12823
+ fullSurfaceWarmupCompleted = false;
12824
+ void error;
12825
+ } finally {
12826
+ perfCounters.increment(
12827
+ "surface.fullSurfaceWarmup.us",
12828
+ Math.round((performance.now() - t0) * 1e3)
12829
+ );
12830
+ }
12831
+ });
12832
+ }
12803
12833
  const getRuntimeForLayoutFacet = () => {
12804
12834
  if (!runtimeRef) {
12805
12835
  throw new Error("Document runtime viewport methods are not initialized");
@@ -12992,6 +13022,15 @@ function createDocumentRuntime(options) {
12992
13022
  let cachedSurface;
12993
13023
  let cachedFullSurface;
12994
13024
  const editableTargetBlockCache = createEditableTargetBlockCache();
13025
+ let paragraphCascadeCache = /* @__PURE__ */ new WeakMap();
13026
+ let paragraphCascadeCacheStylesRef = null;
13027
+ function ensureParagraphCascadeCacheForStyles(nextStyles) {
13028
+ if (paragraphCascadeCacheStylesRef !== nextStyles) {
13029
+ paragraphCascadeCache = /* @__PURE__ */ new WeakMap();
13030
+ paragraphCascadeCacheStylesRef = nextStyles;
13031
+ }
13032
+ return paragraphCascadeCache;
13033
+ }
12995
13034
  let cachedEditableTargetMap = null;
12996
13035
  function getEditableTargetsByBlockPath(document) {
12997
13036
  if (cachedEditableTargetMap !== null && cachedEditableTargetMap.document === document) {
@@ -13045,6 +13084,7 @@ function createDocumentRuntime(options) {
13045
13084
  const snapshot = createEditorSurfaceSnapshot(document, state.selection, nextActiveStory, {
13046
13085
  viewportBlockRanges: null,
13047
13086
  editableTargetsByBlockPath: getEditableTargetsByBlockPath(document),
13087
+ paragraphCascadeCache: ensureParagraphCascadeCacheForStyles(document.styles),
13048
13088
  ...effectiveMarkupModeProvider ? { getEffectiveMarkupMode: effectiveMarkupModeProvider } : {}
13049
13089
  });
13050
13090
  recordPerfSample("snapshot.surface");
@@ -13085,6 +13125,7 @@ function createDocumentRuntime(options) {
13085
13125
  activeStoryKey,
13086
13126
  surfaceViewportRanges
13087
13127
  ),
13128
+ paragraphCascadeCache: ensureParagraphCascadeCacheForStyles(document.styles),
13088
13129
  ...effectiveMarkupModeProvider ? { getEffectiveMarkupMode: effectiveMarkupModeProvider } : {}
13089
13130
  });
13090
13131
  recordPerfSample("snapshot.surface");
@@ -13296,7 +13337,17 @@ function createDocumentRuntime(options) {
13296
13337
  }
13297
13338
  }
13298
13339
  function tryPatchNestedLocalTextSurface(previousSurface, editFrom, editTo, insertedText) {
13299
- const shiftBudget = estimateLocalTextPatchShiftBudget(previousSurface.blocks, 0);
13340
+ const containerIndex = previousSurface.blocks.findIndex(
13341
+ (block) => editFrom >= block.from && editTo <= block.to
13342
+ );
13343
+ if (containerIndex < 0) {
13344
+ perfCounters.increment("surface.localText.patchMiss");
13345
+ return null;
13346
+ }
13347
+ const shiftBudget = estimateLocalTextPatchShiftBudget(
13348
+ previousSurface.blocks,
13349
+ containerIndex + 1
13350
+ );
13300
13351
  perfCounters.increment("surface.localText.shiftedBlocks", shiftBudget.shiftedBlocks);
13301
13352
  perfCounters.increment("surface.localText.shiftedNodes", shiftBudget.shiftedNodes);
13302
13353
  if (!shiftBudget.withinBudget) {
@@ -13376,19 +13427,9 @@ function createDocumentRuntime(options) {
13376
13427
  for (let index = startIndex; index < blocks.length; index += 1) {
13377
13428
  const shiftedBlockNodes = countSurfaceShiftNodesUpTo(
13378
13429
  blocks[index],
13379
- Math.min(
13380
- policy.maxShiftedNodesPerBlock,
13381
- policy.maxShiftedSurfaceNodes - shiftedNodes
13382
- ) + 1
13430
+ policy.maxShiftedSurfaceNodes - shiftedNodes + 1
13383
13431
  );
13384
13432
  shiftedNodes += shiftedBlockNodes;
13385
- if (shiftedBlockNodes > policy.maxShiftedNodesPerBlock) {
13386
- return {
13387
- shiftedBlocks,
13388
- shiftedNodes,
13389
- withinBudget: false
13390
- };
13391
- }
13392
13433
  if (shiftedNodes > policy.maxShiftedSurfaceNodes) {
13393
13434
  return {
13394
13435
  shiftedBlocks,
@@ -14060,6 +14101,9 @@ function createDocumentRuntime(options) {
14060
14101
  viewportBlockRangesOverride: firstSurfaceViewportBlockRanges
14061
14102
  }) : getCachedSurface(state.document, activeStory)
14062
14103
  );
14104
+ if (firstSurfaceViewportBlockRanges) {
14105
+ scheduleFullSurfaceWarmupAfterCull();
14106
+ }
14063
14107
  const snapshot = {
14064
14108
  documentId: state.documentId,
14065
14109
  sessionId: state.sessionId,
@@ -14173,6 +14217,9 @@ function createDocumentRuntime(options) {
14173
14217
  activeStoryKey,
14174
14218
  viewportBlockRanges
14175
14219
  ),
14220
+ paragraphCascadeCache: ensureParagraphCascadeCacheForStyles(
14221
+ state.document.styles
14222
+ ),
14176
14223
  ...effectiveMarkupModeProvider ? { getEffectiveMarkupMode: effectiveMarkupModeProvider } : {}
14177
14224
  }
14178
14225
  );
@@ -17445,10 +17492,11 @@ function createDocumentRuntime(options) {
17445
17492
  document: state.document,
17446
17493
  editableTarget,
17447
17494
  selection,
17495
+ storyTarget: activeStory,
17448
17496
  targetResolution,
17449
17497
  timestamp
17450
17498
  });
17451
- if (selectedListItemDelete && activeStory.kind === "main" && context.documentMode !== "suggesting") {
17499
+ if (selectedListItemDelete && context.documentMode !== "suggesting") {
17452
17500
  const replacementCommand = {
17453
17501
  type: "document.replace",
17454
17502
  document: selectedListItemDelete.document,
@@ -17713,6 +17761,9 @@ function createDocumentRuntime(options) {
17713
17761
  });
17714
17762
  }
17715
17763
  function scheduleIdleContextAnalytics(callback) {
17764
+ runOnIdle(callback);
17765
+ }
17766
+ function runOnIdle(callback) {
17716
17767
  const requestIdle = globalThis.requestIdleCallback;
17717
17768
  if (typeof requestIdle === "function") {
17718
17769
  requestIdle(callback, { timeout: 250 });
@@ -20353,7 +20404,7 @@ function isTopLevelMainStoryBlockPath(blockPath) {
20353
20404
  return typeof blockPath === "string" && /^main\/block\[\d+\]$/u.test(blockPath);
20354
20405
  }
20355
20406
  function createSelectedListItemDeleteReplacement(input) {
20356
- const { command, document, editableTarget, selection, targetResolution, timestamp } = input;
20407
+ const { command, document, editableTarget, selection, storyTarget, targetResolution, timestamp } = input;
20357
20408
  if (command.type !== "text.delete-backward" && command.type !== "text.delete-forward") {
20358
20409
  return null;
20359
20410
  }
@@ -20365,20 +20416,19 @@ function createSelectedListItemDeleteReplacement(input) {
20365
20416
  if (selectionFrom !== targetResolution.range.from || selectionTo !== targetResolution.range.to) {
20366
20417
  return null;
20367
20418
  }
20368
- const root = document.content;
20369
- const replacement = removeNumberedParagraphAtMainStoryPath(root.children, editableTarget.blockPath);
20419
+ const storyBlocks = getStoryBlocks(document, storyTarget);
20420
+ const replacement = removeNumberedParagraphAtStoryPath(storyBlocks, editableTarget.blockPath, storyTarget);
20370
20421
  if (!replacement) {
20371
20422
  return null;
20372
20423
  }
20373
- const nextDocument = {
20424
+ const nextDocument = replaceStoryBlocks({
20374
20425
  ...document,
20375
- updatedAt: timestamp,
20376
- content: {
20377
- ...root,
20378
- children: replacement.blocks
20379
- }
20380
- };
20381
- const nextStorySize = parseTextStory(nextDocument.content).size;
20426
+ updatedAt: timestamp
20427
+ }, storyTarget, replacement.blocks);
20428
+ const nextStorySize = parseTextStory({
20429
+ type: "doc",
20430
+ children: [...getStoryBlocks(nextDocument, storyTarget)]
20431
+ }).size;
20382
20432
  const nextAnchor = Math.min(selectionFrom, nextStorySize);
20383
20433
  return {
20384
20434
  document: nextDocument,
@@ -20395,8 +20445,8 @@ function createSelectedListItemDeleteReplacement(input) {
20395
20445
  }
20396
20446
  };
20397
20447
  }
20398
- function removeNumberedParagraphAtMainStoryPath(blocks, blockPath) {
20399
- const tokens = parseMainStoryBlockPathTokens(blockPath);
20448
+ function removeNumberedParagraphAtStoryPath(blocks, blockPath, storyTarget) {
20449
+ const tokens = parseStoryBlockPathTokens(blockPath, storyTarget);
20400
20450
  if (!tokens) return null;
20401
20451
  return removeNumberedParagraphFromBlocks(blocks, tokens);
20402
20452
  }
@@ -20442,6 +20492,52 @@ function removeNumberedParagraphFromBlocks(blocks, tokens) {
20442
20492
  ]
20443
20493
  };
20444
20494
  }
20495
+ if (block.type === "paragraph" && next?.kind === "inline") {
20496
+ const updatedParagraph = removeNumberedParagraphFromTextBoxInline(block, rest);
20497
+ if (!updatedParagraph) return null;
20498
+ return {
20499
+ blocks: [
20500
+ ...blocks.slice(0, token.index),
20501
+ updatedParagraph,
20502
+ ...blocks.slice(token.index + 1)
20503
+ ]
20504
+ };
20505
+ }
20506
+ return null;
20507
+ }
20508
+ function removeNumberedParagraphFromTextBoxInline(paragraph, tokens) {
20509
+ const [inlineToken, textBoxToken, ...childTokens] = tokens;
20510
+ if (inlineToken?.kind !== "inline" || textBoxToken?.kind !== "txbx" || childTokens[0]?.kind !== "block") {
20511
+ return null;
20512
+ }
20513
+ const inline = paragraph.children[inlineToken.index];
20514
+ if (!inline) return null;
20515
+ const updatedInline = removeNumberedParagraphFromInlineTextBox(inline, childTokens);
20516
+ if (!updatedInline) return null;
20517
+ return {
20518
+ ...paragraph,
20519
+ children: [
20520
+ ...paragraph.children.slice(0, inlineToken.index),
20521
+ updatedInline,
20522
+ ...paragraph.children.slice(inlineToken.index + 1)
20523
+ ]
20524
+ };
20525
+ }
20526
+ function removeNumberedParagraphFromInlineTextBox(inline, tokens) {
20527
+ if (inline.type === "shape" && inline.txbxBlocks) {
20528
+ const updatedBlocks = removeNumberedParagraphFromBlocks(inline.txbxBlocks, tokens);
20529
+ return updatedBlocks ? { ...inline, txbxBlocks: updatedBlocks.blocks } : null;
20530
+ }
20531
+ if (inline.type === "drawing_frame" && inline.content.type === "shape" && inline.content.txbxBlocks) {
20532
+ const updatedBlocks = removeNumberedParagraphFromBlocks(inline.content.txbxBlocks, tokens);
20533
+ return updatedBlocks ? {
20534
+ ...inline,
20535
+ content: {
20536
+ ...inline.content,
20537
+ txbxBlocks: updatedBlocks.blocks
20538
+ }
20539
+ } : null;
20540
+ }
20445
20541
  return null;
20446
20542
  }
20447
20543
  function removeNumberedParagraphFromTable(table, tokens) {
@@ -20482,15 +20578,29 @@ function createSelectedListItemDeleteReplayCommand(input) {
20482
20578
  target: editableTarget,
20483
20579
  activeStoryKey: canonicalEditableTargetStoryKey(storyTarget)
20484
20580
  });
20581
+ const resolvedEditableTarget = targetResolution.kind === "accepted" ? editableTarget : storyTarget.kind !== "main" && blockPathBelongsToStoryTarget(editableTarget.blockPath, storyTarget) ? resolveEditableCommandTarget({
20582
+ document,
20583
+ target: editableTarget,
20584
+ activeStoryKey: canonicalEditableTargetStoryKey(storyTarget),
20585
+ commandFamilies: ["text-leaf"]
20586
+ }) : null;
20587
+ const selectedRange = {
20588
+ from: Math.min(selection.anchor, selection.head),
20589
+ to: Math.max(selection.anchor, selection.head)
20590
+ };
20485
20591
  const replacement = createSelectedListItemDeleteReplacement({
20486
20592
  command,
20487
20593
  document,
20488
- editableTarget,
20594
+ editableTarget: resolvedEditableTarget && resolvedEditableTarget.kind === "accepted" ? resolvedEditableTarget.target : editableTarget,
20489
20595
  selection,
20490
- targetResolution,
20596
+ storyTarget,
20597
+ targetResolution: resolvedEditableTarget && resolvedEditableTarget.kind === "accepted" ? {
20598
+ kind: "accepted",
20599
+ range: selectedRange
20600
+ } : targetResolution,
20491
20601
  timestamp
20492
20602
  });
20493
- if (!replacement || storyTarget.kind !== "main") {
20603
+ if (!replacement) {
20494
20604
  return null;
20495
20605
  }
20496
20606
  return {
@@ -20502,22 +20612,49 @@ function createSelectedListItemDeleteReplayCommand(input) {
20502
20612
  origin: command.origin
20503
20613
  };
20504
20614
  }
20505
- function parseMainStoryBlockPathTokens(blockPath) {
20506
- const parts = blockPath?.split("/") ?? [];
20507
- if (parts[0] !== "main" || parts.length < 2) {
20615
+ function parseStoryBlockPathTokens(blockPath, storyTarget) {
20616
+ if (!blockPath) {
20617
+ return null;
20618
+ }
20619
+ const firstTokenMatch = /\/(?:block|row|cell)\[\d+\]/u.exec(blockPath);
20620
+ if (!firstTokenMatch?.index) {
20508
20621
  return null;
20509
20622
  }
20623
+ const storyPrefix = blockPath.slice(0, firstTokenMatch.index);
20624
+ if (!blockPathBelongsToStoryTarget(storyPrefix, storyTarget)) {
20625
+ return null;
20626
+ }
20627
+ const parts = blockPath.slice(firstTokenMatch.index + 1).split("/");
20510
20628
  const tokens = [];
20511
- for (const part of parts.slice(1)) {
20512
- const match = /^(block|row|cell)\[(\d+)\]$/u.exec(part);
20629
+ for (const part of parts) {
20630
+ if (part === "txbx") {
20631
+ tokens.push({ kind: "txbx" });
20632
+ continue;
20633
+ }
20634
+ const match = /^(block|row|cell|inline)\[(\d+)\]$/u.exec(part);
20513
20635
  if (!match) return null;
20636
+ const kind = match[1];
20514
20637
  tokens.push({
20515
- kind: match[1],
20638
+ kind,
20516
20639
  index: Number.parseInt(match[2], 10)
20517
20640
  });
20518
20641
  }
20519
20642
  return tokens;
20520
20643
  }
20644
+ function blockPathBelongsToStoryTarget(storyPrefix, storyTarget) {
20645
+ switch (storyTarget.kind) {
20646
+ case "main":
20647
+ return storyPrefix === "main" || storyPrefix.startsWith("main/");
20648
+ case "header":
20649
+ return storyPrefix.startsWith("header:");
20650
+ case "footer":
20651
+ return storyPrefix.startsWith("footer:");
20652
+ case "footnote":
20653
+ return storyPrefix === `footnote:${storyTarget.noteId}` || storyPrefix.startsWith(`footnote:${storyTarget.noteId}/`);
20654
+ case "endnote":
20655
+ return storyPrefix === `endnote:${storyTarget.noteId}` || storyPrefix.startsWith(`endnote:${storyTarget.noteId}/`);
20656
+ }
20657
+ }
20521
20658
  function toInternalSelectionSnapshot(selection) {
20522
20659
  return {
20523
20660
  anchor: selection.anchor,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PAGE_STACK_GAP_PX,
3
3
  resolveDefaultZoom
4
- } from "./chunk-O4EDZR44.js";
4
+ } from "./chunk-P7XDEVS6.js";
5
5
  import {
6
6
  MAIN_STORY_KEY,
7
7
  collectCanonicalLayoutInputs,
@@ -8,7 +8,7 @@ import {
8
8
  getRevisionRangeState,
9
9
  selectionTouchesRange,
10
10
  shouldHideInCleanMode
11
- } from "./chunk-3YR47WTD.js";
11
+ } from "./chunk-FGJTOFZY.js";
12
12
 
13
13
  // src/ui-tailwind/editor-surface/tw-editor-surface.tsx
14
14
  import { useMemo } from "react";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildSearchPattern
3
- } from "./chunk-O4EDZR44.js";
3
+ } from "./chunk-P7XDEVS6.js";
4
4
 
5
5
  // src/ui-tailwind/editor-surface/search-plugin.ts
6
6
  import { Plugin, PluginKey } from "prosemirror-state";
@@ -20,7 +20,7 @@ import {
20
20
  resolveSectionVariants,
21
21
  sectionSupportsStoryTarget,
22
22
  storyTargetKey
23
- } from "./chunk-XBQFDBXE.js";
23
+ } from "./chunk-EZFF6GKF.js";
24
24
  import {
25
25
  createSelectionSnapshot
26
26
  } from "./chunk-OYGMRRR7.js";
@@ -8998,6 +8998,8 @@ function buildSearchPattern(query, options = {}) {
8998
8998
  function findSearchMatches(text, query, options = {}) {
8999
8999
  const pattern = buildSearchPattern(query, options);
9000
9000
  if (!pattern) return [];
9001
+ const limit = normalizeSearchLimit(options.limit);
9002
+ if (limit === 0) return [];
9001
9003
  const results = [];
9002
9004
  let match;
9003
9005
  pattern.lastIndex = 0;
@@ -9008,12 +9010,21 @@ function findSearchMatches(text, query, options = {}) {
9008
9010
  text: match[0],
9009
9011
  index: results.length
9010
9012
  });
9013
+ if (results.length >= limit) {
9014
+ break;
9015
+ }
9011
9016
  if (match[0].length === 0) {
9012
9017
  pattern.lastIndex += 1;
9013
9018
  }
9014
9019
  }
9015
9020
  return results;
9016
9021
  }
9022
+ function normalizeSearchLimit(limit) {
9023
+ if (limit === void 0 || !Number.isFinite(limit)) {
9024
+ return Number.POSITIVE_INFINITY;
9025
+ }
9026
+ return Math.max(0, Math.floor(limit));
9027
+ }
9017
9028
  function createSearchExcerpt(text, from, to, radius = 24) {
9018
9029
  const safeFrom = Math.max(0, Math.min(from, text.length));
9019
9030
  const safeTo = Math.max(safeFrom, Math.min(to, text.length));
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  NO_EDITABLE_TARGETS_INDEX,
3
3
  createEditorSurfaceSnapshot
4
- } from "./chunk-XBQFDBXE.js";
4
+ } from "./chunk-EZFF6GKF.js";
5
5
  import {
6
6
  createSelectionSnapshot
7
7
  } from "./chunk-OYGMRRR7.js";
@@ -3,7 +3,7 @@ import {
3
3
  createNoopStructuralMutation,
4
4
  findTableCellParagraphSelection,
5
5
  findTopLevelParagraphSelectionNearBlock
6
- } from "./chunk-QTRJLKR2.js";
6
+ } from "./chunk-TSNK4ECL.js";
7
7
  import {
8
8
  collectEditableTargetRefs,
9
9
  collectStoryBlockContexts,
@@ -1,6 +1,6 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { gc as Alignment, gd as FormattingMutationResult, ge as FormattingOperation, gf as TextMarkClearTarget, gg as TextMarkRangeOperation, gh as applyFormattingOperationToDocument, gi as applyIndentation, gj as applyTextMarkOperationToDocumentRange, gk as getFormattingStateFromRenderSnapshot, gl as isMarkActive, gm as makeSetAlignment, gn as makeSetFontFamily, go as makeSetFontSize, gp as makeSetHighlight, gq as makeSetTextColor, gr as makeToggleAllCaps, gs as makeToggleBold, gt as makeToggleItalic, gu as makeToggleSmallCaps, gv as makeToggleStrikethrough, gw as makeToggleSubscript, gx as makeToggleSuperscript, gy as makeToggleUnderline } from '../../public-types-BR1SYK2F.cjs';
3
+ export { gc as Alignment, gd as FormattingMutationResult, ge as FormattingOperation, gf as TextMarkClearTarget, gg as TextMarkRangeOperation, gh as applyFormattingOperationToDocument, gi as applyIndentation, gj as applyTextMarkOperationToDocumentRange, gk as getFormattingStateFromRenderSnapshot, gl as isMarkActive, gm as makeSetAlignment, gn as makeSetFontFamily, go as makeSetFontSize, gp as makeSetHighlight, gq as makeSetTextColor, gr as makeToggleAllCaps, gs as makeToggleBold, gt as makeToggleItalic, gu as makeToggleSmallCaps, gv as makeToggleStrikethrough, gw as makeToggleSubscript, gx as makeToggleSuperscript, gy as makeToggleUnderline } from '../../public-types-D31xKNGc.cjs';
4
4
  import '../../canonical-document-CfZIc-fC.cjs';
5
5
  import 'react';
6
6
  import 'yjs';
@@ -1,6 +1,6 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { gc as Alignment, gd as FormattingMutationResult, ge as FormattingOperation, gf as TextMarkClearTarget, gg as TextMarkRangeOperation, gh as applyFormattingOperationToDocument, gi as applyIndentation, gj as applyTextMarkOperationToDocumentRange, gk as getFormattingStateFromRenderSnapshot, gl as isMarkActive, gm as makeSetAlignment, gn as makeSetFontFamily, go as makeSetFontSize, gp as makeSetHighlight, gq as makeSetTextColor, gr as makeToggleAllCaps, gs as makeToggleBold, gt as makeToggleItalic, gu as makeToggleSmallCaps, gv as makeToggleStrikethrough, gw as makeToggleSubscript, gx as makeToggleSuperscript, gy as makeToggleUnderline } from '../../public-types-DXNZVKrS.js';
3
+ export { gc as Alignment, gd as FormattingMutationResult, ge as FormattingOperation, gf as TextMarkClearTarget, gg as TextMarkRangeOperation, gh as applyFormattingOperationToDocument, gi as applyIndentation, gj as applyTextMarkOperationToDocumentRange, gk as getFormattingStateFromRenderSnapshot, gl as isMarkActive, gm as makeSetAlignment, gn as makeSetFontFamily, go as makeSetFontSize, gp as makeSetHighlight, gq as makeSetTextColor, gr as makeToggleAllCaps, gs as makeToggleBold, gt as makeToggleItalic, gu as makeToggleSmallCaps, gv as makeToggleStrikethrough, gw as makeToggleSubscript, gx as makeToggleSuperscript, gy as makeToggleUnderline } from '../../public-types-DqYt8GdP.js';
4
4
  import '../../canonical-document-CfZIc-fC.js';
5
5
  import 'react';
6
6
  import 'yjs';
@@ -5315,10 +5315,16 @@ var FormattingContextImpl = class {
5315
5315
  // surface-projection calls `resolveParagraphCascade` on the same
5316
5316
  // paragraph via `resolveParagraph` + numbering resolve + marker-rPr;
5317
5317
  // each of those re-walked the style catalog before.
5318
- paragraphCascadeCache = /* @__PURE__ */ new WeakMap();
5318
+ //
5319
+ // Defaults to a per-context instance, but the runtime can supply a
5320
+ // persistent `WeakMap` via `FormattingContextOptions.paragraphCascadeCache`
5321
+ // so unchanged paragraphs don't re-cascade on every keystroke. See the
5322
+ // contract on the option for invalidation semantics.
5323
+ paragraphCascadeCache;
5319
5324
  constructor(doc, opts) {
5320
5325
  this.doc = doc;
5321
5326
  this.opts = opts;
5327
+ this.paragraphCascadeCache = opts.paragraphCascadeCache ?? /* @__PURE__ */ new WeakMap();
5322
5328
  const canonicalTheme = doc.subParts?.canonicalTheme;
5323
5329
  this.theme = opts.themeResolver ?? (canonicalTheme ? new ThemeColorResolver(canonicalTheme) : void 0);
5324
5330
  this.numbering = opts.numberingPrefixResolver ?? createNumberingPrefixResolver(doc.numbering);
@@ -5803,7 +5809,8 @@ function createEditorSurfaceSnapshot(document, _selection, activeStory = { kind:
5803
5809
  const formattingContext = createFormattingContext(document, {
5804
5810
  ...options.revisionMarkupMode ? { revisionMarkupMode: options.revisionMarkupMode } : {},
5805
5811
  ...options.getEffectiveMarkupMode ? { getEffectiveMarkupMode: options.getEffectiveMarkupMode } : {},
5806
- ...options.authorColorPalette ? { authorColorPalette: options.authorColorPalette } : {}
5812
+ ...options.authorColorPalette ? { authorColorPalette: options.authorColorPalette } : {},
5813
+ ...options.paragraphCascadeCache ? { paragraphCascadeCache: options.paragraphCascadeCache } : {}
5807
5814
  });
5808
5815
  const editableTargetsByBlockPath = options.editableTargetsByBlockPath ?? indexEditableTargetsByBlockPath(document);
5809
5816
  const layoutIdentitiesByBlockPath = options.layoutIdentitiesByBlockPath;
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-BR1SYK2F.cjs';
1
+ import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-D31xKNGc.cjs';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-DXNZVKrS.js';
1
+ import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-DqYt8GdP.js';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -2,11 +2,11 @@ import {
2
2
  insertImage,
3
3
  repositionFloatingImage,
4
4
  resizeImage
5
- } from "../../chunk-INLRCC4N.js";
6
- import "../../chunk-MQ5GAJ54.js";
7
- import "../../chunk-QTRJLKR2.js";
5
+ } from "../../chunk-4CIHTMCH.js";
6
+ import "../../chunk-BJXSMPHD.js";
7
+ import "../../chunk-TSNK4ECL.js";
8
8
  import "../../chunk-QIO6V46H.js";
9
- import "../../chunk-XBQFDBXE.js";
9
+ import "../../chunk-EZFF6GKF.js";
10
10
  import "../../chunk-OYGMRRR7.js";
11
11
  import "../../chunk-5KTJKTNE.js";
12
12
  import "../../chunk-UFVDIR2C.js";
@@ -1,4 +1,4 @@
1
- import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-BR1SYK2F.cjs';
1
+ import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-D31xKNGc.cjs';
2
2
  import { C as CanonicalDocument, P as PageSize, a as PageMargins, b as ColumnProperties, c as PageNumbering } from '../../canonical-document-CfZIc-fC.cjs';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -1,4 +1,4 @@
1
- import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-DXNZVKrS.js';
1
+ import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-DqYt8GdP.js';
2
2
  import { C as CanonicalDocument, P as PageSize, a as PageMargins, b as ColumnProperties, c as PageNumbering } from '../../canonical-document-CfZIc-fC.js';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -1,4 +1,4 @@
1
- import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-BR1SYK2F.cjs';
1
+ import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-D31xKNGc.cjs';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1,4 +1,4 @@
1
- import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-DXNZVKrS.js';
1
+ import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-DqYt8GdP.js';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -4880,10 +4880,16 @@ var FormattingContextImpl = class {
4880
4880
  // surface-projection calls `resolveParagraphCascade` on the same
4881
4881
  // paragraph via `resolveParagraph` + numbering resolve + marker-rPr;
4882
4882
  // each of those re-walked the style catalog before.
4883
- paragraphCascadeCache = /* @__PURE__ */ new WeakMap();
4883
+ //
4884
+ // Defaults to a per-context instance, but the runtime can supply a
4885
+ // persistent `WeakMap` via `FormattingContextOptions.paragraphCascadeCache`
4886
+ // so unchanged paragraphs don't re-cascade on every keystroke. See the
4887
+ // contract on the option for invalidation semantics.
4888
+ paragraphCascadeCache;
4884
4889
  constructor(doc, opts) {
4885
4890
  this.doc = doc;
4886
4891
  this.opts = opts;
4892
+ this.paragraphCascadeCache = opts.paragraphCascadeCache ?? /* @__PURE__ */ new WeakMap();
4887
4893
  const canonicalTheme = doc.subParts?.canonicalTheme;
4888
4894
  this.theme = opts.themeResolver ?? (canonicalTheme ? new ThemeColorResolver(canonicalTheme) : void 0);
4889
4895
  this.numbering = opts.numberingPrefixResolver ?? createNumberingPrefixResolver(doc.numbering);
@@ -5367,7 +5373,8 @@ function createEditorSurfaceSnapshot(document, _selection, activeStory = { kind:
5367
5373
  const formattingContext = createFormattingContext(document, {
5368
5374
  ...options.revisionMarkupMode ? { revisionMarkupMode: options.revisionMarkupMode } : {},
5369
5375
  ...options.getEffectiveMarkupMode ? { getEffectiveMarkupMode: options.getEffectiveMarkupMode } : {},
5370
- ...options.authorColorPalette ? { authorColorPalette: options.authorColorPalette } : {}
5376
+ ...options.authorColorPalette ? { authorColorPalette: options.authorColorPalette } : {},
5377
+ ...options.paragraphCascadeCache ? { paragraphCascadeCache: options.paragraphCascadeCache } : {}
5371
5378
  });
5372
5379
  const editableTargetsByBlockPath = options.editableTargetsByBlockPath ?? indexEditableTargetsByBlockPath(document);
5373
5380
  const layoutIdentitiesByBlockPath = options.layoutIdentitiesByBlockPath;
@@ -1,4 +1,4 @@
1
- export { gz as CellLocator, gA as TableStructureOperation, gB as applyTableStructureOperation, gC as applyTableStructureOperationForEditableTarget, gD as getTableStructureContext, gE as removeCellFromRow, gF as removeTableRowPure, gG as tableStructureActionHandleForTarget } from '../../public-types-BR1SYK2F.cjs';
1
+ export { gz as CellLocator, gA as TableStructureOperation, gB as applyTableStructureOperation, gC as applyTableStructureOperationForEditableTarget, gD as getTableStructureContext, gE as removeCellFromRow, gF as removeTableRowPure, gG as tableStructureActionHandleForTarget } from '../../public-types-D31xKNGc.cjs';
2
2
  import '../../canonical-document-CfZIc-fC.cjs';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -1,4 +1,4 @@
1
- export { gz as CellLocator, gA as TableStructureOperation, gB as applyTableStructureOperation, gC as applyTableStructureOperationForEditableTarget, gD as getTableStructureContext, gE as removeCellFromRow, gF as removeTableRowPure, gG as tableStructureActionHandleForTarget } from '../../public-types-DXNZVKrS.js';
1
+ export { gz as CellLocator, gA as TableStructureOperation, gB as applyTableStructureOperation, gC as applyTableStructureOperationForEditableTarget, gD as getTableStructureContext, gE as removeCellFromRow, gF as removeTableRowPure, gG as tableStructureActionHandleForTarget } from '../../public-types-DqYt8GdP.js';
2
2
  import '../../canonical-document-CfZIc-fC.js';
3
3
  import 'react';
4
4
  import 'yjs';