@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
@@ -6,7 +6,7 @@ import {
6
6
  createHeaderFooterStoryKey,
7
7
  createNoteStoryKey,
8
8
  sha256TextHex
9
- } from "./chunk-RYMMKOFI.js";
9
+ } from "./chunk-5KTJKTNE.js";
10
10
  import {
11
11
  SCOPE_MARKER_BOOKMARK_PREFIX,
12
12
  buildGrabBagSourceChildFromParsed,
@@ -1147,7 +1147,7 @@ function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
1147
1147
  const rEmbed = blip?.attributes["r:embed"] ?? blip?.attributes.embed;
1148
1148
  if (rEmbed) {
1149
1149
  const rel = context.relationships.find((r) => r.id === rEmbed);
1150
- if (rel) {
1150
+ if (isEmbeddedImageRelationship(rel)) {
1151
1151
  const packagePartName = normalizePartPath(
1152
1152
  resolveRelationshipTarget(context.partPath ?? "/word/numbering.xml", rel)
1153
1153
  );
@@ -1165,7 +1165,7 @@ function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
1165
1165
  const rId = imagedata?.attributes["r:id"] ?? imagedata?.attributes.id;
1166
1166
  if (rId && context?.relationships && context.relationships.length > 0) {
1167
1167
  const rel = context.relationships.find((r) => r.id === rId);
1168
- if (rel) {
1168
+ if (isEmbeddedImageRelationship(rel)) {
1169
1169
  const packagePartName = normalizePartPath(
1170
1170
  resolveRelationshipTarget(context.partPath ?? "/word/numbering.xml", rel)
1171
1171
  );
@@ -1190,6 +1190,11 @@ function readNumPicBullet(node, numPicBulletId, context, xmlPath) {
1190
1190
  ...mediaId !== void 0 ? { mediaId } : {}
1191
1191
  };
1192
1192
  }
1193
+ function isEmbeddedImageRelationship(relationship) {
1194
+ return Boolean(
1195
+ relationship && relationship.targetMode === "internal" && relationship.type.endsWith("/image")
1196
+ );
1197
+ }
1193
1198
  function toCanonicalAbstractNumberingId(value) {
1194
1199
  return value.startsWith("abstract-num:") ? value : `abstract-num:${value}`;
1195
1200
  }
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  loadDocxSessionAsync
3
- } from "./chunk-JVTDBX67.js";
3
+ } from "./chunk-EFEW7BTT.js";
4
4
  import {
5
5
  buildCompatibilityReport,
6
6
  createLoadScheduler
7
- } from "./chunk-4HGFJ6Z2.js";
7
+ } from "./chunk-PZIEOEJZ.js";
8
8
  import {
9
9
  decodePersistedSourcePackageBytes,
10
10
  hasValidPersistedSourcePackageDigest,
@@ -3,12 +3,12 @@ import {
3
3
  createNoopStructuralMutation,
4
4
  findTableCellParagraphSelection,
5
5
  findTopLevelParagraphSelectionNearBlock
6
- } from "./chunk-C5LXKR54.js";
6
+ } from "./chunk-QTRJLKR2.js";
7
7
  import {
8
8
  collectEditableTargetRefs,
9
9
  collectStoryBlockContexts,
10
10
  createHeaderFooterStoryKey
11
- } from "./chunk-RYMMKOFI.js";
11
+ } from "./chunk-5KTJKTNE.js";
12
12
  import {
13
13
  createDetachedAnchor,
14
14
  createNodeAnchor,
@@ -4,7 +4,7 @@ import {
4
4
  MAIN_STORY_KEY,
5
5
  collectCanonicalFieldRegionIdentities,
6
6
  collectEditableTargetRefs
7
- } from "./chunk-RYMMKOFI.js";
7
+ } from "./chunk-5KTJKTNE.js";
8
8
  import {
9
9
  describeOpaqueFragment,
10
10
  describeStructuredWrapperBlock,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  buildSearchPattern
3
- } from "./chunk-LPLJZJT2.js";
3
+ } from "./chunk-CVSD3UNK.js";
4
4
 
5
5
  // src/ui-tailwind/editor-surface/search-plugin.ts
6
6
  import { Plugin, PluginKey } from "prosemirror-state";
@@ -1,6 +1,6 @@
1
1
  import 'prosemirror-state';
2
2
  import 'prosemirror-model';
3
- export { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-KBS6JnOs.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-S8gTYwKo.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 { g4 as Alignment, g5 as FormattingMutationResult, g6 as FormattingOperation, g7 as TextMarkClearTarget, g8 as TextMarkRangeOperation, g9 as applyFormattingOperationToDocument, ga as applyIndentation, gb as applyTextMarkOperationToDocumentRange, gc as getFormattingStateFromRenderSnapshot, gd as isMarkActive, ge as makeSetAlignment, gf as makeSetFontFamily, gg as makeSetFontSize, gh as makeSetHighlight, gi as makeSetTextColor, gj as makeToggleAllCaps, gk as makeToggleBold, gl as makeToggleItalic, gm as makeToggleSmallCaps, gn as makeToggleStrikethrough, go as makeToggleSubscript, gp as makeToggleSuperscript, gq as makeToggleUnderline } from '../../public-types-Cjs8glST.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-B5lOUIrP.js';
4
4
  import '../../canonical-document-CfZIc-fC.js';
5
5
  import 'react';
6
6
  import 'yjs';
@@ -2402,7 +2402,20 @@ function sourceJoinHash(refs) {
2402
2402
  if (sourceIds.length === 0) return void 0;
2403
2403
  return hashText(sourceIds.join("\0"));
2404
2404
  }
2405
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
2406
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
2405
2407
  function createNumberingCatalogRevisionHash(doc) {
2408
+ const numbering = doc.numbering;
2409
+ if (numbering !== void 0) {
2410
+ const cached = numberingCatalogHashCache.get(numbering);
2411
+ if (cached !== void 0) return cached;
2412
+ const fresh = computeNumberingCatalogRevisionHash(doc);
2413
+ numberingCatalogHashCache.set(numbering, fresh);
2414
+ return fresh;
2415
+ }
2416
+ return computeNumberingCatalogRevisionHash(doc);
2417
+ }
2418
+ function computeNumberingCatalogRevisionHash(doc) {
2406
2419
  const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
2407
2420
  const abstractDefinitions = catalog.abstractDefinitions ?? {};
2408
2421
  const instances = catalog.instances ?? {};
@@ -2453,8 +2466,27 @@ function createNumberingCatalogRevisionHash(doc) {
2453
2466
  }));
2454
2467
  }
2455
2468
  function createNumberingTargetRevisionHash(doc) {
2469
+ const numbering = doc.numbering;
2470
+ const styles = doc.styles;
2471
+ if (numbering !== void 0 && styles !== void 0) {
2472
+ let inner = numberingTargetHashCache.get(numbering);
2473
+ if (inner === void 0) {
2474
+ inner = /* @__PURE__ */ new WeakMap();
2475
+ numberingTargetHashCache.set(numbering, inner);
2476
+ }
2477
+ const cached = inner.get(styles);
2478
+ if (cached !== void 0) return cached;
2479
+ const fresh = computeNumberingTargetRevisionHash(doc);
2480
+ inner.set(styles, fresh);
2481
+ return fresh;
2482
+ }
2483
+ return computeNumberingTargetRevisionHash(doc);
2484
+ }
2485
+ function computeNumberingTargetRevisionHash(doc) {
2456
2486
  const paragraphStyles = doc.styles?.paragraphs ?? {};
2457
2487
  return hashText(JSON.stringify({
2488
+ // Reuses the memoized catalog hash on the hot path so a typing edit
2489
+ // pays for the catalog hash at most once across both helpers.
2458
2490
  numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
2459
2491
  paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
2460
2492
  const style = paragraphStyles[styleId];
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-KBS6JnOs.cjs';
1
+ import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-S8gTYwKo.cjs';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1,4 +1,4 @@
1
- import { C as CanonicalDocumentEnvelope, S as SelectionSnapshot, g as TransactionMapping } from '../../public-types-Cjs8glST.js';
1
+ import { C as CanonicalDocumentEnvelope, e as SelectionSnapshot, i as TransactionMapping } from '../../public-types-B5lOUIrP.js';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -2,13 +2,13 @@ import {
2
2
  insertImage,
3
3
  repositionFloatingImage,
4
4
  resizeImage
5
- } from "../../chunk-UFPBYJMA.js";
6
- import "../../chunk-N5FTU4HZ.js";
7
- import "../../chunk-C5LXKR54.js";
5
+ } from "../../chunk-INLRCC4N.js";
6
+ import "../../chunk-MQ5GAJ54.js";
7
+ import "../../chunk-QTRJLKR2.js";
8
8
  import "../../chunk-QIO6V46H.js";
9
- import "../../chunk-U3UMKA7B.js";
9
+ import "../../chunk-XBQFDBXE.js";
10
10
  import "../../chunk-OYGMRRR7.js";
11
- import "../../chunk-RYMMKOFI.js";
11
+ import "../../chunk-5KTJKTNE.js";
12
12
  import "../../chunk-UFVDIR2C.js";
13
13
  import "../../chunk-PGGPPZ65.js";
14
14
  import "../../chunk-DNXYUIIS.js";
@@ -1,4 +1,4 @@
1
- import { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-KBS6JnOs.cjs';
1
+ import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-S8gTYwKo.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 { h as SelectionSnapshot, M as MarginPresetDefinition, i as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-Cjs8glST.js';
1
+ import { j as SelectionSnapshot, M as MarginPresetDefinition, k as PageFormatDefinition, R as RuntimeRenderSnapshot } from '../../public-types-B5lOUIrP.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-KBS6JnOs.cjs';
1
+ import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-S8gTYwKo.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-Cjs8glST.js';
1
+ import { P as PersistedEditorSnapshot, R as RuntimeRenderSnapshot } from '../../public-types-B5lOUIrP.js';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -1807,7 +1807,20 @@ function sourceJoinHash(refs) {
1807
1807
  if (sourceIds.length === 0) return void 0;
1808
1808
  return hashText(sourceIds.join("\0"));
1809
1809
  }
1810
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
1811
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
1810
1812
  function createNumberingCatalogRevisionHash(doc) {
1813
+ const numbering = doc.numbering;
1814
+ if (numbering !== void 0) {
1815
+ const cached = numberingCatalogHashCache.get(numbering);
1816
+ if (cached !== void 0) return cached;
1817
+ const fresh = computeNumberingCatalogRevisionHash(doc);
1818
+ numberingCatalogHashCache.set(numbering, fresh);
1819
+ return fresh;
1820
+ }
1821
+ return computeNumberingCatalogRevisionHash(doc);
1822
+ }
1823
+ function computeNumberingCatalogRevisionHash(doc) {
1811
1824
  const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
1812
1825
  const abstractDefinitions = catalog.abstractDefinitions ?? {};
1813
1826
  const instances = catalog.instances ?? {};
@@ -1858,8 +1871,27 @@ function createNumberingCatalogRevisionHash(doc) {
1858
1871
  }));
1859
1872
  }
1860
1873
  function createNumberingTargetRevisionHash(doc) {
1874
+ const numbering = doc.numbering;
1875
+ const styles = doc.styles;
1876
+ if (numbering !== void 0 && styles !== void 0) {
1877
+ let inner = numberingTargetHashCache.get(numbering);
1878
+ if (inner === void 0) {
1879
+ inner = /* @__PURE__ */ new WeakMap();
1880
+ numberingTargetHashCache.set(numbering, inner);
1881
+ }
1882
+ const cached = inner.get(styles);
1883
+ if (cached !== void 0) return cached;
1884
+ const fresh = computeNumberingTargetRevisionHash(doc);
1885
+ inner.set(styles, fresh);
1886
+ return fresh;
1887
+ }
1888
+ return computeNumberingTargetRevisionHash(doc);
1889
+ }
1890
+ function computeNumberingTargetRevisionHash(doc) {
1861
1891
  const paragraphStyles = doc.styles?.paragraphs ?? {};
1862
1892
  return hashText(JSON.stringify({
1893
+ // Reuses the memoized catalog hash on the hot path so a typing edit
1894
+ // pays for the catalog hash at most once across both helpers.
1863
1895
  numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
1864
1896
  paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
1865
1897
  const style = paragraphStyles[styleId];
@@ -1,4 +1,4 @@
1
- export { gr as CellLocator, gs as TableStructureOperation, gt as applyTableStructureOperation, gu as applyTableStructureOperationForEditableTarget, gv as getTableStructureContext, gw as removeCellFromRow, gx as removeTableRowPure, gy as tableStructureActionHandleForTarget } from '../../public-types-KBS6JnOs.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-S8gTYwKo.cjs';
2
2
  import '../../canonical-document-CfZIc-fC.cjs';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -1,4 +1,4 @@
1
- export { gr as CellLocator, gs as TableStructureOperation, gt as applyTableStructureOperation, gu as applyTableStructureOperationForEditableTarget, gv as getTableStructureContext, gw as removeCellFromRow, gx as removeTableRowPure, gy as tableStructureActionHandleForTarget } from '../../public-types-Cjs8glST.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-B5lOUIrP.js';
2
2
  import '../../canonical-document-CfZIc-fC.js';
3
3
  import 'react';
4
4
  import 'yjs';
@@ -5,11 +5,11 @@ import {
5
5
  removeCellFromRow,
6
6
  removeTableRowPure,
7
7
  tableStructureActionHandleForTarget
8
- } from "../../chunk-6TLZ6CMP.js";
9
- import "../../chunk-C5LXKR54.js";
10
- import "../../chunk-U3UMKA7B.js";
8
+ } from "../../chunk-WDDFU2N2.js";
9
+ import "../../chunk-QTRJLKR2.js";
10
+ import "../../chunk-XBQFDBXE.js";
11
11
  import "../../chunk-OYGMRRR7.js";
12
- import "../../chunk-RYMMKOFI.js";
12
+ import "../../chunk-5KTJKTNE.js";
13
13
  import "../../chunk-UFVDIR2C.js";
14
14
  import "../../chunk-PGGPPZ65.js";
15
15
  import "../../chunk-DNXYUIIS.js";
@@ -2477,7 +2477,20 @@ function sourceJoinHash(refs) {
2477
2477
  if (sourceIds.length === 0) return void 0;
2478
2478
  return hashText(sourceIds.join("\0"));
2479
2479
  }
2480
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
2481
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
2480
2482
  function createNumberingCatalogRevisionHash(doc) {
2483
+ const numbering = doc.numbering;
2484
+ if (numbering !== void 0) {
2485
+ const cached = numberingCatalogHashCache.get(numbering);
2486
+ if (cached !== void 0) return cached;
2487
+ const fresh = computeNumberingCatalogRevisionHash(doc);
2488
+ numberingCatalogHashCache.set(numbering, fresh);
2489
+ return fresh;
2490
+ }
2491
+ return computeNumberingCatalogRevisionHash(doc);
2492
+ }
2493
+ function computeNumberingCatalogRevisionHash(doc) {
2481
2494
  const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
2482
2495
  const abstractDefinitions = catalog.abstractDefinitions ?? {};
2483
2496
  const instances = catalog.instances ?? {};
@@ -2528,8 +2541,27 @@ function createNumberingCatalogRevisionHash(doc) {
2528
2541
  }));
2529
2542
  }
2530
2543
  function createNumberingTargetRevisionHash(doc) {
2544
+ const numbering = doc.numbering;
2545
+ const styles = doc.styles;
2546
+ if (numbering !== void 0 && styles !== void 0) {
2547
+ let inner = numberingTargetHashCache.get(numbering);
2548
+ if (inner === void 0) {
2549
+ inner = /* @__PURE__ */ new WeakMap();
2550
+ numberingTargetHashCache.set(numbering, inner);
2551
+ }
2552
+ const cached = inner.get(styles);
2553
+ if (cached !== void 0) return cached;
2554
+ const fresh = computeNumberingTargetRevisionHash(doc);
2555
+ inner.set(styles, fresh);
2556
+ return fresh;
2557
+ }
2558
+ return computeNumberingTargetRevisionHash(doc);
2559
+ }
2560
+ function computeNumberingTargetRevisionHash(doc) {
2531
2561
  const paragraphStyles = doc.styles?.paragraphs ?? {};
2532
2562
  return hashText(JSON.stringify({
2563
+ // Reuses the memoized catalog hash on the hot path so a typing edit
2564
+ // pays for the catalog hash at most once across both helpers.
2533
2565
  numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
2534
2566
  paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
2535
2567
  const style = paragraphStyles[styleId];
@@ -7884,7 +7916,38 @@ var TextTransactionError = class extends Error {
7884
7916
  this.code = code;
7885
7917
  }
7886
7918
  };
7919
+ function isUsableScopeSurface(surface, document) {
7920
+ if (surface.viewportBlockRanges !== null) return false;
7921
+ const root = document.content;
7922
+ if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
7923
+ return false;
7924
+ }
7925
+ return surface.blocks.length === root.children.length;
7926
+ }
7927
+ function createScopeSurfaceCache(document, selection, precomputedSurface, telemetry) {
7928
+ let cached;
7929
+ if (precomputedSurface && isUsableScopeSurface(precomputedSurface, document)) {
7930
+ cached = precomputedSurface;
7931
+ telemetry?.onPrecomputedSurfaceHit?.();
7932
+ }
7933
+ return {
7934
+ get() {
7935
+ if (cached) return cached;
7936
+ telemetry?.onScopeSurfaceBuild?.();
7937
+ cached = createEditorSurfaceSnapshot(document, selection, void 0, {
7938
+ editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
7939
+ });
7940
+ return cached;
7941
+ }
7942
+ };
7943
+ }
7887
7944
  function applyTextTransaction(document, selection, intent, options) {
7945
+ const scopeSurfaceCache = createScopeSurfaceCache(
7946
+ document,
7947
+ selection,
7948
+ options.precomputedSurface,
7949
+ options.surfaceTelemetry
7950
+ );
7888
7951
  if (options.textTarget) {
7889
7952
  if (options.textTarget.kind === "hyperlink-display") {
7890
7953
  const targetedHyperlinkResult = tryApplyHyperlinkDisplayTransaction(
@@ -7920,7 +7983,8 @@ function applyTextTransaction(document, selection, intent, options) {
7920
7983
  document,
7921
7984
  selection,
7922
7985
  intent,
7923
- options
7986
+ options,
7987
+ scopeSurfaceCache
7924
7988
  );
7925
7989
  if (targetedTableResult) {
7926
7990
  return targetedTableResult;
@@ -7934,7 +7998,8 @@ function applyTextTransaction(document, selection, intent, options) {
7934
7998
  const tableStructureRefusal = resolveTargetlessTableStructureInsertRefusal(
7935
7999
  document,
7936
8000
  selection,
7937
- intent
8001
+ intent,
8002
+ scopeSurfaceCache
7938
8003
  );
7939
8004
  if (tableStructureRefusal) {
7940
8005
  throw new TextTransactionError("unsupported_content", tableStructureRefusal);
@@ -7944,7 +8009,8 @@ function applyTextTransaction(document, selection, intent, options) {
7944
8009
  document,
7945
8010
  selection,
7946
8011
  intent,
7947
- options
8012
+ options,
8013
+ scopeSurfaceCache
7948
8014
  );
7949
8015
  if (topLevelParagraphResult) {
7950
8016
  return topLevelParagraphResult;
@@ -7953,7 +8019,8 @@ function applyTextTransaction(document, selection, intent, options) {
7953
8019
  document,
7954
8020
  selection,
7955
8021
  intent,
7956
- options
8022
+ options,
8023
+ scopeSurfaceCache
7957
8024
  );
7958
8025
  if (sdtScopedResult) {
7959
8026
  return sdtScopedResult;
@@ -7962,7 +8029,8 @@ function applyTextTransaction(document, selection, intent, options) {
7962
8029
  document,
7963
8030
  selection,
7964
8031
  intent,
7965
- options
8032
+ options,
8033
+ scopeSurfaceCache
7966
8034
  );
7967
8035
  if (tableScopedResult) {
7968
8036
  return tableScopedResult;
@@ -8015,9 +8083,9 @@ function applyLinearTextTransaction(document, selection, intent, options) {
8015
8083
  storyText: createPlainText(nextStory)
8016
8084
  };
8017
8085
  }
8018
- function tryApplyTableParagraphTransaction(document, selection, intent, options) {
8086
+ function tryApplyTableParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
8019
8087
  const tableTarget = options.textTarget?.kind === "table-paragraph" ? options.textTarget : void 0;
8020
- const scope = resolveTableParagraphScope(document, selection, tableTarget);
8088
+ const scope = resolveTableParagraphScope(document, selection, tableTarget, scopeSurfaceCache);
8021
8089
  if (!scope) {
8022
8090
  return null;
8023
8091
  }
@@ -8140,7 +8208,11 @@ function tryApplyTargetedTextLeafTransaction(document, selection, intent, option
8140
8208
  };
8141
8209
  }
8142
8210
  function tryApplyHyperlinkDisplayTransaction(document, selection, intent, options) {
8143
- const scope = resolveTargetedHyperlinkDisplayScope(document, selection, options.textTarget);
8211
+ const scope = resolveTargetedHyperlinkDisplayScope(
8212
+ document,
8213
+ selection,
8214
+ options.textTarget
8215
+ );
8144
8216
  if (!scope) {
8145
8217
  return null;
8146
8218
  }
@@ -8198,8 +8270,8 @@ function tryApplyHyperlinkDisplayTransaction(document, selection, intent, option
8198
8270
  storyText: localResult.storyText
8199
8271
  };
8200
8272
  }
8201
- function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options) {
8202
- const scope = resolveTopLevelSdtParagraphScope(document, selection);
8273
+ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
8274
+ const scope = resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache);
8203
8275
  if (!scope) {
8204
8276
  return null;
8205
8277
  }
@@ -8251,8 +8323,8 @@ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, op
8251
8323
  storyText: localResult.storyText
8252
8324
  };
8253
8325
  }
8254
- function tryApplyTopLevelParagraphTransaction(document, selection, intent, options) {
8255
- const scope = resolveTopLevelParagraphScope(document, selection);
8326
+ function tryApplyTopLevelParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
8327
+ const scope = resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache);
8256
8328
  if (!scope) {
8257
8329
  return null;
8258
8330
  }
@@ -8362,17 +8434,15 @@ function resolveTargetedHyperlinkDisplayScope(document, selection, target) {
8362
8434
  replace: resolved.replace
8363
8435
  };
8364
8436
  }
8365
- function resolveTableParagraphScope(document, selection, target) {
8437
+ function resolveTableParagraphScope(document, selection, target, scopeSurfaceCache) {
8366
8438
  if (target) {
8367
- return resolveTargetedTableParagraphScope(document, selection, target);
8439
+ return resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache);
8368
8440
  }
8369
8441
  const root = document.content;
8370
8442
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8371
8443
  return null;
8372
8444
  }
8373
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8374
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8375
- });
8445
+ const surface = scopeSurfaceCache.get();
8376
8446
  const selectionFrom = Math.min(selection.anchor, selection.head);
8377
8447
  const selectionTo = Math.max(selection.anchor, selection.head);
8378
8448
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -8477,7 +8547,7 @@ function resolveTableParagraphScope(document, selection, target) {
8477
8547
  }
8478
8548
  return null;
8479
8549
  }
8480
- function resolveTargetlessTableStructureInsertRefusal(document, selection, intent) {
8550
+ function resolveTargetlessTableStructureInsertRefusal(document, selection, intent, scopeSurfaceCache) {
8481
8551
  if (!isCollapsedInsertIntent(intent, selection)) {
8482
8552
  return null;
8483
8553
  }
@@ -8485,9 +8555,7 @@ function resolveTargetlessTableStructureInsertRefusal(document, selection, inten
8485
8555
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8486
8556
  return null;
8487
8557
  }
8488
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8489
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8490
- });
8558
+ const surface = scopeSurfaceCache.get();
8491
8559
  if (!selectionTouchesTableStructureBoundary(surface.blocks, selection.anchor)) {
8492
8560
  return null;
8493
8561
  }
@@ -8501,7 +8569,7 @@ function isCollapsedInsertIntent(intent, selection) {
8501
8569
  const rangeTo = intent.range ? Math.max(intent.range.from, intent.range.to) : Math.max(selection.anchor, selection.head);
8502
8570
  return rangeFrom === rangeTo;
8503
8571
  }
8504
- function resolveTargetedTableParagraphScope(document, selection, target) {
8572
+ function resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache) {
8505
8573
  const root = document.content;
8506
8574
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8507
8575
  return null;
@@ -8514,7 +8582,8 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8514
8582
  root,
8515
8583
  document,
8516
8584
  selection,
8517
- target
8585
+ target,
8586
+ scopeSurfaceCache
8518
8587
  );
8519
8588
  if (targetScope) {
8520
8589
  return targetScope;
@@ -8537,9 +8606,7 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8537
8606
  if (cell.verticalMerge === "continue") {
8538
8607
  return "unsupported";
8539
8608
  }
8540
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8541
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8542
- });
8609
+ const surface = scopeSurfaceCache.get();
8543
8610
  const surfaceBlock = surface.blocks[target.tableBlockIndex];
8544
8611
  const surfaceRow = surfaceBlock?.kind === "table" ? surfaceBlock.rows[target.rowIndex] : void 0;
8545
8612
  const surfaceCell = surfaceRow?.cells[target.cellIndex];
@@ -8603,16 +8670,14 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8603
8670
  }
8604
8671
  };
8605
8672
  }
8606
- function resolveTargetedTableParagraphScopeByPath(root, document, selection, target) {
8673
+ function resolveTargetedTableParagraphScopeByPath(root, document, selection, target, scopeSurfaceCache) {
8607
8674
  if (!target.blockPath) return null;
8608
8675
  const tokens = parseCanonicalBlockPath(target.blockPath);
8609
8676
  if (!tokens) return null;
8610
8677
  const resolved = resolveBlockPathInCanonicalBlocks(root.children, tokens, 0);
8611
8678
  if (!resolved || resolved.block.type !== "paragraph") return null;
8612
8679
  if (resolved.hasVerticalMergeContinuation) return null;
8613
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8614
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8615
- });
8680
+ const surface = scopeSurfaceCache.get();
8616
8681
  const surfaceResolved = resolveBlockPathInSurfaceBlocks(surface.blocks, tokens, 0);
8617
8682
  if (!surfaceResolved || surfaceResolved.kind !== "paragraph") return null;
8618
8683
  if (surfaceResolved.hasVerticalMergeContinuation) return null;
@@ -9067,14 +9132,12 @@ function resolveBlockPathInSurfaceBlocks(blocks, tokens, tokenIndex, hasVertical
9067
9132
  hasVerticalMergeContinuation || cell.verticalMerge === "continue"
9068
9133
  );
9069
9134
  }
9070
- function resolveTopLevelParagraphScope(document, selection) {
9135
+ function resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache) {
9071
9136
  const root = document.content;
9072
9137
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
9073
9138
  return null;
9074
9139
  }
9075
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
9076
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
9077
- });
9140
+ const surface = scopeSurfaceCache.get();
9078
9141
  const selectionFrom = Math.min(selection.anchor, selection.head);
9079
9142
  const selectionTo = Math.max(selection.anchor, selection.head);
9080
9143
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -9103,14 +9166,12 @@ function resolveTopLevelParagraphScope(document, selection) {
9103
9166
  }
9104
9167
  return null;
9105
9168
  }
9106
- function resolveTopLevelSdtParagraphScope(document, selection) {
9169
+ function resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache) {
9107
9170
  const root = document.content;
9108
9171
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
9109
9172
  return null;
9110
9173
  }
9111
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
9112
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
9113
- });
9174
+ const surface = scopeSurfaceCache.get();
9114
9175
  const selectionFrom = Math.min(selection.anchor, selection.head);
9115
9176
  const selectionTo = Math.max(selection.anchor, selection.head);
9116
9177
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -1,4 +1,4 @@
1
- import { T as TextTransactionTextTarget, C as CanonicalDocumentEnvelope, S as SelectionSnapshot, d as TextTransactionResult, e as StructuralMutationResult, I as InsertTableOptions, f as TextFormattingDirective, g as TransactionMapping } from '../../public-types-KBS6JnOs.cjs';
1
+ import { T as TextTransactionTextTarget, d as EditorSurfaceSnapshot, S as ScopeSurfaceTelemetry, C as CanonicalDocumentEnvelope, e as SelectionSnapshot, f as TextTransactionResult, g as StructuralMutationResult, I as InsertTableOptions, h as TextFormattingDirective, i as TransactionMapping } from '../../public-types-S8gTYwKo.cjs';
2
2
  import 'react';
3
3
  import 'yjs';
4
4
  import 'y-protocols/awareness';
@@ -12,6 +12,17 @@ interface TextCommandContext {
12
12
  textTarget?: TextTransactionTextTarget;
13
13
  rejectTargetlessTableStructureInsert?: boolean;
14
14
  preserveNumberingOnSplit?: boolean;
15
+ /**
16
+ * Optional pre-built scope surface for the current document/selection.
17
+ * Threaded from `CommandExecutionContext.renderSnapshot.surface` by the
18
+ * runtime so the canonical text-transaction layer reuses the runtime's
19
+ * cached surface on the typing hot path. The L02 layer keeps full
20
+ * functional correctness when this is omitted.
21
+ */
22
+ precomputedSurface?: EditorSurfaceSnapshot;
23
+ /** Optional perf-counter callbacks so the runtime can observe whether the
24
+ * precomputed surface was reused or a fresh one had to be built. */
25
+ surfaceTelemetry?: ScopeSurfaceTelemetry;
15
26
  }
16
27
  declare function insertText(document: CanonicalDocumentEnvelope, selection: SelectionSnapshot, text: string, context: TextCommandContext, formatting?: TextFormattingDirective): TextTransactionResult;
17
28
  declare function deleteSelectionOrBackward(document: CanonicalDocumentEnvelope, selection: SelectionSnapshot, context: TextCommandContext): TextTransactionResult;