@underverse-ui/underverse 1.0.204 → 1.0.206

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/api-reference.json +1 -1
  2. package/dist/{EmojiPicker-UN6N7YVB.js → EmojiPicker-FEJJDAWZ.js} +4 -4
  3. package/dist/{chunk-CC3QO2YM.js → chunk-4E43DRP2.js} +243 -57
  4. package/dist/chunk-4E43DRP2.js.map +1 -0
  5. package/dist/{chunk-KFTYWTJR.js → chunk-AMAILXHP.js} +81 -36
  6. package/dist/chunk-AMAILXHP.js.map +1 -0
  7. package/dist/{chunk-GSBRTFP2.js → chunk-BRDGIALS.js} +28 -17
  8. package/dist/chunk-BRDGIALS.js.map +1 -0
  9. package/dist/{chunk-ZUAIBY2Z.js → chunk-CYCBSKWI.js} +2 -2
  10. package/dist/{chunk-CKKLFVOY.js → chunk-F6A7HJE4.js} +3 -3
  11. package/dist/{chunk-QVQTWZ24.js → chunk-GKY5DHGR.js} +3 -3
  12. package/dist/index.cjs +328 -90
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +16 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.js +6 -6
  17. package/dist/{menu-bar-6U5S4PS7.js → menu-bar-6GS5LLTD.js} +4 -4
  18. package/dist/ueditor.cjs +338 -101
  19. package/dist/ueditor.cjs.map +1 -1
  20. package/dist/ueditor.d.cts +6 -0
  21. package/dist/ueditor.d.ts +6 -0
  22. package/dist/ueditor.js +4 -4
  23. package/package.json +1 -1
  24. package/dist/chunk-CC3QO2YM.js.map +0 -1
  25. package/dist/chunk-GSBRTFP2.js.map +0 -1
  26. package/dist/chunk-KFTYWTJR.js.map +0 -1
  27. /package/dist/{EmojiPicker-UN6N7YVB.js.map → EmojiPicker-FEJJDAWZ.js.map} +0 -0
  28. /package/dist/{chunk-ZUAIBY2Z.js.map → chunk-CYCBSKWI.js.map} +0 -0
  29. /package/dist/{chunk-CKKLFVOY.js.map → chunk-F6A7HJE4.js.map} +0 -0
  30. /package/dist/{chunk-QVQTWZ24.js.map → chunk-GKY5DHGR.js.map} +0 -0
  31. /package/dist/{menu-bar-6U5S4PS7.js.map → menu-bar-6GS5LLTD.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "1.0.204",
3
+ "version": "1.0.206",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 252,
6
6
  "exports": [
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  EmojiPicker,
4
4
  EmojiPicker_default
5
- } from "./chunk-CKKLFVOY.js";
6
- import "./chunk-ZUAIBY2Z.js";
5
+ } from "./chunk-F6A7HJE4.js";
6
+ import "./chunk-CYCBSKWI.js";
7
7
  import "./chunk-4TYW5K4J.js";
8
- import "./chunk-GSBRTFP2.js";
8
+ import "./chunk-BRDGIALS.js";
9
9
  import "./chunk-NSBPE2FW.js";
10
10
  export {
11
11
  EmojiPicker,
12
12
  EmojiPicker_default as default
13
13
  };
14
- //# sourceMappingURL=EmojiPicker-UN6N7YVB.js.map
14
+ //# sourceMappingURL=EmojiPicker-FEJJDAWZ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EmojiGridButton,
3
3
  formatEmojiCountLabel
4
- } from "./chunk-ZUAIBY2Z.js";
4
+ } from "./chunk-CYCBSKWI.js";
5
5
  import {
6
6
  COLUMN_RESIZE_LINE_THICKNESS,
7
7
  CellBgColorIcon,
@@ -42,6 +42,7 @@ import {
42
42
  getRelativeSelectedCellsMetrics,
43
43
  getSelectionTableCell,
44
44
  isColumnResizeHotspot,
45
+ isPointOverRenderedText,
45
46
  isRowResizeHotspot,
46
47
  isSafeUEditorUrl,
47
48
  mergeTableCellsPreservingColumnWidths,
@@ -52,12 +53,12 @@ import {
52
53
  sanitizeUEditorUrl,
53
54
  useEditorColors,
54
55
  useSharedEditorUiRenderState
55
- } from "./chunk-KFTYWTJR.js";
56
+ } from "./chunk-AMAILXHP.js";
56
57
  import {
57
58
  Tooltip,
58
59
  cn,
59
60
  useSmartTranslations
60
- } from "./chunk-GSBRTFP2.js";
61
+ } from "./chunk-BRDGIALS.js";
61
62
 
62
63
  // src/components/UEditor/prepare-content-for-save.ts
63
64
  var MIME_EXTENSION_MAP = {
@@ -472,11 +473,11 @@ async function prepareUEditorContentForSave({
472
473
  }
473
474
 
474
475
  // src/components/UEditor/UEditor.tsx
475
- import React14, { useEffect as useEffect9, useImperativeHandle as useImperativeHandle4, useMemo as useMemo2, useRef as useRef9 } from "react";
476
+ import React15, { useEffect as useEffect10, useImperativeHandle as useImperativeHandle4, useMemo as useMemo2, useRef as useRef10 } from "react";
476
477
  import { useEditor, EditorContent } from "@tiptap/react";
477
478
 
478
479
  // src/components/UEditor/extensions.ts
479
- import { mergeAttributes as mergeAttributes7 } from "@tiptap/core";
480
+ import { mergeAttributes as mergeAttributes8 } from "@tiptap/core";
480
481
  import { Document } from "@tiptap/extension-document";
481
482
  import { Paragraph } from "@tiptap/extension-paragraph";
482
483
  import { Text } from "@tiptap/extension-text";
@@ -507,7 +508,7 @@ import { NodeViewWrapper, NodeViewContent } from "@tiptap/react";
507
508
  import React from "react";
508
509
  import { jsx } from "react/jsx-runtime";
509
510
  var LazyBaseEmojiPicker = React.lazy(async () => {
510
- const { EmojiPicker: EmojiPicker2 } = await import("./EmojiPicker-UN6N7YVB.js");
511
+ const { EmojiPicker: EmojiPicker2 } = await import("./EmojiPicker-FEJJDAWZ.js");
511
512
  return { default: EmojiPicker2 };
512
513
  });
513
514
  var EmojiPicker = ({ onSelect }) => {
@@ -3310,6 +3311,7 @@ var Indent = Extension9.create({
3310
3311
  var indent_default = Indent;
3311
3312
 
3312
3313
  // src/components/UEditor/table-align.ts
3314
+ import { mergeAttributes as mergeAttributes7 } from "@tiptap/core";
3313
3315
  import { Table as Table2 } from "@tiptap/extension-table";
3314
3316
  import { Plugin as Plugin4 } from "@tiptap/pm/state";
3315
3317
  import { tableEditing } from "@tiptap/pm/tables";
@@ -3329,12 +3331,13 @@ import {
3329
3331
  } from "@tiptap/pm/tables";
3330
3332
  var DEFAULT_TABLE_COLUMN_WIDTH = 100;
3331
3333
  var MIN_RESIZED_TABLE_COLUMN_WIDTH = 25;
3332
- function getDynamicColumnMinWidth(startWidth, fallbackMinWidth) {
3333
- return Math.max(fallbackMinWidth, Math.round(startWidth / 3));
3334
+ function getColumnResizeMinWidth(configuredMinWidth) {
3335
+ const normalizedMinWidth = Number.isFinite(configuredMinWidth) && configuredMinWidth > 0 ? Math.round(configuredMinWidth) : MIN_RESIZED_TABLE_COLUMN_WIDTH;
3336
+ return Math.max(MIN_RESIZED_TABLE_COLUMN_WIDTH, normalizedMinWidth);
3334
3337
  }
3335
3338
  function setColumnStyle(column, width) {
3336
3339
  if (width == null) {
3337
- column.style.width = "";
3340
+ column.style.width = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
3338
3341
  column.style.minWidth = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
3339
3342
  return;
3340
3343
  }
@@ -3346,7 +3349,6 @@ function isTableColumnElement(node) {
3346
3349
  }
3347
3350
  function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue) {
3348
3351
  let totalWidth = 0;
3349
- let fixedWidth = true;
3350
3352
  let nextDOM = colgroup.firstChild;
3351
3353
  const row = node.firstChild;
3352
3354
  if (row) {
@@ -3356,9 +3358,6 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
3356
3358
  const rawWidth = overrideCol === col ? overrideValue : colwidth?.[spanIndex];
3357
3359
  const width = rawWidth ? Math.max(rawWidth, MIN_RESIZED_TABLE_COLUMN_WIDTH) : null;
3358
3360
  totalWidth += width ?? DEFAULT_TABLE_COLUMN_WIDTH;
3359
- if (!width) {
3360
- fixedWidth = false;
3361
- }
3362
3361
  const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(document.createElement("col"));
3363
3362
  setColumnStyle(colElement, width);
3364
3363
  nextDOM = colElement.nextSibling;
@@ -3371,11 +3370,10 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
3371
3370
  nextDOM = after;
3372
3371
  }
3373
3372
  const hasUserWidth = typeof node.attrs.style === "string" && /\bwidth\s*:/i.test(node.attrs.style);
3374
- if (fixedWidth && !hasUserWidth) {
3373
+ if (!hasUserWidth) {
3375
3374
  table.style.width = `${totalWidth}px`;
3376
3375
  table.style.minWidth = "";
3377
3376
  } else {
3378
- table.style.width = "";
3379
3377
  table.style.minWidth = `${totalWidth}px`;
3380
3378
  }
3381
3379
  }
@@ -3388,6 +3386,7 @@ var UEditorTableView = class {
3388
3386
  if (node.attrs.style) {
3389
3387
  this.table.style.cssText = node.attrs.style;
3390
3388
  }
3389
+ this.table.style.tableLayout = "fixed";
3391
3390
  this.colgroup = this.table.appendChild(document.createElement("colgroup"));
3392
3391
  updateDynamicColumns(node, this.colgroup, this.table);
3393
3392
  this.contentDOM = this.table.appendChild(document.createElement("tbody"));
@@ -3569,7 +3568,7 @@ function handleMouseDown(view, event, cellMinWidth) {
3569
3568
  colspan: attrs.colspan ?? 1,
3570
3569
  colwidth: attrs.colwidth
3571
3570
  });
3572
- const minWidth = getDynamicColumnMinWidth(width, cellMinWidth);
3571
+ const minWidth = getColumnResizeMinWidth(cellMinWidth);
3573
3572
  const dragging = {
3574
3573
  startX: event.clientX,
3575
3574
  startWidth: width,
@@ -3697,15 +3696,37 @@ function parseTableAlign(element) {
3697
3696
  function renderTableAlignStyle(tableAlign) {
3698
3697
  switch (tableAlign) {
3699
3698
  case "center":
3700
- return "width: max-content; max-width: 100%; margin-left: auto; margin-right: auto;";
3699
+ return "table-layout: fixed; margin-left: auto; margin-right: auto;";
3701
3700
  case "right":
3702
- return "width: max-content; max-width: 100%; margin-left: auto; margin-right: 0;";
3701
+ return "table-layout: fixed; margin-left: auto; margin-right: 0;";
3703
3702
  case "left":
3704
- return "width: max-content; max-width: 100%; margin-left: 0; margin-right: auto;";
3703
+ return "table-layout: fixed; margin-left: 0; margin-right: auto;";
3705
3704
  default:
3706
3705
  return "";
3707
3706
  }
3708
3707
  }
3708
+ function createUEditorColGroup(node) {
3709
+ const columns = [];
3710
+ let totalWidth = 0;
3711
+ const firstRow = node.firstChild;
3712
+ if (firstRow) {
3713
+ for (let cellIndex = 0; cellIndex < firstRow.childCount; cellIndex += 1) {
3714
+ const cell = firstRow.child(cellIndex);
3715
+ const colspan = Math.max(1, Number(cell.attrs.colspan) || 1);
3716
+ const colwidth = Array.isArray(cell.attrs.colwidth) ? cell.attrs.colwidth : [];
3717
+ for (let spanIndex = 0; spanIndex < colspan; spanIndex += 1) {
3718
+ const storedWidth = Number(colwidth[spanIndex]);
3719
+ const width = Number.isFinite(storedWidth) && storedWidth > 0 ? Math.max(MIN_RESIZED_TABLE_COLUMN_WIDTH, Math.round(storedWidth)) : DEFAULT_TABLE_COLUMN_WIDTH;
3720
+ totalWidth += width;
3721
+ columns.push(["col", { style: `width: ${width}px; min-width: ${width}px;`, width: String(width) }]);
3722
+ }
3723
+ }
3724
+ }
3725
+ return {
3726
+ colgroup: ["colgroup", {}, ...columns],
3727
+ tableWidth: totalWidth > 0 ? `${totalWidth}px` : ""
3728
+ };
3729
+ }
3709
3730
  var UEditorTable = Table2.extend({
3710
3731
  addGlobalAttributes() {
3711
3732
  return [
@@ -3759,6 +3780,18 @@ var UEditorTable = Table2.extend({
3759
3780
  }
3760
3781
  };
3761
3782
  },
3783
+ renderHTML({ node, HTMLAttributes }) {
3784
+ const { colgroup, tableWidth } = createUEditorColGroup(node);
3785
+ const table = [
3786
+ "table",
3787
+ mergeAttributes7(this.options.HTMLAttributes, HTMLAttributes, {
3788
+ style: tableWidth ? `width: ${tableWidth};` : "table-layout: fixed;"
3789
+ }),
3790
+ colgroup,
3791
+ ["tbody", 0]
3792
+ ];
3793
+ return this.options.renderWrapper ? ["div", { class: "tableWrapper" }, table] : table;
3794
+ },
3762
3795
  addProseMirrorPlugins() {
3763
3796
  const isResizable = this.options.resizable && this.editor.isEditable;
3764
3797
  return [
@@ -5150,6 +5183,21 @@ function getFormulaStateAttributes(attributes) {
5150
5183
  "data-formula-state": computedValue.startsWith("#") ? "error" : "computed"
5151
5184
  };
5152
5185
  }
5186
+ function normalizeTableCellTextWrap(value) {
5187
+ return value === "nowrap" ? "nowrap" : "wrap";
5188
+ }
5189
+ function parseTableCellTextWrap(element) {
5190
+ if (element.getAttribute("data-text-wrap") === "nowrap" || element.style.whiteSpace === "nowrap") {
5191
+ return "nowrap";
5192
+ }
5193
+ return "wrap";
5194
+ }
5195
+ function renderTableCellTextWrap(attributes) {
5196
+ return normalizeTableCellTextWrap(attributes.textWrap) === "nowrap" ? { "data-text-wrap": "nowrap" } : {};
5197
+ }
5198
+ function getTableCellTextWrapStyle(value) {
5199
+ return normalizeTableCellTextWrap(value) === "nowrap" ? "white-space: nowrap; overflow-wrap: normal; word-break: normal" : "white-space: normal; overflow-wrap: anywhere; word-break: normal";
5200
+ }
5153
5201
  var CustomTableCell = TableCell.extend({
5154
5202
  addAttributes() {
5155
5203
  return {
@@ -5250,6 +5298,11 @@ var CustomTableCell = TableCell.extend({
5250
5298
  default: null,
5251
5299
  parseHTML: (element) => element.getAttribute("data-text-direction") === "vertical" || ["sideways-lr", "vertical-lr", "vertical-rl"].includes(element.style.writingMode) ? "vertical" : null,
5252
5300
  renderHTML: (attributes) => attributes.textDirection === "vertical" ? { "data-text-direction": "vertical" } : {}
5301
+ },
5302
+ textWrap: {
5303
+ default: "wrap",
5304
+ parseHTML: parseTableCellTextWrap,
5305
+ renderHTML: renderTableCellTextWrap
5253
5306
  }
5254
5307
  };
5255
5308
  },
@@ -5261,6 +5314,7 @@ var CustomTableCell = TableCell.extend({
5261
5314
  const borderWidth = HTMLAttributes["data-border-width"];
5262
5315
  const verticalAlign = HTMLAttributes["data-vertical-align"];
5263
5316
  const textDirection = HTMLAttributes["data-text-direction"];
5317
+ const textWrap = HTMLAttributes["data-text-wrap"];
5264
5318
  let mergedStyle = style;
5265
5319
  if (bg) mergedStyle += `; background-color: ${bg}`;
5266
5320
  if (borderColor) mergedStyle += `; border-color: ${borderColor}`;
@@ -5268,10 +5322,11 @@ var CustomTableCell = TableCell.extend({
5268
5322
  if (borderWidth) mergedStyle += `; border-width: ${borderWidth}`;
5269
5323
  if (verticalAlign) mergedStyle += `; vertical-align: ${verticalAlign}`;
5270
5324
  if (textDirection === "vertical") mergedStyle += "; writing-mode: sideways-lr; text-orientation: mixed";
5325
+ mergedStyle += `; ${getTableCellTextWrapStyle(textWrap)}`;
5271
5326
  mergedStyle = mergedStyle.replace(/^;/, "").trim();
5272
5327
  return [
5273
5328
  "td",
5274
- mergeAttributes7(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
5329
+ mergeAttributes8(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
5275
5330
  0
5276
5331
  ];
5277
5332
  }
@@ -5376,6 +5431,11 @@ var CustomTableHeader = TableHeader.extend({
5376
5431
  default: null,
5377
5432
  parseHTML: (element) => element.getAttribute("data-text-direction") === "vertical" || ["sideways-lr", "vertical-lr", "vertical-rl"].includes(element.style.writingMode) ? "vertical" : null,
5378
5433
  renderHTML: (attributes) => attributes.textDirection === "vertical" ? { "data-text-direction": "vertical" } : {}
5434
+ },
5435
+ textWrap: {
5436
+ default: "wrap",
5437
+ parseHTML: parseTableCellTextWrap,
5438
+ renderHTML: renderTableCellTextWrap
5379
5439
  }
5380
5440
  };
5381
5441
  },
@@ -5387,6 +5447,7 @@ var CustomTableHeader = TableHeader.extend({
5387
5447
  const borderWidth = HTMLAttributes["data-border-width"];
5388
5448
  const verticalAlign = HTMLAttributes["data-vertical-align"];
5389
5449
  const textDirection = HTMLAttributes["data-text-direction"];
5450
+ const textWrap = HTMLAttributes["data-text-wrap"];
5390
5451
  let mergedStyle = style;
5391
5452
  if (bg) mergedStyle += `; background-color: ${bg}`;
5392
5453
  if (borderColor) mergedStyle += `; border-color: ${borderColor}`;
@@ -5394,10 +5455,11 @@ var CustomTableHeader = TableHeader.extend({
5394
5455
  if (borderWidth) mergedStyle += `; border-width: ${borderWidth}`;
5395
5456
  if (verticalAlign) mergedStyle += `; vertical-align: ${verticalAlign}`;
5396
5457
  if (textDirection === "vertical") mergedStyle += "; writing-mode: sideways-lr; text-orientation: mixed";
5458
+ mergedStyle += `; ${getTableCellTextWrapStyle(textWrap)}`;
5397
5459
  mergedStyle = mergedStyle.replace(/^;/, "").trim();
5398
5460
  return [
5399
5461
  "th",
5400
- mergeAttributes7(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
5462
+ mergeAttributes8(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
5401
5463
  0
5402
5464
  ];
5403
5465
  }
@@ -5559,7 +5621,8 @@ function buildUEditorExtensions({
5559
5621
  handleWidth: 10,
5560
5622
  allowTableNodeSelection: true,
5561
5623
  HTMLAttributes: {
5562
- class: "border-collapse my-4"
5624
+ class: "border-collapse my-4",
5625
+ style: "table-layout: fixed;"
5563
5626
  }
5564
5627
  }),
5565
5628
  table_row_default,
@@ -5642,7 +5705,8 @@ import {
5642
5705
  AlignCenterVertical,
5643
5706
  AlignEndVertical,
5644
5707
  ArrowDown,
5645
- ArrowRight
5708
+ ArrowRight,
5709
+ WrapText
5646
5710
  } from "lucide-react";
5647
5711
 
5648
5712
  // src/components/UEditor/table-border-commands.ts
@@ -5984,6 +6048,7 @@ var BubbleMenuContent = ({
5984
6048
  const [activeBorderPosition, setActiveBorderPosition] = useState5("all");
5985
6049
  const currentCellVerticalAlign = normalizeStyleValue(editor.getAttributes("tableCell").verticalAlign || editor.getAttributes("tableHeader").verticalAlign) || "";
5986
6050
  const currentCellTextDirection = normalizeStyleValue(editor.getAttributes("tableCell").textDirection || editor.getAttributes("tableHeader").textDirection) || "horizontal";
6051
+ const currentCellTextWrap = normalizeStyleValue(editor.getAttributes("tableCell").textWrap || editor.getAttributes("tableHeader").textWrap) || "wrap";
5987
6052
  const isInTable3 = isSelectionInTable(editor.state);
5988
6053
  const canMergeCells = isInTable3 && editor.can().mergeCells();
5989
6054
  const canSplitCell = isInTable3 && editor.can().splitCell();
@@ -6644,6 +6709,20 @@ var BubbleMenuContent = ({
6644
6709
  children: /* @__PURE__ */ jsx12(TableCellsMerge, { className: "w-4 h-4" })
6645
6710
  }
6646
6711
  ),
6712
+ /* @__PURE__ */ jsx12(
6713
+ ToolbarButton,
6714
+ {
6715
+ onClick: () => applyTableCellAttribute(
6716
+ editor,
6717
+ "textWrap",
6718
+ currentCellTextWrap === "nowrap" ? "wrap" : "nowrap",
6719
+ { focus: false }
6720
+ ),
6721
+ active: currentCellTextWrap !== "nowrap",
6722
+ title: currentCellTextWrap === "nowrap" ? t("tableMenu.wrapText") : t("tableMenu.noWrapText"),
6723
+ children: /* @__PURE__ */ jsx12(WrapText, { className: "h-4 w-4" })
6724
+ }
6725
+ ),
6647
6726
  /* @__PURE__ */ jsxs10(
6648
6727
  DropdownMenu,
6649
6728
  {
@@ -11457,6 +11536,22 @@ function buildLogicalRowMetrics({
11457
11536
  };
11458
11537
  });
11459
11538
  }
11539
+ function getTableCellTextSelectionRange(editor, cellPos) {
11540
+ const cellNode = editor.state.doc.nodeAt(cellPos);
11541
+ if (!cellNode || cellNode.type.name !== "tableCell" && cellNode.type.name !== "tableHeader") {
11542
+ return null;
11543
+ }
11544
+ let from = null;
11545
+ let to = null;
11546
+ cellNode.descendants((node, relativePos) => {
11547
+ if (!node.isText || node.nodeSize === 0) return true;
11548
+ const textStart = cellPos + 1 + relativePos;
11549
+ from ?? (from = textStart);
11550
+ to = textStart + node.nodeSize;
11551
+ return true;
11552
+ });
11553
+ return from !== null && to !== null && from < to ? { from, to } : null;
11554
+ }
11460
11555
  function buildTableControlLayout(editor, surface, cell) {
11461
11556
  const row = cell.closest("tr");
11462
11557
  const table = cell.closest("table");
@@ -11562,6 +11657,9 @@ function buildTableHoverState({
11562
11657
  layout,
11563
11658
  surface
11564
11659
  }) {
11660
+ if (event.buttons !== 0) {
11661
+ return DEFAULT_TABLE_HOVER_STATE;
11662
+ }
11565
11663
  const surfaceRect = surface.getBoundingClientRect();
11566
11664
  const relativeX = event.clientX - surfaceRect.left + surface.scrollLeft;
11567
11665
  const relativeY = event.clientY - surfaceRect.top + surface.scrollTop;
@@ -11571,8 +11669,8 @@ function buildTableHoverState({
11571
11669
  const directTableMenu = targetElement?.closest?.("[data-table-control='table-menu']");
11572
11670
  const directAddColumn = targetElement?.closest?.("[data-table-control='add-column']");
11573
11671
  const directAddRow = targetElement?.closest?.("[data-table-control='add-row']");
11574
- const directRowHandleIndex = directRowHandle instanceof HTMLElement ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
11575
- const directColumnHandleIndex = directColumnHandle instanceof HTMLElement ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
11672
+ const directRowHandleIndex = directRowHandle instanceof HTMLElement && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
11673
+ const directColumnHandleIndex = directColumnHandle instanceof HTMLElement && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
11576
11674
  const visibleBounds = getVisibleTableBounds(layout);
11577
11675
  const rowRailTop = layout.wrapperTop + layout.wrapperHeight;
11578
11676
  const isMouseInTable = relativeX >= layout.tableLeft && relativeX <= layout.tableLeft + layout.tableWidth && relativeY >= layout.tableTop && relativeY <= layout.tableTop + layout.tableHeight;
@@ -11883,7 +11981,8 @@ function TableRowHandles({
11883
11981
  "data-row-handle-index": rowHandle.index,
11884
11982
  style: {
11885
11983
  top: Math.max(8, rowHandle.center - 12),
11886
- left: rowHandleLeft
11984
+ left: rowHandleLeft,
11985
+ pointerEvents: visible ? "auto" : "none"
11887
11986
  },
11888
11987
  children: /* @__PURE__ */ jsx16(
11889
11988
  Tooltip,
@@ -11916,7 +12015,10 @@ function TableRowHandles({
11916
12015
  style: {
11917
12016
  opacity: isShown ? 1 : 0,
11918
12017
  transform: isShown ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`,
11919
- pointerEvents: isShown ? "auto" : "none"
12018
+ // The idle marker is only a location hint. Keeping it
12019
+ // pointer-transparent prevents it from stealing a text
12020
+ // selection near the first character of a table cell.
12021
+ pointerEvents: visible ? "auto" : "none"
11920
12022
  },
11921
12023
  children: visible ? /* @__PURE__ */ jsx16(GripVertical, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx16("div", { className: "h-3 w-1 rounded-full bg-muted-foreground/50 hover:bg-muted-foreground" })
11922
12024
  }
@@ -11954,7 +12056,8 @@ function TableColumnHandles({
11954
12056
  "data-column-handle-index": columnHandle.index,
11955
12057
  style: {
11956
12058
  top: columnHandleTop,
11957
- left: Math.max(8, columnHandle.center - 12)
12059
+ left: Math.max(8, columnHandle.center - 12),
12060
+ pointerEvents: visible ? "auto" : "none"
11958
12061
  },
11959
12062
  children: /* @__PURE__ */ jsx16(
11960
12063
  Tooltip,
@@ -11987,7 +12090,7 @@ function TableColumnHandles({
11987
12090
  style: {
11988
12091
  opacity: isShown ? 1 : 0,
11989
12092
  transform: isShown ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`,
11990
- pointerEvents: isShown ? "auto" : "none"
12093
+ pointerEvents: visible ? "auto" : "none"
11991
12094
  },
11992
12095
  children: visible ? /* @__PURE__ */ jsx16(GripHorizontal, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx16("div", { className: "h-1 w-3 rounded-full bg-muted-foreground/50 hover:bg-muted-foreground" })
11993
12096
  }
@@ -12233,6 +12336,7 @@ function applyTableSize(editor, snapshot, dimensions) {
12233
12336
  // src/components/UEditor/table-controls.tsx
12234
12337
  import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
12235
12338
  var TABLE_MENU_TOP_OFFSET = 10;
12339
+ var AXIS_HANDLE_RADIUS = 12;
12236
12340
  function nearestIndex(centers, position) {
12237
12341
  let bestIndex = 0;
12238
12342
  let bestDistance = Number.POSITIVE_INFINITY;
@@ -12410,6 +12514,20 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
12410
12514
  const surface2 = containerRef.current;
12411
12515
  const nextLayout = surface2 ? buildTableControlLayout(editor, surface2, cell) : null;
12412
12516
  if (!nextLayout) return;
12517
+ if (isPointOverRenderedText(cell, event.clientX, event.clientY)) {
12518
+ const textSelection = getTableCellTextSelectionRange(editor, nextLayout.cellPos);
12519
+ if (textSelection) {
12520
+ event.preventDefault();
12521
+ const didSelectText = editor.commands.setTextSelection(textSelection);
12522
+ if (didSelectText) {
12523
+ editor.view.focus();
12524
+ layoutRef.current = nextLayout;
12525
+ setLayout(nextLayout);
12526
+ setHoverState(DEFAULT_TABLE_HOVER_STATE);
12527
+ return;
12528
+ }
12529
+ }
12530
+ }
12413
12531
  const didSelect = editor.commands.setCellSelection({
12414
12532
  anchorCell: nextLayout.cellPos,
12415
12533
  headCell: nextLayout.cellPos
@@ -12876,8 +12994,8 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
12876
12994
  }
12877
12995
  const menuTop = Math.max(8, layout.tableTop - TABLE_MENU_TOP_OFFSET);
12878
12996
  const menuLeft = Math.max(8, layout.tableLeft);
12879
- const rowHandleLeft = layout.tableLeft - 12;
12880
- const columnHandleTop = layout.tableTop - 12;
12997
+ const rowHandleLeft = layout.tableLeft - AXIS_HANDLE_RADIUS;
12998
+ const columnHandleTop = layout.tableTop - AXIS_HANDLE_RADIUS;
12881
12999
  return /* @__PURE__ */ jsxs15(Fragment6, { children: [
12882
13000
  /* @__PURE__ */ jsx18(
12883
13001
  TableRowHandles,
@@ -14051,17 +14169,85 @@ function TableFormulaBar({ editor }) {
14051
14169
  );
14052
14170
  }
14053
14171
 
14172
+ // src/components/UEditor/use-editor-output.ts
14173
+ import * as React14 from "react";
14174
+ function normalizeDebounceMs(value) {
14175
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
14176
+ }
14177
+ function useUEditorOutput({
14178
+ onChange,
14179
+ onHtmlChange,
14180
+ onJsonChange,
14181
+ outputDebounceMs
14182
+ }) {
14183
+ const callbacksRef = React14.useRef({});
14184
+ const pendingEditorRef = React14.useRef(null);
14185
+ const timeoutRef = React14.useRef(null);
14186
+ const debounceMs = normalizeDebounceMs(outputDebounceMs);
14187
+ callbacksRef.current = { onChange, onHtmlChange, onJsonChange };
14188
+ const flushOutputUpdates = React14.useCallback(() => {
14189
+ if (timeoutRef.current !== null) {
14190
+ clearTimeout(timeoutRef.current);
14191
+ timeoutRef.current = null;
14192
+ }
14193
+ const editor = pendingEditorRef.current;
14194
+ pendingEditorRef.current = null;
14195
+ if (!editor || editor.isDestroyed) return;
14196
+ const callbacks = callbacksRef.current;
14197
+ if (callbacks.onChange || callbacks.onHtmlChange) {
14198
+ const html = editor.getHTML();
14199
+ callbacks.onChange?.(html);
14200
+ callbacks.onHtmlChange?.(html);
14201
+ }
14202
+ if (callbacks.onJsonChange) {
14203
+ callbacks.onJsonChange(editor.getJSON());
14204
+ }
14205
+ }, []);
14206
+ const scheduleOutputUpdate = React14.useCallback((editor) => {
14207
+ const callbacks = callbacksRef.current;
14208
+ if (!callbacks.onChange && !callbacks.onHtmlChange && !callbacks.onJsonChange) return;
14209
+ pendingEditorRef.current = editor;
14210
+ if (timeoutRef.current !== null) {
14211
+ clearTimeout(timeoutRef.current);
14212
+ timeoutRef.current = null;
14213
+ }
14214
+ if (debounceMs === 0) {
14215
+ flushOutputUpdates();
14216
+ return;
14217
+ }
14218
+ timeoutRef.current = setTimeout(flushOutputUpdates, debounceMs);
14219
+ }, [debounceMs, flushOutputUpdates]);
14220
+ React14.useEffect(() => {
14221
+ if (!pendingEditorRef.current || timeoutRef.current === null) return;
14222
+ clearTimeout(timeoutRef.current);
14223
+ timeoutRef.current = debounceMs === 0 ? null : setTimeout(flushOutputUpdates, debounceMs);
14224
+ if (debounceMs === 0) flushOutputUpdates();
14225
+ }, [debounceMs, flushOutputUpdates]);
14226
+ React14.useEffect(() => () => {
14227
+ if (timeoutRef.current !== null) {
14228
+ clearTimeout(timeoutRef.current);
14229
+ timeoutRef.current = null;
14230
+ }
14231
+ pendingEditorRef.current = null;
14232
+ }, []);
14233
+ return {
14234
+ flushOutputUpdates,
14235
+ scheduleOutputUpdate
14236
+ };
14237
+ }
14238
+
14054
14239
  // src/components/UEditor/UEditor.tsx
14055
14240
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
14056
- var LazyMenuBar = React14.lazy(async () => {
14057
- const { MenuBar } = await import("./menu-bar-6U5S4PS7.js");
14241
+ var LazyMenuBar = React15.lazy(async () => {
14242
+ const { MenuBar } = await import("./menu-bar-6GS5LLTD.js");
14058
14243
  return { default: MenuBar };
14059
14244
  });
14060
- var UEditor = React14.forwardRef(({
14245
+ var UEditor = React15.forwardRef(({
14061
14246
  content = "",
14062
14247
  onChange,
14063
14248
  onHtmlChange,
14064
14249
  onJsonChange,
14250
+ outputDebounceMs = 0,
14065
14251
  uploadImage,
14066
14252
  uploadImageForSave,
14067
14253
  uploadImageConcurrency = 3,
@@ -14099,15 +14285,21 @@ var UEditor = React14.forwardRef(({
14099
14285
  }, ref) => {
14100
14286
  const t = useSmartTranslations("UEditor");
14101
14287
  const effectivePlaceholder = placeholder ?? t("placeholder");
14102
- const inFlightPrepareRef = useRef9(null);
14103
- const lastAppliedContentRef = useRef9(content ?? "");
14104
- const scheduledFormulaRecalculateRef = useRef9(false);
14105
- const pendingFormulaTextRecalculateRef = useRef9(false);
14106
- const editorInstanceRef = useRef9(null);
14107
- const formulaRangePickRef = useRef9(null);
14108
- const formulaRangeSurfaceRef = useRef9(null);
14109
- const [formulaRangeHighlight, setFormulaRangeHighlight] = React14.useState(null);
14110
- const scheduleFormulaRecalculate = React14.useCallback((editor2, options) => {
14288
+ const inFlightPrepareRef = useRef10(null);
14289
+ const lastAppliedContentRef = useRef10(content ?? "");
14290
+ const scheduledFormulaRecalculateRef = useRef10(false);
14291
+ const pendingFormulaTextRecalculateRef = useRef10(false);
14292
+ const editorInstanceRef = useRef10(null);
14293
+ const formulaRangePickRef = useRef10(null);
14294
+ const formulaRangeSurfaceRef = useRef10(null);
14295
+ const [formulaRangeHighlight, setFormulaRangeHighlight] = React15.useState(null);
14296
+ const { flushOutputUpdates, scheduleOutputUpdate } = useUEditorOutput({
14297
+ onChange,
14298
+ onHtmlChange,
14299
+ onJsonChange,
14300
+ outputDebounceMs
14301
+ });
14302
+ const scheduleFormulaRecalculate = React15.useCallback((editor2, options) => {
14111
14303
  if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
14112
14304
  if (!options?.force && isEditingTableFormulaText(editor2)) return;
14113
14305
  scheduledFormulaRecalculateRef.current = true;
@@ -14147,7 +14339,7 @@ var UEditor = React14.forwardRef(({
14147
14339
  ],
14148
14340
  [effectivePlaceholder, t, maxCharacters, uploadImage, resolvedUploadFile, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, editable, fetchMetadata, extraExtensions]
14149
14341
  );
14150
- const syncFormulaRangeHighlight = React14.useCallback((pickState) => {
14342
+ const syncFormulaRangeHighlight = React15.useCallback((pickState) => {
14151
14343
  const container = formulaRangeSurfaceRef.current;
14152
14344
  setFormulaRangeHighlight(container && pickState ? getFormulaRangePickHighlight(container, pickState) : null);
14153
14345
  }, []);
@@ -14248,14 +14440,7 @@ var UEditor = React14.forwardRef(({
14248
14440
  pendingFormulaTextRecalculateRef.current = false;
14249
14441
  }
14250
14442
  }
14251
- if (onChange || onHtmlChange) {
14252
- const html = editor2.getHTML();
14253
- onChange?.(html);
14254
- onHtmlChange?.(html);
14255
- }
14256
- if (onJsonChange) {
14257
- onJsonChange(editor2.getJSON());
14258
- }
14443
+ scheduleOutputUpdate(editor2);
14259
14444
  },
14260
14445
  onSelectionUpdate: ({ editor: editor2 }) => {
14261
14446
  if (pendingFormulaTextRecalculateRef.current && !isEditingTableFormulaText(editor2)) {
@@ -14269,9 +14454,10 @@ var UEditor = React14.forwardRef(({
14269
14454
  const shouldRecalculate = pendingFormulaTextRecalculateRef.current;
14270
14455
  pendingFormulaTextRecalculateRef.current = false;
14271
14456
  if (shouldRecalculate) scheduleFormulaRecalculate(editor2, { force: true });
14457
+ queueMicrotask(flushOutputUpdates);
14272
14458
  }
14273
14459
  });
14274
- useEffect9(() => {
14460
+ useEffect10(() => {
14275
14461
  editorInstanceRef.current = editor;
14276
14462
  return () => {
14277
14463
  if (editorInstanceRef.current === editor) editorInstanceRef.current = null;
@@ -14312,7 +14498,7 @@ var UEditor = React14.forwardRef(({
14312
14498
  }),
14313
14499
  [content, editor, uploadImageForSave, uploadFileForSave, uploadImageConcurrency]
14314
14500
  );
14315
- useEffect9(() => {
14501
+ useEffect10(() => {
14316
14502
  if (!editor) return;
14317
14503
  queueMicrotask(() => {
14318
14504
  if (!editor.isDestroyed) {
@@ -14320,7 +14506,7 @@ var UEditor = React14.forwardRef(({
14320
14506
  }
14321
14507
  });
14322
14508
  }, [editor]);
14323
- useEffect9(() => {
14509
+ useEffect10(() => {
14324
14510
  if (!editor) return;
14325
14511
  const nextContent = content ?? "";
14326
14512
  if (lastAppliedContentRef.current === nextContent) return;
@@ -14365,7 +14551,7 @@ var UEditor = React14.forwardRef(({
14365
14551
  ),
14366
14552
  children: [
14367
14553
  editable && (showMenuBar || showToolbar || showBubbleMenu) ? /* @__PURE__ */ jsxs17(EditorUiRenderStateProvider, { editor, children: [
14368
- showMenuBar && /* @__PURE__ */ jsx20(React14.Suspense, { fallback: null, children: /* @__PURE__ */ jsx20(
14554
+ showMenuBar && /* @__PURE__ */ jsx20(React15.Suspense, { fallback: null, children: /* @__PURE__ */ jsx20(
14369
14555
  LazyMenuBar,
14370
14556
  {
14371
14557
  editor,
@@ -14503,4 +14689,4 @@ export {
14503
14689
  prepareUEditorContentForSave,
14504
14690
  UEditor_default
14505
14691
  };
14506
- //# sourceMappingURL=chunk-CC3QO2YM.js.map
14692
+ //# sourceMappingURL=chunk-4E43DRP2.js.map