@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/ueditor.cjs
CHANGED
|
@@ -5061,17 +5061,60 @@ function getSelectionTableCell(view) {
|
|
|
5061
5061
|
const cell = element?.closest?.("th,td");
|
|
5062
5062
|
return cell instanceof HTMLElement ? cell : null;
|
|
5063
5063
|
}
|
|
5064
|
-
function
|
|
5064
|
+
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
5065
5065
|
const rect = cell.getBoundingClientRect();
|
|
5066
|
-
const
|
|
5067
|
-
|
|
5068
|
-
|
|
5066
|
+
const row = cell.closest("tr");
|
|
5067
|
+
if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
|
|
5068
|
+
return null;
|
|
5069
|
+
}
|
|
5070
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
5071
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
5072
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
5073
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
5074
|
+
if (distToRight <= 3 || distToLeft <= 3) {
|
|
5075
|
+
return null;
|
|
5076
|
+
}
|
|
5077
|
+
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
5078
|
+
return { row, cell };
|
|
5079
|
+
}
|
|
5080
|
+
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
5081
|
+
const prevRow = row.previousElementSibling;
|
|
5082
|
+
if (prevRow instanceof HTMLTableRowElement) {
|
|
5083
|
+
const cellIndex = cell.cellIndex;
|
|
5084
|
+
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
5085
|
+
if (prevCell instanceof HTMLTableCellElement) {
|
|
5086
|
+
return { row: prevRow, cell: prevCell };
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
return null;
|
|
5069
5091
|
}
|
|
5070
|
-
function
|
|
5092
|
+
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
5071
5093
|
const rect = cell.getBoundingClientRect();
|
|
5072
|
-
const
|
|
5073
|
-
|
|
5074
|
-
|
|
5094
|
+
const row = cell.closest("tr");
|
|
5095
|
+
if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
|
|
5096
|
+
return null;
|
|
5097
|
+
}
|
|
5098
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
5099
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
5100
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
5101
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
5102
|
+
if (distToBottom <= 3 || distToTop <= 3) {
|
|
5103
|
+
return null;
|
|
5104
|
+
}
|
|
5105
|
+
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
5106
|
+
return { row, cell };
|
|
5107
|
+
}
|
|
5108
|
+
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
5109
|
+
const prevCell = cell.previousElementSibling;
|
|
5110
|
+
if (prevCell instanceof HTMLTableCellElement) {
|
|
5111
|
+
return { row, cell: prevCell };
|
|
5112
|
+
}
|
|
5113
|
+
}
|
|
5114
|
+
return null;
|
|
5115
|
+
}
|
|
5116
|
+
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
5117
|
+
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
5075
5118
|
}
|
|
5076
5119
|
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
5077
5120
|
const surfaceRect = surface.getBoundingClientRect();
|
|
@@ -5123,7 +5166,7 @@ function getRelativeSelectedCellsMetrics(surface) {
|
|
|
5123
5166
|
height: bottom - top
|
|
5124
5167
|
};
|
|
5125
5168
|
}
|
|
5126
|
-
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;
|
|
5169
|
+
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;
|
|
5127
5170
|
var init_table_dom_utils = __esm({
|
|
5128
5171
|
"src/components/UEditor/table-dom-utils.ts"() {
|
|
5129
5172
|
"use strict";
|
|
@@ -5131,8 +5174,9 @@ var init_table_dom_utils = __esm({
|
|
|
5131
5174
|
MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
5132
5175
|
COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
5133
5176
|
ROW_RESIZE_LINE_THICKNESS = 2;
|
|
5134
|
-
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor
|
|
5135
|
-
|
|
5177
|
+
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
5178
|
+
isRowResizingGlobal = { active: false };
|
|
5179
|
+
TABLE_RESIZE_HIT_ZONE = 5;
|
|
5136
5180
|
}
|
|
5137
5181
|
});
|
|
5138
5182
|
|
|
@@ -6211,6 +6255,18 @@ var init_colors = __esm({
|
|
|
6211
6255
|
const automaticColor = colors[0]?.color ?? "";
|
|
6212
6256
|
const paletteColors = colors.slice(1);
|
|
6213
6257
|
const customColorSelect = onCustomColorSelect ?? onSelect;
|
|
6258
|
+
const [hexInput, setHexInput] = import_react31.default.useState(currentColor.startsWith("#") ? currentColor : "");
|
|
6259
|
+
import_react31.default.useEffect(() => {
|
|
6260
|
+
setHexInput(currentColor.startsWith("#") ? currentColor : "");
|
|
6261
|
+
}, [currentColor]);
|
|
6262
|
+
const commitHex = (val) => {
|
|
6263
|
+
let formatted = val.trim();
|
|
6264
|
+
if (!formatted) return;
|
|
6265
|
+
if (!formatted.startsWith("#")) formatted = `#${formatted}`;
|
|
6266
|
+
if (/^#([0-9A-F]{3}){1,2}$/i.test(formatted)) {
|
|
6267
|
+
customColorSelect(formatted);
|
|
6268
|
+
}
|
|
6269
|
+
};
|
|
6214
6270
|
import_react31.default.useEffect(() => {
|
|
6215
6271
|
const input = colorInputRef.current;
|
|
6216
6272
|
if (!input) return;
|
|
@@ -6222,7 +6278,7 @@ var init_colors = __esm({
|
|
|
6222
6278
|
const input = colorInputRef.current;
|
|
6223
6279
|
if (input) input.value = currentColor.startsWith("#") ? currentColor : "#000000";
|
|
6224
6280
|
}, [currentColor]);
|
|
6225
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "w-56 p-2", children: [
|
|
6281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "w-56 p-2", "data-ueditor-keep-open": true, children: [
|
|
6226
6282
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
|
|
6227
6283
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
6228
6284
|
"button",
|
|
@@ -6256,29 +6312,48 @@ var init_colors = __esm({
|
|
|
6256
6312
|
children: currentColor === c.color && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react11.Check, { className: cn("h-3.5 w-3.5", getSwatchCheckClass(c.color)) }) })
|
|
6257
6313
|
}
|
|
6258
6314
|
) }, `${c.name}-${c.color}`)) }),
|
|
6259
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
6260
|
-
"
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6315
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "mt-3 flex items-center gap-2", children: [
|
|
6316
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex h-8 flex-1 items-center gap-1.5 rounded-md border border-input bg-muted/30 px-2", children: [
|
|
6317
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6318
|
+
"span",
|
|
6319
|
+
{
|
|
6320
|
+
className: "h-4 w-4 shrink-0 rounded-[2px] border border-border",
|
|
6321
|
+
style: { backgroundColor: hexInput.startsWith("#") ? hexInput : currentColor.startsWith("#") ? currentColor : "transparent" }
|
|
6322
|
+
}
|
|
6323
|
+
),
|
|
6324
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6325
|
+
"input",
|
|
6326
|
+
{
|
|
6327
|
+
type: "text",
|
|
6328
|
+
value: hexInput,
|
|
6329
|
+
onChange: (e) => setHexInput(e.target.value),
|
|
6330
|
+
onBlur: () => commitHex(hexInput),
|
|
6331
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
6332
|
+
onClick: (e) => e.stopPropagation(),
|
|
6333
|
+
onKeyDown: (e) => {
|
|
6334
|
+
e.stopPropagation();
|
|
6335
|
+
if (e.key === "Enter") {
|
|
6336
|
+
e.preventDefault();
|
|
6337
|
+
commitHex(hexInput);
|
|
6274
6338
|
}
|
|
6275
|
-
}
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
}
|
|
6281
|
-
|
|
6339
|
+
},
|
|
6340
|
+
placeholder: "#HEX",
|
|
6341
|
+
className: "h-full w-full bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground"
|
|
6342
|
+
}
|
|
6343
|
+
)
|
|
6344
|
+
] }),
|
|
6345
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6346
|
+
"button",
|
|
6347
|
+
{
|
|
6348
|
+
type: "button",
|
|
6349
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
6350
|
+
onClick: () => colorInputRef.current?.click(),
|
|
6351
|
+
title: t("colors.moreColors"),
|
|
6352
|
+
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",
|
|
6353
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react11.Palette, { className: "h-4 w-4 text-muted-foreground" })
|
|
6354
|
+
}
|
|
6355
|
+
)
|
|
6356
|
+
] }),
|
|
6282
6357
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
6283
6358
|
"input",
|
|
6284
6359
|
{
|
|
@@ -6852,7 +6927,7 @@ var init_toolbar = __esm({
|
|
|
6852
6927
|
return button;
|
|
6853
6928
|
});
|
|
6854
6929
|
ToolbarButton.displayName = "ToolbarButton";
|
|
6855
|
-
ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { "aria-hidden": "true", className: "mx-1
|
|
6930
|
+
ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { "aria-hidden": "true", className: "mx-1 h-5 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
|
|
6856
6931
|
TableInsertGrid = ({
|
|
6857
6932
|
insertLabel,
|
|
6858
6933
|
previewTemplate,
|
|
@@ -6897,6 +6972,7 @@ var init_toolbar = __esm({
|
|
|
6897
6972
|
maxImageFileSize = DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
|
|
6898
6973
|
allowedImageMimeTypes = DEFAULT_UEDITOR_IMAGE_MIME_TYPES,
|
|
6899
6974
|
fontFamilies,
|
|
6975
|
+
defaultFontFamily = "Inter",
|
|
6900
6976
|
fontSizes,
|
|
6901
6977
|
lineHeights,
|
|
6902
6978
|
letterSpacings
|
|
@@ -6939,9 +7015,9 @@ var init_toolbar = __esm({
|
|
|
6939
7015
|
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? "13";
|
|
6940
7016
|
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
6941
7017
|
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
6942
|
-
const
|
|
6943
|
-
const defaultFontFamilyValue =
|
|
6944
|
-
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel :
|
|
7018
|
+
const defaultFontFamilyOption = availableFontFamilies.find((opt) => normalizeStyleValue(opt.value) === normalizeStyleValue(defaultFontFamily)) ?? availableFontFamilies[0];
|
|
7019
|
+
const defaultFontFamilyValue = defaultFontFamilyOption?.value ?? defaultFontFamily ?? "Inter";
|
|
7020
|
+
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamilyOption?.label ?? defaultFontFamily ?? t("toolbar.fontDefault");
|
|
6945
7021
|
const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
|
|
6946
7022
|
const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
|
|
6947
7023
|
const activeFontSize = currentFontSize || "13px";
|
|
@@ -7073,7 +7149,7 @@ var init_toolbar = __esm({
|
|
|
7073
7149
|
"div",
|
|
7074
7150
|
{
|
|
7075
7151
|
role: "toolbar",
|
|
7076
|
-
className: "flex min-h-
|
|
7152
|
+
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",
|
|
7077
7153
|
children: [
|
|
7078
7154
|
isFull && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7079
7155
|
DropdownMenu,
|
|
@@ -7084,9 +7160,9 @@ var init_toolbar = __esm({
|
|
|
7084
7160
|
onClick: () => {
|
|
7085
7161
|
},
|
|
7086
7162
|
title: t("toolbar.fontFamily"),
|
|
7087
|
-
className: "h-
|
|
7163
|
+
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",
|
|
7088
7164
|
children: [
|
|
7089
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "min-w-0 flex-1 truncate text-left text-
|
|
7165
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "min-w-0 flex-1 truncate text-left text-xs font-normal", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
|
|
7090
7166
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
|
|
7091
7167
|
]
|
|
7092
7168
|
}
|
|
@@ -7113,9 +7189,9 @@ var init_toolbar = __esm({
|
|
|
7113
7189
|
onClick: () => {
|
|
7114
7190
|
},
|
|
7115
7191
|
title: t("toolbar.fontSize"),
|
|
7116
|
-
className: "h-
|
|
7192
|
+
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",
|
|
7117
7193
|
children: [
|
|
7118
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-
|
|
7194
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-xs font-normal leading-none", children: displayedFontSizeLabel }),
|
|
7119
7195
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
|
|
7120
7196
|
]
|
|
7121
7197
|
}
|
|
@@ -7240,6 +7316,27 @@ var init_toolbar = __esm({
|
|
|
7240
7316
|
)
|
|
7241
7317
|
] }),
|
|
7242
7318
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarDivider, {}),
|
|
7319
|
+
(isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7320
|
+
DropdownMenu,
|
|
7321
|
+
{
|
|
7322
|
+
isOpen: isTableMenuOpen,
|
|
7323
|
+
onOpenChange: setIsTableMenuOpen,
|
|
7324
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => {
|
|
7325
|
+
}, title: t("toolbar.table"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaTableIcon, { className: "h-4 w-4" }) }),
|
|
7326
|
+
contentClassName: "p-2 min-w-56",
|
|
7327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7328
|
+
TableInsertGrid,
|
|
7329
|
+
{
|
|
7330
|
+
insertLabel: t("tableMenu.insertTable"),
|
|
7331
|
+
previewTemplate: t("tableMenu.gridPreview"),
|
|
7332
|
+
onInsert: (rows, cols) => {
|
|
7333
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
7334
|
+
setIsTableMenuOpen(false);
|
|
7335
|
+
}
|
|
7336
|
+
}
|
|
7337
|
+
)
|
|
7338
|
+
}
|
|
7339
|
+
),
|
|
7243
7340
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaBoldIcon, { className: "h-4 w-4" }) }),
|
|
7244
7341
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaItalicIcon, { className: "h-4 w-4" }) }),
|
|
7245
7342
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
@@ -7710,27 +7807,6 @@ var init_toolbar = __esm({
|
|
|
7710
7807
|
] })
|
|
7711
7808
|
}
|
|
7712
7809
|
),
|
|
7713
|
-
(isMediumFull || isFull) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7714
|
-
DropdownMenu,
|
|
7715
|
-
{
|
|
7716
|
-
isOpen: isTableMenuOpen,
|
|
7717
|
-
onOpenChange: setIsTableMenuOpen,
|
|
7718
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => {
|
|
7719
|
-
}, title: t("toolbar.table"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaTableIcon, { className: "h-4 w-4" }) }),
|
|
7720
|
-
contentClassName: "p-2 min-w-56",
|
|
7721
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7722
|
-
TableInsertGrid,
|
|
7723
|
-
{
|
|
7724
|
-
insertLabel: t("tableMenu.insertTable"),
|
|
7725
|
-
previewTemplate: t("tableMenu.gridPreview"),
|
|
7726
|
-
onInsert: (rows, cols) => {
|
|
7727
|
-
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
7728
|
-
setIsTableMenuOpen(false);
|
|
7729
|
-
}
|
|
7730
|
-
}
|
|
7731
|
-
)
|
|
7732
|
-
}
|
|
7733
|
-
),
|
|
7734
7810
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarDivider, {}),
|
|
7735
7811
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().undo().run(), disabled: !editor.can().undo(), title: t("toolbar.undo"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaUndoIcon, { className: "h-4 w-4" }) }),
|
|
7736
7812
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().redo().run(), disabled: !editor.can().redo(), title: t("toolbar.redo"), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FigmaRedoIcon, { className: "h-4 w-4" }) }),
|
|
@@ -7929,7 +8005,7 @@ var init_editor_styles = __esm({
|
|
|
7929
8005
|
"[&_.selectedCell]:after:absolute",
|
|
7930
8006
|
"[&_.selectedCell]:after:inset-0",
|
|
7931
8007
|
"[&_.selectedCell]:after:z-[2]",
|
|
7932
|
-
"[&_.selectedCell]:after:bg-primary/
|
|
8008
|
+
"[&_.selectedCell]:after:bg-primary/8",
|
|
7933
8009
|
"[&_.selectedCell]:after:pointer-events-none",
|
|
7934
8010
|
"[&_.column-resize-handle]:pointer-events-auto",
|
|
7935
8011
|
"[&_.column-resize-handle]:cursor-col-resize",
|
|
@@ -7943,17 +8019,10 @@ var init_editor_styles = __esm({
|
|
|
7943
8019
|
"[&_.column-resize-handle]:rounded-none",
|
|
7944
8020
|
"[&_.column-resize-handle]:opacity-0",
|
|
7945
8021
|
"[&_.column-resize-handle]:transition-opacity",
|
|
7946
|
-
"[&_.column-resize-handle]:
|
|
7947
|
-
"[&_.column-resize-handle]:
|
|
7948
|
-
"[&_.column-resize-handle]:
|
|
7949
|
-
"[&_.column-resize-handle]:after:
|
|
7950
|
-
"[&_.column-resize-handle]:after:w-0.5",
|
|
7951
|
-
"[&_.column-resize-handle]:after:-translate-x-1/2",
|
|
7952
|
-
"[&_.column-resize-handle]:after:rounded-full",
|
|
7953
|
-
"[&_.column-resize-handle]:after:bg-primary/75",
|
|
7954
|
-
"[&_.column-resize-handle]:after:content-['']",
|
|
7955
|
-
"[&.resize-cursor_.column-resize-handle]:opacity-100",
|
|
7956
|
-
"[&.resize-cursor_.column-resize-handle]:after:bg-primary",
|
|
8022
|
+
"[&_.column-resize-handle]:duration-200",
|
|
8023
|
+
"[&_.column-resize-handle]:delay-100",
|
|
8024
|
+
"[&_.column-resize-handle]:ease-out",
|
|
8025
|
+
"[&_.column-resize-handle]:after:hidden",
|
|
7957
8026
|
"[&_.column-resize-dragging]:min-w-0",
|
|
7958
8027
|
"[&.resize-cursor]:cursor-col-resize",
|
|
7959
8028
|
"[&.resize-row-cursor]:cursor-row-resize",
|
|
@@ -12116,6 +12185,15 @@ function edgeCell(view, event, side, handleWidth) {
|
|
|
12116
12185
|
const index = map.map.indexOf($cell.pos - start);
|
|
12117
12186
|
return index % map.width === 0 ? -1 : start + map.map[index - 1];
|
|
12118
12187
|
}
|
|
12188
|
+
var handleHoverTimer = null;
|
|
12189
|
+
var pendingHandleCell = -1;
|
|
12190
|
+
function clearHandleHoverTimer() {
|
|
12191
|
+
if (handleHoverTimer !== null) {
|
|
12192
|
+
window.clearTimeout(handleHoverTimer);
|
|
12193
|
+
handleHoverTimer = null;
|
|
12194
|
+
}
|
|
12195
|
+
pendingHandleCell = -1;
|
|
12196
|
+
}
|
|
12119
12197
|
function updateHandle(view, value) {
|
|
12120
12198
|
view.dispatch(view.state.tr.setMeta(import_tables2.columnResizingPluginKey, { setHandle: value }));
|
|
12121
12199
|
}
|
|
@@ -12130,19 +12208,43 @@ function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
|
12130
12208
|
if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
12131
12209
|
else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
12132
12210
|
}
|
|
12133
|
-
if (cell === pluginState.activeHandle)
|
|
12134
|
-
|
|
12211
|
+
if (cell === pluginState.activeHandle) {
|
|
12212
|
+
clearHandleHoverTimer();
|
|
12213
|
+
return;
|
|
12214
|
+
}
|
|
12215
|
+
if (cell === -1) {
|
|
12216
|
+
clearHandleHoverTimer();
|
|
12217
|
+
if (pluginState.activeHandle !== -1) {
|
|
12218
|
+
updateHandle(view, -1);
|
|
12219
|
+
}
|
|
12220
|
+
return;
|
|
12221
|
+
}
|
|
12222
|
+
if (!lastColumnResizable) {
|
|
12135
12223
|
const $cell = view.state.doc.resolve(cell);
|
|
12136
12224
|
const table = $cell.node(-1);
|
|
12137
12225
|
const map = import_tables2.TableMap.get(table);
|
|
12138
12226
|
const tableStart = $cell.start(-1);
|
|
12139
12227
|
const nodeAfter = $cell.nodeAfter;
|
|
12140
12228
|
if (!nodeAfter) return;
|
|
12141
|
-
if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1)
|
|
12229
|
+
if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1) {
|
|
12230
|
+
clearHandleHoverTimer();
|
|
12231
|
+
if (pluginState.activeHandle !== -1) {
|
|
12232
|
+
updateHandle(view, -1);
|
|
12233
|
+
}
|
|
12234
|
+
return;
|
|
12235
|
+
}
|
|
12142
12236
|
}
|
|
12143
|
-
|
|
12237
|
+
if (pendingHandleCell === cell) return;
|
|
12238
|
+
clearHandleHoverTimer();
|
|
12239
|
+
pendingHandleCell = cell;
|
|
12240
|
+
handleHoverTimer = window.setTimeout(() => {
|
|
12241
|
+
handleHoverTimer = null;
|
|
12242
|
+
pendingHandleCell = -1;
|
|
12243
|
+
updateHandle(view, cell);
|
|
12244
|
+
}, 100);
|
|
12144
12245
|
}
|
|
12145
12246
|
function handleMouseLeave(view) {
|
|
12247
|
+
clearHandleHoverTimer();
|
|
12146
12248
|
if (!view.editable) return;
|
|
12147
12249
|
const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
|
|
12148
12250
|
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
@@ -12191,7 +12293,7 @@ function getColumnResizeGhost(view) {
|
|
|
12191
12293
|
ghost.style.pointerEvents = "none";
|
|
12192
12294
|
ghost.style.width = "2px";
|
|
12193
12295
|
ghost.style.backgroundColor = "var(--primary, #2563eb)";
|
|
12194
|
-
ghost.style.opacity = "
|
|
12296
|
+
ghost.style.opacity = "0.5";
|
|
12195
12297
|
ghost.style.borderRadius = "9999px";
|
|
12196
12298
|
ghost.style.boxShadow = "0 0 0 1px color-mix(in oklch, var(--background, #fff) 80%, transparent)";
|
|
12197
12299
|
ghost.style.transform = "translateX(-1px)";
|
|
@@ -12220,6 +12322,7 @@ function showColumnResizeGhost(view, cell, dragging, width) {
|
|
|
12220
12322
|
ghost.style.height = `${rect.height}px`;
|
|
12221
12323
|
}
|
|
12222
12324
|
function handleMouseDown(view, event, cellMinWidth) {
|
|
12325
|
+
clearHandleHoverTimer();
|
|
12223
12326
|
if (!view.editable) return false;
|
|
12224
12327
|
const win = view.dom.ownerDocument.defaultView ?? window;
|
|
12225
12328
|
const pluginState = import_tables2.columnResizingPluginKey.getState(view.state);
|
|
@@ -12341,6 +12444,7 @@ function dynamicColumnResizing({
|
|
|
12341
12444
|
|
|
12342
12445
|
// src/components/UEditor/table-align.ts
|
|
12343
12446
|
init_table_align_utils();
|
|
12447
|
+
init_table_dom_utils();
|
|
12344
12448
|
function normalizeTableAlign(value) {
|
|
12345
12449
|
if (value === "left" || value === "center" || value === "right") {
|
|
12346
12450
|
return value;
|
|
@@ -12467,6 +12571,38 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
12467
12571
|
lastColumnResizable: this.options.lastColumnResizable
|
|
12468
12572
|
})
|
|
12469
12573
|
] : [],
|
|
12574
|
+
new import_state7.Plugin({
|
|
12575
|
+
key: new import_state7.PluginKey("tableRowResizeInterceptor"),
|
|
12576
|
+
props: {
|
|
12577
|
+
handleDOMEvents: {
|
|
12578
|
+
mousedown(view, event) {
|
|
12579
|
+
if (event.button !== 0) return false;
|
|
12580
|
+
const target = resolveEventElement(event.target);
|
|
12581
|
+
const cell = target?.closest("th,td");
|
|
12582
|
+
if (cell instanceof HTMLElement && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
12583
|
+
isRowResizingGlobal.active = true;
|
|
12584
|
+
return true;
|
|
12585
|
+
}
|
|
12586
|
+
return false;
|
|
12587
|
+
},
|
|
12588
|
+
mousemove(_view, event) {
|
|
12589
|
+
if (isRowResizingGlobal.active) {
|
|
12590
|
+
if (event.buttons === 0) {
|
|
12591
|
+
isRowResizingGlobal.active = false;
|
|
12592
|
+
return false;
|
|
12593
|
+
}
|
|
12594
|
+
event.preventDefault();
|
|
12595
|
+
return true;
|
|
12596
|
+
}
|
|
12597
|
+
return false;
|
|
12598
|
+
},
|
|
12599
|
+
mouseup() {
|
|
12600
|
+
isRowResizingGlobal.active = false;
|
|
12601
|
+
return false;
|
|
12602
|
+
}
|
|
12603
|
+
}
|
|
12604
|
+
}
|
|
12605
|
+
}),
|
|
12470
12606
|
(0, import_tables3.tableEditing)({
|
|
12471
12607
|
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
12472
12608
|
}),
|
|
@@ -15626,7 +15762,11 @@ var CustomBubbleMenu = ({
|
|
|
15626
15762
|
setIsVisible(false);
|
|
15627
15763
|
return;
|
|
15628
15764
|
}
|
|
15629
|
-
|
|
15765
|
+
const isInputFocused = () => {
|
|
15766
|
+
const active = document.activeElement;
|
|
15767
|
+
return Boolean(active && (menuRef.current?.contains(active) || active.closest?.("[data-ueditor-keep-open]")));
|
|
15768
|
+
};
|
|
15769
|
+
if (!keepOpenRef.current && !isInputFocused() && (context2 === "none" || !view.hasFocus())) {
|
|
15630
15770
|
clearShowTimeout();
|
|
15631
15771
|
setIsVisible(false);
|
|
15632
15772
|
return;
|
|
@@ -15667,7 +15807,8 @@ var CustomBubbleMenu = ({
|
|
|
15667
15807
|
}, SHOW_DELAY_MS);
|
|
15668
15808
|
};
|
|
15669
15809
|
const handleBlur = () => {
|
|
15670
|
-
|
|
15810
|
+
const isInputFocused = Boolean(document.activeElement && (menuRef.current?.contains(document.activeElement) || document.activeElement.closest?.("[data-ueditor-keep-open]")));
|
|
15811
|
+
if (!keepOpenRef.current && !isInputFocused) {
|
|
15671
15812
|
clearShowTimeout();
|
|
15672
15813
|
setIsVisible(false);
|
|
15673
15814
|
}
|
|
@@ -15761,6 +15902,9 @@ var CustomBubbleMenu = ({
|
|
|
15761
15902
|
} else if (target?.closest?.("[data-ueditor-keep-open]")) {
|
|
15762
15903
|
setKeepOpen(true);
|
|
15763
15904
|
}
|
|
15905
|
+
if (target && target.closest("input, textarea, select")) {
|
|
15906
|
+
return;
|
|
15907
|
+
}
|
|
15764
15908
|
e.preventDefault();
|
|
15765
15909
|
},
|
|
15766
15910
|
children: context === "link" && !keepOpen && !linkInputOpen ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -19334,7 +19478,7 @@ function createKey(name) {
|
|
|
19334
19478
|
keys[name] = 0;
|
|
19335
19479
|
return name + "$";
|
|
19336
19480
|
}
|
|
19337
|
-
var
|
|
19481
|
+
var PluginKey7 = class {
|
|
19338
19482
|
/**
|
|
19339
19483
|
Create a plugin key.
|
|
19340
19484
|
*/
|
|
@@ -19766,7 +19910,7 @@ function tableNodeTypes2(schema) {
|
|
|
19766
19910
|
}
|
|
19767
19911
|
return result;
|
|
19768
19912
|
}
|
|
19769
|
-
var tableEditingKey = new
|
|
19913
|
+
var tableEditingKey = new PluginKey7("selectingCells");
|
|
19770
19914
|
function cellAround2($pos) {
|
|
19771
19915
|
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));
|
|
19772
19916
|
return null;
|
|
@@ -19997,7 +20141,7 @@ var CellBookmark = class CellBookmark2 {
|
|
|
19997
20141
|
else return Selection.near($headCell, 1);
|
|
19998
20142
|
}
|
|
19999
20143
|
};
|
|
20000
|
-
var fixTablesKey = new
|
|
20144
|
+
var fixTablesKey = new PluginKey7("fix-tables");
|
|
20001
20145
|
function convertTableNodeToArrayOfRows(tableNode) {
|
|
20002
20146
|
const map = TableMap4.get(tableNode);
|
|
20003
20147
|
const rows = [];
|
|
@@ -20475,7 +20619,7 @@ function atEndOfCell(view, axis, dir) {
|
|
|
20475
20619
|
}
|
|
20476
20620
|
return null;
|
|
20477
20621
|
}
|
|
20478
|
-
var columnResizingPluginKey2 = new
|
|
20622
|
+
var columnResizingPluginKey2 = new PluginKey7("tableColumnResizing");
|
|
20479
20623
|
|
|
20480
20624
|
// src/components/UEditor/table-controls.tsx
|
|
20481
20625
|
var import_lucide_react18 = require("lucide-react");
|
|
@@ -20924,6 +21068,8 @@ init_Tooltip();
|
|
|
20924
21068
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
20925
21069
|
var ADD_COLUMN_RAIL_GAP = 4;
|
|
20926
21070
|
var ADD_ROW_RAIL_GAP = 4;
|
|
21071
|
+
var BUTTON_LONG_SIZE = 36;
|
|
21072
|
+
var BUTTON_SHORT_SIZE = 14;
|
|
20927
21073
|
function TableAddRails({
|
|
20928
21074
|
addColumnVisible,
|
|
20929
21075
|
addRowVisible,
|
|
@@ -20936,10 +21082,10 @@ function TableAddRails({
|
|
|
20936
21082
|
quickAddRowLabel
|
|
20937
21083
|
}) {
|
|
20938
21084
|
const visibleBounds = getVisibleTableBounds(layout);
|
|
20939
|
-
const columnRailTop = visibleBounds.top;
|
|
21085
|
+
const columnRailTop = visibleBounds.top + Math.max(0, (visibleBounds.height - BUTTON_LONG_SIZE) / 2);
|
|
20940
21086
|
const columnRailLeft = visibleBounds.right + ADD_COLUMN_RAIL_GAP;
|
|
20941
21087
|
const rowRailTop = layout.wrapperTop + layout.wrapperHeight + ADD_ROW_RAIL_GAP;
|
|
20942
|
-
const rowRailLeft = visibleBounds.left;
|
|
21088
|
+
const rowRailLeft = visibleBounds.left + Math.max(0, (visibleBounds.width - BUTTON_LONG_SIZE) / 2);
|
|
20943
21089
|
const showColumnRail = controlsVisible || addColumnVisible;
|
|
20944
21090
|
const showRowRail = controlsVisible || addRowVisible;
|
|
20945
21091
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
@@ -20964,15 +21110,15 @@ function TableAddRails({
|
|
|
20964
21110
|
className: cn(
|
|
20965
21111
|
"absolute z-30 inline-flex items-center justify-center rounded-md",
|
|
20966
21112
|
"border border-border/70 bg-muted/40 text-muted-foreground shadow-sm backdrop-blur",
|
|
20967
|
-
"transition-[opacity,transform,colors] duration-
|
|
21113
|
+
"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"
|
|
20968
21114
|
),
|
|
20969
21115
|
style: {
|
|
20970
|
-
top:
|
|
21116
|
+
top: columnRailTop,
|
|
20971
21117
|
left: columnRailLeft,
|
|
20972
|
-
width:
|
|
20973
|
-
height:
|
|
21118
|
+
width: BUTTON_SHORT_SIZE,
|
|
21119
|
+
height: BUTTON_LONG_SIZE,
|
|
20974
21120
|
opacity: showColumnRail ? 1 : 0,
|
|
20975
|
-
transform: showColumnRail ? "scale(1)" : "scale(0.
|
|
21121
|
+
transform: showColumnRail ? "scale(1)" : "scale(0.85)",
|
|
20976
21122
|
pointerEvents: showColumnRail ? "auto" : "none"
|
|
20977
21123
|
},
|
|
20978
21124
|
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
@@ -21001,15 +21147,15 @@ function TableAddRails({
|
|
|
21001
21147
|
className: cn(
|
|
21002
21148
|
"absolute z-30 inline-flex items-center justify-center rounded-md",
|
|
21003
21149
|
"border border-border/70 bg-muted/40 text-muted-foreground shadow-sm backdrop-blur",
|
|
21004
|
-
"transition-[opacity,transform,colors] duration-
|
|
21150
|
+
"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"
|
|
21005
21151
|
),
|
|
21006
21152
|
style: {
|
|
21007
21153
|
top: rowRailTop,
|
|
21008
|
-
left:
|
|
21009
|
-
width:
|
|
21010
|
-
height:
|
|
21154
|
+
left: rowRailLeft,
|
|
21155
|
+
width: BUTTON_LONG_SIZE,
|
|
21156
|
+
height: BUTTON_SHORT_SIZE,
|
|
21011
21157
|
opacity: showRowRail ? 1 : 0,
|
|
21012
|
-
transform: showRowRail ? "scale(1)" : "scale(0.
|
|
21158
|
+
transform: showRowRail ? "scale(1)" : "scale(0.85)",
|
|
21013
21159
|
pointerEvents: showRowRail ? "auto" : "none"
|
|
21014
21160
|
},
|
|
21015
21161
|
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
@@ -21146,7 +21292,7 @@ function TableRowHandles({
|
|
|
21146
21292
|
onStartDrag(rowHandle);
|
|
21147
21293
|
},
|
|
21148
21294
|
className: cn(
|
|
21149
|
-
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-
|
|
21295
|
+
"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",
|
|
21150
21296
|
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"
|
|
21151
21297
|
),
|
|
21152
21298
|
style: {
|
|
@@ -21221,7 +21367,7 @@ function TableColumnHandles({
|
|
|
21221
21367
|
onStartDrag(columnHandle);
|
|
21222
21368
|
},
|
|
21223
21369
|
className: cn(
|
|
21224
|
-
"inline-flex h-6 w-6 items-center justify-center rounded-full transition-[opacity,transform,colors,border,background-color] duration-
|
|
21370
|
+
"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",
|
|
21225
21371
|
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"
|
|
21226
21372
|
),
|
|
21227
21373
|
style: {
|
|
@@ -21610,7 +21756,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
21610
21756
|
const updateHoverState = import_react37.default.useCallback((event) => {
|
|
21611
21757
|
const activeLayout = layoutRef.current;
|
|
21612
21758
|
const surface = containerRef.current;
|
|
21613
|
-
if (!activeLayout || !surface || dragStateRef.current) {
|
|
21759
|
+
if (!activeLayout || !surface || dragStateRef.current || event.buttons !== 0) {
|
|
21614
21760
|
setHoverState(DEFAULT_TABLE_HOVER_STATE);
|
|
21615
21761
|
return;
|
|
21616
21762
|
}
|
|
@@ -21744,7 +21890,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
21744
21890
|
return result;
|
|
21745
21891
|
}, [editor, scheduleSyncFromSelection]);
|
|
21746
21892
|
const canExpandTable = Boolean(layout);
|
|
21747
|
-
const controlsVisible =
|
|
21893
|
+
const controlsVisible = false;
|
|
21748
21894
|
const tableMenuOpen = openMenuKey === "table";
|
|
21749
21895
|
const startTableResize = import_react37.default.useCallback((event) => {
|
|
21750
21896
|
if (event.button !== 0 || dragStateRef.current) return;
|
|
@@ -22271,6 +22417,9 @@ function useTableRowResize({
|
|
|
22271
22417
|
pendingHeight: startHeight
|
|
22272
22418
|
};
|
|
22273
22419
|
showRowGuide(table, row, cell, startHeight);
|
|
22420
|
+
isRowResizingGlobal.active = true;
|
|
22421
|
+
window.getSelection()?.removeAllRanges();
|
|
22422
|
+
document.body.style.userSelect = "none";
|
|
22274
22423
|
document.body.style.cursor = "row-resize";
|
|
22275
22424
|
event.preventDefault();
|
|
22276
22425
|
event.stopPropagation();
|
|
@@ -22312,6 +22461,8 @@ function useTableRowResize({
|
|
|
22312
22461
|
editor.view.dispatch(tr);
|
|
22313
22462
|
}
|
|
22314
22463
|
stateRef.current = null;
|
|
22464
|
+
isRowResizingGlobal.active = false;
|
|
22465
|
+
document.body.style.userSelect = "";
|
|
22315
22466
|
document.body.style.cursor = "";
|
|
22316
22467
|
clearHoveredTableCell();
|
|
22317
22468
|
clearAllTableResizeHover();
|
|
@@ -22320,6 +22471,8 @@ function useTableRowResize({
|
|
|
22320
22471
|
const cancelResize = import_react38.default.useCallback(() => {
|
|
22321
22472
|
if (!stateRef.current) return;
|
|
22322
22473
|
stateRef.current = null;
|
|
22474
|
+
isRowResizingGlobal.active = false;
|
|
22475
|
+
document.body.style.userSelect = "";
|
|
22323
22476
|
document.body.style.cursor = "";
|
|
22324
22477
|
clearHoveredTableCell();
|
|
22325
22478
|
clearAllTableResizeHover();
|
|
@@ -22327,6 +22480,8 @@ function useTableRowResize({
|
|
|
22327
22480
|
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
22328
22481
|
const cleanup = import_react38.default.useCallback(() => {
|
|
22329
22482
|
stateRef.current = null;
|
|
22483
|
+
isRowResizingGlobal.active = false;
|
|
22484
|
+
document.body.style.userSelect = "";
|
|
22330
22485
|
document.body.style.cursor = "";
|
|
22331
22486
|
}, []);
|
|
22332
22487
|
return {
|
|
@@ -22375,11 +22530,21 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
22375
22530
|
guide.style.opacity = "0";
|
|
22376
22531
|
}
|
|
22377
22532
|
}, [getProseMirrorElement]);
|
|
22533
|
+
const hotspotTimerRef = (0, import_react39.useRef)(null);
|
|
22534
|
+
const activeHotspotKeyRef = (0, import_react39.useRef)(null);
|
|
22535
|
+
const clearHotspotTimer = import_react39.default.useCallback(() => {
|
|
22536
|
+
if (hotspotTimerRef.current !== null) {
|
|
22537
|
+
window.clearTimeout(hotspotTimerRef.current);
|
|
22538
|
+
hotspotTimerRef.current = null;
|
|
22539
|
+
}
|
|
22540
|
+
}, []);
|
|
22378
22541
|
const clearAllTableResizeHover = import_react39.default.useCallback(() => {
|
|
22542
|
+
clearHotspotTimer();
|
|
22543
|
+
activeHotspotKeyRef.current = null;
|
|
22379
22544
|
setEditorResizeCursor("");
|
|
22380
22545
|
hideColumnGuide();
|
|
22381
22546
|
hideRowGuide();
|
|
22382
|
-
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
22547
|
+
}, [clearHotspotTimer, hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
22383
22548
|
const updateActiveCellHighlight = import_react39.default.useCallback((cell) => {
|
|
22384
22549
|
const surface = editorContentRef.current;
|
|
22385
22550
|
const highlight = activeTableCellHighlightRef.current;
|
|
@@ -22518,6 +22683,10 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
22518
22683
|
if (syncActiveRowResizeGuide()) {
|
|
22519
22684
|
return;
|
|
22520
22685
|
}
|
|
22686
|
+
if (event.buttons !== 0) {
|
|
22687
|
+
clearAllTableResizeHover();
|
|
22688
|
+
return;
|
|
22689
|
+
}
|
|
22521
22690
|
const target = resolveEventElement(event.target);
|
|
22522
22691
|
if (!(target instanceof Element)) {
|
|
22523
22692
|
clearAllTableResizeHover();
|
|
@@ -22537,18 +22706,46 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
22537
22706
|
clearAllTableResizeHover();
|
|
22538
22707
|
return;
|
|
22539
22708
|
}
|
|
22540
|
-
const
|
|
22541
|
-
const
|
|
22542
|
-
if (
|
|
22543
|
-
|
|
22544
|
-
|
|
22709
|
+
const rowTarget = resolveRowResizeTarget(cell, event.clientX, event.clientY);
|
|
22710
|
+
const colTarget = resolveColumnResizeTarget(cell, event.clientX, event.clientY);
|
|
22711
|
+
if (rowTarget) {
|
|
22712
|
+
const hotspotKey = `row:${rowTarget.row.rowIndex}-${rowTarget.cell.cellIndex}`;
|
|
22713
|
+
if (activeHotspotKeyRef.current === hotspotKey) {
|
|
22714
|
+
hideColumnGuide();
|
|
22715
|
+
showRowGuide(table, rowTarget.row, rowTarget.cell);
|
|
22716
|
+
return;
|
|
22717
|
+
}
|
|
22718
|
+
if (activeHotspotKeyRef.current !== hotspotKey) {
|
|
22719
|
+
clearHotspotTimer();
|
|
22720
|
+
activeHotspotKeyRef.current = hotspotKey;
|
|
22721
|
+
hotspotTimerRef.current = window.setTimeout(() => {
|
|
22722
|
+
hotspotTimerRef.current = null;
|
|
22723
|
+
hideColumnGuide();
|
|
22724
|
+
showRowGuide(table, rowTarget.row, rowTarget.cell);
|
|
22725
|
+
}, 100);
|
|
22726
|
+
}
|
|
22545
22727
|
return;
|
|
22546
22728
|
}
|
|
22547
|
-
if (
|
|
22548
|
-
|
|
22549
|
-
|
|
22729
|
+
if (colTarget) {
|
|
22730
|
+
const hotspotKey = `col:${colTarget.row.rowIndex}-${colTarget.cell.cellIndex}`;
|
|
22731
|
+
if (activeHotspotKeyRef.current === hotspotKey) {
|
|
22732
|
+
hideRowGuide();
|
|
22733
|
+
showColumnGuide(table, colTarget.row, colTarget.cell);
|
|
22734
|
+
return;
|
|
22735
|
+
}
|
|
22736
|
+
if (activeHotspotKeyRef.current !== hotspotKey) {
|
|
22737
|
+
clearHotspotTimer();
|
|
22738
|
+
activeHotspotKeyRef.current = hotspotKey;
|
|
22739
|
+
hotspotTimerRef.current = window.setTimeout(() => {
|
|
22740
|
+
hotspotTimerRef.current = null;
|
|
22741
|
+
hideRowGuide();
|
|
22742
|
+
showColumnGuide(table, colTarget.row, colTarget.cell);
|
|
22743
|
+
}, 100);
|
|
22744
|
+
}
|
|
22550
22745
|
return;
|
|
22551
22746
|
}
|
|
22747
|
+
clearHotspotTimer();
|
|
22748
|
+
activeHotspotKeyRef.current = null;
|
|
22552
22749
|
clearAllTableResizeHover();
|
|
22553
22750
|
};
|
|
22554
22751
|
const handleEditorMouseLeave = () => {
|
|
@@ -22569,15 +22766,22 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
22569
22766
|
clearActiveTableCell();
|
|
22570
22767
|
return;
|
|
22571
22768
|
}
|
|
22572
|
-
setActiveTableCell(cell);
|
|
22573
|
-
scheduleActiveCellSync(cell);
|
|
22574
22769
|
const row = cell.closest("tr");
|
|
22575
22770
|
const table = cell.closest("table");
|
|
22576
22771
|
if (!(row instanceof HTMLTableRowElement) || !(table instanceof HTMLTableElement)) return;
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22772
|
+
const rowTarget = resolveRowResizeTarget(cell, event.clientX, event.clientY);
|
|
22773
|
+
if (rowTarget) {
|
|
22774
|
+
event.preventDefault();
|
|
22775
|
+
event.stopPropagation();
|
|
22776
|
+
window.getSelection()?.removeAllRanges();
|
|
22777
|
+
if (beginResize(event, table, rowTarget.row, rowTarget.cell)) {
|
|
22778
|
+
suppressActiveCellHighlightRef.current = true;
|
|
22779
|
+
updateActiveCellHighlight(null);
|
|
22780
|
+
return;
|
|
22781
|
+
}
|
|
22580
22782
|
}
|
|
22783
|
+
setActiveTableCell(cell);
|
|
22784
|
+
scheduleActiveCellSync(cell);
|
|
22581
22785
|
};
|
|
22582
22786
|
const handlePointerMove = (event) => {
|
|
22583
22787
|
handleRowResizePointerMove(event);
|
|
@@ -22666,8 +22870,9 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
22666
22870
|
clearActiveTableCell();
|
|
22667
22871
|
clearHoveredTableCell();
|
|
22668
22872
|
clearAllTableResizeHover();
|
|
22873
|
+
clearHotspotTimer();
|
|
22669
22874
|
};
|
|
22670
|
-
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, scheduleTableLayoutSync, setActiveTableCell, setHoveredTableCell, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
22875
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHotspotTimer, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, scheduleTableLayoutSync, setActiveTableCell, setHoveredTableCell, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
22671
22876
|
return {
|
|
22672
22877
|
editorContentRef,
|
|
22673
22878
|
tableColumnGuideRef,
|
|
@@ -23429,6 +23634,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23429
23634
|
variant = "default",
|
|
23430
23635
|
rounded = true,
|
|
23431
23636
|
fontFamilies,
|
|
23637
|
+
defaultFontFamily = "Inter",
|
|
23432
23638
|
fontSizes,
|
|
23433
23639
|
lineHeights,
|
|
23434
23640
|
letterSpacings,
|
|
@@ -23737,6 +23943,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23737
23943
|
maxImageFileSize,
|
|
23738
23944
|
allowedImageMimeTypes,
|
|
23739
23945
|
fontFamilies,
|
|
23946
|
+
defaultFontFamily,
|
|
23740
23947
|
fontSizes,
|
|
23741
23948
|
lineHeights,
|
|
23742
23949
|
letterSpacings
|
|
@@ -23762,6 +23969,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23762
23969
|
},
|
|
23763
23970
|
className: "relative flex-1 overflow-y-auto",
|
|
23764
23971
|
style: {
|
|
23972
|
+
fontFamily: defaultFontFamily,
|
|
23765
23973
|
minHeight: editable ? minHeight : void 0,
|
|
23766
23974
|
maxHeight
|
|
23767
23975
|
},
|
|
@@ -23771,7 +23979,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23771
23979
|
{
|
|
23772
23980
|
ref: tableColumnGuideRef,
|
|
23773
23981
|
"aria-hidden": "true",
|
|
23774
|
-
className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
|
|
23982
|
+
className: "pointer-events-none absolute z-20 bg-primary/50 opacity-0 transition-opacity duration-200 delay-100 ease-out"
|
|
23775
23983
|
}
|
|
23776
23984
|
),
|
|
23777
23985
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -23779,7 +23987,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23779
23987
|
{
|
|
23780
23988
|
ref: tableRowGuideRef,
|
|
23781
23989
|
"aria-hidden": "true",
|
|
23782
|
-
className: "pointer-events-none absolute z-20 bg-primary opacity-0 transition-opacity duration-100"
|
|
23990
|
+
className: "pointer-events-none absolute z-20 bg-primary/50 opacity-0 transition-opacity duration-200 delay-100 ease-out"
|
|
23783
23991
|
}
|
|
23784
23992
|
),
|
|
23785
23993
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -23788,7 +23996,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23788
23996
|
ref: activeTableCellHighlightRef,
|
|
23789
23997
|
"aria-hidden": "true",
|
|
23790
23998
|
"data-ueditor-active-cell-highlight": "",
|
|
23791
|
-
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border
|
|
23999
|
+
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border border-primary/50 bg-primary/5"
|
|
23792
24000
|
}
|
|
23793
24001
|
),
|
|
23794
24002
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|