@underverse-ui/underverse 2.0.12 → 2.0.13
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/api-reference.json +1 -1
- package/dist/{chunk-EVS5YWTO.js → chunk-MMMCBJ2L.js} +148 -77
- package/dist/{chunk-EVS5YWTO.js.map → chunk-MMMCBJ2L.js.map} +1 -1
- package/dist/{chunk-Q6BQUWKB.js → chunk-R7ZKNCWR.js} +2 -2
- package/dist/{chunk-P2RLTURA.js → chunk-WDY3QWOW.js} +192 -52
- package/dist/chunk-WDY3QWOW.js.map +1 -0
- package/dist/index.cjs +329 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{menu-bar-JSXW6AXW.js → menu-bar-SVX36W4S.js} +3 -3
- package/dist/ueditor.cjs +329 -121
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.d.cts +3 -0
- package/dist/ueditor.d.ts +3 -0
- package/dist/ueditor.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-P2RLTURA.js.map +0 -1
- /package/dist/{chunk-Q6BQUWKB.js.map → chunk-R7ZKNCWR.js.map} +0 -0
- /package/dist/{menu-bar-JSXW6AXW.js.map → menu-bar-SVX36W4S.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -5848,17 +5848,60 @@ function getSelectionTableCell(view) {
|
|
|
5848
5848
|
const cell = element?.closest?.("th,td");
|
|
5849
5849
|
return cell instanceof HTMLElement ? cell : null;
|
|
5850
5850
|
}
|
|
5851
|
-
function
|
|
5851
|
+
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
5852
5852
|
const rect = cell.getBoundingClientRect();
|
|
5853
|
-
const
|
|
5854
|
-
|
|
5855
|
-
|
|
5853
|
+
const row = cell.closest("tr");
|
|
5854
|
+
if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
|
|
5855
|
+
return null;
|
|
5856
|
+
}
|
|
5857
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
5858
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
5859
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
5860
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
5861
|
+
if (distToRight <= 3 || distToLeft <= 3) {
|
|
5862
|
+
return null;
|
|
5863
|
+
}
|
|
5864
|
+
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
5865
|
+
return { row, cell };
|
|
5866
|
+
}
|
|
5867
|
+
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
5868
|
+
const prevRow = row.previousElementSibling;
|
|
5869
|
+
if (prevRow instanceof HTMLTableRowElement) {
|
|
5870
|
+
const cellIndex = cell.cellIndex;
|
|
5871
|
+
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
5872
|
+
if (prevCell instanceof HTMLTableCellElement) {
|
|
5873
|
+
return { row: prevRow, cell: prevCell };
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
}
|
|
5877
|
+
return null;
|
|
5856
5878
|
}
|
|
5857
|
-
function
|
|
5879
|
+
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
5858
5880
|
const rect = cell.getBoundingClientRect();
|
|
5859
|
-
const
|
|
5860
|
-
|
|
5861
|
-
|
|
5881
|
+
const row = cell.closest("tr");
|
|
5882
|
+
if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
|
|
5883
|
+
return null;
|
|
5884
|
+
}
|
|
5885
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
5886
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
5887
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
5888
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
5889
|
+
if (distToBottom <= 3 || distToTop <= 3) {
|
|
5890
|
+
return null;
|
|
5891
|
+
}
|
|
5892
|
+
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
5893
|
+
return { row, cell };
|
|
5894
|
+
}
|
|
5895
|
+
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
5896
|
+
const prevCell = cell.previousElementSibling;
|
|
5897
|
+
if (prevCell instanceof HTMLTableCellElement) {
|
|
5898
|
+
return { row, cell: prevCell };
|
|
5899
|
+
}
|
|
5900
|
+
}
|
|
5901
|
+
return null;
|
|
5902
|
+
}
|
|
5903
|
+
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
5904
|
+
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
5862
5905
|
}
|
|
5863
5906
|
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
5864
5907
|
const surfaceRect = surface.getBoundingClientRect();
|
|
@@ -5910,7 +5953,7 @@ function getRelativeSelectedCellsMetrics(surface) {
|
|
|
5910
5953
|
height: bottom - top
|
|
5911
5954
|
};
|
|
5912
5955
|
}
|
|
5913
|
-
var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, TABLE_RESIZE_HIT_ZONE;
|
|
5956
|
+
var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, isRowResizingGlobal, TABLE_RESIZE_HIT_ZONE;
|
|
5914
5957
|
var init_table_dom_utils = __esm({
|
|
5915
5958
|
"src/components/UEditor/table-dom-utils.ts"() {
|
|
5916
5959
|
"use strict";
|
|
@@ -5918,8 +5961,9 @@ var init_table_dom_utils = __esm({
|
|
|
5918
5961
|
MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
5919
5962
|
COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
5920
5963
|
ROW_RESIZE_LINE_THICKNESS = 2;
|
|
5921
|
-
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor
|
|
5922
|
-
|
|
5964
|
+
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
5965
|
+
isRowResizingGlobal = { active: false };
|
|
5966
|
+
TABLE_RESIZE_HIT_ZONE = 5;
|
|
5923
5967
|
}
|
|
5924
5968
|
});
|
|
5925
5969
|
|
|
@@ -6629,6 +6673,18 @@ var init_colors = __esm({
|
|
|
6629
6673
|
const automaticColor = colors[0]?.color ?? "";
|
|
6630
6674
|
const paletteColors = colors.slice(1);
|
|
6631
6675
|
const customColorSelect = onCustomColorSelect ?? onSelect;
|
|
6676
|
+
const [hexInput, setHexInput] = import_react71.default.useState(currentColor.startsWith("#") ? currentColor : "");
|
|
6677
|
+
import_react71.default.useEffect(() => {
|
|
6678
|
+
setHexInput(currentColor.startsWith("#") ? currentColor : "");
|
|
6679
|
+
}, [currentColor]);
|
|
6680
|
+
const commitHex = (val) => {
|
|
6681
|
+
let formatted = val.trim();
|
|
6682
|
+
if (!formatted) return;
|
|
6683
|
+
if (!formatted.startsWith("#")) formatted = `#${formatted}`;
|
|
6684
|
+
if (/^#([0-9A-F]{3}){1,2}$/i.test(formatted)) {
|
|
6685
|
+
customColorSelect(formatted);
|
|
6686
|
+
}
|
|
6687
|
+
};
|
|
6632
6688
|
import_react71.default.useEffect(() => {
|
|
6633
6689
|
const input = colorInputRef.current;
|
|
6634
6690
|
if (!input) return;
|
|
@@ -6640,7 +6696,7 @@ var init_colors = __esm({
|
|
|
6640
6696
|
const input = colorInputRef.current;
|
|
6641
6697
|
if (input) input.value = currentColor.startsWith("#") ? currentColor : "#000000";
|
|
6642
6698
|
}, [currentColor]);
|
|
6643
|
-
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "w-56 p-2", children: [
|
|
6699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "w-56 p-2", "data-ueditor-keep-open": true, children: [
|
|
6644
6700
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
|
|
6645
6701
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
6646
6702
|
"button",
|
|
@@ -6674,29 +6730,48 @@ var init_colors = __esm({
|
|
|
6674
6730
|
children: currentColor === c.color && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_lucide_react50.Check, { className: cn("h-3.5 w-3.5", getSwatchCheckClass(c.color)) }) })
|
|
6675
6731
|
}
|
|
6676
6732
|
) }, `${c.name}-${c.color}`)) }),
|
|
6677
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
6678
|
-
"
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6733
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
|
|
6734
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "flex h-8 flex-1 items-center gap-1.5 rounded-md border border-input bg-muted/30 px-2", children: [
|
|
6735
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
6736
|
+
"span",
|
|
6737
|
+
{
|
|
6738
|
+
className: "h-4 w-4 shrink-0 rounded-[2px] border border-border",
|
|
6739
|
+
style: { backgroundColor: hexInput.startsWith("#") ? hexInput : currentColor.startsWith("#") ? currentColor : "transparent" }
|
|
6740
|
+
}
|
|
6741
|
+
),
|
|
6742
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
6743
|
+
"input",
|
|
6744
|
+
{
|
|
6745
|
+
type: "text",
|
|
6746
|
+
value: hexInput,
|
|
6747
|
+
onChange: (e) => setHexInput(e.target.value),
|
|
6748
|
+
onBlur: () => commitHex(hexInput),
|
|
6749
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
6750
|
+
onClick: (e) => e.stopPropagation(),
|
|
6751
|
+
onKeyDown: (e) => {
|
|
6752
|
+
e.stopPropagation();
|
|
6753
|
+
if (e.key === "Enter") {
|
|
6754
|
+
e.preventDefault();
|
|
6755
|
+
commitHex(hexInput);
|
|
6692
6756
|
}
|
|
6693
|
-
}
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
}
|
|
6699
|
-
|
|
6757
|
+
},
|
|
6758
|
+
placeholder: "#HEX",
|
|
6759
|
+
className: "h-full w-full bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground"
|
|
6760
|
+
}
|
|
6761
|
+
)
|
|
6762
|
+
] }),
|
|
6763
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
6764
|
+
"button",
|
|
6765
|
+
{
|
|
6766
|
+
type: "button",
|
|
6767
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
6768
|
+
onClick: () => colorInputRef.current?.click(),
|
|
6769
|
+
title: t("colors.moreColors"),
|
|
6770
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-input bg-muted/30 text-foreground transition-colors hover:bg-muted",
|
|
6771
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_lucide_react50.Palette, { className: "h-4 w-4 text-muted-foreground" })
|
|
6772
|
+
}
|
|
6773
|
+
)
|
|
6774
|
+
] }),
|
|
6700
6775
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
6701
6776
|
"input",
|
|
6702
6777
|
{
|
|
@@ -7270,7 +7345,7 @@ var init_toolbar = __esm({
|
|
|
7270
7345
|
return button;
|
|
7271
7346
|
});
|
|
7272
7347
|
ToolbarButton.displayName = "ToolbarButton";
|
|
7273
|
-
ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { "aria-hidden": "true", className: "mx-1
|
|
7348
|
+
ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { "aria-hidden": "true", className: "mx-1 h-5 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
|
|
7274
7349
|
TableInsertGrid = ({
|
|
7275
7350
|
insertLabel,
|
|
7276
7351
|
previewTemplate,
|
|
@@ -7315,6 +7390,7 @@ var init_toolbar = __esm({
|
|
|
7315
7390
|
maxImageFileSize = DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
|
|
7316
7391
|
allowedImageMimeTypes = DEFAULT_UEDITOR_IMAGE_MIME_TYPES,
|
|
7317
7392
|
fontFamilies,
|
|
7393
|
+
defaultFontFamily = "Inter",
|
|
7318
7394
|
fontSizes,
|
|
7319
7395
|
lineHeights,
|
|
7320
7396
|
letterSpacings
|
|
@@ -7357,9 +7433,9 @@ var init_toolbar = __esm({
|
|
|
7357
7433
|
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? "13";
|
|
7358
7434
|
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
7359
7435
|
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
7360
|
-
const
|
|
7361
|
-
const defaultFontFamilyValue =
|
|
7362
|
-
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel :
|
|
7436
|
+
const defaultFontFamilyOption = availableFontFamilies.find((opt) => normalizeStyleValue(opt.value) === normalizeStyleValue(defaultFontFamily)) ?? availableFontFamilies[0];
|
|
7437
|
+
const defaultFontFamilyValue = defaultFontFamilyOption?.value ?? defaultFontFamily ?? "Inter";
|
|
7438
|
+
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamilyOption?.label ?? defaultFontFamily ?? t("toolbar.fontDefault");
|
|
7363
7439
|
const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
|
|
7364
7440
|
const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
|
|
7365
7441
|
const activeFontSize = currentFontSize || "13px";
|
|
@@ -7491,7 +7567,7 @@ var init_toolbar = __esm({
|
|
|
7491
7567
|
"div",
|
|
7492
7568
|
{
|
|
7493
7569
|
role: "toolbar",
|
|
7494
|
-
className: "flex min-h-
|
|
7570
|
+
className: "flex min-h-9 flex-nowrap items-center gap-0.5 overflow-x-auto border-b border-[rgba(196,197,213,0.6)] bg-[#F4F4F4] px-1.5 py-1 dark:bg-muted/60",
|
|
7495
7571
|
children: [
|
|
7496
7572
|
isFull && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
7497
7573
|
DropdownMenu,
|
|
@@ -7502,9 +7578,9 @@ var init_toolbar = __esm({
|
|
|
7502
7578
|
onClick: () => {
|
|
7503
7579
|
},
|
|
7504
7580
|
title: t("toolbar.fontFamily"),
|
|
7505
|
-
className: "h-
|
|
7581
|
+
className: "h-7 w-40 max-w-40 justify-between gap-1.5 border border-[rgba(196,197,213,0.6)] bg-white px-2 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
|
|
7506
7582
|
children: [
|
|
7507
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "min-w-0 flex-1 truncate text-left text-
|
|
7583
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "min-w-0 flex-1 truncate text-left text-xs font-normal", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
|
|
7508
7584
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
|
|
7509
7585
|
]
|
|
7510
7586
|
}
|
|
@@ -7531,9 +7607,9 @@ var init_toolbar = __esm({
|
|
|
7531
7607
|
onClick: () => {
|
|
7532
7608
|
},
|
|
7533
7609
|
title: t("toolbar.fontSize"),
|
|
7534
|
-
className: "h-
|
|
7610
|
+
className: "h-7 w-14 justify-between gap-1 border border-[rgba(196,197,213,0.6)] bg-white px-2 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
|
|
7535
7611
|
children: [
|
|
7536
|
-
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "text-
|
|
7612
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("span", { className: "text-xs font-normal leading-none", children: displayedFontSizeLabel }),
|
|
7537
7613
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
|
|
7538
7614
|
]
|
|
7539
7615
|
}
|
|
@@ -7658,6 +7734,27 @@ var init_toolbar = __esm({
|
|
|
7658
7734
|
)
|
|
7659
7735
|
] }),
|
|
7660
7736
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarDivider, {}),
|
|
7737
|
+
(isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
7738
|
+
DropdownMenu,
|
|
7739
|
+
{
|
|
7740
|
+
isOpen: isTableMenuOpen,
|
|
7741
|
+
onOpenChange: setIsTableMenuOpen,
|
|
7742
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
|
|
7743
|
+
}, title: t("toolbar.table"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTableIcon, { className: "h-4 w-4" }) }),
|
|
7744
|
+
contentClassName: "p-2 min-w-56",
|
|
7745
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
7746
|
+
TableInsertGrid,
|
|
7747
|
+
{
|
|
7748
|
+
insertLabel: t("tableMenu.insertTable"),
|
|
7749
|
+
previewTemplate: t("tableMenu.gridPreview"),
|
|
7750
|
+
onInsert: (rows, cols) => {
|
|
7751
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
7752
|
+
setIsTableMenuOpen(false);
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7755
|
+
)
|
|
7756
|
+
}
|
|
7757
|
+
),
|
|
7661
7758
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaBoldIcon, { className: "h-4 w-4" }) }),
|
|
7662
7759
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaItalicIcon, { className: "h-4 w-4" }) }),
|
|
7663
7760
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
@@ -8128,27 +8225,6 @@ var init_toolbar = __esm({
|
|
|
8128
8225
|
] })
|
|
8129
8226
|
}
|
|
8130
8227
|
),
|
|
8131
|
-
(isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
8132
|
-
DropdownMenu,
|
|
8133
|
-
{
|
|
8134
|
-
isOpen: isTableMenuOpen,
|
|
8135
|
-
onOpenChange: setIsTableMenuOpen,
|
|
8136
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => {
|
|
8137
|
-
}, title: t("toolbar.table"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaTableIcon, { className: "h-4 w-4" }) }),
|
|
8138
|
-
contentClassName: "p-2 min-w-56",
|
|
8139
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
|
|
8140
|
-
TableInsertGrid,
|
|
8141
|
-
{
|
|
8142
|
-
insertLabel: t("tableMenu.insertTable"),
|
|
8143
|
-
previewTemplate: t("tableMenu.gridPreview"),
|
|
8144
|
-
onInsert: (rows, cols) => {
|
|
8145
|
-
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
8146
|
-
setIsTableMenuOpen(false);
|
|
8147
|
-
}
|
|
8148
|
-
}
|
|
8149
|
-
)
|
|
8150
|
-
}
|
|
8151
|
-
),
|
|
8152
8228
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarDivider, {}),
|
|
8153
8229
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().undo().run(), disabled: !editor.can().undo(), title: t("toolbar.undo"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaUndoIcon, { className: "h-4 w-4" }) }),
|
|
8154
8230
|
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().redo().run(), disabled: !editor.can().redo(), title: t("toolbar.redo"), children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(FigmaRedoIcon, { className: "h-4 w-4" }) }),
|
|
@@ -8347,7 +8423,7 @@ var init_editor_styles = __esm({
|
|
|
8347
8423
|
"[&_.selectedCell]:after:absolute",
|
|
8348
8424
|
"[&_.selectedCell]:after:inset-0",
|
|
8349
8425
|
"[&_.selectedCell]:after:z-[2]",
|
|
8350
|
-
"[&_.selectedCell]:after:bg-primary/
|
|
8426
|
+
"[&_.selectedCell]:after:bg-primary/8",
|
|
8351
8427
|
"[&_.selectedCell]:after:pointer-events-none",
|
|
8352
8428
|
"[&_.column-resize-handle]:pointer-events-auto",
|
|
8353
8429
|
"[&_.column-resize-handle]:cursor-col-resize",
|
|
@@ -8361,17 +8437,10 @@ var init_editor_styles = __esm({
|
|
|
8361
8437
|
"[&_.column-resize-handle]:rounded-none",
|
|
8362
8438
|
"[&_.column-resize-handle]:opacity-0",
|
|
8363
8439
|
"[&_.column-resize-handle]:transition-opacity",
|
|
8364
|
-
"[&_.column-resize-handle]:
|
|
8365
|
-
"[&_.column-resize-handle]:
|
|
8366
|
-
"[&_.column-resize-handle]:
|
|
8367
|
-
"[&_.column-resize-handle]:after:
|
|
8368
|
-
"[&_.column-resize-handle]:after:w-0.5",
|
|
8369
|
-
"[&_.column-resize-handle]:after:-translate-x-1/2",
|
|
8370
|
-
"[&_.column-resize-handle]:after:rounded-full",
|
|
8371
|
-
"[&_.column-resize-handle]:after:bg-primary/75",
|
|
8372
|
-
"[&_.column-resize-handle]:after:content-['']",
|
|
8373
|
-
"[&.resize-cursor_.column-resize-handle]:opacity-100",
|
|
8374
|
-
"[&.resize-cursor_.column-resize-handle]:after:bg-primary",
|
|
8440
|
+
"[&_.column-resize-handle]:duration-200",
|
|
8441
|
+
"[&_.column-resize-handle]:delay-100",
|
|
8442
|
+
"[&_.column-resize-handle]:ease-out",
|
|
8443
|
+
"[&_.column-resize-handle]:after:hidden",
|
|
8375
8444
|
"[&_.column-resize-dragging]:min-w-0",
|
|
8376
8445
|
"[&.resize-cursor]:cursor-col-resize",
|
|
8377
8446
|
"[&.resize-row-cursor]:cursor-row-resize",
|
|
@@ -36474,6 +36543,15 @@ function edgeCell(view, event, side, handleWidth) {
|
|
|
36474
36543
|
const index = map.map.indexOf($cell.pos - start);
|
|
36475
36544
|
return index % map.width === 0 ? -1 : start + map.map[index - 1];
|
|
36476
36545
|
}
|
|
36546
|
+
var handleHoverTimer = null;
|
|
36547
|
+
var pendingHandleCell = -1;
|
|
36548
|
+
function clearHandleHoverTimer() {
|
|
36549
|
+
if (handleHoverTimer !== null) {
|
|
36550
|
+
window.clearTimeout(handleHoverTimer);
|
|
36551
|
+
handleHoverTimer = null;
|
|
36552
|
+
}
|
|
36553
|
+
pendingHandleCell = -1;
|
|
36554
|
+
}
|
|
36477
36555
|
function updateHandle(view, value) {
|
|
36478
36556
|
view.dispatch(view.state.tr.setMeta(import_tables2.columnResizingPluginKey, { setHandle: value }));
|
|
36479
36557
|
}
|
|
@@ -36488,19 +36566,43 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
36488
36566
|
if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
36489
36567
|
else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
36490
36568
|
}
|
|
36491
|
-
if (cell === pluginState.activeHandle)
|
|
36492
|
-
|
|
36569
|
+
if (cell === pluginState.activeHandle) {
|
|
36570
|
+
clearHandleHoverTimer();
|
|
36571
|
+
return;
|
|
36572
|
+
}
|
|
36573
|
+
if (cell === -1) {
|
|
36574
|
+
clearHandleHoverTimer();
|
|
36575
|
+
if (pluginState.activeHandle !== -1) {
|
|
36576
|
+
updateHandle(view, -1);
|
|
36577
|
+
}
|
|
36578
|
+
return;
|
|
36579
|
+
}
|
|
36580
|
+
if (!lastColumnResizable) {
|
|
36493
36581
|
const $cell = view.state.doc.resolve(cell);
|
|
36494
36582
|
const table = $cell.node(-1);
|
|
36495
36583
|
const map = import_tables2.TableMap.get(table);
|
|
36496
36584
|
const tableStart = $cell.start(-1);
|
|
36497
36585
|
const nodeAfter = $cell.nodeAfter;
|
|
36498
36586
|
if (!nodeAfter) return;
|
|
36499
|
-
if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1)
|
|
36587
|
+
if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1) {
|
|
36588
|
+
clearHandleHoverTimer();
|
|
36589
|
+
if (pluginState.activeHandle !== -1) {
|
|
36590
|
+
updateHandle(view, -1);
|
|
36591
|
+
}
|
|
36592
|
+
return;
|
|
36593
|
+
}
|
|
36500
36594
|
}
|
|
36501
|
-
|
|
36595
|
+
if (pendingHandleCell === cell) return;
|
|
36596
|
+
clearHandleHoverTimer();
|
|
36597
|
+
pendingHandleCell = cell;
|
|
36598
|
+
handleHoverTimer = window.setTimeout(() => {
|
|
36599
|
+
handleHoverTimer = null;
|
|
36600
|
+
pendingHandleCell = -1;
|
|
36601
|
+
updateHandle(view, cell);
|
|
36602
|
+
}, 100);
|
|
36502
36603
|
}
|
|
36503
36604
|
function handleMouseLeave(view) {
|
|
36605
|
+
clearHandleHoverTimer();
|
|
36504
36606
|
if (!view.editable) return;
|
|
36505
36607
|
const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
|
|
36506
36608
|
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
@@ -36549,7 +36651,7 @@ function getColumnResizeGhost(view) {
|
|
|
36549
36651
|
ghost.style.pointerEvents = "none";
|
|
36550
36652
|
ghost.style.width = "2px";
|
|
36551
36653
|
ghost.style.backgroundColor = "var(--primary, #2563eb)";
|
|
36552
|
-
ghost.style.opacity = "
|
|
36654
|
+
ghost.style.opacity = "0.5";
|
|
36553
36655
|
ghost.style.borderRadius = "9999px";
|
|
36554
36656
|
ghost.style.boxShadow = "0 0 0 1px color-mix(in oklch, var(--background, #fff) 80%, transparent)";
|
|
36555
36657
|
ghost.style.transform = "translateX(-1px)";
|
|
@@ -36578,6 +36680,7 @@ function showColumnResizeGhost(view, cell, dragging, width) {
|
|
|
36578
36680
|
ghost.style.height = `${rect.height}px`;
|
|
36579
36681
|
}
|
|
36580
36682
|
function handleMouseDown(view, event, cellMinWidth) {
|
|
36683
|
+
clearHandleHoverTimer();
|
|
36581
36684
|
if (!view.editable) return false;
|
|
36582
36685
|
const win = view.dom.ownerDocument.defaultView ?? window;
|
|
36583
36686
|
const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
|
|
@@ -36699,6 +36802,7 @@ function dynamicColumnResizing({
|
|
|
36699
36802
|
|
|
36700
36803
|
// src/components/UEditor/table-align.ts
|
|
36701
36804
|
init_table_align_utils();
|
|
36805
|
+
init_table_dom_utils();
|
|
36702
36806
|
function normalizeTableAlign(value) {
|
|
36703
36807
|
if (value === "left" || value === "center" || value === "right") {
|
|
36704
36808
|
return value;
|
|
@@ -36825,6 +36929,38 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
36825
36929
|
lastColumnResizable: this.options.lastColumnResizable
|
|
36826
36930
|
})
|
|
36827
36931
|
] : [],
|
|
36932
|
+
new import_state7.Plugin({
|
|
36933
|
+
key: new import_state7.PluginKey("tableRowResizeInterceptor"),
|
|
36934
|
+
props: {
|
|
36935
|
+
handleDOMEvents: {
|
|
36936
|
+
mousedown(view, event) {
|
|
36937
|
+
if (event.button !== 0) return false;
|
|
36938
|
+
const target = resolveEventElement(event.target);
|
|
36939
|
+
const cell = target?.closest("th,td");
|
|
36940
|
+
if (cell instanceof HTMLElement && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
36941
|
+
isRowResizingGlobal.active = true;
|
|
36942
|
+
return true;
|
|
36943
|
+
}
|
|
36944
|
+
return false;
|
|
36945
|
+
},
|
|
36946
|
+
mousemove(_view, event) {
|
|
36947
|
+
if (isRowResizingGlobal.active) {
|
|
36948
|
+
if (event.buttons === 0) {
|
|
36949
|
+
isRowResizingGlobal.active = false;
|
|
36950
|
+
return false;
|
|
36951
|
+
}
|
|
36952
|
+
event.preventDefault();
|
|
36953
|
+
return true;
|
|
36954
|
+
}
|
|
36955
|
+
return false;
|
|
36956
|
+
},
|
|
36957
|
+
mouseup() {
|
|
36958
|
+
isRowResizingGlobal.active = false;
|
|
36959
|
+
return false;
|
|
36960
|
+
}
|
|
36961
|
+
}
|
|
36962
|
+
}
|
|
36963
|
+
}),
|
|
36828
36964
|
(0, import_tables3.tableEditing)({
|
|
36829
36965
|
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
36830
36966
|
}),
|
|
@@ -39984,7 +40120,11 @@ var CustomBubbleMenu = ({
|
|
|
39984
40120
|
setIsVisible(false);
|
|
39985
40121
|
return;
|
|
39986
40122
|
}
|
|
39987
|
-
|
|
40123
|
+
const isInputFocused = () => {
|
|
40124
|
+
const active = document.activeElement;
|
|
40125
|
+
return Boolean(active && (menuRef.current?.contains(active) || active.closest?.("[data-ueditor-keep-open]")));
|
|
40126
|
+
};
|
|
40127
|
+
if (!keepOpenRef.current && !isInputFocused() && (context2 === "none" || !view.hasFocus())) {
|
|
39988
40128
|
clearShowTimeout();
|
|
39989
40129
|
setIsVisible(false);
|
|
39990
40130
|
return;
|
|
@@ -40025,7 +40165,8 @@ var CustomBubbleMenu = ({
|
|
|
40025
40165
|
}, SHOW_DELAY_MS);
|
|
40026
40166
|
};
|
|
40027
40167
|
const handleBlur = () => {
|
|
40028
|
-
|
|
40168
|
+
const isInputFocused = Boolean(document.activeElement && (menuRef.current?.contains(document.activeElement) || document.activeElement.closest?.("[data-ueditor-keep-open]")));
|
|
40169
|
+
if (!keepOpenRef.current && !isInputFocused) {
|
|
40029
40170
|
clearShowTimeout();
|
|
40030
40171
|
setIsVisible(false);
|
|
40031
40172
|
}
|
|
@@ -40119,6 +40260,9 @@ var CustomBubbleMenu = ({
|
|
|
40119
40260
|
} else if (target?.closest?.("[data-ueditor-keep-open]")) {
|
|
40120
40261
|
setKeepOpen(true);
|
|
40121
40262
|
}
|
|
40263
|
+
if (target && target.closest("input, textarea, select")) {
|
|
40264
|
+
return;
|
|
40265
|
+
}
|
|
40122
40266
|
e.preventDefault();
|
|
40123
40267
|
},
|
|
40124
40268
|
children: context === "link" && !keepOpen && !linkInputOpen ? /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
@@ -43692,7 +43836,7 @@ function createKey(name) {
|
|
|
43692
43836
|
keys[name] = 0;
|
|
43693
43837
|
return name + "$";
|
|
43694
43838
|
}
|
|
43695
|
-
var
|
|
43839
|
+
var PluginKey7 = class {
|
|
43696
43840
|
/**
|
|
43697
43841
|
Create a plugin key.
|
|
43698
43842
|
*/
|
|
@@ -44124,7 +44268,7 @@ function tableNodeTypes2(schema) {
|
|
|
44124
44268
|
}
|
|
44125
44269
|
return result;
|
|
44126
44270
|
}
|
|
44127
|
-
var tableEditingKey = new
|
|
44271
|
+
var tableEditingKey = new PluginKey7("selectingCells");
|
|
44128
44272
|
function cellAround2($pos) {
|
|
44129
44273
|
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));
|
|
44130
44274
|
return null;
|
|
@@ -44355,7 +44499,7 @@ var CellBookmark = class CellBookmark2 {
|
|
|
44355
44499
|
else return Selection.near($headCell, 1);
|
|
44356
44500
|
}
|
|
44357
44501
|
};
|
|
44358
|
-
var fixTablesKey = new
|
|
44502
|
+
var fixTablesKey = new PluginKey7("fix-tables");
|
|
44359
44503
|
function convertTableNodeToArrayOfRows(tableNode) {
|
|
44360
44504
|
const map = TableMap4.get(tableNode);
|
|
44361
44505
|
const rows = [];
|
|
@@ -44833,7 +44977,7 @@ function atEndOfCell(view, axis, dir) {
|
|
|
44833
44977
|
}
|
|
44834
44978
|
return null;
|
|
44835
44979
|
}
|
|
44836
|
-
var columnResizingPluginKey2 = new
|
|
44980
|
+
var columnResizingPluginKey2 = new PluginKey7("tableColumnResizing");
|
|
44837
44981
|
|
|
44838
44982
|
// src/components/UEditor/table-controls.tsx
|
|
44839
44983
|
var import_lucide_react57 = require("lucide-react");
|
|
@@ -45282,6 +45426,8 @@ init_Tooltip();
|
|
|
45282
45426
|
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
45283
45427
|
var ADD_COLUMN_RAIL_GAP = 4;
|
|
45284
45428
|
var ADD_ROW_RAIL_GAP = 4;
|
|
45429
|
+
var BUTTON_LONG_SIZE = 36;
|
|
45430
|
+
var BUTTON_SHORT_SIZE = 14;
|
|
45285
45431
|
function TableAddRails({
|
|
45286
45432
|
addColumnVisible,
|
|
45287
45433
|
addRowVisible,
|
|
@@ -45294,10 +45440,10 @@ function TableAddRails({
|
|
|
45294
45440
|
quickAddRowLabel
|
|
45295
45441
|
}) {
|
|
45296
45442
|
const visibleBounds = getVisibleTableBounds(layout);
|
|
45297
|
-
const columnRailTop = visibleBounds.top;
|
|
45443
|
+
const columnRailTop = visibleBounds.top + Math.max(0, (visibleBounds.height - BUTTON_LONG_SIZE) / 2);
|
|
45298
45444
|
const columnRailLeft = visibleBounds.right + ADD_COLUMN_RAIL_GAP;
|
|
45299
45445
|
const rowRailTop = layout.wrapperTop + layout.wrapperHeight + ADD_ROW_RAIL_GAP;
|
|
45300
|
-
const rowRailLeft = visibleBounds.left;
|
|
45446
|
+
const rowRailLeft = visibleBounds.left + Math.max(0, (visibleBounds.width - BUTTON_LONG_SIZE) / 2);
|
|
45301
45447
|
const showColumnRail = controlsVisible || addColumnVisible;
|
|
45302
45448
|
const showRowRail = controlsVisible || addRowVisible;
|
|
45303
45449
|
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_jsx_runtime97.Fragment, { children: [
|
|
@@ -45322,15 +45468,15 @@ function TableAddRails({
|
|
|
45322
45468
|
className: cn(
|
|
45323
45469
|
"absolute z-30 inline-flex items-center justify-center rounded-md",
|
|
45324
45470
|
"border border-border/70 bg-muted/40 text-muted-foreground shadow-sm backdrop-blur",
|
|
45325
|
-
"transition-[opacity,transform,colors] duration-
|
|
45471
|
+
"transition-[opacity,transform,colors] duration-200 delay-100 ease-out cursor-pointer hover:bg-accent hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed"
|
|
45326
45472
|
),
|
|
45327
45473
|
style: {
|
|
45328
|
-
top:
|
|
45474
|
+
top: columnRailTop,
|
|
45329
45475
|
left: columnRailLeft,
|
|
45330
|
-
width:
|
|
45331
|
-
height:
|
|
45476
|
+
width: BUTTON_SHORT_SIZE,
|
|
45477
|
+
height: BUTTON_LONG_SIZE,
|
|
45332
45478
|
opacity: showColumnRail ? 1 : 0,
|
|
45333
|
-
transform: showColumnRail ? "scale(1)" : "scale(0.
|
|
45479
|
+
transform: showColumnRail ? "scale(1)" : "scale(0.85)",
|
|
45334
45480
|
pointerEvents: showColumnRail ? "auto" : "none"
|
|
45335
45481
|
},
|
|
45336
45482
|
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
@@ -45359,15 +45505,15 @@ function TableAddRails({
|
|
|
45359
45505
|
className: cn(
|
|
45360
45506
|
"absolute z-30 inline-flex items-center justify-center rounded-md",
|
|
45361
45507
|
"border border-border/70 bg-muted/40 text-muted-foreground shadow-sm backdrop-blur",
|
|
45362
|
-
"transition-[opacity,transform,colors] duration-
|
|
45508
|
+
"transition-[opacity,transform,colors] duration-200 delay-100 ease-out cursor-pointer hover:bg-accent hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed"
|
|
45363
45509
|
),
|
|
45364
45510
|
style: {
|
|
45365
45511
|
top: rowRailTop,
|
|
45366
|
-
left:
|
|
45367
|
-
width:
|
|
45368
|
-
height:
|
|
45512
|
+
left: rowRailLeft,
|
|
45513
|
+
width: BUTTON_LONG_SIZE,
|
|
45514
|
+
height: BUTTON_SHORT_SIZE,
|
|
45369
45515
|
opacity: showRowRail ? 1 : 0,
|
|
45370
|
-
transform: showRowRail ? "scale(1)" : "scale(0.
|
|
45516
|
+
transform: showRowRail ? "scale(1)" : "scale(0.85)",
|
|
45371
45517
|
pointerEvents: showRowRail ? "auto" : "none"
|
|
45372
45518
|
},
|
|
45373
45519
|
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
@@ -45504,7 +45650,7 @@ function TableRowHandles({
|
|
|
45504
45650
|
onStartDrag(rowHandle);
|
|
45505
45651
|
},
|
|
45506
45652
|
className: cn(
|
|
45507
|
-
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-
|
|
45653
|
+
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-200 delay-100 ease-out",
|
|
45508
45654
|
visible ? "border border-border/70 bg-background/95 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-foreground cursor-grab active:cursor-grabbing" : "border-transparent bg-transparent cursor-pointer"
|
|
45509
45655
|
),
|
|
45510
45656
|
style: {
|
|
@@ -45579,7 +45725,7 @@ function TableColumnHandles({
|
|
|
45579
45725
|
onStartDrag(columnHandle);
|
|
45580
45726
|
},
|
|
45581
45727
|
className: cn(
|
|
45582
|
-
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-
|
|
45728
|
+
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-200 delay-100 ease-out",
|
|
45583
45729
|
visible ? "border border-border/70 bg-background/95 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-foreground cursor-grab active:cursor-grabbing" : "border-transparent bg-transparent cursor-pointer"
|
|
45584
45730
|
),
|
|
45585
45731
|
style: {
|
|
@@ -45968,7 +46114,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
45968
46114
|
const updateHoverState = import_react77.default.useCallback((event) => {
|
|
45969
46115
|
const activeLayout = layoutRef.current;
|
|
45970
46116
|
const surface = containerRef.current;
|
|
45971
|
-
if (!activeLayout || !surface || dragStateRef.current) {
|
|
46117
|
+
if (!activeLayout || !surface || dragStateRef.current || event.buttons !== 0) {
|
|
45972
46118
|
setHoverState(DEFAULT_TABLE_HOVER_STATE);
|
|
45973
46119
|
return;
|
|
45974
46120
|
}
|
|
@@ -46102,7 +46248,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
46102
46248
|
return result;
|
|
46103
46249
|
}, [editor, scheduleSyncFromSelection]);
|
|
46104
46250
|
const canExpandTable = Boolean(layout);
|
|
46105
|
-
const controlsVisible =
|
|
46251
|
+
const controlsVisible = false;
|
|
46106
46252
|
const tableMenuOpen = openMenuKey === "table";
|
|
46107
46253
|
const startTableResize = import_react77.default.useCallback((event) => {
|
|
46108
46254
|
if (event.button !== 0 || dragStateRef.current) return;
|
|
@@ -46629,6 +46775,9 @@ function useTableRowResize({
|
|
|
46629
46775
|
pendingHeight: startHeight
|
|
46630
46776
|
};
|
|
46631
46777
|
showRowGuide(table, row, cell, startHeight);
|
|
46778
|
+
isRowResizingGlobal.active = true;
|
|
46779
|
+
window.getSelection()?.removeAllRanges();
|
|
46780
|
+
document.body.style.userSelect = "none";
|
|
46632
46781
|
document.body.style.cursor = "row-resize";
|
|
46633
46782
|
event.preventDefault();
|
|
46634
46783
|
event.stopPropagation();
|
|
@@ -46670,6 +46819,8 @@ function useTableRowResize({
|
|
|
46670
46819
|
editor.view.dispatch(tr);
|
|
46671
46820
|
}
|
|
46672
46821
|
stateRef.current = null;
|
|
46822
|
+
isRowResizingGlobal.active = false;
|
|
46823
|
+
document.body.style.userSelect = "";
|
|
46673
46824
|
document.body.style.cursor = "";
|
|
46674
46825
|
clearHoveredTableCell();
|
|
46675
46826
|
clearAllTableResizeHover();
|
|
@@ -46678,6 +46829,8 @@ function useTableRowResize({
|
|
|
46678
46829
|
const cancelResize = import_react78.default.useCallback(() => {
|
|
46679
46830
|
if (!stateRef.current) return;
|
|
46680
46831
|
stateRef.current = null;
|
|
46832
|
+
isRowResizingGlobal.active = false;
|
|
46833
|
+
document.body.style.userSelect = "";
|
|
46681
46834
|
document.body.style.cursor = "";
|
|
46682
46835
|
clearHoveredTableCell();
|
|
46683
46836
|
clearAllTableResizeHover();
|
|
@@ -46685,6 +46838,8 @@ function useTableRowResize({
|
|
|
46685
46838
|
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
46686
46839
|
const cleanup = import_react78.default.useCallback(() => {
|
|
46687
46840
|
stateRef.current = null;
|
|
46841
|
+
isRowResizingGlobal.active = false;
|
|
46842
|
+
document.body.style.userSelect = "";
|
|
46688
46843
|
document.body.style.cursor = "";
|
|
46689
46844
|
}, []);
|
|
46690
46845
|
return {
|
|
@@ -46733,11 +46888,21 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
46733
46888
|
guide.style.opacity = "0";
|
|
46734
46889
|
}
|
|
46735
46890
|
}, [getProseMirrorElement]);
|
|
46891
|
+
const hotspotTimerRef = (0, import_react79.useRef)(null);
|
|
46892
|
+
const activeHotspotKeyRef = (0, import_react79.useRef)(null);
|
|
46893
|
+
const clearHotspotTimer = import_react79.default.useCallback(() => {
|
|
46894
|
+
if (hotspotTimerRef.current !== null) {
|
|
46895
|
+
window.clearTimeout(hotspotTimerRef.current);
|
|
46896
|
+
hotspotTimerRef.current = null;
|
|
46897
|
+
}
|
|
46898
|
+
}, []);
|
|
46736
46899
|
const clearAllTableResizeHover = import_react79.default.useCallback(() => {
|
|
46900
|
+
clearHotspotTimer();
|
|
46901
|
+
activeHotspotKeyRef.current = null;
|
|
46737
46902
|
setEditorResizeCursor("");
|
|
46738
46903
|
hideColumnGuide();
|
|
46739
46904
|
hideRowGuide();
|
|
46740
|
-
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
46905
|
+
}, [clearHotspotTimer, hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
46741
46906
|
const updateActiveCellHighlight = import_react79.default.useCallback((cell) => {
|
|
46742
46907
|
const surface = editorContentRef.current;
|
|
46743
46908
|
const highlight = activeTableCellHighlightRef.current;
|
|
@@ -46876,6 +47041,10 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
46876
47041
|
if (syncActiveRowResizeGuide()) {
|
|
46877
47042
|
return;
|
|
46878
47043
|
}
|
|
47044
|
+
if (event.buttons !== 0) {
|
|
47045
|
+
clearAllTableResizeHover();
|
|
47046
|
+
return;
|
|
47047
|
+
}
|
|
46879
47048
|
const target = resolveEventElement(event.target);
|
|
46880
47049
|
if (!(target instanceof Element)) {
|
|
46881
47050
|
clearAllTableResizeHover();
|
|
@@ -46895,18 +47064,46 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
46895
47064
|
clearAllTableResizeHover();
|
|
46896
47065
|
return;
|
|
46897
47066
|
}
|
|
46898
|
-
const
|
|
46899
|
-
const
|
|
46900
|
-
if (
|
|
46901
|
-
|
|
46902
|
-
|
|
47067
|
+
const rowTarget = resolveRowResizeTarget(cell, event.clientX, event.clientY);
|
|
47068
|
+
const colTarget = resolveColumnResizeTarget(cell, event.clientX, event.clientY);
|
|
47069
|
+
if (rowTarget) {
|
|
47070
|
+
const hotspotKey = `row:${rowTarget.row.rowIndex}-${rowTarget.cell.cellIndex}`;
|
|
47071
|
+
if (activeHotspotKeyRef.current === hotspotKey) {
|
|
47072
|
+
hideColumnGuide();
|
|
47073
|
+
showRowGuide(table, rowTarget.row, rowTarget.cell);
|
|
47074
|
+
return;
|
|
47075
|
+
}
|
|
47076
|
+
if (activeHotspotKeyRef.current !== hotspotKey) {
|
|
47077
|
+
clearHotspotTimer();
|
|
47078
|
+
activeHotspotKeyRef.current = hotspotKey;
|
|
47079
|
+
hotspotTimerRef.current = window.setTimeout(() => {
|
|
47080
|
+
hotspotTimerRef.current = null;
|
|
47081
|
+
hideColumnGuide();
|
|
47082
|
+
showRowGuide(table, rowTarget.row, rowTarget.cell);
|
|
47083
|
+
}, 100);
|
|
47084
|
+
}
|
|
46903
47085
|
return;
|
|
46904
47086
|
}
|
|
46905
|
-
if (
|
|
46906
|
-
|
|
46907
|
-
|
|
47087
|
+
if (colTarget) {
|
|
47088
|
+
const hotspotKey = `col:${colTarget.row.rowIndex}-${colTarget.cell.cellIndex}`;
|
|
47089
|
+
if (activeHotspotKeyRef.current === hotspotKey) {
|
|
47090
|
+
hideRowGuide();
|
|
47091
|
+
showColumnGuide(table, colTarget.row, colTarget.cell);
|
|
47092
|
+
return;
|
|
47093
|
+
}
|
|
47094
|
+
if (activeHotspotKeyRef.current !== hotspotKey) {
|
|
47095
|
+
clearHotspotTimer();
|
|
47096
|
+
activeHotspotKeyRef.current = hotspotKey;
|
|
47097
|
+
hotspotTimerRef.current = window.setTimeout(() => {
|
|
47098
|
+
hotspotTimerRef.current = null;
|
|
47099
|
+
hideRowGuide();
|
|
47100
|
+
showColumnGuide(table, colTarget.row, colTarget.cell);
|
|
47101
|
+
}, 100);
|
|
47102
|
+
}
|
|
46908
47103
|
return;
|
|
46909
47104
|
}
|
|
47105
|
+
clearHotspotTimer();
|
|
47106
|
+
activeHotspotKeyRef.current = null;
|
|
46910
47107
|
clearAllTableResizeHover();
|
|
46911
47108
|
};
|
|
46912
47109
|
const handleEditorMouseLeave = () => {
|
|
@@ -46927,15 +47124,22 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
46927
47124
|
clearActiveTableCell();
|
|
46928
47125
|
return;
|
|
46929
47126
|
}
|
|
46930
|
-
setActiveTableCell(cell);
|
|
46931
|
-
scheduleActiveCellSync(cell);
|
|
46932
47127
|
const row = cell.closest("tr");
|
|
46933
47128
|
const table = cell.closest("table");
|
|
46934
47129
|
if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) return;
|
|
46935
|
-
|
|
46936
|
-
|
|
46937
|
-
|
|
47130
|
+
const rowTarget = resolveRowResizeTarget(cell, event.clientX, event.clientY);
|
|
47131
|
+
if (rowTarget) {
|
|
47132
|
+
event.preventDefault();
|
|
47133
|
+
event.stopPropagation();
|
|
47134
|
+
window.getSelection()?.removeAllRanges();
|
|
47135
|
+
if (beginResize(event, table, rowTarget.row, rowTarget.cell)) {
|
|
47136
|
+
suppressActiveCellHighlightRef.current = true;
|
|
47137
|
+
updateActiveCellHighlight(null);
|
|
47138
|
+
return;
|
|
47139
|
+
}
|
|
46938
47140
|
}
|
|
47141
|
+
setActiveTableCell(cell);
|
|
47142
|
+
scheduleActiveCellSync(cell);
|
|
46939
47143
|
};
|
|
46940
47144
|
const handlePointerMove = (event) => {
|
|
46941
47145
|
handleRowResizePointerMove(event);
|
|
@@ -47024,8 +47228,9 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
47024
47228
|
clearActiveTableCell();
|
|
47025
47229
|
clearHoveredTableCell();
|
|
47026
47230
|
clearAllTableResizeHover();
|
|
47231
|
+
clearHotspotTimer();
|
|
47027
47232
|
};
|
|
47028
|
-
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, scheduleTableLayoutSync, setActiveTableCell, setHoveredTableCell, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
47233
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHotspotTimer, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, scheduleTableLayoutSync, setActiveTableCell, setHoveredTableCell, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
47029
47234
|
return {
|
|
47030
47235
|
editorContentRef,
|
|
47031
47236
|
tableColumnGuideRef,
|
|
@@ -47787,6 +47992,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
47787
47992
|
variant = "default",
|
|
47788
47993
|
rounded = true,
|
|
47789
47994
|
fontFamilies,
|
|
47995
|
+
defaultFontFamily = "Inter",
|
|
47790
47996
|
fontSizes,
|
|
47791
47997
|
lineHeights,
|
|
47792
47998
|
letterSpacings,
|
|
@@ -48095,6 +48301,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
48095
48301
|
maxImageFileSize,
|
|
48096
48302
|
allowedImageMimeTypes,
|
|
48097
48303
|
fontFamilies,
|
|
48304
|
+
defaultFontFamily,
|
|
48098
48305
|
fontSizes,
|
|
48099
48306
|
lineHeights,
|
|
48100
48307
|
letterSpacings
|
|
@@ -48120,6 +48327,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
48120
48327
|
},
|
|
48121
48328
|
className: "relative flex-1 overflow-y-auto",
|
|
48122
48329
|
style: {
|
|
48330
|
+
fontFamily: defaultFontFamily,
|
|
48123
48331
|
minHeight: editable ? minHeight : void 0,
|
|
48124
48332
|
maxHeight
|
|
48125
48333
|
},
|
|
@@ -48129,7 +48337,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
48129
48337
|
{
|
|
48130
48338
|
ref: tableColumnGuideRef,
|
|
48131
48339
|
"aria-hidden": "true",
|
|
48132
|
-
className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
|
|
48340
|
+
className: "pointer-events-none absolute z-20 bg-primary/50 opacity-0 transition-opacity duration-200 delay-100 ease-out"
|
|
48133
48341
|
}
|
|
48134
48342
|
),
|
|
48135
48343
|
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
@@ -48137,7 +48345,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
48137
48345
|
{
|
|
48138
48346
|
ref: tableRowGuideRef,
|
|
48139
48347
|
"aria-hidden": "true",
|
|
48140
|
-
className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
|
|
48348
|
+
className: "pointer-events-none absolute z-20 bg-primary/50 opacity-0 transition-opacity duration-200 delay-100 ease-out"
|
|
48141
48349
|
}
|
|
48142
48350
|
),
|
|
48143
48351
|
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
@@ -48146,7 +48354,7 @@ var UEditor = import_react84.default.forwardRef(({
|
|
|
48146
48354
|
ref: activeTableCellHighlightRef,
|
|
48147
48355
|
"aria-hidden": "true",
|
|
48148
48356
|
"data-ueditor-active-cell-highlight": "",
|
|
48149
|
-
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border
|
|
48357
|
+
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border border-primary/50 bg-primary/5"
|
|
48150
48358
|
}
|
|
48151
48359
|
),
|
|
48152
48360
|
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|