@underverse-ui/underverse 1.0.159 → 1.0.160

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
@@ -3619,7 +3619,7 @@ var Tooltip = React10.forwardRef(({
3619
3619
  setIsOpen(true);
3620
3620
  }, delayOpen);
3621
3621
  };
3622
- const handleMouseLeave = () => {
3622
+ const handleMouseLeave2 = () => {
3623
3623
  clearTimeout(timeoutRef.current);
3624
3624
  timeoutRef.current = setTimeout(() => {
3625
3625
  setIsOpen(false);
@@ -3744,7 +3744,7 @@ var Tooltip = React10.forwardRef(({
3744
3744
  childProps.onMouseLeave,
3745
3745
  (e) => {
3746
3746
  triggerRef.current = e.currentTarget;
3747
- handleMouseLeave();
3747
+ handleMouseLeave2();
3748
3748
  }
3749
3749
  ),
3750
3750
  onPointerDown: chainEventHandlers(
@@ -18103,18 +18103,18 @@ function OverlayControls({
18103
18103
  setControlsVisible(false);
18104
18104
  }, autoHideDelay);
18105
18105
  };
18106
- const handleMouseMove = () => resetTimer();
18107
- const handleMouseLeave = () => {
18106
+ const handleMouseMove2 = () => resetTimer();
18107
+ const handleMouseLeave2 = () => {
18108
18108
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
18109
18109
  hideTimerRef.current = setTimeout(() => {
18110
18110
  setControlsVisible(false);
18111
18111
  }, autoHideDelay);
18112
18112
  };
18113
18113
  resetTimer();
18114
- document.addEventListener("mousemove", handleMouseMove);
18114
+ document.addEventListener("mousemove", handleMouseMove2);
18115
18115
  return () => {
18116
18116
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
18117
- document.removeEventListener("mousemove", handleMouseMove);
18117
+ document.removeEventListener("mousemove", handleMouseMove2);
18118
18118
  };
18119
18119
  }, [autoHide, autoHideDelay, showOnHover]);
18120
18120
  const showFeedback = import_react21.default.useCallback((type, value2) => {
@@ -27219,7 +27219,8 @@ var import_core9 = require("@tiptap/core");
27219
27219
  var import_react56 = require("@tiptap/react");
27220
27220
 
27221
27221
  // src/components/UEditor/table-dom-utils.ts
27222
- var MIN_TABLE_ROW_HEIGHT = 36;
27222
+ var DEFAULT_TABLE_ROW_HEIGHT = 25;
27223
+ var MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
27223
27224
  var COLUMN_RESIZE_LINE_THICKNESS = 2;
27224
27225
  var ROW_RESIZE_LINE_THICKNESS = 2;
27225
27226
  var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor-table-layout-change";
@@ -27705,25 +27706,29 @@ function parseRowHeight(value) {
27705
27706
  const match = String(value).match(/(\d+(?:\.\d+)?)/);
27706
27707
  if (!match) return null;
27707
27708
  const parsed = Number.parseFloat(match[1]);
27708
- return Number.isFinite(parsed) && parsed > 0 ? Math.round(parsed) : null;
27709
+ return normalizeRowHeight(parsed);
27710
+ }
27711
+ function normalizeRowHeight(value) {
27712
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.max(MIN_TABLE_ROW_HEIGHT, Math.round(value)) : null;
27709
27713
  }
27710
27714
  var UEditorTableRow = import_extension_table_row.default.extend({
27711
27715
  addAttributes() {
27712
27716
  return {
27713
27717
  ...this.parent?.(),
27714
27718
  rowHeight: {
27715
- default: null,
27719
+ default: DEFAULT_TABLE_ROW_HEIGHT,
27716
27720
  parseHTML: (element) => {
27717
27721
  if (!(element instanceof HTMLElement)) return null;
27718
27722
  return parseRowHeight(element.getAttribute("data-row-height")) ?? parseRowHeight(element.style.height);
27719
27723
  },
27720
27724
  renderHTML: (attributes) => {
27721
- if (!attributes.rowHeight || typeof attributes.rowHeight !== "number") {
27725
+ const rowHeight = normalizeRowHeight(attributes.rowHeight);
27726
+ if (!rowHeight) {
27722
27727
  return {};
27723
27728
  }
27724
27729
  return {
27725
- "data-row-height": String(attributes.rowHeight),
27726
- style: `height: ${attributes.rowHeight}px;`
27730
+ "data-row-height": String(rowHeight),
27731
+ style: `height: ${rowHeight}px; min-height: ${rowHeight}px;`
27727
27732
  };
27728
27733
  }
27729
27734
  }
@@ -27878,7 +27883,362 @@ var letter_spacing_default = LetterSpacing;
27878
27883
 
27879
27884
  // src/components/UEditor/table-align.ts
27880
27885
  var import_extension_table = require("@tiptap/extension-table");
27886
+ var import_state7 = require("@tiptap/pm/state");
27887
+ var import_tables2 = require("@tiptap/pm/tables");
27888
+
27889
+ // src/components/UEditor/table-column-resize.ts
27881
27890
  var import_state6 = require("@tiptap/pm/state");
27891
+ var import_view2 = require("@tiptap/pm/view");
27892
+ var import_tables = require("@tiptap/pm/tables");
27893
+ var DEFAULT_TABLE_COLUMN_WIDTH = 100;
27894
+ var MIN_RESIZED_TABLE_COLUMN_WIDTH = 25;
27895
+ function getDynamicColumnMinWidth(startWidth, fallbackMinWidth) {
27896
+ return Math.max(fallbackMinWidth, Math.round(startWidth / 3));
27897
+ }
27898
+ function setColumnStyle(column, width) {
27899
+ if (width == null) {
27900
+ column.style.width = "";
27901
+ column.style.minWidth = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
27902
+ return;
27903
+ }
27904
+ column.style.width = `${Math.max(width, MIN_RESIZED_TABLE_COLUMN_WIDTH)}px`;
27905
+ column.style.minWidth = "";
27906
+ }
27907
+ function isTableColumnElement(node) {
27908
+ return node instanceof HTMLElement && node.tagName.toLowerCase() === "col";
27909
+ }
27910
+ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue) {
27911
+ let totalWidth = 0;
27912
+ let fixedWidth = true;
27913
+ let nextDOM = colgroup.firstChild;
27914
+ const row = node.firstChild;
27915
+ if (row) {
27916
+ for (let rowCellIndex = 0, col = 0; rowCellIndex < row.childCount; rowCellIndex += 1) {
27917
+ const { colspan, colwidth } = row.child(rowCellIndex).attrs;
27918
+ for (let spanIndex = 0; spanIndex < colspan; spanIndex += 1, col += 1) {
27919
+ const rawWidth = overrideCol === col ? overrideValue : colwidth?.[spanIndex];
27920
+ const width = rawWidth ? Math.max(rawWidth, MIN_RESIZED_TABLE_COLUMN_WIDTH) : null;
27921
+ totalWidth += width ?? DEFAULT_TABLE_COLUMN_WIDTH;
27922
+ if (!width) {
27923
+ fixedWidth = false;
27924
+ }
27925
+ const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(document.createElement("col"));
27926
+ setColumnStyle(colElement, width);
27927
+ nextDOM = colElement.nextSibling;
27928
+ }
27929
+ }
27930
+ }
27931
+ while (nextDOM) {
27932
+ const after = nextDOM.nextSibling;
27933
+ nextDOM.parentNode?.removeChild(nextDOM);
27934
+ nextDOM = after;
27935
+ }
27936
+ const hasUserWidth = typeof node.attrs.style === "string" && /\bwidth\s*:/i.test(node.attrs.style);
27937
+ if (fixedWidth && !hasUserWidth) {
27938
+ table.style.width = `${totalWidth}px`;
27939
+ table.style.minWidth = "";
27940
+ } else {
27941
+ table.style.width = "";
27942
+ table.style.minWidth = `${totalWidth}px`;
27943
+ }
27944
+ }
27945
+ var UEditorTableView = class {
27946
+ constructor(node) {
27947
+ this.node = node;
27948
+ this.dom = document.createElement("div");
27949
+ this.dom.className = "tableWrapper";
27950
+ this.table = this.dom.appendChild(document.createElement("table"));
27951
+ if (node.attrs.style) {
27952
+ this.table.style.cssText = node.attrs.style;
27953
+ }
27954
+ this.colgroup = this.table.appendChild(document.createElement("colgroup"));
27955
+ updateDynamicColumns(node, this.colgroup, this.table);
27956
+ this.contentDOM = this.table.appendChild(document.createElement("tbody"));
27957
+ }
27958
+ update(node) {
27959
+ if (node.type !== this.node.type) return false;
27960
+ this.node = node;
27961
+ updateDynamicColumns(node, this.colgroup, this.table);
27962
+ return true;
27963
+ }
27964
+ ignoreMutation(mutation) {
27965
+ const target = mutation.target;
27966
+ const isInsideWrapper = this.dom.contains(target);
27967
+ const isInsideContent = this.contentDOM.contains(target);
27968
+ if (isInsideWrapper && !isInsideContent) {
27969
+ return mutation.type === "attributes" || mutation.type === "childList" || mutation.type === "characterData";
27970
+ }
27971
+ return false;
27972
+ }
27973
+ };
27974
+ function getDraggedWidth(dragging, event) {
27975
+ const offset = event.clientX - dragging.startX;
27976
+ return Math.max(dragging.minWidth, Math.round(dragging.startWidth + offset));
27977
+ }
27978
+ function getCurrentColWidth(view, cellPos, { colspan, colwidth }) {
27979
+ const width = colwidth?.[colwidth.length - 1];
27980
+ if (width) return width;
27981
+ const dom = view.domAtPos(cellPos);
27982
+ const cellElement = dom.node.childNodes[dom.offset];
27983
+ let domWidth = cellElement instanceof HTMLElement ? cellElement.offsetWidth : 0;
27984
+ let parts = Math.max(1, colspan);
27985
+ if (colwidth) {
27986
+ for (let index = 0; index < colspan; index += 1) {
27987
+ const partWidth = colwidth[index];
27988
+ if (partWidth) {
27989
+ domWidth -= partWidth;
27990
+ parts -= 1;
27991
+ }
27992
+ }
27993
+ }
27994
+ return domWidth / Math.max(1, parts);
27995
+ }
27996
+ function domCellAround(target) {
27997
+ let node = target instanceof Node ? target : null;
27998
+ while (node && node.nodeName !== "TD" && node.nodeName !== "TH") {
27999
+ const element = node instanceof Element ? node : null;
28000
+ if (element?.classList.contains("ProseMirror")) return null;
28001
+ node = node.parentNode;
28002
+ }
28003
+ return node instanceof HTMLElement ? node : null;
28004
+ }
28005
+ function edgeCell(view, event, side, handleWidth) {
28006
+ const offset = side === "right" ? -handleWidth : handleWidth;
28007
+ const found2 = view.posAtCoords({
28008
+ left: event.clientX + offset,
28009
+ top: event.clientY
28010
+ });
28011
+ if (!found2) return -1;
28012
+ const $cell = (0, import_tables.cellAround)(view.state.doc.resolve(found2.pos));
28013
+ if (!$cell) return -1;
28014
+ if (side === "right") return $cell.pos;
28015
+ const map = import_tables.TableMap.get($cell.node(-1));
28016
+ const start = $cell.start(-1);
28017
+ const index = map.map.indexOf($cell.pos - start);
28018
+ return index % map.width === 0 ? -1 : start + map.map[index - 1];
28019
+ }
28020
+ function updateHandle(view, value) {
28021
+ view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setHandle: value }));
28022
+ }
28023
+ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
28024
+ if (!view.editable) return;
28025
+ const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
28026
+ if (!pluginState || pluginState.dragging) return;
28027
+ const target = domCellAround(event.target);
28028
+ let cell = -1;
28029
+ if (target) {
28030
+ const { left, right } = target.getBoundingClientRect();
28031
+ if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
28032
+ else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
28033
+ }
28034
+ if (cell === pluginState.activeHandle) return;
28035
+ if (!lastColumnResizable && cell !== -1) {
28036
+ const $cell = view.state.doc.resolve(cell);
28037
+ const table = $cell.node(-1);
28038
+ const map = import_tables.TableMap.get(table);
28039
+ const tableStart = $cell.start(-1);
28040
+ const nodeAfter = $cell.nodeAfter;
28041
+ if (!nodeAfter) return;
28042
+ if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1) return;
28043
+ }
28044
+ updateHandle(view, cell);
28045
+ }
28046
+ function handleMouseLeave(view) {
28047
+ if (!view.editable) return;
28048
+ const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
28049
+ if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
28050
+ updateHandle(view, -1);
28051
+ }
28052
+ }
28053
+ function updateColumnWidth(view, cell, width) {
28054
+ const $cell = view.state.doc.resolve(cell);
28055
+ const table = $cell.node(-1);
28056
+ const map = import_tables.TableMap.get(table);
28057
+ const start = $cell.start(-1);
28058
+ const nodeAfter = $cell.nodeAfter;
28059
+ if (!nodeAfter) return;
28060
+ const col = map.colCount($cell.pos - start) + nodeAfter.attrs.colspan - 1;
28061
+ const tr = view.state.tr;
28062
+ for (let row = 0; row < map.height; row += 1) {
28063
+ const mapIndex = row * map.width + col;
28064
+ if (row && map.map[mapIndex] === map.map[mapIndex - map.width]) continue;
28065
+ const pos = map.map[mapIndex];
28066
+ const cellNode = table.nodeAt(pos);
28067
+ if (!cellNode) continue;
28068
+ const attrs = cellNode.attrs;
28069
+ const index = attrs.colspan === 1 ? 0 : col - map.colCount(pos);
28070
+ if (attrs.colwidth?.[index] === width) continue;
28071
+ const colwidth = attrs.colwidth ? attrs.colwidth.slice() : Array.from({ length: attrs.colspan }, () => 0);
28072
+ colwidth[index] = width;
28073
+ tr.setNodeMarkup(start + pos, null, {
28074
+ ...attrs,
28075
+ colwidth
28076
+ });
28077
+ }
28078
+ if (tr.docChanged) view.dispatch(tr);
28079
+ }
28080
+ function getActiveDragging(state) {
28081
+ const dragging = import_tables.columnResizingPluginKey.getState(state)?.dragging;
28082
+ return dragging ? dragging : null;
28083
+ }
28084
+ function getColumnResizeGhost(view) {
28085
+ const doc = view.dom.ownerDocument;
28086
+ let ghost = doc.querySelector("[data-ueditor-column-resize-ghost]");
28087
+ if (!ghost) {
28088
+ ghost = doc.createElement("div");
28089
+ ghost.setAttribute("data-ueditor-column-resize-ghost", "");
28090
+ ghost.style.position = "fixed";
28091
+ ghost.style.zIndex = "99999";
28092
+ ghost.style.pointerEvents = "none";
28093
+ ghost.style.width = "2px";
28094
+ ghost.style.backgroundColor = "var(--primary, #2563eb)";
28095
+ ghost.style.opacity = "1";
28096
+ ghost.style.borderRadius = "9999px";
28097
+ ghost.style.boxShadow = "0 0 0 1px color-mix(in oklch, var(--background, #fff) 80%, transparent)";
28098
+ ghost.style.transform = "translateX(-1px)";
28099
+ ghost.style.willChange = "left";
28100
+ doc.body.appendChild(ghost);
28101
+ }
28102
+ return ghost;
28103
+ }
28104
+ function hideColumnResizeGhost(view) {
28105
+ view.dom.ownerDocument.querySelector("[data-ueditor-column-resize-ghost]")?.remove();
28106
+ }
28107
+ function getTableElementAtCell(view, cell) {
28108
+ const $cell = view.state.doc.resolve(cell);
28109
+ let dom = view.domAtPos($cell.start(-1)).node;
28110
+ while (dom && dom.nodeName !== "TABLE") dom = dom.parentNode;
28111
+ return dom instanceof HTMLTableElement ? dom : null;
28112
+ }
28113
+ function showColumnResizeGhost(view, cell, dragging, width) {
28114
+ const table = getTableElementAtCell(view, cell);
28115
+ if (!table) return;
28116
+ const rect = table.getBoundingClientRect();
28117
+ const left = dragging.startX + width - dragging.startWidth;
28118
+ const ghost = getColumnResizeGhost(view);
28119
+ ghost.style.left = `${left}px`;
28120
+ ghost.style.top = `${rect.top}px`;
28121
+ ghost.style.height = `${rect.height}px`;
28122
+ }
28123
+ function handleMouseDown(view, event, cellMinWidth) {
28124
+ if (!view.editable) return false;
28125
+ const win = view.dom.ownerDocument.defaultView ?? window;
28126
+ const pluginState = import_tables.columnResizingPluginKey.getState(view.state);
28127
+ if (!pluginState || pluginState.activeHandle === -1 || pluginState.dragging) return false;
28128
+ const cell = view.state.doc.nodeAt(pluginState.activeHandle);
28129
+ if (!cell) return false;
28130
+ const attrs = cell.attrs;
28131
+ const width = getCurrentColWidth(view, pluginState.activeHandle, {
28132
+ colspan: attrs.colspan ?? 1,
28133
+ colwidth: attrs.colwidth
28134
+ });
28135
+ const minWidth = getDynamicColumnMinWidth(width, cellMinWidth);
28136
+ const dragging = {
28137
+ startX: event.clientX,
28138
+ startWidth: width,
28139
+ minWidth
28140
+ };
28141
+ view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setDragging: dragging }));
28142
+ function finish(nextEvent) {
28143
+ win.removeEventListener("mouseup", finish);
28144
+ win.removeEventListener("mousemove", move);
28145
+ const activeDragging = getActiveDragging(view.state);
28146
+ const activeHandle = import_tables.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
28147
+ if (activeDragging && activeHandle > -1) {
28148
+ updateColumnWidth(view, activeHandle, getDraggedWidth(activeDragging, nextEvent));
28149
+ view.dispatch(view.state.tr.setMeta(import_tables.columnResizingPluginKey, { setDragging: null }));
28150
+ }
28151
+ hideColumnResizeGhost(view);
28152
+ }
28153
+ function move(nextEvent) {
28154
+ if (!nextEvent.buttons) return finish(nextEvent);
28155
+ const activeDragging = getActiveDragging(view.state);
28156
+ const activeHandle = import_tables.columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
28157
+ if (activeDragging && activeHandle > -1) {
28158
+ showColumnResizeGhost(view, activeHandle, activeDragging, getDraggedWidth(activeDragging, nextEvent));
28159
+ }
28160
+ }
28161
+ showColumnResizeGhost(view, pluginState.activeHandle, dragging, width);
28162
+ win.addEventListener("mouseup", finish);
28163
+ win.addEventListener("mousemove", move);
28164
+ event.preventDefault();
28165
+ return true;
28166
+ }
28167
+ function handleDecorations(state, cell) {
28168
+ const decorations = [];
28169
+ const $cell = state.doc.resolve(cell);
28170
+ const table = $cell.node(-1);
28171
+ if (!table) return import_view2.DecorationSet.empty;
28172
+ const map = import_tables.TableMap.get(table);
28173
+ const start = $cell.start(-1);
28174
+ const nodeAfter = $cell.nodeAfter;
28175
+ if (!nodeAfter) return import_view2.DecorationSet.empty;
28176
+ const col = map.colCount($cell.pos - start) + nodeAfter.attrs.colspan - 1;
28177
+ for (let row = 0; row < map.height; row += 1) {
28178
+ const index = col + row * map.width;
28179
+ if ((col === map.width - 1 || map.map[index] !== map.map[index + 1]) && (row === 0 || map.map[index] !== map.map[index - map.width])) {
28180
+ const cellPos = map.map[index];
28181
+ const cellNode = table.nodeAt(cellPos);
28182
+ if (!cellNode) continue;
28183
+ const pos = start + cellPos + cellNode.nodeSize - 1;
28184
+ const dom = document.createElement("div");
28185
+ dom.className = "column-resize-handle";
28186
+ if (import_tables.columnResizingPluginKey.getState(state)?.dragging) {
28187
+ decorations.push(import_view2.Decoration.node(start + cellPos, start + cellPos + cellNode.nodeSize, { class: "column-resize-dragging" }));
28188
+ }
28189
+ decorations.push(import_view2.Decoration.widget(pos, dom));
28190
+ }
28191
+ }
28192
+ return import_view2.DecorationSet.create(state.doc, decorations);
28193
+ }
28194
+ function dynamicColumnResizing({
28195
+ handleWidth = 5,
28196
+ cellMinWidth = MIN_RESIZED_TABLE_COLUMN_WIDTH,
28197
+ defaultCellMinWidth = DEFAULT_TABLE_COLUMN_WIDTH,
28198
+ View = UEditorTableView,
28199
+ lastColumnResizable = true
28200
+ } = {}) {
28201
+ const plugin = new import_state6.Plugin({
28202
+ key: import_tables.columnResizingPluginKey,
28203
+ state: {
28204
+ init(_, state) {
28205
+ const nodeViews = plugin.spec.props?.nodeViews;
28206
+ const tableName = (0, import_tables.tableNodeTypes)(state.schema).table.name;
28207
+ if (View && nodeViews) {
28208
+ nodeViews[tableName] = (node, view) => new View(node, defaultCellMinWidth, view);
28209
+ }
28210
+ return new import_tables.ResizeState(-1, false);
28211
+ },
28212
+ apply(tr, prev) {
28213
+ return prev.apply(tr);
28214
+ }
28215
+ },
28216
+ props: {
28217
+ attributes: (state) => {
28218
+ const pluginState = import_tables.columnResizingPluginKey.getState(state);
28219
+ return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
28220
+ },
28221
+ handleDOMEvents: {
28222
+ mousemove: (view, event) => {
28223
+ handleMouseMove(view, event, handleWidth, lastColumnResizable);
28224
+ },
28225
+ mouseleave: (view) => {
28226
+ handleMouseLeave(view);
28227
+ },
28228
+ mousedown: (view, event) => handleMouseDown(view, event, cellMinWidth)
28229
+ },
28230
+ decorations: (state) => {
28231
+ const pluginState = import_tables.columnResizingPluginKey.getState(state);
28232
+ if (pluginState && pluginState.activeHandle > -1) {
28233
+ return handleDecorations(state, pluginState.activeHandle);
28234
+ }
28235
+ return void 0;
28236
+ },
28237
+ nodeViews: {}
28238
+ }
28239
+ });
28240
+ return plugin;
28241
+ }
27882
28242
 
27883
28243
  // src/components/UEditor/table-align-utils.ts
27884
28244
  function findTableNodeInfoAtResolvedPos($pos) {
@@ -28015,9 +28375,20 @@ var UEditorTable = import_extension_table.Table.extend({
28015
28375
  };
28016
28376
  },
28017
28377
  addProseMirrorPlugins() {
28378
+ const isResizable = this.options.resizable && this.editor.isEditable;
28018
28379
  return [
28019
- ...this.parent?.() ?? [],
28020
- new import_state6.Plugin({
28380
+ ...isResizable ? [
28381
+ dynamicColumnResizing({
28382
+ handleWidth: this.options.handleWidth,
28383
+ cellMinWidth: this.options.cellMinWidth,
28384
+ defaultCellMinWidth: DEFAULT_TABLE_COLUMN_WIDTH,
28385
+ lastColumnResizable: this.options.lastColumnResizable
28386
+ })
28387
+ ] : [],
28388
+ (0, import_tables2.tableEditing)({
28389
+ allowTableNodeSelection: this.options.allowTableNodeSelection
28390
+ }),
28391
+ new import_state7.Plugin({
28021
28392
  appendTransaction(_transactions, _oldState, newState) {
28022
28393
  const { doc, schema } = newState;
28023
28394
  const paragraphType = schema.nodes.paragraph;
@@ -28502,12 +28873,12 @@ function buildUEditorExtensions({
28502
28873
  table_row_default,
28503
28874
  CustomTableCell.configure({
28504
28875
  HTMLAttributes: {
28505
- class: "border border-border px-2 py-0 min-w-25"
28876
+ class: "border border-black px-2 py-0 min-w-25"
28506
28877
  }
28507
28878
  }),
28508
28879
  CustomTableHeader.configure({
28509
28880
  HTMLAttributes: {
28510
- class: "border border-border px-2 py-0 bg-muted font-semibold min-w-25"
28881
+ class: "border border-black px-2 py-0 bg-muted font-semibold min-w-25"
28511
28882
  }
28512
28883
  }),
28513
28884
  import_extension_character_count.default.configure({
@@ -28799,7 +29170,7 @@ var EditorColorPalette = ({
28799
29170
  };
28800
29171
 
28801
29172
  // src/components/UEditor/image-commands.ts
28802
- var import_state7 = require("@tiptap/pm/state");
29173
+ var import_state8 = require("@tiptap/pm/state");
28803
29174
  var IMAGE_WIDTHS_BY_LAYOUT = {
28804
29175
  block: {
28805
29176
  sm: 180,
@@ -28814,7 +29185,7 @@ var IMAGE_WIDTHS_BY_LAYOUT = {
28814
29185
  };
28815
29186
  function isSelectedImage(editor) {
28816
29187
  const { selection } = editor.state;
28817
- return selection instanceof import_state7.NodeSelection && selection.node.type.name === "image";
29188
+ return selection instanceof import_state8.NodeSelection && selection.node.type.name === "image";
28818
29189
  }
28819
29190
  function toPositiveNumber(value) {
28820
29191
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
@@ -28856,7 +29227,7 @@ function getImagePresetAttributes(editor, width, preset, attrs, pos) {
28856
29227
  function applyImageLayout(editor, layout) {
28857
29228
  const { state, view } = editor;
28858
29229
  const { selection, schema } = state;
28859
- if (!(selection instanceof import_state7.NodeSelection) || selection.node.type.name !== "image") {
29230
+ if (!(selection instanceof import_state8.NodeSelection) || selection.node.type.name !== "image") {
28860
29231
  editor.chain().focus().updateAttributes("image", { imageLayout: layout }).run();
28861
29232
  return;
28862
29233
  }
@@ -28874,10 +29245,10 @@ function applyImageLayout(editor, layout) {
28874
29245
  }
28875
29246
  }
28876
29247
  const resolvedPos = transaction.doc.resolve(Math.min(nextPos + 1, transaction.doc.content.size));
28877
- transaction = transaction.setSelection(import_state7.TextSelection.near(resolvedPos));
29248
+ transaction = transaction.setSelection(import_state8.TextSelection.near(resolvedPos));
28878
29249
  } else {
28879
29250
  const resolvedPos = transaction.doc.resolve(selection.from);
28880
- transaction = transaction.setSelection(import_state7.NodeSelection.create(transaction.doc, resolvedPos.pos));
29251
+ transaction = transaction.setSelection(import_state8.NodeSelection.create(transaction.doc, resolvedPos.pos));
28881
29252
  }
28882
29253
  view.dispatch(transaction.scrollIntoView());
28883
29254
  view.focus();
@@ -29024,8 +29395,8 @@ var ImageInput = ({ onSubmit, onCancel }) => {
29024
29395
  };
29025
29396
 
29026
29397
  // src/components/UEditor/table-cell-commands.ts
29027
- var import_state8 = require("@tiptap/pm/state");
29028
- var import_tables = require("@tiptap/pm/tables");
29398
+ var import_state9 = require("@tiptap/pm/state");
29399
+ var import_tables3 = require("@tiptap/pm/tables");
29029
29400
  function getCellSelectionPositions(selection) {
29030
29401
  const value = selection;
29031
29402
  const anchor = value.$anchorCell?.pos;
@@ -29058,7 +29429,7 @@ function getFocusableCellPos(editor, cellPos) {
29058
29429
  return node?.isTextblock ? offset + 1 : cellPos + 1;
29059
29430
  }
29060
29431
  function focusCell(editor, cellPos) {
29061
- const selection = import_state8.TextSelection.near(editor.state.doc.resolve(getFocusableCellPos(editor, cellPos)));
29432
+ const selection = import_state9.TextSelection.near(editor.state.doc.resolve(getFocusableCellPos(editor, cellPos)));
29062
29433
  editor.view.dispatch(editor.state.tr.setSelection(selection));
29063
29434
  editor.view.focus();
29064
29435
  }
@@ -29117,7 +29488,7 @@ function getSelectedTableRect(editor) {
29117
29488
  if (cellSelection) {
29118
29489
  const tableInfo = findTableInfoFromCellPos(editor, cellSelection.anchor);
29119
29490
  if (tableInfo) {
29120
- const map = import_tables.TableMap.get(tableInfo.table);
29491
+ const map = import_tables3.TableMap.get(tableInfo.table);
29121
29492
  const rect = map.rectBetween(
29122
29493
  cellSelection.anchor - tableInfo.tableStart,
29123
29494
  cellSelection.head - tableInfo.tableStart
@@ -29130,7 +29501,7 @@ function getSelectedTableRect(editor) {
29130
29501
  };
29131
29502
  }
29132
29503
  }
29133
- return (0, import_tables.selectedRect)(editor.state);
29504
+ return (0, import_tables3.selectedRect)(editor.state);
29134
29505
  }
29135
29506
  function parsePixelWidth(value) {
29136
29507
  if (!value) return null;
@@ -29213,7 +29584,7 @@ function runTableCommandAtCellPos(editor, cellPos, command) {
29213
29584
  function getTableCornerCellPos(editor, activePos) {
29214
29585
  const tableInfo = findTableInfoFromCellPos(editor, activePos);
29215
29586
  if (!tableInfo) return null;
29216
- const map = import_tables.TableMap.get(tableInfo.table);
29587
+ const map = import_tables3.TableMap.get(tableInfo.table);
29217
29588
  return tableInfo.tableStart + map.positionAt(map.height - 1, map.width - 1, tableInfo.table);
29218
29589
  }
29219
29590
  function replaceTableAtCellPos(editor, cellPos, updateTable) {
@@ -29237,7 +29608,7 @@ function duplicateTableRowAt(editor, rowIndex, cellPos) {
29237
29608
  }
29238
29609
  function clearTableRowAt(editor, rowIndex, cellPos) {
29239
29610
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
29240
- const map = import_tables.TableMap.get(tableNode);
29611
+ const map = import_tables3.TableMap.get(tableNode);
29241
29612
  if (rowIndex < 0 || rowIndex >= map.height) return null;
29242
29613
  const rows = getTableRows(tableNode).map((rowInfo) => {
29243
29614
  const cells = collectChildren(rowInfo.node);
@@ -29253,7 +29624,7 @@ function clearTableRowAt(editor, rowIndex, cellPos) {
29253
29624
  }
29254
29625
  function duplicateTableColumnAt(editor, columnIndex, cellPos) {
29255
29626
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
29256
- const map = import_tables.TableMap.get(tableNode);
29627
+ const map = import_tables3.TableMap.get(tableNode);
29257
29628
  if (columnIndex < 0 || columnIndex >= map.width) return null;
29258
29629
  const rows = getTableRows(tableNode).map((rowInfo, rowIndex) => {
29259
29630
  const cells = collectChildren(rowInfo.node);
@@ -29275,7 +29646,7 @@ function duplicateTableColumnAt(editor, columnIndex, cellPos) {
29275
29646
  }
29276
29647
  function clearTableColumnAt(editor, columnIndex, cellPos) {
29277
29648
  return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
29278
- const map = import_tables.TableMap.get(tableNode);
29649
+ const map = import_tables3.TableMap.get(tableNode);
29279
29650
  if (columnIndex < 0 || columnIndex >= map.width) return null;
29280
29651
  const rows = getTableRows(tableNode).map((rowInfo) => {
29281
29652
  const cells = collectChildren(rowInfo.node);
@@ -29314,6 +29685,16 @@ function normalizeStyleValue(value) {
29314
29685
  }
29315
29686
  function getDefaultFontFamilies(t) {
29316
29687
  return [
29688
+ { label: "\uAD74\uB9BC", value: '"Gulim", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
29689
+ { label: "\uAD74\uB9BC\uCCB4", value: '"GulimChe", "Gulim", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
29690
+ { label: "\uAD81\uC11C", value: '"Gungsuh", "Nanum Myeongjo", serif' },
29691
+ { label: "\uAD81\uC11C\uCCB4", value: '"GungsuhChe", "Gungsuh", "Nanum Myeongjo", serif' },
29692
+ { label: "\uB3CB\uC6C0", value: '"Dotum", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
29693
+ { label: "\uB3CB\uC6C0\uCCB4", value: '"DotumChe", "Dotum", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
29694
+ { label: "\uBC14\uD0D5", value: '"Batang", "Nanum Myeongjo", serif' },
29695
+ { label: "\uBC14\uD0D5\uCCB4", value: '"BatangChe", "Batang", "Nanum Myeongjo", serif' },
29696
+ { label: "\uB9D1\uC740\uACE0\uB515", value: '"Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
29697
+ { label: "\uB098\uB214\uBA85\uC870", value: '"Nanum Myeongjo", "Batang", serif' },
29317
29698
  { label: "Inter", value: '"Inter", "Noto Sans", "Noto Sans CJK KR", "Noto Sans CJK JP", "Segoe UI", sans-serif' },
29318
29699
  { label: "System UI", value: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' },
29319
29700
  { label: "Roboto", value: '"Roboto", "Noto Sans", "Apple SD Gothic Neo", "Hiragino Kaku Gothic ProN", sans-serif' },
@@ -29335,13 +29716,21 @@ function getDefaultFontSizes() {
29335
29716
  { label: "10", value: "10px" },
29336
29717
  { label: "11", value: "11px" },
29337
29718
  { label: "12", value: "12px" },
29719
+ { label: "13", value: "13px" },
29338
29720
  { label: "14", value: "14px" },
29721
+ { label: "15", value: "15px" },
29339
29722
  { label: "16", value: "16px" },
29723
+ { label: "17", value: "17px" },
29340
29724
  { label: "18", value: "18px" },
29725
+ { label: "19", value: "19px" },
29341
29726
  { label: "20", value: "20px" },
29727
+ { label: "21", value: "21px" },
29342
29728
  { label: "22", value: "22px" },
29729
+ { label: "23", value: "23px" },
29343
29730
  { label: "24", value: "24px" },
29731
+ { label: "25", value: "25px" },
29344
29732
  { label: "26", value: "26px" },
29733
+ { label: "27", value: "27px" },
29345
29734
  { label: "28", value: "28px" },
29346
29735
  { label: "36", value: "36px" },
29347
29736
  { label: "48", value: "48px" },
@@ -29517,10 +29906,15 @@ var EditorToolbar = ({
29517
29906
  const availableLetterSpacings = import_react62.default.useMemo(() => letterSpacings ?? getDefaultLetterSpacings(), [letterSpacings]);
29518
29907
  const currentFontFamilyDisplayValue = currentFontFamily.split(",")[0]?.trim() ?? currentFontFamily;
29519
29908
  const currentFontFamilyLabel = availableFontFamilies.find((option) => normalizeStyleValue(option.value) === currentFontFamily)?.label ?? (currentFontFamilyDisplayValue || t("toolbar.fontDefault"));
29520
- const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? t("toolbar.sizeDefault");
29909
+ const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? "13";
29521
29910
  const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
29522
29911
  const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
29523
- const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : availableFontFamilies[0]?.label ?? t("toolbar.fontDefault");
29912
+ const defaultFontFamily = availableFontFamilies[0];
29913
+ const defaultFontFamilyValue = defaultFontFamily?.value ?? "";
29914
+ const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamily?.label ?? t("toolbar.fontDefault");
29915
+ const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
29916
+ const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
29917
+ const activeFontSize = currentFontSize || "13px";
29524
29918
  const tableCommandAnchorPos = tableCommandAnchorPosRef.current ?? tableAnchorPos ?? void 0;
29525
29919
  const insertImageFiles = async (files) => {
29526
29920
  if (files.length === 0) return;
@@ -29558,70 +29952,48 @@ var EditorToolbar = ({
29558
29952
  ] });
29559
29953
  }
29560
29954
  return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "flex flex-wrap items-center gap-0.5 border-b border-border/35 bg-linear-to-r from-muted/25 to-transparent p-1.5", children: [
29561
- /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
29955
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29562
29956
  DropdownMenu,
29563
29957
  {
29564
29958
  trigger: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(ToolbarButton, { onClick: () => {
29565
- }, title: t("toolbar.fontFamily"), className: "px-1.5 w-auto gap-0.5", children: [
29566
- /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_lucide_react49.Baseline, { className: "w-4 h-4" }),
29959
+ }, title: t("toolbar.fontFamily"), className: "min-w-0 max-w-40 px-1.5 w-auto gap-1", children: [
29960
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "max-w-28 truncate text-xs font-medium", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
29567
29961
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_lucide_react49.ChevronDown, { className: "h-3 w-3 text-muted-foreground" })
29568
29962
  ] }),
29569
29963
  contentClassName: "max-h-80 overflow-y-auto min-w-56 p-2",
29570
- children: [
29571
- /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29572
- DropdownMenuItem,
29573
- {
29574
- icon: import_lucide_react49.Type,
29575
- label: t("toolbar.fontDefault"),
29576
- onClick: () => editor.chain().focus().unsetFontFamily().run(),
29577
- active: !currentFontFamily
29578
- }
29579
- ),
29580
- availableFontFamilies.map((option) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29581
- DropdownMenuItem,
29582
- {
29583
- label: option.label,
29584
- onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
29585
- active: normalizeStyleValue(option.value) === currentFontFamily,
29586
- className: "font-medium"
29587
- },
29588
- option.value
29589
- ))
29590
- ]
29964
+ children: availableFontFamilies.map((option) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29965
+ DropdownMenuItem,
29966
+ {
29967
+ label: option.label,
29968
+ onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
29969
+ active: normalizeStyleValue(option.value) === (currentFontFamily || normalizeStyleValue(defaultFontFamilyValue)),
29970
+ className: "font-medium"
29971
+ },
29972
+ option.value
29973
+ ))
29591
29974
  }
29592
29975
  ),
29593
- /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
29976
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29594
29977
  DropdownMenu,
29595
29978
  {
29596
29979
  trigger: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(ToolbarButton, { onClick: () => {
29597
- }, title: t("toolbar.fontSize"), className: "px-1.5 w-auto gap-0.5", children: [
29980
+ }, title: t("toolbar.fontSize"), className: "px-1.5 w-auto gap-1", children: [
29598
29981
  /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "flex items-center gap-0.5", children: [
29599
29982
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_lucide_react49.ChevronsUpDown, { className: "h-3 w-3 text-muted-foreground", strokeWidth: 2.5 }),
29600
- /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "text-xs font-bold leading-none", children: "A" })
29983
+ /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "min-w-4 text-center text-xs font-semibold leading-none", children: displayedFontSizeLabel })
29601
29984
  ] }),
29602
29985
  /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_lucide_react49.ChevronDown, { className: "h-3 w-3 text-muted-foreground" })
29603
29986
  ] }),
29604
29987
  contentClassName: "max-h-80 overflow-y-auto min-w-32 p-2",
29605
- children: [
29606
- /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29607
- DropdownMenuItem,
29608
- {
29609
- icon: import_lucide_react49.Type,
29610
- label: t("toolbar.sizeDefault"),
29611
- onClick: () => editor.chain().focus().unsetFontSize().run(),
29612
- active: !currentFontSize
29613
- }
29614
- ),
29615
- availableFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29616
- DropdownMenuItem,
29617
- {
29618
- label: option.label,
29619
- onClick: () => editor.chain().focus().setFontSize(option.value).run(),
29620
- active: normalizeStyleValue(option.value) === currentFontSize
29621
- },
29622
- option.value
29623
- ))
29624
- ]
29988
+ children: availableFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
29989
+ DropdownMenuItem,
29990
+ {
29991
+ label: option.label,
29992
+ onClick: () => editor.chain().focus().setFontSize(option.value).run(),
29993
+ active: normalizeStyleValue(option.value) === activeFontSize
29994
+ },
29995
+ option.value
29996
+ ))
29625
29997
  }
29626
29998
  ),
29627
29999
  /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
@@ -30336,12 +30708,12 @@ var EditorToolbar = ({
30336
30708
  // src/components/UEditor/menus.tsx
30337
30709
  var import_react64 = require("react");
30338
30710
  var import_react65 = require("@tiptap/react");
30339
- var import_tables3 = require("@tiptap/pm/tables");
30711
+ var import_tables5 = require("@tiptap/pm/tables");
30340
30712
  var import_react_dom8 = require("react-dom");
30341
30713
  var import_lucide_react50 = require("lucide-react");
30342
30714
 
30343
30715
  // src/components/UEditor/table-formula-commands.ts
30344
- var import_tables2 = require("@tiptap/pm/tables");
30716
+ var import_tables4 = require("@tiptap/pm/tables");
30345
30717
 
30346
30718
  // src/components/UEditor/table-formula.ts
30347
30719
  var CELL_ADDRESS_RE = /^([A-Z]+)([1-9]\d*)$/i;
@@ -30875,7 +31247,7 @@ function getSelectionTableCellLabel(editor) {
30875
31247
  const tableNode = $from.node(tableDepth);
30876
31248
  const tableStart = $from.start(tableDepth);
30877
31249
  const relativeCellPos = $from.before(cellDepth) - tableStart;
30878
- const rect = safeFindCell2(import_tables2.TableMap.get(tableNode), relativeCellPos);
31250
+ const rect = safeFindCell2(import_tables4.TableMap.get(tableNode), relativeCellPos);
30879
31251
  if (!rect) return null;
30880
31252
  return `${indexToColumnName(rect.left)}${rect.top + 1}`;
30881
31253
  }
@@ -30891,7 +31263,7 @@ function createCellDisplayContent(cellNode, displayValue) {
30891
31263
  return [paragraphType.create(null, cellNode.type.schema.text(displayValue))];
30892
31264
  }
30893
31265
  function buildTableValueMap(tableNode) {
30894
- const map = import_tables2.TableMap.get(tableNode);
31266
+ const map = import_tables4.TableMap.get(tableNode);
30895
31267
  const values = /* @__PURE__ */ new Map();
30896
31268
  for (const rowInfo of getTableRows2(tableNode)) {
30897
31269
  for (const entry of rowInfo.cells) {
@@ -30913,8 +31285,8 @@ function setSelectedTableCellFormula(editor, formula) {
30913
31285
  const normalized = normalizeFormulaInput(formula);
30914
31286
  const { state, view } = editor;
30915
31287
  if (!normalized) {
30916
- const clearedFormula = (0, import_tables2.setCellAttr)("formula", null)(state, view.dispatch.bind(view));
30917
- const clearedValue2 = (0, import_tables2.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
31288
+ const clearedFormula = (0, import_tables4.setCellAttr)("formula", null)(state, view.dispatch.bind(view));
31289
+ const clearedValue2 = (0, import_tables4.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
30918
31290
  if (clearedFormula || clearedValue2) {
30919
31291
  recalculateActiveTableFormulas(editor);
30920
31292
  view.focus();
@@ -30923,8 +31295,8 @@ function setSelectedTableCellFormula(editor, formula) {
30923
31295
  }
30924
31296
  return false;
30925
31297
  }
30926
- const appliedFormula = (0, import_tables2.setCellAttr)("formula", normalized)(state, view.dispatch.bind(view));
30927
- const clearedValue = (0, import_tables2.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
31298
+ const appliedFormula = (0, import_tables4.setCellAttr)("formula", normalized)(state, view.dispatch.bind(view));
31299
+ const clearedValue = (0, import_tables4.setCellAttr)("computedValue", null)(editor.state, view.dispatch.bind(view));
30928
31300
  if (appliedFormula || clearedValue) {
30929
31301
  recalculateActiveTableFormulas(editor);
30930
31302
  view.focus();
@@ -30939,7 +31311,7 @@ function clearSelectedTableCellFormula(editor) {
30939
31311
  function setSelectedTableCellNumberFormat(editor, numberFormat) {
30940
31312
  const value = numberFormat && numberFormat !== "text" ? numberFormat : null;
30941
31313
  const { state, view } = editor;
30942
- const applied = (0, import_tables2.setCellAttr)("numberFormat", value)(state, view.dispatch.bind(view));
31314
+ const applied = (0, import_tables4.setCellAttr)("numberFormat", value)(state, view.dispatch.bind(view));
30943
31315
  if (!applied) return false;
30944
31316
  recalculateSelectedTable(editor);
30945
31317
  view.focus();
@@ -31011,7 +31383,7 @@ function promoteFormulaTextInTableNode(tableNode) {
31011
31383
  function recalculateTableNode(tableNode, options) {
31012
31384
  const promoted = promoteFormulaTextInTableNode(tableNode);
31013
31385
  tableNode = promoted.tableNode;
31014
- const map = import_tables2.TableMap.get(tableNode);
31386
+ const map = import_tables4.TableMap.get(tableNode);
31015
31387
  const values = buildTableValueMap(tableNode);
31016
31388
  const formulaEntries = /* @__PURE__ */ new Map();
31017
31389
  let changed = false;
@@ -31082,7 +31454,7 @@ function recalculateTableNode(tableNode, options) {
31082
31454
  return tableNode.type.create(tableNode.attrs, rows);
31083
31455
  }
31084
31456
  function recalculateSelectedTable(editor) {
31085
- const rect = (0, import_tables2.selectedRect)(editor.state);
31457
+ const rect = (0, import_tables4.selectedRect)(editor.state);
31086
31458
  const tableNode = rect.table;
31087
31459
  const nextTable = recalculateTableNode(tableNode);
31088
31460
  if (!nextTable) return false;
@@ -31137,7 +31509,7 @@ var import_jsx_runtime87 = require("react/jsx-runtime");
31137
31509
  function applyTableCellBackground(editor, color) {
31138
31510
  const value = color || null;
31139
31511
  const { state, view } = editor;
31140
- const applied = (0, import_tables3.setCellAttr)("backgroundColor", value)(state, view.dispatch.bind(view));
31512
+ const applied = (0, import_tables5.setCellAttr)("backgroundColor", value)(state, view.dispatch.bind(view));
31141
31513
  if (applied) {
31142
31514
  view.focus();
31143
31515
  return;
@@ -31147,7 +31519,7 @@ function applyTableCellBackground(editor, color) {
31147
31519
  function applyTableCellAttribute(editor, name, value, options = {}) {
31148
31520
  const shouldFocus = options.focus ?? true;
31149
31521
  const { state, view } = editor;
31150
- const applied = (0, import_tables3.setCellAttr)(name, value)(state, view.dispatch.bind(view));
31522
+ const applied = (0, import_tables5.setCellAttr)(name, value)(state, view.dispatch.bind(view));
31151
31523
  if (applied) {
31152
31524
  if (shouldFocus) view.focus();
31153
31525
  return;
@@ -31211,7 +31583,7 @@ var BubbleMenuContent = ({
31211
31583
  const currentCellNumberFormat = normalizeStyleValue(editor.getAttributes("tableCell").numberFormat || editor.getAttributes("tableHeader").numberFormat) || "text";
31212
31584
  const currentCellBorderStyle = editor.getAttributes("tableCell").borderStyle || editor.getAttributes("tableHeader").borderStyle || "solid";
31213
31585
  const currentCellBorderWidth = editor.getAttributes("tableCell").borderWidth || editor.getAttributes("tableHeader").borderWidth || "1px";
31214
- const isInTable2 = (0, import_tables3.isInTable)(editor.state);
31586
+ const isInTable2 = (0, import_tables5.isInTable)(editor.state);
31215
31587
  const canMergeCells = isInTable2 && editor.can().mergeCells();
31216
31588
  const canSplitCell = isInTable2 && editor.can().splitCell();
31217
31589
  const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
@@ -35669,7 +36041,7 @@ if (typeof WeakMap != "undefined") {
35669
36041
  return cache[cachePos++] = value;
35670
36042
  };
35671
36043
  }
35672
- var TableMap3 = class {
36044
+ var TableMap4 = class {
35673
36045
  constructor(width, height, map, problems) {
35674
36046
  this.width = width;
35675
36047
  this.height = height;
@@ -35806,7 +36178,7 @@ function computeMap(table) {
35806
36178
  pos++;
35807
36179
  }
35808
36180
  if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
35809
- const tableMap = new TableMap3(width, height, map, problems);
36181
+ const tableMap = new TableMap4(width, height, map, problems);
35810
36182
  let badWidths = false;
35811
36183
  for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
35812
36184
  if (badWidths) findBadColWidths(tableMap, colWidths, table);
@@ -35863,7 +36235,7 @@ function freshColWidth(attrs) {
35863
36235
  for (let i = 0; i < attrs.colspan; i++) result.push(0);
35864
36236
  return result;
35865
36237
  }
35866
- function tableNodeTypes(schema) {
36238
+ function tableNodeTypes2(schema) {
35867
36239
  let result = schema.cached.tableNodeTypes;
35868
36240
  if (!result) {
35869
36241
  result = schema.cached.tableNodeTypes = {};
@@ -35875,7 +36247,7 @@ function tableNodeTypes(schema) {
35875
36247
  return result;
35876
36248
  }
35877
36249
  var tableEditingKey = new PluginKey5("selectingCells");
35878
- function cellAround($pos) {
36250
+ function cellAround2($pos) {
35879
36251
  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));
35880
36252
  return null;
35881
36253
  }
@@ -35888,7 +36260,7 @@ function selectionCell(state) {
35888
36260
  const sel = state.selection;
35889
36261
  if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
35890
36262
  else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
35891
- const $cell = cellAround(sel.$head) || cellNear(sel.$head);
36263
+ const $cell = cellAround2(sel.$head) || cellNear(sel.$head);
35892
36264
  if ($cell) return $cell;
35893
36265
  throw new RangeError(`No cell found around position ${sel.head}`);
35894
36266
  }
@@ -35902,7 +36274,7 @@ function cellNear($pos) {
35902
36274
  if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
35903
36275
  }
35904
36276
  }
35905
- function pointsAtCell($pos) {
36277
+ function pointsAtCell2($pos) {
35906
36278
  return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
35907
36279
  }
35908
36280
  function inSameTable($cellA, $cellB) {
@@ -35910,7 +36282,7 @@ function inSameTable($cellA, $cellB) {
35910
36282
  }
35911
36283
  function nextCell($pos, axis, dir) {
35912
36284
  const table = $pos.node(-1);
35913
- const map = TableMap3.get(table);
36285
+ const map = TableMap4.get(table);
35914
36286
  const tableStart = $pos.start(-1);
35915
36287
  const moved = map.nextCell($pos.pos - tableStart, axis, dir);
35916
36288
  return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
@@ -35930,7 +36302,7 @@ function removeColSpan(attrs, pos, n = 1) {
35930
36302
  var CellSelection = class CellSelection2 extends Selection {
35931
36303
  constructor($anchorCell, $headCell = $anchorCell) {
35932
36304
  const table = $anchorCell.node(-1);
35933
- const map = TableMap3.get(table);
36305
+ const map = TableMap4.get(table);
35934
36306
  const tableStart = $anchorCell.start(-1);
35935
36307
  const rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
35936
36308
  const doc = $anchorCell.node(0);
@@ -35949,7 +36321,7 @@ var CellSelection = class CellSelection2 extends Selection {
35949
36321
  map(doc, mapping) {
35950
36322
  const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
35951
36323
  const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
35952
- if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
36324
+ if (pointsAtCell2($anchorCell) && pointsAtCell2($headCell) && inSameTable($anchorCell, $headCell)) {
35953
36325
  const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
35954
36326
  if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
35955
36327
  else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
@@ -35959,7 +36331,7 @@ var CellSelection = class CellSelection2 extends Selection {
35959
36331
  }
35960
36332
  content() {
35961
36333
  const table = this.$anchorCell.node(-1);
35962
- const map = TableMap3.get(table);
36334
+ const map = TableMap4.get(table);
35963
36335
  const tableStart = this.$anchorCell.start(-1);
35964
36336
  const rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
35965
36337
  const seen = {};
@@ -36013,7 +36385,7 @@ var CellSelection = class CellSelection2 extends Selection {
36013
36385
  }
36014
36386
  forEachCell(f) {
36015
36387
  const table = this.$anchorCell.node(-1);
36016
- const map = TableMap3.get(table);
36388
+ const map = TableMap4.get(table);
36017
36389
  const tableStart = this.$anchorCell.start(-1);
36018
36390
  const cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
36019
36391
  for (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);
@@ -36028,7 +36400,7 @@ var CellSelection = class CellSelection2 extends Selection {
36028
36400
  }
36029
36401
  static colSelection($anchorCell, $headCell = $anchorCell) {
36030
36402
  const table = $anchorCell.node(-1);
36031
- const map = TableMap3.get(table);
36403
+ const map = TableMap4.get(table);
36032
36404
  const tableStart = $anchorCell.start(-1);
36033
36405
  const anchorRect = map.findCell($anchorCell.pos - tableStart);
36034
36406
  const headRect = map.findCell($headCell.pos - tableStart);
@@ -36044,7 +36416,7 @@ var CellSelection = class CellSelection2 extends Selection {
36044
36416
  }
36045
36417
  isRowSelection() {
36046
36418
  const table = this.$anchorCell.node(-1);
36047
- const map = TableMap3.get(table);
36419
+ const map = TableMap4.get(table);
36048
36420
  const tableStart = this.$anchorCell.start(-1);
36049
36421
  const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);
36050
36422
  const headLeft = map.colCount(this.$headCell.pos - tableStart);
@@ -36058,7 +36430,7 @@ var CellSelection = class CellSelection2 extends Selection {
36058
36430
  }
36059
36431
  static rowSelection($anchorCell, $headCell = $anchorCell) {
36060
36432
  const table = $anchorCell.node(-1);
36061
- const map = TableMap3.get(table);
36433
+ const map = TableMap4.get(table);
36062
36434
  const tableStart = $anchorCell.start(-1);
36063
36435
  const anchorRect = map.findCell($anchorCell.pos - tableStart);
36064
36436
  const headRect = map.findCell($headCell.pos - tableStart);
@@ -36107,7 +36479,7 @@ var CellBookmark = class CellBookmark2 {
36107
36479
  };
36108
36480
  var fixTablesKey = new PluginKey5("fix-tables");
36109
36481
  function convertTableNodeToArrayOfRows(tableNode) {
36110
- const map = TableMap3.get(tableNode);
36482
+ const map = TableMap4.get(tableNode);
36111
36483
  const rows = [];
36112
36484
  const rowCount = map.height;
36113
36485
  const colCount$1 = map.width;
@@ -36138,7 +36510,7 @@ function convertTableNodeToArrayOfRows(tableNode) {
36138
36510
  }
36139
36511
  function convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {
36140
36512
  const newRows = [];
36141
- const map = TableMap3.get(tableNode);
36513
+ const map = TableMap4.get(tableNode);
36142
36514
  const rowCount = map.height;
36143
36515
  const colCount$1 = map.width;
36144
36516
  for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
@@ -36187,7 +36559,7 @@ function findParentNode(predicate, $pos) {
36187
36559
  function getCellsInColumn(columnIndex, selection) {
36188
36560
  const table = findTable(selection.$from);
36189
36561
  if (!table) return;
36190
- const map = TableMap3.get(table.node);
36562
+ const map = TableMap4.get(table.node);
36191
36563
  if (columnIndex < 0 || columnIndex > map.width - 1) return;
36192
36564
  return map.cellsInRect({
36193
36565
  left: columnIndex,
@@ -36208,7 +36580,7 @@ function getCellsInColumn(columnIndex, selection) {
36208
36580
  function getCellsInRow(rowIndex, selection) {
36209
36581
  const table = findTable(selection.$from);
36210
36582
  if (!table) return;
36211
- const map = TableMap3.get(table.node);
36583
+ const map = TableMap4.get(table.node);
36212
36584
  if (rowIndex < 0 || rowIndex > map.height - 1) return;
36213
36585
  return map.cellsInRect({
36214
36586
  left: 0,
@@ -36337,7 +36709,7 @@ function moveColumn(moveColParams) {
36337
36709
  const newTable = moveTableColumn$1(table.node, indexesOriginColumn, indexesTargetColumn, 0);
36338
36710
  tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
36339
36711
  if (!select) return true;
36340
- const map = TableMap3.get(newTable);
36712
+ const map = TableMap4.get(newTable);
36341
36713
  const start = table.start;
36342
36714
  const index = targetIndex;
36343
36715
  const lastCell = map.positionAt(map.height - 1, index, newTable);
@@ -36365,7 +36737,7 @@ function moveRow(moveRowParams) {
36365
36737
  const newTable = moveTableRow$1(table.node, indexesOriginRow, indexesTargetRow, 0);
36366
36738
  tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
36367
36739
  if (!select) return true;
36368
- const map = TableMap3.get(newTable);
36740
+ const map = TableMap4.get(newTable);
36369
36741
  const start = table.start;
36370
36742
  const index = targetIndex;
36371
36743
  const lastCell = map.positionAt(index, map.width - 1, newTable);
@@ -36385,7 +36757,7 @@ function selectedRect3(state) {
36385
36757
  const $pos = selectionCell(state);
36386
36758
  const table = $pos.node(-1);
36387
36759
  const tableStart = $pos.start(-1);
36388
- const map = TableMap3.get(table);
36760
+ const map = TableMap4.get(table);
36389
36761
  return {
36390
36762
  ...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
36391
36763
  tableStart,
@@ -36397,7 +36769,7 @@ function deprecated_toggleHeader(type) {
36397
36769
  return function(state, dispatch) {
36398
36770
  if (!isInTable(state)) return false;
36399
36771
  if (dispatch) {
36400
- const types = tableNodeTypes(state.schema);
36772
+ const types = tableNodeTypes2(state.schema);
36401
36773
  const rect = selectedRect3(state), tr = state.tr;
36402
36774
  const cells = rect.map.cellsInRect(type == "column" ? {
36403
36775
  left: rect.left,
@@ -36437,7 +36809,7 @@ function toggleHeader(type, options) {
36437
36809
  return function(state, dispatch) {
36438
36810
  if (!isInTable(state)) return false;
36439
36811
  if (dispatch) {
36440
- const types = tableNodeTypes(state.schema);
36812
+ const types = tableNodeTypes2(state.schema);
36441
36813
  const rect = selectedRect3(state), tr = state.tr;
36442
36814
  const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
36443
36815
  const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types);
@@ -36472,7 +36844,7 @@ function deleteCellSelection(state, dispatch) {
36472
36844
  if (!(sel instanceof CellSelection)) return false;
36473
36845
  if (dispatch) {
36474
36846
  const tr = state.tr;
36475
- const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
36847
+ const baseContent = tableNodeTypes2(state.schema).cell.createAndFill().content;
36476
36848
  sel.forEachCell((cell, pos) => {
36477
36849
  if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
36478
36850
  });
@@ -36583,13 +36955,13 @@ function atEndOfCell(view, axis, dir) {
36583
36955
  }
36584
36956
  return null;
36585
36957
  }
36586
- var columnResizingPluginKey = new PluginKey5("tableColumnResizing");
36958
+ var columnResizingPluginKey2 = new PluginKey5("tableColumnResizing");
36587
36959
 
36588
36960
  // src/components/UEditor/table-controls.tsx
36589
36961
  var import_lucide_react53 = require("lucide-react");
36590
36962
 
36591
36963
  // src/components/UEditor/table-layout-model.ts
36592
- var FALLBACK_TABLE_ROW_HEIGHT = 44;
36964
+ var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
36593
36965
  var FALLBACK_TABLE_COLUMN_WIDTH = 160;
36594
36966
  function getVisibleTableBounds(layout) {
36595
36967
  const left = Math.max(layout.tableLeft, layout.wrapperLeft);
@@ -36671,7 +37043,7 @@ function buildLogicalColumnMetrics({
36671
37043
  tableLeft,
36672
37044
  tableWidth
36673
37045
  }) {
36674
- const map = TableMap3.get(tableInfo.node);
37046
+ const map = TableMap4.get(tableInfo.node);
36675
37047
  const fallbackWidth = metricOrFallback(tableWidth / map.width, FALLBACK_TABLE_COLUMN_WIDTH);
36676
37048
  const firstRow = tableElement.rows.item(0);
36677
37049
  const visualColumns = [];
@@ -36724,7 +37096,7 @@ function buildLogicalRowMetrics({
36724
37096
  tableHeight,
36725
37097
  cornerCell
36726
37098
  }) {
36727
- const map = TableMap3.get(tableInfo.node);
37099
+ const map = TableMap4.get(tableInfo.node);
36728
37100
  const fallbackHeight = metricOrFallback(tableHeight / map.height, FALLBACK_TABLE_ROW_HEIGHT);
36729
37101
  const visualRows = [];
36730
37102
  const seenCellPositions = /* @__PURE__ */ new Set();
@@ -36778,7 +37150,7 @@ function buildTableControlLayout(editor, surface, cell) {
36778
37150
  if (rows.length === 0 || !tableInfo || !(cornerCell instanceof HTMLTableCellElement)) {
36779
37151
  return null;
36780
37152
  }
36781
- const map = TableMap3.get(tableInfo.node);
37153
+ const map = TableMap4.get(tableInfo.node);
36782
37154
  const surfaceRect = surface.getBoundingClientRect();
36783
37155
  const tableRect = table.getBoundingClientRect();
36784
37156
  const wrapperElement = table.closest(".tableWrapper");
@@ -37412,7 +37784,7 @@ function TableControls({ editor, containerRef }) {
37412
37784
  const handleSurfaceMouseMove = (event) => {
37413
37785
  updateHoverState(event);
37414
37786
  };
37415
- const handleMouseLeave = () => {
37787
+ const handleMouseLeave2 = () => {
37416
37788
  if (dragStateRef.current) return;
37417
37789
  setHoverState(DEFAULT_TABLE_HOVER_STATE);
37418
37790
  };
@@ -37422,7 +37794,7 @@ function TableControls({ editor, containerRef }) {
37422
37794
  syncFromCell(cell ?? getSelectedCell(editor));
37423
37795
  };
37424
37796
  proseMirror.addEventListener("mouseover", handleMouseOver);
37425
- proseMirror.addEventListener("mouseleave", handleMouseLeave);
37797
+ proseMirror.addEventListener("mouseleave", handleMouseLeave2);
37426
37798
  proseMirror.addEventListener("click", handleFocusIn);
37427
37799
  proseMirror.addEventListener("mouseup", handleFocusIn);
37428
37800
  proseMirror.addEventListener("focusin", handleFocusIn);
@@ -37436,7 +37808,7 @@ function TableControls({ editor, containerRef }) {
37436
37808
  syncFromSelection();
37437
37809
  return () => {
37438
37810
  proseMirror.removeEventListener("mouseover", handleMouseOver);
37439
- proseMirror.removeEventListener("mouseleave", handleMouseLeave);
37811
+ proseMirror.removeEventListener("mouseleave", handleMouseLeave2);
37440
37812
  proseMirror.removeEventListener("click", handleFocusIn);
37441
37813
  proseMirror.removeEventListener("mouseup", handleFocusIn);
37442
37814
  proseMirror.removeEventListener("focusin", handleFocusIn);
@@ -37535,7 +37907,7 @@ function TableControls({ editor, containerRef }) {
37535
37907
  document.body.style.cursor = "grabbing";
37536
37908
  }, []);
37537
37909
  import_react66.default.useEffect(() => {
37538
- const handleMouseMove = (event) => {
37910
+ const handleMouseMove2 = (event) => {
37539
37911
  const dragState = dragStateRef.current;
37540
37912
  const activeLayout = layoutRef.current;
37541
37913
  const surface = containerRef.current;
@@ -37614,11 +37986,11 @@ function TableControls({ editor, containerRef }) {
37614
37986
  }
37615
37987
  clearDrag();
37616
37988
  };
37617
- window.addEventListener("mousemove", handleMouseMove);
37989
+ window.addEventListener("mousemove", handleMouseMove2);
37618
37990
  window.addEventListener("mouseup", handleMouseUp);
37619
37991
  window.addEventListener("blur", clearDrag);
37620
37992
  return () => {
37621
- window.removeEventListener("mousemove", handleMouseMove);
37993
+ window.removeEventListener("mousemove", handleMouseMove2);
37622
37994
  window.removeEventListener("mouseup", handleMouseUp);
37623
37995
  window.removeEventListener("blur", clearDrag);
37624
37996
  };
@@ -37906,6 +38278,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
37906
38278
  "[&_th]:px-2",
37907
38279
  "[&_th]:py-0",
37908
38280
  "[&_th_p]:my-0",
38281
+ "[&_td[colwidth]]:min-w-0",
38282
+ "[&_th[colwidth]]:min-w-0",
38283
+ "[&_td[data-colwidth]]:min-w-0",
38284
+ "[&_th[data-colwidth]]:min-w-0",
37909
38285
  "[&_.selectedCell]:after:content-['']",
37910
38286
  "[&_.selectedCell]:after:absolute",
37911
38287
  "[&_.selectedCell]:after:inset-0",
@@ -37935,6 +38311,7 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
37935
38311
  "[&_.column-resize-handle]:after:content-['']",
37936
38312
  "[&.resize-cursor_.column-resize-handle]:opacity-100",
37937
38313
  "[&.resize-cursor_.column-resize-handle]:after:bg-primary",
38314
+ "[&_.column-resize-dragging]:min-w-0",
37938
38315
  "[&.resize-cursor]:cursor-col-resize",
37939
38316
  "[&.resize-row-cursor]:cursor-row-resize",
37940
38317
  "[&_img.ProseMirror-selectednode]:ring-2",
@@ -38007,55 +38384,12 @@ function useTableRowResize({
38007
38384
  clearAllTableResizeHover,
38008
38385
  scheduleTableLayoutSync
38009
38386
  }) {
38010
- const commitFrameRef = (0, import_react67.useRef)(null);
38011
38387
  const stateRef = (0, import_react67.useRef)(null);
38012
- const commitPreview = import_react67.default.useCallback(() => {
38013
- if (!editor) return;
38014
- const state = stateRef.current;
38015
- if (!state) return;
38016
- const nextHeight = state.pendingHeight;
38017
- if (nextHeight === state.previewHeight) {
38018
- document.body.style.cursor = "row-resize";
38019
- showRowGuide(state.tableElement, state.rowElement, state.cellElement);
38020
- scheduleTableLayoutSync();
38021
- return;
38022
- }
38023
- state.previewHeight = nextHeight;
38024
- const tr = editor.view.state.tr;
38025
- tr.setNodeMarkup(state.rowPos, void 0, {
38026
- ...state.rowNode.attrs,
38027
- rowHeight: nextHeight
38028
- });
38029
- tr.setMeta("addToHistory", false);
38030
- editor.view.dispatch(tr);
38031
- state.rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
38032
- const rowIndex = state.rowElement.rowIndex;
38033
- if (rowIndex >= 0) {
38034
- const refreshedRow = state.tableElement.rows.item(rowIndex);
38035
- if (refreshedRow instanceof HTMLTableRowElement) {
38036
- state.rowElement = refreshedRow;
38037
- const refreshedCell = refreshedRow.cells.item(state.cellIndex);
38038
- if (refreshedCell instanceof HTMLTableCellElement) {
38039
- state.cellElement = refreshedCell;
38040
- }
38041
- }
38042
- }
38043
- document.body.style.cursor = "row-resize";
38044
- showRowGuide(state.tableElement, state.rowElement, state.cellElement);
38045
- scheduleTableLayoutSync();
38046
- }, [editor, scheduleTableLayoutSync, showRowGuide]);
38047
- const scheduleCommit = import_react67.default.useCallback(() => {
38048
- if (commitFrameRef.current !== null) return;
38049
- commitFrameRef.current = window.requestAnimationFrame(() => {
38050
- commitFrameRef.current = null;
38051
- commitPreview();
38052
- });
38053
- }, [commitPreview]);
38054
38388
  const syncActiveGuide = import_react67.default.useCallback(() => {
38055
38389
  const state = stateRef.current;
38056
38390
  if (!state) return false;
38057
38391
  setHoveredTableCell(state.cellElement);
38058
- showRowGuide(state.tableElement, state.rowElement, state.cellElement);
38392
+ showRowGuide(state.tableElement, state.rowElement, state.cellElement, state.pendingHeight);
38059
38393
  return true;
38060
38394
  }, [setHoveredTableCell, showRowGuide]);
38061
38395
  const isResizing = import_react67.default.useCallback(() => stateRef.current !== null, []);
@@ -38079,7 +38413,7 @@ function useTableRowResize({
38079
38413
  previewHeight: startHeight,
38080
38414
  pendingHeight: startHeight
38081
38415
  };
38082
- showRowGuide(table, row, cell);
38416
+ showRowGuide(table, row, cell, startHeight);
38083
38417
  document.body.style.cursor = "row-resize";
38084
38418
  event.preventDefault();
38085
38419
  event.stopPropagation();
@@ -38094,13 +38428,14 @@ function useTableRowResize({
38094
38428
  );
38095
38429
  if (nextHeight === state.pendingHeight) {
38096
38430
  document.body.style.cursor = "row-resize";
38097
- showRowGuide(state.tableElement, state.rowElement, state.cellElement);
38431
+ showRowGuide(state.tableElement, state.rowElement, state.cellElement, state.pendingHeight);
38098
38432
  return;
38099
38433
  }
38100
38434
  state.pendingHeight = nextHeight;
38435
+ state.previewHeight = nextHeight;
38101
38436
  document.body.style.cursor = "row-resize";
38102
- scheduleCommit();
38103
- }, [scheduleCommit, showRowGuide]);
38437
+ showRowGuide(state.tableElement, state.rowElement, state.cellElement, nextHeight);
38438
+ }, [showRowGuide]);
38104
38439
  const handlePointerUp = import_react67.default.useCallback((event) => {
38105
38440
  if (!editor) return;
38106
38441
  const state = stateRef.current;
@@ -38110,16 +38445,10 @@ function useTableRowResize({
38110
38445
  Math.round(state.startHeight + (event.clientY - state.startY))
38111
38446
  );
38112
38447
  state.pendingHeight = nextHeight;
38113
- if (commitFrameRef.current !== null) {
38114
- window.cancelAnimationFrame(commitFrameRef.current);
38115
- commitFrameRef.current = null;
38116
- }
38117
- commitPreview();
38118
- const latestState = stateRef.current ?? state;
38119
- const rowNode = editor.view.state.doc.nodeAt(latestState.rowPos) ?? latestState.rowNode;
38448
+ const rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
38120
38449
  if (rowNode.attrs.rowHeight !== nextHeight) {
38121
38450
  const tr = editor.view.state.tr;
38122
- tr.setNodeMarkup(latestState.rowPos, void 0, {
38451
+ tr.setNodeMarkup(state.rowPos, void 0, {
38123
38452
  ...rowNode.attrs,
38124
38453
  rowHeight: nextHeight
38125
38454
  });
@@ -38130,13 +38459,9 @@ function useTableRowResize({
38130
38459
  clearHoveredTableCell();
38131
38460
  clearAllTableResizeHover();
38132
38461
  scheduleTableLayoutSync();
38133
- }, [clearAllTableResizeHover, clearHoveredTableCell, commitPreview, editor, scheduleTableLayoutSync]);
38462
+ }, [clearAllTableResizeHover, clearHoveredTableCell, editor, scheduleTableLayoutSync]);
38134
38463
  const cancelResize = import_react67.default.useCallback(() => {
38135
38464
  if (!stateRef.current) return;
38136
- if (commitFrameRef.current !== null) {
38137
- window.cancelAnimationFrame(commitFrameRef.current);
38138
- commitFrameRef.current = null;
38139
- }
38140
38465
  stateRef.current = null;
38141
38466
  document.body.style.cursor = "";
38142
38467
  clearHoveredTableCell();
@@ -38144,10 +38469,6 @@ function useTableRowResize({
38144
38469
  scheduleTableLayoutSync();
38145
38470
  }, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
38146
38471
  const cleanup = import_react67.default.useCallback(() => {
38147
- if (commitFrameRef.current !== null) {
38148
- window.cancelAnimationFrame(commitFrameRef.current);
38149
- commitFrameRef.current = null;
38150
- }
38151
38472
  stateRef.current = null;
38152
38473
  document.body.style.cursor = "";
38153
38474
  }, []);
@@ -38257,13 +38578,15 @@ function useUEditorTableInteractions(editor, editable = true) {
38257
38578
  getProseMirrorElement()?.classList.add("resize-cursor");
38258
38579
  setEditorResizeCursor("col-resize");
38259
38580
  }, [getProseMirrorElement, setEditorResizeCursor]);
38260
- const showRowGuide = import_react68.default.useCallback((table, row, cell) => {
38581
+ const showRowGuide = import_react68.default.useCallback((table, row, cell, previewHeight) => {
38261
38582
  const surface = editorContentRef.current;
38262
38583
  const guide = tableRowGuideRef.current;
38263
38584
  if (!surface || !guide) return;
38264
38585
  const metrics = getRelativeBoundaryMetrics(surface, table, row, cell);
38586
+ const rowRect = row.getBoundingClientRect();
38587
+ const previewBottom = typeof previewHeight === "number" ? metrics.rowBottom - rowRect.height + previewHeight : metrics.rowBottom;
38265
38588
  guide.style.left = `${metrics.left}px`;
38266
- guide.style.top = `${metrics.rowBottom - ROW_RESIZE_LINE_THICKNESS / 2}px`;
38589
+ guide.style.top = `${previewBottom - ROW_RESIZE_LINE_THICKNESS / 2}px`;
38267
38590
  guide.style.width = `${metrics.width}px`;
38268
38591
  guide.style.height = `${ROW_RESIZE_LINE_THICKNESS}px`;
38269
38592
  guide.style.opacity = "1";
@@ -38475,7 +38798,7 @@ var import_react70 = require("@tiptap/react");
38475
38798
  var import_lucide_react54 = require("lucide-react");
38476
38799
 
38477
38800
  // src/components/UEditor/preview-html.ts
38478
- var DEFAULT_TABLE_COLUMN_WIDTH = 100;
38801
+ var DEFAULT_TABLE_COLUMN_WIDTH2 = 100;
38479
38802
  var TIPTAP_TABLE_MIN_COLUMN_WIDTH = 25;
38480
38803
  function parsePixelWidth2(value) {
38481
38804
  if (!value) return null;
@@ -38502,7 +38825,7 @@ function getCellWidths(cell) {
38502
38825
  const width = parsePixelWidth2(cell.getAttribute("width")) ?? parseStyleWidth(cell.style);
38503
38826
  if (!width) return null;
38504
38827
  const colspan = getCellColspan(cell);
38505
- return Array.from({ length: colspan }, () => Math.max(DEFAULT_TABLE_COLUMN_WIDTH, Math.round(width / colspan)));
38828
+ return Array.from({ length: colspan }, () => Math.max(DEFAULT_TABLE_COLUMN_WIDTH2, Math.round(width / colspan)));
38506
38829
  }
38507
38830
  function getColumnCount(table) {
38508
38831
  const colCount = table.querySelectorAll("colgroup > col").length;
@@ -38517,7 +38840,7 @@ function getColumnCount(table) {
38517
38840
  function resolveColumnWidths(table) {
38518
38841
  const columnCount = getColumnCount(table);
38519
38842
  if (columnCount <= 0) return [];
38520
- const widths = Array.from({ length: columnCount }, () => DEFAULT_TABLE_COLUMN_WIDTH);
38843
+ const widths = Array.from({ length: columnCount }, () => DEFAULT_TABLE_COLUMN_WIDTH2);
38521
38844
  const cols = Array.from(table.querySelectorAll("colgroup > col"));
38522
38845
  cols.slice(0, columnCount).forEach((col, index) => {
38523
38846
  const width = parsePixelWidth2(col.getAttribute("width")) ?? parseStyleWidth(col.style);
@@ -38551,11 +38874,10 @@ function resolveExplicitRowHeight(row) {
38551
38874
  const height = parsePixelWidth2(cell.getAttribute("height")) ?? parseStyleHeight(cell.style);
38552
38875
  return height ? Math.max(maxHeight, height) : maxHeight;
38553
38876
  }, 0);
38554
- return cellHeight ? Math.max(MIN_TABLE_ROW_HEIGHT, cellHeight) : null;
38877
+ return cellHeight ? Math.max(MIN_TABLE_ROW_HEIGHT, cellHeight) : DEFAULT_TABLE_ROW_HEIGHT;
38555
38878
  }
38556
38879
  function normalizePreviewRowHeight(row) {
38557
38880
  const rowHeight = resolveExplicitRowHeight(row);
38558
- if (!rowHeight) return;
38559
38881
  row.style.height = `${rowHeight}px`;
38560
38882
  row.style.minHeight = `${rowHeight}px`;
38561
38883
  Array.from(row.cells).forEach((cell) => {
@@ -38987,17 +39309,6 @@ function buildTableMenuItems(t, editor, onInsertTable) {
38987
39309
  label: t("menubar.row"),
38988
39310
  disabled: !inTable,
38989
39311
  items: [
38990
- {
38991
- type: "action",
38992
- label: t("menubar.addRowBefore"),
38993
- onClick: () => editor.chain().focus().addRowBefore().run()
38994
- },
38995
- {
38996
- type: "action",
38997
- label: t("menubar.addRowAfter"),
38998
- onClick: () => editor.chain().focus().addRowAfter().run()
38999
- },
39000
- { type: "separator" },
39001
39312
  {
39002
39313
  type: "action",
39003
39314
  label: t("menubar.deleteRow"),
@@ -39011,17 +39322,6 @@ function buildTableMenuItems(t, editor, onInsertTable) {
39011
39322
  label: t("menubar.column"),
39012
39323
  disabled: !inTable,
39013
39324
  items: [
39014
- {
39015
- type: "action",
39016
- label: t("menubar.addColumnBefore"),
39017
- onClick: () => editor.chain().focus().addColumnBefore().run()
39018
- },
39019
- {
39020
- type: "action",
39021
- label: t("menubar.addColumnAfter"),
39022
- onClick: () => editor.chain().focus().addColumnAfter().run()
39023
- },
39024
- { type: "separator" },
39025
39325
  {
39026
39326
  type: "action",
39027
39327
  label: t("menubar.deleteColumn"),
@@ -39357,8 +39657,8 @@ var MenuBar = ({
39357
39657
  };
39358
39658
 
39359
39659
  // src/components/UEditor/table-formula-range-picker.ts
39360
- var import_state9 = require("@tiptap/pm/state");
39361
- var import_tables4 = require("@tiptap/pm/tables");
39660
+ var import_state10 = require("@tiptap/pm/state");
39661
+ var import_tables6 = require("@tiptap/pm/tables");
39362
39662
  function getCellText2(cellNode) {
39363
39663
  return cellNode.textBetween(0, cellNode.content.size, "\n").trim();
39364
39664
  }
@@ -39413,7 +39713,7 @@ function getPickedCellLabel(view, target, tablePos) {
39413
39713
  const domPos = view.posAtDOM(cell, 0);
39414
39714
  const tableInfo = findTableForPos(view, domPos);
39415
39715
  if (!tableInfo || tableInfo.pos !== tablePos) return null;
39416
- const map = import_tables4.TableMap.get(tableInfo.node);
39716
+ const map = import_tables6.TableMap.get(tableInfo.node);
39417
39717
  const relativeCellPos = getCellRelativePosFromDomPos2(map, tableInfo.start, domPos);
39418
39718
  if (relativeCellPos == null) return null;
39419
39719
  const rect = map.findCell(relativeCellPos);
@@ -39435,7 +39735,7 @@ function replacePickedLabel(view, pickState, nextLabel, currentCell) {
39435
39735
  }
39436
39736
  let tr = view.state.tr.insertText(nextLabel, pickState.insertedFrom, pickState.insertedTo);
39437
39737
  const nextTo = pickState.insertedFrom + nextLabel.length;
39438
- tr = tr.setSelection(import_state9.TextSelection.create(tr.doc, nextTo));
39738
+ tr = tr.setSelection(import_state10.TextSelection.create(tr.doc, nextTo));
39439
39739
  view.dispatch(tr);
39440
39740
  return {
39441
39741
  ...pickState,
@@ -39452,7 +39752,7 @@ function beginFormulaRangePick(view, event) {
39452
39752
  if (!picked || picked.cell === formulaCell.cellDom) return null;
39453
39753
  const { from, to } = view.state.selection;
39454
39754
  let tr = view.state.tr.insertText(picked.label, from, to);
39455
- tr = tr.setSelection(import_state9.TextSelection.create(tr.doc, from + picked.label.length));
39755
+ tr = tr.setSelection(import_state10.TextSelection.create(tr.doc, from + picked.label.length));
39456
39756
  view.dispatch(tr);
39457
39757
  view.focus();
39458
39758
  event.preventDefault();