@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
package/dist/tailwind.cjs CHANGED
@@ -2668,6 +2668,43 @@ function TwToolbar(props) {
2668
2668
  const showPostFormattingDivider = showListActionsInRow || showSpacingActionsInRow || showInsertActionsInRow || showUpdateActionsInRow || showCompactOverflow;
2669
2669
  const zoomLabel = typeof zoomLevel === "number" ? `${zoomLevel}%` : zoomLevel === "pageWidth" ? "Fit width" : "Fit page";
2670
2670
  const showZoomSteppers = responsiveTier === "wide";
2671
+ const bulletedListState = resolveListCommandControl({
2672
+ canEdit,
2673
+ editDisabledReason,
2674
+ callback: props.onToggleBulletedList,
2675
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-bulleted")
2676
+ });
2677
+ const numberedListState = resolveListCommandControl({
2678
+ canEdit,
2679
+ editDisabledReason,
2680
+ callback: props.onToggleNumberedList,
2681
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-numbered")
2682
+ });
2683
+ const outdentState = resolveListCommandControl({
2684
+ canEdit,
2685
+ editDisabledReason,
2686
+ callback: props.onOutdent,
2687
+ availability: getListCommandAvailability(props.activeListReadback, "outdent")
2688
+ });
2689
+ const indentState = resolveListCommandControl({
2690
+ canEdit,
2691
+ editDisabledReason,
2692
+ callback: props.onIndent,
2693
+ availability: getListCommandAvailability(props.activeListReadback, "indent")
2694
+ });
2695
+ const restartNumberingState = resolveListCommandControl({
2696
+ canEdit,
2697
+ editDisabledReason,
2698
+ callback: props.onRestartNumbering,
2699
+ availability: getListCommandAvailability(props.activeListReadback, "restart-numbering")
2700
+ });
2701
+ const continueNumberingState = resolveListCommandControl({
2702
+ canEdit,
2703
+ editDisabledReason,
2704
+ callback: props.onContinueNumbering,
2705
+ availability: getListCommandAvailability(props.activeListReadback, "continue-numbering")
2706
+ });
2707
+ const activeListKind = props.activeListReadback?.listKind;
2671
2708
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2672
2709
  "header",
2673
2710
  {
@@ -2683,7 +2720,7 @@ function TwToolbar(props) {
2683
2720
  },
2684
2721
  className: [
2685
2722
  "shrink-0 rounded-[var(--radius-sm)] border border-[var(--color-border-subtle)]",
2686
- "bg-[var(--color-bg-chrome)] px-2.5",
2723
+ "bg-[var(--color-bg-chrome)] px-2.5 shadow-[var(--shadow-soft)]",
2687
2724
  isCompact ? "flex min-h-10 flex-wrap items-center gap-1.5 py-1.5" : "flex items-center gap-1"
2688
2725
  ].join(" "),
2689
2726
  children: [
@@ -2852,9 +2889,9 @@ function TwToolbar(props) {
2852
2889
  {
2853
2890
  icon: import_lucide_react5.List,
2854
2891
  label: "Bulleted list",
2855
- active: Boolean(props.activeListContext && !props.activeListContext.isOrdered),
2856
- disabled: !canEdit || !props.onToggleBulletedList,
2857
- disabledReason: editDisabledReason,
2892
+ active: activeListKind ? activeListKind === "bulleted" : Boolean(props.activeListContext && !props.activeListContext.isOrdered),
2893
+ disabled: bulletedListState.disabled,
2894
+ disabledReason: bulletedListState.disabledReason,
2858
2895
  onClick: props.onToggleBulletedList
2859
2896
  }
2860
2897
  ),
@@ -2863,9 +2900,9 @@ function TwToolbar(props) {
2863
2900
  {
2864
2901
  icon: import_lucide_react5.Rows3,
2865
2902
  label: "Numbered list",
2866
- active: Boolean(props.activeListContext?.isOrdered),
2867
- disabled: !canEdit || !props.onToggleNumberedList,
2868
- disabledReason: editDisabledReason,
2903
+ active: activeListKind ? activeListKind === "numbered" : Boolean(props.activeListContext?.isOrdered),
2904
+ disabled: numberedListState.disabled,
2905
+ disabledReason: numberedListState.disabledReason,
2869
2906
  onClick: props.onToggleNumberedList
2870
2907
  }
2871
2908
  )
@@ -2876,8 +2913,8 @@ function TwToolbar(props) {
2876
2913
  {
2877
2914
  icon: import_lucide_react5.Outdent,
2878
2915
  label: "Outdent",
2879
- disabled: !canEdit || !props.onOutdent,
2880
- disabledReason: editDisabledReason,
2916
+ disabled: outdentState.disabled,
2917
+ disabledReason: outdentState.disabledReason,
2881
2918
  onClick: props.onOutdent
2882
2919
  }
2883
2920
  ),
@@ -2886,8 +2923,8 @@ function TwToolbar(props) {
2886
2923
  {
2887
2924
  icon: import_lucide_react5.Indent,
2888
2925
  label: "Indent",
2889
- disabled: !canEdit || !props.onIndent,
2890
- disabledReason: editDisabledReason,
2926
+ disabled: indentState.disabled,
2927
+ disabledReason: indentState.disabledReason,
2891
2928
  onClick: props.onIndent
2892
2929
  }
2893
2930
  )
@@ -2897,8 +2934,8 @@ function TwToolbar(props) {
2897
2934
  ToolbarTextButton,
2898
2935
  {
2899
2936
  ariaLabel: "Restart numbering",
2900
- disabled: !canEdit || !props.onRestartNumbering,
2901
- disabledReason: editDisabledReason,
2937
+ disabled: restartNumberingState.disabled,
2938
+ disabledReason: restartNumberingState.disabledReason,
2902
2939
  onClick: props.onRestartNumbering,
2903
2940
  children: "Restart"
2904
2941
  }
@@ -2907,8 +2944,8 @@ function TwToolbar(props) {
2907
2944
  ToolbarTextButton,
2908
2945
  {
2909
2946
  ariaLabel: "Continue numbering",
2910
- disabled: !canEdit || !props.onContinueNumbering,
2911
- disabledReason: editDisabledReason,
2947
+ disabled: continueNumberingState.disabled,
2948
+ disabledReason: continueNumberingState.disabledReason,
2912
2949
  onClick: props.onContinueNumbering,
2913
2950
  children: "Continue"
2914
2951
  }
@@ -2952,6 +2989,7 @@ function TwToolbar(props) {
2952
2989
  ToolbarCompactOverflow,
2953
2990
  {
2954
2991
  activeListContext: props.activeListContext,
2992
+ activeListReadback: props.activeListReadback,
2955
2993
  canEdit,
2956
2994
  canInsertStructural,
2957
2995
  editDisabledReason,
@@ -3485,8 +3523,59 @@ function ToolbarFontSizeSelect(props) {
3485
3523
  }
3486
3524
  );
3487
3525
  }
3526
+ function getListCommandAvailability(readback, command) {
3527
+ return readback?.commandSupport.find((entry) => entry.command === command);
3528
+ }
3529
+ function resolveListCommandControl(input) {
3530
+ if (!input.canEdit) {
3531
+ return { disabled: true, disabledReason: input.editDisabledReason };
3532
+ }
3533
+ if (!input.callback) {
3534
+ return { disabled: true };
3535
+ }
3536
+ if (input.availability?.enabled === false) {
3537
+ return { disabled: true, disabledReason: input.availability.reason };
3538
+ }
3539
+ return { disabled: false };
3540
+ }
3488
3541
  function ToolbarCompactOverflow(props) {
3489
3542
  const [open, setOpen] = import_react4.default.useState(false);
3543
+ const bulletedListState = resolveListCommandControl({
3544
+ canEdit: props.canEdit,
3545
+ editDisabledReason: props.editDisabledReason,
3546
+ callback: props.onToggleBulletedList,
3547
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-bulleted")
3548
+ });
3549
+ const numberedListState = resolveListCommandControl({
3550
+ canEdit: props.canEdit,
3551
+ editDisabledReason: props.editDisabledReason,
3552
+ callback: props.onToggleNumberedList,
3553
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-numbered")
3554
+ });
3555
+ const outdentState = resolveListCommandControl({
3556
+ canEdit: props.canEdit,
3557
+ editDisabledReason: props.editDisabledReason,
3558
+ callback: props.onOutdent,
3559
+ availability: getListCommandAvailability(props.activeListReadback, "outdent")
3560
+ });
3561
+ const indentState = resolveListCommandControl({
3562
+ canEdit: props.canEdit,
3563
+ editDisabledReason: props.editDisabledReason,
3564
+ callback: props.onIndent,
3565
+ availability: getListCommandAvailability(props.activeListReadback, "indent")
3566
+ });
3567
+ const restartNumberingState = resolveListCommandControl({
3568
+ canEdit: props.canEdit,
3569
+ editDisabledReason: props.editDisabledReason,
3570
+ callback: props.onRestartNumbering,
3571
+ availability: getListCommandAvailability(props.activeListReadback, "restart-numbering")
3572
+ });
3573
+ const continueNumberingState = resolveListCommandControl({
3574
+ canEdit: props.canEdit,
3575
+ editDisabledReason: props.editDisabledReason,
3576
+ callback: props.onContinueNumbering,
3577
+ availability: getListCommandAvailability(props.activeListReadback, "continue-numbering")
3578
+ });
3490
3579
  const overflowGroups = [
3491
3580
  props.showStyleSelectors || props.showInlineFormatting || props.showTextColors ? "Format" : null,
3492
3581
  props.showListActions || props.showParagraphActions || props.showParagraphAlignment || props.showListContinuation ? "Paragraph" : null,
@@ -3703,8 +3792,8 @@ function ToolbarCompactOverflow(props) {
3703
3792
  ToolbarMenuButton,
3704
3793
  {
3705
3794
  ariaLabel: "Bulleted list",
3706
- disabled: !props.canEdit || !props.onToggleBulletedList,
3707
- disabledReason: props.editDisabledReason,
3795
+ disabled: bulletedListState.disabled,
3796
+ disabledReason: bulletedListState.disabledReason,
3708
3797
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.List, { className: "h-3.5 w-3.5" }),
3709
3798
  label: "Bulleted list",
3710
3799
  onClick: () => {
@@ -3717,8 +3806,8 @@ function ToolbarCompactOverflow(props) {
3717
3806
  ToolbarMenuButton,
3718
3807
  {
3719
3808
  ariaLabel: "Numbered list",
3720
- disabled: !props.canEdit || !props.onToggleNumberedList,
3721
- disabledReason: props.editDisabledReason,
3809
+ disabled: numberedListState.disabled,
3810
+ disabledReason: numberedListState.disabledReason,
3722
3811
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Rows3, { className: "h-3.5 w-3.5" }),
3723
3812
  label: "Numbered list",
3724
3813
  onClick: () => {
@@ -3747,8 +3836,8 @@ function ToolbarCompactOverflow(props) {
3747
3836
  ToolbarMenuButton,
3748
3837
  {
3749
3838
  ariaLabel: "Outdent",
3750
- disabled: !props.canEdit || !props.onOutdent,
3751
- disabledReason: props.editDisabledReason,
3839
+ disabled: outdentState.disabled,
3840
+ disabledReason: outdentState.disabledReason,
3752
3841
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Outdent, { className: "h-3.5 w-3.5" }),
3753
3842
  label: "Outdent",
3754
3843
  onClick: () => {
@@ -3761,8 +3850,8 @@ function ToolbarCompactOverflow(props) {
3761
3850
  ToolbarMenuButton,
3762
3851
  {
3763
3852
  ariaLabel: "Indent",
3764
- disabled: !props.canEdit || !props.onIndent,
3765
- disabledReason: props.editDisabledReason,
3853
+ disabled: indentState.disabled,
3854
+ disabledReason: indentState.disabledReason,
3766
3855
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Indent, { className: "h-3.5 w-3.5" }),
3767
3856
  label: "Indent",
3768
3857
  onClick: () => {
@@ -3777,8 +3866,8 @@ function ToolbarCompactOverflow(props) {
3777
3866
  ToolbarMenuButton,
3778
3867
  {
3779
3868
  ariaLabel: "Restart numbering",
3780
- disabled: !props.canEdit || !props.onRestartNumbering,
3781
- disabledReason: props.editDisabledReason,
3869
+ disabled: restartNumberingState.disabled,
3870
+ disabledReason: restartNumberingState.disabledReason,
3782
3871
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Rows3, { className: "h-3.5 w-3.5" }),
3783
3872
  label: "Restart numbering",
3784
3873
  onClick: () => {
@@ -3791,8 +3880,8 @@ function ToolbarCompactOverflow(props) {
3791
3880
  ToolbarMenuButton,
3792
3881
  {
3793
3882
  ariaLabel: "Continue numbering",
3794
- disabled: !props.canEdit || !props.onContinueNumbering,
3795
- disabledReason: props.editDisabledReason,
3883
+ disabled: continueNumberingState.disabled,
3884
+ disabledReason: continueNumberingState.disabledReason,
3796
3885
  icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.Rows3, { className: "h-3.5 w-3.5" }),
3797
3886
  label: "Continue numbering",
3798
3887
  onClick: () => {
@@ -6486,6 +6575,187 @@ function createNodeAnchor(at, assoc = 1) {
6486
6575
  }
6487
6576
  var MAIN_STORY_TARGET = { kind: "main" };
6488
6577
 
6578
+ // src/runtime/telemetry/perf-probe.ts
6579
+ function recordPerfSample(kind, durationMs = 0) {
6580
+ const state = getEnabledState();
6581
+ if (!state) {
6582
+ return null;
6583
+ }
6584
+ const token = `${kind}-${state.nextToken ?? 0}`;
6585
+ state.nextToken = (state.nextToken ?? 0) + 1;
6586
+ const sample = {
6587
+ token,
6588
+ kind,
6589
+ durationMs,
6590
+ recordedAt: Date.now()
6591
+ };
6592
+ pushSample(state, sample);
6593
+ return sample;
6594
+ }
6595
+ function incrementInvalidationCounter(counter, amount = 1) {
6596
+ const state = getEnabledState();
6597
+ if (!state) {
6598
+ return 0;
6599
+ }
6600
+ state.invalidationCounts ??= {};
6601
+ state.invalidationCounts[counter] = (state.invalidationCounts[counter] ?? 0) + amount;
6602
+ return state.invalidationCounts[counter];
6603
+ }
6604
+ function getEnabledState() {
6605
+ if (typeof window === "undefined") {
6606
+ return null;
6607
+ }
6608
+ const state = window.__DOCX_REACT_PERF_PROBE__;
6609
+ if (!state?.enabled) {
6610
+ return null;
6611
+ }
6612
+ return state;
6613
+ }
6614
+ function pushSample(state, sample) {
6615
+ state.samples ??= [];
6616
+ state.samples.push(sample);
6617
+ const maxSamples = state.maxSamples ?? 20;
6618
+ if (state.samples.length > maxSamples) {
6619
+ state.samples.splice(0, state.samples.length - maxSamples);
6620
+ }
6621
+ }
6622
+
6623
+ // src/runtime/story-context.ts
6624
+ function collectSectionContexts(document2) {
6625
+ const sections = [];
6626
+ let sectionIndex = 0;
6627
+ for (const block of document2.content.children) {
6628
+ if (block.type !== "section_break") {
6629
+ continue;
6630
+ }
6631
+ sections.push({
6632
+ index: sectionIndex,
6633
+ properties: block.sectionProperties
6634
+ });
6635
+ sectionIndex += 1;
6636
+ }
6637
+ sections.push({
6638
+ index: sectionIndex,
6639
+ properties: document2.subParts?.finalSectionProperties
6640
+ });
6641
+ return sections;
6642
+ }
6643
+ function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
6644
+ if (explicitReferences && explicitReferences.length > 0) {
6645
+ return explicitReferences.map((ref) => ({
6646
+ variant: ref.variant,
6647
+ relationshipId: ref.relationshipId
6648
+ }));
6649
+ }
6650
+ return documents.filter(
6651
+ (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
6652
+ ).map((entry) => ({
6653
+ variant: entry.variant,
6654
+ relationshipId: entry.relationshipId
6655
+ }));
6656
+ }
6657
+ function findHeaderFooterDocumentEntry(document2, target) {
6658
+ const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
6659
+ const matches = documents.filter(
6660
+ (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
6661
+ );
6662
+ if (matches.length === 0) {
6663
+ return void 0;
6664
+ }
6665
+ if (target.sectionIndex !== void 0) {
6666
+ return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
6667
+ }
6668
+ return matches[0];
6669
+ }
6670
+ function sectionSupportsStoryTarget(document2, sectionIndex, target) {
6671
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
6672
+ return false;
6673
+ }
6674
+ const section = collectSectionContexts(document2).find(
6675
+ (candidate) => candidate.index === sectionIndex
6676
+ );
6677
+ if (!section) {
6678
+ return false;
6679
+ }
6680
+ const variants = resolveSectionVariants(
6681
+ target.kind,
6682
+ sectionIndex,
6683
+ target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
6684
+ target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
6685
+ );
6686
+ return variants.some(
6687
+ (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
6688
+ );
6689
+ }
6690
+ function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
6691
+ if (!findHeaderFooterDocumentEntry(document2, target)) {
6692
+ return void 0;
6693
+ }
6694
+ if (target.sectionIndex !== void 0) {
6695
+ return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
6696
+ }
6697
+ const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
6698
+ (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
6699
+ );
6700
+ if (candidateIndexes.length === 0) {
6701
+ return void 0;
6702
+ }
6703
+ const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
6704
+ return {
6705
+ ...target,
6706
+ sectionIndex: resolvedSectionIndex
6707
+ };
6708
+ }
6709
+
6710
+ // src/runtime/story-targeting.ts
6711
+ function storyTargetKey(target) {
6712
+ switch (target.kind) {
6713
+ case "main":
6714
+ return "main";
6715
+ case "header":
6716
+ return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
6717
+ case "footer":
6718
+ return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
6719
+ case "footnote":
6720
+ return `footnote:${target.noteId}`;
6721
+ case "endnote":
6722
+ return `endnote:${target.noteId}`;
6723
+ }
6724
+ }
6725
+ function getStoryBlocks(document2, target) {
6726
+ if (target.kind === "main") {
6727
+ return document2.content.children;
6728
+ }
6729
+ const subParts = document2.subParts;
6730
+ if (!subParts) {
6731
+ return [];
6732
+ }
6733
+ switch (target.kind) {
6734
+ case "header": {
6735
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
6736
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
6737
+ }
6738
+ case "footer": {
6739
+ const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
6740
+ return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
6741
+ }
6742
+ case "footnote":
6743
+ return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
6744
+ case "endnote":
6745
+ return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
6746
+ }
6747
+ }
6748
+
6749
+ // src/runtime/render/render-frame-types.ts
6750
+ var DEFAULT_PX_PER_TWIP = 96 / 1440;
6751
+ var EMPTY_DECORATION_INDEX = Object.freeze({
6752
+ workflow: Object.freeze([]),
6753
+ comments: Object.freeze([]),
6754
+ revisions: Object.freeze([]),
6755
+ search: Object.freeze([]),
6756
+ locked: Object.freeze([])
6757
+ });
6758
+
6489
6759
  // src/core/schema/text-schema.ts
6490
6760
  function parseTextStory(content) {
6491
6761
  const root = normalizeDocumentRoot(content);
@@ -6893,151 +7163,25 @@ function deriveCapabilities(snapshot, reviewMode, workflowScope) {
6893
7163
  healthIssueCount,
6894
7164
  workflowOverlayPresent,
6895
7165
  workflowBlocked,
6896
- isDirty: snapshot.isDirty,
6897
- isReady,
6898
- hasFatalError
6899
- };
6900
- }
6901
- function toRuntimeAnchor(anchor) {
6902
- switch (anchor.kind) {
6903
- case "range":
6904
- return createRangeAnchor(anchor.from, anchor.to, anchor.assoc);
6905
- case "node":
6906
- return createNodeAnchor(anchor.at, anchor.assoc);
6907
- case "detached":
6908
- return createDetachedAnchor(anchor.lastKnownRange, anchor.reason);
6909
- }
6910
- }
6911
-
6912
- // src/api/public-types.ts
6913
- init_measurement_backend_canvas();
6914
-
6915
- // src/runtime/story-context.ts
6916
- function collectSectionContexts(document2) {
6917
- const sections = [];
6918
- let sectionIndex = 0;
6919
- for (const block of document2.content.children) {
6920
- if (block.type !== "section_break") {
6921
- continue;
6922
- }
6923
- sections.push({
6924
- index: sectionIndex,
6925
- properties: block.sectionProperties
6926
- });
6927
- sectionIndex += 1;
6928
- }
6929
- sections.push({
6930
- index: sectionIndex,
6931
- properties: document2.subParts?.finalSectionProperties
6932
- });
6933
- return sections;
6934
- }
6935
- function resolveSectionVariants(kind, sectionIndex, explicitReferences, documents) {
6936
- if (explicitReferences && explicitReferences.length > 0) {
6937
- return explicitReferences.map((ref) => ({
6938
- variant: ref.variant,
6939
- relationshipId: ref.relationshipId
6940
- }));
6941
- }
6942
- return documents.filter(
6943
- (entry) => entry.sectionIndex === void 0 || entry.sectionIndex === sectionIndex
6944
- ).map((entry) => ({
6945
- variant: entry.variant,
6946
- relationshipId: entry.relationshipId
6947
- }));
6948
- }
6949
- function findHeaderFooterDocumentEntry(document2, target) {
6950
- const documents = target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? [];
6951
- const matches = documents.filter(
6952
- (entry) => entry.relationshipId === target.relationshipId && entry.variant === target.variant
6953
- );
6954
- if (matches.length === 0) {
6955
- return void 0;
6956
- }
6957
- if (target.sectionIndex !== void 0) {
6958
- return matches.find((entry) => entry.sectionIndex === target.sectionIndex) ?? matches.find((entry) => entry.sectionIndex === void 0) ?? matches[0];
6959
- }
6960
- return matches[0];
6961
- }
6962
- function sectionSupportsStoryTarget(document2, sectionIndex, target) {
6963
- if (!findHeaderFooterDocumentEntry(document2, target)) {
6964
- return false;
6965
- }
6966
- const section = collectSectionContexts(document2).find(
6967
- (candidate) => candidate.index === sectionIndex
6968
- );
6969
- if (!section) {
6970
- return false;
6971
- }
6972
- const variants = resolveSectionVariants(
6973
- target.kind,
6974
- sectionIndex,
6975
- target.kind === "header" ? section.properties?.headerReferences : section.properties?.footerReferences,
6976
- target.kind === "header" ? document2.subParts?.headers ?? [] : document2.subParts?.footers ?? []
6977
- );
6978
- return variants.some(
6979
- (variant) => variant.relationshipId === target.relationshipId && variant.variant === target.variant
6980
- );
6981
- }
6982
- function normalizeHeaderFooterTarget(document2, target, preferredSectionIndex) {
6983
- if (!findHeaderFooterDocumentEntry(document2, target)) {
6984
- return void 0;
6985
- }
6986
- if (target.sectionIndex !== void 0) {
6987
- return sectionSupportsStoryTarget(document2, target.sectionIndex, target) ? target : void 0;
6988
- }
6989
- const candidateIndexes = collectSectionContexts(document2).map((section) => section.index).filter(
6990
- (sectionIndex) => sectionSupportsStoryTarget(document2, sectionIndex, target)
6991
- );
6992
- if (candidateIndexes.length === 0) {
6993
- return void 0;
6994
- }
6995
- const resolvedSectionIndex = preferredSectionIndex !== void 0 && candidateIndexes.includes(preferredSectionIndex) ? preferredSectionIndex : candidateIndexes[0];
6996
- return {
6997
- ...target,
6998
- sectionIndex: resolvedSectionIndex
6999
- };
7000
- }
7001
-
7002
- // src/runtime/story-targeting.ts
7003
- function storyTargetKey(target) {
7004
- switch (target.kind) {
7005
- case "main":
7006
- return "main";
7007
- case "header":
7008
- return `header:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
7009
- case "footer":
7010
- return `footer:${target.relationshipId}:${target.variant}:${target.sectionIndex ?? "*"}`;
7011
- case "footnote":
7012
- return `footnote:${target.noteId}`;
7013
- case "endnote":
7014
- return `endnote:${target.noteId}`;
7015
- }
7166
+ isDirty: snapshot.isDirty,
7167
+ isReady,
7168
+ hasFatalError
7169
+ };
7016
7170
  }
7017
- function getStoryBlocks(document2, target) {
7018
- if (target.kind === "main") {
7019
- return document2.content.children;
7020
- }
7021
- const subParts = document2.subParts;
7022
- if (!subParts) {
7023
- return [];
7024
- }
7025
- switch (target.kind) {
7026
- case "header": {
7027
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
7028
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
7029
- }
7030
- case "footer": {
7031
- const resolvedTarget = normalizeHeaderFooterTarget(document2, target);
7032
- return (resolvedTarget && findHeaderFooterDocumentEntry(document2, resolvedTarget)?.blocks) ?? [];
7033
- }
7034
- case "footnote":
7035
- return subParts.footnoteCollection?.footnotes[target.noteId]?.blocks ?? [];
7036
- case "endnote":
7037
- return subParts.footnoteCollection?.endnotes[target.noteId]?.blocks ?? [];
7171
+ function toRuntimeAnchor(anchor) {
7172
+ switch (anchor.kind) {
7173
+ case "range":
7174
+ return createRangeAnchor(anchor.from, anchor.to, anchor.assoc);
7175
+ case "node":
7176
+ return createNodeAnchor(anchor.at, anchor.assoc);
7177
+ case "detached":
7178
+ return createDetachedAnchor(anchor.lastKnownRange, anchor.reason);
7038
7179
  }
7039
7180
  }
7040
7181
 
7182
+ // src/api/public-types.ts
7183
+ init_measurement_backend_canvas();
7184
+
7041
7185
  // src/core/selection/anchor-conversion.ts
7042
7186
  var DEFAULT_PUBLIC_ASSOC = {
7043
7187
  start: -1,
@@ -7533,11 +7677,14 @@ function collectEditableTargetRefs(doc, cache) {
7533
7677
  collectEditableTargetsInBlocks(
7534
7678
  context.blocks,
7535
7679
  {
7680
+ doc,
7536
7681
  storyKey: context.storyKey,
7537
7682
  basePath: context.basePath,
7538
7683
  insideSdt: false,
7539
7684
  insideTextBox: false,
7540
- tableDepth: 0
7685
+ tableDepth: 0,
7686
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
7687
+ numberingTargetRevisionHash: createNumberingTargetRevisionHash(doc)
7541
7688
  },
7542
7689
  targets,
7543
7690
  cache
@@ -7554,6 +7701,7 @@ function buildBlockCacheSignature(context, blockIndex) {
7554
7701
  const owner = tt?.editableOwnersByChildIndex?.get(blockIndex);
7555
7702
  return [
7556
7703
  context.storyKey,
7704
+ context.numberingTargetRevisionHash,
7557
7705
  context.insideSdt ? "1" : "0",
7558
7706
  context.insideTextBox ? "1" : "0",
7559
7707
  String(context.tableDepth),
@@ -7599,7 +7747,8 @@ function collectEditableTargetsInBlocks(blocks, context, targets, cache, blockIn
7599
7747
  editableParagraphTargetPosture(targetKind),
7600
7748
  context.contentControl,
7601
7749
  context.tableTarget,
7602
- context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex)
7750
+ context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex),
7751
+ resolveEditableParagraphListIdentity(block, context)
7603
7752
  )
7604
7753
  );
7605
7754
  }
@@ -8128,7 +8277,7 @@ function collectEditableTargetsInInlines(inlines, basePath, context, targets) {
8128
8277
  }
8129
8278
  }
8130
8279
  }
8131
- function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner) {
8280
+ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner, listIdentity) {
8132
8281
  const paragraphText = collectParagraphText(paragraph);
8133
8282
  const paragraphTextHash = hashText(paragraphText);
8134
8283
  const sourceRef = paragraph.sourceRef;
@@ -8139,19 +8288,39 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
8139
8288
  context: { storyKey, insideSdt: contentControl !== void 0 },
8140
8289
  ...tableTarget
8141
8290
  }) : void 0;
8142
- const listAddress = paragraph.numbering !== void 0 ? createCanonicalAddress({
8291
+ const listAddress = listIdentity !== void 0 ? createCanonicalAddress({
8143
8292
  addressKind: "list-item-text",
8144
8293
  storyKey,
8145
8294
  staleCheckKind: "paragraph",
8146
8295
  operationScope: "list-text",
8147
- sourceRefs: [sourceRef],
8296
+ sourceRefs: [
8297
+ sourceRef,
8298
+ listIdentity.paragraphNumberingSourceRef,
8299
+ listIdentity.instanceSourceRef,
8300
+ listIdentity.abstractSourceRef
8301
+ ],
8148
8302
  staleHash: paragraphTextHash,
8149
8303
  rangeBoundary: { boundaryKind: "list-item-text" },
8304
+ list: {
8305
+ numberingOrigin: listIdentity.numberingOrigin,
8306
+ numberingInstanceId: listIdentity.numberingInstanceId,
8307
+ ...listIdentity.abstractNumberingId !== void 0 ? { abstractNumberingId: listIdentity.abstractNumberingId } : {},
8308
+ level: listIdentity.level,
8309
+ ...listIdentity.overrideHash !== void 0 ? { overrideHash: listIdentity.overrideHash } : {},
8310
+ numberingCatalogHash: listIdentity.numberingCatalogHash
8311
+ },
8150
8312
  discriminator: {
8151
8313
  blockPath,
8152
- numberingInstanceId: paragraph.numbering.numberingInstanceId,
8153
- level: paragraph.numbering.level,
8314
+ numberingOrigin: listIdentity.numberingOrigin,
8315
+ numberingInstanceId: listIdentity.numberingInstanceId,
8316
+ abstractNumberingId: listIdentity.abstractNumberingId ?? null,
8317
+ level: listIdentity.level,
8318
+ overrideHash: listIdentity.overrideHash ?? null,
8319
+ numberingCatalogHash: listIdentity.numberingCatalogHash,
8154
8320
  sourceId: sourceRef?.sourceId ?? null,
8321
+ numberingSourceId: listIdentity.paragraphNumberingSourceRef?.sourceId ?? null,
8322
+ numberingInstanceSourceId: listIdentity.instanceSourceRef?.sourceId ?? null,
8323
+ abstractNumberingSourceId: listIdentity.abstractSourceRef?.sourceId ?? null,
8155
8324
  paraId: paragraph.wordExtensionIds?.paraId ?? null,
8156
8325
  textId: paragraph.wordExtensionIds?.textId ?? null
8157
8326
  }
@@ -8192,11 +8361,62 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
8192
8361
  blockType: "paragraph",
8193
8362
  ...paragraph.wordExtensionIds?.paraId !== void 0 ? { wordParaId: paragraph.wordExtensionIds.paraId } : {},
8194
8363
  ...paragraph.wordExtensionIds?.textId !== void 0 ? { wordTextId: paragraph.wordExtensionIds.textId } : {},
8195
- ...sourceRef !== void 0 ? { sourceRef } : {}
8364
+ ...sourceRef !== void 0 ? { sourceRef } : {},
8365
+ ...listIdentity !== void 0 ? {
8366
+ listNumberingOrigin: listIdentity.numberingOrigin,
8367
+ listNumberingInstanceId: listIdentity.numberingInstanceId,
8368
+ ...listIdentity.abstractNumberingId !== void 0 ? { listAbstractNumberingId: listIdentity.abstractNumberingId } : {},
8369
+ listLevel: listIdentity.level,
8370
+ ...listIdentity.overrideHash !== void 0 ? { listOverrideHash: listIdentity.overrideHash } : {},
8371
+ numberingCatalogHash: listIdentity.numberingCatalogHash
8372
+ } : {}
8196
8373
  },
8197
8374
  posture
8198
8375
  };
8199
8376
  }
8377
+ function resolveEditableParagraphListIdentity(paragraph, context) {
8378
+ const directNumbering = paragraph.numbering;
8379
+ const styleNumbering = directNumbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(context.doc, paragraph.styleId) : void 0;
8380
+ const numbering = directNumbering ?? styleNumbering;
8381
+ if (numbering === void 0) return void 0;
8382
+ const numberingCatalog = context.doc.numbering ?? { abstractDefinitions: {}, instances: {} };
8383
+ const instances = numberingCatalog.instances ?? {};
8384
+ const abstractDefinitions = numberingCatalog.abstractDefinitions ?? {};
8385
+ const instance = instances[numbering.numberingInstanceId];
8386
+ const abstractDefinition = instance !== void 0 ? abstractDefinitions[instance.abstractNumberingId] : void 0;
8387
+ const level = numbering.level ?? 0;
8388
+ const override = instance?.overrides.find((entry) => entry.level === level);
8389
+ const overrideHash = override !== void 0 ? hashText(JSON.stringify(numberingOverrideDiscriminator(override))) : void 0;
8390
+ return {
8391
+ numberingOrigin: directNumbering !== void 0 ? "paragraph" : "paragraph-style",
8392
+ numberingInstanceId: numbering.numberingInstanceId,
8393
+ ...instance?.abstractNumberingId !== void 0 ? { abstractNumberingId: instance.abstractNumberingId } : {},
8394
+ level,
8395
+ ...overrideHash !== void 0 ? { overrideHash } : {},
8396
+ numberingCatalogHash: context.numberingCatalogHash,
8397
+ ...directNumbering?.sourceRef !== void 0 ? { paragraphNumberingSourceRef: directNumbering.sourceRef } : {},
8398
+ ...instance?.sourceRef !== void 0 ? { instanceSourceRef: instance.sourceRef } : {},
8399
+ ...abstractDefinition?.sourceRef !== void 0 ? { abstractSourceRef: abstractDefinition.sourceRef } : {}
8400
+ };
8401
+ }
8402
+ function numberingOverrideDiscriminator(override) {
8403
+ return {
8404
+ level: override.level,
8405
+ startAt: override.startAt ?? null,
8406
+ sourceId: override.sourceRef?.sourceId ?? null,
8407
+ levelDefinition: override.levelDefinition === void 0 ? null : {
8408
+ sourceId: override.levelDefinition.sourceRef?.sourceId ?? null,
8409
+ format: override.levelDefinition.format ?? null,
8410
+ text: override.levelDefinition.text ?? null,
8411
+ startAt: override.levelDefinition.startAt ?? null,
8412
+ paragraphStyleId: override.levelDefinition.paragraphStyleId ?? null,
8413
+ isLegalNumbering: override.levelDefinition.isLegalNumbering ?? null,
8414
+ suffix: override.levelDefinition.suffix ?? null,
8415
+ restartAfterLevel: override.levelDefinition.restartAfterLevel ?? null,
8416
+ picBulletId: override.levelDefinition.picBulletId ?? null
8417
+ }
8418
+ };
8419
+ }
8200
8420
  function contentControlLocksContent(contentControl) {
8201
8421
  return contentControl?.lock !== void 0 && contentControl.lock !== "unlocked" && contentControl.lock !== "none";
8202
8422
  }
@@ -8965,6 +9185,7 @@ function createCanonicalAddress(input) {
8965
9185
  ...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
8966
9186
  ...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
8967
9187
  ...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
9188
+ ...input.list !== void 0 ? { list: input.list } : {},
8968
9189
  ...input.secondaryStory === true ? { secondaryStory: true } : {},
8969
9190
  ...input.nestedTable === true ? { nestedTable: true } : {},
8970
9191
  ...input.insideSdt === true ? { insideSdt: true } : {},
@@ -8999,6 +9220,103 @@ function sourceJoinHash(refs) {
8999
9220
  if (sourceIds.length === 0) return void 0;
9000
9221
  return hashText(sourceIds.join("\0"));
9001
9222
  }
9223
+ var numberingCatalogHashCache = /* @__PURE__ */ new WeakMap();
9224
+ var numberingTargetHashCache = /* @__PURE__ */ new WeakMap();
9225
+ function createNumberingCatalogRevisionHash(doc) {
9226
+ const numbering = doc.numbering;
9227
+ if (numbering !== void 0) {
9228
+ const cached = numberingCatalogHashCache.get(numbering);
9229
+ if (cached !== void 0) return cached;
9230
+ const fresh = computeNumberingCatalogRevisionHash(doc);
9231
+ numberingCatalogHashCache.set(numbering, fresh);
9232
+ return fresh;
9233
+ }
9234
+ return computeNumberingCatalogRevisionHash(doc);
9235
+ }
9236
+ function computeNumberingCatalogRevisionHash(doc) {
9237
+ const catalog = doc.numbering ?? { abstractDefinitions: {}, instances: {} };
9238
+ const abstractDefinitions = catalog.abstractDefinitions ?? {};
9239
+ const instances = catalog.instances ?? {};
9240
+ const numPicBullets = catalog.numPicBullets ?? {};
9241
+ return hashText(JSON.stringify({
9242
+ abstractDefinitions: Object.keys(abstractDefinitions).sort().map((abstractNumberingId) => {
9243
+ const definition = abstractDefinitions[abstractNumberingId];
9244
+ return {
9245
+ abstractNumberingId,
9246
+ sourceId: definition.sourceRef?.sourceId ?? null,
9247
+ nsid: definition.nsid ?? null,
9248
+ tplc: definition.tplc ?? null,
9249
+ styleLink: definition.styleLink ?? null,
9250
+ numStyleLink: definition.numStyleLink ?? null,
9251
+ levels: definition.levels.map((level) => ({
9252
+ sourceId: level.sourceRef?.sourceId ?? null,
9253
+ level: level.level,
9254
+ format: level.format,
9255
+ text: level.text,
9256
+ startAt: level.startAt ?? null,
9257
+ paragraphStyleId: level.paragraphStyleId ?? null,
9258
+ isLegalNumbering: level.isLegalNumbering ?? null,
9259
+ suffix: level.suffix ?? null,
9260
+ restartAfterLevel: level.restartAfterLevel ?? null,
9261
+ picBulletId: level.picBulletId ?? null
9262
+ }))
9263
+ };
9264
+ }),
9265
+ instances: Object.keys(instances).sort().map((numberingInstanceId) => {
9266
+ const instance = instances[numberingInstanceId];
9267
+ return {
9268
+ numberingInstanceId,
9269
+ sourceId: instance.sourceRef?.sourceId ?? null,
9270
+ abstractNumberingId: instance.abstractNumberingId,
9271
+ overrides: instance.overrides.map(numberingOverrideDiscriminator)
9272
+ };
9273
+ }),
9274
+ numPicBullets: Object.keys(numPicBullets).sort().map((numPicBulletId) => {
9275
+ const picBullet = numPicBullets[numPicBulletId];
9276
+ return {
9277
+ numPicBulletId,
9278
+ sourceId: picBullet.sourceRef?.sourceId ?? null,
9279
+ mediaId: picBullet.mediaId ?? null,
9280
+ widthEmu: picBullet.widthEmu ?? null,
9281
+ heightEmu: picBullet.heightEmu ?? null
9282
+ };
9283
+ })
9284
+ }));
9285
+ }
9286
+ function createNumberingTargetRevisionHash(doc) {
9287
+ const numbering = doc.numbering;
9288
+ const styles = doc.styles;
9289
+ if (numbering !== void 0 && styles !== void 0) {
9290
+ let inner = numberingTargetHashCache.get(numbering);
9291
+ if (inner === void 0) {
9292
+ inner = /* @__PURE__ */ new WeakMap();
9293
+ numberingTargetHashCache.set(numbering, inner);
9294
+ }
9295
+ const cached = inner.get(styles);
9296
+ if (cached !== void 0) return cached;
9297
+ const fresh = computeNumberingTargetRevisionHash(doc);
9298
+ inner.set(styles, fresh);
9299
+ return fresh;
9300
+ }
9301
+ return computeNumberingTargetRevisionHash(doc);
9302
+ }
9303
+ function computeNumberingTargetRevisionHash(doc) {
9304
+ const paragraphStyles = doc.styles?.paragraphs ?? {};
9305
+ return hashText(JSON.stringify({
9306
+ // Reuses the memoized catalog hash on the hot path so a typing edit
9307
+ // pays for the catalog hash at most once across both helpers.
9308
+ numberingCatalogHash: createNumberingCatalogRevisionHash(doc),
9309
+ paragraphStyleNumbering: Object.keys(paragraphStyles).sort().map((styleId) => {
9310
+ const style = paragraphStyles[styleId];
9311
+ return {
9312
+ styleId,
9313
+ basedOn: style.basedOn ?? null,
9314
+ numberingInstanceId: style.numbering?.numberingInstanceId ?? null,
9315
+ level: style.numbering?.level ?? null
9316
+ };
9317
+ })
9318
+ }));
9319
+ }
9002
9320
  function collectCanonicalStoryIdentities(doc) {
9003
9321
  const stories = [
9004
9322
  {
@@ -9130,7 +9448,7 @@ function resolveParagraphStyleNumbering(doc, styleId) {
9130
9448
  let currentStyleId = styleId;
9131
9449
  while (currentStyleId !== void 0 && !visited.has(currentStyleId)) {
9132
9450
  visited.add(currentStyleId);
9133
- const style = doc.styles.paragraphs[currentStyleId];
9451
+ const style = doc.styles?.paragraphs?.[currentStyleId];
9134
9452
  if (style === void 0) {
9135
9453
  return void 0;
9136
9454
  }
@@ -10686,6 +11004,10 @@ function createNumberingPrefixResolver(catalog) {
10686
11004
  ])
10687
11005
  ) : resolved.effectiveLevels;
10688
11006
  const picBulletId = resolved.effectiveLevel.picBulletId;
11007
+ const pictureBulletPosture = resolvePictureBulletRenderPosture(
11008
+ picBulletId,
11009
+ picBulletId != null ? catalog.numPicBullets?.[picBulletId] : void 0
11010
+ );
10689
11011
  const text = renderLevelText(
10690
11012
  resolved.effectiveLevel.text,
10691
11013
  workingState.counters,
@@ -10694,14 +11016,20 @@ function createNumberingPrefixResolver(catalog) {
10694
11016
  if (picBulletId == null && resolved.effectiveLevel.format !== "none" && text === null) {
10695
11017
  return null;
10696
11018
  }
10697
- const visibleText = resolved.effectiveLevel.format === "none" ? null : text;
11019
+ const visibleText = resolved.effectiveLevel.format === "none" ? null : text ?? pictureBulletPosture?.fallbackGlyph ?? null;
11020
+ const normalizedMarkerText = normalizeMarkerText(
11021
+ visibleText,
11022
+ resolved.effectiveLevel.format,
11023
+ resolved.geometry.markerRunProperties
11024
+ );
10698
11025
  const formatPosture = getNumberingFormatPosture(
10699
11026
  resolved.effectiveLevel.format,
10700
11027
  currentCounter
10701
11028
  );
10702
- const picBulletMediaId = picBulletId != null ? catalog.numPicBullets?.[picBulletId]?.mediaId : void 0;
11029
+ const picBulletMediaId = pictureBulletPosture?.mediaId;
10703
11030
  return {
10704
- text: visibleText,
11031
+ text: normalizedMarkerText.text,
11032
+ ...normalizedMarkerText.posture !== void 0 ? { markerTextPosture: normalizedMarkerText.posture } : {},
10705
11033
  level: resolved.effectiveLevel.level,
10706
11034
  format: resolved.effectiveLevel.format,
10707
11035
  ...formatPosture !== void 0 ? { formatPosture } : {},
@@ -10711,7 +11039,9 @@ function createNumberingPrefixResolver(catalog) {
10711
11039
  ...resolved.effectiveLevel.isLegalNumbering ? { isLegalNumbering: true } : {},
10712
11040
  ...resolved.geometry.markerRunProperties ? { markerRunProperties: resolved.geometry.markerRunProperties } : {},
10713
11041
  geometry: resolved.geometry,
10714
- ...picBulletMediaId != null ? { picBulletMediaId } : {}
11042
+ ...picBulletId != null ? { picBulletId } : {},
11043
+ ...picBulletMediaId != null ? { picBulletMediaId } : {},
11044
+ ...pictureBulletPosture !== void 0 ? { pictureBulletPosture } : {}
10715
11045
  };
10716
11046
  }
10717
11047
  return {
@@ -10727,6 +11057,69 @@ function createNumberingPrefixResolver(catalog) {
10727
11057
  }
10728
11058
  };
10729
11059
  }
11060
+ function normalizeMarkerText(text, format, markerRunProperties) {
11061
+ if (text === null || format !== "bullet") {
11062
+ return { text };
11063
+ }
11064
+ const fontFamily = getMarkerFontFamily(markerRunProperties);
11065
+ if (!isKnownSymbolBulletFont(fontFamily)) {
11066
+ return { text };
11067
+ }
11068
+ const renderedText = Array.from(text, (char) => SYMBOL_BULLET_GLYPH_MAP.get(char) ?? char).join("");
11069
+ if (renderedText === text) {
11070
+ return { text };
11071
+ }
11072
+ return {
11073
+ text: renderedText,
11074
+ posture: {
11075
+ status: "normalized",
11076
+ sourceText: text,
11077
+ renderedText,
11078
+ reason: "symbol-font-bullet-normalized",
11079
+ ...fontFamily ? { fontFamily } : {}
11080
+ }
11081
+ };
11082
+ }
11083
+ function getMarkerFontFamily(markerRunProperties) {
11084
+ return markerRunProperties?.fontFamilyAscii ?? markerRunProperties?.fontFamilyHAnsi ?? markerRunProperties?.fontFamilyEastAsia ?? markerRunProperties?.fontFamilyCs ?? markerRunProperties?.fontFamily;
11085
+ }
11086
+ function isKnownSymbolBulletFont(fontFamily) {
11087
+ return fontFamily !== void 0 && /^(?:symbol|wingdings|wingdings 2|wingdings 3|webdings)$/iu.test(
11088
+ fontFamily.trim()
11089
+ );
11090
+ }
11091
+ var SYMBOL_BULLET_GLYPH_MAP = /* @__PURE__ */ new Map([
11092
+ ["\uF0B7", "\u2022"],
11093
+ ["\uF0A7", "\u25AA"],
11094
+ ["\uF0FC", "\u2713"]
11095
+ ]);
11096
+ function resolvePictureBulletRenderPosture(picBulletId, picBullet) {
11097
+ if (picBulletId == null) return void 0;
11098
+ if (!picBullet) {
11099
+ return {
11100
+ status: "preserve-only",
11101
+ picBulletId,
11102
+ fallbackGlyph: "\u2022",
11103
+ reason: "picture-bullet-catalog-entry-missing"
11104
+ };
11105
+ }
11106
+ if (picBullet.mediaId) {
11107
+ return {
11108
+ status: "media-rendered",
11109
+ picBulletId,
11110
+ mediaId: picBullet.mediaId,
11111
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
11112
+ reason: "picture-bullet-media-rendered"
11113
+ };
11114
+ }
11115
+ return {
11116
+ status: "glyph-fallback",
11117
+ picBulletId,
11118
+ fallbackGlyph: "\u2022",
11119
+ ...picBullet.sourceRef ? { sourceRef: picBullet.sourceRef } : {},
11120
+ reason: "picture-bullet-media-unavailable"
11121
+ };
11122
+ }
10730
11123
  function getSequenceState(states, numberingInstanceId, options = { create: true }) {
10731
11124
  const existing = states.get(numberingInstanceId);
10732
11125
  if (existing) {
@@ -10789,7 +11182,7 @@ function getNumberingFormatPosture(format, value) {
10789
11182
  reason: registryEntry?.fallbackReason ?? "unsupported-numbering-format-decimal-fallback"
10790
11183
  };
10791
11184
  }
10792
- 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)) {
11185
+ 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)) {
10793
11186
  return {
10794
11187
  status: "approximated",
10795
11188
  requestedFormat: format,
@@ -10883,6 +11276,37 @@ var exactNumberingFormatEntries = [
10883
11276
  supportsMutation: true,
10884
11277
  render: toOrdinal2
10885
11278
  },
11279
+ {
11280
+ format: "decimalFullWidth",
11281
+ renderSupport: "supported",
11282
+ renderedFormat: "decimalFullWidth",
11283
+ supportsMutation: false,
11284
+ render: toFullWidthDecimal
11285
+ },
11286
+ {
11287
+ format: "decimalEnclosedCircle",
11288
+ renderSupport: "supported",
11289
+ renderedFormat: "decimalEnclosedCircle",
11290
+ supportsMutation: false,
11291
+ render: toCircledDecimal,
11292
+ isInRange: (value) => Number.isInteger(value) && value >= 0 && value <= 50
11293
+ },
11294
+ {
11295
+ format: "decimalEnclosedParen",
11296
+ renderSupport: "supported",
11297
+ renderedFormat: "decimalEnclosedParen",
11298
+ supportsMutation: false,
11299
+ render: (value) => Number.isInteger(value) && value > 0 ? `(${value})` : String(value),
11300
+ isInRange: (value) => Number.isInteger(value) && value > 0
11301
+ },
11302
+ {
11303
+ format: "decimalEnclosedFullstop",
11304
+ renderSupport: "supported",
11305
+ renderedFormat: "decimalEnclosedFullstop",
11306
+ supportsMutation: false,
11307
+ render: (value) => Number.isInteger(value) && value > 0 ? `${value}.` : String(value),
11308
+ isInRange: (value) => Number.isInteger(value) && value > 0
11309
+ },
10886
11310
  {
10887
11311
  format: "cardinalText",
10888
11312
  renderSupport: "supported",
@@ -10920,10 +11344,6 @@ var exactNumberingFormatEntries = [
10920
11344
  }
10921
11345
  ];
10922
11346
  var approximatedDecimalFormats = [
10923
- "decimalEnclosedCircle",
10924
- "decimalEnclosedFullstop",
10925
- "decimalEnclosedParen",
10926
- "decimalFullWidth",
10927
11347
  "decimalHalfWidth",
10928
11348
  "aiueo",
10929
11349
  "iroha",
@@ -10975,6 +11395,30 @@ function toOrdinal2(value) {
10975
11395
  return `${value}th`;
10976
11396
  }
10977
11397
  }
11398
+ function toFullWidthDecimal(value) {
11399
+ return String(value).replace(
11400
+ /[0-9]/g,
11401
+ (digit) => String.fromCharCode(65296 + Number.parseInt(digit, 10))
11402
+ );
11403
+ }
11404
+ var CIRCLED_DECIMAL_BY_VALUE = new Map([
11405
+ [0, "\u24EA"],
11406
+ ...Array.from({ length: 20 }, (_, index) => [
11407
+ index + 1,
11408
+ String.fromCodePoint(9312 + index)
11409
+ ]),
11410
+ ...Array.from({ length: 15 }, (_, index) => [
11411
+ index + 21,
11412
+ String.fromCodePoint(12881 + index)
11413
+ ]),
11414
+ ...Array.from({ length: 15 }, (_, index) => [
11415
+ index + 36,
11416
+ String.fromCodePoint(12977 + index)
11417
+ ])
11418
+ ]);
11419
+ function toCircledDecimal(value) {
11420
+ return CIRCLED_DECIMAL_BY_VALUE.get(value) ?? String(value);
11421
+ }
10978
11422
  function toAlphabetic2(value) {
10979
11423
  if (value <= 0) {
10980
11424
  return String(value);
@@ -11748,6 +12192,7 @@ function toNumberingLayoutInput(numbering) {
11748
12192
  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);
11749
12193
  return {
11750
12194
  markerText: numbering.text,
12195
+ ...numbering.markerTextPosture ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
11751
12196
  ...numbering.markerRunProperties ? { markerRunFormatting: numbering.markerRunProperties } : {},
11752
12197
  markerSuffix: normalizeNumberingMarkerSuffix(numbering.suffix),
11753
12198
  ...markerLane ? { markerLaneStartTwips: markerLane.start } : {},
@@ -11760,7 +12205,9 @@ function toNumberingLayoutInput(numbering) {
11760
12205
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
11761
12206
  startAt: numbering.startAt,
11762
12207
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
11763
- ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {}
12208
+ ...numbering.picBulletId ? { pictureBulletId: numbering.picBulletId } : {},
12209
+ ...numbering.picBulletMediaId ? { pictureBulletMediaId: numbering.picBulletMediaId } : {},
12210
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
11764
12211
  };
11765
12212
  }
11766
12213
  function toFieldLayoutInput(entry, resolved, region) {
@@ -12272,6 +12719,7 @@ function buildEffectiveNumbering(detail) {
12272
12719
  const result = {
12273
12720
  level: detail.level,
12274
12721
  ...detail.text !== null ? { marker: detail.text } : {},
12722
+ ...detail.markerTextPosture ? { markerTextPosture: { ...detail.markerTextPosture } } : {},
12275
12723
  ...detail.markerRunProperties ? { markerRunFormatting: detail.markerRunProperties } : {},
12276
12724
  ...detail.geometry ? {
12277
12725
  indentation: {
@@ -12281,7 +12729,8 @@ function buildEffectiveNumbering(detail) {
12281
12729
  ...detail.geometry.tabStops && detail.geometry.tabStops.length > 0 ? { tab: detail.geometry.tabStops[0].position } : {}
12282
12730
  }
12283
12731
  } : {},
12284
- ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {}
12732
+ ...detail.picBulletMediaId ? { pictureBulletRef: detail.picBulletMediaId } : {},
12733
+ ...detail.pictureBulletPosture ? { pictureBulletPosture: { ...detail.pictureBulletPosture } } : {}
12285
12734
  };
12286
12735
  return result;
12287
12736
  }
@@ -14197,6 +14646,7 @@ function toSurfaceResolvedNumbering(numbering) {
14197
14646
  format: numbering.format,
14198
14647
  ...numbering.formatPosture !== void 0 ? { formatPosture: { ...numbering.formatPosture } } : {},
14199
14648
  ...numbering.text !== null ? { text: numbering.text } : {},
14649
+ ...numbering.markerTextPosture !== void 0 ? { markerTextPosture: { ...numbering.markerTextPosture } } : {},
14200
14650
  startAt: numbering.startAt,
14201
14651
  ...numbering.paragraphStyleId ? { paragraphStyleId: numbering.paragraphStyleId } : {},
14202
14652
  ...numbering.isLegalNumbering ? { isLegalNumbering: true } : {},
@@ -14209,7 +14659,9 @@ function toSurfaceResolvedNumbering(numbering) {
14209
14659
  ...numbering.geometry.markerLane ? { markerLane: { ...numbering.geometry.markerLane } } : {},
14210
14660
  ...numbering.geometry.textColumn ? { textColumn: { ...numbering.geometry.textColumn } } : {}
14211
14661
  },
14212
- ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {}
14662
+ ...numbering.picBulletId ? { picBulletId: numbering.picBulletId } : {},
14663
+ ...numbering.picBulletMediaId ? { picBulletMediaId: numbering.picBulletMediaId } : {},
14664
+ ...numbering.pictureBulletPosture ? { pictureBulletPosture: { ...numbering.pictureBulletPosture } } : {}
14213
14665
  };
14214
14666
  }
14215
14667
  function describePreservedInlinePreview(payloadReference) {
@@ -18281,6 +18733,11 @@ function freezeNumberingLayoutFacts(numbering) {
18281
18733
  if (numbering.numberingSourceRef) Object.freeze(numbering.numberingSourceRef);
18282
18734
  if (numbering.numberingInstanceSourceRef) Object.freeze(numbering.numberingInstanceSourceRef);
18283
18735
  if (numbering.abstractNumberingSourceRef) Object.freeze(numbering.abstractNumberingSourceRef);
18736
+ if (numbering.markerTextPosture) Object.freeze(numbering.markerTextPosture);
18737
+ if (numbering.pictureBulletPosture) {
18738
+ if (numbering.pictureBulletPosture.sourceRef) Object.freeze(numbering.pictureBulletPosture.sourceRef);
18739
+ Object.freeze(numbering.pictureBulletPosture);
18740
+ }
18284
18741
  if (numbering.markerLane) Object.freeze(numbering.markerLane);
18285
18742
  if (numbering.textColumn) Object.freeze(numbering.textColumn);
18286
18743
  if (numbering.tabStops) {
@@ -19233,8 +19690,17 @@ function collectNumberingLayoutFacts(block) {
19233
19690
  ...block.resolvedNumbering?.format !== void 0 ? { format: block.resolvedNumbering.format } : {},
19234
19691
  ...block.resolvedNumbering?.formatPosture !== void 0 ? { formatPosture: { ...block.resolvedNumbering.formatPosture } } : {},
19235
19692
  ...block.numberingPrefix !== void 0 ? { markerText: block.numberingPrefix } : {},
19693
+ ...block.resolvedNumbering?.markerTextPosture !== void 0 ? { markerTextPosture: { ...block.resolvedNumbering.markerTextPosture } } : {},
19236
19694
  ...block.numberingSuffix !== void 0 ? { markerSuffix: block.numberingSuffix } : {},
19237
19695
  ...block.resolvedNumbering?.geometry.markerJustification !== void 0 ? { markerJustification: block.resolvedNumbering.geometry.markerJustification } : {},
19696
+ ...block.resolvedNumbering?.picBulletId !== void 0 ? { picBulletId: block.resolvedNumbering.picBulletId } : {},
19697
+ ...block.resolvedNumbering?.picBulletMediaId !== void 0 ? { picBulletMediaId: block.resolvedNumbering.picBulletMediaId } : {},
19698
+ ...block.resolvedNumbering?.pictureBulletPosture !== void 0 ? {
19699
+ pictureBulletPosture: {
19700
+ ...block.resolvedNumbering.pictureBulletPosture,
19701
+ ...block.resolvedNumbering.pictureBulletPosture.sourceRef !== void 0 ? { sourceRef: { ...block.resolvedNumbering.pictureBulletPosture.sourceRef } } : {}
19702
+ }
19703
+ } : {},
19238
19704
  ...markerLane ? {
19239
19705
  markerLane: {
19240
19706
  startTwips: markerLane.start,
@@ -20023,7 +20489,7 @@ function fnv1a2(input) {
20023
20489
  }
20024
20490
 
20025
20491
  // src/runtime/layout/layout-engine-version.ts
20026
- var LAYOUT_ENGINE_VERSION = 93;
20492
+ var LAYOUT_ENGINE_VERSION = 94;
20027
20493
 
20028
20494
  // src/runtime/layout/layout-engine-instance.ts
20029
20495
  var FULL_VIEWPORT_WINDOW_KEY = "full";
@@ -20249,11 +20715,45 @@ function createLayoutEngine(options = {}) {
20249
20715
  const telemetryBus = options.telemetryBus;
20250
20716
  const dirtyFieldFamilies = /* @__PURE__ */ new Set();
20251
20717
  const listeners = /* @__PURE__ */ new Set();
20252
- let cachedKey = null;
20253
- let cachedGraph = null;
20254
- let cachedFormatting = null;
20255
- let cachedMapper = null;
20718
+ let cachedFull = null;
20719
+ let cachedWindowed = null;
20256
20720
  let previousPageCount = 0;
20721
+ function isFullViewportKey(key) {
20722
+ return key === FULL_VIEWPORT_WINDOW_KEY;
20723
+ }
20724
+ function getCachedSlot(viewportWindowKeyValue) {
20725
+ return isFullViewportKey(viewportWindowKeyValue) ? cachedFull : cachedWindowed;
20726
+ }
20727
+ function preferredCachedGraph() {
20728
+ return cachedFull?.graph ?? cachedWindowed?.graph ?? null;
20729
+ }
20730
+ function clearAllSlots() {
20731
+ cachedFull = null;
20732
+ cachedWindowed = null;
20733
+ }
20734
+ function clearWindowedSlot() {
20735
+ cachedWindowed = null;
20736
+ }
20737
+ function evictStaleSiblingSlot(freshKey) {
20738
+ const sibling = isFullViewportKey(freshKey.viewportWindowKey) ? cachedWindowed : cachedFull;
20739
+ if (sibling === null) return;
20740
+ if (sibling.key.content === freshKey.content && sibling.key.styles === freshKey.styles && sibling.key.subParts === freshKey.subParts) {
20741
+ return;
20742
+ }
20743
+ if (isFullViewportKey(freshKey.viewportWindowKey)) {
20744
+ cachedWindowed = null;
20745
+ } else {
20746
+ cachedFull = null;
20747
+ }
20748
+ }
20749
+ function commitSlot(slot) {
20750
+ if (isFullViewportKey(slot.key.viewportWindowKey)) {
20751
+ cachedFull = slot;
20752
+ } else {
20753
+ cachedWindowed = slot;
20754
+ }
20755
+ evictStaleSiblingSlot(slot.key);
20756
+ }
20257
20757
  let pendingInvalidation = null;
20258
20758
  function emit(event) {
20259
20759
  for (const listener of listeners) {
@@ -20399,27 +20899,31 @@ function createLayoutEngine(options = {}) {
20399
20899
  subParts: document2.subParts,
20400
20900
  anchors: layoutInputs.anchors
20401
20901
  });
20902
+ const priorGraphForMaterialization = preferredCachedGraph();
20402
20903
  const graph = applyViewportWindowMaterialization(
20403
20904
  measuredGraph,
20404
20905
  viewportWindow,
20405
- cachedGraph
20906
+ priorGraphForMaterialization
20406
20907
  );
20407
- const dirtyFamilies = computeFieldDirtiness(cachedGraph, graph);
20908
+ const priorGraphForFieldDirtiness = preferredCachedGraph();
20909
+ const dirtyFamilies = computeFieldDirtiness(priorGraphForFieldDirtiness, graph);
20408
20910
  for (const family of dirtyFamilies) {
20409
20911
  dirtyFieldFamilies.add(family);
20410
20912
  }
20411
20913
  const formatting = buildResolvedFormattingState(document2, mainSurface);
20412
20914
  const currentPageCount = graph.contentPageCount;
20413
20915
  const pageCountDelta = currentPageCount !== previousPageCount ? { previous: previousPageCount, current: currentPageCount } : void 0;
20414
- cachedKey = {
20415
- content: document2.content,
20416
- styles: document2.styles,
20417
- subParts: document2.subParts,
20418
- viewportWindowKey: viewportWindowKey(viewportWindow)
20419
- };
20420
- cachedGraph = graph;
20421
- cachedFormatting = formatting;
20422
- cachedMapper = createPageFragmentMapper(graph);
20916
+ commitSlot({
20917
+ key: {
20918
+ content: document2.content,
20919
+ styles: document2.styles,
20920
+ subParts: document2.subParts,
20921
+ viewportWindowKey: viewportWindowKey(viewportWindow)
20922
+ },
20923
+ graph,
20924
+ formatting,
20925
+ mapper: createPageFragmentMapper(graph)
20926
+ });
20423
20927
  if (pageCountDelta) {
20424
20928
  emit({
20425
20929
  kind: "page_count_changed",
@@ -20460,7 +20964,7 @@ function createLayoutEngine(options = {}) {
20460
20964
  return graph;
20461
20965
  }
20462
20966
  function incrementalRelayout(input, pending) {
20463
- const priorGraph = cachedGraph;
20967
+ const priorGraph = cachedFull?.graph ?? null;
20464
20968
  const range = pending.result.dirtyPageRange;
20465
20969
  if (!priorGraph || !range) return null;
20466
20970
  const telemetryOn = telemetryBus?.isEnabled("layout") ?? false;
@@ -20553,6 +21057,22 @@ function createLayoutEngine(options = {}) {
20553
21057
  deriveDocumentPageSnapshots(splicedGraph)
20554
21058
  );
20555
21059
  const pageCountDelta = currentPageCount !== previousPageCount ? { previous: previousPageCount, current: currentPageCount } : void 0;
21060
+ const priorMapper = cachedFull?.mapper ?? null;
21061
+ commitSlot({
21062
+ key: {
21063
+ content: document2.content,
21064
+ styles: document2.styles,
21065
+ subParts: document2.subParts,
21066
+ viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
21067
+ },
21068
+ graph: splicedGraph,
21069
+ formatting,
21070
+ mapper: rebuildMapper(
21071
+ priorMapper ?? createPageFragmentMapper(splicedGraph),
21072
+ splicedGraph,
21073
+ firstDirty
21074
+ )
21075
+ });
20556
21076
  if (pageCountDelta) {
20557
21077
  emit({
20558
21078
  kind: "page_count_changed",
@@ -20582,19 +21102,6 @@ function createLayoutEngine(options = {}) {
20582
21102
  ...dirtyFamilies.length > 0 ? { dirtyFieldFamilies: dirtyFamilies } : {},
20583
21103
  ...pageCountDelta ? { pageCountDelta } : {}
20584
21104
  });
20585
- cachedKey = {
20586
- content: document2.content,
20587
- styles: document2.styles,
20588
- subParts: document2.subParts,
20589
- viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
20590
- };
20591
- cachedGraph = splicedGraph;
20592
- cachedFormatting = formatting;
20593
- cachedMapper = rebuildMapper(
20594
- cachedMapper ?? createPageFragmentMapper(splicedGraph),
20595
- splicedGraph,
20596
- firstDirty
20597
- );
20598
21105
  if (telemetryOn) {
20599
21106
  emitRecomputeCompleted(
20600
21107
  "bounded",
@@ -20611,13 +21118,14 @@ function createLayoutEngine(options = {}) {
20611
21118
  const document2 = input.document;
20612
21119
  const normalizedWindow = normalizeViewportPageWindow(input.viewportPageWindow);
20613
21120
  const currentViewportWindowKey = viewportWindowKey(normalizedWindow);
20614
- const keyEqual = cachedGraph !== null && cachedKey !== null && cachedKey.content === document2.content && cachedKey.styles === document2.styles && cachedKey.subParts === document2.subParts && cachedKey.viewportWindowKey === currentViewportWindowKey;
21121
+ const slot = getCachedSlot(currentViewportWindowKey);
21122
+ const keyEqual = slot !== null && slot.key.content === document2.content && slot.key.styles === document2.styles && slot.key.subParts === document2.subParts && slot.key.viewportWindowKey === currentViewportWindowKey;
20615
21123
  if (keyEqual && pendingInvalidation === null) {
20616
- return cachedGraph;
21124
+ return slot.graph;
20617
21125
  }
20618
21126
  const pending = pendingInvalidation;
20619
21127
  pendingInvalidation = null;
20620
- if (pending !== null && pending.result.scope === "bounded" && cachedGraph !== null && normalizedWindow === void 0) {
21128
+ if (pending !== null && pending.result.scope === "bounded" && cachedFull !== null && normalizedWindow === void 0) {
20621
21129
  const spliced = incrementalRelayout(input, pending);
20622
21130
  if (spliced !== null) {
20623
21131
  return spliced;
@@ -20626,16 +21134,39 @@ function createLayoutEngine(options = {}) {
20626
21134
  }
20627
21135
  return fullRebuild(input, pending?.reason);
20628
21136
  }
21137
+ function ensureSlotMapperAndFormatting(slot, document2) {
21138
+ if (slot.mapper === null) {
21139
+ slot.mapper = createPageFragmentMapper(slot.graph);
21140
+ }
21141
+ if (slot.formatting === null) {
21142
+ const mainSurface = createEditorSurfaceSnapshot(
21143
+ document2,
21144
+ createSelectionSnapshot(0, 0),
21145
+ MAIN_STORY_TARGET
21146
+ );
21147
+ slot.formatting = buildResolvedFormattingState(document2, mainSurface);
21148
+ }
21149
+ }
20629
21150
  function getMapper(input) {
20630
21151
  getGraphInternal(input);
20631
- return cachedMapper;
21152
+ const currentViewportWindowKey = viewportWindowKey(
21153
+ normalizeViewportPageWindow(input.viewportPageWindow)
21154
+ );
21155
+ const slot = getCachedSlot(currentViewportWindowKey);
21156
+ ensureSlotMapperAndFormatting(slot, input.document);
21157
+ return slot.mapper;
20632
21158
  }
20633
21159
  function getFormatting(input) {
20634
21160
  getGraphInternal(input);
20635
- return cachedFormatting;
21161
+ const currentViewportWindowKey = viewportWindowKey(
21162
+ normalizeViewportPageWindow(input.viewportPageWindow)
21163
+ );
21164
+ const slot = getCachedSlot(currentViewportWindowKey);
21165
+ ensureSlotMapperAndFormatting(slot, input.document);
21166
+ return slot.formatting;
20636
21167
  }
20637
21168
  if (autoUpgradeToCanvas && options.measurementProvider === void 0 && typeof document !== "undefined" && typeof HTMLCanvasElement !== "undefined") {
20638
- const readCachedRevision = () => cachedGraph?.revision ?? 0;
21169
+ const readCachedRevision = () => preferredCachedGraph()?.revision ?? 0;
20639
21170
  void (async () => {
20640
21171
  try {
20641
21172
  const mod = await Promise.resolve().then(() => (init_measurement_backend_canvas(), measurement_backend_canvas_exports));
@@ -20645,10 +21176,7 @@ function createLayoutEngine(options = {}) {
20645
21176
  options.measurementCache,
20646
21177
  telemetryBus
20647
21178
  );
20648
- cachedKey = null;
20649
- cachedGraph = null;
20650
- cachedFormatting = null;
20651
- cachedMapper = null;
21179
+ clearAllSlots();
20652
21180
  emit({
20653
21181
  kind: "measurement_backend_ready",
20654
21182
  revision: readCachedRevision(),
@@ -20692,22 +21220,19 @@ function createLayoutEngine(options = {}) {
20692
21220
  return getMapper(input);
20693
21221
  },
20694
21222
  invalidate(reason) {
20695
- const result = analyzeInvalidation(reason, cachedGraph);
21223
+ const result = analyzeInvalidation(reason, preferredCachedGraph());
20696
21224
  for (const family of result.dirtyFieldFamilies) {
20697
21225
  dirtyFieldFamilies.add(family);
20698
21226
  }
20699
21227
  if (result.scope === "bounded") {
20700
21228
  pendingInvalidation = { reason, result };
20701
21229
  } else {
20702
- cachedKey = null;
20703
- cachedGraph = null;
20704
- cachedFormatting = null;
20705
- cachedMapper = null;
21230
+ clearAllSlots();
20706
21231
  pendingInvalidation = { reason, result };
20707
21232
  }
20708
21233
  },
20709
21234
  analyzeInvalidation(reason) {
20710
- return analyzeInvalidation(reason, cachedGraph);
21235
+ return analyzeInvalidation(reason, preferredCachedGraph());
20711
21236
  },
20712
21237
  getDirtyFieldFamilies() {
20713
21238
  return Array.from(dirtyFieldFamilies);
@@ -20735,14 +21260,11 @@ function createLayoutEngine(options = {}) {
20735
21260
  telemetryBus
20736
21261
  );
20737
21262
  if (previousFidelity !== provider.fidelity) {
20738
- cachedKey = null;
20739
- cachedGraph = null;
20740
- cachedFormatting = null;
20741
- cachedMapper = null;
21263
+ clearAllSlots();
20742
21264
  }
20743
21265
  emit({
20744
21266
  kind: "measurement_backend_ready",
20745
- revision: cachedGraph?.revision ?? 0,
21267
+ revision: preferredCachedGraph()?.revision ?? 0,
20746
21268
  fidelity: provider.fidelity
20747
21269
  });
20748
21270
  },
@@ -20757,30 +21279,33 @@ function createLayoutEngine(options = {}) {
20757
21279
  */
20758
21280
  invalidateMeasurementCache() {
20759
21281
  measurementProvider.invalidateCache();
20760
- cachedKey = null;
20761
- cachedGraph = null;
20762
- cachedFormatting = null;
20763
- cachedMapper = null;
21282
+ clearAllSlots();
20764
21283
  },
20765
21284
  getMeasurementCacheStats() {
20766
21285
  if (!isCachedLayoutMeasurementProvider(measurementProvider)) return null;
20767
21286
  return measurementProvider.measurementCacheStats();
20768
21287
  },
20769
21288
  /**
20770
- * L7 Phase 2.5 — seed the cached graph from a prerender envelope.
20771
- * Populates both `cachedGraph` and `cachedKey` (keyed on the provided
20772
- * document's identity-equal slots) so the next getPageGraph query
20773
- * returns the seeded graph directly. Any subsequent mutation
20774
- * invalidates normally through the existing path.
21289
+ * L7 Phase 2.5 — seed the full-slot cached graph from a prerender
21290
+ * envelope. Populates the full slot (graph + key, with formatting and
21291
+ * mapper computed lazily on first read) so the next viewport-
21292
+ * independent `getPageGraph` query returns the seeded graph directly.
21293
+ * Any subsequent mutation invalidates normally through the existing
21294
+ * path; sibling eviction in `commitSlot` clears `cachedWindowed` if
21295
+ * it carried a different document tuple.
20775
21296
  */
20776
21297
  seedCachedGraph(graph, document2) {
20777
- cachedGraph = graph;
20778
- cachedKey = {
20779
- content: document2.content,
20780
- styles: document2.styles,
20781
- subParts: document2.subParts,
20782
- viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
20783
- };
21298
+ commitSlot({
21299
+ key: {
21300
+ content: document2.content,
21301
+ styles: document2.styles,
21302
+ subParts: document2.subParts,
21303
+ viewportWindowKey: FULL_VIEWPORT_WINDOW_KEY
21304
+ },
21305
+ graph,
21306
+ formatting: null,
21307
+ mapper: null
21308
+ });
20784
21309
  previousPageCount = graph.contentPageCount;
20785
21310
  }
20786
21311
  };
@@ -20848,16 +21373,6 @@ function findPageForOffset3(pages, offset) {
20848
21373
  return Math.max(0, pages.length - 1);
20849
21374
  }
20850
21375
 
20851
- // src/runtime/render/render-frame-types.ts
20852
- var DEFAULT_PX_PER_TWIP = 96 / 1440;
20853
- var EMPTY_DECORATION_INDEX = Object.freeze({
20854
- workflow: Object.freeze([]),
20855
- comments: Object.freeze([]),
20856
- revisions: Object.freeze([]),
20857
- search: Object.freeze([]),
20858
- locked: Object.freeze([])
20859
- });
20860
-
20861
21376
  // src/runtime/markdown-sanitizer.ts
20862
21377
  function sanitizeMarkdown(raw) {
20863
21378
  let sanitized = false;
@@ -21697,7 +22212,17 @@ function TwSelectionToolStructure(props) {
21697
22212
  onSetCellVerticalAlign: props.onSetCellVerticalAlign
21698
22213
  }
21699
22214
  );
21700
- case "list":
22215
+ case "list": {
22216
+ const continueState = resolveListToolbarButtonState({
22217
+ canMutate: props.model.canMutate,
22218
+ callback: props.onContinueNumbering,
22219
+ availability: getListCommandAvailability2(props.activeListReadback, "continue-numbering")
22220
+ });
22221
+ const restartState = resolveListToolbarButtonState({
22222
+ canMutate: props.model.canMutate,
22223
+ callback: props.onRestartNumbering,
22224
+ availability: getListCommandAvailability2(props.activeListReadback, "restart-numbering")
22225
+ });
21701
22226
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
21702
22227
  "div",
21703
22228
  {
@@ -21709,7 +22234,8 @@ function TwSelectionToolStructure(props) {
21709
22234
  ToolbarButton3,
21710
22235
  {
21711
22236
  ariaLabel: "Continue numbering",
21712
- disabled: !props.model.canMutate || !props.onContinueNumbering,
22237
+ disabled: continueState.disabled,
22238
+ disabledReason: continueState.disabledReason,
21713
22239
  onClick: props.onContinueNumbering,
21714
22240
  children: "Continue"
21715
22241
  }
@@ -21718,7 +22244,8 @@ function TwSelectionToolStructure(props) {
21718
22244
  ToolbarButton3,
21719
22245
  {
21720
22246
  ariaLabel: "Restart numbering",
21721
- disabled: !props.model.canMutate || !props.onRestartNumbering,
22247
+ disabled: restartState.disabled,
22248
+ disabledReason: restartState.disabledReason,
21722
22249
  onClick: props.onRestartNumbering,
21723
22250
  children: "Restart"
21724
22251
  }
@@ -21726,15 +22253,31 @@ function TwSelectionToolStructure(props) {
21726
22253
  ]
21727
22254
  }
21728
22255
  );
22256
+ }
22257
+ }
22258
+ }
22259
+ function getListCommandAvailability2(readback, command) {
22260
+ return readback?.commandSupport.find((entry) => entry.command === command);
22261
+ }
22262
+ function resolveListToolbarButtonState(input) {
22263
+ if (!input.canMutate || !input.callback) {
22264
+ return { disabled: true };
22265
+ }
22266
+ if (input.availability?.enabled === false) {
22267
+ return { disabled: true, disabledReason: input.availability.reason };
21729
22268
  }
22269
+ return { disabled: false };
21730
22270
  }
21731
22271
  function ToolbarButton3(props) {
22272
+ const disabledReason = props.disabled && props.disabledReason ? props.disabledReason : void 0;
21732
22273
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
21733
22274
  "button",
21734
22275
  {
21735
22276
  type: "button",
21736
22277
  "aria-label": props.ariaLabel,
21737
22278
  disabled: props.disabled,
22279
+ "data-disabled-reason": disabledReason,
22280
+ title: disabledReason ? `Not available: ${disabledReason}` : void 0,
21738
22281
  onMouseDown: preserveEditorSelectionMouseDown,
21739
22282
  onClick: props.onClick,
21740
22283
  className: "inline-flex h-7 items-center rounded-md border border-border px-2 text-[length:var(--text-xs)] font-medium text-secondary transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-40",
@@ -22123,6 +22666,7 @@ function renderTool(props, tool, density) {
22123
22666
  onSetImageFrame: props.onSetImageFrame,
22124
22667
  onRestartNumbering: props.onRestartNumbering,
22125
22668
  onContinueNumbering: props.onContinueNumbering,
22669
+ activeListReadback: props.activeListReadback,
22126
22670
  onToggleRowHeader: props.onToggleRowHeader,
22127
22671
  onToggleRowCantSplit: props.onToggleRowCantSplit,
22128
22672
  onDistributeColumnsEvenly: props.onDistributeColumnsEvenly,
@@ -24084,6 +24628,7 @@ var EDITOR_ACTION_REGISTRY = [
24084
24628
  group: "clipboard",
24085
24629
  targetKinds: [
24086
24630
  "plain-text",
24631
+ "list-item",
24087
24632
  "table-cell",
24088
24633
  "image",
24089
24634
  "hyperlink",
@@ -24102,9 +24647,11 @@ var EDITOR_ACTION_REGISTRY = [
24102
24647
  group: "clipboard",
24103
24648
  targetKinds: [
24104
24649
  "plain-text",
24650
+ "list-item",
24105
24651
  "table-cell",
24106
24652
  "image",
24107
24653
  "hyperlink",
24654
+ "generated-field",
24108
24655
  "suggestion",
24109
24656
  "comment-anchor",
24110
24657
  "opaque-block",
@@ -24119,6 +24666,7 @@ var EDITOR_ACTION_REGISTRY = [
24119
24666
  group: "clipboard",
24120
24667
  targetKinds: [
24121
24668
  "plain-text",
24669
+ "list-item",
24122
24670
  "table-cell",
24123
24671
  "hyperlink",
24124
24672
  "suggestion",
@@ -24279,28 +24827,28 @@ var EDITOR_ACTION_REGISTRY = [
24279
24827
  id: "list-bulleted",
24280
24828
  label: "Bulleted list",
24281
24829
  group: "formatting",
24282
- targetKinds: ["plain-text", "table-cell"],
24830
+ targetKinds: ["list-item", "plain-text", "table-cell"],
24283
24831
  callback: "onToggleBulletedList"
24284
24832
  }),
24285
24833
  mk({
24286
24834
  id: "list-numbered",
24287
24835
  label: "Numbered list",
24288
24836
  group: "formatting",
24289
- targetKinds: ["plain-text", "table-cell"],
24837
+ targetKinds: ["list-item", "plain-text", "table-cell"],
24290
24838
  callback: "onToggleNumberedList"
24291
24839
  }),
24292
24840
  mk({
24293
24841
  id: "paragraph-outdent",
24294
24842
  label: "Decrease indent",
24295
24843
  group: "formatting",
24296
- targetKinds: ["plain-text", "table-cell"],
24844
+ targetKinds: ["list-item", "plain-text", "table-cell"],
24297
24845
  callback: "onOutdent"
24298
24846
  }),
24299
24847
  mk({
24300
24848
  id: "paragraph-indent",
24301
24849
  label: "Increase indent",
24302
24850
  group: "formatting",
24303
- targetKinds: ["plain-text", "table-cell"],
24851
+ targetKinds: ["list-item", "plain-text", "table-cell"],
24304
24852
  callback: "onIndent"
24305
24853
  }),
24306
24854
  mkArg({
@@ -24649,6 +25197,15 @@ var EDITOR_ACTION_REGISTRY = [
24649
25197
  targetKinds: ["hyperlink"],
24650
25198
  callback: "onOpenHyperlink"
24651
25199
  }),
25200
+ // -------- Generated fields --------
25201
+ mk({
25202
+ id: "field-refresh",
25203
+ label: "Refresh field",
25204
+ description: "Refresh generated field results through the runtime field updater.",
25205
+ group: "misc",
25206
+ targetKinds: ["generated-field"],
25207
+ callback: "onUpdateFields"
25208
+ }),
24652
25209
  // -------- Workflow scope --------
24653
25210
  mk({
24654
25211
  id: "scope-open-card",
@@ -25547,8 +26104,18 @@ function resolveTargetKind(target, options = {}) {
25547
26104
  const el = toElement(target);
25548
26105
  if (el) {
25549
26106
  const { root } = options;
26107
+ const insideNumberingMarker = hasAncestorAttributeValue(
26108
+ el,
26109
+ "data-numbering-marker",
26110
+ "true",
26111
+ root
26112
+ );
26113
+ const insideListItem = insideNumberingMarker || hasAncestorAttributeValue(el, "data-numbered", "true", root);
26114
+ const insideGeneratedField = hasAncestorAttributeValue(el, "data-generated-field", "true", root) || hasAncestorAttributeValue(el, "data-node-type", "field_ref_atom", root) || hasAncestorAttributeValue(el, "data-node-type", "field_ref", root);
26115
+ if (insideListItem) kinds.push("list-item");
26116
+ if (insideGeneratedField) kinds.push("generated-field");
25550
26117
  if (hasAncestorTag(el, "a", root)) kinds.push("hyperlink");
25551
- if (hasAncestorTag(el, "img", root)) {
26118
+ if (!insideNumberingMarker && hasAncestorTag(el, "img", root)) {
25552
26119
  kinds.push("image");
25553
26120
  }
25554
26121
  if (hasAncestorTag(el, "td", root) || hasAncestorTag(el, "th", root)) {
@@ -25584,7 +26151,9 @@ function resolveTargetKind(target, options = {}) {
25584
26151
  if (!kinds.includes("template-slot")) kinds.push("template-slot");
25585
26152
  }
25586
26153
  }
25587
- if (!kinds.includes("plain-text")) kinds.push("plain-text");
26154
+ if (!kinds.includes("generated-field") && !kinds.includes("plain-text")) {
26155
+ kinds.push("plain-text");
26156
+ }
25588
26157
  return kinds;
25589
26158
  }
25590
26159
 
@@ -25772,51 +26341,6 @@ function noopDismiss() {
25772
26341
  // src/ui-tailwind/chrome-overlay/tw-scope-card-layer.tsx
25773
26342
  var React20 = __toESM(require("react"), 1);
25774
26343
 
25775
- // src/runtime/telemetry/perf-probe.ts
25776
- function recordPerfSample(kind, durationMs = 0) {
25777
- const state = getEnabledState();
25778
- if (!state) {
25779
- return null;
25780
- }
25781
- const token = `${kind}-${state.nextToken ?? 0}`;
25782
- state.nextToken = (state.nextToken ?? 0) + 1;
25783
- const sample = {
25784
- token,
25785
- kind,
25786
- durationMs,
25787
- recordedAt: Date.now()
25788
- };
25789
- pushSample(state, sample);
25790
- return sample;
25791
- }
25792
- function incrementInvalidationCounter(counter, amount = 1) {
25793
- const state = getEnabledState();
25794
- if (!state) {
25795
- return 0;
25796
- }
25797
- state.invalidationCounts ??= {};
25798
- state.invalidationCounts[counter] = (state.invalidationCounts[counter] ?? 0) + amount;
25799
- return state.invalidationCounts[counter];
25800
- }
25801
- function getEnabledState() {
25802
- if (typeof window === "undefined") {
25803
- return null;
25804
- }
25805
- const state = window.__DOCX_REACT_PERF_PROBE__;
25806
- if (!state?.enabled) {
25807
- return null;
25808
- }
25809
- return state;
25810
- }
25811
- function pushSample(state, sample) {
25812
- state.samples ??= [];
25813
- state.samples.push(sample);
25814
- const maxSamples = state.maxSamples ?? 20;
25815
- if (state.samples.length > maxSamples) {
25816
- state.samples.splice(0, state.samples.length - maxSamples);
25817
- }
25818
- }
25819
-
25820
26344
  // src/ui-tailwind/chrome-overlay/chrome-overlay-projector.ts
25821
26345
  function projectRectToOverlay(rect2, space = { originLeftPx: 0, originTopPx: 0 }) {
25822
26346
  const t0 = typeof performance !== "undefined" ? performance.now() : 0;
@@ -27850,6 +28374,18 @@ function emuToPx(emu, pxPerTwip) {
27850
28374
  return emu / EMU_PER_PX * zoomFactor;
27851
28375
  }
27852
28376
 
28377
+ // src/ui-tailwind/editor-surface/media-src-policy.ts
28378
+ var SAFE_DATA_IMAGE_PREFIX_RE = /^data:image\/(?:png|jpe?g|gif|webp|bmp);base64,/iu;
28379
+ var MAX_NUMBERING_PICTURE_BULLET_DATA_URL_LENGTH = 1024 * 1024;
28380
+ function sanitizeNumberingPictureBulletSrc(src) {
28381
+ if (typeof src !== "string") return null;
28382
+ const trimmed = src.trim();
28383
+ if (trimmed.length === 0) return null;
28384
+ if (trimmed.length > MAX_NUMBERING_PICTURE_BULLET_DATA_URL_LENGTH) return null;
28385
+ if (!SAFE_DATA_IMAGE_PREFIX_RE.test(trimmed)) return null;
28386
+ return trimmed;
28387
+ }
28388
+
27853
28389
  // src/ui-tailwind/page-stack/tw-region-block-renderer.tsx
27854
28390
  var import_jsx_runtime49 = require("react/jsx-runtime");
27855
28391
  var EMU_PER_PX2 = 9525;
@@ -27964,6 +28500,10 @@ function renderSegment(seg, mediaPreviews, fallbackDisplay, tabInfoBySegment) {
27964
28500
  "span",
27965
28501
  {
27966
28502
  "data-node-type": "field_ref",
28503
+ "data-generated-field": "true",
28504
+ "data-field-family": seg.fieldFamily,
28505
+ "data-field-target": seg.fieldTarget,
28506
+ "data-field-refresh-status": seg.refreshStatus,
27967
28507
  style: { opacity: 0.6, fontSize: "0.85em" },
27968
28508
  children: seg.displayText ?? seg.label
27969
28509
  },
@@ -28013,6 +28553,9 @@ function RegionParagraph({
28013
28553
  const markerWidth = resolvedNumbering?.geometry?.markerLane?.width;
28014
28554
  const markerStart = resolvedNumbering?.geometry?.markerLane?.start;
28015
28555
  const markerJustification = resolvedNumbering?.geometry?.markerJustification;
28556
+ const pictureBulletSrc = sanitizeNumberingPictureBulletSrc(
28557
+ resolvedNumbering?.picBulletMediaId ? mediaPreviews[resolvedNumbering.picBulletMediaId]?.src : null
28558
+ );
28016
28559
  const prefixSpan = numberingPrefix != null ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
28017
28560
  "span",
28018
28561
  {
@@ -28023,7 +28566,9 @@ function RegionParagraph({
28023
28566
  ...!markerRunProperties ? ["text-tertiary", "font-[family-name:var(--font-legal-sans)]"] : []
28024
28567
  ].join(" "),
28025
28568
  contentEditable: false,
28026
- "data-numbering-prefix": numberingPrefix,
28569
+ "data-numbering-marker": "true",
28570
+ "data-numbering-prefix": pictureBulletSrc ? "" : numberingPrefix,
28571
+ ...pictureBulletSrc ? { "data-numbering-picture-bullet": resolvedNumbering?.pictureBulletPosture?.status ?? "media-rendered" } : {},
28027
28572
  ...typeof resolvedNumbering?.level === "number" ? { "data-numbering-level": String(resolvedNumbering.level) } : {},
28028
28573
  ...numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {},
28029
28574
  style: buildMarkerStyle(
@@ -28034,7 +28579,20 @@ function RegionParagraph({
28034
28579
  markerStart,
28035
28580
  markerJustification
28036
28581
  ),
28037
- children: numberingPrefix
28582
+ children: pictureBulletSrc ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
28583
+ "img",
28584
+ {
28585
+ src: pictureBulletSrc,
28586
+ alt: "",
28587
+ "aria-hidden": "true",
28588
+ style: {
28589
+ maxWidth: "100%",
28590
+ maxHeight: "100%",
28591
+ objectFit: "contain",
28592
+ display: "block"
28593
+ }
28594
+ }
28595
+ ) : numberingPrefix
28038
28596
  }
28039
28597
  ) : null;
28040
28598
  const attrs = {
@@ -33404,6 +33962,21 @@ function resolveRoleChromePreset(basePreset, role) {
33404
33962
  }
33405
33963
  return basePreset;
33406
33964
  }
33965
+ function resolveActiveListReadback(rows, activeListContext, selection) {
33966
+ if (!activeListContext) {
33967
+ return null;
33968
+ }
33969
+ const selectionPoint = selection.activeRange.kind === "range" ? selection.head : selection.activeRange.kind === "node" ? selection.activeRange.at : selection.activeRange.lastKnownRange.from;
33970
+ const matchingSelectionRow = rows.find(
33971
+ (row) => row.numberingInstanceId === activeListContext.numberingInstanceId && row.level === activeListContext.level && selectionPoint >= row.authoredTextRange.from && selectionPoint <= row.authoredTextRange.to
33972
+ );
33973
+ if (matchingSelectionRow) {
33974
+ return matchingSelectionRow;
33975
+ }
33976
+ return rows.find(
33977
+ (row) => row.numberingInstanceId === activeListContext.numberingInstanceId && row.level === activeListContext.level
33978
+ ) ?? null;
33979
+ }
33407
33980
  function TwReviewWorkspace(inputProps) {
33408
33981
  const props = {
33409
33982
  ...inputProps,
@@ -33518,6 +34091,14 @@ function TwReviewWorkspace(inputProps) {
33518
34091
  () => uiApi?.scope.list().length,
33519
34092
  [uiApi, renderFrameRevision]
33520
34093
  );
34094
+ const activeListReadback = (0, import_react51.useMemo)(
34095
+ () => resolveActiveListReadback(
34096
+ uiApi?.lists.list() ?? [],
34097
+ props.activeListContext,
34098
+ viewState.selection
34099
+ ),
34100
+ [uiApi, props.activeListContext, viewState.selection, renderFrameRevision]
34101
+ );
33521
34102
  const headings = props.documentNavigation?.headings ?? [];
33522
34103
  const headerVariant = snapshot.pageLayout?.headerVariants[0]?.variant ?? "default";
33523
34104
  const footerVariant = snapshot.pageLayout?.footerVariants[0]?.variant ?? "default";
@@ -33786,6 +34367,7 @@ function TwReviewWorkspace(inputProps) {
33786
34367
  zoomLevel: props.zoomLevel,
33787
34368
  formattingState: props.formattingState,
33788
34369
  activeListContext: props.activeListContext,
34370
+ activeListReadback,
33789
34371
  styleCatalog: props.styleCatalog,
33790
34372
  showTrackedChanges: trackedChangesAuthoringEnabled,
33791
34373
  showSidebarToggle: responsiveChrome.showSidebarToggle,
@@ -33997,6 +34579,7 @@ function TwReviewWorkspace(inputProps) {
33997
34579
  onSetImageFrame: props.onSetImageFrame,
33998
34580
  onRestartNumbering: props.onRestartNumbering,
33999
34581
  onContinueNumbering: props.onContinueNumbering,
34582
+ activeListReadback,
34000
34583
  onToggleRowHeader: props.onToggleRowHeader,
34001
34584
  onToggleRowCantSplit: props.onToggleRowCantSplit,
34002
34585
  onDistributeColumnsEvenly: props.onDistributeColumnsEvenly,