@underverse-ui/underverse 1.0.204 → 1.0.206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-reference.json +1 -1
- package/dist/{EmojiPicker-UN6N7YVB.js → EmojiPicker-FEJJDAWZ.js} +4 -4
- package/dist/{chunk-CC3QO2YM.js → chunk-4E43DRP2.js} +243 -57
- package/dist/chunk-4E43DRP2.js.map +1 -0
- package/dist/{chunk-KFTYWTJR.js → chunk-AMAILXHP.js} +81 -36
- package/dist/chunk-AMAILXHP.js.map +1 -0
- package/dist/{chunk-GSBRTFP2.js → chunk-BRDGIALS.js} +28 -17
- package/dist/chunk-BRDGIALS.js.map +1 -0
- package/dist/{chunk-ZUAIBY2Z.js → chunk-CYCBSKWI.js} +2 -2
- package/dist/{chunk-CKKLFVOY.js → chunk-F6A7HJE4.js} +3 -3
- package/dist/{chunk-QVQTWZ24.js → chunk-GKY5DHGR.js} +3 -3
- package/dist/index.cjs +328 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +6 -6
- package/dist/{menu-bar-6U5S4PS7.js → menu-bar-6GS5LLTD.js} +4 -4
- package/dist/ueditor.cjs +338 -101
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.d.cts +6 -0
- package/dist/ueditor.d.ts +6 -0
- package/dist/ueditor.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-CC3QO2YM.js.map +0 -1
- package/dist/chunk-GSBRTFP2.js.map +0 -1
- package/dist/chunk-KFTYWTJR.js.map +0 -1
- /package/dist/{EmojiPicker-UN6N7YVB.js.map → EmojiPicker-FEJJDAWZ.js.map} +0 -0
- /package/dist/{chunk-ZUAIBY2Z.js.map → chunk-CYCBSKWI.js.map} +0 -0
- /package/dist/{chunk-CKKLFVOY.js.map → chunk-F6A7HJE4.js.map} +0 -0
- /package/dist/{chunk-QVQTWZ24.js.map → chunk-GKY5DHGR.js.map} +0 -0
- /package/dist/{menu-bar-6U5S4PS7.js.map → menu-bar-6GS5LLTD.js.map} +0 -0
package/dist/ueditor.cjs
CHANGED
|
@@ -378,7 +378,9 @@ var init_en = __esm({
|
|
|
378
378
|
alignVerticalBottom: "Bottom Align",
|
|
379
379
|
textDirection: "Text Direction",
|
|
380
380
|
horizontalText: "Horizontal Text",
|
|
381
|
-
verticalText: "Vertical Text"
|
|
381
|
+
verticalText: "Vertical Text",
|
|
382
|
+
wrapText: "Wrap Text",
|
|
383
|
+
noWrapText: "Don't Wrap Text"
|
|
382
384
|
},
|
|
383
385
|
callout: {
|
|
384
386
|
selectEmoji: "Select Emoji",
|
|
@@ -834,7 +836,9 @@ var init_vi = __esm({
|
|
|
834
836
|
alignVerticalBottom: "C\u0103n d\u01B0\u1EDBi",
|
|
835
837
|
textDirection: "H\u01B0\u1EDBng ch\u1EEF",
|
|
836
838
|
horizontalText: "Ch\u1EEF ngang",
|
|
837
|
-
verticalText: "Ch\u1EEF d\u1ECDc"
|
|
839
|
+
verticalText: "Ch\u1EEF d\u1ECDc",
|
|
840
|
+
wrapText: "T\u1EF1 xu\u1ED1ng d\xF2ng",
|
|
841
|
+
noWrapText: "Kh\xF4ng xu\u1ED1ng d\xF2ng"
|
|
838
842
|
},
|
|
839
843
|
callout: {
|
|
840
844
|
selectEmoji: "Ch\u1ECDn Bi\u1EC3u t\u01B0\u1EE3ng",
|
|
@@ -1290,7 +1294,9 @@ var init_ko = __esm({
|
|
|
1290
1294
|
alignVerticalBottom: "\uC544\uB798\uCABD \uB9DE\uCDA4",
|
|
1291
1295
|
textDirection: "\uD14D\uC2A4\uD2B8 \uBC29\uD5A5",
|
|
1292
1296
|
horizontalText: "\uAC00\uB85C\uC4F0\uAE30",
|
|
1293
|
-
verticalText: "\uC138\uB85C\uC4F0\uAE30"
|
|
1297
|
+
verticalText: "\uC138\uB85C\uC4F0\uAE30",
|
|
1298
|
+
wrapText: "\uD14D\uC2A4\uD2B8 \uC904 \uBC14\uAFC8",
|
|
1299
|
+
noWrapText: "\uC904 \uBC14\uAFC8 \uC548 \uD568"
|
|
1294
1300
|
},
|
|
1295
1301
|
callout: {
|
|
1296
1302
|
selectEmoji: "\uC774\uBAA8\uC9C0 \uC120\uD0DD",
|
|
@@ -1746,7 +1752,9 @@ var init_ja = __esm({
|
|
|
1746
1752
|
alignVerticalBottom: "\u4E0B\u63C3\u3048",
|
|
1747
1753
|
textDirection: "\u6587\u5B57\u65B9\u5411",
|
|
1748
1754
|
horizontalText: "\u6A2A\u66F8\u304D",
|
|
1749
|
-
verticalText: "\u7E26\u66F8\u304D"
|
|
1755
|
+
verticalText: "\u7E26\u66F8\u304D",
|
|
1756
|
+
wrapText: "\u30C6\u30AD\u30B9\u30C8\u3092\u6298\u308A\u8FD4\u3059",
|
|
1757
|
+
noWrapText: "\u6298\u308A\u8FD4\u3055\u306A\u3044"
|
|
1750
1758
|
},
|
|
1751
1759
|
callout: {
|
|
1752
1760
|
selectEmoji: "\u7D75\u6587\u5B57\u3092\u9078\u629E",
|
|
@@ -1911,12 +1919,14 @@ var init_TranslationContext = __esm({
|
|
|
1911
1919
|
TranslationContext = React2.createContext(null);
|
|
1912
1920
|
useUnderverseTranslations = (namespace) => {
|
|
1913
1921
|
const context = React2.useContext(TranslationContext);
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
return
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1922
|
+
return React2.useMemo(() => {
|
|
1923
|
+
if (!context) {
|
|
1924
|
+
return (key) => {
|
|
1925
|
+
return getUnderverseDefaultTranslation("en", namespace, key);
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
return context.t(namespace);
|
|
1929
|
+
}, [context, namespace]);
|
|
1920
1930
|
};
|
|
1921
1931
|
useUnderverseLocale = () => {
|
|
1922
1932
|
const context = React2.useContext(TranslationContext);
|
|
@@ -1982,10 +1992,10 @@ function useSmartTranslations(namespace) {
|
|
|
1982
1992
|
setEnvironmentLocale(detected);
|
|
1983
1993
|
}
|
|
1984
1994
|
}, [forceInternal, internalLocale, nextIntlBridge]);
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1995
|
+
return React4.useCallback((key) => {
|
|
1996
|
+
if (forceInternal) {
|
|
1997
|
+
return internalT(key);
|
|
1998
|
+
}
|
|
1989
1999
|
const resolvedEnvironmentLocale = environmentLocale && environmentLocale !== internalLocale ? environmentLocale : null;
|
|
1990
2000
|
const primaryLocale = nextIntlBridge?.locale ?? resolvedEnvironmentLocale ?? internalLocale;
|
|
1991
2001
|
const fallbackLocale = resolvedEnvironmentLocale && resolvedEnvironmentLocale !== primaryLocale ? resolvedEnvironmentLocale : null;
|
|
@@ -2014,7 +2024,7 @@ function useSmartTranslations(namespace) {
|
|
|
2014
2024
|
return internalValue;
|
|
2015
2025
|
}
|
|
2016
2026
|
return key;
|
|
2017
|
-
};
|
|
2027
|
+
}, [environmentLocale, forceInternal, internalLocale, internalT, namespace, nextIntlBridge]);
|
|
2018
2028
|
}
|
|
2019
2029
|
var React4, import_jsx_runtime4, ForceInternalContext;
|
|
2020
2030
|
var init_useSmartTranslations = __esm({
|
|
@@ -4993,6 +5003,25 @@ function resolveEventElement(target) {
|
|
|
4993
5003
|
if (target instanceof Node) return target.parentElement;
|
|
4994
5004
|
return null;
|
|
4995
5005
|
}
|
|
5006
|
+
function isPointOverRenderedText(root, clientX, clientY) {
|
|
5007
|
+
const view = root.ownerDocument.defaultView;
|
|
5008
|
+
if (!view) return false;
|
|
5009
|
+
const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
|
|
5010
|
+
let textNode = walker.nextNode();
|
|
5011
|
+
while (textNode) {
|
|
5012
|
+
if (textNode.textContent?.length) {
|
|
5013
|
+
const range = root.ownerDocument.createRange();
|
|
5014
|
+
range.selectNodeContents(textNode);
|
|
5015
|
+
const textRects = Array.from(range.getClientRects());
|
|
5016
|
+
range.detach?.();
|
|
5017
|
+
if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
|
|
5018
|
+
return true;
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
5021
|
+
textNode = walker.nextNode();
|
|
5022
|
+
}
|
|
5023
|
+
return false;
|
|
5024
|
+
}
|
|
4996
5025
|
function getSelectionTableCell(view) {
|
|
4997
5026
|
const browserSelection = window.getSelection();
|
|
4998
5027
|
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
@@ -5116,16 +5145,19 @@ function applyTableAlignment(editor, tableAlign, anchorPos) {
|
|
|
5116
5145
|
const tableDom = editor.view.nodeDOM(tableInfo.pos);
|
|
5117
5146
|
const tableElement = domAtTableElement?.closest?.("table") ?? (tableDom instanceof HTMLTableElement ? tableDom : tableDom instanceof HTMLElement ? tableDom.querySelector("table") : null) ?? (editor.view.dom.querySelectorAll("table").length === 1 ? editor.view.dom.querySelector("table") : null);
|
|
5118
5147
|
if (tableElement instanceof HTMLTableElement) {
|
|
5148
|
+
tableElement.style.tableLayout = "fixed";
|
|
5149
|
+
if (tableElement.style.width === "max-content") {
|
|
5150
|
+
tableElement.style.removeProperty("width");
|
|
5151
|
+
}
|
|
5152
|
+
if (tableElement.style.maxWidth === "100%") {
|
|
5153
|
+
tableElement.style.removeProperty("max-width");
|
|
5154
|
+
}
|
|
5119
5155
|
if (tableAlign) {
|
|
5120
5156
|
tableElement.setAttribute("data-table-align", tableAlign);
|
|
5121
|
-
tableElement.style.width = "max-content";
|
|
5122
|
-
tableElement.style.maxWidth = "100%";
|
|
5123
5157
|
tableElement.style.marginLeft = tableAlign === "center" || tableAlign === "right" ? "auto" : "0";
|
|
5124
5158
|
tableElement.style.marginRight = tableAlign === "center" ? "auto" : tableAlign === "right" ? "0" : "auto";
|
|
5125
5159
|
} else {
|
|
5126
5160
|
tableElement.removeAttribute("data-table-align");
|
|
5127
|
-
tableElement.style.removeProperty("width");
|
|
5128
|
-
tableElement.style.removeProperty("max-width");
|
|
5129
5161
|
tableElement.style.removeProperty("margin-left");
|
|
5130
5162
|
tableElement.style.removeProperty("margin-right");
|
|
5131
5163
|
}
|
|
@@ -6640,6 +6672,7 @@ function computeEditorUiRenderState(editor) {
|
|
|
6640
6672
|
formula: tableCell.formula ?? tableHeader.formula ?? null,
|
|
6641
6673
|
numberFormat: tableCell.numberFormat ?? tableHeader.numberFormat ?? null,
|
|
6642
6674
|
textDirection: tableCell.textDirection ?? tableHeader.textDirection ?? null,
|
|
6675
|
+
textWrap: tableCell.textWrap ?? tableHeader.textWrap ?? "wrap",
|
|
6643
6676
|
verticalAlign: tableCell.verticalAlign ?? tableHeader.verticalAlign ?? null
|
|
6644
6677
|
},
|
|
6645
6678
|
can: {
|
|
@@ -6851,6 +6884,7 @@ var init_toolbar = __esm({
|
|
|
6851
6884
|
const canSplitCell = hasTableContext && editor.can().splitCell();
|
|
6852
6885
|
const currentCellVerticalAlign = normalizeStyleValue(editor.getAttributes("tableCell").verticalAlign || editor.getAttributes("tableHeader").verticalAlign) || "";
|
|
6853
6886
|
const currentCellTextDirection = normalizeStyleValue(editor.getAttributes("tableCell").textDirection || editor.getAttributes("tableHeader").textDirection) || "horizontal";
|
|
6887
|
+
const currentCellTextWrap = normalizeStyleValue(editor.getAttributes("tableCell").textWrap || editor.getAttributes("tableHeader").textWrap) || "wrap";
|
|
6854
6888
|
const currentFontFamily = normalizeStyleValue(textStyleAttrs.fontFamily);
|
|
6855
6889
|
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
6856
6890
|
const currentTextColor = normalizeStyleValue(textStyleAttrs.color) || "inherit";
|
|
@@ -7361,33 +7395,44 @@ var init_toolbar = __esm({
|
|
|
7361
7395
|
]
|
|
7362
7396
|
}
|
|
7363
7397
|
),
|
|
7364
|
-
hasTableContext && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7398
|
+
hasTableContext && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
7399
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
7400
|
+
DropdownMenu,
|
|
7401
|
+
{
|
|
7402
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarButton, { onClick: () => {
|
|
7403
|
+
}, title: t("tableMenu.textDirection"), children: currentCellTextDirection === "vertical" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react13.ArrowDown, { className: "w-4 h-4" }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react13.ArrowRight, { className: "w-4 h-4" }) }),
|
|
7404
|
+
children: [
|
|
7405
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7406
|
+
DropdownMenuItem,
|
|
7407
|
+
{
|
|
7408
|
+
icon: import_lucide_react13.ArrowRight,
|
|
7409
|
+
label: t("tableMenu.horizontalText"),
|
|
7410
|
+
onClick: () => applyTableCellAttribute(editor, "textDirection", null),
|
|
7411
|
+
active: currentCellTextDirection === "horizontal"
|
|
7412
|
+
}
|
|
7413
|
+
),
|
|
7414
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7415
|
+
DropdownMenuItem,
|
|
7416
|
+
{
|
|
7417
|
+
icon: import_lucide_react13.ArrowDown,
|
|
7418
|
+
label: t("tableMenu.verticalText"),
|
|
7419
|
+
onClick: () => applyTableCellAttribute(editor, "textDirection", "vertical"),
|
|
7420
|
+
active: currentCellTextDirection === "vertical"
|
|
7421
|
+
}
|
|
7422
|
+
)
|
|
7423
|
+
]
|
|
7424
|
+
}
|
|
7425
|
+
),
|
|
7426
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
7427
|
+
ToolbarButton,
|
|
7428
|
+
{
|
|
7429
|
+
onClick: () => applyTableCellAttribute(editor, "textWrap", currentCellTextWrap === "nowrap" ? "wrap" : "nowrap"),
|
|
7430
|
+
active: currentCellTextWrap !== "nowrap",
|
|
7431
|
+
title: currentCellTextWrap === "nowrap" ? t("tableMenu.wrapText") : t("tableMenu.noWrapText"),
|
|
7432
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react13.WrapText, { className: "h-4 w-4" })
|
|
7433
|
+
}
|
|
7434
|
+
)
|
|
7435
|
+
] })
|
|
7391
7436
|
] }),
|
|
7392
7437
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToolbarDivider, {}),
|
|
7393
7438
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
@@ -7774,8 +7819,6 @@ var init_editor_styles = __esm({
|
|
|
7774
7819
|
"[&_table]:table-fixed",
|
|
7775
7820
|
"[&_table]:overflow-hidden",
|
|
7776
7821
|
"[&_table]:select-text",
|
|
7777
|
-
"[&_table[data-table-align]]:w-max",
|
|
7778
|
-
"[&_table[data-table-align]]:max-w-full",
|
|
7779
7822
|
"[&_table[data-table-align='center']]:mx-auto",
|
|
7780
7823
|
"[&_table[data-table-align='right']]:ml-auto",
|
|
7781
7824
|
"[&_table[data-table-align='right']]:mr-0",
|
|
@@ -7785,6 +7828,11 @@ var init_editor_styles = __esm({
|
|
|
7785
7828
|
"[&_td]:select-text",
|
|
7786
7829
|
"[&_td]:px-2",
|
|
7787
7830
|
"[&_td]:py-0",
|
|
7831
|
+
"[&_td]:whitespace-normal",
|
|
7832
|
+
"[&_td]:[overflow-wrap:anywhere]",
|
|
7833
|
+
"[&_td]:[word-break:normal]",
|
|
7834
|
+
"[&_td[data-text-wrap='nowrap']]:whitespace-nowrap",
|
|
7835
|
+
"[&_td[data-text-wrap='nowrap']]:[overflow-wrap:normal]",
|
|
7788
7836
|
"[&_td_p]:my-0",
|
|
7789
7837
|
"[&_th]:relative",
|
|
7790
7838
|
"[&_th]:align-top",
|
|
@@ -7792,6 +7840,11 @@ var init_editor_styles = __esm({
|
|
|
7792
7840
|
"[&_th]:select-text",
|
|
7793
7841
|
"[&_th]:px-2",
|
|
7794
7842
|
"[&_th]:py-0",
|
|
7843
|
+
"[&_th]:whitespace-normal",
|
|
7844
|
+
"[&_th]:[overflow-wrap:anywhere]",
|
|
7845
|
+
"[&_th]:[word-break:normal]",
|
|
7846
|
+
"[&_th[data-text-wrap='nowrap']]:whitespace-nowrap",
|
|
7847
|
+
"[&_th[data-text-wrap='nowrap']]:[overflow-wrap:normal]",
|
|
7795
7848
|
"[&_th_p]:my-0",
|
|
7796
7849
|
"[&_td[data-formula]]:pr-7",
|
|
7797
7850
|
"[&_th[data-formula]]:pr-7",
|
|
@@ -7925,12 +7978,12 @@ var init_editor_styles = __esm({
|
|
|
7925
7978
|
});
|
|
7926
7979
|
|
|
7927
7980
|
// src/components/Modal.tsx
|
|
7928
|
-
var
|
|
7981
|
+
var React29, import_react_dom4, import_lucide_react20, import_jsx_runtime35, sizeStyles, Modal, Modal_default;
|
|
7929
7982
|
var init_Modal = __esm({
|
|
7930
7983
|
"src/components/Modal.tsx"() {
|
|
7931
7984
|
"use strict";
|
|
7932
7985
|
"use client";
|
|
7933
|
-
|
|
7986
|
+
React29 = __toESM(require("react"), 1);
|
|
7934
7987
|
import_react_dom4 = require("react-dom");
|
|
7935
7988
|
init_cn();
|
|
7936
7989
|
import_lucide_react20 = require("lucide-react");
|
|
@@ -7967,17 +8020,17 @@ var init_Modal = __esm({
|
|
|
7967
8020
|
const gi18n = useGlobalI18n();
|
|
7968
8021
|
const globalConfig = useUnderverseUIConfig();
|
|
7969
8022
|
const resolvedBorderMode = borderMode ?? globalConfig.borderMode;
|
|
7970
|
-
const [isMounted, setIsMounted] =
|
|
7971
|
-
const [isVisible, setIsVisible] =
|
|
7972
|
-
const [isAnimating, setIsAnimating] =
|
|
7973
|
-
const mouseDownTarget =
|
|
7974
|
-
const modalContentRef =
|
|
7975
|
-
|
|
8023
|
+
const [isMounted, setIsMounted] = React29.useState(false);
|
|
8024
|
+
const [isVisible, setIsVisible] = React29.useState(false);
|
|
8025
|
+
const [isAnimating, setIsAnimating] = React29.useState(true);
|
|
8026
|
+
const mouseDownTarget = React29.useRef(null);
|
|
8027
|
+
const modalContentRef = React29.useRef(null);
|
|
8028
|
+
React29.useEffect(() => {
|
|
7976
8029
|
setIsMounted(true);
|
|
7977
8030
|
return () => setIsMounted(false);
|
|
7978
8031
|
}, []);
|
|
7979
|
-
const animationRef =
|
|
7980
|
-
|
|
8032
|
+
const animationRef = React29.useRef(false);
|
|
8033
|
+
React29.useEffect(() => {
|
|
7981
8034
|
if (isOpen) {
|
|
7982
8035
|
if (animationRef.current) return;
|
|
7983
8036
|
animationRef.current = true;
|
|
@@ -7997,7 +8050,7 @@ var init_Modal = __esm({
|
|
|
7997
8050
|
}
|
|
7998
8051
|
}
|
|
7999
8052
|
}, [isOpen, isVisible]);
|
|
8000
|
-
|
|
8053
|
+
React29.useEffect(() => {
|
|
8001
8054
|
if (!isOpen || !closeOnEsc) return;
|
|
8002
8055
|
const handleEscape = (event) => {
|
|
8003
8056
|
if (event.key === "Escape") {
|
|
@@ -8007,7 +8060,7 @@ var init_Modal = __esm({
|
|
|
8007
8060
|
document.addEventListener("keydown", handleEscape);
|
|
8008
8061
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
8009
8062
|
}, [isOpen, closeOnEsc, onClose]);
|
|
8010
|
-
|
|
8063
|
+
React29.useEffect(() => {
|
|
8011
8064
|
if (isOpen) {
|
|
8012
8065
|
document.body.style.overflow = "hidden";
|
|
8013
8066
|
} else {
|
|
@@ -9049,7 +9102,7 @@ var import_react45 = require("@tiptap/react");
|
|
|
9049
9102
|
init_cn();
|
|
9050
9103
|
|
|
9051
9104
|
// src/components/UEditor/extensions.ts
|
|
9052
|
-
var
|
|
9105
|
+
var import_core20 = require("@tiptap/core");
|
|
9053
9106
|
var import_extension_document = require("@tiptap/extension-document");
|
|
9054
9107
|
var import_extension_paragraph = require("@tiptap/extension-paragraph");
|
|
9055
9108
|
var import_extension_text = require("@tiptap/extension-text");
|
|
@@ -9066,7 +9119,7 @@ var import_extension_task_list = require("@tiptap/extension-task-list");
|
|
|
9066
9119
|
var import_extension_task_item = require("@tiptap/extension-task-item");
|
|
9067
9120
|
var import_extension_blockquote = require("@tiptap/extension-blockquote");
|
|
9068
9121
|
var import_extension_code = require("@tiptap/extension-code");
|
|
9069
|
-
var
|
|
9122
|
+
var import_core21 = require("@tiptap/core");
|
|
9070
9123
|
var import_react28 = require("@tiptap/react");
|
|
9071
9124
|
|
|
9072
9125
|
// src/components/UEditor/callout.ts
|
|
@@ -11889,6 +11942,7 @@ var Indent = import_core16.Extension.create({
|
|
|
11889
11942
|
var indent_default = Indent;
|
|
11890
11943
|
|
|
11891
11944
|
// src/components/UEditor/table-align.ts
|
|
11945
|
+
var import_core17 = require("@tiptap/core");
|
|
11892
11946
|
var import_extension_table = require("@tiptap/extension-table");
|
|
11893
11947
|
var import_state7 = require("@tiptap/pm/state");
|
|
11894
11948
|
var import_tables3 = require("@tiptap/pm/tables");
|
|
@@ -11899,12 +11953,13 @@ var import_view2 = require("@tiptap/pm/view");
|
|
|
11899
11953
|
var import_tables2 = require("@tiptap/pm/tables");
|
|
11900
11954
|
var DEFAULT_TABLE_COLUMN_WIDTH = 100;
|
|
11901
11955
|
var MIN_RESIZED_TABLE_COLUMN_WIDTH = 25;
|
|
11902
|
-
function
|
|
11903
|
-
|
|
11956
|
+
function getColumnResizeMinWidth(configuredMinWidth) {
|
|
11957
|
+
const normalizedMinWidth = Number.isFinite(configuredMinWidth) && configuredMinWidth > 0 ? Math.round(configuredMinWidth) : MIN_RESIZED_TABLE_COLUMN_WIDTH;
|
|
11958
|
+
return Math.max(MIN_RESIZED_TABLE_COLUMN_WIDTH, normalizedMinWidth);
|
|
11904
11959
|
}
|
|
11905
11960
|
function setColumnStyle(column, width) {
|
|
11906
11961
|
if (width == null) {
|
|
11907
|
-
column.style.width =
|
|
11962
|
+
column.style.width = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
|
|
11908
11963
|
column.style.minWidth = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
|
|
11909
11964
|
return;
|
|
11910
11965
|
}
|
|
@@ -11916,7 +11971,6 @@ function isTableColumnElement(node) {
|
|
|
11916
11971
|
}
|
|
11917
11972
|
function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue) {
|
|
11918
11973
|
let totalWidth = 0;
|
|
11919
|
-
let fixedWidth = true;
|
|
11920
11974
|
let nextDOM = colgroup.firstChild;
|
|
11921
11975
|
const row = node.firstChild;
|
|
11922
11976
|
if (row) {
|
|
@@ -11926,9 +11980,6 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
|
|
|
11926
11980
|
const rawWidth = overrideCol === col ? overrideValue : colwidth?.[spanIndex];
|
|
11927
11981
|
const width = rawWidth ? Math.max(rawWidth, MIN_RESIZED_TABLE_COLUMN_WIDTH) : null;
|
|
11928
11982
|
totalWidth += width ?? DEFAULT_TABLE_COLUMN_WIDTH;
|
|
11929
|
-
if (!width) {
|
|
11930
|
-
fixedWidth = false;
|
|
11931
|
-
}
|
|
11932
11983
|
const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(document.createElement("col"));
|
|
11933
11984
|
setColumnStyle(colElement, width);
|
|
11934
11985
|
nextDOM = colElement.nextSibling;
|
|
@@ -11941,11 +11992,10 @@ function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue)
|
|
|
11941
11992
|
nextDOM = after;
|
|
11942
11993
|
}
|
|
11943
11994
|
const hasUserWidth = typeof node.attrs.style === "string" && /\bwidth\s*:/i.test(node.attrs.style);
|
|
11944
|
-
if (
|
|
11995
|
+
if (!hasUserWidth) {
|
|
11945
11996
|
table.style.width = `${totalWidth}px`;
|
|
11946
11997
|
table.style.minWidth = "";
|
|
11947
11998
|
} else {
|
|
11948
|
-
table.style.width = "";
|
|
11949
11999
|
table.style.minWidth = `${totalWidth}px`;
|
|
11950
12000
|
}
|
|
11951
12001
|
}
|
|
@@ -11958,6 +12008,7 @@ var UEditorTableView = class {
|
|
|
11958
12008
|
if (node.attrs.style) {
|
|
11959
12009
|
this.table.style.cssText = node.attrs.style;
|
|
11960
12010
|
}
|
|
12011
|
+
this.table.style.tableLayout = "fixed";
|
|
11961
12012
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
11962
12013
|
updateDynamicColumns(node, this.colgroup, this.table);
|
|
11963
12014
|
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
@@ -12139,7 +12190,7 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
12139
12190
|
colspan: attrs.colspan ?? 1,
|
|
12140
12191
|
colwidth: attrs.colwidth
|
|
12141
12192
|
});
|
|
12142
|
-
const minWidth =
|
|
12193
|
+
const minWidth = getColumnResizeMinWidth(cellMinWidth);
|
|
12143
12194
|
const dragging = {
|
|
12144
12195
|
startX: event.clientX,
|
|
12145
12196
|
startWidth: width,
|
|
@@ -12268,15 +12319,37 @@ function parseTableAlign(element) {
|
|
|
12268
12319
|
function renderTableAlignStyle(tableAlign) {
|
|
12269
12320
|
switch (tableAlign) {
|
|
12270
12321
|
case "center":
|
|
12271
|
-
return "
|
|
12322
|
+
return "table-layout: fixed; margin-left: auto; margin-right: auto;";
|
|
12272
12323
|
case "right":
|
|
12273
|
-
return "
|
|
12324
|
+
return "table-layout: fixed; margin-left: auto; margin-right: 0;";
|
|
12274
12325
|
case "left":
|
|
12275
|
-
return "
|
|
12326
|
+
return "table-layout: fixed; margin-left: 0; margin-right: auto;";
|
|
12276
12327
|
default:
|
|
12277
12328
|
return "";
|
|
12278
12329
|
}
|
|
12279
12330
|
}
|
|
12331
|
+
function createUEditorColGroup(node) {
|
|
12332
|
+
const columns = [];
|
|
12333
|
+
let totalWidth = 0;
|
|
12334
|
+
const firstRow = node.firstChild;
|
|
12335
|
+
if (firstRow) {
|
|
12336
|
+
for (let cellIndex = 0; cellIndex < firstRow.childCount; cellIndex += 1) {
|
|
12337
|
+
const cell = firstRow.child(cellIndex);
|
|
12338
|
+
const colspan = Math.max(1, Number(cell.attrs.colspan) || 1);
|
|
12339
|
+
const colwidth = Array.isArray(cell.attrs.colwidth) ? cell.attrs.colwidth : [];
|
|
12340
|
+
for (let spanIndex = 0; spanIndex < colspan; spanIndex += 1) {
|
|
12341
|
+
const storedWidth = Number(colwidth[spanIndex]);
|
|
12342
|
+
const width = Number.isFinite(storedWidth) && storedWidth > 0 ? Math.max(MIN_RESIZED_TABLE_COLUMN_WIDTH, Math.round(storedWidth)) : DEFAULT_TABLE_COLUMN_WIDTH;
|
|
12343
|
+
totalWidth += width;
|
|
12344
|
+
columns.push(["col", { style: `width: ${width}px; min-width: ${width}px;`, width: String(width) }]);
|
|
12345
|
+
}
|
|
12346
|
+
}
|
|
12347
|
+
}
|
|
12348
|
+
return {
|
|
12349
|
+
colgroup: ["colgroup", {}, ...columns],
|
|
12350
|
+
tableWidth: totalWidth > 0 ? `${totalWidth}px` : ""
|
|
12351
|
+
};
|
|
12352
|
+
}
|
|
12280
12353
|
var UEditorTable = import_extension_table.Table.extend({
|
|
12281
12354
|
addGlobalAttributes() {
|
|
12282
12355
|
return [
|
|
@@ -12330,6 +12403,18 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
12330
12403
|
}
|
|
12331
12404
|
};
|
|
12332
12405
|
},
|
|
12406
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
12407
|
+
const { colgroup, tableWidth } = createUEditorColGroup(node);
|
|
12408
|
+
const table = [
|
|
12409
|
+
"table",
|
|
12410
|
+
(0, import_core17.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
|
|
12411
|
+
style: tableWidth ? `width: ${tableWidth};` : "table-layout: fixed;"
|
|
12412
|
+
}),
|
|
12413
|
+
colgroup,
|
|
12414
|
+
["tbody", 0]
|
|
12415
|
+
];
|
|
12416
|
+
return this.options.renderWrapper ? ["div", { class: "tableWrapper" }, table] : table;
|
|
12417
|
+
},
|
|
12333
12418
|
addProseMirrorPlugins() {
|
|
12334
12419
|
const isResizable = this.options.resizable && this.editor.isEditable;
|
|
12335
12420
|
return [
|
|
@@ -12483,7 +12568,7 @@ var CodeBlockView = ({
|
|
|
12483
12568
|
};
|
|
12484
12569
|
|
|
12485
12570
|
// src/components/UEditor/optimized-lowlight.ts
|
|
12486
|
-
var
|
|
12571
|
+
var import_core18 = require("@tiptap/core");
|
|
12487
12572
|
var import_state8 = require("@tiptap/pm/state");
|
|
12488
12573
|
var import_view3 = require("@tiptap/pm/view");
|
|
12489
12574
|
function parseHighlightNodes(nodes, inheritedClasses = []) {
|
|
@@ -12530,7 +12615,7 @@ function buildLowlightDecorations({
|
|
|
12530
12615
|
nodeName
|
|
12531
12616
|
}) {
|
|
12532
12617
|
const decorations = [];
|
|
12533
|
-
for (const block of (0,
|
|
12618
|
+
for (const block of (0, import_core18.findChildren)(doc, (node) => node.type.name === nodeName)) {
|
|
12534
12619
|
let from = block.pos + 1;
|
|
12535
12620
|
const language = block.node.attrs.language || defaultLanguage;
|
|
12536
12621
|
const result = highlightCode(lowlight, language, block.node.textContent);
|
|
@@ -12671,7 +12756,7 @@ function createOptimizedLowlightPlugin({
|
|
|
12671
12756
|
}
|
|
12672
12757
|
|
|
12673
12758
|
// src/components/UEditor/table-formula-recalculation.ts
|
|
12674
|
-
var
|
|
12759
|
+
var import_core19 = require("@tiptap/core");
|
|
12675
12760
|
var import_state11 = require("@tiptap/pm/state");
|
|
12676
12761
|
|
|
12677
12762
|
// src/components/UEditor/table-formula-commands.ts
|
|
@@ -13695,7 +13780,7 @@ function recalculateAllTableFormulas(editor) {
|
|
|
13695
13780
|
}
|
|
13696
13781
|
|
|
13697
13782
|
// src/components/UEditor/table-formula-recalculation.ts
|
|
13698
|
-
var TableFormulaRecalculation =
|
|
13783
|
+
var TableFormulaRecalculation = import_core19.Extension.create({
|
|
13699
13784
|
name: "tableFormulaRecalculation",
|
|
13700
13785
|
addProseMirrorPlugins() {
|
|
13701
13786
|
return [
|
|
@@ -13726,6 +13811,21 @@ function getFormulaStateAttributes(attributes) {
|
|
|
13726
13811
|
"data-formula-state": computedValue.startsWith("#") ? "error" : "computed"
|
|
13727
13812
|
};
|
|
13728
13813
|
}
|
|
13814
|
+
function normalizeTableCellTextWrap(value) {
|
|
13815
|
+
return value === "nowrap" ? "nowrap" : "wrap";
|
|
13816
|
+
}
|
|
13817
|
+
function parseTableCellTextWrap(element) {
|
|
13818
|
+
if (element.getAttribute("data-text-wrap") === "nowrap" || element.style.whiteSpace === "nowrap") {
|
|
13819
|
+
return "nowrap";
|
|
13820
|
+
}
|
|
13821
|
+
return "wrap";
|
|
13822
|
+
}
|
|
13823
|
+
function renderTableCellTextWrap(attributes) {
|
|
13824
|
+
return normalizeTableCellTextWrap(attributes.textWrap) === "nowrap" ? { "data-text-wrap": "nowrap" } : {};
|
|
13825
|
+
}
|
|
13826
|
+
function getTableCellTextWrapStyle(value) {
|
|
13827
|
+
return normalizeTableCellTextWrap(value) === "nowrap" ? "white-space: nowrap; overflow-wrap: normal; word-break: normal" : "white-space: normal; overflow-wrap: anywhere; word-break: normal";
|
|
13828
|
+
}
|
|
13729
13829
|
var CustomTableCell = import_extension_table_cell.TableCell.extend({
|
|
13730
13830
|
addAttributes() {
|
|
13731
13831
|
return {
|
|
@@ -13826,6 +13926,11 @@ var CustomTableCell = import_extension_table_cell.TableCell.extend({
|
|
|
13826
13926
|
default: null,
|
|
13827
13927
|
parseHTML: (element) => element.getAttribute("data-text-direction") === "vertical" || ["sideways-lr", "vertical-lr", "vertical-rl"].includes(element.style.writingMode) ? "vertical" : null,
|
|
13828
13928
|
renderHTML: (attributes) => attributes.textDirection === "vertical" ? { "data-text-direction": "vertical" } : {}
|
|
13929
|
+
},
|
|
13930
|
+
textWrap: {
|
|
13931
|
+
default: "wrap",
|
|
13932
|
+
parseHTML: parseTableCellTextWrap,
|
|
13933
|
+
renderHTML: renderTableCellTextWrap
|
|
13829
13934
|
}
|
|
13830
13935
|
};
|
|
13831
13936
|
},
|
|
@@ -13837,6 +13942,7 @@ var CustomTableCell = import_extension_table_cell.TableCell.extend({
|
|
|
13837
13942
|
const borderWidth = HTMLAttributes["data-border-width"];
|
|
13838
13943
|
const verticalAlign = HTMLAttributes["data-vertical-align"];
|
|
13839
13944
|
const textDirection = HTMLAttributes["data-text-direction"];
|
|
13945
|
+
const textWrap = HTMLAttributes["data-text-wrap"];
|
|
13840
13946
|
let mergedStyle = style;
|
|
13841
13947
|
if (bg) mergedStyle += `; background-color: ${bg}`;
|
|
13842
13948
|
if (borderColor) mergedStyle += `; border-color: ${borderColor}`;
|
|
@@ -13844,10 +13950,11 @@ var CustomTableCell = import_extension_table_cell.TableCell.extend({
|
|
|
13844
13950
|
if (borderWidth) mergedStyle += `; border-width: ${borderWidth}`;
|
|
13845
13951
|
if (verticalAlign) mergedStyle += `; vertical-align: ${verticalAlign}`;
|
|
13846
13952
|
if (textDirection === "vertical") mergedStyle += "; writing-mode: sideways-lr; text-orientation: mixed";
|
|
13953
|
+
mergedStyle += `; ${getTableCellTextWrapStyle(textWrap)}`;
|
|
13847
13954
|
mergedStyle = mergedStyle.replace(/^;/, "").trim();
|
|
13848
13955
|
return [
|
|
13849
13956
|
"td",
|
|
13850
|
-
(0,
|
|
13957
|
+
(0, import_core20.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
|
|
13851
13958
|
0
|
|
13852
13959
|
];
|
|
13853
13960
|
}
|
|
@@ -13952,6 +14059,11 @@ var CustomTableHeader = import_extension_table_header.TableHeader.extend({
|
|
|
13952
14059
|
default: null,
|
|
13953
14060
|
parseHTML: (element) => element.getAttribute("data-text-direction") === "vertical" || ["sideways-lr", "vertical-lr", "vertical-rl"].includes(element.style.writingMode) ? "vertical" : null,
|
|
13954
14061
|
renderHTML: (attributes) => attributes.textDirection === "vertical" ? { "data-text-direction": "vertical" } : {}
|
|
14062
|
+
},
|
|
14063
|
+
textWrap: {
|
|
14064
|
+
default: "wrap",
|
|
14065
|
+
parseHTML: parseTableCellTextWrap,
|
|
14066
|
+
renderHTML: renderTableCellTextWrap
|
|
13955
14067
|
}
|
|
13956
14068
|
};
|
|
13957
14069
|
},
|
|
@@ -13963,6 +14075,7 @@ var CustomTableHeader = import_extension_table_header.TableHeader.extend({
|
|
|
13963
14075
|
const borderWidth = HTMLAttributes["data-border-width"];
|
|
13964
14076
|
const verticalAlign = HTMLAttributes["data-vertical-align"];
|
|
13965
14077
|
const textDirection = HTMLAttributes["data-text-direction"];
|
|
14078
|
+
const textWrap = HTMLAttributes["data-text-wrap"];
|
|
13966
14079
|
let mergedStyle = style;
|
|
13967
14080
|
if (bg) mergedStyle += `; background-color: ${bg}`;
|
|
13968
14081
|
if (borderColor) mergedStyle += `; border-color: ${borderColor}`;
|
|
@@ -13970,10 +14083,11 @@ var CustomTableHeader = import_extension_table_header.TableHeader.extend({
|
|
|
13970
14083
|
if (borderWidth) mergedStyle += `; border-width: ${borderWidth}`;
|
|
13971
14084
|
if (verticalAlign) mergedStyle += `; vertical-align: ${verticalAlign}`;
|
|
13972
14085
|
if (textDirection === "vertical") mergedStyle += "; writing-mode: sideways-lr; text-orientation: mixed";
|
|
14086
|
+
mergedStyle += `; ${getTableCellTextWrapStyle(textWrap)}`;
|
|
13973
14087
|
mergedStyle = mergedStyle.replace(/^;/, "").trim();
|
|
13974
14088
|
return [
|
|
13975
14089
|
"th",
|
|
13976
|
-
(0,
|
|
14090
|
+
(0, import_core20.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, getFormulaStateAttributes(HTMLAttributes), mergedStyle ? { style: mergedStyle } : {}),
|
|
13977
14091
|
0
|
|
13978
14092
|
];
|
|
13979
14093
|
}
|
|
@@ -13981,15 +14095,15 @@ var CustomTableHeader = import_extension_table_header.TableHeader.extend({
|
|
|
13981
14095
|
var CustomTaskList = import_extension_task_list.TaskList.extend({
|
|
13982
14096
|
addInputRules() {
|
|
13983
14097
|
return [
|
|
13984
|
-
(0,
|
|
14098
|
+
(0, import_core21.wrappingInputRule)({
|
|
13985
14099
|
find: /^\s*(\[ \]|\[\])\s$/,
|
|
13986
14100
|
type: this.type
|
|
13987
14101
|
}),
|
|
13988
|
-
(0,
|
|
14102
|
+
(0, import_core21.wrappingInputRule)({
|
|
13989
14103
|
find: /^\s*(-\s*\[ \]|-\s*\[\])\s$/,
|
|
13990
14104
|
type: this.type
|
|
13991
14105
|
}),
|
|
13992
|
-
(0,
|
|
14106
|
+
(0, import_core21.wrappingInputRule)({
|
|
13993
14107
|
find: /^\s*(\*\s*\[ \]|-\s*\[\])\s$/,
|
|
13994
14108
|
type: this.type
|
|
13995
14109
|
})
|
|
@@ -14135,7 +14249,8 @@ function buildUEditorExtensions({
|
|
|
14135
14249
|
handleWidth: 10,
|
|
14136
14250
|
allowTableNodeSelection: true,
|
|
14137
14251
|
HTMLAttributes: {
|
|
14138
|
-
class: "border-collapse my-4"
|
|
14252
|
+
class: "border-collapse my-4",
|
|
14253
|
+
style: "table-layout: fixed;"
|
|
14139
14254
|
}
|
|
14140
14255
|
}),
|
|
14141
14256
|
table_row_default,
|
|
@@ -14548,6 +14663,7 @@ var BubbleMenuContent = ({
|
|
|
14548
14663
|
const [activeBorderPosition, setActiveBorderPosition] = (0, import_react35.useState)("all");
|
|
14549
14664
|
const currentCellVerticalAlign = normalizeStyleValue(editor.getAttributes("tableCell").verticalAlign || editor.getAttributes("tableHeader").verticalAlign) || "";
|
|
14550
14665
|
const currentCellTextDirection = normalizeStyleValue(editor.getAttributes("tableCell").textDirection || editor.getAttributes("tableHeader").textDirection) || "horizontal";
|
|
14666
|
+
const currentCellTextWrap = normalizeStyleValue(editor.getAttributes("tableCell").textWrap || editor.getAttributes("tableHeader").textWrap) || "wrap";
|
|
14551
14667
|
const isInTable3 = (0, import_tables8.isInTable)(editor.state);
|
|
14552
14668
|
const canMergeCells = isInTable3 && editor.can().mergeCells();
|
|
14553
14669
|
const canSplitCell = isInTable3 && editor.can().splitCell();
|
|
@@ -15208,6 +15324,20 @@ var BubbleMenuContent = ({
|
|
|
15208
15324
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.TableCellsMerge, { className: "w-4 h-4" })
|
|
15209
15325
|
}
|
|
15210
15326
|
),
|
|
15327
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
15328
|
+
ToolbarButton,
|
|
15329
|
+
{
|
|
15330
|
+
onClick: () => applyTableCellAttribute2(
|
|
15331
|
+
editor,
|
|
15332
|
+
"textWrap",
|
|
15333
|
+
currentCellTextWrap === "nowrap" ? "wrap" : "nowrap",
|
|
15334
|
+
{ focus: false }
|
|
15335
|
+
),
|
|
15336
|
+
active: currentCellTextWrap !== "nowrap",
|
|
15337
|
+
title: currentCellTextWrap === "nowrap" ? t("tableMenu.wrapText") : t("tableMenu.noWrapText"),
|
|
15338
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react14.WrapText, { className: "h-4 w-4" })
|
|
15339
|
+
}
|
|
15340
|
+
),
|
|
15211
15341
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
15212
15342
|
DropdownMenu,
|
|
15213
15343
|
{
|
|
@@ -20432,6 +20562,22 @@ function buildLogicalRowMetrics({
|
|
|
20432
20562
|
};
|
|
20433
20563
|
});
|
|
20434
20564
|
}
|
|
20565
|
+
function getTableCellTextSelectionRange(editor, cellPos) {
|
|
20566
|
+
const cellNode = editor.state.doc.nodeAt(cellPos);
|
|
20567
|
+
if (!cellNode || cellNode.type.name !== "tableCell" && cellNode.type.name !== "tableHeader") {
|
|
20568
|
+
return null;
|
|
20569
|
+
}
|
|
20570
|
+
let from = null;
|
|
20571
|
+
let to = null;
|
|
20572
|
+
cellNode.descendants((node, relativePos) => {
|
|
20573
|
+
if (!node.isText || node.nodeSize === 0) return true;
|
|
20574
|
+
const textStart = cellPos + 1 + relativePos;
|
|
20575
|
+
from ?? (from = textStart);
|
|
20576
|
+
to = textStart + node.nodeSize;
|
|
20577
|
+
return true;
|
|
20578
|
+
});
|
|
20579
|
+
return from !== null && to !== null && from < to ? { from, to } : null;
|
|
20580
|
+
}
|
|
20435
20581
|
function buildTableControlLayout(editor, surface, cell) {
|
|
20436
20582
|
const row = cell.closest("tr");
|
|
20437
20583
|
const table = cell.closest("table");
|
|
@@ -20537,6 +20683,9 @@ function buildTableHoverState({
|
|
|
20537
20683
|
layout,
|
|
20538
20684
|
surface
|
|
20539
20685
|
}) {
|
|
20686
|
+
if (event.buttons !== 0) {
|
|
20687
|
+
return DEFAULT_TABLE_HOVER_STATE;
|
|
20688
|
+
}
|
|
20540
20689
|
const surfaceRect = surface.getBoundingClientRect();
|
|
20541
20690
|
const relativeX = event.clientX - surfaceRect.left + surface.scrollLeft;
|
|
20542
20691
|
const relativeY = event.clientY - surfaceRect.top + surface.scrollTop;
|
|
@@ -20546,8 +20695,8 @@ function buildTableHoverState({
|
|
|
20546
20695
|
const directTableMenu = targetElement?.closest?.("[data-table-control='table-menu']");
|
|
20547
20696
|
const directAddColumn = targetElement?.closest?.("[data-table-control='add-column']");
|
|
20548
20697
|
const directAddRow = targetElement?.closest?.("[data-table-control='add-row']");
|
|
20549
|
-
const directRowHandleIndex = directRowHandle instanceof HTMLElement ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
|
|
20550
|
-
const directColumnHandleIndex = directColumnHandle instanceof HTMLElement ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
|
|
20698
|
+
const directRowHandleIndex = directRowHandle instanceof HTMLElement && relativeX <= layout.tableLeft ? Number.parseInt(directRowHandle.dataset.rowHandleIndex ?? "", 10) : Number.NaN;
|
|
20699
|
+
const directColumnHandleIndex = directColumnHandle instanceof HTMLElement && relativeY <= layout.tableTop ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
|
|
20551
20700
|
const visibleBounds = getVisibleTableBounds(layout);
|
|
20552
20701
|
const rowRailTop = layout.wrapperTop + layout.wrapperHeight;
|
|
20553
20702
|
const isMouseInTable = relativeX >= layout.tableLeft && relativeX <= layout.tableLeft + layout.tableWidth && relativeY >= layout.tableTop && relativeY <= layout.tableTop + layout.tableHeight;
|
|
@@ -20866,7 +21015,8 @@ function TableRowHandles({
|
|
|
20866
21015
|
"data-row-handle-index": rowHandle.index,
|
|
20867
21016
|
style: {
|
|
20868
21017
|
top: Math.max(8, rowHandle.center - 12),
|
|
20869
|
-
left: rowHandleLeft
|
|
21018
|
+
left: rowHandleLeft,
|
|
21019
|
+
pointerEvents: visible ? "auto" : "none"
|
|
20870
21020
|
},
|
|
20871
21021
|
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
20872
21022
|
Tooltip,
|
|
@@ -20899,7 +21049,10 @@ function TableRowHandles({
|
|
|
20899
21049
|
style: {
|
|
20900
21050
|
opacity: isShown ? 1 : 0,
|
|
20901
21051
|
transform: isShown ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`,
|
|
20902
|
-
|
|
21052
|
+
// The idle marker is only a location hint. Keeping it
|
|
21053
|
+
// pointer-transparent prevents it from stealing a text
|
|
21054
|
+
// selection near the first character of a table cell.
|
|
21055
|
+
pointerEvents: visible ? "auto" : "none"
|
|
20903
21056
|
},
|
|
20904
21057
|
children: visible ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react16.GripVertical, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "h-3 w-1 rounded-full bg-muted-foreground/50 hover:bg-muted-foreground" })
|
|
20905
21058
|
}
|
|
@@ -20937,7 +21090,8 @@ function TableColumnHandles({
|
|
|
20937
21090
|
"data-column-handle-index": columnHandle.index,
|
|
20938
21091
|
style: {
|
|
20939
21092
|
top: columnHandleTop,
|
|
20940
|
-
left: Math.max(8, columnHandle.center - 12)
|
|
21093
|
+
left: Math.max(8, columnHandle.center - 12),
|
|
21094
|
+
pointerEvents: visible ? "auto" : "none"
|
|
20941
21095
|
},
|
|
20942
21096
|
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
20943
21097
|
Tooltip,
|
|
@@ -20970,7 +21124,7 @@ function TableColumnHandles({
|
|
|
20970
21124
|
style: {
|
|
20971
21125
|
opacity: isShown ? 1 : 0,
|
|
20972
21126
|
transform: isShown ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`,
|
|
20973
|
-
pointerEvents:
|
|
21127
|
+
pointerEvents: visible ? "auto" : "none"
|
|
20974
21128
|
},
|
|
20975
21129
|
children: visible ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react16.GripHorizontal, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "h-1 w-3 rounded-full bg-muted-foreground/50 hover:bg-muted-foreground" })
|
|
20976
21130
|
}
|
|
@@ -21218,6 +21372,7 @@ function applyTableSize(editor, snapshot, dimensions) {
|
|
|
21218
21372
|
// src/components/UEditor/table-controls.tsx
|
|
21219
21373
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
21220
21374
|
var TABLE_MENU_TOP_OFFSET = 10;
|
|
21375
|
+
var AXIS_HANDLE_RADIUS = 12;
|
|
21221
21376
|
function nearestIndex(centers, position) {
|
|
21222
21377
|
let bestIndex = 0;
|
|
21223
21378
|
let bestDistance = Number.POSITIVE_INFINITY;
|
|
@@ -21395,6 +21550,20 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
21395
21550
|
const surface2 = containerRef.current;
|
|
21396
21551
|
const nextLayout = surface2 ? buildTableControlLayout(editor, surface2, cell) : null;
|
|
21397
21552
|
if (!nextLayout) return;
|
|
21553
|
+
if (isPointOverRenderedText(cell, event.clientX, event.clientY)) {
|
|
21554
|
+
const textSelection = getTableCellTextSelectionRange(editor, nextLayout.cellPos);
|
|
21555
|
+
if (textSelection) {
|
|
21556
|
+
event.preventDefault();
|
|
21557
|
+
const didSelectText = editor.commands.setTextSelection(textSelection);
|
|
21558
|
+
if (didSelectText) {
|
|
21559
|
+
editor.view.focus();
|
|
21560
|
+
layoutRef.current = nextLayout;
|
|
21561
|
+
setLayout(nextLayout);
|
|
21562
|
+
setHoverState(DEFAULT_TABLE_HOVER_STATE);
|
|
21563
|
+
return;
|
|
21564
|
+
}
|
|
21565
|
+
}
|
|
21566
|
+
}
|
|
21398
21567
|
const didSelect = editor.commands.setCellSelection({
|
|
21399
21568
|
anchorCell: nextLayout.cellPos,
|
|
21400
21569
|
headCell: nextLayout.cellPos
|
|
@@ -21861,8 +22030,8 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
21861
22030
|
}
|
|
21862
22031
|
const menuTop = Math.max(8, layout.tableTop - TABLE_MENU_TOP_OFFSET);
|
|
21863
22032
|
const menuLeft = Math.max(8, layout.tableLeft);
|
|
21864
|
-
const rowHandleLeft = layout.tableLeft -
|
|
21865
|
-
const columnHandleTop = layout.tableTop -
|
|
22033
|
+
const rowHandleLeft = layout.tableLeft - AXIS_HANDLE_RADIUS;
|
|
22034
|
+
const columnHandleTop = layout.tableTop - AXIS_HANDLE_RADIUS;
|
|
21866
22035
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
21867
22036
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
21868
22037
|
TableRowHandles,
|
|
@@ -23049,6 +23218,73 @@ function TableFormulaBar({ editor }) {
|
|
|
23049
23218
|
);
|
|
23050
23219
|
}
|
|
23051
23220
|
|
|
23221
|
+
// src/components/UEditor/use-editor-output.ts
|
|
23222
|
+
var React28 = __toESM(require("react"), 1);
|
|
23223
|
+
function normalizeDebounceMs(value) {
|
|
23224
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
23225
|
+
}
|
|
23226
|
+
function useUEditorOutput({
|
|
23227
|
+
onChange,
|
|
23228
|
+
onHtmlChange,
|
|
23229
|
+
onJsonChange,
|
|
23230
|
+
outputDebounceMs
|
|
23231
|
+
}) {
|
|
23232
|
+
const callbacksRef = React28.useRef({});
|
|
23233
|
+
const pendingEditorRef = React28.useRef(null);
|
|
23234
|
+
const timeoutRef = React28.useRef(null);
|
|
23235
|
+
const debounceMs = normalizeDebounceMs(outputDebounceMs);
|
|
23236
|
+
callbacksRef.current = { onChange, onHtmlChange, onJsonChange };
|
|
23237
|
+
const flushOutputUpdates = React28.useCallback(() => {
|
|
23238
|
+
if (timeoutRef.current !== null) {
|
|
23239
|
+
clearTimeout(timeoutRef.current);
|
|
23240
|
+
timeoutRef.current = null;
|
|
23241
|
+
}
|
|
23242
|
+
const editor = pendingEditorRef.current;
|
|
23243
|
+
pendingEditorRef.current = null;
|
|
23244
|
+
if (!editor || editor.isDestroyed) return;
|
|
23245
|
+
const callbacks = callbacksRef.current;
|
|
23246
|
+
if (callbacks.onChange || callbacks.onHtmlChange) {
|
|
23247
|
+
const html = editor.getHTML();
|
|
23248
|
+
callbacks.onChange?.(html);
|
|
23249
|
+
callbacks.onHtmlChange?.(html);
|
|
23250
|
+
}
|
|
23251
|
+
if (callbacks.onJsonChange) {
|
|
23252
|
+
callbacks.onJsonChange(editor.getJSON());
|
|
23253
|
+
}
|
|
23254
|
+
}, []);
|
|
23255
|
+
const scheduleOutputUpdate = React28.useCallback((editor) => {
|
|
23256
|
+
const callbacks = callbacksRef.current;
|
|
23257
|
+
if (!callbacks.onChange && !callbacks.onHtmlChange && !callbacks.onJsonChange) return;
|
|
23258
|
+
pendingEditorRef.current = editor;
|
|
23259
|
+
if (timeoutRef.current !== null) {
|
|
23260
|
+
clearTimeout(timeoutRef.current);
|
|
23261
|
+
timeoutRef.current = null;
|
|
23262
|
+
}
|
|
23263
|
+
if (debounceMs === 0) {
|
|
23264
|
+
flushOutputUpdates();
|
|
23265
|
+
return;
|
|
23266
|
+
}
|
|
23267
|
+
timeoutRef.current = setTimeout(flushOutputUpdates, debounceMs);
|
|
23268
|
+
}, [debounceMs, flushOutputUpdates]);
|
|
23269
|
+
React28.useEffect(() => {
|
|
23270
|
+
if (!pendingEditorRef.current || timeoutRef.current === null) return;
|
|
23271
|
+
clearTimeout(timeoutRef.current);
|
|
23272
|
+
timeoutRef.current = debounceMs === 0 ? null : setTimeout(flushOutputUpdates, debounceMs);
|
|
23273
|
+
if (debounceMs === 0) flushOutputUpdates();
|
|
23274
|
+
}, [debounceMs, flushOutputUpdates]);
|
|
23275
|
+
React28.useEffect(() => () => {
|
|
23276
|
+
if (timeoutRef.current !== null) {
|
|
23277
|
+
clearTimeout(timeoutRef.current);
|
|
23278
|
+
timeoutRef.current = null;
|
|
23279
|
+
}
|
|
23280
|
+
pendingEditorRef.current = null;
|
|
23281
|
+
}, []);
|
|
23282
|
+
return {
|
|
23283
|
+
flushOutputUpdates,
|
|
23284
|
+
scheduleOutputUpdate
|
|
23285
|
+
};
|
|
23286
|
+
}
|
|
23287
|
+
|
|
23052
23288
|
// src/components/UEditor/UEditor.tsx
|
|
23053
23289
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
23054
23290
|
var LazyMenuBar = import_react44.default.lazy(async () => {
|
|
@@ -23060,6 +23296,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23060
23296
|
onChange,
|
|
23061
23297
|
onHtmlChange,
|
|
23062
23298
|
onJsonChange,
|
|
23299
|
+
outputDebounceMs = 0,
|
|
23063
23300
|
uploadImage,
|
|
23064
23301
|
uploadImageForSave,
|
|
23065
23302
|
uploadImageConcurrency = 3,
|
|
@@ -23105,6 +23342,12 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23105
23342
|
const formulaRangePickRef = (0, import_react44.useRef)(null);
|
|
23106
23343
|
const formulaRangeSurfaceRef = (0, import_react44.useRef)(null);
|
|
23107
23344
|
const [formulaRangeHighlight, setFormulaRangeHighlight] = import_react44.default.useState(null);
|
|
23345
|
+
const { flushOutputUpdates, scheduleOutputUpdate } = useUEditorOutput({
|
|
23346
|
+
onChange,
|
|
23347
|
+
onHtmlChange,
|
|
23348
|
+
onJsonChange,
|
|
23349
|
+
outputDebounceMs
|
|
23350
|
+
});
|
|
23108
23351
|
const scheduleFormulaRecalculate = import_react44.default.useCallback((editor2, options) => {
|
|
23109
23352
|
if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
|
|
23110
23353
|
if (!options?.force && isEditingTableFormulaText(editor2)) return;
|
|
@@ -23246,14 +23489,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23246
23489
|
pendingFormulaTextRecalculateRef.current = false;
|
|
23247
23490
|
}
|
|
23248
23491
|
}
|
|
23249
|
-
|
|
23250
|
-
const html = editor2.getHTML();
|
|
23251
|
-
onChange?.(html);
|
|
23252
|
-
onHtmlChange?.(html);
|
|
23253
|
-
}
|
|
23254
|
-
if (onJsonChange) {
|
|
23255
|
-
onJsonChange(editor2.getJSON());
|
|
23256
|
-
}
|
|
23492
|
+
scheduleOutputUpdate(editor2);
|
|
23257
23493
|
},
|
|
23258
23494
|
onSelectionUpdate: ({ editor: editor2 }) => {
|
|
23259
23495
|
if (pendingFormulaTextRecalculateRef.current && !isEditingTableFormulaText(editor2)) {
|
|
@@ -23267,6 +23503,7 @@ var UEditor = import_react44.default.forwardRef(({
|
|
|
23267
23503
|
const shouldRecalculate = pendingFormulaTextRecalculateRef.current;
|
|
23268
23504
|
pendingFormulaTextRecalculateRef.current = false;
|
|
23269
23505
|
if (shouldRecalculate) scheduleFormulaRecalculate(editor2, { force: true });
|
|
23506
|
+
queueMicrotask(flushOutputUpdates);
|
|
23270
23507
|
}
|
|
23271
23508
|
});
|
|
23272
23509
|
(0, import_react44.useEffect)(() => {
|