@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
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-M6XR534O.js";
12
12
  import {
13
13
  buildBookmarkNameMap
14
- } from "./chunk-ZVC23LKV.js";
14
+ } from "./chunk-RP76USJE.js";
15
15
  import {
16
16
  deleteSelectionOrBackward,
17
17
  deleteSelectionOrForward,
@@ -22,7 +22,7 @@ import {
22
22
  insertText,
23
23
  outdentParagraphAtSelection,
24
24
  splitParagraph
25
- } from "./chunk-QXKQPUOM.js";
25
+ } from "./chunk-REFHJ2FN.js";
26
26
  import {
27
27
  applyFormattingOperationToDocument,
28
28
  applyTextMarkOperationToDocumentRange,
@@ -32,32 +32,30 @@ import {
32
32
  insertImage,
33
33
  repositionFloatingImage,
34
34
  resizeImage
35
- } from "./chunk-KNHMXKC6.js";
35
+ } from "./chunk-INLRCC4N.js";
36
36
  import {
37
37
  applyTextTransaction
38
- } from "./chunk-T5YYFDZB.js";
38
+ } from "./chunk-MQ5GAJ54.js";
39
39
  import {
40
40
  applyTableStructureOperationForEditableTarget,
41
41
  removeCellFromRow,
42
42
  removeTableRowPure
43
- } from "./chunk-Q7Y57KOK.js";
43
+ } from "./chunk-WDDFU2N2.js";
44
44
  import {
45
45
  resolveParagraphScope
46
- } from "./chunk-PHMWH23E.js";
46
+ } from "./chunk-QTRJLKR2.js";
47
47
  import {
48
48
  buildGeometryDebugEntry,
49
49
  collectLineBoxesForRegion,
50
- createGeometryFacet,
51
- createRenderKernel,
52
- incrementInvalidationCounter,
53
- recordPerfSample
54
- } from "./chunk-35RHOE6I.js";
50
+ createGeometryFacet
51
+ } from "./chunk-57HTKX3P.js";
55
52
  import {
56
53
  AI_ACTION_POLICIES,
57
54
  allocateNumberingInstance,
58
55
  buildFormattingDebugEntry,
59
56
  cloneNumberingCatalog,
60
57
  collectScopeLocations,
58
+ computeScopeStoryLayout,
61
59
  createDocumentOutlineSnapshot,
62
60
  createDocumentSectionSnapshots,
63
61
  createScopeCompilerService,
@@ -67,19 +65,25 @@ import {
67
65
  findAllScopesAt,
68
66
  findBookmarkNameForOffset,
69
67
  findDocumentSectionSnapshot,
68
+ findOwningBlockSlotAtPosition,
69
+ findParagraphSlotAtPosition,
70
70
  findScopesIntersecting,
71
71
  findTextMatches,
72
72
  findTextWithStyleMatches,
73
73
  getListKind,
74
+ inlineLengthForScopeCoordinates,
74
75
  rebuildFieldRegistry,
76
+ removeScopeMarkersFromBlockList,
77
+ replaceParagraphChildrenAtPath,
75
78
  resolveEditableCommandTarget,
76
79
  resolveEditableTableStructureTarget,
77
80
  resolveEditableTextTarget,
78
81
  resolveHeadingPath,
79
82
  resolveScope,
83
+ sameScopeParagraphPath,
80
84
  serializeFragmentToWordML,
81
85
  setStartOverride
82
- } from "./chunk-7G5GR3VV.js";
86
+ } from "./chunk-224TSMEB.js";
83
87
  import {
84
88
  ISSUE_METADATA_ID,
85
89
  LAYOUT_ENGINE_VERSION,
@@ -95,14 +99,17 @@ import {
95
99
  createEditorViewStateSnapshot,
96
100
  createLayoutEngine,
97
101
  createMeasurementProvider,
102
+ createRenderKernel,
98
103
  createViewState,
99
104
  detachReviewAnchor,
100
105
  getAnchorRange,
106
+ incrementInvalidationCounter,
101
107
  mapReviewAnchor,
102
108
  mappingTouchesAnchorContent,
103
109
  matchPageFormat,
104
110
  projectSurfaceText,
105
111
  rangeStaysWithinCommentableStory,
112
+ recordPerfSample,
106
113
  resolveActiveSection,
107
114
  resolveLayoutCompatInputs,
108
115
  searchProjectedSurfaceText,
@@ -114,7 +121,7 @@ import {
114
121
  setWorkspaceMode,
115
122
  setZoomLevel,
116
123
  snapCommentAnchorAwayFromTable
117
- } from "./chunk-THVM6EP5.js";
124
+ } from "./chunk-CVSD3UNK.js";
118
125
  import {
119
126
  countLogicalPositions,
120
127
  createPlainText,
@@ -133,7 +140,7 @@ import {
133
140
  replaceStoryBlocks,
134
141
  resolvePageFieldDisplayText,
135
142
  storyTargetKey
136
- } from "./chunk-A3GSNB4G.js";
143
+ } from "./chunk-XBQFDBXE.js";
137
144
  import {
138
145
  createCommentSidebarProjection,
139
146
  createCommentStoreFromRuntimeComments
@@ -157,12 +164,12 @@ import {
157
164
  persistedSnapshotFromEditorSessionState,
158
165
  remapRevisionStore,
159
166
  setRevisionStatus
160
- } from "./chunk-4YCWECLZ.js";
167
+ } from "./chunk-PZIEOEJZ.js";
161
168
  import {
162
169
  isSupportedFieldFamily,
163
170
  parseTocLevelRange,
164
171
  resolveRefFieldText
165
- } from "./chunk-M7YRJX6V.js";
172
+ } from "./chunk-T66OS7MN.js";
166
173
  import {
167
174
  collectEditableTargetRefs,
168
175
  collectEditableTargetRefsForStoryBlockRanges,
@@ -171,7 +178,7 @@ import {
171
178
  createHeaderFooterStoryKey,
172
179
  sha256TextHex,
173
180
  validateEditableTargetRef
174
- } from "./chunk-A66ZVUAT.js";
181
+ } from "./chunk-5KTJKTNE.js";
175
182
  import {
176
183
  setActiveSerializeTelemetryBus
177
184
  } from "./chunk-FM4K4XFJ.js";
@@ -2022,13 +2029,14 @@ function mapRecordAnchor(anchor, mapping) {
2022
2029
  return toPublicAnchorProjection(mapAnchor(toInternalAnchorProjection(anchor), mapping));
2023
2030
  }
2024
2031
  function withCommandTextTarget(context, command) {
2025
- if (!command.textTarget || context.textTarget === command.textTarget) {
2026
- return context;
2032
+ let next = context;
2033
+ if (next.precomputedSurface === void 0 && next.renderSnapshot?.surface !== void 0) {
2034
+ next = { ...next, precomputedSurface: next.renderSnapshot.surface };
2027
2035
  }
2028
- return {
2029
- ...context,
2030
- textTarget: command.textTarget
2031
- };
2036
+ if (command.textTarget && next.textTarget !== command.textTarget) {
2037
+ next = { ...next, textTarget: command.textTarget };
2038
+ }
2039
+ return next;
2032
2040
  }
2033
2041
  function listCommandContext(context) {
2034
2042
  return {
@@ -7232,39 +7240,8 @@ function insertScopeMarkers(document, params) {
7232
7240
  to: normalizedTo
7233
7241
  };
7234
7242
  }
7235
- const paraSlots = [];
7236
- let cursor = 0;
7237
- let fromBlockIndex = -1;
7238
- let fromBlockKind = null;
7239
- let toBlockIndex = -1;
7240
- let toBlockKind = null;
7241
- let storyLength = 0;
7242
- for (let i = 0; i < root.children.length; i += 1) {
7243
- const block = root.children[i];
7244
- const blockFrom = cursor;
7245
- let blockLength;
7246
- if (block.type === "paragraph") {
7247
- blockLength = block.children.reduce(
7248
- (total, child) => total + inlineLength(child),
7249
- 0
7250
- );
7251
- paraSlots.push({ index: i, from: blockFrom, to: blockFrom + blockLength });
7252
- } else {
7253
- blockLength = 1;
7254
- }
7255
- const blockTo = blockFrom + blockLength;
7256
- if (fromBlockIndex === -1 && normalizedFrom >= blockFrom && normalizedFrom <= blockTo) {
7257
- fromBlockIndex = i;
7258
- fromBlockKind = block.type;
7259
- }
7260
- if (toBlockIndex === -1 && normalizedTo >= blockFrom && normalizedTo <= blockTo) {
7261
- toBlockIndex = i;
7262
- toBlockKind = block.type;
7263
- }
7264
- cursor = blockTo;
7265
- if (i < root.children.length - 1) cursor += 1;
7266
- storyLength = cursor;
7267
- }
7243
+ const layout = computeScopeStoryLayout(document);
7244
+ const storyLength = layout.storyLength;
7268
7245
  if (normalizedFrom < 0 || normalizedTo > storyLength) {
7269
7246
  return {
7270
7247
  status: "range-out-of-bounds",
@@ -7274,73 +7251,71 @@ function insertScopeMarkers(document, params) {
7274
7251
  storyLength
7275
7252
  };
7276
7253
  }
7277
- if (fromBlockIndex === -1 || toBlockIndex === -1) {
7278
- return {
7279
- status: "range-out-of-bounds",
7280
- scopeId,
7281
- from: normalizedFrom,
7282
- to: normalizedTo,
7283
- storyLength
7284
- };
7285
- }
7286
- if (fromBlockKind !== "paragraph" || toBlockKind !== "paragraph") {
7287
- const nonParaIndex = fromBlockKind !== "paragraph" ? fromBlockIndex : toBlockIndex;
7288
- const nonParaKind = fromBlockKind !== "paragraph" ? fromBlockKind : toBlockKind;
7254
+ const startSlot = findParagraphSlotAtPosition(
7255
+ layout,
7256
+ normalizedFrom,
7257
+ "start"
7258
+ );
7259
+ const endSlot = findParagraphSlotAtPosition(layout, normalizedTo, "end");
7260
+ if (!startSlot || !endSlot) {
7261
+ const offenderPosition = !startSlot ? normalizedFrom : normalizedTo;
7262
+ const owner = findOwningBlockSlotAtPosition(layout, offenderPosition);
7289
7263
  return {
7290
7264
  status: "non-paragraph-target",
7291
7265
  scopeId,
7292
7266
  from: normalizedFrom,
7293
7267
  to: normalizedTo,
7294
- blockIndex: nonParaIndex,
7295
- blockKind: nonParaKind ?? "unknown"
7268
+ blockIndex: owner?.rootBlockIndex ?? -1,
7269
+ blockKind: owner?.kind ?? "unknown"
7296
7270
  };
7297
7271
  }
7298
- const startSlot = paraSlots.find((s) => s.index === fromBlockIndex);
7299
- const endSlot = paraSlots.find((s) => s.index === toBlockIndex);
7300
- if (startSlot.index === endSlot.index) {
7272
+ if (sameScopeParagraphPath(startSlot.path, endSlot.path)) {
7301
7273
  const newChildren = injectMarkersIntoInlineList(
7302
- root.children[startSlot.index].children,
7274
+ startSlot.paragraph.children,
7303
7275
  scopeId,
7304
7276
  normalizedFrom - startSlot.from,
7305
7277
  normalizedTo - startSlot.from,
7306
7278
  "both"
7307
7279
  );
7308
- const children2 = root.children.map(
7309
- (block, i) => i === startSlot.index ? { ...block, children: newChildren } : block
7280
+ const nextRoot = replaceParagraphChildrenAtPath(
7281
+ root,
7282
+ startSlot.path,
7283
+ newChildren
7310
7284
  );
7311
7285
  return {
7312
7286
  status: "planted",
7313
- document: { ...document, content: { ...root, children: children2 } },
7287
+ document: { ...document, content: nextRoot },
7314
7288
  scopeId,
7315
7289
  plantedRange: { from: normalizedFrom, to: normalizedTo }
7316
7290
  };
7317
7291
  }
7318
- const children = root.children.map((block, i) => {
7319
- if (i === startSlot.index) {
7320
- const newChildren = injectMarkersIntoInlineList(
7321
- block.children,
7322
- scopeId,
7323
- normalizedFrom - startSlot.from,
7324
- Number.POSITIVE_INFINITY,
7325
- "start-only"
7326
- );
7327
- return { ...block, children: newChildren };
7328
- }
7329
- if (i === endSlot.index) {
7330
- const newChildren = injectMarkersIntoInlineList(
7331
- block.children,
7332
- scopeId,
7333
- Number.NEGATIVE_INFINITY,
7334
- normalizedTo - endSlot.from,
7335
- "end-only"
7336
- );
7337
- return { ...block, children: newChildren };
7338
- }
7339
- return block;
7340
- });
7292
+ const startChildren = injectMarkersIntoInlineList(
7293
+ startSlot.paragraph.children,
7294
+ scopeId,
7295
+ normalizedFrom - startSlot.from,
7296
+ Number.POSITIVE_INFINITY,
7297
+ "start-only"
7298
+ );
7299
+ const endChildren = injectMarkersIntoInlineList(
7300
+ endSlot.paragraph.children,
7301
+ scopeId,
7302
+ Number.NEGATIVE_INFINITY,
7303
+ normalizedTo - endSlot.from,
7304
+ "end-only"
7305
+ );
7306
+ const rootWithStart = replaceParagraphChildrenAtPath(
7307
+ root,
7308
+ startSlot.path,
7309
+ startChildren
7310
+ );
7311
+ const rootWithBoth = replaceParagraphChildrenAtPath(
7312
+ rootWithStart,
7313
+ endSlot.path,
7314
+ endChildren
7315
+ );
7341
7316
  return {
7342
7317
  status: "planted",
7343
- document: { ...document, content: { ...root, children } },
7318
+ document: { ...document, content: rootWithBoth },
7344
7319
  scopeId,
7345
7320
  plantedRange: { from: normalizedFrom, to: normalizedTo }
7346
7321
  };
@@ -7348,43 +7323,15 @@ function insertScopeMarkers(document, params) {
7348
7323
  function removeScopeMarkers(document, scopeId) {
7349
7324
  const root = document.content;
7350
7325
  if (!root || root.type !== "doc") return document;
7351
- let mutated = false;
7352
- const children = root.children.map((block) => {
7353
- if (block.type !== "paragraph") return block;
7354
- const kept = block.children.filter((child) => {
7355
- if ((child.type === "scope_marker_start" || child.type === "scope_marker_end") && child.scopeId === scopeId) {
7356
- mutated = true;
7357
- return false;
7358
- }
7359
- return true;
7360
- });
7361
- if (kept.length === block.children.length) return block;
7362
- return { ...block, children: kept };
7363
- });
7364
- if (!mutated) return document;
7326
+ const result = removeScopeMarkersFromBlockList(root.children, scopeId);
7327
+ if (!result.mutated) return document;
7365
7328
  return {
7366
7329
  ...document,
7367
- content: { ...root, children }
7330
+ content: { ...root, children: result.blocks }
7368
7331
  };
7369
7332
  }
7370
7333
  function inlineLength(node) {
7371
- switch (node.type) {
7372
- case "text":
7373
- return Array.from(node.text).length;
7374
- case "hyperlink":
7375
- case "field":
7376
- return node.children.reduce(
7377
- (total, child) => total + inlineLength(child),
7378
- 0
7379
- );
7380
- case "bookmark_start":
7381
- case "bookmark_end":
7382
- case "scope_marker_start":
7383
- case "scope_marker_end":
7384
- return 0;
7385
- default:
7386
- return 1;
7387
- }
7334
+ return inlineLengthForScopeCoordinates(node);
7388
7335
  }
7389
7336
  function injectMarkersIntoInlineList(inlines, scopeId, startOffset, endOffset, mode) {
7390
7337
  const start = { type: "scope_marker_start", scopeId };
@@ -10350,6 +10297,13 @@ function cloneNumberingLayoutFacts(numbering) {
10350
10297
  ...numbering.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...numbering.numberingSourceRef } } : {},
10351
10298
  ...numbering.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...numbering.numberingInstanceSourceRef } } : {},
10352
10299
  ...numbering.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...numbering.abstractNumberingSourceRef } } : {},
10300
+ ...numbering.markerTextPosture !== void 0 ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
10301
+ ...numbering.pictureBulletPosture !== void 0 ? {
10302
+ pictureBulletPosture: {
10303
+ ...numbering.pictureBulletPosture,
10304
+ ...numbering.pictureBulletPosture.sourceRef !== void 0 ? { sourceRef: { ...numbering.pictureBulletPosture.sourceRef } } : {}
10305
+ }
10306
+ } : {},
10353
10307
  ...numbering.markerLane !== void 0 ? { markerLane: { ...numbering.markerLane } } : {},
10354
10308
  ...numbering.textColumn !== void 0 ? { textColumn: { ...numbering.textColumn } } : {},
10355
10309
  ...numbering.tabStops !== void 0 ? { tabStops: numbering.tabStops.map((tab) => ({ ...tab })) } : {}
@@ -12585,6 +12539,14 @@ function createDocumentRuntime(options) {
12585
12539
  let effectiveMarkupModeProvider;
12586
12540
  const perfCounters = new PerfCounters();
12587
12541
  const hotEditTraces = new HotEditTraceRecorder();
12542
+ const scopeSurfaceTelemetry = {
12543
+ onPrecomputedSurfaceHit: () => {
12544
+ perfCounters.increment("surface.scope.precomputedSurfaceHit");
12545
+ },
12546
+ onScopeSurfaceBuild: () => {
12547
+ perfCounters.increment("surface.scope.builds");
12548
+ }
12549
+ };
12588
12550
  let cachedHotEditPolicy = null;
12589
12551
  function getHotEditPolicy() {
12590
12552
  if (cachedHotEditPolicy?.document === state.document) {
@@ -13033,7 +12995,7 @@ function createDocumentRuntime(options) {
13033
12995
  viewportRangesKey: rangesKey,
13034
12996
  snapshot: surface
13035
12997
  };
13036
- const fullSurface = fullSurfaceForCache ?? (surface.viewportBlockRanges === null ? surface : void 0);
12998
+ const fullSurface = fullSurfaceForCache?.viewportBlockRanges === null ? fullSurfaceForCache : surface.viewportBlockRanges === null ? surface : void 0;
13037
12999
  if (fullSurface) {
13038
13000
  cachedFullSurface = {
13039
13001
  content: state.document.content,
@@ -14596,6 +14558,7 @@ function createDocumentRuntime(options) {
14596
14558
  documentMode: workflowCoordinator.getEffectiveDocumentMode(commandSelection),
14597
14559
  defaultAuthorId: defaultAuthorId ?? void 0,
14598
14560
  renderSnapshot: cachedRenderSnapshot,
14561
+ surfaceTelemetry: scopeSurfaceTelemetry,
14599
14562
  activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
14600
14563
  editableTargetCache: editableTargetBlockCache,
14601
14564
  ...resolvedFragmentTextTarget ? { textTarget: resolvedFragmentTextTarget } : {}
@@ -16868,7 +16831,8 @@ function createDocumentRuntime(options) {
16868
16831
  applyViewportRanges(getSelectionCorridorViewportRanges(cachedRenderSnapshot.surface));
16869
16832
  }
16870
16833
  const tValidation0 = performance.now();
16871
- const patchedFullLocalTextSurface = useLocalTextCommitSnapshot ? tryPatchLocalTextSurface(cachedRenderSnapshot.surface, transaction.mapping) : null;
16834
+ const patchSourceSurface = getReusableCachedFullSurface(previous.document, activeStory) ?? cachedRenderSnapshot.surface;
16835
+ const patchedFullLocalTextSurface = useLocalTextCommitSnapshot ? tryPatchLocalTextSurface(patchSourceSurface, transaction.mapping) : null;
16872
16836
  const patchedLocalTextSurface = patchedFullLocalTextSurface ? createLocalTextCorridorSurfaceFromFullSurface(patchedFullLocalTextSurface) : null;
16873
16837
  if (patchedLocalTextSurface) {
16874
16838
  cachePatchedLocalTextSurface(
@@ -17212,11 +17176,14 @@ function createDocumentRuntime(options) {
17212
17176
  }
17213
17177
  const listBoundaryDeleteUsesStoryText = targetResolution?.kind === "accepted" && editableTarget?.listAddress?.operationScope === "list-text" && isTopLevelMainStoryBlockPath(editableTarget.blockPath) && selection.isCollapsed && (commandForDispatch.type === "text.delete-backward" && selection.anchor === targetResolution.range.from || commandForDispatch.type === "text.delete-forward" && selection.anchor === targetResolution.range.to);
17214
17178
  const textTarget = targetResolution?.kind === "accepted" && !listBoundaryDeleteUsesStoryText ? targetResolution.textTarget : legacyTextTarget;
17179
+ const fullScopeSurface = cachedFullSurface?.snapshot;
17215
17180
  const context = {
17216
17181
  timestamp,
17217
17182
  documentMode: textOptions.documentModeOverride ?? workflowCoordinator.getEffectiveDocumentMode(selection),
17218
17183
  defaultAuthorId: defaultAuthorId ?? void 0,
17219
17184
  renderSnapshot: cachedRenderSnapshot,
17185
+ surfaceTelemetry: scopeSurfaceTelemetry,
17186
+ ...fullScopeSurface ? { precomputedSurface: fullScopeSurface } : {},
17220
17187
  activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
17221
17188
  editableTargetCache: editableTargetBlockCache,
17222
17189
  activeStorySize: cachedRenderSnapshot.surface?.storySize,
@@ -17542,6 +17509,7 @@ function createDocumentRuntime(options) {
17542
17509
  documentMode: workflowCoordinator.getEffectiveDocumentMode(state.selection),
17543
17510
  defaultAuthorId: defaultAuthorId ?? void 0,
17544
17511
  renderSnapshot: cachedRenderSnapshot,
17512
+ surfaceTelemetry: scopeSurfaceTelemetry,
17545
17513
  activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
17546
17514
  editableTargetCache: editableTargetBlockCache
17547
17515
  };