@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
@@ -934,11 +934,14 @@ function collectEditableTargetRefs(doc, cache) {
934
934
  collectEditableTargetsInBlocks(
935
935
  context.blocks,
936
936
  {
937
+ doc,
937
938
  storyKey: context.storyKey,
938
939
  basePath: context.basePath,
939
940
  insideSdt: false,
940
941
  insideTextBox: false,
941
- tableDepth: 0
942
+ tableDepth: 0,
943
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
944
+ numberingTargetRevisionHash: createNumberingTargetRevisionHash(doc)
942
945
  },
943
946
  targets,
944
947
  cache
@@ -955,6 +958,7 @@ function buildBlockCacheSignature(context, blockIndex) {
955
958
  const owner = tt?.editableOwnersByChildIndex?.get(blockIndex);
956
959
  return [
957
960
  context.storyKey,
961
+ context.numberingTargetRevisionHash,
958
962
  context.insideSdt ? "1" : "0",
959
963
  context.insideTextBox ? "1" : "0",
960
964
  String(context.tableDepth),
@@ -1000,7 +1004,8 @@ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIn
1000
1004
  editableParagraphTargetPosture(targetKind),
1001
1005
  context.contentControl,
1002
1006
  context.tableTarget,
1003
- context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex)
1007
+ context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex),
1008
+ resolveEditableParagraphListIdentity(block, context)
1004
1009
  )
1005
1010
  );
1006
1011
  }
@@ -1529,7 +1534,7 @@ function collectEditableTargetsInInlines(inlines, basePath, context, targets) {
1529
1534
  }
1530
1535
  }
1531
1536
  }
1532
- function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner) {
1537
+ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner, listIdentity) {
1533
1538
  const paragraphText = collectParagraphText(paragraph);
1534
1539
  const paragraphTextHash = hashText(paragraphText);
1535
1540
  const sourceRef = paragraph.sourceRef;
@@ -1540,19 +1545,39 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
1540
1545
  context: { storyKey, insideSdt: contentControl !== void 0 },
1541
1546
  ...tableTarget
1542
1547
  }) : void 0;
1543
- const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
1548
+ const listAddress = listIdentity !== void 0 ? createCanonicalAddress({
1544
1549
  addressKind: "list-item-text",
1545
1550
  storyKey,
1546
1551
  staleCheckKind: "paragraph",
1547
1552
  operationScope: "list-text",
1548
- sourceRefs: [sourceRef],
1553
+ sourceRefs: [
1554
+ sourceRef,
1555
+ listIdentity.paragraphNumberingSourceRef,
1556
+ listIdentity.instanceSourceRef,
1557
+ listIdentity.abstractSourceRef
1558
+ ],
1549
1559
  staleHash: paragraphTextHash,
1550
1560
  rangeBoundary: { boundaryKind: "list-item-text" },
1561
+ list: {
1562
+ numberingOrigin: listIdentity.numberingOrigin,
1563
+ numberingInstanceId: listIdentity.numberingInstanceId,
1564
+ ...listIdentity.abstractNumberingId !== void 0 ? { abstractNumberingId: listIdentity.abstractNumberingId } : {},
1565
+ level: listIdentity.level,
1566
+ ...listIdentity.overrideHash !== void 0 ? { overrideHash: listIdentity.overrideHash } : {},
1567
+ numberingCatalogHash: listIdentity.numberingCatalogHash
1568
+ },
1551
1569
  discriminator: {
1552
1570
  blockPath,
1553
- numberingInstanceId: paragraph.numbering.numberingInstanceId,
1554
- level: paragraph.numbering.level,
1571
+ numberingOrigin: listIdentity.numberingOrigin,
1572
+ numberingInstanceId: listIdentity.numberingInstanceId,
1573
+ abstractNumberingId: listIdentity.abstractNumberingId ?? null,
1574
+ level: listIdentity.level,
1575
+ overrideHash: listIdentity.overrideHash ?? null,
1576
+ numberingCatalogHash: listIdentity.numberingCatalogHash,
1555
1577
  sourceId: sourceRef?.sourceId ?? null,
1578
+ numberingSourceId: listIdentity.paragraphNumberingSourceRef?.sourceId ?? null,
1579
+ numberingInstanceSourceId: listIdentity.instanceSourceRef?.sourceId ?? null,
1580
+ abstractNumberingSourceId: listIdentity.abstractSourceRef?.sourceId ?? null,
1556
1581
  paraId: paragraph.wordExtensionIds?.paraId ?? null,
1557
1582
  textId: paragraph.wordExtensionIds?.textId ?? null
1558
1583
  }
@@ -1593,11 +1618,62 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
1593
1618
  blockType: "paragraph",
1594
1619
  ...paragraph.wordExtensionIds?.paraId !== void 0 ? { wordParaId: paragraph.wordExtensionIds.paraId } : {},
1595
1620
  ...paragraph.wordExtensionIds?.textId !== void 0 ? { wordTextId: paragraph.wordExtensionIds.textId } : {},
1596
- ...sourceRef !== void 0 ? { sourceRef } : {}
1621
+ ...sourceRef !== void 0 ? { sourceRef } : {},
1622
+ ...listIdentity !== void 0 ? {
1623
+ listNumberingOrigin: listIdentity.numberingOrigin,
1624
+ listNumberingInstanceId: listIdentity.numberingInstanceId,
1625
+ ...listIdentity.abstractNumberingId !== void 0 ? { listAbstractNumberingId: listIdentity.abstractNumberingId } : {},
1626
+ listLevel: listIdentity.level,
1627
+ ...listIdentity.overrideHash !== void 0 ? { listOverrideHash: listIdentity.overrideHash } : {},
1628
+ numberingCatalogHash: listIdentity.numberingCatalogHash
1629
+ } : {}
1597
1630
  },
1598
1631
  posture
1599
1632
  };
1600
1633
  }
1634
+ function resolveEditableParagraphListIdentity(paragraph, context) {
1635
+ const directNumbering = paragraph.numbering;
1636
+ const styleNumbering = directNumbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(context.doc, paragraph.styleId) : void 0;
1637
+ const numbering = directNumbering ?? styleNumbering;
1638
+ if (numbering === void 0) return void 0;
1639
+ const numberingCatalog = context.doc.numbering ?? { abstractDefinitions: {}, instances: {} };
1640
+ const instances = numberingCatalog.instances ?? {};
1641
+ const abstractDefinitions = numberingCatalog.abstractDefinitions ?? {};
1642
+ const instance = instances[numbering.numberingInstanceId];
1643
+ const abstractDefinition = instance !== void 0 ? abstractDefinitions[instance.abstractNumberingId] : void 0;
1644
+ const level = numbering.level ?? 0;
1645
+ const override = instance?.overrides.find((entry) => entry.level === level);
1646
+ const overrideHash = override !== void 0 ? hashText(JSON.stringify(numberingOverrideDiscriminator(override))) : void 0;
1647
+ return {
1648
+ numberingOrigin: directNumbering !== void 0 ? "paragraph" : "paragraph-style",
1649
+ numberingInstanceId: numbering.numberingInstanceId,
1650
+ ...instance?.abstractNumberingId !== void 0 ? { abstractNumberingId: instance.abstractNumberingId } : {},
1651
+ level,
1652
+ ...overrideHash !== void 0 ? { overrideHash } : {},
1653
+ numberingCatalogHash: context.numberingCatalogHash,
1654
+ ...directNumbering?.sourceRef !== void 0 ? { paragraphNumberingSourceRef: directNumbering.sourceRef } : {},
1655
+ ...instance?.sourceRef !== void 0 ? { instanceSourceRef: instance.sourceRef } : {},
1656
+ ...abstractDefinition?.sourceRef !== void 0 ? { abstractSourceRef: abstractDefinition.sourceRef } : {}
1657
+ };
1658
+ }
1659
+ function numberingOverrideDiscriminator(override) {
1660
+ return {
1661
+ level: override.level,
1662
+ startAt: override.startAt ?? null,
1663
+ sourceId: override.sourceRef?.sourceId ?? null,
1664
+ levelDefinition: override.levelDefinition === void 0 ? null : {
1665
+ sourceId: override.levelDefinition.sourceRef?.sourceId ?? null,
1666
+ format: override.levelDefinition.format ?? null,
1667
+ text: override.levelDefinition.text ?? null,
1668
+ startAt: override.levelDefinition.startAt ?? null,
1669
+ paragraphStyleId: override.levelDefinition.paragraphStyleId ?? null,
1670
+ isLegalNumbering: override.levelDefinition.isLegalNumbering ?? null,
1671
+ suffix: override.levelDefinition.suffix ?? null,
1672
+ restartAfterLevel: override.levelDefinition.restartAfterLevel ?? null,
1673
+ picBulletId: override.levelDefinition.picBulletId ?? null
1674
+ }
1675
+ };
1676
+ }
1601
1677
  function contentControlLocksContent(contentControl) {
1602
1678
  return contentControl?.lock !== void 0 && contentControl.lock !== "unlocked" && contentControl.lock !== "none";
1603
1679
  }
@@ -2366,6 +2442,7 @@ function createCanonicalAddress(input) {
2366
2442
  ...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
2367
2443
  ...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
2368
2444
  ...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
2445
+ ...input.list !== void 0 ? { list: input.list } : {},
2369
2446
  ...input.secondaryStory === true ? { secondaryStory: true } : {},
2370
2447
  ...input.nestedTable === true ? { nestedTable: true } : {},
2371
2448
  ...input.insideSdt === true ? { insideSdt: true } : {},
@@ -2400,6 +2477,119 @@ function sourceJoinHash(refs) {
2400
2477
  if (sourceIds.length === 0) return void 0;
2401
2478
  return hashText(sourceIds.join("\0"));
2402
2479
  }
2480
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
2481
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
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) {
2494
+ const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
2495
+ const abstractDefinitions = catalog.abstractDefinitions ?? {};
2496
+ const instances = catalog.instances ?? {};
2497
+ const numPicBullets = catalog.numPicBullets ?? {};
2498
+ return hashText(JSON.stringify({
2499
+ abstractDefinitions: Object.keys(abstractDefinitions).sort().map((abstractNumberingId) => {
2500
+ const definition = abstractDefinitions[abstractNumberingId];
2501
+ return {
2502
+ abstractNumberingId,
2503
+ sourceId: definition.sourceRef?.sourceId ?? null,
2504
+ nsid: definition.nsid ?? null,
2505
+ tplc: definition.tplc ?? null,
2506
+ styleLink: definition.styleLink ?? null,
2507
+ numStyleLink: definition.numStyleLink ?? null,
2508
+ levels: definition.levels.map((level) => ({
2509
+ sourceId: level.sourceRef?.sourceId ?? null,
2510
+ level: level.level,
2511
+ format: level.format,
2512
+ text: level.text,
2513
+ startAt: level.startAt ?? null,
2514
+ paragraphStyleId: level.paragraphStyleId ?? null,
2515
+ isLegalNumbering: level.isLegalNumbering ?? null,
2516
+ suffix: level.suffix ?? null,
2517
+ restartAfterLevel: level.restartAfterLevel ?? null,
2518
+ picBulletId: level.picBulletId ?? null
2519
+ }))
2520
+ };
2521
+ }),
2522
+ instances: Object.keys(instances).sort().map((numberingInstanceId) => {
2523
+ const instance = instances[numberingInstanceId];
2524
+ return {
2525
+ numberingInstanceId,
2526
+ sourceId: instance.sourceRef?.sourceId ?? null,
2527
+ abstractNumberingId: instance.abstractNumberingId,
2528
+ overrides: instance.overrides.map(numberingOverrideDiscriminator)
2529
+ };
2530
+ }),
2531
+ numPicBullets: Object.keys(numPicBullets).sort().map((numPicBulletId) => {
2532
+ const picBullet = numPicBullets[numPicBulletId];
2533
+ return {
2534
+ numPicBulletId,
2535
+ sourceId: picBullet.sourceRef?.sourceId ?? null,
2536
+ mediaId: picBullet.mediaId ?? null,
2537
+ widthEmu: picBullet.widthEmu ?? null,
2538
+ heightEmu: picBullet.heightEmu ?? null
2539
+ };
2540
+ })
2541
+ }));
2542
+ }
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) {
2561
+ const paragraphStyles = doc.styles?.paragraphs ?? {};
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.
2565
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
2566
+ paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
2567
+ const style = paragraphStyles[styleId];
2568
+ return {
2569
+ styleId,
2570
+ basedOn: style.basedOn ?? null,
2571
+ numberingInstanceId: style.numbering?.numberingInstanceId ?? null,
2572
+ level: style.numbering?.level ?? null
2573
+ };
2574
+ })
2575
+ }));
2576
+ }
2577
+ function resolveParagraphStyleNumbering(doc, styleId) {
2578
+ const visited = /* @__PURE__ */ new Set();
2579
+ let currentStyleId = styleId;
2580
+ while (currentStyleId !== void 0 && !visited.has(currentStyleId)) {
2581
+ visited.add(currentStyleId);
2582
+ const style = doc.styles?.paragraphs?.[currentStyleId];
2583
+ if (style === void 0) {
2584
+ return void 0;
2585
+ }
2586
+ if (style.numbering !== void 0) {
2587
+ return style.numbering;
2588
+ }
2589
+ currentStyleId = style.basedOn;
2590
+ }
2591
+ return void 0;
2592
+ }
2403
2593
  function collectCanonicalFieldRegionIdentities(doc) {
2404
2594
  const registry = doc.fieldRegistry;
2405
2595
  const byFieldIndex = new Map(
@@ -3846,6 +4036,10 @@ function createNumberingPrefixResolver(catalog) {
3846
4036
  ])
3847
4037
  ) : resolved.effectiveLevels;
3848
4038
  const picBulletId = resolved.effectiveLevel.picBulletId;
4039
+ const pictureBulletPosture = resolvePictureBulletRenderPosture(
4040
+ picBulletId,
4041
+ picBulletId != null ? catalog.numPicBullets?.[picBulletId] : void 0
4042
+ );
3849
4043
  const text = renderLevelText(
3850
4044
  resolved.effectiveLevel.text,
3851
4045
  workingState.counters,
@@ -3854,14 +4048,20 @@ function createNumberingPrefixResolver(catalog) {
3854
4048
  if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
3855
4049
  return null;
3856
4050
  }
3857
- const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
4051
+ const visibleText = resolved.effectiveLevel.format === "none" ? null : text ?? pictureBulletPosture?.fallbackGlyph ?? null;
4052
+ const normalizedMarkerText = normalizeMarkerText(
4053
+ visibleText,
4054
+ resolved.effectiveLevel.format,
4055
+ resolved.geometry.markerRunProperties
4056
+ );
3858
4057
  const formatPosture = getNumberingFormatPosture(
3859
4058
  resolved.effectiveLevel.format,
3860
4059
  currentCounter
3861
4060
  );
3862
- const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
4061
+ const picBulletMediaId = pictureBulletPosture?.mediaId;
3863
4062
  return {
3864
- text: visibleText,
4063
+ text: normalizedMarkerText.text,
4064
+ ...normalizedMarkerText.posture !== void 0 ? { markerTextPosture: normalizedMarkerText.posture } : {},
3865
4065
  level: resolved.effectiveLevel.level,
3866
4066
  format: resolved.effectiveLevel.format,
3867
4067
  ...formatPosture !== void 0 ? { formatPosture } : {},
@@ -3871,7 +4071,9 @@ function createNumberingPrefixResolver(catalog) {
3871
4071
  ...resolved.effectiveLevel.isLegalNumbering ? { isLegalNumbering: true } : {},
3872
4072
  ...resolved.geometry.markerRunProperties ? { markerRunProperties: resolved.geometry.markerRunProperties } : {},
3873
4073
  geometry: resolved.geometry,
3874
- ...picBulletMediaId != null ? { picBulletMediaId } : {}
4074
+ ...picBulletId != null ? { picBulletId } : {},
4075
+ ...picBulletMediaId != null ? { picBulletMediaId } : {},
4076
+ ...pictureBulletPosture !== void 0 ? { pictureBulletPosture } : {}
3875
4077
  };
3876
4078
  }
3877
4079
  return {
@@ -3887,6 +4089,69 @@ function createNumberingPrefixResolver(catalog) {
3887
4089
  }
3888
4090
  };
3889
4091
  }
4092
+ function normalizeMarkerText(text, format, markerRunProperties) {
4093
+ if (text === null || format !== "bullet") {
4094
+ return { text };
4095
+ }
4096
+ const fontFamily = getMarkerFontFamily(markerRunProperties);
4097
+ if (!isKnownSymbolBulletFont(fontFamily)) {
4098
+ return { text };
4099
+ }
4100
+ const renderedText = Array.from(text, (char) => SYMBOL_BULLET_GLYPH_MAP.get(char) ?? char).join("");
4101
+ if (renderedText === text) {
4102
+ return { text };
4103
+ }
4104
+ return {
4105
+ text: renderedText,
4106
+ posture: {
4107
+ status: "normalized",
4108
+ sourceText: text,
4109
+ renderedText,
4110
+ reason: "symbol-font-bullet-normalized",
4111
+ ...fontFamily ? { fontFamily } : {}
4112
+ }
4113
+ };
4114
+ }
4115
+ function getMarkerFontFamily(markerRunProperties) {
4116
+ return markerRunProperties?.fontFamilyAscii ?? markerRunProperties?.fontFamilyHAnsi ?? markerRunProperties?.fontFamilyEastAsia ?? markerRunProperties?.fontFamilyCs ?? markerRunProperties?.fontFamily;
4117
+ }
4118
+ function isKnownSymbolBulletFont(fontFamily) {
4119
+ return fontFamily !== void 0 && /^(?:symbol|wingdings|wingdings 2|wingdings 3|webdings)$/iu.test(
4120
+ fontFamily.trim()
4121
+ );
4122
+ }
4123
+ var SYMBOL_BULLET_GLYPH_MAP = /* @__PURE__ */ new Map([
4124
+ ["\uF0B7", "\u2022"],
4125
+ ["\uF0A7", "\u25AA"],
4126
+ ["\uF0FC", "\u2713"]
4127
+ ]);
4128
+ function resolvePictureBulletRenderPosture(picBulletId, picBullet) {
4129
+ if (picBulletId == null) return void 0;
4130
+ if (!picBullet) {
4131
+ return {
4132
+ status: "preserve-only",
4133
+ picBulletId,
4134
+ fallbackGlyph: "\u2022",
4135
+ reason: "picture-bullet-catalog-entry-missing"
4136
+ };
4137
+ }
4138
+ if (picBullet.mediaId) {
4139
+ return {
4140
+ status: "media-rendered",
4141
+ picBulletId,
4142
+ mediaId: picBullet.mediaId,
4143
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
4144
+ reason: "picture-bullet-media-rendered"
4145
+ };
4146
+ }
4147
+ return {
4148
+ status: "glyph-fallback",
4149
+ picBulletId,
4150
+ fallbackGlyph: "\u2022",
4151
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
4152
+ reason: "picture-bullet-media-unavailable"
4153
+ };
4154
+ }
3890
4155
  function getSequenceState(states, numberingInstanceId, options = { create: true }) {
3891
4156
  const existing = states.get(numberingInstanceId);
3892
4157
  if (existing) {
@@ -3949,7 +4214,7 @@ function getNumberingFormatPosture(format, value) {
3949
4214
  reason: registryEntry?.fallbackReason ?? "unsupported-numbering-format-decimal-fallback"
3950
4215
  };
3951
4216
  }
3952
- if (value !== void 0 && ((format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
4217
+ if (value !== void 0 && (registryEntry.isInRange !== void 0 && !registryEntry.isInRange(value) || (format === "upperRoman" || format === "lowerRoman") && (value <= 0 || value >= 4e3) || (format === "cardinalText" || format === "ordinalText") && (!Number.isInteger(value) || value < 1 || value > 999) || (format === "upperLetter" || format === "lowerLetter" || format === "chicago") && value < 1)) {
3953
4218
  return {
3954
4219
  status: "approximated",
3955
4220
  requestedFormat: format,
@@ -4043,6 +4308,37 @@ var exactNumberingFormatEntries = [
4043
4308
  supportsMutation: true,
4044
4309
  render: toOrdinal2
4045
4310
  },
4311
+ {
4312
+ format: "decimalFullWidth",
4313
+ renderSupport: "supported",
4314
+ renderedFormat: "decimalFullWidth",
4315
+ supportsMutation: false,
4316
+ render: toFullWidthDecimal
4317
+ },
4318
+ {
4319
+ format: "decimalEnclosedCircle",
4320
+ renderSupport: "supported",
4321
+ renderedFormat: "decimalEnclosedCircle",
4322
+ supportsMutation: false,
4323
+ render: toCircledDecimal,
4324
+ isInRange: (value) => Number.isInteger(value) && value >= 0 && value <= 50
4325
+ },
4326
+ {
4327
+ format: "decimalEnclosedParen",
4328
+ renderSupport: "supported",
4329
+ renderedFormat: "decimalEnclosedParen",
4330
+ supportsMutation: false,
4331
+ render: (value) => Number.isInteger(value) && value > 0 ? `(${value})` : String(value),
4332
+ isInRange: (value) => Number.isInteger(value) && value > 0
4333
+ },
4334
+ {
4335
+ format: "decimalEnclosedFullstop",
4336
+ renderSupport: "supported",
4337
+ renderedFormat: "decimalEnclosedFullstop",
4338
+ supportsMutation: false,
4339
+ render: (value) => Number.isInteger(value) && value > 0 ? `${value}.` : String(value),
4340
+ isInRange: (value) => Number.isInteger(value) && value > 0
4341
+ },
4046
4342
  {
4047
4343
  format: "cardinalText",
4048
4344
  renderSupport: "supported",
@@ -4080,10 +4376,6 @@ var exactNumberingFormatEntries = [
4080
4376
  }
4081
4377
  ];
4082
4378
  var approximatedDecimalFormats = [
4083
- "decimalEnclosedCircle",
4084
- "decimalEnclosedFullstop",
4085
- "decimalEnclosedParen",
4086
- "decimalFullWidth",
4087
4379
  "decimalHalfWidth",
4088
4380
  "aiueo",
4089
4381
  "iroha",
@@ -4135,6 +4427,30 @@ function toOrdinal2(value) {
4135
4427
  return `${value}th`;
4136
4428
  }
4137
4429
  }
4430
+ function toFullWidthDecimal(value) {
4431
+ return String(value).replace(
4432
+ /[0-9]/g,
4433
+ (digit) => String.fromCharCode(65296 + Number.parseInt(digit, 10))
4434
+ );
4435
+ }
4436
+ var CIRCLED_DECIMAL_BY_VALUE = new Map([
4437
+ [0, "\u24EA"],
4438
+ ...Array.from({ length: 20 }, (_, index) => [
4439
+ index + 1,
4440
+ String.fromCodePoint(9312 + index)
4441
+ ]),
4442
+ ...Array.from({ length: 15 }, (_, index) => [
4443
+ index + 21,
4444
+ String.fromCodePoint(12881 + index)
4445
+ ]),
4446
+ ...Array.from({ length: 15 }, (_, index) => [
4447
+ index + 36,
4448
+ String.fromCodePoint(12977 + index)
4449
+ ])
4450
+ ]);
4451
+ function toCircledDecimal(value) {
4452
+ return CIRCLED_DECIMAL_BY_VALUE.get(value) ?? String(value);
4453
+ }
4138
4454
  function toAlphabetic2(value) {
4139
4455
  if (value <= 0) {
4140
4456
  return String(value);
@@ -4908,6 +5224,7 @@ function toNumberingLayoutInput(numbering) {
4908
5224
  const hangingTwips = textColumn?.hanging ?? numbering.geometry.indentation?.hanging ?? (typeof numbering.geometry.indentation?.firstLine === "number" && numbering.geometry.indentation.firstLine < 0 ? Math.abs(numbering.geometry.indentation.firstLine) : void 0);
4909
5225
  return {
4910
5226
  markerText: numbering.text,
5227
+ ...numbering.markerTextPosture ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
4911
5228
  ...numbering.markerRunProperties ? { markerRunFormatting: numbering.markerRunProperties } : {},
4912
5229
  markerSuffix: normalizeNumberingMarkerSuffix(numbering.suffix),
4913
5230
  ...markerLane ? { markerLaneStartTwips: markerLane.start } : {},
@@ -4920,7 +5237,9 @@ function toNumberingLayoutInput(numbering) {
4920
5237
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
4921
5238
  startAt: numbering.startAt,
4922
5239
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
4923
- ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
5240
+ ...numbering.picBulletId ? { pictureBulletId: numbering.picBulletId } : {},
5241
+ ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {},
5242
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
4924
5243
  };
4925
5244
  }
4926
5245
  function toFieldLayoutInput(entry, resolved, region) {
@@ -5432,6 +5751,7 @@ function buildEffectiveNumbering(detail) {
5432
5751
  const result = {
5433
5752
  level: detail.level,
5434
5753
  ...detail.text !== null ? { marker: detail.text } : {},
5754
+ ...detail.markerTextPosture ? { markerTextPosture: { ...detail.markerTextPosture } } : {},
5435
5755
  ...detail.markerRunProperties ? { markerRunFormatting: detail.markerRunProperties } : {},
5436
5756
  ...detail.geometry ? {
5437
5757
  indentation: {
@@ -5441,7 +5761,8 @@ function buildEffectiveNumbering(detail) {
5441
5761
  ...detail.geometry.tabStops && detail.geometry.tabStops.length > 0 ? { tab: detail.geometry.tabStops[0].position } : {}
5442
5762
  }
5443
5763
  } : {},
5444
- ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {}
5764
+ ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {},
5765
+ ...detail.pictureBulletPosture ? { pictureBulletPosture: { ...detail.pictureBulletPosture } } : {}
5445
5766
  };
5446
5767
  return result;
5447
5768
  }
@@ -7358,6 +7679,7 @@ function toSurfaceResolvedNumbering(numbering) {
7358
7679
  format: numbering.format,
7359
7680
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
7360
7681
  ...numbering.text !== null ? { text: numbering.text } : {},
7682
+ ...numbering.markerTextPosture !== void 0 ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
7361
7683
  startAt: numbering.startAt,
7362
7684
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
7363
7685
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
@@ -7370,7 +7692,9 @@ function toSurfaceResolvedNumbering(numbering) {
7370
7692
  ...numbering.geometry.markerLane ? { markerLane: { ...numbering.geometry.markerLane } } : {},
7371
7693
  ...numbering.geometry.textColumn ? { textColumn: { ...numbering.geometry.textColumn } } : {}
7372
7694
  },
7373
- ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {}
7695
+ ...numbering.picBulletId ? { picBulletId: numbering.picBulletId } : {},
7696
+ ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {},
7697
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
7374
7698
  };
7375
7699
  }
7376
7700
  function describePreservedInlinePreview(payloadReference) {
@@ -7592,7 +7916,38 @@ var TextTransactionError = class extends Error {
7592
7916
  this.code = code;
7593
7917
  }
7594
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
+ }
7595
7944
  function applyTextTransaction(document, selection, intent, options) {
7945
+ const scopeSurfaceCache = createScopeSurfaceCache(
7946
+ document,
7947
+ selection,
7948
+ options.precomputedSurface,
7949
+ options.surfaceTelemetry
7950
+ );
7596
7951
  if (options.textTarget) {
7597
7952
  if (options.textTarget.kind === "hyperlink-display") {
7598
7953
  const targetedHyperlinkResult = tryApplyHyperlinkDisplayTransaction(
@@ -7628,7 +7983,8 @@ function applyTextTransaction(document, selection, intent, options) {
7628
7983
  document,
7629
7984
  selection,
7630
7985
  intent,
7631
- options
7986
+ options,
7987
+ scopeSurfaceCache
7632
7988
  );
7633
7989
  if (targetedTableResult) {
7634
7990
  return targetedTableResult;
@@ -7642,7 +7998,8 @@ function applyTextTransaction(document, selection, intent, options) {
7642
7998
  const tableStructureRefusal = resolveTargetlessTableStructureInsertRefusal(
7643
7999
  document,
7644
8000
  selection,
7645
- intent
8001
+ intent,
8002
+ scopeSurfaceCache
7646
8003
  );
7647
8004
  if (tableStructureRefusal) {
7648
8005
  throw new TextTransactionError("unsupported_content", tableStructureRefusal);
@@ -7652,7 +8009,8 @@ function applyTextTransaction(document, selection, intent, options) {
7652
8009
  document,
7653
8010
  selection,
7654
8011
  intent,
7655
- options
8012
+ options,
8013
+ scopeSurfaceCache
7656
8014
  );
7657
8015
  if (topLevelParagraphResult) {
7658
8016
  return topLevelParagraphResult;
@@ -7661,7 +8019,8 @@ function applyTextTransaction(document, selection, intent, options) {
7661
8019
  document,
7662
8020
  selection,
7663
8021
  intent,
7664
- options
8022
+ options,
8023
+ scopeSurfaceCache
7665
8024
  );
7666
8025
  if (sdtScopedResult) {
7667
8026
  return sdtScopedResult;
@@ -7670,7 +8029,8 @@ function applyTextTransaction(document, selection, intent, options) {
7670
8029
  document,
7671
8030
  selection,
7672
8031
  intent,
7673
- options
8032
+ options,
8033
+ scopeSurfaceCache
7674
8034
  );
7675
8035
  if (tableScopedResult) {
7676
8036
  return tableScopedResult;
@@ -7723,9 +8083,9 @@ function applyLinearTextTransaction(document, selection, intent, options) {
7723
8083
  storyText: createPlainText(nextStory)
7724
8084
  };
7725
8085
  }
7726
- function tryApplyTableParagraphTransaction(document, selection, intent, options) {
8086
+ function tryApplyTableParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
7727
8087
  const tableTarget = options.textTarget?.kind === "table-paragraph" ? options.textTarget : void 0;
7728
- const scope = resolveTableParagraphScope(document, selection, tableTarget);
8088
+ const scope = resolveTableParagraphScope(document, selection, tableTarget, scopeSurfaceCache);
7729
8089
  if (!scope) {
7730
8090
  return null;
7731
8091
  }
@@ -7848,7 +8208,11 @@ function tryApplyTargetedTextLeafTransaction(document, selection, intent, option
7848
8208
  };
7849
8209
  }
7850
8210
  function tryApplyHyperlinkDisplayTransaction(document, selection, intent, options) {
7851
- const scope = resolveTargetedHyperlinkDisplayScope(document, selection, options.textTarget);
8211
+ const scope = resolveTargetedHyperlinkDisplayScope(
8212
+ document,
8213
+ selection,
8214
+ options.textTarget
8215
+ );
7852
8216
  if (!scope) {
7853
8217
  return null;
7854
8218
  }
@@ -7906,8 +8270,8 @@ function tryApplyHyperlinkDisplayTransaction(document, selection, intent, option
7906
8270
  storyText: localResult.storyText
7907
8271
  };
7908
8272
  }
7909
- function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options) {
7910
- const scope = resolveTopLevelSdtParagraphScope(document, selection);
8273
+ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
8274
+ const scope = resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache);
7911
8275
  if (!scope) {
7912
8276
  return null;
7913
8277
  }
@@ -7959,8 +8323,8 @@ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, op
7959
8323
  storyText: localResult.storyText
7960
8324
  };
7961
8325
  }
7962
- function tryApplyTopLevelParagraphTransaction(document, selection, intent, options) {
7963
- const scope = resolveTopLevelParagraphScope(document, selection);
8326
+ function tryApplyTopLevelParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
8327
+ const scope = resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache);
7964
8328
  if (!scope) {
7965
8329
  return null;
7966
8330
  }
@@ -8070,17 +8434,15 @@ function resolveTargetedHyperlinkDisplayScope(document, selection, target) {
8070
8434
  replace: resolved.replace
8071
8435
  };
8072
8436
  }
8073
- function resolveTableParagraphScope(document, selection, target) {
8437
+ function resolveTableParagraphScope(document, selection, target, scopeSurfaceCache) {
8074
8438
  if (target) {
8075
- return resolveTargetedTableParagraphScope(document, selection, target);
8439
+ return resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache);
8076
8440
  }
8077
8441
  const root = document.content;
8078
8442
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8079
8443
  return null;
8080
8444
  }
8081
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8082
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8083
- });
8445
+ const surface = scopeSurfaceCache.get();
8084
8446
  const selectionFrom = Math.min(selection.anchor, selection.head);
8085
8447
  const selectionTo = Math.max(selection.anchor, selection.head);
8086
8448
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -8185,7 +8547,7 @@ function resolveTableParagraphScope(document, selection, target) {
8185
8547
  }
8186
8548
  return null;
8187
8549
  }
8188
- function resolveTargetlessTableStructureInsertRefusal(document, selection, intent) {
8550
+ function resolveTargetlessTableStructureInsertRefusal(document, selection, intent, scopeSurfaceCache) {
8189
8551
  if (!isCollapsedInsertIntent(intent, selection)) {
8190
8552
  return null;
8191
8553
  }
@@ -8193,9 +8555,7 @@ function resolveTargetlessTableStructureInsertRefusal(document, selection, inten
8193
8555
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8194
8556
  return null;
8195
8557
  }
8196
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8197
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8198
- });
8558
+ const surface = scopeSurfaceCache.get();
8199
8559
  if (!selectionTouchesTableStructureBoundary(surface.blocks, selection.anchor)) {
8200
8560
  return null;
8201
8561
  }
@@ -8209,7 +8569,7 @@ function isCollapsedInsertIntent(intent, selection) {
8209
8569
  const rangeTo = intent.range ? Math.max(intent.range.from, intent.range.to) : Math.max(selection.anchor, selection.head);
8210
8570
  return rangeFrom === rangeTo;
8211
8571
  }
8212
- function resolveTargetedTableParagraphScope(document, selection, target) {
8572
+ function resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache) {
8213
8573
  const root = document.content;
8214
8574
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8215
8575
  return null;
@@ -8222,7 +8582,8 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8222
8582
  root,
8223
8583
  document,
8224
8584
  selection,
8225
- target
8585
+ target,
8586
+ scopeSurfaceCache
8226
8587
  );
8227
8588
  if (targetScope) {
8228
8589
  return targetScope;
@@ -8245,9 +8606,7 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8245
8606
  if (cell.verticalMerge === "continue") {
8246
8607
  return "unsupported";
8247
8608
  }
8248
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8249
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8250
- });
8609
+ const surface = scopeSurfaceCache.get();
8251
8610
  const surfaceBlock = surface.blocks[target.tableBlockIndex];
8252
8611
  const surfaceRow = surfaceBlock?.kind === "table" ? surfaceBlock.rows[target.rowIndex] : void 0;
8253
8612
  const surfaceCell = surfaceRow?.cells[target.cellIndex];
@@ -8311,16 +8670,14 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
8311
8670
  }
8312
8671
  };
8313
8672
  }
8314
- function resolveTargetedTableParagraphScopeByPath(root, document, selection, target) {
8673
+ function resolveTargetedTableParagraphScopeByPath(root, document, selection, target, scopeSurfaceCache) {
8315
8674
  if (!target.blockPath) return null;
8316
8675
  const tokens = parseCanonicalBlockPath(target.blockPath);
8317
8676
  if (!tokens) return null;
8318
8677
  const resolved = resolveBlockPathInCanonicalBlocks(root.children, tokens, 0);
8319
8678
  if (!resolved || resolved.block.type !== "paragraph") return null;
8320
8679
  if (resolved.hasVerticalMergeContinuation) return null;
8321
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8322
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8323
- });
8680
+ const surface = scopeSurfaceCache.get();
8324
8681
  const surfaceResolved = resolveBlockPathInSurfaceBlocks(surface.blocks, tokens, 0);
8325
8682
  if (!surfaceResolved || surfaceResolved.kind !== "paragraph") return null;
8326
8683
  if (surfaceResolved.hasVerticalMergeContinuation) return null;
@@ -8775,14 +9132,12 @@ function resolveBlockPathInSurfaceBlocks(blocks, tokens, tokenIndex, hasVertical
8775
9132
  hasVerticalMergeContinuation || cell.verticalMerge === "continue"
8776
9133
  );
8777
9134
  }
8778
- function resolveTopLevelParagraphScope(document, selection) {
9135
+ function resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache) {
8779
9136
  const root = document.content;
8780
9137
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8781
9138
  return null;
8782
9139
  }
8783
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8784
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8785
- });
9140
+ const surface = scopeSurfaceCache.get();
8786
9141
  const selectionFrom = Math.min(selection.anchor, selection.head);
8787
9142
  const selectionTo = Math.max(selection.anchor, selection.head);
8788
9143
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
@@ -8811,14 +9166,12 @@ function resolveTopLevelParagraphScope(document, selection) {
8811
9166
  }
8812
9167
  return null;
8813
9168
  }
8814
- function resolveTopLevelSdtParagraphScope(document, selection) {
9169
+ function resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache) {
8815
9170
  const root = document.content;
8816
9171
  if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
8817
9172
  return null;
8818
9173
  }
8819
- const surface = createEditorSurfaceSnapshot(document, selection, void 0, {
8820
- editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
8821
- });
9174
+ const surface = scopeSurfaceCache.get();
8822
9175
  const selectionFrom = Math.min(selection.anchor, selection.head);
8823
9176
  const selectionTo = Math.max(selection.anchor, selection.head);
8824
9177
  for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {