@underverse-ui/underverse 1.0.201 → 1.0.203

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.
package/dist/index.cjs CHANGED
@@ -998,6 +998,8 @@ var en_default = {
998
998
  alignCenter: "Align Center",
999
999
  alignRight: "Align Right",
1000
1000
  justify: "Justify",
1001
+ decreaseIndent: "Decrease Indent",
1002
+ increaseIndent: "Increase Indent",
1001
1003
  bulletList: "Bullet List",
1002
1004
  orderedList: "Numbered List",
1003
1005
  taskList: "Task List",
@@ -1135,11 +1137,14 @@ var en_default = {
1135
1137
  mergeCells: "Merge Cells",
1136
1138
  splitCell: "Split Cell",
1137
1139
  openControls: "Open Table Controls",
1140
+ cellFormatting: "Cell Formatting",
1138
1141
  quickAddColumnAfter: "Quick Add Column After",
1139
1142
  quickAddRowAfter: "Quick Add Row After",
1140
1143
  expandTable: "Expand Table",
1141
1144
  dragRow: "Drag Row",
1142
1145
  dragColumn: "Drag Column",
1146
+ resizeBoth: "Resize Table",
1147
+ resizeCtrlHint: "Drag freely. Hold Ctrl to lock to one axis; hold Ctrl+Shift to preserve proportions",
1143
1148
  alignLeft: "Align Table Left",
1144
1149
  alignCenter: "Align Table Center",
1145
1150
  alignRight: "Align Table Right",
@@ -1444,6 +1449,8 @@ var vi_default = {
1444
1449
  alignCenter: "C\u0103n gi\u1EEFa",
1445
1450
  alignRight: "C\u0103n ph\u1EA3i",
1446
1451
  justify: "C\u0103n \u0111\u1EC1u",
1452
+ decreaseIndent: "Gi\u1EA3m l\u1EC1",
1453
+ increaseIndent: "T\u0103ng l\u1EC1",
1447
1454
  bulletList: "Danh s\xE1ch d\u1EA5u ch\u1EA5m",
1448
1455
  orderedList: "Danh s\xE1ch s\u1ED1",
1449
1456
  taskList: "Danh s\xE1ch c\xF4ng vi\u1EC7c",
@@ -1581,11 +1588,14 @@ var vi_default = {
1581
1588
  mergeCells: "G\u1ED9p \xF4",
1582
1589
  splitCell: "T\xE1ch \xF4",
1583
1590
  openControls: "M\u1EDF \u0111i\u1EC1u khi\u1EC3n b\u1EA3ng",
1591
+ cellFormatting: "\u0110\u1ECBnh d\u1EA1ng \xF4",
1584
1592
  quickAddColumnAfter: "Th\xEAm nhanh c\u1ED9t sau",
1585
1593
  quickAddRowAfter: "Th\xEAm nhanh h\xE0ng sau",
1586
1594
  expandTable: "M\u1EDF r\u1ED9ng b\u1EA3ng",
1587
1595
  dragRow: "K\xE9o h\xE0ng",
1588
1596
  dragColumn: "K\xE9o c\u1ED9t",
1597
+ resizeBoth: "\u0110\u1ED5i k\xEDch th\u01B0\u1EDBc b\u1EA3ng",
1598
+ resizeCtrlHint: "K\xE9o t\u1EF1 do; gi\u1EEF Ctrl \u0111\u1EC3 kh\xF3a m\u1ED9t chi\u1EC1u, ho\u1EB7c Ctrl+Shift \u0111\u1EC3 gi\u1EEF nguy\xEAn t\u1EF7 l\u1EC7",
1589
1599
  alignLeft: "C\u0103n b\u1EA3ng tr\xE1i",
1590
1600
  alignCenter: "C\u0103n b\u1EA3ng gi\u1EEFa",
1591
1601
  alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i",
@@ -1890,6 +1900,8 @@ var ko_default = {
1890
1900
  alignCenter: "\uAC00\uC6B4\uB370 \uC815\uB82C",
1891
1901
  alignRight: "\uC624\uB978\uCABD \uC815\uB82C",
1892
1902
  justify: "\uC591\uCABD \uB9DE\uCDA4",
1903
+ decreaseIndent: "\uB0B4\uC5B4\uC4F0\uAE30",
1904
+ increaseIndent: "\uB4E4\uC5EC\uC4F0\uAE30",
1893
1905
  bulletList: "\uAE00\uBA38\uB9AC \uAE30\uD638 \uBAA9\uB85D",
1894
1906
  orderedList: "\uBC88\uD638 \uB9E4\uAE30\uAE30 \uBAA9\uB85D",
1895
1907
  taskList: "\uD560 \uC77C \uBAA9\uB85D",
@@ -2027,11 +2039,14 @@ var ko_default = {
2027
2039
  mergeCells: "\uC140 \uBCD1\uD569",
2028
2040
  splitCell: "\uC140 \uBD84\uD560",
2029
2041
  openControls: "\uD45C \uCEE8\uD2B8\uB864 \uC5F4\uAE30",
2042
+ cellFormatting: "\uC140 \uC11C\uC2DD",
2030
2043
  quickAddColumnAfter: "\uC624\uB978\uCABD \uC5F4 \uBE60\uB974\uAC8C \uCD94\uAC00",
2031
2044
  quickAddRowAfter: "\uC544\uB798 \uD589 \uBE60\uB974\uAC8C \uCD94\uAC00",
2032
2045
  expandTable: "\uD45C \uD655\uC7A5",
2033
2046
  dragRow: "\uD589 \uB4DC\uB798\uADF8",
2034
2047
  dragColumn: "\uC5F4 \uB4DC\uB798\uADF8",
2048
+ resizeBoth: "\uD45C \uD06C\uAE30 \uC870\uC808",
2049
+ resizeCtrlHint: "\uC790\uC720\uB86D\uAC8C \uB4DC\uB798\uADF8\uD569\uB2C8\uB2E4. Ctrl \uD0A4\uB97C \uB204\uB974\uBA74 \uD55C \uCD95\uC73C\uB85C \uACE0\uC815\uB418\uACE0, Ctrl+Shift \uD0A4\uB97C \uB204\uB974\uBA74 \uBE44\uC728\uC774 \uC720\uC9C0\uB429\uB2C8\uB2E4",
2035
2050
  alignLeft: "\uD45C \uC67C\uCABD \uC815\uB82C",
2036
2051
  alignCenter: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
2037
2052
  alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C",
@@ -2336,6 +2351,8 @@ var ja_default = {
2336
2351
  alignCenter: "\u4E2D\u592E\u63C3\u3048",
2337
2352
  alignRight: "\u53F3\u63C3\u3048",
2338
2353
  justify: "\u4E21\u7AEF\u63C3\u3048",
2354
+ decreaseIndent: "\u30A4\u30F3\u30C7\u30F3\u30C8\u3092\u6E1B\u3089\u3059",
2355
+ increaseIndent: "\u30A4\u30F3\u30C7\u30F3\u30C8\u3092\u5897\u3084\u3059",
2339
2356
  bulletList: "\u7B87\u6761\u66F8\u304D",
2340
2357
  orderedList: "\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",
2341
2358
  taskList: "\u30BF\u30B9\u30AF\u30EA\u30B9\u30C8",
@@ -2473,11 +2490,14 @@ var ja_default = {
2473
2490
  mergeCells: "\u30BB\u30EB\u3092\u7D50\u5408",
2474
2491
  splitCell: "\u30BB\u30EB\u3092\u5206\u5272",
2475
2492
  openControls: "\u8868\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u3092\u958B\u304F",
2493
+ cellFormatting: "\u30BB\u30EB\u306E\u66F8\u5F0F\u8A2D\u5B9A",
2476
2494
  quickAddColumnAfter: "\u53F3\u5074\u306B\u5217\u3092\u3059\u3070\u3084\u304F\u8FFD\u52A0",
2477
2495
  quickAddRowAfter: "\u4E0B\u306B\u884C\u3092\u3059\u3070\u3084\u304F\u8FFD\u52A0",
2478
2496
  expandTable: "\u8868\u3092\u62E1\u5F35",
2479
2497
  dragRow: "\u884C\u3092\u30C9\u30E9\u30C3\u30B0",
2480
2498
  dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0",
2499
+ resizeBoth: "\u8868\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4",
2500
+ resizeCtrlHint: "\u81EA\u7531\u306B\u30C9\u30E9\u30C3\u30B0\u3067\u304D\u307E\u3059\u3002Ctrl\u30AD\u30FC\u30671\u65B9\u5411\u306B\u56FA\u5B9A\u3057\u3001Ctrl+Shift\u30AD\u30FC\u3067\u7E26\u6A2A\u6BD4\u3092\u7DAD\u6301\u3057\u307E\u3059",
2481
2501
  alignLeft: "\u8868\u3092\u5DE6\u5BC4\u305B",
2482
2502
  alignCenter: "\u8868\u3092\u4E2D\u592E\u63C3\u3048",
2483
2503
  alignRight: "\u8868\u3092\u53F3\u5BC4\u305B",
@@ -8876,6 +8896,8 @@ var DropdownMenu = ({
8876
8896
  disabled = false,
8877
8897
  isOpen,
8878
8898
  onOpenChange,
8899
+ openOnHover = false,
8900
+ hoverCloseDelay = 120,
8879
8901
  items,
8880
8902
  borderMode
8881
8903
  }) => {
@@ -8895,10 +8917,26 @@ var DropdownMenu = ({
8895
8917
  const itemsRef = import_react17.default.useRef([]);
8896
8918
  const [activeIndex, setActiveIndex] = useResettingIndex(open);
8897
8919
  const parentMenu = import_react17.default.useContext(DropdownMenuContext);
8920
+ const hoverCloseTimeoutRef = import_react17.default.useRef(null);
8921
+ const cancelHoverClose = import_react17.default.useCallback(() => {
8922
+ if (hoverCloseTimeoutRef.current === null) return;
8923
+ clearTimeout(hoverCloseTimeoutRef.current);
8924
+ hoverCloseTimeoutRef.current = null;
8925
+ }, []);
8926
+ const scheduleHoverClose = import_react17.default.useCallback(() => {
8927
+ if (!openOnHover) return;
8928
+ cancelHoverClose();
8929
+ hoverCloseTimeoutRef.current = setTimeout(() => {
8930
+ hoverCloseTimeoutRef.current = null;
8931
+ setOpen(false);
8932
+ }, hoverCloseDelay);
8933
+ }, [cancelHoverClose, hoverCloseDelay, openOnHover, setOpen]);
8934
+ import_react17.default.useEffect(() => () => cancelHoverClose(), [cancelHoverClose]);
8898
8935
  const closeMenu = import_react17.default.useCallback(() => {
8936
+ cancelHoverClose();
8899
8937
  setOpen(false);
8900
8938
  parentMenu?.closeMenu();
8901
- }, [parentMenu, setOpen]);
8939
+ }, [cancelHoverClose, parentMenu, setOpen]);
8902
8940
  const getEnabledMenuItems = import_react17.default.useCallback(() => {
8903
8941
  const menuEl = menuRef.current;
8904
8942
  if (!menuEl) return [];
@@ -8955,9 +8993,11 @@ var DropdownMenu = ({
8955
8993
  const menuContext = import_react17.default.useMemo(
8956
8994
  () => ({
8957
8995
  closeMenu,
8958
- closeOnSelect
8996
+ closeOnSelect,
8997
+ cancelHoverClose,
8998
+ scheduleHoverClose
8959
8999
  }),
8960
- [closeMenu, closeOnSelect]
9000
+ [cancelHoverClose, closeMenu, closeOnSelect, scheduleHoverClose]
8961
9001
  );
8962
9002
  const handleItemClick = (itemOnClick) => {
8963
9003
  itemOnClick();
@@ -8965,71 +9005,117 @@ var DropdownMenu = ({
8965
9005
  closeMenu();
8966
9006
  }
8967
9007
  };
8968
- const menuBody = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropdownMenuContext.Provider, { value: menuContext, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: menuRef, "data-dropdown-menu": true, "data-state": open ? "open" : "closed", role: "menu", className: cn("min-w-40", className), children: items ? items.map((item, index) => {
8969
- const IconComponent = item.icon;
8970
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
8971
- "button",
8972
- {
8973
- ref: (el) => {
8974
- if (el) itemsRef.current[index] = el;
8975
- },
8976
- onClick: () => handleItemClick(item.onClick),
8977
- disabled: item.disabled,
8978
- role: "menuitem",
8979
- "data-dropdown-menu-item": "",
8980
- tabIndex: -1,
8981
- style: {
8982
- animationDelay: open ? `${Math.min(index * 20, 200)}ms` : "0ms"
8983
- },
8984
- className: cn(
8985
- "dropdown-item flex w-full items-center gap-2 px-2.5 py-1.5 text-sm",
8986
- resolvedBorderMode ? getBorderRadiusClass(resolvedBorderMode) : "rounded-lg",
8987
- "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
8988
- "hover:bg-accent hover:text-accent-foreground",
8989
- "focus:bg-accent focus:text-accent-foreground",
8990
- "disabled:opacity-50 disabled:cursor-not-allowed",
8991
- item.destructive && "text-destructive hover:bg-destructive/10 focus:bg-destructive/10"
8992
- ),
8993
- children: [
8994
- IconComponent && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(IconComponent, { className: "h-4 w-4" }),
8995
- item.label
8996
- ]
8997
- },
8998
- index
8999
- );
9000
- }) : children }) });
9008
+ const menuBody = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropdownMenuContext.Provider, { value: menuContext, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
9009
+ "div",
9010
+ {
9011
+ ref: menuRef,
9012
+ "data-dropdown-menu": true,
9013
+ "data-state": open ? "open" : "closed",
9014
+ role: "menu",
9015
+ className: cn("min-w-40", className),
9016
+ onMouseEnter: openOnHover ? () => {
9017
+ cancelHoverClose();
9018
+ parentMenu?.cancelHoverClose();
9019
+ } : void 0,
9020
+ onMouseLeave: openOnHover ? () => {
9021
+ scheduleHoverClose();
9022
+ parentMenu?.scheduleHoverClose();
9023
+ } : void 0,
9024
+ children: items ? items.map((item, index) => {
9025
+ const IconComponent = item.icon;
9026
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
9027
+ "button",
9028
+ {
9029
+ ref: (el) => {
9030
+ if (el) itemsRef.current[index] = el;
9031
+ },
9032
+ onClick: () => handleItemClick(item.onClick),
9033
+ disabled: item.disabled,
9034
+ role: "menuitem",
9035
+ "data-dropdown-menu-item": "",
9036
+ tabIndex: -1,
9037
+ style: {
9038
+ animationDelay: open ? `${Math.min(index * 20, 200)}ms` : "0ms"
9039
+ },
9040
+ className: cn(
9041
+ "dropdown-item flex w-full items-center gap-2 px-2.5 py-1.5 text-sm",
9042
+ resolvedBorderMode ? getBorderRadiusClass(resolvedBorderMode) : "rounded-lg",
9043
+ "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
9044
+ "hover:bg-accent hover:text-accent-foreground",
9045
+ "focus:bg-accent focus:text-accent-foreground",
9046
+ "disabled:opacity-50 disabled:cursor-not-allowed",
9047
+ item.destructive && "text-destructive hover:bg-destructive/10 focus:bg-destructive/10"
9048
+ ),
9049
+ children: [
9050
+ IconComponent && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(IconComponent, { className: "h-4 w-4" }),
9051
+ item.label
9052
+ ]
9053
+ },
9054
+ index
9055
+ );
9056
+ }) : children
9057
+ }
9058
+ ) });
9001
9059
  const triggerProps = trigger.props;
9002
- const childRef = triggerProps.ref;
9060
+ const {
9061
+ ref: childRef,
9062
+ onKeyDown: triggerOnKeyDown,
9063
+ onClick: triggerOnClick,
9064
+ onMouseEnter: triggerOnMouseEnter,
9065
+ onMouseLeave: triggerOnMouseLeave
9066
+ } = triggerProps;
9067
+ const setTriggerNode = import_react17.default.useCallback((node) => {
9068
+ setRefValue(childRef, node);
9069
+ triggerRef.current = node;
9070
+ }, [childRef]);
9071
+ const handleTriggerKeyDown = import_react17.default.useCallback((event) => {
9072
+ if (!disabled) {
9073
+ if (event.key === "ArrowDown") {
9074
+ event.preventDefault();
9075
+ setOpen(true);
9076
+ requestAnimationFrame(() => focusMenuItem(0));
9077
+ } else if (event.key === "ArrowUp") {
9078
+ event.preventDefault();
9079
+ setOpen(true);
9080
+ requestAnimationFrame(() => {
9081
+ const enabled = getEnabledMenuItems();
9082
+ focusMenuItem(enabled.length - 1);
9083
+ });
9084
+ } else if (event.key === "Escape") {
9085
+ event.preventDefault();
9086
+ setOpen(false);
9087
+ }
9088
+ }
9089
+ triggerOnKeyDown?.(event);
9090
+ }, [disabled, focusMenuItem, getEnabledMenuItems, setOpen, triggerOnKeyDown]);
9091
+ const handleTriggerClick = import_react17.default.useCallback((event) => {
9092
+ if (openOnHover && !disabled) {
9093
+ cancelHoverClose();
9094
+ setOpen(true);
9095
+ }
9096
+ triggerOnClick?.(event);
9097
+ }, [cancelHoverClose, disabled, openOnHover, setOpen, triggerOnClick]);
9098
+ const handleTriggerMouseEnter = import_react17.default.useCallback((event) => {
9099
+ if (openOnHover && !disabled) {
9100
+ cancelHoverClose();
9101
+ parentMenu?.cancelHoverClose();
9102
+ setOpen(true);
9103
+ }
9104
+ triggerOnMouseEnter?.(event);
9105
+ }, [cancelHoverClose, disabled, openOnHover, parentMenu, setOpen, triggerOnMouseEnter]);
9106
+ const handleTriggerMouseLeave = import_react17.default.useCallback((event) => {
9107
+ scheduleHoverClose();
9108
+ triggerOnMouseLeave?.(event);
9109
+ }, [scheduleHoverClose, triggerOnMouseLeave]);
9003
9110
  const enhancedTrigger = import_react17.default.cloneElement(trigger, {
9004
9111
  ...triggerProps,
9005
- ref: mergeRefs(childRef, (node) => {
9006
- triggerRef.current = node;
9007
- }),
9112
+ ref: setTriggerNode,
9008
9113
  "aria-haspopup": "menu",
9009
9114
  "aria-expanded": open,
9010
- onKeyDown: chainEventHandlers((e) => {
9011
- triggerRef.current = e.currentTarget;
9012
- if (!disabled) {
9013
- if (e.key === "ArrowDown") {
9014
- e.preventDefault();
9015
- setOpen(true);
9016
- requestAnimationFrame(() => focusMenuItem(0));
9017
- } else if (e.key === "ArrowUp") {
9018
- e.preventDefault();
9019
- setOpen(true);
9020
- requestAnimationFrame(() => {
9021
- const enabled = getEnabledMenuItems();
9022
- focusMenuItem(enabled.length - 1);
9023
- });
9024
- } else if (e.key === "Escape") {
9025
- e.preventDefault();
9026
- setOpen(false);
9027
- }
9028
- }
9029
- }, triggerProps.onKeyDown),
9030
- onFocus: chainEventHandlers((e) => {
9031
- triggerRef.current = e.currentTarget;
9032
- }, triggerProps.onFocus)
9115
+ onKeyDown: handleTriggerKeyDown,
9116
+ onClick: handleTriggerClick,
9117
+ onMouseEnter: handleTriggerMouseEnter,
9118
+ onMouseLeave: handleTriggerMouseLeave
9033
9119
  });
9034
9120
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
9035
9121
  Popover,
@@ -9127,6 +9213,7 @@ var DropdownMenuSub = ({ label, icon: Icon, disabled, borderMode, children }) =>
9127
9213
  }
9128
9214
  ),
9129
9215
  placement: "right",
9216
+ openOnHover: true,
9130
9217
  children
9131
9218
  }
9132
9219
  );
@@ -28048,11 +28135,11 @@ function useLocale2() {
28048
28135
  }
28049
28136
 
28050
28137
  // src/components/UEditor/UEditor.tsx
28051
- var import_react84 = __toESM(require("react"), 1);
28052
- var import_react85 = require("@tiptap/react");
28138
+ var import_react85 = __toESM(require("react"), 1);
28139
+ var import_react86 = require("@tiptap/react");
28053
28140
 
28054
28141
  // src/components/UEditor/extensions.ts
28055
- var import_core16 = require("@tiptap/core");
28142
+ var import_core17 = require("@tiptap/core");
28056
28143
  var import_extension_document = __toESM(require("@tiptap/extension-document"), 1);
28057
28144
  var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"), 1);
28058
28145
  var import_extension_text = __toESM(require("@tiptap/extension-text"), 1);
@@ -28068,7 +28155,7 @@ var import_extension_task_list = __toESM(require("@tiptap/extension-task-list"),
28068
28155
  var import_extension_task_item = __toESM(require("@tiptap/extension-task-item"), 1);
28069
28156
  var import_extension_blockquote = __toESM(require("@tiptap/extension-blockquote"), 1);
28070
28157
  var import_extension_code = __toESM(require("@tiptap/extension-code"), 1);
28071
- var import_core17 = require("@tiptap/core");
28158
+ var import_core18 = require("@tiptap/core");
28072
28159
  var import_react68 = require("@tiptap/react");
28073
28160
 
28074
28161
  // src/components/UEditor/callout.ts
@@ -31581,15 +31668,208 @@ var LetterSpacing = import_core15.Extension.create({
31581
31668
  });
31582
31669
  var letter_spacing_default = LetterSpacing;
31583
31670
 
31671
+ // src/components/UEditor/indent.ts
31672
+ var import_core16 = require("@tiptap/core");
31673
+ var import_tables = require("@tiptap/pm/tables");
31674
+ var DEFAULT_MAX_LEVEL = 6;
31675
+ var DEFAULT_MIN_LEVEL = 0;
31676
+ var DEFAULT_STEP_REM = 2;
31677
+ var INLINE_TAB_SPACES = "\xA0".repeat(4);
31678
+ var LIST_ITEM_TYPES = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
31679
+ var TABLE_CELL_TYPES = /* @__PURE__ */ new Set(["tableCell", "tableHeader"]);
31680
+ function clampIndentLevel(value, minLevel, maxLevel) {
31681
+ const numericValue = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
31682
+ if (!Number.isFinite(numericValue)) return minLevel;
31683
+ return Math.min(maxLevel, Math.max(minLevel, Math.round(numericValue)));
31684
+ }
31685
+ function parseIndentLevel(element, options) {
31686
+ const dataIndent = element.getAttribute("data-indent");
31687
+ if (dataIndent !== null) {
31688
+ return clampIndentLevel(dataIndent, options.minLevel, options.maxLevel);
31689
+ }
31690
+ const marginLeft = element.style.marginLeft.trim();
31691
+ const match = marginLeft.match(/^(-?\d+(?:\.\d+)?)(rem|em|px)$/i);
31692
+ if (!match) return options.minLevel;
31693
+ const value = Number.parseFloat(match[1] ?? "0");
31694
+ const unit = match[2]?.toLowerCase();
31695
+ const remValue = unit === "px" ? value / 16 : value;
31696
+ return clampIndentLevel(remValue / options.stepRem, options.minLevel, options.maxLevel);
31697
+ }
31698
+ function getNodePos($pos, depth) {
31699
+ return depth > 0 ? $pos.before(depth) : 0;
31700
+ }
31701
+ function getIndentTargetAt($pos, indentTypes) {
31702
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
31703
+ const nodeName = $pos.node(depth).type.name;
31704
+ if (LIST_ITEM_TYPES.has(nodeName) || TABLE_CELL_TYPES.has(nodeName)) return null;
31705
+ }
31706
+ if (indentTypes.has("blockquote")) {
31707
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
31708
+ const node = $pos.node(depth);
31709
+ if (node.type.name === "blockquote") {
31710
+ return { node, pos: getNodePos($pos, depth) };
31711
+ }
31712
+ }
31713
+ }
31714
+ for (let depth = $pos.depth; depth > 0; depth -= 1) {
31715
+ const node = $pos.node(depth);
31716
+ if (indentTypes.has(node.type.name)) {
31717
+ return { node, pos: getNodePos($pos, depth) };
31718
+ }
31719
+ }
31720
+ return null;
31721
+ }
31722
+ function getIndentTargets(state, types) {
31723
+ if ((0, import_tables.isInTable)(state)) return [];
31724
+ const indentTypes = new Set(types);
31725
+ const targets = /* @__PURE__ */ new Map();
31726
+ const addTarget = (target) => {
31727
+ if (target) targets.set(target.pos, target);
31728
+ };
31729
+ addTarget(getIndentTargetAt(state.selection.$from, indentTypes));
31730
+ addTarget(getIndentTargetAt(state.selection.$to, indentTypes));
31731
+ if (!state.selection.empty) {
31732
+ state.doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
31733
+ if (!indentTypes.has(node.type.name)) return true;
31734
+ const resolvedPos = state.doc.resolve(Math.min(pos + 1, state.doc.content.size));
31735
+ addTarget(getIndentTargetAt(resolvedPos, indentTypes));
31736
+ return node.type.name !== "blockquote";
31737
+ });
31738
+ }
31739
+ return Array.from(targets.values()).sort((a, b) => a.pos - b.pos);
31740
+ }
31741
+ function updateBlockIndent({
31742
+ state,
31743
+ dispatch,
31744
+ options,
31745
+ delta
31746
+ }) {
31747
+ const targets = getIndentTargets(state, options.types);
31748
+ let transaction = state.tr;
31749
+ let changed = false;
31750
+ for (const target of targets) {
31751
+ const currentLevel = clampIndentLevel(target.node.attrs.indent, options.minLevel, options.maxLevel);
31752
+ const nextLevel = clampIndentLevel(currentLevel + delta, options.minLevel, options.maxLevel);
31753
+ if (nextLevel === currentLevel) continue;
31754
+ transaction = transaction.setNodeMarkup(target.pos, void 0, {
31755
+ ...target.node.attrs,
31756
+ indent: nextLevel
31757
+ });
31758
+ changed = true;
31759
+ }
31760
+ if (changed && dispatch) dispatch(transaction.scrollIntoView());
31761
+ return changed;
31762
+ }
31763
+ function insertTabAtCursor(state, dispatch) {
31764
+ if (!state.selection.empty) return false;
31765
+ if (dispatch) {
31766
+ dispatch(state.tr.insertText(INLINE_TAB_SPACES, state.selection.from).scrollIntoView());
31767
+ }
31768
+ return true;
31769
+ }
31770
+ function removeTabBeforeCursor(state, dispatch) {
31771
+ if (!state.selection.empty || state.selection.$from.parentOffset <= 0) return false;
31772
+ const cursorPos = state.selection.from;
31773
+ const tabStartPos = cursorPos - INLINE_TAB_SPACES.length;
31774
+ if (tabStartPos < 0 || state.doc.textBetween(tabStartPos, cursorPos) !== INLINE_TAB_SPACES) return false;
31775
+ if (dispatch) {
31776
+ dispatch(state.tr.delete(tabStartPos, cursorPos).scrollIntoView());
31777
+ }
31778
+ return true;
31779
+ }
31780
+ var Indent = import_core16.Extension.create({
31781
+ name: "indent",
31782
+ addOptions() {
31783
+ return {
31784
+ maxLevel: DEFAULT_MAX_LEVEL,
31785
+ minLevel: DEFAULT_MIN_LEVEL,
31786
+ stepRem: DEFAULT_STEP_REM,
31787
+ types: ["paragraph", "blockquote"]
31788
+ };
31789
+ },
31790
+ addGlobalAttributes() {
31791
+ return [
31792
+ {
31793
+ types: this.options.types,
31794
+ attributes: {
31795
+ indent: {
31796
+ default: this.options.minLevel,
31797
+ parseHTML: (element) => parseIndentLevel(element, this.options),
31798
+ renderHTML: (attributes) => {
31799
+ const level = clampIndentLevel(attributes.indent, this.options.minLevel, this.options.maxLevel);
31800
+ if (level <= this.options.minLevel) return {};
31801
+ return {
31802
+ "data-indent": String(level),
31803
+ style: `margin-left: ${level * this.options.stepRem}rem`
31804
+ };
31805
+ }
31806
+ }
31807
+ }
31808
+ }
31809
+ ];
31810
+ },
31811
+ addCommands() {
31812
+ return {
31813
+ increaseIndent: () => ({ editor, commands, state, dispatch }) => {
31814
+ if (editor.isActive("taskItem")) return commands.sinkListItem("taskItem");
31815
+ if (editor.isActive("listItem")) return commands.sinkListItem("listItem");
31816
+ return updateBlockIndent({
31817
+ state,
31818
+ dispatch,
31819
+ options: this.options,
31820
+ delta: 1
31821
+ });
31822
+ },
31823
+ decreaseIndent: () => ({ editor, commands, state, dispatch }) => {
31824
+ if (editor.isActive("taskItem")) return commands.liftListItem("taskItem");
31825
+ if (editor.isActive("listItem")) return commands.liftListItem("listItem");
31826
+ return updateBlockIndent({
31827
+ state,
31828
+ dispatch,
31829
+ options: this.options,
31830
+ delta: -1
31831
+ });
31832
+ }
31833
+ };
31834
+ },
31835
+ addKeyboardShortcuts() {
31836
+ const handleBlockIndent = (delta) => {
31837
+ const { state } = this.editor;
31838
+ const hasBlockTarget = getIndentTargets(state, this.options.types).length > 0;
31839
+ if (!hasBlockTarget) {
31840
+ return delta > 0 ? this.editor.commands.increaseIndent() : this.editor.commands.decreaseIndent();
31841
+ }
31842
+ if (state.selection.empty && state.selection.$from.parentOffset > 0) {
31843
+ if (delta > 0) {
31844
+ return insertTabAtCursor(state, (transaction) => this.editor.view.dispatch(transaction));
31845
+ }
31846
+ removeTabBeforeCursor(state, (transaction) => this.editor.view.dispatch(transaction));
31847
+ return true;
31848
+ }
31849
+ if (delta > 0) {
31850
+ this.editor.commands.increaseIndent();
31851
+ } else {
31852
+ this.editor.commands.decreaseIndent();
31853
+ }
31854
+ return true;
31855
+ };
31856
+ return {
31857
+ Tab: () => handleBlockIndent(1),
31858
+ "Shift-Tab": () => handleBlockIndent(-1)
31859
+ };
31860
+ }
31861
+ });
31862
+ var indent_default = Indent;
31863
+
31584
31864
  // src/components/UEditor/table-align.ts
31585
31865
  var import_extension_table = require("@tiptap/extension-table");
31586
31866
  var import_state7 = require("@tiptap/pm/state");
31587
- var import_tables2 = require("@tiptap/pm/tables");
31867
+ var import_tables3 = require("@tiptap/pm/tables");
31588
31868
 
31589
31869
  // src/components/UEditor/table-column-resize.ts
31590
31870
  var import_state6 = require("@tiptap/pm/state");
31591
31871
  var import_view2 = require("@tiptap/pm/view");
31592
- var import_tables = require("@tiptap/pm/tables");
31872
+ var import_tables2 = require("@tiptap/pm/tables");
31593
31873
  var DEFAULT_TABLE_COLUMN_WIDTH = 100;
31594
31874
  var MIN_RESIZED_TABLE_COLUMN_WIDTH = 25;
31595
31875
  function getDynamicColumnMinWidth(startWidth, fallbackMinWidth) {
@@ -31709,20 +31989,20 @@ function edgeCell(view, event, side, handleWidth) {
31709
31989
  top: event.clientY
31710
31990
  });
31711
31991
  if (!found2) return -1;
31712
- const $cell = (0, import_tables.cellAround)(view.state.doc.resolve(found2.pos));
31992
+ const $cell = (0, import_tables2.cellAround)(view.state.doc.resolve(found2.pos));
31713
31993
  if (!$cell) return -1;
31714
31994
  if (side === "right") return $cell.pos;
31715
- const map = import_tables.TableMap.get($cell.node(-1));
31995
+ const map = import_tables2.TableMap.get($cell.node(-1));
31716
31996
  const start = $cell.start(-1);
31717
31997
  const index = map.map.indexOf($cell.pos - start);
31718
31998
  return index % map.width === 0 ? -1 : start + map.map[index - 1];
31719
31999
  }
31720
32000
  function updateHandle(view, value) {
31721
- view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setHandle: value }));
32001
+ view.dispatch(view.state.tr.setMeta(import_tables2.columnResizingPluginKey, { setHandle: value }));
31722
32002
  }
31723
32003
  function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
31724
32004
  if (!view.editable) return;
31725
- const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
32005
+ const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
31726
32006
  if (!pluginState || pluginState.dragging) return;
31727
32007
  const target = domCellAround(event.target);
31728
32008
  let cell = -1;
@@ -31735,7 +32015,7 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
31735
32015
  if (!lastColumnResizable && cell !== -1) {
31736
32016
  const $cell = view.state.doc.resolve(cell);
31737
32017
  const table = $cell.node(-1);
31738
- const map = import_tables.TableMap.get(table);
32018
+ const map = import_tables2.TableMap.get(table);
31739
32019
  const tableStart = $cell.start(-1);
31740
32020
  const nodeAfter = $cell.nodeAfter;
31741
32021
  if (!nodeAfter) return;
@@ -31745,7 +32025,7 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
31745
32025
  }
31746
32026
  function handleMouseLeave(view) {
31747
32027
  if (!view.editable) return;
31748
- const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
32028
+ const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
31749
32029
  if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
31750
32030
  updateHandle(view, -1);
31751
32031
  }
@@ -31753,7 +32033,7 @@ function handleMouseLeave(view) {
31753
32033
  function updateColumnWidth(view, cell, width) {
31754
32034
  const $cell = view.state.doc.resolve(cell);
31755
32035
  const table = $cell.node(-1);
31756
- const map = import_tables.TableMap.get(table);
32036
+ const map = import_tables2.TableMap.get(table);
31757
32037
  const start = $cell.start(-1);
31758
32038
  const nodeAfter = $cell.nodeAfter;
31759
32039
  if (!nodeAfter) return;
@@ -31778,7 +32058,7 @@ function updateColumnWidth(view, cell, width) {
31778
32058
  if (tr.docChanged) view.dispatch(tr);
31779
32059
  }
31780
32060
  function getActiveDragging(state) {
31781
- const dragging = import_tables.columnResizingPluginKey.getState(state)?.dragging;
32061
+ const dragging = import_tables2.columnResizingPluginKey.getState(state)?.dragging;
31782
32062
  return dragging ? dragging : null;
31783
32063
  }
31784
32064
  function getColumnResizeGhost(view) {
@@ -31823,7 +32103,7 @@ function showColumnResizeGhost(view, cell, dragging, width) {
31823
32103
  function handleMouseDown(view, event, cellMinWidth) {
31824
32104
  if (!view.editable) return false;
31825
32105
  const win = view.dom.ownerDocument.defaultView ?? window;
31826
- const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
32106
+ const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
31827
32107
  if (!pluginState || pluginState.activeHandle === -1 || pluginState.dragging) return false;
31828
32108
  const cell = view.state.doc.nodeAt(pluginState.activeHandle);
31829
32109
  if (!cell) return false;
@@ -31838,22 +32118,22 @@ function handleMouseDown(view, event, cellMinWidth) {
31838
32118
  startWidth: width,
31839
32119
  minWidth
31840
32120
  };
31841
- view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setDragging: dragging }));
32121
+ view.dispatch(view.state.tr.setMeta(import_tables2.columnResizingPluginKey, { setDragging: dragging }));
31842
32122
  function finish(nextEvent) {
31843
32123
  win.removeEventListener("mouseup", finish);
31844
32124
  win.removeEventListener("mousemove", move);
31845
32125
  const activeDragging = getActiveDragging(view.state);
31846
- const activeHandle = import_tables.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
32126
+ const activeHandle = import_tables2.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
31847
32127
  if (activeDragging && activeHandle > -1) {
31848
32128
  updateColumnWidth(view, activeHandle, getDraggedWidth(activeDragging, nextEvent));
31849
- view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setDragging: null }));
32129
+ view.dispatch(view.state.tr.setMeta(import_tables2.columnResizingPluginKey, { setDragging: null }));
31850
32130
  }
31851
32131
  hideColumnResizeGhost(view);
31852
32132
  }
31853
32133
  function move(nextEvent) {
31854
32134
  if (!nextEvent.buttons) return finish(nextEvent);
31855
32135
  const activeDragging = getActiveDragging(view.state);
31856
- const activeHandle = import_tables.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
32136
+ const activeHandle = import_tables2.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
31857
32137
  if (activeDragging && activeHandle > -1) {
31858
32138
  showColumnResizeGhost(view, activeHandle, activeDragging, getDraggedWidth(activeDragging, nextEvent));
31859
32139
  }
@@ -31869,7 +32149,7 @@ function handleDecorations(state, cell) {
31869
32149
  const $cell = state.doc.resolve(cell);
31870
32150
  const table = $cell.node(-1);
31871
32151
  if (!table) return import_view2.DecorationSet.empty;
31872
- const map = import_tables.TableMap.get(table);
32152
+ const map = import_tables2.TableMap.get(table);
31873
32153
  const start = $cell.start(-1);
31874
32154
  const nodeAfter = $cell.nodeAfter;
31875
32155
  if (!nodeAfter) return import_view2.DecorationSet.empty;
@@ -31883,7 +32163,7 @@ function handleDecorations(state, cell) {
31883
32163
  const pos = start + cellPos + cellNode.nodeSize - 1;
31884
32164
  const dom = document.createElement("div");
31885
32165
  dom.className = "column-resize-handle";
31886
- if (import_tables.columnResizingPluginKey.getState(state)?.dragging) {
32166
+ if (import_tables2.columnResizingPluginKey.getState(state)?.dragging) {
31887
32167
  decorations.push(import_view2.Decoration.node(start + cellPos, start + cellPos + cellNode.nodeSize, { class: "column-resize-dragging" }));
31888
32168
  }
31889
32169
  decorations.push(import_view2.Decoration.widget(pos, dom));
@@ -31899,15 +32179,15 @@ function dynamicColumnResizing({
31899
32179
  lastColumnResizable = true
31900
32180
  } = {}) {
31901
32181
  const plugin = new import_state6.Plugin({
31902
- key: import_tables.columnResizingPluginKey,
32182
+ key: import_tables2.columnResizingPluginKey,
31903
32183
  state: {
31904
32184
  init(_, state) {
31905
32185
  const nodeViews = plugin.spec.props?.nodeViews;
31906
- const tableName = (0, import_tables.tableNodeTypes)(state.schema).table.name;
32186
+ const tableName = (0, import_tables2.tableNodeTypes)(state.schema).table.name;
31907
32187
  if (View && nodeViews) {
31908
32188
  nodeViews[tableName] = (node, view) => new View(node, defaultCellMinWidth, view);
31909
32189
  }
31910
- return new import_tables.ResizeState(-1, false);
32190
+ return new import_tables2.ResizeState(-1, false);
31911
32191
  },
31912
32192
  apply(tr, prev) {
31913
32193
  return prev.apply(tr);
@@ -31915,7 +32195,7 @@ function dynamicColumnResizing({
31915
32195
  },
31916
32196
  props: {
31917
32197
  attributes: (state) => {
31918
- const pluginState = import_tables.columnResizingPluginKey.getState(state);
32198
+ const pluginState = import_tables2.columnResizingPluginKey.getState(state);
31919
32199
  return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
31920
32200
  },
31921
32201
  handleDOMEvents: {
@@ -31928,7 +32208,7 @@ function dynamicColumnResizing({
31928
32208
  mousedown: (view, event) => handleMouseDown(view, event, cellMinWidth)
31929
32209
  },
31930
32210
  decorations: (state) => {
31931
- const pluginState = import_tables.columnResizingPluginKey.getState(state);
32211
+ const pluginState = import_tables2.columnResizingPluginKey.getState(state);
31932
32212
  if (pluginState && pluginState.activeHandle > -1) {
31933
32213
  return handleDecorations(state, pluginState.activeHandle);
31934
32214
  }
@@ -32085,7 +32365,7 @@ var UEditorTable = import_extension_table.Table.extend({
32085
32365
  lastColumnResizable: this.options.lastColumnResizable
32086
32366
  })
32087
32367
  ] : [],
32088
- (0, import_tables2.tableEditing)({
32368
+ (0, import_tables3.tableEditing)({
32089
32369
  allowTableNodeSelection: this.options.allowTableNodeSelection
32090
32370
  }),
32091
32371
  new import_state7.Plugin({
@@ -32354,7 +32634,7 @@ var CustomTableCell = import_extension_table_cell.default.extend({
32354
32634
  mergedStyle = mergedStyle.replace(/^;/, "").trim();
32355
32635
  return [
32356
32636
  "td",
32357
- (0, import_core16.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
32637
+ (0, import_core17.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
32358
32638
  0
32359
32639
  ];
32360
32640
  }
@@ -32480,7 +32760,7 @@ var CustomTableHeader = import_extension_table_header.default.extend({
32480
32760
  mergedStyle = mergedStyle.replace(/^;/, "").trim();
32481
32761
  return [
32482
32762
  "th",
32483
- (0, import_core16.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
32763
+ (0, import_core17.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
32484
32764
  0
32485
32765
  ];
32486
32766
  }
@@ -32488,15 +32768,15 @@ var CustomTableHeader = import_extension_table_header.default.extend({
32488
32768
  var CustomTaskList = import_extension_task_list.default.extend({
32489
32769
  addInputRules() {
32490
32770
  return [
32491
- (0, import_core17.wrappingInputRule)({
32771
+ (0, import_core18.wrappingInputRule)({
32492
32772
  find: /^\s*(\[ \]|\[\])\s$/,
32493
32773
  type: this.type
32494
32774
  }),
32495
- (0, import_core17.wrappingInputRule)({
32775
+ (0, import_core18.wrappingInputRule)({
32496
32776
  find: /^\s*(-\s*\[ \]|-\s*\[\])\s$/,
32497
32777
  type: this.type
32498
32778
  }),
32499
- (0, import_core17.wrappingInputRule)({
32779
+ (0, import_core18.wrappingInputRule)({
32500
32780
  find: /^\s*(\*\s*\[ \]|-\s*\[\])\s$/,
32501
32781
  type: this.type
32502
32782
  })
@@ -32592,6 +32872,7 @@ function buildUEditorExtensions({
32592
32872
  font_size_default,
32593
32873
  line_height_default,
32594
32874
  letter_spacing_default,
32875
+ indent_default,
32595
32876
  import_extension_color.default,
32596
32877
  import_extension_highlight.default.configure({
32597
32878
  multicolor: true
@@ -32659,7 +32940,7 @@ function buildUEditorExtensions({
32659
32940
  var import_react72 = __toESM(require("react"), 1);
32660
32941
  var import_react73 = require("@tiptap/react");
32661
32942
  var import_lucide_react52 = require("lucide-react");
32662
- var import_tables4 = require("@tiptap/pm/tables");
32943
+ var import_tables5 = require("@tiptap/pm/tables");
32663
32944
 
32664
32945
  // src/components/UEditor/colors.tsx
32665
32946
  var import_react70 = require("react");
@@ -33316,7 +33597,7 @@ function applyEditorLink(editor, href) {
33316
33597
 
33317
33598
  // src/components/UEditor/table-cell-commands.ts
33318
33599
  var import_state10 = require("@tiptap/pm/state");
33319
- var import_tables3 = require("@tiptap/pm/tables");
33600
+ var import_tables4 = require("@tiptap/pm/tables");
33320
33601
  function getCellSelectionPositions(selection) {
33321
33602
  const value = selection;
33322
33603
  const anchor = value.$anchorCell?.pos;
@@ -33408,7 +33689,7 @@ function getSelectedTableRect(editor) {
33408
33689
  if (cellSelection) {
33409
33690
  const tableInfo = findTableInfoFromCellPos(editor, cellSelection.anchor);
33410
33691
  if (tableInfo) {
33411
- const map = import_tables3.TableMap.get(tableInfo.table);
33692
+ const map = import_tables4.TableMap.get(tableInfo.table);
33412
33693
  const rect = map.rectBetween(
33413
33694
  cellSelection.anchor - tableInfo.tableStart,
33414
33695
  cellSelection.head - tableInfo.tableStart
@@ -33421,7 +33702,7 @@ function getSelectedTableRect(editor) {
33421
33702
  };
33422
33703
  }
33423
33704
  }
33424
- return (0, import_tables3.selectedRect)(editor.state);
33705
+ return (0, import_tables4.selectedRect)(editor.state);
33425
33706
  }
33426
33707
  function parsePixelWidth(value) {
33427
33708
  if (!value) return null;
@@ -33504,7 +33785,7 @@ function runTableCommandAtCellPos(editor, cellPos, command) {
33504
33785
  function getTableCornerCellPos(editor, activePos) {
33505
33786
  const tableInfo = findTableInfoFromCellPos(editor, activePos);
33506
33787
  if (!tableInfo) return null;
33507
- const map = import_tables3.TableMap.get(tableInfo.table);
33788
+ const map = import_tables4.TableMap.get(tableInfo.table);
33508
33789
  return tableInfo.tableStart + map.positionAt(map.height - 1, map.width - 1, tableInfo.table);
33509
33790
  }
33510
33791
  function replaceTableAtCellPos(editor, cellPos, updateTable) {
@@ -33528,7 +33809,7 @@ function duplicateTableRowAt(editor, rowIndex, cellPos) {
33528
33809
  }
33529
33810
  function clearTableRowAt(editor, rowIndex, cellPos) {
33530
33811
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
33531
- const map = import_tables3.TableMap.get(tableNode);
33812
+ const map = import_tables4.TableMap.get(tableNode);
33532
33813
  if (rowIndex < 0 || rowIndex >= map.height) return null;
33533
33814
  const rows = getTableRows(tableNode).map((rowInfo) => {
33534
33815
  const cells = collectChildren(rowInfo.node);
@@ -33544,7 +33825,7 @@ function clearTableRowAt(editor, rowIndex, cellPos) {
33544
33825
  }
33545
33826
  function duplicateTableColumnAt(editor, columnIndex, cellPos) {
33546
33827
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
33547
- const map = import_tables3.TableMap.get(tableNode);
33828
+ const map = import_tables4.TableMap.get(tableNode);
33548
33829
  if (columnIndex < 0 || columnIndex >= map.width) return null;
33549
33830
  const rows = getTableRows(tableNode).map((rowInfo, rowIndex) => {
33550
33831
  const cells = collectChildren(rowInfo.node);
@@ -33566,7 +33847,7 @@ function duplicateTableColumnAt(editor, columnIndex, cellPos) {
33566
33847
  }
33567
33848
  function clearTableColumnAt(editor, columnIndex, cellPos) {
33568
33849
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
33569
- const map = import_tables3.TableMap.get(tableNode);
33850
+ const map = import_tables4.TableMap.get(tableNode);
33570
33851
  if (columnIndex < 0 || columnIndex >= map.width) return null;
33571
33852
  const rows = getTableRows(tableNode).map((rowInfo) => {
33572
33853
  const cells = collectChildren(rowInfo.node);
@@ -33696,6 +33977,77 @@ function getTableAnchorPos(editor) {
33696
33977
  const firstCell = tables[0]?.querySelector("th,td");
33697
33978
  return firstCell instanceof HTMLTableCellElement ? editor.view.posAtDOM(firstCell, 0) + 1 : null;
33698
33979
  }
33980
+ var EDITOR_UI_ACTIVE_MARKS = [
33981
+ "blockquote",
33982
+ "bold",
33983
+ "bulletList",
33984
+ "code",
33985
+ "codeBlock",
33986
+ "formCheckbox",
33987
+ "highlight",
33988
+ "image",
33989
+ "italic",
33990
+ "link",
33991
+ "orderedList",
33992
+ "paragraph",
33993
+ "strike",
33994
+ "subscript",
33995
+ "superscript",
33996
+ "taskList",
33997
+ "underline"
33998
+ ];
33999
+ function getEditorUiRenderState(editor) {
34000
+ const textStyle = editor.getAttributes("textStyle");
34001
+ const highlight = editor.getAttributes("highlight");
34002
+ const image = editor.getAttributes("image");
34003
+ const link = editor.getAttributes("link");
34004
+ const tableCell = editor.getAttributes("tableCell");
34005
+ const tableHeader = editor.getAttributes("tableHeader");
34006
+ const hasTableContext = getTableAnchorPos(editor) !== null;
34007
+ const can = editor.can();
34008
+ return {
34009
+ active: EDITOR_UI_ACTIVE_MARKS.map((name) => editor.isActive(name)),
34010
+ alignment: ["left", "center", "right", "justify"].map((textAlign) => editor.isActive({ textAlign })),
34011
+ heading: [1, 2, 3].map((level) => editor.isActive("heading", { level })),
34012
+ textStyle: {
34013
+ color: textStyle.color ?? null,
34014
+ fontFamily: textStyle.fontFamily ?? null,
34015
+ fontSize: textStyle.fontSize ?? null,
34016
+ letterSpacing: textStyle.letterSpacing ?? null,
34017
+ lineHeight: textStyle.lineHeight ?? null
34018
+ },
34019
+ highlightColor: highlight.color ?? null,
34020
+ image: {
34021
+ imageLayout: image.imageLayout ?? null,
34022
+ imageWidthPreset: image.imageWidthPreset ?? null
34023
+ },
34024
+ linkHref: link.href ?? null,
34025
+ tableCell: {
34026
+ backgroundColor: tableCell.backgroundColor ?? tableHeader.backgroundColor ?? null,
34027
+ borderColor: tableCell.borderColor ?? tableHeader.borderColor ?? null,
34028
+ borderStyle: tableCell.borderStyle ?? tableHeader.borderStyle ?? null,
34029
+ borderWidth: tableCell.borderWidth ?? tableHeader.borderWidth ?? null,
34030
+ formula: tableCell.formula ?? tableHeader.formula ?? null,
34031
+ numberFormat: tableCell.numberFormat ?? tableHeader.numberFormat ?? null,
34032
+ textDirection: tableCell.textDirection ?? tableHeader.textDirection ?? null,
34033
+ verticalAlign: tableCell.verticalAlign ?? tableHeader.verticalAlign ?? null
34034
+ },
34035
+ can: {
34036
+ addColumnAfter: hasTableContext && can.addColumnAfter(),
34037
+ addColumnBefore: hasTableContext && can.addColumnBefore(),
34038
+ addRowAfter: hasTableContext && can.addRowAfter(),
34039
+ addRowBefore: hasTableContext && can.addRowBefore(),
34040
+ decreaseIndent: can.decreaseIndent(),
34041
+ increaseIndent: can.increaseIndent(),
34042
+ mergeCells: hasTableContext && can.mergeCells(),
34043
+ redo: can.redo(),
34044
+ splitCell: hasTableContext && can.splitCell(),
34045
+ undo: can.undo()
34046
+ },
34047
+ hasTableContext,
34048
+ isEmpty: editor.isEmpty
34049
+ };
34050
+ }
33699
34051
  function fileToDataUrl2(file) {
33700
34052
  return new Promise((resolve, reject) => {
33701
34053
  const reader = new FileReader();
@@ -33721,10 +34073,10 @@ var ToolbarButton = import_react72.default.forwardRef(({ onClick, onMouseDown, a
33721
34073
  onClick,
33722
34074
  disabled,
33723
34075
  className: cn(
33724
- "flex h-8 w-8 shrink-0 items-center justify-center rounded-md transition-colors duration-150 cursor-pointer",
33725
- "gap-0.5 [&_svg+svg]:-ml-1",
34076
+ "flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors duration-150",
34077
+ "gap-0.5 [&>svg]:h-3.5 [&>svg]:w-3.5 [&>svg]:shrink-0",
33726
34078
  "hover:bg-accent",
33727
- "focus:outline-none focus:ring-2 focus:ring-primary/20",
34079
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/20",
33728
34080
  "disabled:opacity-40 disabled:cursor-not-allowed",
33729
34081
  active ? "bg-primary/10 text-primary shadow-sm" : "text-[#7B8184] hover:text-foreground dark:text-muted-foreground",
33730
34082
  className
@@ -33738,7 +34090,7 @@ var ToolbarButton = import_react72.default.forwardRef(({ onClick, onMouseDown, a
33738
34090
  return button;
33739
34091
  });
33740
34092
  ToolbarButton.displayName = "ToolbarButton";
33741
- var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { "aria-hidden": "true", className: "mx-2 h-9 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
34093
+ var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { "aria-hidden": "true", className: "mx-1.5 h-7 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
33742
34094
  var TableInsertGrid = ({
33743
34095
  insertLabel,
33744
34096
  previewTemplate,
@@ -33749,7 +34101,7 @@ var TableInsertGrid = ({
33749
34101
  const maxCols = 8;
33750
34102
  return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: "mb-2 rounded-xl border border-border/60 bg-muted/20 p-2", children: [
33751
34103
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "mb-2 text-sm font-medium text-foreground", children: formatTableInsertLabel(previewTemplate, selection.rows, selection.cols) }),
33752
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "grid grid-cols-8 gap-1", onMouseLeave: () => setSelection((prev) => prev), children: Array.from({ length: maxRows }).map(
34104
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "grid grid-cols-8 gap-1", children: Array.from({ length: maxRows }).map(
33753
34105
  (_, rowIndex) => Array.from({ length: maxCols }).map((__, colIndex) => {
33754
34106
  const rows = rowIndex + 1;
33755
34107
  const cols = colIndex + 1;
@@ -33777,7 +34129,7 @@ var TableInsertGrid = ({
33777
34129
  };
33778
34130
  function applyTableCellAttribute(editor, name, value) {
33779
34131
  const { state, view } = editor;
33780
- const applied = (0, import_tables4.setCellAttr)(name, value)(state, view.dispatch.bind(view));
34132
+ const applied = (0, import_tables5.setCellAttr)(name, value)(state, view.dispatch.bind(view));
33781
34133
  if (applied) {
33782
34134
  view.focus();
33783
34135
  return;
@@ -33797,15 +34149,14 @@ var EditorToolbar = ({
33797
34149
  letterSpacings
33798
34150
  }) => {
33799
34151
  const t = useSmartTranslations("UEditor");
33800
- (0, import_react73.useEditorState)({
34152
+ const editorUiState = (0, import_react73.useEditorState)({
33801
34153
  editor,
33802
- selector: ({ transactionNumber }) => transactionNumber
34154
+ selector: ({ editor: currentEditor }) => getEditorUiRenderState(currentEditor)
33803
34155
  });
33804
34156
  const { textColors, highlightColors } = useEditorColors();
33805
34157
  const [showImageInput, setShowImageInput] = (0, import_react72.useState)(false);
33806
34158
  const [showLinkInput, setShowLinkInput] = (0, import_react72.useState)(false);
33807
34159
  const [isTableMenuOpen, setIsTableMenuOpen] = (0, import_react72.useState)(false);
33808
- const [preservedTableAnchorPos, setPreservedTableAnchorPos] = (0, import_react72.useState)(null);
33809
34160
  const fileInputRef = (0, import_react72.useRef)(null);
33810
34161
  const [isUploadingImage, setIsUploadingImage] = (0, import_react72.useState)(false);
33811
34162
  const [imageUploadError, setImageUploadError] = (0, import_react72.useState)(null);
@@ -33813,14 +34164,11 @@ var EditorToolbar = ({
33813
34164
  const imageAttrs = editor.getAttributes("image");
33814
34165
  const tableAnchorPos = getTableAnchorPos(editor);
33815
34166
  const tableInfo = tableAnchorPos == null ? null : findTableNodeInfoFromState(editor.state, tableAnchorPos);
33816
- const tableAttrs = tableInfo?.node.attrs ?? editor.getAttributes("table");
33817
34167
  const textStyleAttrs = editor.getAttributes("textStyle");
33818
34168
  const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
33819
34169
  const imageWidthPreset = imageAttrs.imageWidthPreset === "sm" || imageAttrs.imageWidthPreset === "md" || imageAttrs.imageWidthPreset === "lg" ? imageAttrs.imageWidthPreset : null;
33820
- const tableAlignAttr = tableAttrs.tableAlign ?? tableAttrs.textAlign;
33821
- const currentTableAlign = tableAlignAttr === "center" || tableAlignAttr === "right" ? tableAlignAttr : "left";
33822
34170
  const isTableSelected = tableInfo !== null;
33823
- const hasTableContext = isTableSelected || preservedTableAnchorPos !== null;
34171
+ const hasTableContext = isTableSelected;
33824
34172
  const canMergeCells = hasTableContext && editor.can().mergeCells();
33825
34173
  const canSplitCell = hasTableContext && editor.can().splitCell();
33826
34174
  const currentCellVerticalAlign = normalizeStyleValue(editor.getAttributes("tableCell").verticalAlign || editor.getAttributes("tableHeader").verticalAlign) || "";
@@ -33846,7 +34194,6 @@ var EditorToolbar = ({
33846
34194
  const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
33847
34195
  const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
33848
34196
  const activeFontSize = currentFontSize || "13px";
33849
- const tableCommandAnchorPos = preservedTableAnchorPos ?? tableAnchorPos ?? void 0;
33850
34197
  const isMedium = variant === "medium";
33851
34198
  const isMediumFull = variant === "medium-full";
33852
34199
  const isFull = variant === "default" || variant === "full" || variant === "notion" || !variant;
@@ -33886,14 +34233,29 @@ var EditorToolbar = ({
33886
34233
  children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaListIcon, { className: "h-4 w-4" })
33887
34234
  }
33888
34235
  ),
34236
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34237
+ ToolbarButton,
34238
+ {
34239
+ onClick: () => editor.chain().focus().decreaseIndent().run(),
34240
+ disabled: !editorUiState.can.decreaseIndent,
34241
+ title: t("toolbar.decreaseIndent"),
34242
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.IndentDecrease, { className: "h-4 w-4" })
34243
+ }
34244
+ ),
34245
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34246
+ ToolbarButton,
34247
+ {
34248
+ onClick: () => editor.chain().focus().increaseIndent().run(),
34249
+ disabled: !editorUiState.can.increaseIndent,
34250
+ title: t("toolbar.increaseIndent"),
34251
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.IndentIncrease, { className: "h-4 w-4" })
34252
+ }
34253
+ ),
33889
34254
  /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
33890
34255
  DropdownMenu,
33891
34256
  {
33892
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
33893
- }, active: editor.isActive("formCheckbox"), title: t("slashCommand.formCheckbox"), children: [
33894
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.SquareCheckBig, { className: "w-4 h-4" }),
33895
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ChevronDown, { className: "w-3 h-3" })
33896
- ] }),
34257
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34258
+ }, active: editor.isActive("formCheckbox"), title: t("slashCommand.formCheckbox"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.SquareCheckBig, { className: "w-4 h-4" }) }),
33897
34259
  children: [
33898
34260
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
33899
34261
  DropdownMenuItem,
@@ -33960,7 +34322,7 @@ var EditorToolbar = ({
33960
34322
  "div",
33961
34323
  {
33962
34324
  role: "toolbar",
33963
- className: "flex min-h-15 flex-nowrap items-center gap-1 overflow-x-auto border-b border-[rgba(196,197,213,0.6)] bg-[#F4F4F4] px-3 py-3 dark:bg-muted/60",
34325
+ className: "flex min-h-12 flex-nowrap items-center gap-0.5 overflow-x-auto border-b border-[rgba(196,197,213,0.6)] bg-[#F4F4F4] px-2 py-2 dark:bg-muted/60",
33964
34326
  children: [
33965
34327
  isFull && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
33966
34328
  DropdownMenu,
@@ -33971,7 +34333,7 @@ var EditorToolbar = ({
33971
34333
  onClick: () => {
33972
34334
  },
33973
34335
  title: t("toolbar.fontFamily"),
33974
- className: "h-9 w-50 max-w-50 justify-between gap-3 rounded-lg border border-[rgba(196,197,213,0.6)] bg-white px-3 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
34336
+ className: "h-8 w-44 max-w-44 justify-between gap-2 border border-[rgba(196,197,213,0.6)] bg-white px-2.5 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
33975
34337
  children: [
33976
34338
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "min-w-0 flex-1 truncate text-left text-sm font-normal", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
33977
34339
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
@@ -34000,7 +34362,7 @@ var EditorToolbar = ({
34000
34362
  onClick: () => {
34001
34363
  },
34002
34364
  title: t("toolbar.fontSize"),
34003
- className: "h-9 w-20 justify-between gap-3 rounded-lg border border-[rgba(196,197,213,0.6)] bg-white px-3 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
34365
+ className: "h-8 w-16 justify-between gap-2 border border-[rgba(196,197,213,0.6)] bg-white px-2.5 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
34004
34366
  children: [
34005
34367
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "text-sm font-normal leading-none", children: displayedFontSizeLabel }),
34006
34368
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
@@ -34023,11 +34385,8 @@ var EditorToolbar = ({
34023
34385
  DropdownMenu,
34024
34386
  {
34025
34387
  contentClassName: "p-1",
34026
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34027
- }, title: t("toolbar.textStyle"), className: "px-1.5 w-auto gap-0.5", children: [
34028
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTextStyleIcon, { className: "h-4 w-4" }),
34029
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34030
- ] }),
34388
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34389
+ }, title: t("toolbar.textStyle"), className: "px-1.5 w-auto gap-0.5", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTextStyleIcon, { className: "h-4 w-4" }) }),
34031
34390
  children: [
34032
34391
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34033
34392
  DropdownMenuItem,
@@ -34206,11 +34565,8 @@ var EditorToolbar = ({
34206
34565
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34207
34566
  DropdownMenu,
34208
34567
  {
34209
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34210
- }, title: t("colors.textColor"), children: [
34211
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(TextColorIcon, { color: currentTextColor }),
34212
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34213
- ] }),
34568
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34569
+ }, title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(TextColorIcon, { color: currentTextColor }) }),
34214
34570
  children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34215
34571
  EditorColorPalette,
34216
34572
  {
@@ -34231,11 +34587,8 @@ var EditorToolbar = ({
34231
34587
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34232
34588
  DropdownMenu,
34233
34589
  {
34234
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34235
- }, active: editor.isActive("highlight"), title: t("colors.highlight"), children: [
34236
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(HighlightColorIcon, { color: currentHighlightColor }),
34237
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34238
- ] }),
34590
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34591
+ }, active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(HighlightColorIcon, { color: currentHighlightColor }) }),
34239
34592
  children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34240
34593
  EditorColorPalette,
34241
34594
  {
@@ -34253,35 +34606,13 @@ var EditorToolbar = ({
34253
34606
  )
34254
34607
  }
34255
34608
  ),
34256
- (isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
34257
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarDivider, {}),
34258
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34259
- DropdownMenu,
34260
- {
34261
- contentClassName: "p-0 overflow-hidden",
34262
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34263
- }, title: t("toolbar.emoji"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaSmileIcon, { className: "h-4 w-4" }) }),
34264
- children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34265
- EmojiPicker2,
34266
- {
34267
- onSelect: (emoji) => {
34268
- editor.chain().focus().insertContent(emoji).run();
34269
- }
34270
- }
34271
- )
34272
- }
34273
- )
34274
- ] }),
34275
34609
  (isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
34276
34610
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarDivider, {}),
34277
34611
  /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34278
34612
  DropdownMenu,
34279
34613
  {
34280
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34281
- }, title: t("toolbar.alignment"), children: [
34282
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaAlignLeftIcon, { className: "h-4 w-4" }),
34283
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34284
- ] }),
34614
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34615
+ }, title: t("toolbar.alignment"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaAlignLeftIcon, { className: "h-4 w-4" }) }),
34285
34616
  children: [
34286
34617
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34287
34618
  DropdownMenuItem,
@@ -34355,11 +34686,8 @@ var EditorToolbar = ({
34355
34686
  hasTableContext && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34356
34687
  DropdownMenu,
34357
34688
  {
34358
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34359
- }, title: t("tableMenu.textDirection"), children: [
34360
- currentCellTextDirection === "vertical" ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ArrowDown, { className: "w-4 h-4" }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ArrowRight, { className: "w-4 h-4" }),
34361
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ChevronDown, { className: "w-3 h-3" })
34362
- ] }),
34689
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34690
+ }, title: t("tableMenu.textDirection"), children: currentCellTextDirection === "vertical" ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ArrowDown, { className: "w-4 h-4" }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ArrowRight, { className: "w-4 h-4" }) }),
34363
34691
  children: [
34364
34692
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34365
34693
  DropdownMenuItem,
@@ -34387,11 +34715,8 @@ var EditorToolbar = ({
34387
34715
  /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34388
34716
  DropdownMenu,
34389
34717
  {
34390
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34391
- }, title: t("toolbar.bulletList"), children: [
34392
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaListIcon, { className: "h-4 w-4" }),
34393
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34394
- ] }),
34718
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34719
+ }, title: t("toolbar.bulletList"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaListIcon, { className: "h-4 w-4" }) }),
34395
34720
  children: [
34396
34721
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34397
34722
  DropdownMenuItem,
@@ -34426,14 +34751,29 @@ var EditorToolbar = ({
34426
34751
  ]
34427
34752
  }
34428
34753
  ),
34754
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34755
+ ToolbarButton,
34756
+ {
34757
+ onClick: () => editor.chain().focus().decreaseIndent().run(),
34758
+ disabled: !editorUiState.can.decreaseIndent,
34759
+ title: t("toolbar.decreaseIndent"),
34760
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.IndentDecrease, { className: "h-4 w-4" })
34761
+ }
34762
+ ),
34763
+ /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34764
+ ToolbarButton,
34765
+ {
34766
+ onClick: () => editor.chain().focus().increaseIndent().run(),
34767
+ disabled: !editorUiState.can.increaseIndent,
34768
+ title: t("toolbar.increaseIndent"),
34769
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.IndentIncrease, { className: "h-4 w-4" })
34770
+ }
34771
+ ),
34429
34772
  /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34430
34773
  DropdownMenu,
34431
34774
  {
34432
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34433
- }, active: editor.isActive("formCheckbox"), title: t("slashCommand.formCheckbox"), children: [
34434
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.SquareCheckBig, { className: "w-4 h-4" }),
34435
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.ChevronDown, { className: "w-3 h-3" })
34436
- ] }),
34775
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34776
+ }, active: editor.isActive("formCheckbox"), title: t("slashCommand.formCheckbox"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_lucide_react52.SquareCheckBig, { className: "w-4 h-4" }) }),
34437
34777
  children: [
34438
34778
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34439
34779
  DropdownMenuItem,
@@ -34458,11 +34798,8 @@ var EditorToolbar = ({
34458
34798
  isFull && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34459
34799
  DropdownMenu,
34460
34800
  {
34461
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34462
- }, title: t("toolbar.quote"), children: [
34463
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaQuoteIcon, { className: "h-4 w-4" }),
34464
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34465
- ] }),
34801
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34802
+ }, title: t("toolbar.quote"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaQuoteIcon, { className: "h-4 w-4" }) }),
34466
34803
  children: [
34467
34804
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34468
34805
  DropdownMenuItem,
@@ -34490,11 +34827,8 @@ var EditorToolbar = ({
34490
34827
  (isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34491
34828
  DropdownMenu,
34492
34829
  {
34493
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34494
- }, title: t("toolbar.image"), children: [
34495
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaImageIcon, { className: "h-4 w-4" }),
34496
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34497
- ] }),
34830
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34831
+ }, title: t("toolbar.image"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaImageIcon, { className: "h-4 w-4" }) }),
34498
34832
  children: showImageInput ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34499
34833
  ImageInput,
34500
34834
  {
@@ -34614,149 +34948,25 @@ var EditorToolbar = ({
34614
34948
  ] })
34615
34949
  }
34616
34950
  ),
34617
- (isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
34951
+ (isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34618
34952
  DropdownMenu,
34619
34953
  {
34620
34954
  isOpen: isTableMenuOpen,
34621
- onOpenChange: (open) => {
34622
- setIsTableMenuOpen(open);
34623
- setPreservedTableAnchorPos(open ? getTableAnchorPos(editor) : null);
34624
- },
34625
- trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(ToolbarButton, { onClick: () => {
34626
- }, title: t("toolbar.table"), children: [
34627
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTableIcon, { className: "h-4 w-4" }),
34628
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-2.5 w-2.5" })
34629
- ] }),
34955
+ onOpenChange: setIsTableMenuOpen,
34956
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
34957
+ }, title: t("toolbar.table"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTableIcon, { className: "h-4 w-4" }) }),
34630
34958
  contentClassName: "p-2 min-w-56",
34631
- children: [
34632
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34633
- TableInsertGrid,
34634
- {
34635
- insertLabel: t("tableMenu.insertTable"),
34636
- previewTemplate: t("tableMenu.gridPreview"),
34637
- onInsert: (rows, cols) => {
34638
- editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
34639
- setIsTableMenuOpen(false);
34640
- setPreservedTableAnchorPos(null);
34641
- }
34642
- }
34643
- ),
34644
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "my-1 border-t" }),
34645
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34646
- DropdownMenuItem,
34647
- {
34648
- icon: import_lucide_react52.AlignLeft,
34649
- label: t("tableMenu.alignLeft"),
34650
- onClick: () => applyTableAlignment(editor, "left", tableCommandAnchorPos),
34651
- active: hasTableContext && currentTableAlign === "left",
34652
- disabled: !hasTableContext
34653
- }
34654
- ),
34655
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34656
- DropdownMenuItem,
34657
- {
34658
- icon: import_lucide_react52.AlignCenter,
34659
- label: t("tableMenu.alignCenter"),
34660
- onClick: () => applyTableAlignment(editor, "center", tableCommandAnchorPos),
34661
- active: hasTableContext && currentTableAlign === "center",
34662
- disabled: !hasTableContext
34663
- }
34664
- ),
34665
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34666
- DropdownMenuItem,
34667
- {
34668
- icon: import_lucide_react52.AlignRight,
34669
- label: t("tableMenu.alignRight"),
34670
- onClick: () => applyTableAlignment(editor, "right", tableCommandAnchorPos),
34671
- active: hasTableContext && currentTableAlign === "right",
34672
- disabled: !hasTableContext
34673
- }
34674
- ),
34675
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "my-1 border-t" }),
34676
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34677
- DropdownMenuItem,
34678
- {
34679
- icon: import_lucide_react52.ArrowLeft,
34680
- label: t("tableMenu.addColumnBefore"),
34681
- onClick: () => editor.chain().focus().addColumnBefore().run(),
34682
- disabled: !hasTableContext || !editor.can().addColumnBefore()
34683
- }
34684
- ),
34685
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34686
- DropdownMenuItem,
34687
- {
34688
- icon: import_lucide_react52.ArrowDown,
34689
- label: t("tableMenu.addColumnAfter"),
34690
- onClick: () => editor.chain().focus().addColumnAfter().run(),
34691
- disabled: !hasTableContext || !editor.can().addColumnAfter()
34692
- }
34693
- ),
34694
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34695
- DropdownMenuItem,
34696
- {
34697
- icon: import_lucide_react52.ArrowUp,
34698
- label: t("tableMenu.addRowBefore"),
34699
- onClick: () => editor.chain().focus().addRowBefore().run(),
34700
- disabled: !hasTableContext || !editor.can().addRowBefore()
34701
- }
34702
- ),
34703
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34704
- DropdownMenuItem,
34705
- {
34706
- icon: import_lucide_react52.ArrowRight,
34707
- label: t("tableMenu.addRowAfter"),
34708
- onClick: () => editor.chain().focus().addRowAfter().run(),
34709
- disabled: !hasTableContext || !editor.can().addRowAfter()
34710
- }
34711
- ),
34712
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "my-1 border-t" }),
34713
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34714
- DropdownMenuItem,
34715
- {
34716
- icon: import_lucide_react52.Table,
34717
- label: t("tableMenu.toggleHeaderRow"),
34718
- onClick: () => editor.chain().focus().toggleHeaderRow().run(),
34719
- disabled: !hasTableContext || !editor.can().toggleHeaderRow()
34720
- }
34721
- ),
34722
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34723
- DropdownMenuItem,
34724
- {
34725
- icon: import_lucide_react52.Table,
34726
- label: t("tableMenu.toggleHeaderColumn"),
34727
- onClick: () => editor.chain().focus().toggleHeaderColumn().run(),
34728
- disabled: !hasTableContext || !editor.can().toggleHeaderColumn()
34729
- }
34730
- ),
34731
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "my-1 border-t" }),
34732
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34733
- DropdownMenuItem,
34734
- {
34735
- icon: import_lucide_react52.Trash2,
34736
- label: t("tableMenu.deleteColumn"),
34737
- onClick: () => editor.chain().focus().deleteColumn().run(),
34738
- disabled: !hasTableContext || !editor.can().deleteColumn()
34739
- }
34740
- ),
34741
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34742
- DropdownMenuItem,
34743
- {
34744
- icon: import_lucide_react52.Trash2,
34745
- label: t("tableMenu.deleteRow"),
34746
- onClick: () => editor.chain().focus().deleteRow().run(),
34747
- disabled: !hasTableContext || !editor.can().deleteRow()
34748
- }
34749
- ),
34750
- /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34751
- DropdownMenuItem,
34752
- {
34753
- icon: import_lucide_react52.Trash2,
34754
- label: t("tableMenu.deleteTable"),
34755
- onClick: () => editor.chain().focus().deleteTable().run(),
34756
- disabled: !hasTableContext || !editor.can().deleteTable()
34959
+ children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
34960
+ TableInsertGrid,
34961
+ {
34962
+ insertLabel: t("tableMenu.insertTable"),
34963
+ previewTemplate: t("tableMenu.gridPreview"),
34964
+ onInsert: (rows, cols) => {
34965
+ editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
34966
+ setIsTableMenuOpen(false);
34757
34967
  }
34758
- )
34759
- ]
34968
+ }
34969
+ )
34760
34970
  }
34761
34971
  ),
34762
34972
  /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarDivider, {}),
@@ -34825,12 +35035,12 @@ var EditorToolbar = ({
34825
35035
  // src/components/UEditor/menus.tsx
34826
35036
  var import_react74 = require("react");
34827
35037
  var import_react75 = require("@tiptap/react");
34828
- var import_tables7 = require("@tiptap/pm/tables");
35038
+ var import_tables8 = require("@tiptap/pm/tables");
34829
35039
  var import_react_dom8 = require("react-dom");
34830
35040
  var import_lucide_react53 = require("lucide-react");
34831
35041
 
34832
35042
  // src/components/UEditor/table-border-commands.ts
34833
- var import_tables5 = require("@tiptap/pm/tables");
35043
+ var import_tables6 = require("@tiptap/pm/tables");
34834
35044
  var SIDES = ["top", "right", "bottom", "left"];
34835
35045
  var OPPOSITE_SIDE = {
34836
35046
  top: "bottom",
@@ -34901,7 +35111,7 @@ function getAppliedSides(position, cell, selection) {
34901
35111
  }
34902
35112
  function applyTableCellBorders(editor, position, format, options = {}) {
34903
35113
  const { state, view } = editor;
34904
- const selection = (0, import_tables5.selectedRect)(state);
35114
+ const selection = (0, import_tables6.selectedRect)(state);
34905
35115
  const transaction = state.tr;
34906
35116
  const cellPositions = new Set(selection.map.cellsInRect(selection));
34907
35117
  const sidesByCell = /* @__PURE__ */ new Map();
@@ -34959,7 +35169,7 @@ function applyTableCellBorders(editor, position, format, options = {}) {
34959
35169
 
34960
35170
  // src/components/UEditor/table-formula-commands.ts
34961
35171
  var import_state11 = require("@tiptap/pm/state");
34962
- var import_tables6 = require("@tiptap/pm/tables");
35172
+ var import_tables7 = require("@tiptap/pm/tables");
34963
35173
 
34964
35174
  // src/components/UEditor/table-formula.ts
34965
35175
  var CELL_ADDRESS_RE = /^([A-Z]+)([1-9]\d*)$/i;
@@ -35550,7 +35760,7 @@ function getSelectionTableCellAnchor(editor) {
35550
35760
  const tableNode = $cell.node(depth);
35551
35761
  if (tableNode.type.name !== "table") continue;
35552
35762
  const tableStart = $cell.start(depth);
35553
- const rect = safeFindCell2(import_tables6.TableMap.get(tableNode), cellPos - tableStart);
35763
+ const rect = safeFindCell2(import_tables7.TableMap.get(tableNode), cellPos - tableStart);
35554
35764
  if (!rect) return null;
35555
35765
  return {
35556
35766
  cellPos,
@@ -35566,7 +35776,7 @@ function getSelectionTableCellAnchor(editor) {
35566
35776
  function restoreSelectionAtTableCell(editor, anchor) {
35567
35777
  const tableNode = editor.state.doc.nodeAt(anchor.tablePos);
35568
35778
  if (!tableNode || tableNode.type.name !== "table") return false;
35569
- const map = import_tables6.TableMap.get(tableNode);
35779
+ const map = import_tables7.TableMap.get(tableNode);
35570
35780
  if (anchor.row >= map.height || anchor.column >= map.width) return false;
35571
35781
  const relativeCellPos = map.positionAt(anchor.row, anchor.column, tableNode);
35572
35782
  const cellPos = anchor.tablePos + 1 + relativeCellPos;
@@ -35622,7 +35832,7 @@ function getSelectionTableCellLabel(editor) {
35622
35832
  const tableNode = $from.node(tableDepth);
35623
35833
  const tableStart = $from.start(tableDepth);
35624
35834
  const relativeCellPos = $from.before(cellDepth) - tableStart;
35625
- const rect = safeFindCell2(import_tables6.TableMap.get(tableNode), relativeCellPos);
35835
+ const rect = safeFindCell2(import_tables7.TableMap.get(tableNode), relativeCellPos);
35626
35836
  if (!rect) return null;
35627
35837
  return `${indexToColumnName(rect.left)}${rect.top + 1}`;
35628
35838
  }
@@ -35660,7 +35870,7 @@ function removeSelectedTableCellFormula(editor, clearContent) {
35660
35870
  return true;
35661
35871
  }
35662
35872
  function buildTableValueMap(tableNode) {
35663
- const map = import_tables6.TableMap.get(tableNode);
35873
+ const map = import_tables7.TableMap.get(tableNode);
35664
35874
  const values = /* @__PURE__ */ new Map();
35665
35875
  for (const rowInfo of getTableRows2(tableNode)) {
35666
35876
  for (const entry of rowInfo.cells) {
@@ -35685,8 +35895,8 @@ function setSelectedTableCellFormula(editor, formula) {
35685
35895
  if (!normalized) {
35686
35896
  return clearSelectedTableCellFormula(editor);
35687
35897
  }
35688
- const appliedFormula = (0, import_tables6.setCellAttr)("formula", normalized)(state, view.dispatch.bind(view));
35689
- const clearedValue = (0, import_tables6.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
35898
+ const appliedFormula = (0, import_tables7.setCellAttr)("formula", normalized)(state, view.dispatch.bind(view));
35899
+ const clearedValue = (0, import_tables7.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
35690
35900
  if (appliedFormula || clearedValue) {
35691
35901
  recalculateActiveTableFormulas(editor);
35692
35902
  if (selectionAnchor) restoreSelectionAtTableCell(editor, selectionAnchor);
@@ -35705,7 +35915,7 @@ function convertSelectedTableCellFormulaToValue(editor) {
35705
35915
  function setSelectedTableCellNumberFormat(editor, numberFormat) {
35706
35916
  const value = numberFormat && numberFormat !== "text" ? numberFormat : null;
35707
35917
  const { state, view } = editor;
35708
- const applied = (0, import_tables6.setCellAttr)("numberFormat", value)(state, view.dispatch.bind(view));
35918
+ const applied = (0, import_tables7.setCellAttr)("numberFormat", value)(state, view.dispatch.bind(view));
35709
35919
  if (!applied) return false;
35710
35920
  recalculateSelectedTable(editor);
35711
35921
  view.focus();
@@ -35777,7 +35987,7 @@ function promoteFormulaTextInTableNode(tableNode) {
35777
35987
  function recalculateTableNode(tableNode, options) {
35778
35988
  const promoted = promoteFormulaTextInTableNode(tableNode);
35779
35989
  tableNode = promoted.tableNode;
35780
- const map = import_tables6.TableMap.get(tableNode);
35990
+ const map = import_tables7.TableMap.get(tableNode);
35781
35991
  const values = buildTableValueMap(tableNode);
35782
35992
  const formulaEntries = /* @__PURE__ */ new Map();
35783
35993
  let changed = false;
@@ -35848,7 +36058,7 @@ function recalculateTableNode(tableNode, options) {
35848
36058
  return tableNode.type.create(tableNode.attrs, rows);
35849
36059
  }
35850
36060
  function recalculateSelectedTable(editor) {
35851
- const rect = (0, import_tables6.selectedRect)(editor.state);
36061
+ const rect = (0, import_tables7.selectedRect)(editor.state);
35852
36062
  const tableNode = rect.table;
35853
36063
  const nextTable = recalculateTableNode(tableNode);
35854
36064
  if (!nextTable) return false;
@@ -35944,7 +36154,7 @@ var FloatingMenuContent = ({ editor }) => {
35944
36154
  {
35945
36155
  type: "button",
35946
36156
  onClick: () => setShowCommands(true),
35947
- className: "flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-accent transition-all group",
36157
+ className: "group flex items-center gap-1 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/30",
35948
36158
  children: [
35949
36159
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Plus, { className: "w-4 h-4 text-muted-foreground group-hover:text-foreground" }),
35950
36160
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { className: "text-sm text-muted-foreground group-hover:text-foreground", children: t("floatingMenu.addBlock") })
@@ -35955,7 +36165,7 @@ var FloatingMenuContent = ({ editor }) => {
35955
36165
  function applyTableCellBackground(editor, color) {
35956
36166
  const value = color || null;
35957
36167
  const { state, view } = editor;
35958
- const applied = (0, import_tables7.setCellAttr)("backgroundColor", value)(state, view.dispatch.bind(view));
36168
+ const applied = (0, import_tables8.setCellAttr)("backgroundColor", value)(state, view.dispatch.bind(view));
35959
36169
  if (applied) {
35960
36170
  view.focus();
35961
36171
  return;
@@ -35965,7 +36175,7 @@ function applyTableCellBackground(editor, color) {
35965
36175
  function applyTableCellAttribute2(editor, name, value, options = {}) {
35966
36176
  const shouldFocus = options.focus ?? true;
35967
36177
  const { state, view } = editor;
35968
- const applied = (0, import_tables7.setCellAttr)(name, value)(state, view.dispatch.bind(view));
36178
+ const applied = (0, import_tables8.setCellAttr)(name, value)(state, view.dispatch.bind(view));
35969
36179
  if (applied) {
35970
36180
  if (shouldFocus) view.focus();
35971
36181
  return;
@@ -36018,20 +36228,28 @@ function BorderPositionPreviewIcon({ position }) {
36018
36228
  showVertical && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("path", { d: "M10 2V18", strokeWidth: "2" })
36019
36229
  ] });
36020
36230
  }
36231
+ function getBubbleMenuContext(editor) {
36232
+ const { selection } = editor.state;
36233
+ if (editor.isActive("image")) return "image";
36234
+ if (selection instanceof import_tables8.CellSelection) return "table-cell";
36235
+ if (editor.isActive("link")) return "link";
36236
+ if (!selection.empty) return "text";
36237
+ return "none";
36238
+ }
36021
36239
  var BubbleMenuContent = ({
36022
36240
  editor,
36241
+ context,
36023
36242
  onKeepOpenChange,
36024
36243
  onLinkInputOpenChange,
36025
36244
  onRequestClose,
36026
36245
  fontSizes,
36027
36246
  lineHeights,
36028
- initialShowLinkInput = false,
36029
- cellBorderOpenRequest = 0
36247
+ initialShowLinkInput = false
36030
36248
  }) => {
36031
36249
  const t = useSmartTranslations("UEditor");
36032
36250
  (0, import_react75.useEditorState)({
36033
36251
  editor,
36034
- selector: ({ transactionNumber }) => transactionNumber
36252
+ selector: ({ editor: currentEditor }) => getEditorUiRenderState(currentEditor)
36035
36253
  });
36036
36254
  const { textColors, highlightColors } = useEditorColors();
36037
36255
  const [showLinkInput, setShowLinkInput] = (0, import_react74.useState)(initialShowLinkInput);
@@ -36039,17 +36257,13 @@ var BubbleMenuContent = ({
36039
36257
  (0, import_react74.useEffect)(() => {
36040
36258
  setShowLinkInput(initialShowLinkInput);
36041
36259
  }, [initialShowLinkInput]);
36042
- (0, import_react74.useEffect)(() => {
36043
- if (!cellBorderOpenRequest) return;
36044
- setActiveColorPalette("cell-border");
36045
- onKeepOpenChange?.(true);
36046
- }, [cellBorderOpenRequest, onKeepOpenChange]);
36047
36260
  const [showTypographyPanel, setShowTypographyPanel] = (0, import_react74.useState)(false);
36048
36261
  const [showFormulaPanel, setShowFormulaPanel] = (0, import_react74.useState)(false);
36049
36262
  const [formulaDraft, setFormulaDraft] = (0, import_react74.useState)("");
36050
36263
  const [showFontSizeOptions, setShowFontSizeOptions] = (0, import_react74.useState)(false);
36051
36264
  const [fontSizeDraft, setFontSizeDraft] = (0, import_react74.useState)("");
36052
- const isImageSelected = editor.isActive("image");
36265
+ const isImageSelected = context === "image";
36266
+ const isTableCellSelection = context === "table-cell";
36053
36267
  const imageAttrs = editor.getAttributes("image");
36054
36268
  const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
36055
36269
  const imageWidthPreset = imageAttrs.imageWidthPreset === "sm" || imageAttrs.imageWidthPreset === "md" || imageAttrs.imageWidthPreset === "lg" ? imageAttrs.imageWidthPreset : null;
@@ -36071,9 +36285,9 @@ var BubbleMenuContent = ({
36071
36285
  const [activeBorderPosition, setActiveBorderPosition] = (0, import_react74.useState)("all");
36072
36286
  const currentCellVerticalAlign = normalizeStyleValue(editor.getAttributes("tableCell").verticalAlign || editor.getAttributes("tableHeader").verticalAlign) || "";
36073
36287
  const currentCellTextDirection = normalizeStyleValue(editor.getAttributes("tableCell").textDirection || editor.getAttributes("tableHeader").textDirection) || "horizontal";
36074
- const isInTable2 = (0, import_tables7.isInTable)(editor.state);
36075
- const canMergeCells = isInTable2 && editor.can().mergeCells();
36076
- const canSplitCell = isInTable2 && editor.can().splitCell();
36288
+ const isInTable3 = (0, import_tables8.isInTable)(editor.state);
36289
+ const canMergeCells = isInTable3 && editor.can().mergeCells();
36290
+ const canSplitCell = isInTable3 && editor.can().splitCell();
36077
36291
  const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
36078
36292
  const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
36079
36293
  const quickFontSizes = (0, import_react74.useMemo)(
@@ -36112,12 +36326,10 @@ var BubbleMenuContent = ({
36112
36326
  setFontSizeDraft(String(clamped));
36113
36327
  };
36114
36328
  (0, import_react74.useEffect)(() => {
36115
- onKeepOpenChange?.(showLinkInput);
36329
+ const shouldKeepOpen = showLinkInput || Boolean(activeColorPalette) || showFormulaPanel || showTypographyPanel;
36330
+ onKeepOpenChange?.(shouldKeepOpen);
36116
36331
  onLinkInputOpenChange?.(showLinkInput);
36117
- }, [onKeepOpenChange, onLinkInputOpenChange, showLinkInput]);
36118
- (0, import_react74.useEffect)(() => {
36119
- onKeepOpenChange?.(Boolean(activeColorPalette));
36120
- }, [activeColorPalette, onKeepOpenChange]);
36332
+ }, [activeColorPalette, onKeepOpenChange, onLinkInputOpenChange, showFormulaPanel, showLinkInput, showTypographyPanel]);
36121
36333
  const closeTransientPanels = (0, import_react74.useCallback)(() => {
36122
36334
  setActiveColorPalette(null);
36123
36335
  setShowLinkInput(false);
@@ -36421,7 +36633,7 @@ var BubbleMenuContent = ({
36421
36633
  )
36422
36634
  ] });
36423
36635
  }
36424
- if (showFormulaPanel && isInTable2) {
36636
+ if (showFormulaPanel && isInTable3) {
36425
36637
  return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "w-72 p-2", children: [
36426
36638
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
36427
36639
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: t("tableMenu.formula") || "Formula" }),
@@ -36676,38 +36888,8 @@ var BubbleMenuContent = ({
36676
36888
  ] });
36677
36889
  }
36678
36890
  const VerticalAlignActiveIcon = currentCellVerticalAlign === "middle" ? import_lucide_react53.AlignCenterVertical : currentCellVerticalAlign === "bottom" ? import_lucide_react53.AlignEndVertical : import_lucide_react53.AlignStartVertical;
36679
- return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "flex items-center gap-0.5 p-1", children: [
36680
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Bold, { className: "w-4 h-4" }) }),
36681
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Italic, { className: "w-4 h-4" }) }),
36682
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36683
- ToolbarButton,
36684
- {
36685
- onClick: () => editor.chain().focus().toggleUnderline().run(),
36686
- active: editor.isActive("underline"),
36687
- title: t("toolbar.underline"),
36688
- children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Underline, { className: "w-4 h-4" })
36689
- }
36690
- ),
36691
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleStrike().run(), active: editor.isActive("strike"), title: t("toolbar.strike"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Strikethrough, { className: "w-4 h-4" }) }),
36692
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleCode().run(), active: editor.isActive("code"), title: t("toolbar.code"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Code, { className: "w-4 h-4" }) }),
36693
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
36694
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36695
- ToolbarButton,
36696
- {
36697
- onMouseDown: () => {
36698
- onKeepOpenChange?.(true);
36699
- },
36700
- onClick: () => {
36701
- setShowLinkInput(true);
36702
- },
36703
- active: editor.isActive("link"),
36704
- title: t("toolbar.link"),
36705
- children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Link, { className: "w-4 h-4" })
36706
- }
36707
- ),
36708
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("text"), title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(TextColorIcon, { color: currentTextColor }) }),
36709
- /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("highlight"), active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(HighlightColorIcon, { color: currentHighlightColor }) }),
36710
- isInTable2 && /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(import_jsx_runtime94.Fragment, { children: [
36891
+ if (isTableCellSelection) {
36892
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "flex items-center gap-0.5 p-1", "data-ueditor-cell-inspector": "", children: [
36711
36893
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36712
36894
  ToolbarButton,
36713
36895
  {
@@ -36720,9 +36902,7 @@ var BubbleMenuContent = ({
36720
36902
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36721
36903
  ToolbarButton,
36722
36904
  {
36723
- onMouseDown: () => {
36724
- onKeepOpenChange?.(true);
36725
- },
36905
+ onMouseDown: () => onKeepOpenChange?.(true),
36726
36906
  onClick: () => setActiveColorPalette("cell-border"),
36727
36907
  active: Boolean(
36728
36908
  editor.getAttributes("tableCell").borderColor || editor.getAttributes("tableHeader").borderColor || editor.getAttributes("tableCell").borderStyle || editor.getAttributes("tableHeader").borderStyle || editor.getAttributes("tableCell").borderWidth || editor.getAttributes("tableHeader").borderWidth
@@ -36739,9 +36919,7 @@ var BubbleMenuContent = ({
36739
36919
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36740
36920
  ToolbarButton,
36741
36921
  {
36742
- onMouseDown: () => {
36743
- onKeepOpenChange?.(true);
36744
- },
36922
+ onMouseDown: () => onKeepOpenChange?.(true),
36745
36923
  onClick: () => {
36746
36924
  setFormulaDraft(currentCellFormula);
36747
36925
  setShowFormulaPanel(true);
@@ -36770,15 +36948,11 @@ var BubbleMenuContent = ({
36770
36948
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
36771
36949
  DropdownMenu,
36772
36950
  {
36773
- onOpenChange: (open) => {
36774
- onKeepOpenChange?.(open);
36775
- },
36951
+ onOpenChange: onKeepOpenChange,
36776
36952
  trigger: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
36777
36953
  ToolbarButton,
36778
36954
  {
36779
- onMouseDown: () => {
36780
- onKeepOpenChange?.(true);
36781
- },
36955
+ onMouseDown: () => onKeepOpenChange?.(true),
36782
36956
  onClick: () => {
36783
36957
  },
36784
36958
  title: t("tableMenu.alignVertical") || "Vertical alignment",
@@ -36822,15 +36996,11 @@ var BubbleMenuContent = ({
36822
36996
  /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
36823
36997
  DropdownMenu,
36824
36998
  {
36825
- onOpenChange: (open) => {
36826
- onKeepOpenChange?.(open);
36827
- },
36999
+ onOpenChange: onKeepOpenChange,
36828
37000
  trigger: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
36829
37001
  ToolbarButton,
36830
37002
  {
36831
- onMouseDown: () => {
36832
- onKeepOpenChange?.(true);
36833
- },
37003
+ onMouseDown: () => onKeepOpenChange?.(true),
36834
37004
  onClick: () => {
36835
37005
  },
36836
37006
  title: t("tableMenu.textDirection"),
@@ -36862,7 +37032,39 @@ var BubbleMenuContent = ({
36862
37032
  ]
36863
37033
  }
36864
37034
  )
36865
- ] }),
37035
+ ] });
37036
+ }
37037
+ return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "flex items-center gap-0.5 p-1", children: [
37038
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Bold, { className: "w-4 h-4" }) }),
37039
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Italic, { className: "w-4 h-4" }) }),
37040
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
37041
+ ToolbarButton,
37042
+ {
37043
+ onClick: () => editor.chain().focus().toggleUnderline().run(),
37044
+ active: editor.isActive("underline"),
37045
+ title: t("toolbar.underline"),
37046
+ children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Underline, { className: "w-4 h-4" })
37047
+ }
37048
+ ),
37049
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleStrike().run(), active: editor.isActive("strike"), title: t("toolbar.strike"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Strikethrough, { className: "w-4 h-4" }) }),
37050
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleCode().run(), active: editor.isActive("code"), title: t("toolbar.code"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Code, { className: "w-4 h-4" }) }),
37051
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
37052
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
37053
+ ToolbarButton,
37054
+ {
37055
+ onMouseDown: () => {
37056
+ onKeepOpenChange?.(true);
37057
+ },
37058
+ onClick: () => {
37059
+ setShowLinkInput(true);
37060
+ },
37061
+ active: editor.isActive("link"),
37062
+ title: t("toolbar.link"),
37063
+ children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_lucide_react53.Link, { className: "w-4 h-4" })
37064
+ }
37065
+ ),
37066
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("text"), title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(TextColorIcon, { color: currentTextColor }) }),
37067
+ /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("highlight"), active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(HighlightColorIcon, { color: currentHighlightColor }) }),
36866
37068
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
36867
37069
  ToolbarButton,
36868
37070
  {
@@ -36902,7 +37104,6 @@ var CustomBubbleMenu = ({
36902
37104
  const BUBBLE_MENU_ESTIMATED_HEIGHT = 44;
36903
37105
  const [isVisible, setIsVisible] = (0, import_react74.useState)(false);
36904
37106
  const [linkInputOpen, setLinkInputOpen] = (0, import_react74.useState)(false);
36905
- const [cellBorderOpenRequest, setCellBorderOpenRequest] = (0, import_react74.useState)(0);
36906
37107
  const [position, setPosition2] = (0, import_react74.useState)({
36907
37108
  top: 0,
36908
37109
  left: 0,
@@ -36939,14 +37140,14 @@ var CustomBubbleMenu = ({
36939
37140
  };
36940
37141
  const updatePosition = () => {
36941
37142
  const { state, view } = editor;
36942
- const { from, to, empty } = state.selection;
36943
- const isLinkActive = editor.isActive("link");
37143
+ const { from, to } = state.selection;
37144
+ const context2 = getBubbleMenuContext(editor);
36944
37145
  if (Date.now() < suppressShowUntilRef.current) {
36945
37146
  clearShowTimeout();
36946
37147
  setIsVisible(false);
36947
37148
  return;
36948
37149
  }
36949
- if (!keepOpenRef.current && (empty && !isLinkActive || !view.hasFocus())) {
37150
+ if (!keepOpenRef.current && (context2 === "none" || !view.hasFocus())) {
36950
37151
  clearShowTimeout();
36951
37152
  setIsVisible(false);
36952
37153
  return;
@@ -36996,20 +37197,24 @@ var CustomBubbleMenu = ({
36996
37197
  setIsVisible(false);
36997
37198
  }
36998
37199
  };
36999
- editor.on("selectionUpdate", updatePosition);
37000
- editor.on("focus", updatePosition);
37200
+ let animationFrameId = null;
37201
+ const schedulePositionUpdate = () => {
37202
+ if (animationFrameId !== null) return;
37203
+ animationFrameId = requestAnimationFrame(() => {
37204
+ animationFrameId = null;
37205
+ updatePosition();
37206
+ });
37207
+ };
37208
+ editor.on("transaction", schedulePositionUpdate);
37209
+ editor.on("focus", schedulePositionUpdate);
37001
37210
  editor.on("blur", handleBlur);
37002
- editor.on("transaction", updatePosition);
37003
- editor.on("update", updatePosition);
37004
- const animationFrameId = requestAnimationFrame(updatePosition);
37211
+ schedulePositionUpdate();
37005
37212
  return () => {
37006
- cancelAnimationFrame(animationFrameId);
37213
+ if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
37007
37214
  clearShowTimeout();
37008
- editor.off("selectionUpdate", updatePosition);
37009
- editor.off("focus", updatePosition);
37215
+ editor.off("transaction", schedulePositionUpdate);
37216
+ editor.off("focus", schedulePositionUpdate);
37010
37217
  editor.off("blur", handleBlur);
37011
- editor.off("transaction", updatePosition);
37012
- editor.off("update", updatePosition);
37013
37218
  };
37014
37219
  }, [editor]);
37015
37220
  (0, import_react74.useEffect)(() => {
@@ -37017,8 +37222,6 @@ var CustomBubbleMenu = ({
37017
37222
  const handlePointerDown = (event) => {
37018
37223
  const target = event.target;
37019
37224
  if (target && (menuRef.current?.contains(target) || target.closest("[data-ueditor-keep-open]"))) return;
37020
- const table = target?.closest("table");
37021
- if (table && editor.view.dom.contains(table)) return;
37022
37225
  closeBubbleMenu(false);
37023
37226
  };
37024
37227
  const handleKeyDown2 = (event) => {
@@ -37031,23 +37234,9 @@ var CustomBubbleMenu = ({
37031
37234
  document.removeEventListener("keydown", handleKeyDown2);
37032
37235
  };
37033
37236
  }, [closeBubbleMenu, editor, isVisible]);
37034
- (0, import_react74.useEffect)(() => {
37035
- const handleTableDoubleClick = (event) => {
37036
- const target = event.target;
37037
- const cell = target?.closest("td,th");
37038
- if (!cell || !editor.view.dom.contains(cell)) return;
37039
- suppressShowUntilRef.current = 0;
37040
- keepOpenRef.current = true;
37041
- setKeepOpenState(true);
37042
- setLinkInputOpen(false);
37043
- setCellBorderOpenRequest((request) => request + 1);
37044
- setIsVisible(true);
37045
- requestAnimationFrame(() => editor.view.focus());
37046
- };
37047
- editor.view.dom.addEventListener("dblclick", handleTableDoubleClick);
37048
- return () => editor.view.dom.removeEventListener("dblclick", handleTableDoubleClick);
37049
- }, [editor]);
37050
37237
  if (!isVisible) return null;
37238
+ const context = getBubbleMenuContext(editor);
37239
+ if (context === "none") return null;
37051
37240
  return (0, import_react_dom8.createPortal)(
37052
37241
  /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
37053
37242
  "div",
@@ -37069,7 +37258,7 @@ var CustomBubbleMenu = ({
37069
37258
  }
37070
37259
  e.preventDefault();
37071
37260
  },
37072
- children: editor.isActive("link") && !keepOpen && !linkInputOpen ? /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
37261
+ children: context === "link" && !keepOpen && !linkInputOpen ? /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
37073
37262
  LinkPreviewContent,
37074
37263
  {
37075
37264
  editor,
@@ -37082,14 +37271,15 @@ var CustomBubbleMenu = ({
37082
37271
  BubbleMenuContent,
37083
37272
  {
37084
37273
  editor,
37274
+ context,
37085
37275
  onKeepOpenChange: setKeepOpen,
37086
37276
  onLinkInputOpenChange: setLinkInputOpen,
37087
37277
  onRequestClose: closeBubbleMenu,
37088
37278
  fontSizes,
37089
37279
  lineHeights,
37090
- initialShowLinkInput: linkInputOpen,
37091
- cellBorderOpenRequest
37092
- }
37280
+ initialShowLinkInput: linkInputOpen
37281
+ },
37282
+ context
37093
37283
  )
37094
37284
  }
37095
37285
  ),
@@ -37114,15 +37304,23 @@ var CustomFloatingMenu = ({ editor }) => {
37114
37304
  setIsVisible(true);
37115
37305
  };
37116
37306
  const handleBlur = () => setIsVisible(false);
37117
- editor.on("selectionUpdate", updatePosition);
37118
- editor.on("focus", updatePosition);
37307
+ let animationFrameId = null;
37308
+ const schedulePositionUpdate = () => {
37309
+ if (animationFrameId !== null) return;
37310
+ animationFrameId = requestAnimationFrame(() => {
37311
+ animationFrameId = null;
37312
+ updatePosition();
37313
+ });
37314
+ };
37315
+ editor.on("transaction", schedulePositionUpdate);
37316
+ editor.on("focus", schedulePositionUpdate);
37119
37317
  editor.on("blur", handleBlur);
37120
- editor.on("update", updatePosition);
37318
+ schedulePositionUpdate();
37121
37319
  return () => {
37122
- editor.off("selectionUpdate", updatePosition);
37123
- editor.off("focus", updatePosition);
37320
+ if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
37321
+ editor.off("transaction", schedulePositionUpdate);
37322
+ editor.off("focus", schedulePositionUpdate);
37124
37323
  editor.off("blur", handleBlur);
37125
- editor.off("update", updatePosition);
37126
37324
  };
37127
37325
  }, [editor]);
37128
37326
  if (!isVisible) return null;
@@ -37146,12 +37344,20 @@ var CustomFloatingMenu = ({ editor }) => {
37146
37344
  };
37147
37345
 
37148
37346
  // src/components/UEditor/CharacterCount.tsx
37347
+ var import_react76 = require("@tiptap/react");
37149
37348
  var import_jsx_runtime95 = require("react/jsx-runtime");
37150
37349
  var CharacterCountDisplay = ({ editor, maxCharacters }) => {
37151
37350
  const t = useSmartTranslations("UEditor");
37152
- const storage = editor.storage;
37153
- const characterCount = storage.characterCount?.characters?.() ?? 0;
37154
- const wordCount = storage.characterCount?.words?.() ?? 0;
37351
+ const { characterCount, wordCount } = (0, import_react76.useEditorState)({
37352
+ editor,
37353
+ selector: ({ editor: currentEditor }) => {
37354
+ const storage = currentEditor.storage;
37355
+ return {
37356
+ characterCount: storage.characterCount?.characters?.() ?? 0,
37357
+ wordCount: storage.characterCount?.words?.() ?? 0
37358
+ };
37359
+ }
37360
+ });
37155
37361
  const percentage = maxCharacters ? Math.round(characterCount / maxCharacters * 100) : 0;
37156
37362
  return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "flex items-center gap-3 px-3 py-2 text-xs text-muted-foreground border-t border-border/30 bg-muted/20", children: [
37157
37363
  /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("span", { children: [
@@ -37585,7 +37791,7 @@ async function prepareUEditorContentForSave({
37585
37791
  }
37586
37792
 
37587
37793
  // src/components/UEditor/table-controls.tsx
37588
- var import_react76 = __toESM(require("react"), 1);
37794
+ var import_react77 = __toESM(require("react"), 1);
37589
37795
 
37590
37796
  // node_modules/prosemirror-model/dist/index.js
37591
37797
  function findDiffStart(a, b, pos) {
@@ -37642,7 +37848,7 @@ function findDiffEnd(a, b, posA, posB) {
37642
37848
  posB -= size;
37643
37849
  }
37644
37850
  }
37645
- var Fragment31 = class _Fragment {
37851
+ var Fragment30 = class _Fragment {
37646
37852
  /**
37647
37853
  @internal
37648
37854
  */
@@ -37934,7 +38140,7 @@ var Fragment31 = class _Fragment {
37934
38140
  throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
37935
38141
  }
37936
38142
  };
37937
- Fragment31.empty = new Fragment31([], 0);
38143
+ Fragment30.empty = new Fragment30([], 0);
37938
38144
  var found = { index: 0, offset: 0 };
37939
38145
  function retIndex(index, offset) {
37940
38146
  found.index = index;
@@ -38159,7 +38365,7 @@ var Slice = class _Slice {
38159
38365
  let openStart = json.openStart || 0, openEnd = json.openEnd || 0;
38160
38366
  if (typeof openStart != "number" || typeof openEnd != "number")
38161
38367
  throw new RangeError("Invalid input for Slice.fromJSON");
38162
- return new _Slice(Fragment31.fromJSON(schema, json.content), openStart, openEnd);
38368
+ return new _Slice(Fragment30.fromJSON(schema, json.content), openStart, openEnd);
38163
38369
  }
38164
38370
  /**
38165
38371
  Create a slice from a fragment by taking the maximum possible
@@ -38174,7 +38380,7 @@ var Slice = class _Slice {
38174
38380
  return new _Slice(fragment, openStart, openEnd);
38175
38381
  }
38176
38382
  };
38177
- Slice.empty = new Slice(Fragment31.empty, 0, 0);
38383
+ Slice.empty = new Slice(Fragment30.empty, 0, 0);
38178
38384
  function removeRange(content, from, to) {
38179
38385
  let { index, offset } = content.findIndex(from), child = content.maybeChild(index);
38180
38386
  let { index: indexTo, offset: offsetTo } = content.findIndex(to);
@@ -38272,7 +38478,7 @@ function replaceThreeWay($from, $start, $end, $to, depth) {
38272
38478
  addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);
38273
38479
  }
38274
38480
  addRange($to, null, depth, content);
38275
- return new Fragment31(content);
38481
+ return new Fragment30(content);
38276
38482
  }
38277
38483
  function replaceTwoWay($from, $to, depth) {
38278
38484
  let content = [];
@@ -38282,13 +38488,13 @@ function replaceTwoWay($from, $to, depth) {
38282
38488
  addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
38283
38489
  }
38284
38490
  addRange($to, null, depth, content);
38285
- return new Fragment31(content);
38491
+ return new Fragment30(content);
38286
38492
  }
38287
38493
  function prepareSliceForReplace(slice, $along) {
38288
38494
  let extra = $along.depth - slice.openStart, parent = $along.node(extra);
38289
38495
  let node = parent.copy(slice.content);
38290
38496
  for (let i = extra - 1; i >= 0; i--)
38291
- node = $along.node(i).copy(Fragment31.from(node));
38497
+ node = $along.node(i).copy(Fragment30.from(node));
38292
38498
  return {
38293
38499
  start: node.resolveNoCache(slice.openStart + extra),
38294
38500
  end: node.resolveNoCache(node.content.size - slice.openEnd - extra)
@@ -38627,7 +38833,7 @@ var Node7 = class _Node {
38627
38833
  this.type = type;
38628
38834
  this.attrs = attrs;
38629
38835
  this.marks = marks;
38630
- this.content = content || Fragment31.empty;
38836
+ this.content = content || Fragment30.empty;
38631
38837
  }
38632
38838
  /**
38633
38839
  The array of this node's child nodes.
@@ -38932,7 +39138,7 @@ var Node7 = class _Node {
38932
39138
  can optionally pass `start` and `end` indices into the
38933
39139
  replacement fragment.
38934
39140
  */
38935
- canReplace(from, to, replacement = Fragment31.empty, start = 0, end = replacement.childCount) {
39141
+ canReplace(from, to, replacement = Fragment30.empty, start = 0, end = replacement.childCount) {
38936
39142
  let one = this.contentMatchAt(from).matchFragment(replacement, start, end);
38937
39143
  let two = one && one.matchFragment(this.content, to);
38938
39144
  if (!two || !two.validEnd)
@@ -39014,7 +39220,7 @@ var Node7 = class _Node {
39014
39220
  throw new RangeError("Invalid text node in JSON");
39015
39221
  return schema.text(json.text, marks);
39016
39222
  }
39017
- let content = Fragment31.fromJSON(schema, json.content);
39223
+ let content = Fragment30.fromJSON(schema, json.content);
39018
39224
  let node = schema.nodeType(json.type).create(json.attrs, content, marks);
39019
39225
  node.type.checkAttrs(node.attrs);
39020
39226
  return node;
@@ -39110,7 +39316,7 @@ var ContentMatch = class _ContentMatch {
39110
39316
  function search(match, types) {
39111
39317
  let finished = match.matchFragment(after, startIndex);
39112
39318
  if (finished && (!toEnd || finished.validEnd))
39113
- return Fragment31.from(types.map((tp) => tp.createAndFill()));
39319
+ return Fragment30.from(types.map((tp) => tp.createAndFill()));
39114
39320
  for (let i = 0; i < match.next.length; i++) {
39115
39321
  let { type, next } = match.next[i];
39116
39322
  if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
@@ -39678,7 +39884,7 @@ function mapFragment(fragment, f, parent) {
39678
39884
  child = f(child, parent, i);
39679
39885
  mapped.push(child);
39680
39886
  }
39681
- return Fragment31.fromArray(mapped);
39887
+ return Fragment30.fromArray(mapped);
39682
39888
  }
39683
39889
  var AddMarkStep = class _AddMarkStep extends Step {
39684
39890
  /**
@@ -39795,7 +40001,7 @@ var AddNodeMarkStep = class _AddNodeMarkStep extends Step {
39795
40001
  if (!node)
39796
40002
  return StepResult.fail("No node at mark step's position");
39797
40003
  let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
39798
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
40004
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
39799
40005
  }
39800
40006
  invert(doc) {
39801
40007
  let node = doc.nodeAt(this.pos);
@@ -39841,7 +40047,7 @@ var RemoveNodeMarkStep = class _RemoveNodeMarkStep extends Step {
39841
40047
  if (!node)
39842
40048
  return StepResult.fail("No node at mark step's position");
39843
40049
  let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
39844
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
40050
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
39845
40051
  }
39846
40052
  invert(doc) {
39847
40053
  let node = doc.nodeAt(this.pos);
@@ -40042,7 +40248,7 @@ var AttrStep = class _AttrStep extends Step {
40042
40248
  attrs[name] = node.attrs[name];
40043
40249
  attrs[this.attr] = this.value;
40044
40250
  let updated = node.type.create(attrs, null, node.marks);
40045
- return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment31.from(updated), 0, node.isLeaf ? 0 : 1));
40251
+ return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment30.from(updated), 0, node.isLeaf ? 0 : 1));
40046
40252
  }
40047
40253
  getMap() {
40048
40254
  return StepMap.empty;
@@ -40426,7 +40632,7 @@ var NodeSelection2 = class _NodeSelection extends Selection {
40426
40632
  return new _NodeSelection($pos);
40427
40633
  }
40428
40634
  content() {
40429
- return new Slice(Fragment31.from(this.node), 0, 0);
40635
+ return new Slice(Fragment30.from(this.node), 0, 0);
40430
40636
  }
40431
40637
  eq(other) {
40432
40638
  return other instanceof _NodeSelection && other.anchor == this.anchor;
@@ -41039,7 +41245,7 @@ function cellAround2($pos) {
41039
41245
  for (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "row") return $pos.node(0).resolve($pos.before(d + 1));
41040
41246
  return null;
41041
41247
  }
41042
- function isInTable(state) {
41248
+ function isInTable2(state) {
41043
41249
  const $head = state.selection.$head;
41044
41250
  for (let d = $head.depth; d > 0; d--) if ($head.node(d).type.spec.tableRole == "row") return true;
41045
41251
  return false;
@@ -41087,7 +41293,7 @@ function removeColSpan(attrs, pos, n = 1) {
41087
41293
  }
41088
41294
  return result;
41089
41295
  }
41090
- var CellSelection = class CellSelection2 extends Selection {
41296
+ var CellSelection2 = class CellSelection3 extends Selection {
41091
41297
  constructor($anchorCell, $headCell = $anchorCell) {
41092
41298
  const table = $anchorCell.node(-1);
41093
41299
  const map = TableMap4.get(table);
@@ -41111,9 +41317,9 @@ var CellSelection = class CellSelection2 extends Selection {
41111
41317
  const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
41112
41318
  if (pointsAtCell2($anchorCell) && pointsAtCell2($headCell) && inSameTable($anchorCell, $headCell)) {
41113
41319
  const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
41114
- if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
41115
- else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
41116
- else return new CellSelection2($anchorCell, $headCell);
41320
+ if (tableChanged && this.isRowSelection()) return CellSelection3.rowSelection($anchorCell, $headCell);
41321
+ else if (tableChanged && this.isColSelection()) return CellSelection3.colSelection($anchorCell, $headCell);
41322
+ else return new CellSelection3($anchorCell, $headCell);
41117
41323
  }
41118
41324
  return TextSelection5.between($anchorCell, $headCell);
41119
41325
  }
@@ -41154,10 +41360,10 @@ var CellSelection = class CellSelection2 extends Selection {
41154
41360
  }
41155
41361
  rowContent.push(cell);
41156
41362
  }
41157
- rows.push(table.child(row).copy(Fragment31.from(rowContent)));
41363
+ rows.push(table.child(row).copy(Fragment30.from(rowContent)));
41158
41364
  }
41159
41365
  const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
41160
- return new Slice(Fragment31.from(fragment), 1, 1);
41366
+ return new Slice(Fragment30.from(fragment), 1, 1);
41161
41367
  }
41162
41368
  replace(tr, content = Slice.empty) {
41163
41369
  const mapFrom = tr.steps.length, ranges = this.ranges;
@@ -41169,7 +41375,7 @@ var CellSelection = class CellSelection2 extends Selection {
41169
41375
  if (sel) tr.setSelection(sel);
41170
41376
  }
41171
41377
  replaceWith(tr, node) {
41172
- this.replace(tr, new Slice(Fragment31.from(node), 0, 0));
41378
+ this.replace(tr, new Slice(Fragment30.from(node), 0, 0));
41173
41379
  }
41174
41380
  forEachCell(f) {
41175
41381
  const table = this.$anchorCell.node(-1);
@@ -41200,7 +41406,7 @@ var CellSelection = class CellSelection2 extends Selection {
41200
41406
  if (headRect.top > 0) $headCell = doc.resolve(tableStart + map.map[headRect.left]);
41201
41407
  if (anchorRect.bottom < map.height) $anchorCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);
41202
41408
  }
41203
- return new CellSelection2($anchorCell, $headCell);
41409
+ return new CellSelection3($anchorCell, $headCell);
41204
41410
  }
41205
41411
  isRowSelection() {
41206
41412
  const table = this.$anchorCell.node(-1);
@@ -41214,7 +41420,7 @@ var CellSelection = class CellSelection2 extends Selection {
41214
41420
  return Math.max(anchorRight, headRight) == map.width;
41215
41421
  }
41216
41422
  eq(other) {
41217
- return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
41423
+ return other instanceof CellSelection3 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
41218
41424
  }
41219
41425
  static rowSelection($anchorCell, $headCell = $anchorCell) {
41220
41426
  const table = $anchorCell.node(-1);
@@ -41230,7 +41436,7 @@ var CellSelection = class CellSelection2 extends Selection {
41230
41436
  if (headRect.left > 0) $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);
41231
41437
  if (anchorRect.right < map.width) $anchorCell = doc.resolve(tableStart + map.map[map.width * (anchorRect.top + 1) - 1]);
41232
41438
  }
41233
- return new CellSelection2($anchorCell, $headCell);
41439
+ return new CellSelection3($anchorCell, $headCell);
41234
41440
  }
41235
41441
  toJSON() {
41236
41442
  return {
@@ -41240,17 +41446,17 @@ var CellSelection = class CellSelection2 extends Selection {
41240
41446
  };
41241
41447
  }
41242
41448
  static fromJSON(doc, json) {
41243
- return new CellSelection2(doc.resolve(json.anchor), doc.resolve(json.head));
41449
+ return new CellSelection3(doc.resolve(json.anchor), doc.resolve(json.head));
41244
41450
  }
41245
41451
  static create(doc, anchorCell, headCell = anchorCell) {
41246
- return new CellSelection2(doc.resolve(anchorCell), doc.resolve(headCell));
41452
+ return new CellSelection3(doc.resolve(anchorCell), doc.resolve(headCell));
41247
41453
  }
41248
41454
  getBookmark() {
41249
41455
  return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
41250
41456
  }
41251
41457
  };
41252
- CellSelection.prototype.visible = false;
41253
- Selection.jsonID("cell", CellSelection);
41458
+ CellSelection2.prototype.visible = false;
41459
+ Selection.jsonID("cell", CellSelection2);
41254
41460
  var CellBookmark = class CellBookmark2 {
41255
41461
  constructor(anchor, head) {
41256
41462
  this.anchor = anchor;
@@ -41261,7 +41467,7 @@ var CellBookmark = class CellBookmark2 {
41261
41467
  }
41262
41468
  resolve(doc) {
41263
41469
  const $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
41264
- if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection($anchorCell, $headCell);
41470
+ if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection2($anchorCell, $headCell);
41265
41471
  else return Selection.near($headCell, 1);
41266
41472
  }
41267
41473
  };
@@ -41504,7 +41710,7 @@ function moveColumn(moveColParams) {
41504
41710
  const $lastCell = tr.doc.resolve(start + lastCell);
41505
41711
  const firstCell = map.positionAt(0, index, newTable);
41506
41712
  const $firstCell = tr.doc.resolve(start + firstCell);
41507
- tr.setSelection(CellSelection.colSelection($lastCell, $firstCell));
41713
+ tr.setSelection(CellSelection2.colSelection($lastCell, $firstCell));
41508
41714
  return true;
41509
41715
  }
41510
41716
  function moveTableColumn$1(table, indexesOrigin, indexesTarget, direction) {
@@ -41532,7 +41738,7 @@ function moveRow(moveRowParams) {
41532
41738
  const $lastCell = tr.doc.resolve(start + lastCell);
41533
41739
  const firstCell = map.positionAt(index, 0, newTable);
41534
41740
  const $firstCell = tr.doc.resolve(start + firstCell);
41535
- tr.setSelection(CellSelection.rowSelection($lastCell, $firstCell));
41741
+ tr.setSelection(CellSelection2.rowSelection($lastCell, $firstCell));
41536
41742
  return true;
41537
41743
  }
41538
41744
  function moveTableRow$1(table, indexesOrigin, indexesTarget, direction) {
@@ -41547,7 +41753,7 @@ function selectedRect4(state) {
41547
41753
  const tableStart = $pos.start(-1);
41548
41754
  const map = TableMap4.get(table);
41549
41755
  return {
41550
- ...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
41756
+ ...sel instanceof CellSelection2 ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
41551
41757
  tableStart,
41552
41758
  map,
41553
41759
  table
@@ -41555,7 +41761,7 @@ function selectedRect4(state) {
41555
41761
  }
41556
41762
  function deprecated_toggleHeader(type) {
41557
41763
  return function(state, dispatch) {
41558
- if (!isInTable(state)) return false;
41764
+ if (!isInTable2(state)) return false;
41559
41765
  if (dispatch) {
41560
41766
  const types = tableNodeTypes2(state.schema);
41561
41767
  const rect = selectedRect4(state), tr = state.tr;
@@ -41595,7 +41801,7 @@ function toggleHeader(type, options) {
41595
41801
  options = options || { useDeprecatedLogic: false };
41596
41802
  if (options.useDeprecatedLogic) return deprecated_toggleHeader(type);
41597
41803
  return function(state, dispatch) {
41598
- if (!isInTable(state)) return false;
41804
+ if (!isInTable2(state)) return false;
41599
41805
  if (dispatch) {
41600
41806
  const types = tableNodeTypes2(state.schema);
41601
41807
  const rect = selectedRect4(state), tr = state.tr;
@@ -41629,7 +41835,7 @@ var toggleHeaderColumn = toggleHeader("column", { useDeprecatedLogic: true });
41629
41835
  var toggleHeaderCell = toggleHeader("cell", { useDeprecatedLogic: true });
41630
41836
  function deleteCellSelection(state, dispatch) {
41631
41837
  const sel = state.selection;
41632
- if (!(sel instanceof CellSelection)) return false;
41838
+ if (!(sel instanceof CellSelection2)) return false;
41633
41839
  if (dispatch) {
41634
41840
  const tr = state.tr;
41635
41841
  const baseContent = tableNodeTypes2(state.schema).cell.createAndFill().content;
@@ -41697,7 +41903,7 @@ function arrow(axis, dir) {
41697
41903
  return (state, dispatch, view) => {
41698
41904
  if (!view) return false;
41699
41905
  const sel = state.selection;
41700
- if (sel instanceof CellSelection) return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir));
41906
+ if (sel instanceof CellSelection2) return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir));
41701
41907
  if (axis != "horiz" && !sel.empty) return false;
41702
41908
  const end = atEndOfCell(view, axis, dir);
41703
41909
  if (end == null) return false;
@@ -41718,15 +41924,15 @@ function shiftArrow(axis, dir) {
41718
41924
  if (!view) return false;
41719
41925
  const sel = state.selection;
41720
41926
  let cellSel;
41721
- if (sel instanceof CellSelection) cellSel = sel;
41927
+ if (sel instanceof CellSelection2) cellSel = sel;
41722
41928
  else {
41723
41929
  const end = atEndOfCell(view, axis, dir);
41724
41930
  if (end == null) return false;
41725
- cellSel = new CellSelection(state.doc.resolve(end));
41931
+ cellSel = new CellSelection2(state.doc.resolve(end));
41726
41932
  }
41727
41933
  const $head = nextCell(cellSel.$headCell, axis, dir);
41728
41934
  if (!$head) return false;
41729
- return maybeSetSelection(state, dispatch, new CellSelection(cellSel.$anchorCell, $head));
41935
+ return maybeSetSelection(state, dispatch, new CellSelection2(cellSel.$anchorCell, $head));
41730
41936
  };
41731
41937
  }
41732
41938
  function atEndOfCell(view, axis, dir) {
@@ -41746,7 +41952,7 @@ function atEndOfCell(view, axis, dir) {
41746
41952
  var columnResizingPluginKey2 = new PluginKey5("tableColumnResizing");
41747
41953
 
41748
41954
  // src/components/UEditor/table-controls.tsx
41749
- var import_lucide_react56 = require("lucide-react");
41955
+ var import_lucide_react57 = require("lucide-react");
41750
41956
 
41751
41957
  // src/components/UEditor/table-layout-model.ts
41752
41958
  var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
@@ -41941,15 +42147,19 @@ function buildTableControlLayout(editor, surface, cell) {
41941
42147
  const map = TableMap4.get(tableInfo.node);
41942
42148
  const surfaceRect = surface.getBoundingClientRect();
41943
42149
  const tableRect = table.getBoundingClientRect();
42150
+ const explicitColumnWidths = Array.from(table.querySelectorAll("colgroup > col")).slice(0, map.width).map((column) => parsePixelMetric(column.style.width));
42151
+ const explicitTableWidth = parsePixelMetric(table.style.width) ?? (explicitColumnWidths.length === map.width && explicitColumnWidths.every((width) => width !== null) ? explicitColumnWidths.reduce((sum, width) => sum + width, 0) : null);
42152
+ const explicitRowHeights = rows.map((tableRow) => parsePixelMetric(tableRow.getAttribute("data-row-height")) ?? parsePixelMetric(tableRow.style.height));
42153
+ const explicitTableHeight = explicitRowHeights.every((height) => height !== null) ? explicitRowHeights.reduce((sum, height) => sum + height, 0) : null;
41944
42154
  const wrapperElement = table.closest(".tableWrapper");
41945
42155
  const wrapper = wrapperElement instanceof HTMLElement ? wrapperElement : null;
41946
42156
  const wrapperRect = wrapper?.getBoundingClientRect() ?? tableRect;
41947
42157
  const tableLeft = tableRect.left - surfaceRect.left + surface.scrollLeft;
41948
42158
  const tableTop = tableRect.top - surfaceRect.top + surface.scrollTop;
41949
- const avgRowHeight = metricOrFallback(tableRect.height / rows.length, FALLBACK_TABLE_ROW_HEIGHT);
41950
- const avgColumnWidth = metricOrFallback(tableRect.width / map.width, FALLBACK_TABLE_COLUMN_WIDTH);
41951
- const tableWidth = metricOrFallback(tableRect.width, avgColumnWidth * map.width);
41952
- const tableHeight = metricOrFallback(tableRect.height, avgRowHeight * rows.length);
42159
+ const tableWidth = metricOrFallback(tableRect.width, explicitTableWidth ?? FALLBACK_TABLE_COLUMN_WIDTH * map.width);
42160
+ const tableHeight = metricOrFallback(tableRect.height, explicitTableHeight ?? FALLBACK_TABLE_ROW_HEIGHT * rows.length);
42161
+ const avgRowHeight = metricOrFallback(tableHeight / rows.length, FALLBACK_TABLE_ROW_HEIGHT);
42162
+ const avgColumnWidth = metricOrFallback(tableWidth / map.width, FALLBACK_TABLE_COLUMN_WIDTH);
41953
42163
  const wrapperLeft = wrapperRect.left - surfaceRect.left + surface.scrollLeft;
41954
42164
  const wrapperTop = wrapperRect.top - surfaceRect.top + surface.scrollTop;
41955
42165
  const wrapperWidth = metricOrFallback(wrapperRect.width, tableWidth);
@@ -42308,7 +42518,7 @@ function TableControlMenu({
42308
42518
  transform: shown ? "scale(1)" : "scale(0.82)",
42309
42519
  pointerEvents: shown ? "auto" : "none"
42310
42520
  },
42311
- children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_lucide_react54.MoreHorizontal, { className: "h-4 w-4" })
42521
+ children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_lucide_react54.MoreHorizontal, { "aria-hidden": "true", className: "h-4 w-4" })
42312
42522
  }
42313
42523
  )
42314
42524
  }
@@ -42466,8 +42676,236 @@ function TableColumnHandles({
42466
42676
  }) });
42467
42677
  }
42468
42678
 
42469
- // src/components/UEditor/table-controls.tsx
42679
+ // src/components/UEditor/table-resize-handles.tsx
42680
+ var import_lucide_react56 = require("lucide-react");
42470
42681
  var import_jsx_runtime100 = require("react/jsx-runtime");
42682
+ var HANDLE_BASE_CLASS = cn(
42683
+ "pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center rounded-md",
42684
+ "bg-background/95 text-primary shadow-sm backdrop-blur-sm",
42685
+ "transition-[color,background-color,box-shadow,transform] duration-150",
42686
+ "hover:bg-primary hover:text-primary-foreground hover:shadow-md active:scale-95",
42687
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
42688
+ );
42689
+ function TableResizeHandles({
42690
+ active,
42691
+ ctrlHint,
42692
+ frameRef,
42693
+ layout,
42694
+ onStartResize,
42695
+ resizeBothLabel
42696
+ }) {
42697
+ return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(
42698
+ "div",
42699
+ {
42700
+ ref: frameRef,
42701
+ "data-table-resize-frame": "",
42702
+ "data-resizing": active ? "true" : "false",
42703
+ className: cn(
42704
+ "pointer-events-none absolute z-[38] box-border border border-primary/55",
42705
+ active && "border-primary bg-primary/[0.03]"
42706
+ ),
42707
+ style: {
42708
+ left: layout.tableLeft,
42709
+ top: layout.tableTop,
42710
+ width: layout.tableWidth,
42711
+ height: layout.tableHeight
42712
+ },
42713
+ children: [
42714
+ /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
42715
+ "button",
42716
+ {
42717
+ type: "button",
42718
+ "aria-label": resizeBothLabel,
42719
+ title: `${resizeBothLabel}. ${ctrlHint}`,
42720
+ "data-table-resize-handle": "both",
42721
+ className: cn(
42722
+ HANDLE_BASE_CLASS,
42723
+ "bottom-[-28px] right-[-30px] h-6 w-6 cursor-nwse-resize",
42724
+ active && "bg-primary text-primary-foreground shadow-md"
42725
+ ),
42726
+ onPointerDown: onStartResize,
42727
+ children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_lucide_react56.MoveDiagonal2, { "aria-hidden": "true", className: "h-3.5 w-3.5", strokeWidth: 2.25 })
42728
+ }
42729
+ ),
42730
+ active ? /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
42731
+ "span",
42732
+ {
42733
+ role: "status",
42734
+ "aria-live": "polite",
42735
+ "data-table-resize-dimensions": "",
42736
+ className: "absolute bottom-2 right-2 rounded bg-foreground/85 px-1.5 py-0.5 text-[10px] font-medium text-background shadow-sm",
42737
+ children: `${Math.round(layout.tableWidth)} \xD7 ${Math.round(layout.tableHeight)}`
42738
+ }
42739
+ ) : null
42740
+ ]
42741
+ }
42742
+ );
42743
+ }
42744
+
42745
+ // src/components/UEditor/table-size-utils.ts
42746
+ var MAX_TABLE_DIMENSION = 8192;
42747
+ function positiveMetric(value, fallback) {
42748
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
42749
+ }
42750
+ function normalizeWeightsToTotal(values, total, minimum) {
42751
+ if (values.length === 0) return [];
42752
+ const safeTotal = Math.max(values.length * minimum, Math.round(total));
42753
+ const positiveValues = values.map((value) => positiveMetric(value, 1));
42754
+ const weightSum = positiveValues.reduce((sum, value) => sum + value, 0);
42755
+ const raw = positiveValues.map((value) => value / weightSum * safeTotal);
42756
+ const normalized = raw.map((value) => Math.max(minimum, Math.round(value)));
42757
+ let difference = safeTotal - normalized.reduce((sum, value) => sum + value, 0);
42758
+ while (difference !== 0) {
42759
+ let changed = false;
42760
+ for (let index = normalized.length - 1; index >= 0 && difference !== 0; index -= 1) {
42761
+ if (difference < 0 && normalized[index] <= minimum) continue;
42762
+ normalized[index] += difference > 0 ? 1 : -1;
42763
+ difference += difference > 0 ? -1 : 1;
42764
+ changed = true;
42765
+ }
42766
+ if (!changed) break;
42767
+ }
42768
+ return normalized;
42769
+ }
42770
+ function getLogicalColumnWidths(table, tableMap, fallback) {
42771
+ return Array.from({ length: tableMap.width }, (_, columnIndex) => {
42772
+ const relativeCellPos = tableMap.positionAt(0, columnIndex, table);
42773
+ const cell = table.nodeAt(relativeCellPos);
42774
+ if (!cell) return fallback;
42775
+ const cellStartColumn = tableMap.colCount(relativeCellPos);
42776
+ const widthIndex = columnIndex - cellStartColumn;
42777
+ const colwidth = cell.attrs.colwidth;
42778
+ return positiveMetric(colwidth?.[widthIndex], fallback);
42779
+ });
42780
+ }
42781
+ function getLogicalRowHeights(table, fallback) {
42782
+ const heights = [];
42783
+ table.forEach((row) => {
42784
+ heights.push(positiveMetric(row.attrs.rowHeight, fallback));
42785
+ });
42786
+ return heights;
42787
+ }
42788
+ function createTableSizeSnapshot(editor, anchorPos, startWidth, startHeight) {
42789
+ const tableInfo = findTableInfo(editor, anchorPos);
42790
+ if (!tableInfo) return null;
42791
+ const tableMap = TableMap4.get(tableInfo.node);
42792
+ if (tableMap.width === 0 || tableMap.height === 0) return null;
42793
+ const safeWidth = Math.max(tableMap.width * MIN_RESIZED_TABLE_COLUMN_WIDTH, Math.round(startWidth));
42794
+ const safeHeight = Math.max(tableMap.height * MIN_TABLE_ROW_HEIGHT, Math.round(startHeight));
42795
+ const fallbackColumnWidth = safeWidth / tableMap.width;
42796
+ const fallbackRowHeight = safeHeight / tableMap.height;
42797
+ return {
42798
+ anchorPos,
42799
+ tablePos: tableInfo.pos,
42800
+ startWidth: safeWidth,
42801
+ startHeight: safeHeight,
42802
+ columnWidths: normalizeWeightsToTotal(
42803
+ getLogicalColumnWidths(tableInfo.node, tableMap, fallbackColumnWidth),
42804
+ safeWidth,
42805
+ MIN_RESIZED_TABLE_COLUMN_WIDTH
42806
+ ),
42807
+ rowHeights: normalizeWeightsToTotal(
42808
+ getLogicalRowHeights(tableInfo.node, fallbackRowHeight),
42809
+ safeHeight,
42810
+ MIN_TABLE_ROW_HEIGHT
42811
+ ),
42812
+ minWidth: tableMap.width * MIN_RESIZED_TABLE_COLUMN_WIDTH,
42813
+ minHeight: tableMap.height * MIN_TABLE_ROW_HEIGHT
42814
+ };
42815
+ }
42816
+ function resolveTableResizeDimensions({
42817
+ deltaX,
42818
+ deltaY,
42819
+ lockAxis,
42820
+ preserveRatio,
42821
+ snapshot
42822
+ }) {
42823
+ let width = snapshot.startWidth + deltaX;
42824
+ let height = snapshot.startHeight + deltaY;
42825
+ if (preserveRatio) {
42826
+ const horizontalDrag = Math.abs(deltaX) >= Math.abs(deltaY);
42827
+ const scale = horizontalDrag ? width / snapshot.startWidth : height / snapshot.startHeight;
42828
+ const minScale = Math.max(
42829
+ snapshot.minWidth / snapshot.startWidth,
42830
+ snapshot.minHeight / snapshot.startHeight
42831
+ );
42832
+ const maxScale = Math.min(
42833
+ MAX_TABLE_DIMENSION / snapshot.startWidth,
42834
+ MAX_TABLE_DIMENSION / snapshot.startHeight
42835
+ );
42836
+ const safeScale = Math.min(Math.max(scale, minScale), maxScale);
42837
+ width = snapshot.startWidth * safeScale;
42838
+ height = snapshot.startHeight * safeScale;
42839
+ } else if (lockAxis) {
42840
+ if (Math.abs(deltaX) >= Math.abs(deltaY)) {
42841
+ height = snapshot.startHeight;
42842
+ } else {
42843
+ width = snapshot.startWidth;
42844
+ }
42845
+ }
42846
+ return {
42847
+ width: Math.min(MAX_TABLE_DIMENSION, Math.max(snapshot.minWidth, Math.round(width))),
42848
+ height: Math.min(MAX_TABLE_DIMENSION, Math.max(snapshot.minHeight, Math.round(height)))
42849
+ };
42850
+ }
42851
+ function arraysEqual(left, right) {
42852
+ return Array.isArray(left) && left.length === right.length && left.every((value, index) => value === right[index]);
42853
+ }
42854
+ function applyTableSize(editor, snapshot, dimensions) {
42855
+ const table = editor.state.doc.nodeAt(snapshot.tablePos);
42856
+ if (!table || table.type.name !== "table") return false;
42857
+ const tableMap = TableMap4.get(table);
42858
+ if (tableMap.width !== snapshot.columnWidths.length || tableMap.height !== snapshot.rowHeights.length) {
42859
+ return false;
42860
+ }
42861
+ const resizeWidth = dimensions.width !== snapshot.startWidth;
42862
+ const resizeHeight = dimensions.height !== snapshot.startHeight;
42863
+ if (!resizeWidth && !resizeHeight) return false;
42864
+ const tableStart = snapshot.tablePos + 1;
42865
+ const transaction = editor.state.tr;
42866
+ if (resizeWidth) {
42867
+ const nextColumnWidths = normalizeWeightsToTotal(
42868
+ snapshot.columnWidths,
42869
+ dimensions.width,
42870
+ MIN_RESIZED_TABLE_COLUMN_WIDTH
42871
+ );
42872
+ const seenCellPositions = /* @__PURE__ */ new Set();
42873
+ for (const relativeCellPos of tableMap.map) {
42874
+ if (seenCellPositions.has(relativeCellPos)) continue;
42875
+ seenCellPositions.add(relativeCellPos);
42876
+ const cell = table.nodeAt(relativeCellPos);
42877
+ if (!cell) continue;
42878
+ const cellRect = tableMap.findCell(relativeCellPos);
42879
+ const colwidth = nextColumnWidths.slice(cellRect.left, cellRect.right);
42880
+ if (arraysEqual(cell.attrs.colwidth, colwidth)) continue;
42881
+ transaction.setNodeMarkup(tableStart + relativeCellPos, void 0, {
42882
+ ...cell.attrs,
42883
+ colwidth
42884
+ });
42885
+ }
42886
+ }
42887
+ if (resizeHeight) {
42888
+ const nextRowHeights = normalizeWeightsToTotal(
42889
+ snapshot.rowHeights,
42890
+ dimensions.height,
42891
+ MIN_TABLE_ROW_HEIGHT
42892
+ );
42893
+ table.forEach((row, offset, rowIndex) => {
42894
+ const rowHeight = nextRowHeights[rowIndex];
42895
+ if (row.attrs.rowHeight === rowHeight) return;
42896
+ transaction.setNodeMarkup(tableStart + offset, void 0, {
42897
+ ...row.attrs,
42898
+ rowHeight
42899
+ });
42900
+ });
42901
+ }
42902
+ if (!transaction.docChanged) return false;
42903
+ editor.view.dispatch(transaction);
42904
+ return true;
42905
+ }
42906
+
42907
+ // src/components/UEditor/table-controls.tsx
42908
+ var import_jsx_runtime101 = require("react/jsx-runtime");
42471
42909
  var TABLE_MENU_TOP_OFFSET = 10;
42472
42910
  function nearestIndex(centers, position) {
42473
42911
  let bestIndex = 0;
@@ -42491,19 +42929,22 @@ function getSelectedCell(editor) {
42491
42929
  const domAtPos = editor.view.domAtPos(editor.state.selection.from);
42492
42930
  return getCellFromTarget(domAtPos.node);
42493
42931
  }
42494
- function TableControls({ editor, containerRef }) {
42932
+ function TableControls({ editor, containerRef, showCellInspector = true }) {
42495
42933
  const t = useSmartTranslations("UEditor");
42496
- const [layout, setLayout] = import_react76.default.useState(null);
42497
- const [dragPreview, setDragPreview] = import_react76.default.useState(null);
42498
- const [hoverState, setHoverState] = import_react76.default.useState(DEFAULT_TABLE_HOVER_STATE);
42499
- const [openMenuKey, setOpenMenuKey] = import_react76.default.useState(null);
42500
- const layoutRef = import_react76.default.useRef(null);
42501
- const dragStateRef = import_react76.default.useRef(null);
42502
- const syncFrameRef = import_react76.default.useRef(null);
42503
- import_react76.default.useEffect(() => {
42934
+ const [layout, setLayout] = import_react77.default.useState(null);
42935
+ const [dragPreview, setDragPreview] = import_react77.default.useState(null);
42936
+ const [tableResizeActive, setTableResizeActive] = import_react77.default.useState(false);
42937
+ const [hoverState, setHoverState] = import_react77.default.useState(DEFAULT_TABLE_HOVER_STATE);
42938
+ const [openMenuKey, setOpenMenuKey] = import_react77.default.useState(null);
42939
+ const layoutRef = import_react77.default.useRef(null);
42940
+ const dragStateRef = import_react77.default.useRef(null);
42941
+ const syncFrameRef = import_react77.default.useRef(null);
42942
+ const tableResizeFrameRef = import_react77.default.useRef(null);
42943
+ const tableResizePreviewFrameRef = import_react77.default.useRef(null);
42944
+ import_react77.default.useEffect(() => {
42504
42945
  layoutRef.current = layout;
42505
42946
  }, [layout]);
42506
- const syncFromCell = import_react76.default.useCallback((cell) => {
42947
+ const syncFromCell = import_react77.default.useCallback((cell) => {
42507
42948
  const surface = containerRef.current;
42508
42949
  if (!surface || !cell) {
42509
42950
  setLayout(null);
@@ -42511,23 +42952,23 @@ function TableControls({ editor, containerRef }) {
42511
42952
  }
42512
42953
  setLayout(buildTableControlLayout(editor, surface, cell));
42513
42954
  }, [containerRef, editor]);
42514
- const syncFromSelection = import_react76.default.useCallback(() => {
42955
+ const syncFromSelection = import_react77.default.useCallback(() => {
42515
42956
  syncFromCell(getSelectedCell(editor));
42516
42957
  }, [editor, syncFromCell]);
42517
- const scheduleSyncFromSelection = import_react76.default.useCallback(() => {
42958
+ const scheduleSyncFromSelection = import_react77.default.useCallback(() => {
42518
42959
  if (syncFrameRef.current !== null) return;
42519
42960
  syncFrameRef.current = window.requestAnimationFrame(() => {
42520
42961
  syncFrameRef.current = null;
42521
42962
  syncFromSelection();
42522
42963
  });
42523
42964
  }, [syncFromSelection]);
42524
- import_react76.default.useEffect(() => () => {
42965
+ import_react77.default.useEffect(() => () => {
42525
42966
  if (syncFrameRef.current !== null) {
42526
42967
  window.cancelAnimationFrame(syncFrameRef.current);
42527
42968
  syncFrameRef.current = null;
42528
42969
  }
42529
42970
  }, []);
42530
- const refreshCurrentLayout = import_react76.default.useCallback(() => {
42971
+ const refreshCurrentLayout = import_react77.default.useCallback(() => {
42531
42972
  setLayout((prev) => {
42532
42973
  if (!prev) return prev;
42533
42974
  const surface = containerRef.current;
@@ -42537,12 +42978,45 @@ function TableControls({ editor, containerRef }) {
42537
42978
  return cell ? buildTableControlLayout(editor, surface, cell) : null;
42538
42979
  });
42539
42980
  }, [containerRef, editor]);
42540
- const clearDrag = import_react76.default.useCallback(() => {
42981
+ const updateTableResizePreview = import_react77.default.useCallback((dimensions) => {
42982
+ const frame = tableResizeFrameRef.current;
42983
+ if (!frame) return;
42984
+ frame.style.width = `${dimensions.width}px`;
42985
+ frame.style.height = `${dimensions.height}px`;
42986
+ const dimensionsLabel = frame.querySelector("[data-table-resize-dimensions]");
42987
+ if (dimensionsLabel) {
42988
+ dimensionsLabel.textContent = `${dimensions.width} \xD7 ${dimensions.height}`;
42989
+ }
42990
+ }, []);
42991
+ const resetTableResizePreview = import_react77.default.useCallback(() => {
42992
+ const activeLayout = layoutRef.current;
42993
+ if (!activeLayout) return;
42994
+ updateTableResizePreview({
42995
+ width: Math.round(activeLayout.tableWidth),
42996
+ height: Math.round(activeLayout.tableHeight)
42997
+ });
42998
+ }, [updateTableResizePreview]);
42999
+ const clearDrag = import_react77.default.useCallback(() => {
43000
+ const dragState = dragStateRef.current;
43001
+ if (dragState?.kind === "resize-table") {
43002
+ try {
43003
+ if (dragState.pointerTarget.hasPointerCapture?.(dragState.pointerId)) {
43004
+ dragState.pointerTarget.releasePointerCapture(dragState.pointerId);
43005
+ }
43006
+ } catch {
43007
+ }
43008
+ }
43009
+ if (tableResizePreviewFrameRef.current !== null) {
43010
+ window.cancelAnimationFrame(tableResizePreviewFrameRef.current);
43011
+ tableResizePreviewFrameRef.current = null;
43012
+ }
42541
43013
  dragStateRef.current = null;
42542
43014
  setDragPreview(null);
43015
+ setTableResizeActive(false);
43016
+ resetTableResizePreview();
42543
43017
  document.body.style.cursor = "";
42544
- }, []);
42545
- const updateHoverState = import_react76.default.useCallback((event) => {
43018
+ }, [resetTableResizePreview]);
43019
+ const updateHoverState = import_react77.default.useCallback((event) => {
42546
43020
  const activeLayout = layoutRef.current;
42547
43021
  const surface = containerRef.current;
42548
43022
  if (!activeLayout || !surface || dragStateRef.current) {
@@ -42558,7 +43032,7 @@ function TableControls({ editor, containerRef }) {
42558
43032
  return areTableHoverStatesEqual(prev, nextState) ? prev : nextState;
42559
43033
  });
42560
43034
  }, [containerRef]);
42561
- import_react76.default.useEffect(() => {
43035
+ import_react77.default.useEffect(() => {
42562
43036
  const proseMirror = editor.view.dom;
42563
43037
  const surface = containerRef.current;
42564
43038
  if (!surface) return void 0;
@@ -42581,9 +43055,26 @@ function TableControls({ editor, containerRef }) {
42581
43055
  const cell = event ? getCellFromTarget(event.target) : null;
42582
43056
  syncFromCell(cell ?? getSelectedCell(editor));
42583
43057
  };
43058
+ const handleDoubleClick = (event) => {
43059
+ if (event.button !== 0) return;
43060
+ const cell = getCellFromTarget(event.target);
43061
+ if (!cell || cell.hasAttribute("data-formula")) return;
43062
+ const surface2 = containerRef.current;
43063
+ const nextLayout = surface2 ? buildTableControlLayout(editor, surface2, cell) : null;
43064
+ if (!nextLayout) return;
43065
+ const didSelect = editor.commands.setCellSelection({
43066
+ anchorCell: nextLayout.cellPos,
43067
+ headCell: nextLayout.cellPos
43068
+ });
43069
+ if (!didSelect) return;
43070
+ event.preventDefault();
43071
+ editor.view.focus();
43072
+ setLayout(nextLayout);
43073
+ };
42584
43074
  proseMirror.addEventListener("mouseover", handleMouseOver);
42585
43075
  proseMirror.addEventListener("mouseleave", handleMouseLeave2);
42586
43076
  proseMirror.addEventListener("click", handleFocusIn);
43077
+ proseMirror.addEventListener("dblclick", handleDoubleClick);
42587
43078
  proseMirror.addEventListener("mouseup", handleFocusIn);
42588
43079
  proseMirror.addEventListener("focusin", handleFocusIn);
42589
43080
  surface.addEventListener("mouseover", handleSurfaceMouseMove);
@@ -42598,6 +43089,7 @@ function TableControls({ editor, containerRef }) {
42598
43089
  proseMirror.removeEventListener("mouseover", handleMouseOver);
42599
43090
  proseMirror.removeEventListener("mouseleave", handleMouseLeave2);
42600
43091
  proseMirror.removeEventListener("click", handleFocusIn);
43092
+ proseMirror.removeEventListener("dblclick", handleDoubleClick);
42601
43093
  proseMirror.removeEventListener("mouseup", handleFocusIn);
42602
43094
  proseMirror.removeEventListener("focusin", handleFocusIn);
42603
43095
  surface.removeEventListener("mouseover", handleSurfaceMouseMove);
@@ -42609,37 +43101,37 @@ function TableControls({ editor, containerRef }) {
42609
43101
  editor.off("update", refreshCurrentLayout);
42610
43102
  };
42611
43103
  }, [clearDrag, containerRef, editor, refreshCurrentLayout, syncFromCell, syncFromSelection, updateHoverState]);
42612
- const runAtCellPos = import_react76.default.useCallback((cellPos, command, options) => {
43104
+ const runAtCellPos = import_react77.default.useCallback((cellPos, command, options) => {
42613
43105
  const result = runTableCommandAtCellPos(editor, cellPos, command);
42614
43106
  if (options?.sync !== false) {
42615
43107
  scheduleSyncFromSelection();
42616
43108
  }
42617
43109
  return result;
42618
43110
  }, [editor, scheduleSyncFromSelection]);
42619
- const runAtActiveCell = import_react76.default.useCallback((command, options) => {
43111
+ const runAtActiveCell = import_react77.default.useCallback((command, options) => {
42620
43112
  return runAtCellPos(layoutRef.current?.cellPos ?? null, command, options);
42621
43113
  }, [runAtCellPos]);
42622
- const duplicateRowAt = import_react76.default.useCallback((rowIndex, cellPos) => {
43114
+ const duplicateRowAt = import_react77.default.useCallback((rowIndex, cellPos) => {
42623
43115
  const result = duplicateTableRowAt(editor, rowIndex, cellPos);
42624
43116
  scheduleSyncFromSelection();
42625
43117
  return result;
42626
43118
  }, [editor, scheduleSyncFromSelection]);
42627
- const clearRowAt = import_react76.default.useCallback((rowIndex, cellPos) => {
43119
+ const clearRowAt = import_react77.default.useCallback((rowIndex, cellPos) => {
42628
43120
  const result = clearTableRowAt(editor, rowIndex, cellPos);
42629
43121
  scheduleSyncFromSelection();
42630
43122
  return result;
42631
43123
  }, [editor, scheduleSyncFromSelection]);
42632
- const duplicateColumnAt = import_react76.default.useCallback((columnIndex, cellPos) => {
43124
+ const duplicateColumnAt = import_react77.default.useCallback((columnIndex, cellPos) => {
42633
43125
  const result = duplicateTableColumnAt(editor, columnIndex, cellPos);
42634
43126
  scheduleSyncFromSelection();
42635
43127
  return result;
42636
43128
  }, [editor, scheduleSyncFromSelection]);
42637
- const clearColumnAt = import_react76.default.useCallback((columnIndex, cellPos) => {
43129
+ const clearColumnAt = import_react77.default.useCallback((columnIndex, cellPos) => {
42638
43130
  const result = clearTableColumnAt(editor, columnIndex, cellPos);
42639
43131
  scheduleSyncFromSelection();
42640
43132
  return result;
42641
43133
  }, [editor, scheduleSyncFromSelection]);
42642
- const expandTableBy = import_react76.default.useCallback((rows, cols) => {
43134
+ const expandTableBy = import_react77.default.useCallback((rows, cols) => {
42643
43135
  const activeCellPos = layoutRef.current?.cellPos ?? editor.state.selection.from;
42644
43136
  const result = expandTableFromCell(editor, activeCellPos, rows, cols);
42645
43137
  scheduleSyncFromSelection();
@@ -42648,19 +43140,55 @@ function TableControls({ editor, containerRef }) {
42648
43140
  const canExpandTable = Boolean(layout);
42649
43141
  const controlsVisible = dragPreview !== null;
42650
43142
  const tableMenuOpen = openMenuKey === "table";
42651
- const startAddColumnDrag = import_react76.default.useCallback(() => {
43143
+ const startTableResize = import_react77.default.useCallback((event) => {
43144
+ if (event.button !== 0 || dragStateRef.current) return;
43145
+ const activeLayout = layoutRef.current;
43146
+ if (!activeLayout) return;
43147
+ const snapshot = createTableSizeSnapshot(
43148
+ editor,
43149
+ activeLayout.cellPos,
43150
+ activeLayout.tableWidth,
43151
+ activeLayout.tableHeight
43152
+ );
43153
+ if (!snapshot) return;
43154
+ event.preventDefault();
43155
+ event.stopPropagation();
43156
+ try {
43157
+ event.currentTarget.setPointerCapture?.(event.pointerId);
43158
+ } catch {
43159
+ }
43160
+ setOpenMenuKey(null);
43161
+ setHoverState(DEFAULT_TABLE_HOVER_STATE);
43162
+ setTableResizeActive(true);
43163
+ const pendingDimensions = {
43164
+ width: snapshot.startWidth,
43165
+ height: snapshot.startHeight
43166
+ };
43167
+ dragStateRef.current = {
43168
+ kind: "resize-table",
43169
+ pointerId: event.pointerId,
43170
+ pointerTarget: event.currentTarget,
43171
+ startX: event.clientX,
43172
+ startY: event.clientY,
43173
+ snapshot,
43174
+ pendingDimensions
43175
+ };
43176
+ updateTableResizePreview(pendingDimensions);
43177
+ document.body.style.cursor = "nwse-resize";
43178
+ }, [editor, updateTableResizePreview]);
43179
+ const startAddColumnDrag = import_react77.default.useCallback(() => {
42652
43180
  setOpenMenuKey(null);
42653
43181
  dragStateRef.current = { kind: "add-column", previewCols: 1 };
42654
43182
  setDragPreview({ kind: "add-column", previewCols: 1 });
42655
43183
  document.body.style.cursor = "ew-resize";
42656
43184
  }, []);
42657
- const startAddRowDrag = import_react76.default.useCallback(() => {
43185
+ const startAddRowDrag = import_react77.default.useCallback(() => {
42658
43186
  setOpenMenuKey(null);
42659
43187
  dragStateRef.current = { kind: "add-row", previewRows: 1 };
42660
43188
  setDragPreview({ kind: "add-row", previewRows: 1 });
42661
43189
  document.body.style.cursor = "ns-resize";
42662
43190
  }, []);
42663
- const startRowDrag = import_react76.default.useCallback((rowHandle) => {
43191
+ const startRowDrag = import_react77.default.useCallback((rowHandle) => {
42664
43192
  setOpenMenuKey(null);
42665
43193
  dragStateRef.current = {
42666
43194
  kind: "row",
@@ -42677,7 +43205,7 @@ function TableControls({ editor, containerRef }) {
42677
43205
  });
42678
43206
  document.body.style.cursor = "grabbing";
42679
43207
  }, []);
42680
- const startColumnDrag = import_react76.default.useCallback((columnHandle) => {
43208
+ const startColumnDrag = import_react77.default.useCallback((columnHandle) => {
42681
43209
  setOpenMenuKey(null);
42682
43210
  dragStateRef.current = {
42683
43211
  kind: "column",
@@ -42694,7 +43222,7 @@ function TableControls({ editor, containerRef }) {
42694
43222
  });
42695
43223
  document.body.style.cursor = "grabbing";
42696
43224
  }, []);
42697
- import_react76.default.useEffect(() => {
43225
+ import_react77.default.useEffect(() => {
42698
43226
  const handleMouseMove2 = (event) => {
42699
43227
  const dragState = dragStateRef.current;
42700
43228
  const activeLayout = layoutRef.current;
@@ -42703,6 +43231,9 @@ function TableControls({ editor, containerRef }) {
42703
43231
  const surfaceRect = surface.getBoundingClientRect();
42704
43232
  const relativeX = event.clientX - surfaceRect.left + surface.scrollLeft;
42705
43233
  const relativeY = event.clientY - surfaceRect.top + surface.scrollTop;
43234
+ if (dragState.kind === "resize-table") {
43235
+ return;
43236
+ }
42706
43237
  if (dragState.kind === "row") {
42707
43238
  const targetHandleIndex = nearestIndex(activeLayout.rowHandles.map((item) => item.center), relativeY);
42708
43239
  const targetRow = activeLayout.rowHandles[targetHandleIndex];
@@ -42747,7 +43278,7 @@ function TableControls({ editor, containerRef }) {
42747
43278
  };
42748
43279
  const handleMouseUp = () => {
42749
43280
  const dragState = dragStateRef.current;
42750
- if (!dragState) return;
43281
+ if (!dragState || dragState.kind === "resize-table") return;
42751
43282
  if (dragState.kind === "row" && dragState.originIndex !== dragState.targetIndex) {
42752
43283
  moveTableRow({
42753
43284
  from: dragState.originIndex,
@@ -42783,126 +43314,193 @@ function TableControls({ editor, containerRef }) {
42783
43314
  window.removeEventListener("blur", clearDrag);
42784
43315
  };
42785
43316
  }, [clearDrag, containerRef, editor, expandTableBy, scheduleSyncFromSelection]);
42786
- const menuItems = import_react76.default.useMemo(() => {
43317
+ import_react77.default.useEffect(() => {
43318
+ const handlePointerMove = (event) => {
43319
+ const dragState = dragStateRef.current;
43320
+ if (!dragState || dragState.kind !== "resize-table" || event.pointerId !== dragState.pointerId) return;
43321
+ dragState.pendingDimensions = resolveTableResizeDimensions({
43322
+ deltaX: event.clientX - dragState.startX,
43323
+ deltaY: event.clientY - dragState.startY,
43324
+ lockAxis: event.ctrlKey && !event.shiftKey,
43325
+ preserveRatio: event.ctrlKey && event.shiftKey,
43326
+ snapshot: dragState.snapshot
43327
+ });
43328
+ if (tableResizePreviewFrameRef.current === null) {
43329
+ tableResizePreviewFrameRef.current = window.requestAnimationFrame(() => {
43330
+ tableResizePreviewFrameRef.current = null;
43331
+ const currentDragState = dragStateRef.current;
43332
+ if (!currentDragState || currentDragState.kind !== "resize-table") return;
43333
+ updateTableResizePreview(currentDragState.pendingDimensions);
43334
+ });
43335
+ }
43336
+ document.body.style.cursor = "nwse-resize";
43337
+ if (event.cancelable) event.preventDefault();
43338
+ };
43339
+ const finishTableResize = (event, commit) => {
43340
+ const dragState = dragStateRef.current;
43341
+ if (!dragState || dragState.kind !== "resize-table" || event.pointerId !== dragState.pointerId) return;
43342
+ if (tableResizePreviewFrameRef.current !== null) {
43343
+ window.cancelAnimationFrame(tableResizePreviewFrameRef.current);
43344
+ tableResizePreviewFrameRef.current = null;
43345
+ }
43346
+ updateTableResizePreview(dragState.pendingDimensions);
43347
+ if (commit && applyTableSize(editor, dragState.snapshot, dragState.pendingDimensions)) {
43348
+ scheduleSyncFromSelection();
43349
+ }
43350
+ clearDrag();
43351
+ };
43352
+ const handlePointerUp = (event) => finishTableResize(event, true);
43353
+ const handlePointerCancel = (event) => finishTableResize(event, false);
43354
+ window.addEventListener("pointermove", handlePointerMove, { passive: false });
43355
+ window.addEventListener("pointerup", handlePointerUp);
43356
+ window.addEventListener("pointercancel", handlePointerCancel);
43357
+ return () => {
43358
+ window.removeEventListener("pointermove", handlePointerMove);
43359
+ window.removeEventListener("pointerup", handlePointerUp);
43360
+ window.removeEventListener("pointercancel", handlePointerCancel);
43361
+ if (tableResizePreviewFrameRef.current !== null) {
43362
+ window.cancelAnimationFrame(tableResizePreviewFrameRef.current);
43363
+ tableResizePreviewFrameRef.current = null;
43364
+ }
43365
+ };
43366
+ }, [clearDrag, editor, scheduleSyncFromSelection, updateTableResizePreview]);
43367
+ const openCellInspector = import_react77.default.useCallback(() => {
43368
+ const cellPos = layoutRef.current?.cellPos;
43369
+ if (!showCellInspector || cellPos == null) return;
43370
+ const didSelect = editor.commands.setCellSelection({
43371
+ anchorCell: cellPos,
43372
+ headCell: cellPos
43373
+ });
43374
+ if (!didSelect) return;
43375
+ window.requestAnimationFrame(() => {
43376
+ if (!editor.isDestroyed) editor.view.focus();
43377
+ });
43378
+ }, [editor, showCellInspector]);
43379
+ const menuItems = import_react77.default.useMemo(() => {
42787
43380
  if (!layout) return [];
42788
43381
  return [
43382
+ ...showCellInspector ? [{
43383
+ label: t("tableMenu.cellFormatting"),
43384
+ icon: import_lucide_react57.Paintbrush,
43385
+ onClick: openCellInspector
43386
+ }] : [],
42789
43387
  {
42790
43388
  label: t("tableMenu.alignLeft"),
42791
- icon: import_lucide_react56.AlignLeft,
43389
+ icon: import_lucide_react57.AlignLeft,
42792
43390
  onClick: () => applyTableAlignment(editor, "left", layout.cellPos)
42793
43391
  },
42794
43392
  {
42795
43393
  label: t("tableMenu.alignCenter"),
42796
- icon: import_lucide_react56.AlignCenter,
43394
+ icon: import_lucide_react57.AlignCenter,
42797
43395
  onClick: () => applyTableAlignment(editor, "center", layout.cellPos)
42798
43396
  },
42799
43397
  {
42800
43398
  label: t("tableMenu.alignRight"),
42801
- icon: import_lucide_react56.AlignRight,
43399
+ icon: import_lucide_react57.AlignRight,
42802
43400
  onClick: () => applyTableAlignment(editor, "right", layout.cellPos)
42803
43401
  },
42804
43402
  {
42805
43403
  label: t("tableMenu.addColumnBefore"),
42806
- icon: import_lucide_react56.ArrowLeft,
43404
+ icon: import_lucide_react57.ArrowLeft,
42807
43405
  onClick: () => runAtActiveCell((chain) => chain.addColumnBefore())
42808
43406
  },
42809
43407
  {
42810
43408
  label: t("tableMenu.addColumnAfter"),
42811
- icon: import_lucide_react56.ArrowRight,
43409
+ icon: import_lucide_react57.ArrowRight,
42812
43410
  onClick: () => runAtActiveCell((chain) => chain.addColumnAfter())
42813
43411
  },
42814
43412
  {
42815
43413
  label: t("tableMenu.addRowBefore"),
42816
- icon: import_lucide_react56.ArrowUp,
43414
+ icon: import_lucide_react57.ArrowUp,
42817
43415
  onClick: () => runAtActiveCell((chain) => chain.addRowBefore())
42818
43416
  },
42819
43417
  {
42820
43418
  label: t("tableMenu.addRowAfter"),
42821
- icon: import_lucide_react56.ArrowDown,
43419
+ icon: import_lucide_react57.ArrowDown,
42822
43420
  onClick: () => runAtActiveCell((chain) => chain.addRowAfter())
42823
43421
  },
42824
43422
  {
42825
43423
  label: t("tableMenu.toggleHeaderRow"),
42826
- icon: import_lucide_react56.Table,
43424
+ icon: import_lucide_react57.Table,
42827
43425
  onClick: () => runAtActiveCell((chain) => chain.toggleHeaderRow())
42828
43426
  },
42829
43427
  {
42830
43428
  label: t("tableMenu.toggleHeaderColumn"),
42831
- icon: import_lucide_react56.Table,
43429
+ icon: import_lucide_react57.Table,
42832
43430
  onClick: () => runAtActiveCell((chain) => chain.toggleHeaderColumn())
42833
43431
  },
42834
43432
  {
42835
43433
  label: t("tableMenu.deleteColumn"),
42836
- icon: import_lucide_react56.Trash2,
43434
+ icon: import_lucide_react57.Trash2,
42837
43435
  onClick: () => runAtActiveCell((chain) => chain.deleteColumn()),
42838
43436
  destructive: true
42839
43437
  },
42840
43438
  {
42841
43439
  label: t("tableMenu.deleteRow"),
42842
- icon: import_lucide_react56.Trash2,
43440
+ icon: import_lucide_react57.Trash2,
42843
43441
  onClick: () => runAtActiveCell((chain) => chain.deleteRow()),
42844
43442
  destructive: true
42845
43443
  },
42846
43444
  {
42847
43445
  label: t("tableMenu.deleteTable"),
42848
- icon: import_lucide_react56.Trash2,
43446
+ icon: import_lucide_react57.Trash2,
42849
43447
  onClick: () => runAtActiveCell((chain) => chain.deleteTable()),
42850
43448
  destructive: true
42851
43449
  }
42852
43450
  ];
42853
- }, [editor, layout, runAtActiveCell, t]);
42854
- const getRowHandleMenuItems = import_react76.default.useCallback((rowHandle) => [
43451
+ }, [editor, layout, openCellInspector, runAtActiveCell, showCellInspector, t]);
43452
+ const getRowHandleMenuItems = import_react77.default.useCallback((rowHandle) => [
42855
43453
  {
42856
43454
  label: t("tableMenu.addRowBefore"),
42857
- icon: import_lucide_react56.ArrowUp,
43455
+ icon: import_lucide_react57.ArrowUp,
42858
43456
  onClick: () => runAtCellPos(rowHandle.cellPos, (chain) => chain.addRowBefore())
42859
43457
  },
42860
43458
  {
42861
43459
  label: t("tableMenu.addRowAfter"),
42862
- icon: import_lucide_react56.ArrowDown,
43460
+ icon: import_lucide_react57.ArrowDown,
42863
43461
  onClick: () => runAtCellPos(rowHandle.cellPos, (chain) => chain.addRowAfter())
42864
43462
  },
42865
43463
  {
42866
43464
  label: t("tableMenu.duplicateRow"),
42867
- icon: import_lucide_react56.Copy,
43465
+ icon: import_lucide_react57.Copy,
42868
43466
  onClick: () => duplicateRowAt(rowHandle.index, rowHandle.cellPos)
42869
43467
  },
42870
43468
  {
42871
43469
  label: t("tableMenu.clearRowContents"),
42872
- icon: import_lucide_react56.Table,
43470
+ icon: import_lucide_react57.Table,
42873
43471
  onClick: () => clearRowAt(rowHandle.index, rowHandle.cellPos)
42874
43472
  },
42875
43473
  {
42876
43474
  label: t("tableMenu.deleteRow"),
42877
- icon: import_lucide_react56.Trash2,
43475
+ icon: import_lucide_react57.Trash2,
42878
43476
  onClick: () => runAtCellPos(rowHandle.cellPos, (chain) => chain.deleteRow()),
42879
43477
  destructive: true
42880
43478
  }
42881
43479
  ], [clearRowAt, duplicateRowAt, runAtCellPos, t]);
42882
- const getColumnHandleMenuItems = import_react76.default.useCallback((columnHandle) => [
43480
+ const getColumnHandleMenuItems = import_react77.default.useCallback((columnHandle) => [
42883
43481
  {
42884
43482
  label: t("tableMenu.addColumnBefore"),
42885
- icon: import_lucide_react56.ArrowLeft,
43483
+ icon: import_lucide_react57.ArrowLeft,
42886
43484
  onClick: () => runAtCellPos(columnHandle.cellPos, (chain) => chain.addColumnBefore())
42887
43485
  },
42888
43486
  {
42889
43487
  label: t("tableMenu.addColumnAfter"),
42890
- icon: import_lucide_react56.ArrowRight,
43488
+ icon: import_lucide_react57.ArrowRight,
42891
43489
  onClick: () => runAtCellPos(columnHandle.cellPos, (chain) => chain.addColumnAfter())
42892
43490
  },
42893
43491
  {
42894
43492
  label: t("tableMenu.duplicateColumn"),
42895
- icon: import_lucide_react56.Copy,
43493
+ icon: import_lucide_react57.Copy,
42896
43494
  onClick: () => duplicateColumnAt(columnHandle.index, columnHandle.cellPos)
42897
43495
  },
42898
43496
  {
42899
43497
  label: t("tableMenu.clearColumnContents"),
42900
- icon: import_lucide_react56.Table,
43498
+ icon: import_lucide_react57.Table,
42901
43499
  onClick: () => clearColumnAt(columnHandle.index, columnHandle.cellPos)
42902
43500
  },
42903
43501
  {
42904
43502
  label: t("tableMenu.deleteColumn"),
42905
- icon: import_lucide_react56.Trash2,
43503
+ icon: import_lucide_react57.Trash2,
42906
43504
  onClick: () => runAtCellPos(columnHandle.cellPos, (chain) => chain.deleteColumn()),
42907
43505
  destructive: true
42908
43506
  }
@@ -42914,8 +43512,8 @@ function TableControls({ editor, containerRef }) {
42914
43512
  const menuLeft = Math.max(8, layout.tableLeft);
42915
43513
  const rowHandleLeft = layout.tableLeft - 12;
42916
43514
  const columnHandleTop = layout.tableTop - 12;
42917
- return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_jsx_runtime100.Fragment, { children: [
42918
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
43515
+ return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
43516
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
42919
43517
  TableRowHandles,
42920
43518
  {
42921
43519
  activeRowIndex: layout.activeRowIndex,
@@ -42932,7 +43530,7 @@ function TableControls({ editor, containerRef }) {
42932
43530
  rowHandles: layout.rowHandles
42933
43531
  }
42934
43532
  ),
42935
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
43533
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
42936
43534
  TableColumnHandles,
42937
43535
  {
42938
43536
  activeColumnIndex: layout.activeColumnIndex,
@@ -42949,7 +43547,7 @@ function TableControls({ editor, containerRef }) {
42949
43547
  openMenuKey
42950
43548
  }
42951
43549
  ),
42952
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
43550
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
42953
43551
  TableControlMenu,
42954
43552
  {
42955
43553
  controlsVisible,
@@ -42964,7 +43562,18 @@ function TableControls({ editor, containerRef }) {
42964
43562
  top: menuTop
42965
43563
  }
42966
43564
  ),
42967
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
43565
+ dragPreview === null && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
43566
+ TableResizeHandles,
43567
+ {
43568
+ active: tableResizeActive,
43569
+ ctrlHint: t("tableMenu.resizeCtrlHint"),
43570
+ frameRef: tableResizeFrameRef,
43571
+ layout,
43572
+ onStartResize: startTableResize,
43573
+ resizeBothLabel: t("tableMenu.resizeBoth")
43574
+ }
43575
+ ),
43576
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
42968
43577
  TableAddRails,
42969
43578
  {
42970
43579
  addColumnVisible: hoverState.addColumnVisible,
@@ -42978,7 +43587,7 @@ function TableControls({ editor, containerRef }) {
42978
43587
  quickAddRowLabel: t("tableMenu.quickAddRowAfter")
42979
43588
  }
42980
43589
  ),
42981
- /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
43590
+ /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
42982
43591
  TableDragPreview,
42983
43592
  {
42984
43593
  columnDragLabel: t("tableMenu.dragColumn"),
@@ -43196,10 +43805,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
43196
43805
  );
43197
43806
 
43198
43807
  // src/components/UEditor/use-table-interactions.ts
43199
- var import_react78 = __toESM(require("react"), 1);
43808
+ var import_react79 = __toESM(require("react"), 1);
43200
43809
 
43201
43810
  // src/components/UEditor/use-table-row-resize.ts
43202
- var import_react77 = __toESM(require("react"), 1);
43811
+ var import_react78 = __toESM(require("react"), 1);
43203
43812
  function useTableRowResize({
43204
43813
  editor,
43205
43814
  setHoveredTableCell,
@@ -43208,16 +43817,16 @@ function useTableRowResize({
43208
43817
  clearAllTableResizeHover,
43209
43818
  scheduleTableLayoutSync
43210
43819
  }) {
43211
- const stateRef = (0, import_react77.useRef)(null);
43212
- const syncActiveGuide = import_react77.default.useCallback(() => {
43820
+ const stateRef = (0, import_react78.useRef)(null);
43821
+ const syncActiveGuide = import_react78.default.useCallback(() => {
43213
43822
  const state = stateRef.current;
43214
43823
  if (!state) return false;
43215
43824
  setHoveredTableCell(state.cellElement);
43216
43825
  showRowGuide(state.tableElement, state.rowElement, state.cellElement, state.pendingHeight);
43217
43826
  return true;
43218
43827
  }, [setHoveredTableCell, showRowGuide]);
43219
- const isResizing = import_react77.default.useCallback(() => stateRef.current !== null, []);
43220
- const beginResize = import_react77.default.useCallback((event, table, row, cell) => {
43828
+ const isResizing = import_react78.default.useCallback(() => stateRef.current !== null, []);
43829
+ const beginResize = import_react78.default.useCallback((event, table, row, cell) => {
43221
43830
  if (!editor || !isRowResizeHotspot(cell, event.clientX, event.clientY)) {
43222
43831
  return false;
43223
43832
  }
@@ -43243,7 +43852,7 @@ function useTableRowResize({
43243
43852
  event.stopPropagation();
43244
43853
  return true;
43245
43854
  }, [editor, setHoveredTableCell, showRowGuide]);
43246
- const handlePointerMove = import_react77.default.useCallback((event) => {
43855
+ const handlePointerMove = import_react78.default.useCallback((event) => {
43247
43856
  const state = stateRef.current;
43248
43857
  if (!state) return;
43249
43858
  const nextHeight = Math.max(
@@ -43260,7 +43869,7 @@ function useTableRowResize({
43260
43869
  document.body.style.cursor = "row-resize";
43261
43870
  showRowGuide(state.tableElement, state.rowElement, state.cellElement, nextHeight);
43262
43871
  }, [showRowGuide]);
43263
- const handlePointerUp = import_react77.default.useCallback((event) => {
43872
+ const handlePointerUp = import_react78.default.useCallback((event) => {
43264
43873
  if (!editor) return;
43265
43874
  const state = stateRef.current;
43266
43875
  if (!state) return;
@@ -43284,7 +43893,7 @@ function useTableRowResize({
43284
43893
  clearAllTableResizeHover();
43285
43894
  scheduleTableLayoutSync();
43286
43895
  }, [clearAllTableResizeHover, clearHoveredTableCell, editor, scheduleTableLayoutSync]);
43287
- const cancelResize = import_react77.default.useCallback(() => {
43896
+ const cancelResize = import_react78.default.useCallback(() => {
43288
43897
  if (!stateRef.current) return;
43289
43898
  stateRef.current = null;
43290
43899
  document.body.style.cursor = "";
@@ -43292,7 +43901,7 @@ function useTableRowResize({
43292
43901
  clearAllTableResizeHover();
43293
43902
  scheduleTableLayoutSync();
43294
43903
  }, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
43295
- const cleanup = import_react77.default.useCallback(() => {
43904
+ const cleanup = import_react78.default.useCallback(() => {
43296
43905
  stateRef.current = null;
43297
43906
  document.body.style.cursor = "";
43298
43907
  }, []);
@@ -43309,24 +43918,24 @@ function useTableRowResize({
43309
43918
 
43310
43919
  // src/components/UEditor/use-table-interactions.ts
43311
43920
  function useUEditorTableInteractions(editor, editable = true) {
43312
- const editorContentRef = (0, import_react78.useRef)(null);
43313
- const tableColumnGuideRef = (0, import_react78.useRef)(null);
43314
- const tableRowGuideRef = (0, import_react78.useRef)(null);
43315
- const activeTableCellHighlightRef = (0, import_react78.useRef)(null);
43316
- const hoveredTableCellRef = (0, import_react78.useRef)(null);
43317
- const activeTableCellRef = (0, import_react78.useRef)(null);
43318
- const suppressActiveCellHighlightRef = (0, import_react78.useRef)(false);
43319
- const tableLayoutSyncFrameRef = (0, import_react78.useRef)(null);
43320
- const getProseMirrorElement = import_react78.default.useCallback(() => {
43921
+ const editorContentRef = (0, import_react79.useRef)(null);
43922
+ const tableColumnGuideRef = (0, import_react79.useRef)(null);
43923
+ const tableRowGuideRef = (0, import_react79.useRef)(null);
43924
+ const activeTableCellHighlightRef = (0, import_react79.useRef)(null);
43925
+ const hoveredTableCellRef = (0, import_react79.useRef)(null);
43926
+ const activeTableCellRef = (0, import_react79.useRef)(null);
43927
+ const suppressActiveCellHighlightRef = (0, import_react79.useRef)(false);
43928
+ const tableLayoutSyncFrameRef = (0, import_react79.useRef)(null);
43929
+ const getProseMirrorElement = import_react79.default.useCallback(() => {
43321
43930
  return editorContentRef.current?.querySelector(".ProseMirror");
43322
43931
  }, []);
43323
- const setEditorResizeCursor = import_react78.default.useCallback((cursor) => {
43932
+ const setEditorResizeCursor = import_react79.default.useCallback((cursor) => {
43324
43933
  const proseMirror = getProseMirrorElement();
43325
43934
  if (proseMirror) {
43326
43935
  proseMirror.style.cursor = cursor;
43327
43936
  }
43328
43937
  }, [getProseMirrorElement]);
43329
- const hideColumnGuide = import_react78.default.useCallback(() => {
43938
+ const hideColumnGuide = import_react79.default.useCallback(() => {
43330
43939
  editorContentRef.current?.classList.remove("resize-cursor");
43331
43940
  getProseMirrorElement()?.classList.remove("resize-cursor");
43332
43941
  const guide = tableColumnGuideRef.current;
@@ -43334,7 +43943,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43334
43943
  guide.style.opacity = "0";
43335
43944
  }
43336
43945
  }, [getProseMirrorElement]);
43337
- const hideRowGuide = import_react78.default.useCallback(() => {
43946
+ const hideRowGuide = import_react79.default.useCallback(() => {
43338
43947
  editorContentRef.current?.classList.remove("resize-row-cursor");
43339
43948
  getProseMirrorElement()?.classList.remove("resize-row-cursor");
43340
43949
  const guide = tableRowGuideRef.current;
@@ -43342,12 +43951,12 @@ function useUEditorTableInteractions(editor, editable = true) {
43342
43951
  guide.style.opacity = "0";
43343
43952
  }
43344
43953
  }, [getProseMirrorElement]);
43345
- const clearAllTableResizeHover = import_react78.default.useCallback(() => {
43954
+ const clearAllTableResizeHover = import_react79.default.useCallback(() => {
43346
43955
  setEditorResizeCursor("");
43347
43956
  hideColumnGuide();
43348
43957
  hideRowGuide();
43349
43958
  }, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
43350
- const updateActiveCellHighlight = import_react78.default.useCallback((cell) => {
43959
+ const updateActiveCellHighlight = import_react79.default.useCallback((cell) => {
43351
43960
  const surface = editorContentRef.current;
43352
43961
  const highlight = activeTableCellHighlightRef.current;
43353
43962
  if (!highlight) return;
@@ -43362,7 +43971,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43362
43971
  highlight.style.width = `${metrics.width}px`;
43363
43972
  highlight.style.height = `${metrics.height}px`;
43364
43973
  }, []);
43365
- const scheduleTableLayoutSync = import_react78.default.useCallback(() => {
43974
+ const scheduleTableLayoutSync = import_react79.default.useCallback(() => {
43366
43975
  if (tableLayoutSyncFrameRef.current !== null) return;
43367
43976
  tableLayoutSyncFrameRef.current = window.requestAnimationFrame(() => {
43368
43977
  tableLayoutSyncFrameRef.current = null;
@@ -43370,7 +43979,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43370
43979
  editorContentRef.current?.dispatchEvent(new CustomEvent(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT));
43371
43980
  });
43372
43981
  }, [updateActiveCellHighlight]);
43373
- const setActiveTableCell = import_react78.default.useCallback((cell) => {
43982
+ const setActiveTableCell = import_react79.default.useCallback((cell) => {
43374
43983
  if (activeTableCellRef.current === cell) {
43375
43984
  updateActiveCellHighlight(cell);
43376
43985
  return;
@@ -43378,17 +43987,17 @@ function useUEditorTableInteractions(editor, editable = true) {
43378
43987
  activeTableCellRef.current = cell;
43379
43988
  updateActiveCellHighlight(activeTableCellRef.current);
43380
43989
  }, [updateActiveCellHighlight]);
43381
- const clearActiveTableCell = import_react78.default.useCallback(() => {
43990
+ const clearActiveTableCell = import_react79.default.useCallback(() => {
43382
43991
  activeTableCellRef.current = null;
43383
43992
  updateActiveCellHighlight(null);
43384
43993
  }, [updateActiveCellHighlight]);
43385
- const setHoveredTableCell = import_react78.default.useCallback((cell) => {
43994
+ const setHoveredTableCell = import_react79.default.useCallback((cell) => {
43386
43995
  hoveredTableCellRef.current = cell;
43387
43996
  }, []);
43388
- const clearHoveredTableCell = import_react78.default.useCallback(() => {
43997
+ const clearHoveredTableCell = import_react79.default.useCallback(() => {
43389
43998
  hoveredTableCellRef.current = null;
43390
43999
  }, []);
43391
- const showColumnGuide = import_react78.default.useCallback((table, row, cell) => {
44000
+ const showColumnGuide = import_react79.default.useCallback((table, row, cell) => {
43392
44001
  const surface = editorContentRef.current;
43393
44002
  const guide = tableColumnGuideRef.current;
43394
44003
  if (!surface || !guide) return;
@@ -43402,7 +44011,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43402
44011
  getProseMirrorElement()?.classList.add("resize-cursor");
43403
44012
  setEditorResizeCursor("col-resize");
43404
44013
  }, [getProseMirrorElement, setEditorResizeCursor]);
43405
- const showRowGuide = import_react78.default.useCallback((table, row, cell, previewHeight) => {
44014
+ const showRowGuide = import_react79.default.useCallback((table, row, cell, previewHeight) => {
43406
44015
  const surface = editorContentRef.current;
43407
44016
  const guide = tableRowGuideRef.current;
43408
44017
  if (!surface || !guide) return;
@@ -43434,7 +44043,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43434
44043
  clearAllTableResizeHover,
43435
44044
  scheduleTableLayoutSync
43436
44045
  });
43437
- const syncActiveTableCellFromSelection = import_react78.default.useCallback(() => {
44046
+ const syncActiveTableCellFromSelection = import_react79.default.useCallback(() => {
43438
44047
  if (!editor) return;
43439
44048
  if (!editor.isFocused) {
43440
44049
  clearActiveTableCell();
@@ -43442,7 +44051,7 @@ function useUEditorTableInteractions(editor, editable = true) {
43442
44051
  }
43443
44052
  setActiveTableCell(getSelectionTableCell(editor.view));
43444
44053
  }, [clearActiveTableCell, editor, setActiveTableCell]);
43445
- (0, import_react78.useEffect)(() => {
44054
+ (0, import_react79.useEffect)(() => {
43446
44055
  if (!editor || !editable) return void 0;
43447
44056
  const proseMirror = editor.view.dom;
43448
44057
  const surface = editorContentRef.current;
@@ -43617,12 +44226,12 @@ function useUEditorTableInteractions(editor, editable = true) {
43617
44226
  }
43618
44227
 
43619
44228
  // src/components/UEditor/use-formula-coordinate-overlay.ts
43620
- var import_react79 = require("react");
43621
- var import_tables9 = require("@tiptap/pm/tables");
44229
+ var import_react80 = require("react");
44230
+ var import_tables10 = require("@tiptap/pm/tables");
43622
44231
 
43623
44232
  // src/components/UEditor/table-formula-range-picker.ts
43624
44233
  var import_state12 = require("@tiptap/pm/state");
43625
- var import_tables8 = require("@tiptap/pm/tables");
44234
+ var import_tables9 = require("@tiptap/pm/tables");
43626
44235
  function getCellText2(cellNode) {
43627
44236
  return cellNode.textBetween(0, cellNode.content.size, "\n").trim();
43628
44237
  }
@@ -43640,7 +44249,7 @@ function getFormulaEditingTableContext(view) {
43640
44249
  if (!tableNode || tableNode.type.name !== "table") return null;
43641
44250
  const tableDom = cellDom.closest("table");
43642
44251
  if (!(tableDom instanceof HTMLTableElement)) return null;
43643
- const tableMap = import_tables8.TableMap.get(tableNode);
44252
+ const tableMap = import_tables9.TableMap.get(tableNode);
43644
44253
  const tableStart = $from.start(tableDepth);
43645
44254
  const formulaCellRect = tableMap.findCell(cellPos - tableStart);
43646
44255
  return {
@@ -43657,7 +44266,7 @@ function getFormulaEditingTableContext(view) {
43657
44266
  return null;
43658
44267
  }
43659
44268
  function collectTableFormulaCells(tableNode) {
43660
- const tableMap = import_tables8.TableMap.get(tableNode);
44269
+ const tableMap = import_tables9.TableMap.get(tableNode);
43661
44270
  const formulas = [];
43662
44271
  tableNode.forEach((rowNode, rowOffset) => {
43663
44272
  rowNode.forEach((cellNode, cellOffset) => {
@@ -43743,7 +44352,7 @@ function getFormulaTableCellInfo(view, target, tablePos) {
43743
44352
  const domPos = view.posAtDOM(cell, 0);
43744
44353
  const tableInfo = findTableForPos(view, domPos);
43745
44354
  if (!tableInfo || tableInfo.pos !== tablePos) return null;
43746
- const map = import_tables8.TableMap.get(tableInfo.node);
44355
+ const map = import_tables9.TableMap.get(tableInfo.node);
43747
44356
  const relativeCellPos = getCellRelativePosFromDomPos2(map, tableInfo.start, domPos);
43748
44357
  if (relativeCellPos == null) return null;
43749
44358
  const rect = map.findCell(relativeCellPos);
@@ -43887,8 +44496,8 @@ function createBlockedReferenceHighlight(label) {
43887
44496
  return element;
43888
44497
  }
43889
44498
  function useFormulaCoordinateOverlay(editor, containerRef, labels) {
43890
- const overlayRef = (0, import_react79.useRef)(null);
43891
- (0, import_react79.useEffect)(() => {
44499
+ const overlayRef = (0, import_react80.useRef)(null);
44500
+ (0, import_react80.useEffect)(() => {
43892
44501
  if (!editor) return void 0;
43893
44502
  const overlay = overlayRef.current;
43894
44503
  const container = containerRef.current;
@@ -43917,7 +44526,7 @@ function useFormulaCoordinateOverlay(editor, containerRef, labels) {
43917
44526
  const tableRect = context.tableDom.getBoundingClientRect();
43918
44527
  const tableLeft = tableRect.left - containerRect.left + container.scrollLeft;
43919
44528
  const tableTop = tableRect.top - containerRect.top + container.scrollTop;
43920
- const map = import_tables9.TableMap.get(context.tableNode);
44529
+ const map = import_tables10.TableMap.get(context.tableNode);
43921
44530
  const columnSegments = Array(map.width);
43922
44531
  const rowSegments = Array(map.height);
43923
44532
  const cellInfos = [];
@@ -44095,9 +44704,9 @@ function useFormulaCoordinateOverlay(editor, containerRef, labels) {
44095
44704
  }
44096
44705
 
44097
44706
  // src/components/UEditor/menu-bar.tsx
44098
- var import_react80 = __toESM(require("react"), 1);
44099
- var import_react81 = require("@tiptap/react");
44100
- var import_lucide_react57 = require("lucide-react");
44707
+ var import_react81 = __toESM(require("react"), 1);
44708
+ var import_react82 = require("@tiptap/react");
44709
+ var import_lucide_react58 = require("lucide-react");
44101
44710
 
44102
44711
  // src/components/UEditor/preview-html.ts
44103
44712
  var DEFAULT_TABLE_COLUMN_WIDTH2 = 100;
@@ -44236,14 +44845,14 @@ function prepareUEditorPreviewHtml(html) {
44236
44845
  }
44237
44846
 
44238
44847
  // src/components/UEditor/menu-bar.tsx
44239
- var import_jsx_runtime101 = require("react/jsx-runtime");
44848
+ var import_jsx_runtime102 = require("react/jsx-runtime");
44240
44849
  function MenuTableInsertGrid({
44241
44850
  insertLabel,
44242
44851
  previewTemplate,
44243
44852
  onInsert
44244
44853
  }) {
44245
44854
  const closeMenu = useDropdownMenuClose();
44246
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
44855
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44247
44856
  TableInsertGrid,
44248
44857
  {
44249
44858
  insertLabel,
@@ -44259,9 +44868,9 @@ function renderMenuItems(items) {
44259
44868
  return items.map((item, i) => {
44260
44869
  switch (item.type) {
44261
44870
  case "separator":
44262
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(DropdownMenuSeparator, {}, i);
44871
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(DropdownMenuSeparator, {}, i);
44263
44872
  case "action":
44264
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
44873
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44265
44874
  DropdownMenuItem,
44266
44875
  {
44267
44876
  label: item.label,
@@ -44275,9 +44884,9 @@ function renderMenuItems(items) {
44275
44884
  i
44276
44885
  );
44277
44886
  case "sub":
44278
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(DropdownMenuSub, { label: item.label, icon: item.icon, disabled: item.disabled, children: renderMenuItems(item.items) }, i);
44887
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(DropdownMenuSub, { label: item.label, icon: item.icon, disabled: item.disabled, children: renderMenuItems(item.items) }, i);
44279
44888
  case "custom":
44280
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_react80.default.Fragment, { children: item.render() }, item.key);
44889
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_react81.default.Fragment, { children: item.render() }, item.key);
44281
44890
  }
44282
44891
  });
44283
44892
  }
@@ -44315,7 +44924,7 @@ function buildEditMenuItems(t, editor) {
44315
44924
  {
44316
44925
  type: "action",
44317
44926
  label: t("menubar.undo"),
44318
- icon: import_lucide_react57.Undo,
44927
+ icon: import_lucide_react58.Undo,
44319
44928
  shortcut: t("menubar.undoShortcut"),
44320
44929
  onClick: () => editor.chain().focus().undo().run(),
44321
44930
  disabled: !editor.can().undo()
@@ -44323,7 +44932,7 @@ function buildEditMenuItems(t, editor) {
44323
44932
  {
44324
44933
  type: "action",
44325
44934
  label: t("menubar.redo"),
44326
- icon: import_lucide_react57.Redo,
44935
+ icon: import_lucide_react58.Redo,
44327
44936
  shortcut: t("menubar.redoShortcut"),
44328
44937
  onClick: () => editor.chain().focus().redo().run(),
44329
44938
  disabled: !editor.can().redo()
@@ -44332,7 +44941,7 @@ function buildEditMenuItems(t, editor) {
44332
44941
  {
44333
44942
  type: "action",
44334
44943
  label: t("menubar.cut"),
44335
- icon: import_lucide_react57.Scissors,
44944
+ icon: import_lucide_react58.Scissors,
44336
44945
  shortcut: t("menubar.cutShortcut"),
44337
44946
  onClick: () => document.execCommand("cut")
44338
44947
  },
@@ -44380,7 +44989,7 @@ function buildViewMenuItems(t, {
44380
44989
  {
44381
44990
  type: "action",
44382
44991
  label: t("menubar.sourceCode"),
44383
- icon: import_lucide_react57.FileCode,
44992
+ icon: import_lucide_react58.FileCode,
44384
44993
  onClick: () => onSourceCode ? onSourceCode() : openSourceDialog()
44385
44994
  },
44386
44995
  {
@@ -44392,7 +45001,7 @@ function buildViewMenuItems(t, {
44392
45001
  {
44393
45002
  type: "action",
44394
45003
  label: t("menubar.fullscreen"),
44395
- icon: import_lucide_react57.Maximize2,
45004
+ icon: import_lucide_react58.Maximize2,
44396
45005
  shortcut: t("menubar.fullscreenShortcut"),
44397
45006
  onClick: () => {
44398
45007
  const el = containerRef.current;
@@ -44411,7 +45020,7 @@ function buildFormatMenuItems(t, editor) {
44411
45020
  {
44412
45021
  type: "action",
44413
45022
  label: t("menubar.bold"),
44414
- icon: import_lucide_react57.Bold,
45023
+ icon: import_lucide_react58.Bold,
44415
45024
  shortcut: t("menubar.boldShortcut"),
44416
45025
  active: editor.isActive("bold"),
44417
45026
  onClick: () => editor.chain().focus().toggleBold().run()
@@ -44419,7 +45028,7 @@ function buildFormatMenuItems(t, editor) {
44419
45028
  {
44420
45029
  type: "action",
44421
45030
  label: t("menubar.italic"),
44422
- icon: import_lucide_react57.Italic,
45031
+ icon: import_lucide_react58.Italic,
44423
45032
  shortcut: t("menubar.italicShortcut"),
44424
45033
  active: editor.isActive("italic"),
44425
45034
  onClick: () => editor.chain().focus().toggleItalic().run()
@@ -44427,7 +45036,7 @@ function buildFormatMenuItems(t, editor) {
44427
45036
  {
44428
45037
  type: "action",
44429
45038
  label: t("menubar.underline"),
44430
- icon: import_lucide_react57.Underline,
45039
+ icon: import_lucide_react58.Underline,
44431
45040
  shortcut: t("menubar.underlineShortcut"),
44432
45041
  active: editor.isActive("underline"),
44433
45042
  onClick: () => editor.chain().focus().toggleUnderline().run()
@@ -44435,28 +45044,28 @@ function buildFormatMenuItems(t, editor) {
44435
45044
  {
44436
45045
  type: "action",
44437
45046
  label: t("menubar.strike"),
44438
- icon: import_lucide_react57.Strikethrough,
45047
+ icon: import_lucide_react58.Strikethrough,
44439
45048
  active: editor.isActive("strike"),
44440
45049
  onClick: () => editor.chain().focus().toggleStrike().run()
44441
45050
  },
44442
45051
  {
44443
45052
  type: "action",
44444
45053
  label: t("menubar.superscript"),
44445
- icon: import_lucide_react57.Superscript,
45054
+ icon: import_lucide_react58.Superscript,
44446
45055
  active: editor.isActive("superscript"),
44447
45056
  onClick: () => editor.chain().focus().toggleSuperscript().run()
44448
45057
  },
44449
45058
  {
44450
45059
  type: "action",
44451
45060
  label: t("menubar.subscript"),
44452
- icon: import_lucide_react57.Subscript,
45061
+ icon: import_lucide_react58.Subscript,
44453
45062
  active: editor.isActive("subscript"),
44454
45063
  onClick: () => editor.chain().focus().toggleSubscript().run()
44455
45064
  },
44456
45065
  {
44457
45066
  type: "action",
44458
45067
  label: t("menubar.code"),
44459
- icon: import_lucide_react57.Code,
45068
+ icon: import_lucide_react58.Code,
44460
45069
  active: editor.isActive("code"),
44461
45070
  onClick: () => editor.chain().focus().toggleCode().run()
44462
45071
  },
@@ -44474,21 +45083,21 @@ function buildFormatMenuItems(t, editor) {
44474
45083
  {
44475
45084
  type: "action",
44476
45085
  label: t("menubar.heading1"),
44477
- icon: import_lucide_react57.Heading1,
45086
+ icon: import_lucide_react58.Heading1,
44478
45087
  active: editor.isActive("heading", { level: 1 }),
44479
45088
  onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run()
44480
45089
  },
44481
45090
  {
44482
45091
  type: "action",
44483
45092
  label: t("menubar.heading2"),
44484
- icon: import_lucide_react57.Heading2,
45093
+ icon: import_lucide_react58.Heading2,
44485
45094
  active: editor.isActive("heading", { level: 2 }),
44486
45095
  onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run()
44487
45096
  },
44488
45097
  {
44489
45098
  type: "action",
44490
45099
  label: t("menubar.heading3"),
44491
- icon: import_lucide_react57.Heading3,
45100
+ icon: import_lucide_react58.Heading3,
44492
45101
  active: editor.isActive("heading", { level: 3 }),
44493
45102
  onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run()
44494
45103
  },
@@ -44496,21 +45105,21 @@ function buildFormatMenuItems(t, editor) {
44496
45105
  {
44497
45106
  type: "action",
44498
45107
  label: t("menubar.blockquote"),
44499
- icon: import_lucide_react57.Quote,
45108
+ icon: import_lucide_react58.Quote,
44500
45109
  active: editor.isActive("blockquote"),
44501
45110
  onClick: () => editor.chain().focus().toggleBlockquote().run()
44502
45111
  },
44503
45112
  {
44504
45113
  type: "action",
44505
45114
  label: t("menubar.codeBlock"),
44506
- icon: import_lucide_react57.FileCode,
45115
+ icon: import_lucide_react58.FileCode,
44507
45116
  active: editor.isActive("codeBlock"),
44508
45117
  onClick: () => editor.chain().focus().toggleCodeBlock().run()
44509
45118
  },
44510
45119
  {
44511
45120
  type: "action",
44512
45121
  label: t("menubar.taskList"),
44513
- icon: import_lucide_react57.ListTodo,
45122
+ icon: import_lucide_react58.ListTodo,
44514
45123
  active: editor.isActive("taskList"),
44515
45124
  onClick: () => editor.chain().focus().toggleTaskList().run()
44516
45125
  }
@@ -44523,28 +45132,28 @@ function buildFormatMenuItems(t, editor) {
44523
45132
  {
44524
45133
  type: "action",
44525
45134
  label: t("menubar.alignLeft"),
44526
- icon: import_lucide_react57.AlignLeft,
45135
+ icon: import_lucide_react58.AlignLeft,
44527
45136
  active: editor.isActive({ textAlign: "left" }),
44528
45137
  onClick: () => editor.chain().focus().setTextAlign("left").run()
44529
45138
  },
44530
45139
  {
44531
45140
  type: "action",
44532
45141
  label: t("menubar.alignCenter"),
44533
- icon: import_lucide_react57.AlignCenter,
45142
+ icon: import_lucide_react58.AlignCenter,
44534
45143
  active: editor.isActive({ textAlign: "center" }),
44535
45144
  onClick: () => editor.chain().focus().setTextAlign("center").run()
44536
45145
  },
44537
45146
  {
44538
45147
  type: "action",
44539
45148
  label: t("menubar.alignRight"),
44540
- icon: import_lucide_react57.AlignRight,
45149
+ icon: import_lucide_react58.AlignRight,
44541
45150
  active: editor.isActive({ textAlign: "right" }),
44542
45151
  onClick: () => editor.chain().focus().setTextAlign("right").run()
44543
45152
  },
44544
45153
  {
44545
45154
  type: "action",
44546
45155
  label: t("menubar.alignJustify"),
44547
- icon: import_lucide_react57.AlignJustify,
45156
+ icon: import_lucide_react58.AlignJustify,
44548
45157
  active: editor.isActive({ textAlign: "justify" }),
44549
45158
  onClick: () => editor.chain().focus().setTextAlign("justify").run()
44550
45159
  }
@@ -44563,7 +45172,7 @@ function buildToolsMenuItems(t, { onSourceCode, openSourceDialog }) {
44563
45172
  {
44564
45173
  type: "action",
44565
45174
  label: t("menubar.sourceCode"),
44566
- icon: import_lucide_react57.FileCode,
45175
+ icon: import_lucide_react58.FileCode,
44567
45176
  onClick: () => onSourceCode ? onSourceCode() : openSourceDialog()
44568
45177
  }
44569
45178
  ];
@@ -44574,12 +45183,12 @@ function buildTableMenuItems(t, editor, onInsertTable) {
44574
45183
  {
44575
45184
  type: "sub",
44576
45185
  label: t("menubar.insertTable"),
44577
- icon: import_lucide_react57.Table,
45186
+ icon: import_lucide_react58.Table,
44578
45187
  items: [
44579
45188
  {
44580
45189
  type: "custom",
44581
45190
  key: "table-insert-grid",
44582
- render: () => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45191
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44583
45192
  MenuTableInsertGrid,
44584
45193
  {
44585
45194
  insertLabel: t("tableMenu.insertTable"),
@@ -44600,7 +45209,7 @@ function buildTableMenuItems(t, editor, onInsertTable) {
44600
45209
  {
44601
45210
  type: "action",
44602
45211
  label: t("menubar.deleteTable"),
44603
- icon: import_lucide_react57.Trash2,
45212
+ icon: import_lucide_react58.Trash2,
44604
45213
  destructive: true,
44605
45214
  disabled: !inTable,
44606
45215
  onClick: () => editor.chain().focus().deleteTable().run()
@@ -44653,8 +45262,8 @@ function buildTableMenuItems(t, editor, onInsertTable) {
44653
45262
  }
44654
45263
  ];
44655
45264
  }
44656
- var MenuBarTrigger = import_react80.default.forwardRef(
44657
- ({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45265
+ var MenuBarTrigger = import_react81.default.forwardRef(
45266
+ ({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44658
45267
  "button",
44659
45268
  {
44660
45269
  ref,
@@ -44685,18 +45294,18 @@ var MenuBar = ({
44685
45294
  onPreview
44686
45295
  }) => {
44687
45296
  const t = useSmartTranslations("UEditor");
44688
- (0, import_react81.useEditorState)({
45297
+ (0, import_react82.useEditorState)({
44689
45298
  editor,
44690
- selector: ({ transactionNumber }) => transactionNumber
45299
+ selector: ({ editor: currentEditor }) => getEditorUiRenderState(currentEditor)
44691
45300
  });
44692
- const fileInputRef = (0, import_react80.useRef)(null);
44693
- const [showImageInput, setShowImageInput] = (0, import_react80.useState)(false);
44694
- const [showLinkInput, setShowLinkInput] = (0, import_react80.useState)(false);
44695
- const [isInsertMenuOpen, setIsInsertMenuOpen] = (0, import_react80.useState)(false);
44696
- const [showSourceDialog, setShowSourceDialog] = (0, import_react80.useState)(false);
44697
- const [sourceHtml, setSourceHtml] = (0, import_react80.useState)("");
44698
- const [showPreviewDialog, setShowPreviewDialog] = (0, import_react80.useState)(false);
44699
- const previewHtml = (0, import_react80.useMemo)(
45301
+ const fileInputRef = (0, import_react81.useRef)(null);
45302
+ const [showImageInput, setShowImageInput] = (0, import_react81.useState)(false);
45303
+ const [showLinkInput, setShowLinkInput] = (0, import_react81.useState)(false);
45304
+ const [openMenuKey, setOpenMenuKey] = (0, import_react81.useState)(null);
45305
+ const [showSourceDialog, setShowSourceDialog] = (0, import_react81.useState)(false);
45306
+ const [sourceHtml, setSourceHtml] = (0, import_react81.useState)("");
45307
+ const [showPreviewDialog, setShowPreviewDialog] = (0, import_react81.useState)(false);
45308
+ const previewHtml = (0, import_react81.useMemo)(
44700
45309
  () => showPreviewDialog ? prepareUEditorPreviewHtml(editor.getHTML()) : "",
44701
45310
  [editor, showPreviewDialog]
44702
45311
  );
@@ -44716,7 +45325,7 @@ var MenuBar = ({
44716
45325
  setShowSourceDialog(false);
44717
45326
  };
44718
45327
  const closeInsertMenu = () => {
44719
- setIsInsertMenuOpen(false);
45328
+ setOpenMenuKey(null);
44720
45329
  setShowImageInput(false);
44721
45330
  setShowLinkInput(false);
44722
45331
  };
@@ -44743,7 +45352,7 @@ var MenuBar = ({
44743
45352
  } catch {
44744
45353
  }
44745
45354
  }
44746
- setIsInsertMenuOpen(false);
45355
+ closeInsertMenu();
44747
45356
  };
44748
45357
  const handleInsertTable = (rows, cols) => {
44749
45358
  editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
@@ -44757,13 +45366,13 @@ var MenuBar = ({
44757
45366
  {
44758
45367
  type: "custom",
44759
45368
  key: "image",
44760
- render: () => showImageInput ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(ImageInput, { onSubmit: handleImageUrl, onCancel: () => setShowImageInput(false) }) : /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
44761
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(DropdownMenuItem, { label: t("menubar.image"), icon: import_lucide_react57.Image, onClick: () => setShowImageInput(true), closeOnSelect: false }),
44762
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45369
+ render: () => showImageInput ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(ImageInput, { onSubmit: handleImageUrl, onCancel: () => setShowImageInput(false) }) : /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, { children: [
45370
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(DropdownMenuItem, { label: t("menubar.image"), icon: import_lucide_react58.Image, onClick: () => setShowImageInput(true), closeOnSelect: false }),
45371
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44763
45372
  DropdownMenuItem,
44764
45373
  {
44765
45374
  label: t("menubar.imageUpload"),
44766
- icon: import_lucide_react57.Upload,
45375
+ icon: import_lucide_react58.Upload,
44767
45376
  onClick: () => fileInputRef.current?.click(),
44768
45377
  closeOnSelect: false
44769
45378
  }
@@ -44774,11 +45383,11 @@ var MenuBar = ({
44774
45383
  {
44775
45384
  type: "custom",
44776
45385
  key: "link",
44777
- render: () => showLinkInput ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(LinkInput, { onSubmit: handleLinkSubmit, onCancel: () => setShowLinkInput(false), initialUrl: editor.getAttributes("link").href ?? "" }) : /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45386
+ render: () => showLinkInput ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(LinkInput, { onSubmit: handleLinkSubmit, onCancel: () => setShowLinkInput(false), initialUrl: editor.getAttributes("link").href ?? "" }) : /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44778
45387
  DropdownMenuItem,
44779
45388
  {
44780
45389
  label: t("menubar.link"),
44781
- icon: import_lucide_react57.Link,
45390
+ icon: import_lucide_react58.Link,
44782
45391
  shortcut: t("menubar.linkShortcut"),
44783
45392
  onClick: () => setShowLinkInput(true),
44784
45393
  closeOnSelect: false
@@ -44789,12 +45398,12 @@ var MenuBar = ({
44789
45398
  {
44790
45399
  type: "sub",
44791
45400
  label: t("menubar.insertTable"),
44792
- icon: import_lucide_react57.Table,
45401
+ icon: import_lucide_react58.Table,
44793
45402
  items: [
44794
45403
  {
44795
45404
  type: "custom",
44796
45405
  key: "table-grid",
44797
- render: () => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45406
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44798
45407
  MenuTableInsertGrid,
44799
45408
  {
44800
45409
  insertLabel: t("tableMenu.insertTable"),
@@ -44809,24 +45418,24 @@ var MenuBar = ({
44809
45418
  {
44810
45419
  type: "sub",
44811
45420
  label: t("menubar.formFields") || "Form Fields",
44812
- icon: import_lucide_react57.ListTodo,
45421
+ icon: import_lucide_react58.ListTodo,
44813
45422
  items: [
44814
45423
  {
44815
45424
  type: "action",
44816
45425
  label: t("menubar.formCheckbox") || "Form Checkbox",
44817
- icon: import_lucide_react57.Square,
45426
+ icon: import_lucide_react58.Square,
44818
45427
  onClick: () => editor.chain().focus().setFormCheckbox().run()
44819
45428
  },
44820
45429
  {
44821
45430
  type: "action",
44822
45431
  label: t("slashCommand.roundCheckbox") || "Round Checkbox",
44823
- icon: import_lucide_react57.CircleCheckBig,
45432
+ icon: import_lucide_react58.CircleCheckBig,
44824
45433
  onClick: () => editor.chain().focus().setFormCheckbox({ variant: "circle" }).run()
44825
45434
  },
44826
45435
  {
44827
45436
  type: "action",
44828
45437
  label: t("menubar.formRadio") || "Form Radio Button",
44829
- icon: import_lucide_react57.CircleDot,
45438
+ icon: import_lucide_react58.CircleDot,
44830
45439
  onClick: () => editor.chain().focus().setFormRadio().run()
44831
45440
  }
44832
45441
  ]
@@ -44840,41 +45449,31 @@ var MenuBar = ({
44840
45449
  ];
44841
45450
  const menus = [
44842
45451
  {
45452
+ key: "file",
44843
45453
  label: t("menubar.file"),
44844
- items: buildFileMenuItems(t, editor, { onSave, onExport }),
44845
- open: void 0,
44846
- onOpenChange: void 0
45454
+ items: buildFileMenuItems(t, editor, { onSave, onExport })
44847
45455
  },
44848
- { label: t("menubar.edit"), items: buildEditMenuItems(t, editor), open: void 0, onOpenChange: void 0 },
45456
+ { key: "edit", label: t("menubar.edit"), items: buildEditMenuItems(t, editor) },
44849
45457
  {
45458
+ key: "view",
44850
45459
  label: t("menubar.view"),
44851
- items: buildViewMenuItems(t, { containerRef, onSourceCode, openSourceDialog, onPreview: handlePreview, openPreviewDialog }),
44852
- open: void 0,
44853
- onOpenChange: void 0
45460
+ items: buildViewMenuItems(t, { containerRef, onSourceCode, openSourceDialog, onPreview: handlePreview, openPreviewDialog })
44854
45461
  },
44855
45462
  {
45463
+ key: "insert",
44856
45464
  label: t("menubar.insert"),
44857
- items: insertMenuItems,
44858
- open: isInsertMenuOpen,
44859
- onOpenChange: (open) => {
44860
- setIsInsertMenuOpen(open);
44861
- if (!open) {
44862
- setShowImageInput(false);
44863
- setShowLinkInput(false);
44864
- }
44865
- }
45465
+ items: insertMenuItems
44866
45466
  },
44867
- { label: t("menubar.format"), items: buildFormatMenuItems(t, editor), open: void 0, onOpenChange: void 0 },
45467
+ { key: "format", label: t("menubar.format"), items: buildFormatMenuItems(t, editor) },
44868
45468
  {
45469
+ key: "tools",
44869
45470
  label: t("menubar.tools"),
44870
- items: buildToolsMenuItems(t, { onSourceCode, openSourceDialog }),
44871
- open: void 0,
44872
- onOpenChange: void 0
45471
+ items: buildToolsMenuItems(t, { onSourceCode, openSourceDialog })
44873
45472
  },
44874
- { label: t("menubar.table"), items: buildTableMenuItems(t, editor, handleInsertTable), open: void 0, onOpenChange: void 0 }
45473
+ { key: "table", label: t("menubar.table"), items: buildTableMenuItems(t, editor, handleInsertTable) }
44875
45474
  ];
44876
- return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)(import_jsx_runtime101.Fragment, { children: [
44877
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45475
+ return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_jsx_runtime102.Fragment, { children: [
45476
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44878
45477
  "input",
44879
45478
  {
44880
45479
  ref: fileInputRef,
@@ -44885,19 +45484,26 @@ var MenuBar = ({
44885
45484
  onChange: (e) => handleImageFiles(e.target.files)
44886
45485
  }
44887
45486
  ),
44888
- /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "flex items-center gap-0.5 border-b border-border/35 bg-muted/20 px-1.5 py-0.5", children: [
44889
- menus.map(({ label, items, open, onOpenChange }) => /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45487
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center gap-0.5 border-b border-border/35 bg-muted/20 px-1.5 py-0.5", children: [
45488
+ menus.map(({ key, label, items }) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44890
45489
  DropdownMenu,
44891
45490
  {
44892
- trigger: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(MenuBarTrigger, { children: label }),
45491
+ trigger: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(MenuBarTrigger, { children: label }),
44893
45492
  placement: "bottom-start",
44894
- isOpen: open,
44895
- onOpenChange,
45493
+ isOpen: openMenuKey === key,
45494
+ onOpenChange: (open) => {
45495
+ setOpenMenuKey((current) => open ? key : current === key ? null : current);
45496
+ if (key === "insert" && !open) {
45497
+ setShowImageInput(false);
45498
+ setShowLinkInput(false);
45499
+ }
45500
+ },
45501
+ openOnHover: true,
44896
45502
  children: renderMenuItems(items)
44897
45503
  },
44898
- label
45504
+ key
44899
45505
  )),
44900
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45506
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44901
45507
  "button",
44902
45508
  {
44903
45509
  type: "button",
@@ -44908,20 +45514,20 @@ var MenuBar = ({
44908
45514
  "ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors",
44909
45515
  "hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1"
44910
45516
  ),
44911
- children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_lucide_react57.Eye, { className: "h-4 w-4", "aria-hidden": "true" })
45517
+ children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.Eye, { className: "h-4 w-4", "aria-hidden": "true" })
44912
45518
  }
44913
45519
  )
44914
45520
  ] }),
44915
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45521
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44916
45522
  Modal_default,
44917
45523
  {
44918
45524
  isOpen: showSourceDialog,
44919
45525
  onClose: () => setShowSourceDialog(false),
44920
45526
  title: t("menubar.sourceCode"),
44921
45527
  size: "lg",
44922
- children: /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "space-y-3", children: [
44923
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("p", { className: "text-xs text-muted-foreground", children: t("menubar.sourceCodeHint") }),
44924
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45528
+ children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "space-y-3", children: [
45529
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "text-xs text-muted-foreground", children: t("menubar.sourceCodeHint") }),
45530
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44925
45531
  "textarea",
44926
45532
  {
44927
45533
  "data-testid": "source-code-textarea",
@@ -44931,8 +45537,8 @@ var MenuBar = ({
44931
45537
  spellCheck: false
44932
45538
  }
44933
45539
  ),
44934
- /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "flex gap-2 justify-end", children: [
44935
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45540
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex gap-2 justify-end", children: [
45541
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44936
45542
  "button",
44937
45543
  {
44938
45544
  type: "button",
@@ -44941,7 +45547,7 @@ var MenuBar = ({
44941
45547
  children: t("menubar.applySource")
44942
45548
  }
44943
45549
  ),
44944
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45550
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44945
45551
  "button",
44946
45552
  {
44947
45553
  type: "button",
@@ -44954,7 +45560,7 @@ var MenuBar = ({
44954
45560
  ] })
44955
45561
  }
44956
45562
  ),
44957
- /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45563
+ /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44958
45564
  Modal_default,
44959
45565
  {
44960
45566
  isOpen: showPreviewDialog,
@@ -44965,12 +45571,12 @@ var MenuBar = ({
44965
45571
  height: "min(860px, calc(100vh - 2rem))",
44966
45572
  className: "flex flex-col overflow-hidden rounded-xl md:rounded-2xl",
44967
45573
  contentClassName: "flex min-h-0 flex-1 overflow-hidden p-0",
44968
- children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45574
+ children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44969
45575
  "div",
44970
45576
  {
44971
45577
  "data-testid": "preview-content",
44972
45578
  className: "min-h-0 flex-1 overflow-y-auto overscroll-contain",
44973
- children: editor.isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
45579
+ children: editor.isEmpty ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "text-muted-foreground text-sm", children: t("menubar.previewEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
44974
45580
  "div",
44975
45581
  {
44976
45582
  className: UEDITOR_PROSEMIRROR_CLASS_NAME,
@@ -44985,20 +45591,33 @@ var MenuBar = ({
44985
45591
  };
44986
45592
 
44987
45593
  // src/components/UEditor/table-formula-bar.tsx
44988
- var import_react82 = require("react");
44989
- var import_react83 = require("@tiptap/react");
44990
- var import_lucide_react58 = require("lucide-react");
44991
- var import_jsx_runtime102 = require("react/jsx-runtime");
45594
+ var import_react83 = require("react");
45595
+ var import_react84 = require("@tiptap/react");
45596
+ var import_lucide_react59 = require("lucide-react");
45597
+ var import_jsx_runtime103 = require("react/jsx-runtime");
44992
45598
  function TableFormulaBar({ editor }) {
44993
45599
  const t = useSmartTranslations("UEditor");
44994
- const inputRef = (0, import_react82.useRef)(null);
44995
- const [draftState, setDraftState] = (0, import_react82.useState)(null);
44996
- (0, import_react83.useEditorState)({
45600
+ const inputRef = (0, import_react83.useRef)(null);
45601
+ const [draftState, setDraftState] = (0, import_react83.useState)(null);
45602
+ const selectedFormulaState = (0, import_react84.useEditorState)({
44997
45603
  editor,
44998
- selector: ({ transactionNumber }) => transactionNumber
45604
+ selector: ({ editor: currentEditor }) => {
45605
+ const cell = getSelectedTableFormulaCell(currentEditor);
45606
+ if (!cell) return null;
45607
+ return {
45608
+ cellPos: cell.cellPos,
45609
+ column: cell.column,
45610
+ computedValue: cell.computedValue,
45611
+ formula: cell.formula,
45612
+ formulaState: cell.formulaState,
45613
+ label: cell.label,
45614
+ row: cell.row,
45615
+ tablePos: cell.tablePos
45616
+ };
45617
+ }
44999
45618
  });
45000
- const selectedCell = getSelectedTableFormulaCell(editor);
45001
- (0, import_react82.useEffect)(() => {
45619
+ const selectedCell = selectedFormulaState ? getSelectedTableFormulaCell(editor) : null;
45620
+ (0, import_react83.useEffect)(() => {
45002
45621
  const focusFormulaInput = () => {
45003
45622
  inputRef.current?.focus();
45004
45623
  };
@@ -45038,7 +45657,7 @@ function TableFormulaBar({ editor }) {
45038
45657
  if (!editor.isDestroyed) editor.commands.focus();
45039
45658
  }, 0);
45040
45659
  };
45041
- return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
45660
+ return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
45042
45661
  "div",
45043
45662
  {
45044
45663
  "data-ueditor-formula-bar": "",
@@ -45046,7 +45665,7 @@ function TableFormulaBar({ editor }) {
45046
45665
  "aria-label": t("tableMenu.formulaBar"),
45047
45666
  className: "flex min-h-10 items-center gap-2 border-b border-border/60 bg-muted/25 px-2 py-1.5",
45048
45667
  children: [
45049
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
45668
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45050
45669
  "span",
45051
45670
  {
45052
45671
  "data-ueditor-formula-cell-label": "",
@@ -45054,8 +45673,8 @@ function TableFormulaBar({ editor }) {
45054
45673
  children: selectedCell.label
45055
45674
  }
45056
45675
  ),
45057
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.Sigma, { "aria-hidden": "true", className: "h-4 w-4 shrink-0 text-primary" }),
45058
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
45676
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_lucide_react59.Sigma, { "aria-hidden": "true", className: "h-4 w-4 shrink-0 text-primary" }),
45677
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45059
45678
  "input",
45060
45679
  {
45061
45680
  ref: inputRef,
@@ -45076,18 +45695,18 @@ function TableFormulaBar({ editor }) {
45076
45695
  className: "h-7 min-w-0 flex-1 rounded-md border border-border/60 bg-background px-2 font-mono text-sm text-foreground outline-none focus:border-primary/40 focus:ring-2 focus:ring-primary/15"
45077
45696
  }
45078
45697
  ),
45079
- selectedCell.formulaState === "error" && /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
45698
+ selectedCell.formulaState === "error" && /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
45080
45699
  "span",
45081
45700
  {
45082
45701
  role: "status",
45083
45702
  className: "hidden shrink-0 items-center gap-1 text-xs font-medium text-destructive sm:inline-flex",
45084
45703
  children: [
45085
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.AlertCircle, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
45704
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_lucide_react59.AlertCircle, { "aria-hidden": "true", className: "h-3.5 w-3.5" }),
45086
45705
  t("tableMenu.formulaError")
45087
45706
  ]
45088
45707
  }
45089
45708
  ),
45090
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
45709
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45091
45710
  "button",
45092
45711
  {
45093
45712
  type: "button",
@@ -45095,10 +45714,10 @@ function TableFormulaBar({ editor }) {
45095
45714
  "aria-label": t("tableMenu.apply"),
45096
45715
  title: t("tableMenu.apply"),
45097
45716
  className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground transition-colors hover:bg-primary/90",
45098
- children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.Check, { "aria-hidden": "true", className: "h-4 w-4" })
45717
+ children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_lucide_react59.Check, { "aria-hidden": "true", className: "h-4 w-4" })
45099
45718
  }
45100
45719
  ),
45101
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
45720
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45102
45721
  "button",
45103
45722
  {
45104
45723
  type: "button",
@@ -45109,10 +45728,10 @@ function TableFormulaBar({ editor }) {
45109
45728
  "aria-label": t("tableMenu.convertToValue"),
45110
45729
  title: t("tableMenu.convertToValue"),
45111
45730
  className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border/60 bg-background text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
45112
- children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.Hash, { "aria-hidden": "true", className: "h-4 w-4" })
45731
+ children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_lucide_react59.Hash, { "aria-hidden": "true", className: "h-4 w-4" })
45113
45732
  }
45114
45733
  ),
45115
- /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
45734
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45116
45735
  "button",
45117
45736
  {
45118
45737
  type: "button",
@@ -45123,7 +45742,7 @@ function TableFormulaBar({ editor }) {
45123
45742
  "aria-label": t("tableMenu.clearCell"),
45124
45743
  title: t("tableMenu.clearCell"),
45125
45744
  className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-destructive/30 bg-background text-destructive transition-colors hover:bg-destructive/10",
45126
- children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_lucide_react58.Trash2, { "aria-hidden": "true", className: "h-4 w-4" })
45745
+ children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_lucide_react59.Trash2, { "aria-hidden": "true", className: "h-4 w-4" })
45127
45746
  }
45128
45747
  )
45129
45748
  ]
@@ -45132,8 +45751,8 @@ function TableFormulaBar({ editor }) {
45132
45751
  }
45133
45752
 
45134
45753
  // src/components/UEditor/UEditor.tsx
45135
- var import_jsx_runtime103 = require("react/jsx-runtime");
45136
- var UEditor = import_react84.default.forwardRef(({
45754
+ var import_jsx_runtime104 = require("react/jsx-runtime");
45755
+ var UEditor = import_react85.default.forwardRef(({
45137
45756
  content = "",
45138
45757
  onChange,
45139
45758
  onHtmlChange,
@@ -45175,14 +45794,15 @@ var UEditor = import_react84.default.forwardRef(({
45175
45794
  }, ref) => {
45176
45795
  const t = useSmartTranslations("UEditor");
45177
45796
  const effectivePlaceholder = placeholder ?? t("placeholder");
45178
- const inFlightPrepareRef = (0, import_react84.useRef)(null);
45179
- const lastAppliedContentRef = (0, import_react84.useRef)(content ?? "");
45180
- const scheduledFormulaRecalculateRef = (0, import_react84.useRef)(false);
45181
- const editorInstanceRef = (0, import_react84.useRef)(null);
45182
- const formulaRangePickRef = (0, import_react84.useRef)(null);
45183
- const formulaRangeSurfaceRef = (0, import_react84.useRef)(null);
45184
- const [formulaRangeHighlight, setFormulaRangeHighlight] = import_react84.default.useState(null);
45185
- const scheduleFormulaRecalculate = import_react84.default.useCallback((editor2, options) => {
45797
+ const inFlightPrepareRef = (0, import_react85.useRef)(null);
45798
+ const lastAppliedContentRef = (0, import_react85.useRef)(content ?? "");
45799
+ const scheduledFormulaRecalculateRef = (0, import_react85.useRef)(false);
45800
+ const pendingFormulaTextRecalculateRef = (0, import_react85.useRef)(false);
45801
+ const editorInstanceRef = (0, import_react85.useRef)(null);
45802
+ const formulaRangePickRef = (0, import_react85.useRef)(null);
45803
+ const formulaRangeSurfaceRef = (0, import_react85.useRef)(null);
45804
+ const [formulaRangeHighlight, setFormulaRangeHighlight] = import_react85.default.useState(null);
45805
+ const scheduleFormulaRecalculate = import_react85.default.useCallback((editor2, options) => {
45186
45806
  if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
45187
45807
  if (!options?.force && isEditingTableFormulaText(editor2)) return;
45188
45808
  scheduledFormulaRecalculateRef.current = true;
@@ -45193,7 +45813,7 @@ var UEditor = import_react84.default.forwardRef(({
45193
45813
  }
45194
45814
  });
45195
45815
  }, []);
45196
- const resolvedUploadFile = (0, import_react84.useMemo)(() => {
45816
+ const resolvedUploadFile = (0, import_react85.useMemo)(() => {
45197
45817
  if (uploadFile) return uploadFile;
45198
45818
  if (uploadFileForSave) {
45199
45819
  return async (file) => {
@@ -45203,7 +45823,7 @@ var UEditor = import_react84.default.forwardRef(({
45203
45823
  }
45204
45824
  return uploadImage;
45205
45825
  }, [uploadFile, uploadFileForSave, uploadImage]);
45206
- const extensions = (0, import_react84.useMemo)(
45826
+ const extensions = (0, import_react85.useMemo)(
45207
45827
  () => [
45208
45828
  ...buildUEditorExtensions({
45209
45829
  placeholder: effectivePlaceholder,
@@ -45222,11 +45842,11 @@ var UEditor = import_react84.default.forwardRef(({
45222
45842
  ],
45223
45843
  [effectivePlaceholder, t, maxCharacters, uploadImage, resolvedUploadFile, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, editable, fetchMetadata, extraExtensions]
45224
45844
  );
45225
- const syncFormulaRangeHighlight = import_react84.default.useCallback((pickState) => {
45845
+ const syncFormulaRangeHighlight = import_react85.default.useCallback((pickState) => {
45226
45846
  const container = formulaRangeSurfaceRef.current;
45227
45847
  setFormulaRangeHighlight(container && pickState ? getFormulaRangePickHighlight(container, pickState) : null);
45228
45848
  }, []);
45229
- const editor = (0, import_react85.useEditor)({
45849
+ const editor = (0, import_react86.useEditor)({
45230
45850
  immediatelyRender: false,
45231
45851
  extensions,
45232
45852
  content,
@@ -45316,23 +45936,36 @@ var UEditor = import_react84.default.forwardRef(({
45316
45936
  },
45317
45937
  onUpdate: ({ editor: editor2, transaction }) => {
45318
45938
  if (!transaction.getMeta(UEDITOR_TABLE_FORMULA_RECALCULATE_META)) {
45319
- scheduleFormulaRecalculate(editor2);
45939
+ if (isEditingTableFormulaText(editor2)) {
45940
+ pendingFormulaTextRecalculateRef.current = true;
45941
+ } else {
45942
+ pendingFormulaTextRecalculateRef.current = false;
45943
+ scheduleFormulaRecalculate(editor2);
45944
+ }
45945
+ }
45946
+ if (onChange || onHtmlChange) {
45947
+ const html = editor2.getHTML();
45948
+ onChange?.(html);
45949
+ onHtmlChange?.(html);
45950
+ }
45951
+ if (onJsonChange) {
45952
+ onJsonChange(editor2.getJSON());
45320
45953
  }
45321
- const html = editor2.getHTML();
45322
- onChange?.(html);
45323
- onHtmlChange?.(html);
45324
- onJsonChange?.(editor2.getJSON());
45325
45954
  },
45326
45955
  onSelectionUpdate: ({ editor: editor2 }) => {
45327
- scheduleFormulaRecalculate(editor2);
45956
+ if (pendingFormulaTextRecalculateRef.current && !isEditingTableFormulaText(editor2)) {
45957
+ pendingFormulaTextRecalculateRef.current = false;
45958
+ scheduleFormulaRecalculate(editor2);
45959
+ }
45328
45960
  },
45329
45961
  onBlur: ({ editor: editor2, event }) => {
45330
45962
  const nextTarget = event.relatedTarget;
45331
45963
  if (nextTarget instanceof Element && nextTarget.closest("[data-ueditor-formula-bar]")) return;
45964
+ pendingFormulaTextRecalculateRef.current = false;
45332
45965
  scheduleFormulaRecalculate(editor2, { force: true });
45333
45966
  }
45334
45967
  });
45335
- (0, import_react84.useEffect)(() => {
45968
+ (0, import_react85.useEffect)(() => {
45336
45969
  editorInstanceRef.current = editor;
45337
45970
  return () => {
45338
45971
  if (editorInstanceRef.current === editor) editorInstanceRef.current = null;
@@ -45348,7 +45981,7 @@ var UEditor = import_react84.default.forwardRef(({
45348
45981
  apply: t("tableMenu.apply"),
45349
45982
  cancel: t("imageInput.cancelBtn")
45350
45983
  });
45351
- (0, import_react84.useImperativeHandle)(
45984
+ (0, import_react85.useImperativeHandle)(
45352
45985
  ref,
45353
45986
  () => ({
45354
45987
  editor,
@@ -45373,7 +46006,7 @@ var UEditor = import_react84.default.forwardRef(({
45373
46006
  }),
45374
46007
  [content, editor, uploadImageForSave, uploadFileForSave, uploadImageConcurrency]
45375
46008
  );
45376
- (0, import_react84.useEffect)(() => {
46009
+ (0, import_react85.useEffect)(() => {
45377
46010
  if (!editor) return;
45378
46011
  queueMicrotask(() => {
45379
46012
  if (!editor.isDestroyed) {
@@ -45381,7 +46014,7 @@ var UEditor = import_react84.default.forwardRef(({
45381
46014
  }
45382
46015
  });
45383
46016
  }, [editor]);
45384
- (0, import_react84.useEffect)(() => {
46017
+ (0, import_react85.useEffect)(() => {
45385
46018
  if (!editor) return;
45386
46019
  const nextContent = content ?? "";
45387
46020
  if (lastAppliedContentRef.current === nextContent) return;
@@ -45400,7 +46033,7 @@ var UEditor = import_react84.default.forwardRef(({
45400
46033
  }
45401
46034
  }, [content, editor]);
45402
46035
  if (!editor) {
45403
- return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46036
+ return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45404
46037
  "div",
45405
46038
  {
45406
46039
  className: cn("w-full border bg-background flex items-center justify-center text-muted-foreground", className),
@@ -45409,7 +46042,7 @@ var UEditor = import_react84.default.forwardRef(({
45409
46042
  }
45410
46043
  );
45411
46044
  }
45412
- return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
46045
+ return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
45413
46046
  "div",
45414
46047
  {
45415
46048
  className: cn(
@@ -45425,7 +46058,7 @@ var UEditor = import_react84.default.forwardRef(({
45425
46058
  className
45426
46059
  ),
45427
46060
  children: [
45428
- editable && showMenuBar && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46061
+ editable && showMenuBar && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45429
46062
  MenuBar,
45430
46063
  {
45431
46064
  editor,
@@ -45440,7 +46073,7 @@ var UEditor = import_react84.default.forwardRef(({
45440
46073
  onPreview
45441
46074
  }
45442
46075
  ),
45443
- editable && showToolbar && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46076
+ editable && showToolbar && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45444
46077
  EditorToolbar,
45445
46078
  {
45446
46079
  editor,
@@ -45455,8 +46088,8 @@ var UEditor = import_react84.default.forwardRef(({
45455
46088
  letterSpacings
45456
46089
  }
45457
46090
  ),
45458
- editable && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(TableFormulaBar, { editor }),
45459
- editable && showBubbleMenu && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46091
+ editable && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(TableFormulaBar, { editor }),
46092
+ editable && showBubbleMenu && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45460
46093
  CustomBubbleMenu,
45461
46094
  {
45462
46095
  editor,
@@ -45464,8 +46097,8 @@ var UEditor = import_react84.default.forwardRef(({
45464
46097
  lineHeights
45465
46098
  }
45466
46099
  ),
45467
- editable && showFloatingMenu && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(CustomFloatingMenu, { editor }),
45468
- /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
46100
+ editable && showFloatingMenu && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(CustomFloatingMenu, { editor }),
46101
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(
45469
46102
  "div",
45470
46103
  {
45471
46104
  ref: (node) => {
@@ -45478,7 +46111,7 @@ var UEditor = import_react84.default.forwardRef(({
45478
46111
  maxHeight
45479
46112
  },
45480
46113
  children: [
45481
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46114
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45482
46115
  "span",
45483
46116
  {
45484
46117
  ref: tableColumnGuideRef,
@@ -45486,7 +46119,7 @@ var UEditor = import_react84.default.forwardRef(({
45486
46119
  className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
45487
46120
  }
45488
46121
  ),
45489
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46122
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45490
46123
  "span",
45491
46124
  {
45492
46125
  ref: tableRowGuideRef,
@@ -45494,7 +46127,7 @@ var UEditor = import_react84.default.forwardRef(({
45494
46127
  className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
45495
46128
  }
45496
46129
  ),
45497
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46130
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45498
46131
  "span",
45499
46132
  {
45500
46133
  ref: activeTableCellHighlightRef,
@@ -45503,7 +46136,7 @@ var UEditor = import_react84.default.forwardRef(({
45503
46136
  className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10"
45504
46137
  }
45505
46138
  ),
45506
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46139
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45507
46140
  "div",
45508
46141
  {
45509
46142
  ref: formulaCoordinateOverlayRef,
@@ -45511,7 +46144,7 @@ var UEditor = import_react84.default.forwardRef(({
45511
46144
  className: "pointer-events-none absolute inset-0 z-[35] hidden overflow-visible"
45512
46145
  }
45513
46146
  ),
45514
- formulaRangeHighlight && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
46147
+ formulaRangeHighlight && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
45515
46148
  "span",
45516
46149
  {
45517
46150
  "aria-hidden": "true",
@@ -45529,9 +46162,16 @@ var UEditor = import_react84.default.forwardRef(({
45529
46162
  }
45530
46163
  }
45531
46164
  ),
45532
- editable && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(TableControls, { editor, containerRef: editorContentRef }),
45533
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
45534
- import_react85.EditorContent,
46165
+ editable && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
46166
+ TableControls,
46167
+ {
46168
+ editor,
46169
+ containerRef: editorContentRef,
46170
+ showCellInspector: showBubbleMenu
46171
+ }
46172
+ ),
46173
+ /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
46174
+ import_react86.EditorContent,
45535
46175
  {
45536
46176
  editor,
45537
46177
  className: "min-h-full"
@@ -45540,7 +46180,7 @@ var UEditor = import_react84.default.forwardRef(({
45540
46180
  ]
45541
46181
  }
45542
46182
  ),
45543
- showFooter && showCharacterCount && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(CharacterCountDisplay, { editor, maxCharacters })
46183
+ showFooter && showCharacterCount && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(CharacterCountDisplay, { editor, maxCharacters })
45544
46184
  ]
45545
46185
  }
45546
46186
  );