@beyondwork/docx-react-component 1.0.132 → 1.0.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/api/public-types.cjs +161 -68
  2. package/dist/api/public-types.d.cts +1 -1
  3. package/dist/api/public-types.d.ts +1 -1
  4. package/dist/api/public-types.js +3 -3
  5. package/dist/api/v3.cjs +9878 -7387
  6. package/dist/api/v3.d.cts +2 -2
  7. package/dist/api/v3.d.ts +2 -2
  8. package/dist/api/v3.js +10 -10
  9. package/dist/{chunk-QUTVR72L.js → chunk-3YR47WTD.js} +296 -587
  10. package/dist/{chunk-RYMMKOFI.js → chunk-5KTJKTNE.js} +32 -0
  11. package/dist/{chunk-UP2KDOYE.js → chunk-74R5B2EZ.js} +6 -2
  12. package/dist/{chunk-6736GA6J.js → chunk-7Y6JCIK3.js} +1 -1
  13. package/dist/{chunk-43JAPM2F.js → chunk-EBSI6VQX.js} +546 -144
  14. package/dist/{chunk-JVTDBX67.js → chunk-EFEW7BTT.js} +2 -2
  15. package/dist/{chunk-YUHNDEV5.js → chunk-ESEEWELA.js} +3534 -1870
  16. package/dist/{chunk-XYTWOJII.js → chunk-IJD6D7HU.js} +745 -103
  17. package/dist/{chunk-UFPBYJMA.js → chunk-INLRCC4N.js} +2 -2
  18. package/dist/{chunk-N5FTU4HZ.js → chunk-MQ5GAJ54.js} +68 -39
  19. package/dist/{chunk-W2I47J2Q.js → chunk-NJFKPDNG.js} +216 -2
  20. package/dist/{chunk-LPLJZJT2.js → chunk-O4EDZR44.js} +131 -70
  21. package/dist/{chunk-4HGFJ6Z2.js → chunk-PZIEOEJZ.js} +1 -1
  22. package/dist/{chunk-C5LXKR54.js → chunk-QTRJLKR2.js} +1 -1
  23. package/dist/{chunk-SZ6BJA4Q.js → chunk-REFHJ2FN.js} +3 -3
  24. package/dist/{chunk-ZDYGRO2Z.js → chunk-RP76USJE.js} +1 -1
  25. package/dist/{chunk-RBWJHRNP.js → chunk-T66OS7MN.js} +8 -3
  26. package/dist/{chunk-ALWXYGXP.js → chunk-V2JF42SI.js} +2 -2
  27. package/dist/{chunk-CDEZGLQ3.js → chunk-VA24T4EB.js} +1 -1
  28. package/dist/{chunk-6TLZ6CMP.js → chunk-WDDFU2N2.js} +2 -2
  29. package/dist/{chunk-U3UMKA7B.js → chunk-XBQFDBXE.js} +1 -1
  30. package/dist/core/commands/formatting-commands.d.cts +1 -1
  31. package/dist/core/commands/formatting-commands.d.ts +1 -1
  32. package/dist/core/commands/image-commands.cjs +32 -0
  33. package/dist/core/commands/image-commands.d.cts +1 -1
  34. package/dist/core/commands/image-commands.d.ts +1 -1
  35. package/dist/core/commands/image-commands.js +5 -5
  36. package/dist/core/commands/section-layout-commands.d.cts +1 -1
  37. package/dist/core/commands/section-layout-commands.d.ts +1 -1
  38. package/dist/core/commands/style-commands.d.cts +1 -1
  39. package/dist/core/commands/style-commands.d.ts +1 -1
  40. package/dist/core/commands/table-structure-commands.cjs +32 -0
  41. package/dist/core/commands/table-structure-commands.d.cts +1 -1
  42. package/dist/core/commands/table-structure-commands.d.ts +1 -1
  43. package/dist/core/commands/table-structure-commands.js +4 -4
  44. package/dist/core/commands/text-commands.cjs +99 -38
  45. package/dist/core/commands/text-commands.d.cts +12 -1
  46. package/dist/core/commands/text-commands.d.ts +12 -1
  47. package/dist/core/commands/text-commands.js +5 -5
  48. package/dist/core/selection/mapping.d.cts +1 -1
  49. package/dist/core/selection/mapping.d.ts +1 -1
  50. package/dist/core/state/editor-state.d.cts +1 -1
  51. package/dist/core/state/editor-state.d.ts +1 -1
  52. package/dist/index.cjs +5365 -2298
  53. package/dist/index.d.cts +4 -4
  54. package/dist/index.d.ts +4 -4
  55. package/dist/index.js +388 -63
  56. package/dist/io/docx-session.cjs +7 -2
  57. package/dist/io/docx-session.d.cts +3 -3
  58. package/dist/io/docx-session.d.ts +3 -3
  59. package/dist/io/docx-session.js +4 -4
  60. package/dist/legal.js +3 -3
  61. package/dist/{loader-MAa8VpzW.d.cts → loader-CK3lZy4h.d.cts} +2 -2
  62. package/dist/{loader-CfpeEPAa.d.ts → loader-CQXplstv.d.ts} +2 -2
  63. package/dist/{public-types-KBS6JnOs.d.cts → public-types-BR1SYK2F.d.cts} +783 -189
  64. package/dist/{public-types-Cjs8glST.d.ts → public-types-DXNZVKrS.d.ts} +783 -189
  65. package/dist/public-types.cjs +161 -68
  66. package/dist/public-types.d.cts +1 -1
  67. package/dist/public-types.d.ts +1 -1
  68. package/dist/public-types.js +3 -3
  69. package/dist/runtime/collab.d.cts +2 -2
  70. package/dist/runtime/collab.d.ts +2 -2
  71. package/dist/runtime/document-runtime.cjs +1597 -444
  72. package/dist/runtime/document-runtime.d.cts +1 -1
  73. package/dist/runtime/document-runtime.d.ts +1 -1
  74. package/dist/runtime/document-runtime.js +14 -14
  75. package/dist/{session-CkoH8FoY.d.ts → session-C9UjrhJF.d.ts} +2 -2
  76. package/dist/{session-wwe0Gib-.d.cts → session-CSbwkgII.d.cts} +2 -2
  77. package/dist/session.cjs +7 -2
  78. package/dist/session.d.cts +4 -4
  79. package/dist/session.d.ts +4 -4
  80. package/dist/session.js +5 -5
  81. package/dist/tailwind.cjs +451 -650
  82. package/dist/tailwind.d.cts +1 -1
  83. package/dist/tailwind.d.ts +1 -1
  84. package/dist/tailwind.js +7 -7
  85. package/dist/{types-B3SGRW0w.d.cts → types-CZtAueri.d.cts} +1 -1
  86. package/dist/{types-CH7NWqVL.d.ts → types-RzkCXDNV.d.ts} +1 -1
  87. package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
  88. package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
  89. package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
  90. package/dist/ui-tailwind.cjs +451 -650
  91. package/dist/ui-tailwind.d.cts +3 -2
  92. package/dist/ui-tailwind.d.ts +3 -2
  93. package/dist/ui-tailwind.js +7 -7
  94. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolvePageOverlayRectsFromGeometry
3
- } from "./chunk-UP2KDOYE.js";
3
+ } from "./chunk-74R5B2EZ.js";
4
4
  import {
5
5
  buildPageAnchorAttributes,
6
6
  buildPageAnchorSelector,
@@ -8,7 +8,7 @@ import {
8
8
  resolveChromePreset,
9
9
  resolveChromePresetOptions,
10
10
  resolveChromeVisibilityForPreset
11
- } from "./chunk-W2I47J2Q.js";
11
+ } from "./chunk-NJFKPDNG.js";
12
12
  import {
13
13
  DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP,
14
14
  DEFAULT_PX_PER_TWIP,
@@ -20,19 +20,19 @@ import {
20
20
  incrementInvalidationCounter,
21
21
  recordPerfSample,
22
22
  sanitizeMarkdown
23
- } from "./chunk-LPLJZJT2.js";
23
+ } from "./chunk-O4EDZR44.js";
24
24
  import {
25
25
  createCanvasBackend
26
26
  } from "./chunk-OVLZQ6FZ.js";
27
27
  import {
28
28
  storyTargetKey
29
- } from "./chunk-U3UMKA7B.js";
29
+ } from "./chunk-XBQFDBXE.js";
30
30
  import {
31
31
  EMU_PER_INCH,
32
32
  EMU_PER_PX,
33
33
  ROTATION_UNITS_PER_DEGREE,
34
34
  TWIPS_PER_PX
35
- } from "./chunk-RYMMKOFI.js";
35
+ } from "./chunk-5KTJKTNE.js";
36
36
  import {
37
37
  createPublicNodeAnchor,
38
38
  createPublicRangeAnchor
@@ -1870,6 +1870,43 @@ function TwToolbar(props) {
1870
1870
  const showPostFormattingDivider = showListActionsInRow || showSpacingActionsInRow || showInsertActionsInRow || showUpdateActionsInRow || showCompactOverflow;
1871
1871
  const zoomLabel = typeof zoomLevel === "number" ? `${zoomLevel}%` : zoomLevel === "pageWidth" ? "Fit width" : "Fit page";
1872
1872
  const showZoomSteppers = responsiveTier === "wide";
1873
+ const bulletedListState = resolveListCommandControl({
1874
+ canEdit,
1875
+ editDisabledReason,
1876
+ callback: props.onToggleBulletedList,
1877
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-bulleted")
1878
+ });
1879
+ const numberedListState = resolveListCommandControl({
1880
+ canEdit,
1881
+ editDisabledReason,
1882
+ callback: props.onToggleNumberedList,
1883
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-numbered")
1884
+ });
1885
+ const outdentState = resolveListCommandControl({
1886
+ canEdit,
1887
+ editDisabledReason,
1888
+ callback: props.onOutdent,
1889
+ availability: getListCommandAvailability(props.activeListReadback, "outdent")
1890
+ });
1891
+ const indentState = resolveListCommandControl({
1892
+ canEdit,
1893
+ editDisabledReason,
1894
+ callback: props.onIndent,
1895
+ availability: getListCommandAvailability(props.activeListReadback, "indent")
1896
+ });
1897
+ const restartNumberingState = resolveListCommandControl({
1898
+ canEdit,
1899
+ editDisabledReason,
1900
+ callback: props.onRestartNumbering,
1901
+ availability: getListCommandAvailability(props.activeListReadback, "restart-numbering")
1902
+ });
1903
+ const continueNumberingState = resolveListCommandControl({
1904
+ canEdit,
1905
+ editDisabledReason,
1906
+ callback: props.onContinueNumbering,
1907
+ availability: getListCommandAvailability(props.activeListReadback, "continue-numbering")
1908
+ });
1909
+ const activeListKind = props.activeListReadback?.listKind;
1873
1910
  return /* @__PURE__ */ jsxs6(
1874
1911
  "header",
1875
1912
  {
@@ -1885,7 +1922,7 @@ function TwToolbar(props) {
1885
1922
  },
1886
1923
  className: [
1887
1924
  "shrink-0 rounded-[var(--radius-sm)] border border-[var(--color-border-subtle)]",
1888
- "bg-[var(--color-bg-chrome)] px-2.5",
1925
+ "bg-[var(--color-bg-chrome)] px-2.5 shadow-[var(--shadow-soft)]",
1889
1926
  isCompact ? "flex min-h-10 flex-wrap items-center gap-1.5 py-1.5" : "flex items-center gap-1"
1890
1927
  ].join(" "),
1891
1928
  children: [
@@ -2054,9 +2091,9 @@ function TwToolbar(props) {
2054
2091
  {
2055
2092
  icon: List,
2056
2093
  label: "Bulleted list",
2057
- active: Boolean(props.activeListContext && !props.activeListContext.isOrdered),
2058
- disabled: !canEdit || !props.onToggleBulletedList,
2059
- disabledReason: editDisabledReason,
2094
+ active: activeListKind ? activeListKind === "bulleted" : Boolean(props.activeListContext && !props.activeListContext.isOrdered),
2095
+ disabled: bulletedListState.disabled,
2096
+ disabledReason: bulletedListState.disabledReason,
2060
2097
  onClick: props.onToggleBulletedList
2061
2098
  }
2062
2099
  ),
@@ -2065,9 +2102,9 @@ function TwToolbar(props) {
2065
2102
  {
2066
2103
  icon: Rows32,
2067
2104
  label: "Numbered list",
2068
- active: Boolean(props.activeListContext?.isOrdered),
2069
- disabled: !canEdit || !props.onToggleNumberedList,
2070
- disabledReason: editDisabledReason,
2105
+ active: activeListKind ? activeListKind === "numbered" : Boolean(props.activeListContext?.isOrdered),
2106
+ disabled: numberedListState.disabled,
2107
+ disabledReason: numberedListState.disabledReason,
2071
2108
  onClick: props.onToggleNumberedList
2072
2109
  }
2073
2110
  )
@@ -2078,8 +2115,8 @@ function TwToolbar(props) {
2078
2115
  {
2079
2116
  icon: Outdent,
2080
2117
  label: "Outdent",
2081
- disabled: !canEdit || !props.onOutdent,
2082
- disabledReason: editDisabledReason,
2118
+ disabled: outdentState.disabled,
2119
+ disabledReason: outdentState.disabledReason,
2083
2120
  onClick: props.onOutdent
2084
2121
  }
2085
2122
  ),
@@ -2088,8 +2125,8 @@ function TwToolbar(props) {
2088
2125
  {
2089
2126
  icon: Indent,
2090
2127
  label: "Indent",
2091
- disabled: !canEdit || !props.onIndent,
2092
- disabledReason: editDisabledReason,
2128
+ disabled: indentState.disabled,
2129
+ disabledReason: indentState.disabledReason,
2093
2130
  onClick: props.onIndent
2094
2131
  }
2095
2132
  )
@@ -2099,8 +2136,8 @@ function TwToolbar(props) {
2099
2136
  ToolbarTextButton,
2100
2137
  {
2101
2138
  ariaLabel: "Restart numbering",
2102
- disabled: !canEdit || !props.onRestartNumbering,
2103
- disabledReason: editDisabledReason,
2139
+ disabled: restartNumberingState.disabled,
2140
+ disabledReason: restartNumberingState.disabledReason,
2104
2141
  onClick: props.onRestartNumbering,
2105
2142
  children: "Restart"
2106
2143
  }
@@ -2109,8 +2146,8 @@ function TwToolbar(props) {
2109
2146
  ToolbarTextButton,
2110
2147
  {
2111
2148
  ariaLabel: "Continue numbering",
2112
- disabled: !canEdit || !props.onContinueNumbering,
2113
- disabledReason: editDisabledReason,
2149
+ disabled: continueNumberingState.disabled,
2150
+ disabledReason: continueNumberingState.disabledReason,
2114
2151
  onClick: props.onContinueNumbering,
2115
2152
  children: "Continue"
2116
2153
  }
@@ -2154,6 +2191,7 @@ function TwToolbar(props) {
2154
2191
  ToolbarCompactOverflow,
2155
2192
  {
2156
2193
  activeListContext: props.activeListContext,
2194
+ activeListReadback: props.activeListReadback,
2157
2195
  canEdit,
2158
2196
  canInsertStructural,
2159
2197
  editDisabledReason,
@@ -2687,8 +2725,59 @@ function ToolbarFontSizeSelect(props) {
2687
2725
  }
2688
2726
  );
2689
2727
  }
2728
+ function getListCommandAvailability(readback, command) {
2729
+ return readback?.commandSupport.find((entry) => entry.command === command);
2730
+ }
2731
+ function resolveListCommandControl(input) {
2732
+ if (!input.canEdit) {
2733
+ return { disabled: true, disabledReason: input.editDisabledReason };
2734
+ }
2735
+ if (!input.callback) {
2736
+ return { disabled: true };
2737
+ }
2738
+ if (input.availability?.enabled === false) {
2739
+ return { disabled: true, disabledReason: input.availability.reason };
2740
+ }
2741
+ return { disabled: false };
2742
+ }
2690
2743
  function ToolbarCompactOverflow(props) {
2691
2744
  const [open, setOpen] = React4.useState(false);
2745
+ const bulletedListState = resolveListCommandControl({
2746
+ canEdit: props.canEdit,
2747
+ editDisabledReason: props.editDisabledReason,
2748
+ callback: props.onToggleBulletedList,
2749
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-bulleted")
2750
+ });
2751
+ const numberedListState = resolveListCommandControl({
2752
+ canEdit: props.canEdit,
2753
+ editDisabledReason: props.editDisabledReason,
2754
+ callback: props.onToggleNumberedList,
2755
+ availability: getListCommandAvailability(props.activeListReadback, "toggle-numbered")
2756
+ });
2757
+ const outdentState = resolveListCommandControl({
2758
+ canEdit: props.canEdit,
2759
+ editDisabledReason: props.editDisabledReason,
2760
+ callback: props.onOutdent,
2761
+ availability: getListCommandAvailability(props.activeListReadback, "outdent")
2762
+ });
2763
+ const indentState = resolveListCommandControl({
2764
+ canEdit: props.canEdit,
2765
+ editDisabledReason: props.editDisabledReason,
2766
+ callback: props.onIndent,
2767
+ availability: getListCommandAvailability(props.activeListReadback, "indent")
2768
+ });
2769
+ const restartNumberingState = resolveListCommandControl({
2770
+ canEdit: props.canEdit,
2771
+ editDisabledReason: props.editDisabledReason,
2772
+ callback: props.onRestartNumbering,
2773
+ availability: getListCommandAvailability(props.activeListReadback, "restart-numbering")
2774
+ });
2775
+ const continueNumberingState = resolveListCommandControl({
2776
+ canEdit: props.canEdit,
2777
+ editDisabledReason: props.editDisabledReason,
2778
+ callback: props.onContinueNumbering,
2779
+ availability: getListCommandAvailability(props.activeListReadback, "continue-numbering")
2780
+ });
2692
2781
  const overflowGroups = [
2693
2782
  props.showStyleSelectors || props.showInlineFormatting || props.showTextColors ? "Format" : null,
2694
2783
  props.showListActions || props.showParagraphActions || props.showParagraphAlignment || props.showListContinuation ? "Paragraph" : null,
@@ -2905,8 +2994,8 @@ function ToolbarCompactOverflow(props) {
2905
2994
  ToolbarMenuButton,
2906
2995
  {
2907
2996
  ariaLabel: "Bulleted list",
2908
- disabled: !props.canEdit || !props.onToggleBulletedList,
2909
- disabledReason: props.editDisabledReason,
2997
+ disabled: bulletedListState.disabled,
2998
+ disabledReason: bulletedListState.disabledReason,
2910
2999
  icon: /* @__PURE__ */ jsx6(List, { className: "h-3.5 w-3.5" }),
2911
3000
  label: "Bulleted list",
2912
3001
  onClick: () => {
@@ -2919,8 +3008,8 @@ function ToolbarCompactOverflow(props) {
2919
3008
  ToolbarMenuButton,
2920
3009
  {
2921
3010
  ariaLabel: "Numbered list",
2922
- disabled: !props.canEdit || !props.onToggleNumberedList,
2923
- disabledReason: props.editDisabledReason,
3011
+ disabled: numberedListState.disabled,
3012
+ disabledReason: numberedListState.disabledReason,
2924
3013
  icon: /* @__PURE__ */ jsx6(Rows32, { className: "h-3.5 w-3.5" }),
2925
3014
  label: "Numbered list",
2926
3015
  onClick: () => {
@@ -2949,8 +3038,8 @@ function ToolbarCompactOverflow(props) {
2949
3038
  ToolbarMenuButton,
2950
3039
  {
2951
3040
  ariaLabel: "Outdent",
2952
- disabled: !props.canEdit || !props.onOutdent,
2953
- disabledReason: props.editDisabledReason,
3041
+ disabled: outdentState.disabled,
3042
+ disabledReason: outdentState.disabledReason,
2954
3043
  icon: /* @__PURE__ */ jsx6(Outdent, { className: "h-3.5 w-3.5" }),
2955
3044
  label: "Outdent",
2956
3045
  onClick: () => {
@@ -2963,8 +3052,8 @@ function ToolbarCompactOverflow(props) {
2963
3052
  ToolbarMenuButton,
2964
3053
  {
2965
3054
  ariaLabel: "Indent",
2966
- disabled: !props.canEdit || !props.onIndent,
2967
- disabledReason: props.editDisabledReason,
3055
+ disabled: indentState.disabled,
3056
+ disabledReason: indentState.disabledReason,
2968
3057
  icon: /* @__PURE__ */ jsx6(Indent, { className: "h-3.5 w-3.5" }),
2969
3058
  label: "Indent",
2970
3059
  onClick: () => {
@@ -2979,8 +3068,8 @@ function ToolbarCompactOverflow(props) {
2979
3068
  ToolbarMenuButton,
2980
3069
  {
2981
3070
  ariaLabel: "Restart numbering",
2982
- disabled: !props.canEdit || !props.onRestartNumbering,
2983
- disabledReason: props.editDisabledReason,
3071
+ disabled: restartNumberingState.disabled,
3072
+ disabledReason: restartNumberingState.disabledReason,
2984
3073
  icon: /* @__PURE__ */ jsx6(Rows32, { className: "h-3.5 w-3.5" }),
2985
3074
  label: "Restart numbering",
2986
3075
  onClick: () => {
@@ -2993,8 +3082,8 @@ function ToolbarCompactOverflow(props) {
2993
3082
  ToolbarMenuButton,
2994
3083
  {
2995
3084
  ariaLabel: "Continue numbering",
2996
- disabled: !props.canEdit || !props.onContinueNumbering,
2997
- disabledReason: props.editDisabledReason,
3085
+ disabled: continueNumberingState.disabled,
3086
+ disabledReason: continueNumberingState.disabledReason,
2998
3087
  icon: /* @__PURE__ */ jsx6(Rows32, { className: "h-3.5 w-3.5" }),
2999
3088
  label: "Continue numbering",
3000
3089
  onClick: () => {
@@ -7904,294 +7993,6 @@ function resolveSkeletalPageOverlayRectsFromLayout(facet) {
7904
7993
  }
7905
7994
  return rects;
7906
7995
  }
7907
- function pageOverlayLastBottom(rects) {
7908
- let bottom = 0;
7909
- for (const rect of rects) {
7910
- if (rect.bottomPx > bottom) bottom = rect.bottomPx;
7911
- }
7912
- return bottom;
7913
- }
7914
- function extendFinalPageOverlayRectToFlowHeight(rects, flowHeightPx) {
7915
- if (rects.length === 0 || !Number.isFinite(flowHeightPx)) return rects;
7916
- const last = rects[rects.length - 1];
7917
- if (flowHeightPx <= last.bottomPx + 1) return rects;
7918
- return [
7919
- ...rects.slice(0, -1),
7920
- {
7921
- ...last,
7922
- bottomPx: flowHeightPx,
7923
- heightPx: Math.max(0, flowHeightPx - last.topPx)
7924
- }
7925
- ];
7926
- }
7927
- function extendPageOverlayRectsAcrossTableBoundaryGaps(rects, tableBoundaryIndices) {
7928
- if (rects.length === 0 || tableBoundaryIndices.length === 0) return rects;
7929
- const tableBoundaries = new Set(tableBoundaryIndices);
7930
- const byPageIndex = /* @__PURE__ */ new Map();
7931
- for (const rect of rects) {
7932
- byPageIndex.set(rect.pageIndex, rect);
7933
- }
7934
- let changed = false;
7935
- const bridged = rects.map((rect) => {
7936
- if (!tableBoundaries.has(rect.pageIndex)) return rect;
7937
- const next = byPageIndex.get(rect.pageIndex + 1);
7938
- if (!next || next.topPx <= rect.bottomPx + 1) return rect;
7939
- changed = true;
7940
- return {
7941
- ...rect,
7942
- bottomPx: next.topPx,
7943
- heightPx: Math.max(0, next.topPx - rect.topPx)
7944
- };
7945
- });
7946
- return changed ? bridged : rects;
7947
- }
7948
- function mergePageOverlayRectsByPageIndex(baseRects, flowRects) {
7949
- if (baseRects.length === 0 || flowRects.length === 0) return baseRects;
7950
- const flowByIndex = /* @__PURE__ */ new Map();
7951
- for (const rect of flowRects) {
7952
- flowByIndex.set(rect.pageIndex, rect);
7953
- }
7954
- return baseRects.map((rect) => flowByIndex.get(rect.pageIndex) ?? rect);
7955
- }
7956
- function normalizeVisiblePageIndexRange(range, pageCount) {
7957
- if (!range || pageCount <= 0) return null;
7958
- const start = Math.max(0, Math.min(range.start, pageCount));
7959
- const end = Math.max(start, Math.min(range.end, pageCount));
7960
- if (start >= end) return null;
7961
- return { start, end };
7962
- }
7963
- function collectBoundaryIndicesForVisibleRange(range, pageCount) {
7964
- if (pageCount <= 1) return [];
7965
- const startBoundaryIndex = Math.max(0, range.start - 1);
7966
- const endBoundaryIndex = Math.min(pageCount - 2, range.end - 1);
7967
- if (startBoundaryIndex > endBoundaryIndex) return [];
7968
- const indices = [];
7969
- for (let index = startBoundaryIndex; index <= endBoundaryIndex; index += 1) {
7970
- indices.push(index);
7971
- }
7972
- return indices;
7973
- }
7974
- function parsePageBoundaryIndex(prevPageId) {
7975
- const match = /^page-(\d+)$/.exec(prevPageId);
7976
- if (!match) return void 0;
7977
- return Number.parseInt(match[1] ?? "", 10);
7978
- }
7979
- function collectTableEmbeddedBoundaryIndices(queryRoot) {
7980
- if (!queryRoot) return [];
7981
- const indices = [];
7982
- const widgets = Array.from(
7983
- queryRoot.querySelectorAll("[data-page-frame-end]")
7984
- );
7985
- for (const widget of widgets) {
7986
- const prevPageId = widget.getAttribute("data-page-frame-end");
7987
- if (!prevPageId) continue;
7988
- const boundaryIndex = parsePageBoundaryIndex(prevPageId);
7989
- if (boundaryIndex === void 0) continue;
7990
- if (widget.closest("[data-pm-table-root='true'], table")) {
7991
- indices.push(boundaryIndex);
7992
- }
7993
- }
7994
- return indices;
7995
- }
7996
- function containsTableBoundaryRisk(queryRoot) {
7997
- if (!queryRoot) return false;
7998
- if (queryRoot.getElementsByTagName("table").length > 0) return true;
7999
- const descendants = queryRoot.getElementsByTagName("*");
8000
- for (let i = 0; i < descendants.length; i += 1) {
8001
- const element = descendants[i];
8002
- if (element.getAttribute("data-pm-table-root") === "true") {
8003
- return true;
8004
- }
8005
- }
8006
- return false;
8007
- }
8008
- function resolvePageOverlayRects(input, legacyPageCount) {
8009
- let widgets;
8010
- let pageCount;
8011
- let scrollHeight;
8012
- if (Array.isArray(input)) {
8013
- const [scrollRoot, count] = input;
8014
- if (!scrollRoot || count <= 0) return [];
8015
- widgets = measureWidgetsViaOffsetChain(scrollRoot);
8016
- pageCount = count;
8017
- scrollHeight = scrollRoot.clientHeight;
8018
- } else if (input !== null && typeof input === "object" && "widgets" in input) {
8019
- widgets = input.widgets;
8020
- pageCount = input.pageCount;
8021
- scrollHeight = input.scrollHeight;
8022
- } else if (input && legacyPageCount !== void 0) {
8023
- const scrollRoot = input;
8024
- if (legacyPageCount <= 0) return [];
8025
- widgets = measureWidgetsViaOffsetChain(scrollRoot);
8026
- pageCount = legacyPageCount;
8027
- scrollHeight = scrollRoot.clientHeight;
8028
- } else {
8029
- return [];
8030
- }
8031
- if (pageCount <= 0) return [];
8032
- const boundaries = [...widgets].sort((a, b) => a.topPx - b.topPx);
8033
- const normalizedVisiblePageIndexRange = Array.isArray(input) ? null : normalizeVisiblePageIndexRange(input.visiblePageIndexRange, pageCount);
8034
- const boundaryByIndex = /* @__PURE__ */ new Map();
8035
- boundaries.forEach((boundary, index) => {
8036
- const boundaryIndex = boundary.boundaryIndex ?? parsePageBoundaryIndex(boundary.prevPageId) ?? index;
8037
- boundaryByIndex.set(boundaryIndex, boundary);
8038
- });
8039
- const pageStart = normalizedVisiblePageIndexRange?.start ?? 0;
8040
- const pageEnd = normalizedVisiblePageIndexRange?.end ?? pageCount;
8041
- const rects = [];
8042
- for (let pageIndex = pageStart; pageIndex < pageEnd; pageIndex += 1) {
8043
- const boundaryBefore = pageIndex === 0 ? null : boundaryByIndex.get(pageIndex - 1) ?? null;
8044
- const boundaryAfter = pageIndex === pageCount - 1 ? null : boundaryByIndex.get(pageIndex) ?? null;
8045
- let pageId = null;
8046
- if (boundaryBefore) pageId = boundaryBefore.nextPageId;
8047
- else if (boundaryAfter) pageId = boundaryAfter.prevPageId;
8048
- if (!pageId) pageId = `page-${pageIndex}`;
8049
- const topPx = boundaryBefore ? boundaryBefore.bottomPx : 0;
8050
- const bottomPx = boundaryAfter ? boundaryAfter.topPx : scrollHeight;
8051
- if (bottomPx <= topPx) continue;
8052
- rects.push({
8053
- pageId,
8054
- pageIndex,
8055
- topPx,
8056
- bottomPx,
8057
- heightPx: bottomPx - topPx
8058
- });
8059
- }
8060
- return rects;
8061
- }
8062
- function measureWidgetsViaBoundingRect(queryRoot, originElement, options) {
8063
- if (!queryRoot || !originElement) return [];
8064
- const originRect = originElement.getBoundingClientRect();
8065
- const normalizedVisiblePageIndexRange = normalizeVisiblePageIndexRange(
8066
- options?.visiblePageIndexRange,
8067
- options?.pageCount ?? 0
8068
- );
8069
- const queryOne = typeof queryRoot.querySelector === "function" ? queryRoot.querySelector.bind(queryRoot) : null;
8070
- const widgets = normalizedVisiblePageIndexRange && queryOne && options?.pageCount ? collectBoundaryIndicesForVisibleRange(
8071
- normalizedVisiblePageIndexRange,
8072
- options.pageCount
8073
- ).map(
8074
- (boundaryIndex) => queryOne(`[data-page-frame-end="page-${boundaryIndex}"]`)
8075
- ).filter((widget) => widget !== null) : Array.from(
8076
- queryRoot.querySelectorAll("[data-page-frame-end]")
8077
- );
8078
- const out = [];
8079
- for (const widget of widgets) {
8080
- const prevPageId = widget.getAttribute("data-page-frame-end");
8081
- const nextPageId = widget.getAttribute("data-page-frame-start");
8082
- if (!prevPageId || !nextPageId) continue;
8083
- const rect = widget.getBoundingClientRect();
8084
- out.push({
8085
- prevPageId,
8086
- nextPageId,
8087
- boundaryIndex: parsePageBoundaryIndex(prevPageId),
8088
- topPx: rect.top - originRect.top,
8089
- bottomPx: rect.bottom - originRect.top
8090
- });
8091
- }
8092
- return out;
8093
- }
8094
- function measureWidgetsViaOffsetChain(scrollRoot, options) {
8095
- const normalizedVisiblePageIndexRange = normalizeVisiblePageIndexRange(
8096
- options?.visiblePageIndexRange,
8097
- options?.pageCount ?? 0
8098
- );
8099
- const queryOne = typeof scrollRoot.querySelector === "function" ? scrollRoot.querySelector.bind(scrollRoot) : null;
8100
- const widgets = normalizedVisiblePageIndexRange && queryOne && options?.pageCount ? collectBoundaryIndicesForVisibleRange(
8101
- normalizedVisiblePageIndexRange,
8102
- options.pageCount
8103
- ).map(
8104
- (boundaryIndex) => queryOne(`[data-page-frame-end="page-${boundaryIndex}"]`)
8105
- ).filter((widget) => widget !== null) : Array.from(
8106
- scrollRoot.querySelectorAll("[data-page-frame-end]")
8107
- );
8108
- const out = [];
8109
- for (const widget of widgets) {
8110
- const prevPageId = widget.getAttribute("data-page-frame-end");
8111
- const nextPageId = widget.getAttribute("data-page-frame-start");
8112
- if (!prevPageId || !nextPageId) continue;
8113
- const topPx = resolveOffsetTop(widget, scrollRoot);
8114
- const bottomPx = topPx + resolveOffsetHeight(widget);
8115
- out.push({
8116
- prevPageId,
8117
- nextPageId,
8118
- boundaryIndex: parsePageBoundaryIndex(prevPageId),
8119
- topPx,
8120
- bottomPx
8121
- });
8122
- }
8123
- return out;
8124
- }
8125
- function resolveOffsetTop(widget, scrollRoot) {
8126
- let node = widget;
8127
- let top = 0;
8128
- while (node) {
8129
- top += node.offsetTop ?? 0;
8130
- const parent = node.offsetParent;
8131
- if (parent === scrollRoot || parent === null) break;
8132
- node = parent;
8133
- }
8134
- return top;
8135
- }
8136
- function resolveOffsetHeight(widget) {
8137
- return widget.offsetHeight ?? 0;
8138
- }
8139
- function readElementFlowHeight(element, options = {}) {
8140
- if (!element) return 0;
8141
- let height = 0;
8142
- height = Math.max(height, element.clientHeight || 0);
8143
- if (options.includeScrollHeight !== false) {
8144
- height = Math.max(height, element.scrollHeight || 0);
8145
- }
8146
- if (height <= 0) {
8147
- const rect = element.getBoundingClientRect();
8148
- height = Math.max(height, rect.height || 0);
8149
- }
8150
- return height;
8151
- }
8152
- function readOverlayFlowHeight(origin) {
8153
- if (!origin) return 0;
8154
- const parent = origin.parentElement instanceof HTMLElement ? origin.parentElement : null;
8155
- const parentHeight = readElementFlowHeight(parent);
8156
- if (parentHeight > 0) return parentHeight;
8157
- return readElementFlowHeight(origin, { includeScrollHeight: false });
8158
- }
8159
- function reconcilePageStackRectsWithFlow(input) {
8160
- const { baseRects, pageCount, scrollRoot, originElement } = input;
8161
- if (baseRects.length === 0 || pageCount <= 0) return baseRects;
8162
- const flowHeight = readOverlayFlowHeight(originElement);
8163
- if (flowHeight <= 0) return baseRects;
8164
- const geometryBottom = pageOverlayLastBottom(baseRects);
8165
- const tableBoundaryRisk = containsTableBoundaryRisk(scrollRoot);
8166
- if (!tableBoundaryRisk && flowHeight <= geometryBottom + 1) {
8167
- return extendFinalPageOverlayRectToFlowHeight(baseRects, flowHeight);
8168
- }
8169
- const bridgedBase = extendPageOverlayRectsAcrossTableBoundaryGaps(
8170
- baseRects,
8171
- tableBoundaryRisk ? collectTableEmbeddedBoundaryIndices(scrollRoot) : []
8172
- );
8173
- const extendedBase = extendFinalPageOverlayRectToFlowHeight(
8174
- bridgedBase,
8175
- flowHeight
8176
- );
8177
- if (!originElement || !scrollRoot) return extendedBase;
8178
- if (flowHeight <= pageOverlayLastBottom(bridgedBase) + 1) {
8179
- return extendedBase;
8180
- }
8181
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, originElement, {
8182
- pageCount,
8183
- visiblePageIndexRange: null
8184
- });
8185
- if (widgets.length === 0) return extendedBase;
8186
- const flowRects = resolvePageOverlayRects({
8187
- widgets,
8188
- pageCount,
8189
- scrollHeight: flowHeight,
8190
- visiblePageIndexRange: null
8191
- });
8192
- const merged = mergePageOverlayRectsByPageIndex(extendedBase, flowRects);
8193
- return extendFinalPageOverlayRectToFlowHeight(merged, flowHeight);
8194
- }
8195
7996
  var resolvePageOverlayRectsFromGeometry2 = resolvePageOverlayRectsFromGeometry;
8196
7997
  function resolvePageOverlayRectsFromUiApi(ui, pageCount, visiblePageIndexRange, pageIds) {
8197
7998
  if (pageCount <= 0) return [];
@@ -8249,17 +8050,6 @@ var TwPageStackOverlayLayer = ({
8249
8050
  },
8250
8051
  []
8251
8052
  );
8252
- const reconcilePaperRectsWithFlow = React14.useCallback(
8253
- (baseRects, pageCount) => {
8254
- return reconcilePageStackRectsWithFlow({
8255
- baseRects,
8256
- pageCount,
8257
- scrollRoot,
8258
- originElement: overlayRootRef.current
8259
- });
8260
- },
8261
- [scrollRoot]
8262
- );
8263
8053
  const refreshRectsNow = React14.useCallback(() => {
8264
8054
  const pageCount = facet.getPageCount();
8265
8055
  const skeletalRects = resolveSkeletalPageOverlayRectsFromLayout(facet);
@@ -8300,51 +8090,11 @@ var TwPageStackOverlayLayer = ({
8300
8090
  setRectsIfChanged(skeletalRects);
8301
8091
  return;
8302
8092
  }
8303
- if (!scrollRoot) {
8304
- setRectsIfChanged(skeletalRects);
8305
- return;
8306
- }
8307
- const origin = overlayRootRef.current;
8308
- incrementInvalidationCounter("overlay.page.dom_fallback");
8309
- if (origin) {
8310
- incrementInvalidationCounter("overlay.page.dom.degraded");
8311
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
8312
- pageCount,
8313
- visiblePageIndexRange: null
8314
- });
8315
- const originRect = origin.getBoundingClientRect();
8316
- const domRects = resolvePageOverlayRects({
8317
- widgets,
8318
- pageCount,
8319
- scrollHeight: (
8320
- // geometry:allow-dom-fallback
8321
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height
8322
- ),
8323
- visiblePageIndexRange: null
8324
- });
8325
- const reconciled = reconcilePaperRectsWithFlow(domRects, pageCount);
8326
- setRectsIfChanged(reconciled.length > 0 ? reconciled : skeletalRects);
8327
- } else {
8328
- incrementInvalidationCounter("overlay.page.dom.degraded");
8329
- const widgets = measureWidgetsViaOffsetChain(scrollRoot, {
8330
- pageCount,
8331
- visiblePageIndexRange: null
8332
- });
8333
- const domRects = resolvePageOverlayRects({
8334
- widgets,
8335
- pageCount,
8336
- // geometry:allow-dom-fallback
8337
- scrollHeight: scrollRoot.clientHeight,
8338
- visiblePageIndexRange: null
8339
- });
8340
- const reconciled = reconcilePaperRectsWithFlow(domRects, pageCount);
8341
- setRectsIfChanged(reconciled.length > 0 ? reconciled : skeletalRects);
8342
- }
8093
+ incrementInvalidationCounter("overlay.page.skeletal_fallback");
8094
+ setRectsIfChanged(skeletalRects);
8343
8095
  }, [
8344
8096
  facet,
8345
8097
  geometryFacet,
8346
- reconcilePaperRectsWithFlow,
8347
- scrollRoot,
8348
8098
  setRectsIfChanged,
8349
8099
  ui
8350
8100
  ]);
@@ -8375,33 +8125,6 @@ var TwPageStackOverlayLayer = ({
8375
8125
  }
8376
8126
  };
8377
8127
  }, [refreshRects, renderFrameRevision, scrollRoot]);
8378
- React14.useEffect(() => {
8379
- if (geometryFacet) return;
8380
- if (!scrollRoot) return;
8381
- const runtime = scrollRoot.ownerDocument?.defaultView;
8382
- if (!runtime?.ResizeObserver) return;
8383
- const observer = new runtime.ResizeObserver(() => refreshRects());
8384
- observer.observe(scrollRoot);
8385
- return () => observer.disconnect();
8386
- }, [geometryFacet, scrollRoot, refreshRects]);
8387
- React14.useEffect(() => {
8388
- if (geometryFacet) return;
8389
- if (!scrollRoot) return;
8390
- const runtime = scrollRoot.ownerDocument?.defaultView;
8391
- if (!runtime?.MutationObserver) return;
8392
- const observer = new runtime.MutationObserver((records) => {
8393
- const overlay = overlayRootRef.current;
8394
- if (overlay) {
8395
- const allSelf = records.every(
8396
- (r) => r.target instanceof Node && overlay.contains(r.target)
8397
- );
8398
- if (allSelf) return;
8399
- }
8400
- refreshRects();
8401
- });
8402
- observer.observe(scrollRoot, { childList: true, subtree: false });
8403
- return () => observer.disconnect();
8404
- }, [geometryFacet, scrollRoot, refreshRects]);
8405
8128
  if (rects.length === 0) {
8406
8129
  return /* @__PURE__ */ jsx28(
8407
8130
  "div",
@@ -9043,6 +8766,18 @@ function emuToPx(emu, pxPerTwip) {
9043
8766
  return emu / EMU_PER_PX * zoomFactor;
9044
8767
  }
9045
8768
 
8769
+ // src/ui-tailwind/editor-surface/media-src-policy.ts
8770
+ var SAFE_DATA_IMAGE_PREFIX_RE = /^data:image\/(?:png|jpe?g|gif|webp|bmp);base64,/iu;
8771
+ var MAX_NUMBERING_PICTURE_BULLET_DATA_URL_LENGTH = 1024 * 1024;
8772
+ function sanitizeNumberingPictureBulletSrc(src) {
8773
+ if (typeof src !== "string") return null;
8774
+ const trimmed = src.trim();
8775
+ if (trimmed.length === 0) return null;
8776
+ if (trimmed.length > MAX_NUMBERING_PICTURE_BULLET_DATA_URL_LENGTH) return null;
8777
+ if (!SAFE_DATA_IMAGE_PREFIX_RE.test(trimmed)) return null;
8778
+ return trimmed;
8779
+ }
8780
+
9046
8781
  // src/ui-tailwind/page-stack/tw-region-block-renderer.tsx
9047
8782
  import { jsx as jsx29, jsxs as jsxs23 } from "react/jsx-runtime";
9048
8783
  var EMU_PER_PX2 = 9525;
@@ -9157,6 +8892,10 @@ function renderSegment(seg, mediaPreviews, fallbackDisplay, tabInfoBySegment) {
9157
8892
  "span",
9158
8893
  {
9159
8894
  "data-node-type": "field_ref",
8895
+ "data-generated-field": "true",
8896
+ "data-field-family": seg.fieldFamily,
8897
+ "data-field-target": seg.fieldTarget,
8898
+ "data-field-refresh-status": seg.refreshStatus,
9160
8899
  style: { opacity: 0.6, fontSize: "0.85em" },
9161
8900
  children: seg.displayText ?? seg.label
9162
8901
  },
@@ -9206,6 +8945,9 @@ function RegionParagraph({
9206
8945
  const markerWidth = resolvedNumbering?.geometry?.markerLane?.width;
9207
8946
  const markerStart = resolvedNumbering?.geometry?.markerLane?.start;
9208
8947
  const markerJustification = resolvedNumbering?.geometry?.markerJustification;
8948
+ const pictureBulletSrc = sanitizeNumberingPictureBulletSrc(
8949
+ resolvedNumbering?.picBulletMediaId ? mediaPreviews[resolvedNumbering.picBulletMediaId]?.src : null
8950
+ );
9209
8951
  const prefixSpan = numberingPrefix != null ? /* @__PURE__ */ jsx29(
9210
8952
  "span",
9211
8953
  {
@@ -9216,7 +8958,9 @@ function RegionParagraph({
9216
8958
  ...!markerRunProperties ? ["text-tertiary", "font-[family-name:var(--font-legal-sans)]"] : []
9217
8959
  ].join(" "),
9218
8960
  contentEditable: false,
9219
- "data-numbering-prefix": numberingPrefix,
8961
+ "data-numbering-marker": "true",
8962
+ "data-numbering-prefix": pictureBulletSrc ? "" : numberingPrefix,
8963
+ ...pictureBulletSrc ? { "data-numbering-picture-bullet": resolvedNumbering?.pictureBulletPosture?.status ?? "media-rendered" } : {},
9220
8964
  ...typeof resolvedNumbering?.level === "number" ? { "data-numbering-level": String(resolvedNumbering.level) } : {},
9221
8965
  ...numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {},
9222
8966
  style: buildMarkerStyle(
@@ -9227,7 +8971,20 @@ function RegionParagraph({
9227
8971
  markerStart,
9228
8972
  markerJustification
9229
8973
  ),
9230
- children: numberingPrefix
8974
+ children: pictureBulletSrc ? /* @__PURE__ */ jsx29(
8975
+ "img",
8976
+ {
8977
+ src: pictureBulletSrc,
8978
+ alt: "",
8979
+ "aria-hidden": "true",
8980
+ style: {
8981
+ maxWidth: "100%",
8982
+ maxHeight: "100%",
8983
+ objectFit: "contain",
8984
+ display: "block"
8985
+ }
8986
+ }
8987
+ ) : numberingPrefix
9231
8988
  }
9232
8989
  ) : null;
9233
8990
  const attrs = {
@@ -9566,18 +9323,7 @@ function findScrollAnchor(root, options) {
9566
9323
  offsetWithinBlock: viewportTopFramePx - blockTop
9567
9324
  };
9568
9325
  }
9569
- }
9570
- const rootRect = root.getBoundingClientRect();
9571
- const rootTop = rootRect.top;
9572
- for (const block of blocks) {
9573
- const rect = block.getBoundingClientRect();
9574
- if (rect.bottom < rootTop) continue;
9575
- const blockId = block.getAttribute("data-block-id");
9576
- if (!blockId) continue;
9577
- return {
9578
- blockId,
9579
- offsetWithinBlock: rootTop - rect.top
9580
- };
9326
+ return null;
9581
9327
  }
9582
9328
  return null;
9583
9329
  }
@@ -9595,17 +9341,9 @@ function resolveScrollTopForAnchor(root, anchor, options) {
9595
9341
  const rect = geometry.rects[0];
9596
9342
  return rect.topPx + anchor.offsetWithinBlock;
9597
9343
  }
9344
+ return null;
9598
9345
  }
9599
- const selector = `[data-block-id="${cssEscape(anchor.blockId)}"]`;
9600
- const block = root.querySelector(selector);
9601
- if (!block) return null;
9602
- const rootRect = root.getBoundingClientRect();
9603
- const blockRect = block.getBoundingClientRect();
9604
- const delta = blockRect.top - rootRect.top + anchor.offsetWithinBlock;
9605
- return root.scrollTop + delta;
9606
- }
9607
- function cssEscape(value) {
9608
- return value.replace(/[^a-zA-Z0-9_-]/g, (ch) => `\\${ch}`);
9346
+ return null;
9609
9347
  }
9610
9348
 
9611
9349
  // src/ui-tailwind/chrome/collab-top-nav-container.tsx
@@ -10945,7 +10683,17 @@ function TwSelectionToolStructure(props) {
10945
10683
  onSetCellVerticalAlign: props.onSetCellVerticalAlign
10946
10684
  }
10947
10685
  );
10948
- case "list":
10686
+ case "list": {
10687
+ const continueState = resolveListToolbarButtonState({
10688
+ canMutate: props.model.canMutate,
10689
+ callback: props.onContinueNumbering,
10690
+ availability: getListCommandAvailability2(props.activeListReadback, "continue-numbering")
10691
+ });
10692
+ const restartState = resolveListToolbarButtonState({
10693
+ canMutate: props.model.canMutate,
10694
+ callback: props.onRestartNumbering,
10695
+ availability: getListCommandAvailability2(props.activeListReadback, "restart-numbering")
10696
+ });
10949
10697
  return /* @__PURE__ */ jsxs34(
10950
10698
  "div",
10951
10699
  {
@@ -10957,7 +10705,8 @@ function TwSelectionToolStructure(props) {
10957
10705
  ToolbarButton3,
10958
10706
  {
10959
10707
  ariaLabel: "Continue numbering",
10960
- disabled: !props.model.canMutate || !props.onContinueNumbering,
10708
+ disabled: continueState.disabled,
10709
+ disabledReason: continueState.disabledReason,
10961
10710
  onClick: props.onContinueNumbering,
10962
10711
  children: "Continue"
10963
10712
  }
@@ -10966,7 +10715,8 @@ function TwSelectionToolStructure(props) {
10966
10715
  ToolbarButton3,
10967
10716
  {
10968
10717
  ariaLabel: "Restart numbering",
10969
- disabled: !props.model.canMutate || !props.onRestartNumbering,
10718
+ disabled: restartState.disabled,
10719
+ disabledReason: restartState.disabledReason,
10970
10720
  onClick: props.onRestartNumbering,
10971
10721
  children: "Restart"
10972
10722
  }
@@ -10974,15 +10724,31 @@ function TwSelectionToolStructure(props) {
10974
10724
  ]
10975
10725
  }
10976
10726
  );
10727
+ }
10977
10728
  }
10978
10729
  }
10730
+ function getListCommandAvailability2(readback, command) {
10731
+ return readback?.commandSupport.find((entry) => entry.command === command);
10732
+ }
10733
+ function resolveListToolbarButtonState(input) {
10734
+ if (!input.canMutate || !input.callback) {
10735
+ return { disabled: true };
10736
+ }
10737
+ if (input.availability?.enabled === false) {
10738
+ return { disabled: true, disabledReason: input.availability.reason };
10739
+ }
10740
+ return { disabled: false };
10741
+ }
10979
10742
  function ToolbarButton3(props) {
10743
+ const disabledReason = props.disabled && props.disabledReason ? props.disabledReason : void 0;
10980
10744
  return /* @__PURE__ */ jsx43(
10981
10745
  "button",
10982
10746
  {
10983
10747
  type: "button",
10984
10748
  "aria-label": props.ariaLabel,
10985
10749
  disabled: props.disabled,
10750
+ "data-disabled-reason": disabledReason,
10751
+ title: disabledReason ? `Not available: ${disabledReason}` : void 0,
10986
10752
  onMouseDown: preserveEditorSelectionMouseDown,
10987
10753
  onClick: props.onClick,
10988
10754
  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",
@@ -11371,6 +11137,7 @@ function renderTool(props, tool, density) {
11371
11137
  onSetImageFrame: props.onSetImageFrame,
11372
11138
  onRestartNumbering: props.onRestartNumbering,
11373
11139
  onContinueNumbering: props.onContinueNumbering,
11140
+ activeListReadback: props.activeListReadback,
11374
11141
  onToggleRowHeader: props.onToggleRowHeader,
11375
11142
  onToggleRowCantSplit: props.onToggleRowCantSplit,
11376
11143
  onDistributeColumnsEvenly: props.onDistributeColumnsEvenly,
@@ -11571,6 +11338,7 @@ var EDITOR_ACTION_REGISTRY = [
11571
11338
  group: "clipboard",
11572
11339
  targetKinds: [
11573
11340
  "plain-text",
11341
+ "list-item",
11574
11342
  "table-cell",
11575
11343
  "image",
11576
11344
  "hyperlink",
@@ -11589,9 +11357,11 @@ var EDITOR_ACTION_REGISTRY = [
11589
11357
  group: "clipboard",
11590
11358
  targetKinds: [
11591
11359
  "plain-text",
11360
+ "list-item",
11592
11361
  "table-cell",
11593
11362
  "image",
11594
11363
  "hyperlink",
11364
+ "generated-field",
11595
11365
  "suggestion",
11596
11366
  "comment-anchor",
11597
11367
  "opaque-block",
@@ -11606,6 +11376,7 @@ var EDITOR_ACTION_REGISTRY = [
11606
11376
  group: "clipboard",
11607
11377
  targetKinds: [
11608
11378
  "plain-text",
11379
+ "list-item",
11609
11380
  "table-cell",
11610
11381
  "hyperlink",
11611
11382
  "suggestion",
@@ -11766,28 +11537,28 @@ var EDITOR_ACTION_REGISTRY = [
11766
11537
  id: "list-bulleted",
11767
11538
  label: "Bulleted list",
11768
11539
  group: "formatting",
11769
- targetKinds: ["plain-text", "table-cell"],
11540
+ targetKinds: ["list-item", "plain-text", "table-cell"],
11770
11541
  callback: "onToggleBulletedList"
11771
11542
  }),
11772
11543
  mk({
11773
11544
  id: "list-numbered",
11774
11545
  label: "Numbered list",
11775
11546
  group: "formatting",
11776
- targetKinds: ["plain-text", "table-cell"],
11547
+ targetKinds: ["list-item", "plain-text", "table-cell"],
11777
11548
  callback: "onToggleNumberedList"
11778
11549
  }),
11779
11550
  mk({
11780
11551
  id: "paragraph-outdent",
11781
11552
  label: "Decrease indent",
11782
11553
  group: "formatting",
11783
- targetKinds: ["plain-text", "table-cell"],
11554
+ targetKinds: ["list-item", "plain-text", "table-cell"],
11784
11555
  callback: "onOutdent"
11785
11556
  }),
11786
11557
  mk({
11787
11558
  id: "paragraph-indent",
11788
11559
  label: "Increase indent",
11789
11560
  group: "formatting",
11790
- targetKinds: ["plain-text", "table-cell"],
11561
+ targetKinds: ["list-item", "plain-text", "table-cell"],
11791
11562
  callback: "onIndent"
11792
11563
  }),
11793
11564
  mkArg({
@@ -12136,6 +11907,23 @@ var EDITOR_ACTION_REGISTRY = [
12136
11907
  targetKinds: ["hyperlink"],
12137
11908
  callback: "onOpenHyperlink"
12138
11909
  }),
11910
+ // -------- Generated fields --------
11911
+ mk({
11912
+ id: "field-refresh",
11913
+ label: "Refresh field",
11914
+ description: "Refresh generated field results through the runtime field updater.",
11915
+ group: "misc",
11916
+ targetKinds: ["generated-field"],
11917
+ callback: "onUpdateFields"
11918
+ }),
11919
+ mk({
11920
+ id: "toc-refresh",
11921
+ label: "Refresh table of contents",
11922
+ description: "Refresh TOC entries through the runtime table-of-contents updater.",
11923
+ group: "misc",
11924
+ targetKinds: ["toc-field"],
11925
+ callback: "onUpdateTableOfContents"
11926
+ }),
12139
11927
  // -------- Workflow scope --------
12140
11928
  mk({
12141
11929
  id: "scope-open-card",
@@ -12721,13 +12509,40 @@ function hasAncestorAttributeValue(el, attribute, expected, root) {
12721
12509
  }
12722
12510
  return false;
12723
12511
  }
12512
+ function hasAncestorAttributeValueInsensitive(el, attribute, expected, root) {
12513
+ const normalizedExpected = expected.toLowerCase();
12514
+ let cursor = el;
12515
+ while (cursor) {
12516
+ if (cursor.getAttribute?.(attribute)?.toLowerCase() === normalizedExpected) {
12517
+ return true;
12518
+ }
12519
+ if (cursor === root) return false;
12520
+ cursor = cursor.parentElement;
12521
+ }
12522
+ return false;
12523
+ }
12724
12524
  function resolveTargetKind(target, options = {}) {
12725
12525
  const kinds = [];
12726
12526
  const el = toElement(target);
12727
12527
  if (el) {
12728
12528
  const { root } = options;
12529
+ const insideNumberingMarker = hasAncestorAttributeValue(
12530
+ el,
12531
+ "data-numbering-marker",
12532
+ "true",
12533
+ root
12534
+ );
12535
+ const insideListItem = insideNumberingMarker || hasAncestorAttributeValue(el, "data-numbered", "true", root);
12536
+ 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);
12537
+ if (insideListItem) kinds.push("list-item");
12538
+ if (insideGeneratedField) {
12539
+ kinds.push("generated-field");
12540
+ if (hasAncestorAttributeValueInsensitive(el, "data-field-family", "TOC", root)) {
12541
+ kinds.push("toc-field");
12542
+ }
12543
+ }
12729
12544
  if (hasAncestorTag(el, "a", root)) kinds.push("hyperlink");
12730
- if (hasAncestorTag(el, "img", root)) {
12545
+ if (!insideNumberingMarker && hasAncestorTag(el, "img", root)) {
12731
12546
  kinds.push("image");
12732
12547
  }
12733
12548
  if (hasAncestorTag(el, "td", root) || hasAncestorTag(el, "th", root)) {
@@ -12763,7 +12578,9 @@ function resolveTargetKind(target, options = {}) {
12763
12578
  if (!kinds.includes("template-slot")) kinds.push("template-slot");
12764
12579
  }
12765
12580
  }
12766
- if (!kinds.includes("plain-text")) kinds.push("plain-text");
12581
+ if (!kinds.includes("generated-field") && !kinds.includes("plain-text")) {
12582
+ kinds.push("plain-text");
12583
+ }
12767
12584
  return kinds;
12768
12585
  }
12769
12586
 
@@ -13029,45 +12846,17 @@ var TwFloatingImageLayer = ({
13029
12846
  const [pageRects, setPageRects] = React25.useState([]);
13030
12847
  const refreshPageRectsNow = React25.useCallback(() => {
13031
12848
  const pageCount = facet.getPageCount();
13032
- if (geometryFacet) {
13033
- const geometryRects = resolvePageOverlayRectsFromGeometry2(
13034
- geometryFacet,
13035
- pageCount,
13036
- visiblePageIndexRange
13037
- );
13038
- if (geometryRects !== null) {
13039
- setPageRects(geometryRects);
13040
- return;
13041
- }
13042
- setPageRects([]);
13043
- return;
13044
- }
13045
- if (!scrollRoot) {
13046
- setPageRects([]);
13047
- return;
13048
- }
13049
- const origin = overlayRootRef.current;
13050
- if (!origin) {
12849
+ if (!geometryFacet) {
13051
12850
  setPageRects([]);
13052
12851
  return;
13053
12852
  }
13054
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
12853
+ const geometryRects = resolvePageOverlayRectsFromGeometry2(
12854
+ geometryFacet,
13055
12855
  pageCount,
13056
12856
  visiblePageIndexRange
13057
- });
13058
- const originRect = origin.getBoundingClientRect();
13059
- setPageRects(
13060
- resolvePageOverlayRects({
13061
- widgets,
13062
- pageCount,
13063
- scrollHeight: (
13064
- // geometry:allow-dom-fallback
13065
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height
13066
- ),
13067
- visiblePageIndexRange
13068
- })
13069
12857
  );
13070
- }, [facet, geometryFacet, scrollRoot, visiblePageIndexRange]);
12858
+ setPageRects(geometryRects ?? []);
12859
+ }, [facet, geometryFacet, visiblePageIndexRange]);
13071
12860
  const refreshPageRects = React25.useCallback(() => {
13072
12861
  if (!scrollRoot) {
13073
12862
  refreshPageRectsNow();
@@ -13097,47 +12886,6 @@ var TwFloatingImageLayer = ({
13097
12886
  }
13098
12887
  };
13099
12888
  }, [refreshPageRects, renderFrameRevision, scrollRoot]);
13100
- React25.useEffect(() => {
13101
- if (geometryFacet) {
13102
- return;
13103
- }
13104
- if (!scrollRoot) {
13105
- return;
13106
- }
13107
- const runtime = scrollRoot.ownerDocument?.defaultView;
13108
- if (!runtime?.ResizeObserver) {
13109
- return;
13110
- }
13111
- const observer = new runtime.ResizeObserver(() => refreshPageRects());
13112
- observer.observe(scrollRoot);
13113
- return () => observer.disconnect();
13114
- }, [geometryFacet, refreshPageRects, scrollRoot]);
13115
- React25.useEffect(() => {
13116
- if (geometryFacet) {
13117
- return;
13118
- }
13119
- if (!scrollRoot) {
13120
- return;
13121
- }
13122
- const runtime = scrollRoot.ownerDocument?.defaultView;
13123
- if (!runtime?.MutationObserver) {
13124
- return;
13125
- }
13126
- const observer = new runtime.MutationObserver((records) => {
13127
- const overlay = overlayRootRef.current;
13128
- if (overlay) {
13129
- const allSelf = records.every(
13130
- (record) => record.target instanceof Node && overlay.contains(record.target)
13131
- );
13132
- if (allSelf) {
13133
- return;
13134
- }
13135
- }
13136
- refreshPageRects();
13137
- });
13138
- observer.observe(scrollRoot, { childList: true, subtree: false });
13139
- return () => observer.disconnect();
13140
- }, [geometryFacet, refreshPageRects, scrollRoot]);
13141
12889
  const items = React25.useMemo(() => {
13142
12890
  const viewportScale = geometryFacet?.getViewport().pxPerTwip;
13143
12891
  const pxPerTwip = typeof viewportScale === "number" && viewportScale > 0 ? viewportScale : void 0;
@@ -15405,6 +15153,21 @@ function resolveRoleChromePreset(basePreset, role) {
15405
15153
  }
15406
15154
  return basePreset;
15407
15155
  }
15156
+ function resolveActiveListReadback(rows, activeListContext, selection) {
15157
+ if (!activeListContext) {
15158
+ return null;
15159
+ }
15160
+ const selectionPoint = selection.activeRange.kind === "range" ? selection.head : selection.activeRange.kind === "node" ? selection.activeRange.at : selection.activeRange.lastKnownRange.from;
15161
+ const matchingSelectionRow = rows.find(
15162
+ (row) => row.numberingInstanceId === activeListContext.numberingInstanceId && row.level === activeListContext.level && selectionPoint >= row.authoredTextRange.from && selectionPoint <= row.authoredTextRange.to
15163
+ );
15164
+ if (matchingSelectionRow) {
15165
+ return matchingSelectionRow;
15166
+ }
15167
+ return rows.find(
15168
+ (row) => row.numberingInstanceId === activeListContext.numberingInstanceId && row.level === activeListContext.level
15169
+ ) ?? null;
15170
+ }
15408
15171
  function TwReviewWorkspace(inputProps) {
15409
15172
  const props = {
15410
15173
  ...inputProps,
@@ -15519,6 +15282,14 @@ function TwReviewWorkspace(inputProps) {
15519
15282
  () => uiApi?.scope.list().length,
15520
15283
  [uiApi, renderFrameRevision]
15521
15284
  );
15285
+ const activeListReadback = useMemo15(
15286
+ () => resolveActiveListReadback(
15287
+ uiApi?.lists.list() ?? [],
15288
+ props.activeListContext,
15289
+ viewState.selection
15290
+ ),
15291
+ [uiApi, props.activeListContext, viewState.selection, renderFrameRevision]
15292
+ );
15522
15293
  const headings = props.documentNavigation?.headings ?? [];
15523
15294
  const headerVariant = snapshot.pageLayout?.headerVariants[0]?.variant ?? "default";
15524
15295
  const footerVariant = snapshot.pageLayout?.footerVariants[0]?.variant ?? "default";
@@ -15787,6 +15558,7 @@ function TwReviewWorkspace(inputProps) {
15787
15558
  zoomLevel: props.zoomLevel,
15788
15559
  formattingState: props.formattingState,
15789
15560
  activeListContext: props.activeListContext,
15561
+ activeListReadback,
15790
15562
  styleCatalog: props.styleCatalog,
15791
15563
  showTrackedChanges: trackedChangesAuthoringEnabled,
15792
15564
  showSidebarToggle: responsiveChrome.showSidebarToggle,
@@ -15998,6 +15770,7 @@ function TwReviewWorkspace(inputProps) {
15998
15770
  onSetImageFrame: props.onSetImageFrame,
15999
15771
  onRestartNumbering: props.onRestartNumbering,
16000
15772
  onContinueNumbering: props.onContinueNumbering,
15773
+ activeListReadback,
16001
15774
  onToggleRowHeader: props.onToggleRowHeader,
16002
15775
  onToggleRowCantSplit: props.onToggleRowCantSplit,
16003
15776
  onDistributeColumnsEvenly: props.onDistributeColumnsEvenly,
@@ -17175,25 +16948,23 @@ var TwPageStackChromeLayerInner = ({
17175
16948
  const pageCount = facet.getPageCount();
17176
16949
  const uiRects = resolveUiPageRects(pageCount);
17177
16950
  if (uiRects !== null) return uiRects;
17178
- if (!geometryFacet) return [];
17179
- const warm = resolvePageOverlayRectsFromGeometry2(
17180
- geometryFacet,
17181
- pageCount,
17182
- visiblePageIndexRange
16951
+ if (geometryFacet) {
16952
+ const warm = resolvePageOverlayRectsFromGeometry2(
16953
+ geometryFacet,
16954
+ pageCount,
16955
+ visiblePageIndexRange
16956
+ );
16957
+ if (warm !== null) return warm;
16958
+ }
16959
+ return resolveSkeletalPageOverlayRectsFromLayout(facet).filter(
16960
+ (rect) => !visiblePageIndexRange || rect.pageIndex >= visiblePageIndexRange.start && rect.pageIndex < visiblePageIndexRange.end
17183
16961
  );
17184
- return warm ?? [];
17185
16962
  });
17186
16963
  const overlayRootRef = React34.useRef(null);
17187
16964
  const rafHandleRef = React34.useRef(null);
17188
16965
  const [activeStoryPageIndex, setActiveStoryPageIndex] = React34.useState(null);
17189
16966
  const refreshRectsNow = React34.useCallback(() => {
17190
16967
  const pageCount = facet.getPageCount();
17191
- const reconcileDomRects = (baseRects) => reconcilePageStackRectsWithFlow({
17192
- baseRects,
17193
- pageCount,
17194
- scrollRoot,
17195
- originElement: overlayRootRef.current
17196
- });
17197
16968
  const uiRects = resolveUiPageRects(pageCount);
17198
16969
  if (uiRects !== null) {
17199
16970
  setRects(uiRects);
@@ -17212,47 +16983,11 @@ var TwPageStackChromeLayerInner = ({
17212
16983
  setRects([]);
17213
16984
  return;
17214
16985
  }
17215
- if (!scrollRoot) {
17216
- setRects([]);
17217
- return;
17218
- }
17219
- const origin = overlayRootRef.current;
17220
- if (origin) {
17221
- const widgets = measureWidgetsViaBoundingRect(scrollRoot, origin, {
17222
- pageCount,
17223
- visiblePageIndexRange
17224
- });
17225
- const originRect = origin.getBoundingClientRect();
17226
- const scrollHeight = (
17227
- // geometry:allow-dom-fallback
17228
- origin.clientHeight > 0 ? origin.clientHeight : originRect.height > 0 ? originRect.height : scrollRoot.clientHeight
17229
- );
17230
- const domRects = resolvePageOverlayRects({
17231
- widgets,
17232
- pageCount,
17233
- scrollHeight,
17234
- visiblePageIndexRange
17235
- });
17236
- setRects(
17237
- reconcileDomRects(domRects)
17238
- );
17239
- } else {
17240
- const widgets = measureWidgetsViaOffsetChain(scrollRoot, {
17241
- pageCount,
17242
- visiblePageIndexRange
17243
- });
17244
- const domRects = resolvePageOverlayRects({
17245
- widgets,
17246
- pageCount,
17247
- // geometry:allow-dom-fallback
17248
- scrollHeight: scrollRoot.clientHeight,
17249
- visiblePageIndexRange
17250
- });
17251
- setRects(
17252
- reconcileDomRects(domRects)
17253
- );
17254
- }
17255
- }, [facet, geometryFacet, resolveUiPageRects, scrollRoot, visiblePageIndexRange]);
16986
+ const skeletalRects = resolveSkeletalPageOverlayRectsFromLayout(facet).filter(
16987
+ (rect) => !visiblePageIndexRange || rect.pageIndex >= visiblePageIndexRange.start && rect.pageIndex < visiblePageIndexRange.end
16988
+ );
16989
+ setRects(skeletalRects);
16990
+ }, [facet, geometryFacet, resolveUiPageRects, visiblePageIndexRange]);
17256
16991
  const refreshRects = React34.useCallback(() => {
17257
16992
  if (!scrollRoot) {
17258
16993
  refreshRectsNow();
@@ -17292,33 +17027,6 @@ var TwPageStackChromeLayerInner = ({
17292
17027
  },
17293
17028
  [onOpenStory]
17294
17029
  );
17295
- React34.useEffect(() => {
17296
- if (geometryFacet) return;
17297
- if (!scrollRoot) return;
17298
- const runtime = scrollRoot.ownerDocument?.defaultView;
17299
- if (!runtime?.ResizeObserver) return;
17300
- const observer = new runtime.ResizeObserver(() => refreshRects());
17301
- observer.observe(scrollRoot);
17302
- return () => observer.disconnect();
17303
- }, [geometryFacet, scrollRoot, refreshRects]);
17304
- React34.useEffect(() => {
17305
- if (geometryFacet) return;
17306
- if (!scrollRoot) return;
17307
- const runtime = scrollRoot.ownerDocument?.defaultView;
17308
- if (!runtime?.MutationObserver) return;
17309
- const observer = new runtime.MutationObserver((records) => {
17310
- const overlay = overlayRootRef.current;
17311
- if (overlay) {
17312
- const allSelf = records.every(
17313
- (r) => r.target instanceof Node && overlay.contains(r.target)
17314
- );
17315
- if (allSelf) return;
17316
- }
17317
- refreshRects();
17318
- });
17319
- observer.observe(scrollRoot, { childList: true, subtree: false });
17320
- return () => observer.disconnect();
17321
- }, [geometryFacet, scrollRoot, refreshRects]);
17322
17030
  React34.useLayoutEffect(() => {
17323
17031
  if (!pmSurfaceElement) return;
17324
17032
  const overlay = overlayRootRef.current;
@@ -18798,6 +18506,7 @@ export {
18798
18506
  TwCommandPaletteMount,
18799
18507
  UiApiProvider,
18800
18508
  shouldRenderAbsoluteFloatingImageInPageOverlay,
18509
+ sanitizeNumberingPictureBulletSrc,
18801
18510
  TwChromeOverlay,
18802
18511
  TwScopeRailLayer,
18803
18512
  buildPictureFilterCss,