@underverse-ui/underverse 1.0.75 → 1.0.77
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 +30 -2
- package/dist/index.cjs +980 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +150 -1
- package/dist/index.d.ts +150 -1
- package/dist/index.js +983 -98
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -889,6 +889,17 @@ var en_default = {
|
|
|
889
889
|
undo: "Undo (Ctrl+Z)",
|
|
890
890
|
redo: "Redo (Ctrl+Y)",
|
|
891
891
|
textStyle: "Text Style",
|
|
892
|
+
fontFamily: "Font Family",
|
|
893
|
+
fontSize: "Font Size",
|
|
894
|
+
lineHeight: "Line Height",
|
|
895
|
+
fontDefault: "Default Font",
|
|
896
|
+
sizeDefault: "Default Size",
|
|
897
|
+
lineHeightDefault: "Default Leading",
|
|
898
|
+
letterSpacing: "Letter Spacing",
|
|
899
|
+
letterSpacingDefault: "Default Tracking",
|
|
900
|
+
fontSans: "Sans",
|
|
901
|
+
fontSerif: "Serif",
|
|
902
|
+
fontMono: "Mono",
|
|
892
903
|
normal: "Normal text",
|
|
893
904
|
heading1: "Heading 1",
|
|
894
905
|
heading2: "Heading 2",
|
|
@@ -962,6 +973,8 @@ var en_default = {
|
|
|
962
973
|
},
|
|
963
974
|
tableMenu: {
|
|
964
975
|
insert3x3: "Insert 3\xD73 Table",
|
|
976
|
+
insertTable: "Insert Table",
|
|
977
|
+
gridPreview: "Insert {rows}\xD7{cols} Table",
|
|
965
978
|
addColumnBefore: "Add Column Before",
|
|
966
979
|
addColumnAfter: "Add Column After",
|
|
967
980
|
addRowBefore: "Add Row Before",
|
|
@@ -980,7 +993,10 @@ var en_default = {
|
|
|
980
993
|
quickAddRowAfter: "Quick Add Row After",
|
|
981
994
|
expandTable: "Expand Table",
|
|
982
995
|
dragRow: "Drag Row",
|
|
983
|
-
dragColumn: "Drag Column"
|
|
996
|
+
dragColumn: "Drag Column",
|
|
997
|
+
alignLeft: "Align Table Left",
|
|
998
|
+
alignCenter: "Align Table Center",
|
|
999
|
+
alignRight: "Align Table Right"
|
|
984
1000
|
}
|
|
985
1001
|
}
|
|
986
1002
|
};
|
|
@@ -1138,6 +1154,17 @@ var vi_default = {
|
|
|
1138
1154
|
undo: "Ho\xE0n t\xE1c (Ctrl+Z)",
|
|
1139
1155
|
redo: "L\xE0m l\u1EA1i (Ctrl+Y)",
|
|
1140
1156
|
textStyle: "Ki\u1EC3u ch\u1EEF",
|
|
1157
|
+
fontFamily: "Ph\xF4ng ch\u1EEF",
|
|
1158
|
+
fontSize: "C\u1EE1 ch\u1EEF",
|
|
1159
|
+
lineHeight: "Gi\xE3n d\xF2ng",
|
|
1160
|
+
fontDefault: "Ph\xF4ng m\u1EB7c \u0111\u1ECBnh",
|
|
1161
|
+
sizeDefault: "C\u1EE1 m\u1EB7c \u0111\u1ECBnh",
|
|
1162
|
+
lineHeightDefault: "Gi\xE3n d\xF2ng m\u1EB7c \u0111\u1ECBnh",
|
|
1163
|
+
letterSpacing: "Gi\xE3n ch\u1EEF",
|
|
1164
|
+
letterSpacingDefault: "Gi\xE3n ch\u1EEF m\u1EB7c \u0111\u1ECBnh",
|
|
1165
|
+
fontSans: "Sans",
|
|
1166
|
+
fontSerif: "Serif",
|
|
1167
|
+
fontMono: "Mono",
|
|
1141
1168
|
normal: "V\u0103n b\u1EA3n th\u01B0\u1EDDng",
|
|
1142
1169
|
heading1: "Ti\xEAu \u0111\u1EC1 1",
|
|
1143
1170
|
heading2: "Ti\xEAu \u0111\u1EC1 2",
|
|
@@ -1211,6 +1238,8 @@ var vi_default = {
|
|
|
1211
1238
|
},
|
|
1212
1239
|
tableMenu: {
|
|
1213
1240
|
insert3x3: "Ch\xE8n b\u1EA3ng 3\xD73",
|
|
1241
|
+
insertTable: "Ch\xE8n b\u1EA3ng",
|
|
1242
|
+
gridPreview: "Ch\xE8n b\u1EA3ng {rows}\xD7{cols}",
|
|
1214
1243
|
addColumnBefore: "Th\xEAm c\u1ED9t tr\u01B0\u1EDBc",
|
|
1215
1244
|
addColumnAfter: "Th\xEAm c\u1ED9t sau",
|
|
1216
1245
|
addRowBefore: "Th\xEAm h\xE0ng tr\u01B0\u1EDBc",
|
|
@@ -1229,7 +1258,10 @@ var vi_default = {
|
|
|
1229
1258
|
quickAddRowAfter: "Th\xEAm nhanh h\xE0ng sau",
|
|
1230
1259
|
expandTable: "M\u1EDF r\u1ED9ng b\u1EA3ng",
|
|
1231
1260
|
dragRow: "K\xE9o h\xE0ng",
|
|
1232
|
-
dragColumn: "K\xE9o c\u1ED9t"
|
|
1261
|
+
dragColumn: "K\xE9o c\u1ED9t",
|
|
1262
|
+
alignLeft: "C\u0103n b\u1EA3ng tr\xE1i",
|
|
1263
|
+
alignCenter: "C\u0103n b\u1EA3ng gi\u1EEFa",
|
|
1264
|
+
alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i"
|
|
1233
1265
|
}
|
|
1234
1266
|
}
|
|
1235
1267
|
};
|
|
@@ -1387,6 +1419,17 @@ var ko_default = {
|
|
|
1387
1419
|
undo: "\uC2E4\uD589 \uCDE8\uC18C",
|
|
1388
1420
|
redo: "\uB2E4\uC2DC \uC2E4\uD589",
|
|
1389
1421
|
textStyle: "\uD14D\uC2A4\uD2B8 \uC2A4\uD0C0\uC77C",
|
|
1422
|
+
fontFamily: "\uAE00\uAF34",
|
|
1423
|
+
fontSize: "\uAE00\uC790 \uD06C\uAE30",
|
|
1424
|
+
lineHeight: "\uC904 \uAC04\uACA9",
|
|
1425
|
+
fontDefault: "\uAE30\uBCF8 \uAE00\uAF34",
|
|
1426
|
+
sizeDefault: "\uAE30\uBCF8 \uD06C\uAE30",
|
|
1427
|
+
lineHeightDefault: "\uAE30\uBCF8 \uC904 \uAC04\uACA9",
|
|
1428
|
+
letterSpacing: "\uC790\uAC04",
|
|
1429
|
+
letterSpacingDefault: "\uAE30\uBCF8 \uC790\uAC04",
|
|
1430
|
+
fontSans: "Sans",
|
|
1431
|
+
fontSerif: "Serif",
|
|
1432
|
+
fontMono: "Mono",
|
|
1390
1433
|
normal: "\uC77C\uBC18 \uD14D\uC2A4\uD2B8",
|
|
1391
1434
|
heading1: "\uC81C\uBAA9 1",
|
|
1392
1435
|
heading2: "\uC81C\uBAA9 2",
|
|
@@ -1459,6 +1502,8 @@ var ko_default = {
|
|
|
1459
1502
|
},
|
|
1460
1503
|
tableMenu: {
|
|
1461
1504
|
insert3x3: "3x3 \uD45C \uC0BD\uC785",
|
|
1505
|
+
insertTable: "\uD45C \uC0BD\uC785",
|
|
1506
|
+
gridPreview: "{rows}\xD7{cols} \uD45C \uC0BD\uC785",
|
|
1462
1507
|
addColumnBefore: "\uC55E\uC5D0 \uC5F4 \uCD94\uAC00",
|
|
1463
1508
|
addColumnAfter: "\uB4A4\uC5D0 \uC5F4 \uCD94\uAC00",
|
|
1464
1509
|
addRowBefore: "\uC704\uC5D0 \uD589 \uCD94\uAC00",
|
|
@@ -1477,7 +1522,10 @@ var ko_default = {
|
|
|
1477
1522
|
quickAddRowAfter: "\uC544\uB798 \uD589 \uBE60\uB974\uAC8C \uCD94\uAC00",
|
|
1478
1523
|
expandTable: "\uD45C \uD655\uC7A5",
|
|
1479
1524
|
dragRow: "\uD589 \uB4DC\uB798\uADF8",
|
|
1480
|
-
dragColumn: "\uC5F4 \uB4DC\uB798\uADF8"
|
|
1525
|
+
dragColumn: "\uC5F4 \uB4DC\uB798\uADF8",
|
|
1526
|
+
alignLeft: "\uD45C \uC67C\uCABD \uC815\uB82C",
|
|
1527
|
+
alignCenter: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
|
|
1528
|
+
alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C"
|
|
1481
1529
|
}
|
|
1482
1530
|
}
|
|
1483
1531
|
};
|
|
@@ -1635,6 +1683,17 @@ var ja_default = {
|
|
|
1635
1683
|
undo: "\u5143\u306B\u623B\u3059",
|
|
1636
1684
|
redo: "\u3084\u308A\u76F4\u3057",
|
|
1637
1685
|
textStyle: "\u30C6\u30AD\u30B9\u30C8\u30B9\u30BF\u30A4\u30EB",
|
|
1686
|
+
fontFamily: "\u30D5\u30A9\u30F3\u30C8",
|
|
1687
|
+
fontSize: "\u6587\u5B57\u30B5\u30A4\u30BA",
|
|
1688
|
+
lineHeight: "\u884C\u9593",
|
|
1689
|
+
fontDefault: "\u6A19\u6E96\u30D5\u30A9\u30F3\u30C8",
|
|
1690
|
+
sizeDefault: "\u6A19\u6E96\u30B5\u30A4\u30BA",
|
|
1691
|
+
lineHeightDefault: "\u6A19\u6E96\u306E\u884C\u9593",
|
|
1692
|
+
letterSpacing: "\u6587\u5B57\u9593\u9694",
|
|
1693
|
+
letterSpacingDefault: "\u6A19\u6E96\u306E\u5B57\u9593",
|
|
1694
|
+
fontSans: "Sans",
|
|
1695
|
+
fontSerif: "Serif",
|
|
1696
|
+
fontMono: "Mono",
|
|
1638
1697
|
normal: "\u6A19\u6E96\u30C6\u30AD\u30B9\u30C8",
|
|
1639
1698
|
heading1: "\u898B\u51FA\u3057 1",
|
|
1640
1699
|
heading2: "\u898B\u51FA\u3057 2",
|
|
@@ -1707,6 +1766,8 @@ var ja_default = {
|
|
|
1707
1766
|
},
|
|
1708
1767
|
tableMenu: {
|
|
1709
1768
|
insert3x3: "3x3 \u8868\u3092\u633F\u5165",
|
|
1769
|
+
insertTable: "\u8868\u3092\u633F\u5165",
|
|
1770
|
+
gridPreview: "{rows}\xD7{cols} \u306E\u8868\u3092\u633F\u5165",
|
|
1710
1771
|
addColumnBefore: "\u524D\u306B\u5217\u3092\u8FFD\u52A0",
|
|
1711
1772
|
addColumnAfter: "\u5F8C\u306B\u5217\u3092\u8FFD\u52A0",
|
|
1712
1773
|
addRowBefore: "\u524D\u306B\u884C\u3092\u8FFD\u52A0",
|
|
@@ -1725,7 +1786,10 @@ var ja_default = {
|
|
|
1725
1786
|
quickAddRowAfter: "\u4E0B\u306B\u884C\u3092\u3059\u3070\u3084\u304F\u8FFD\u52A0",
|
|
1726
1787
|
expandTable: "\u8868\u3092\u62E1\u5F35",
|
|
1727
1788
|
dragRow: "\u884C\u3092\u30C9\u30E9\u30C3\u30B0",
|
|
1728
|
-
dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0"
|
|
1789
|
+
dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0",
|
|
1790
|
+
alignLeft: "\u8868\u3092\u5DE6\u5BC4\u305B",
|
|
1791
|
+
alignCenter: "\u8868\u3092\u4E2D\u592E\u63C3\u3048",
|
|
1792
|
+
alignRight: "\u8868\u3092\u53F3\u5BC4\u305B"
|
|
1729
1793
|
}
|
|
1730
1794
|
}
|
|
1731
1795
|
};
|
|
@@ -3881,7 +3945,8 @@ var EmojiPicker = ({
|
|
|
3881
3945
|
showSearch = true,
|
|
3882
3946
|
showCategoryNav = true,
|
|
3883
3947
|
columns = 9,
|
|
3884
|
-
maxHeight = "20rem"
|
|
3948
|
+
maxHeight = "20rem",
|
|
3949
|
+
chrome = "standalone"
|
|
3885
3950
|
}) => {
|
|
3886
3951
|
const t = useSmartTranslations("UEditor");
|
|
3887
3952
|
const [search, setSearch] = (0, import_react6.useState)("");
|
|
@@ -3892,6 +3957,11 @@ var EmojiPicker = ({
|
|
|
3892
3957
|
const resolvedSearchPlaceholder = searchPlaceholder ?? t("emojiPicker.searchPlaceholder");
|
|
3893
3958
|
const resolvedEmptyText = emptyText ?? t("emojiPicker.noResults");
|
|
3894
3959
|
const resolvedEmptyHint = emptyHint ?? t("emojiPicker.tryDifferentSearch");
|
|
3960
|
+
const resolvedColumns = Math.max(1, Math.floor(columns));
|
|
3961
|
+
const isEmbedded = chrome === "embedded";
|
|
3962
|
+
const gridStyle = {
|
|
3963
|
+
gridTemplateColumns: `repeat(${resolvedColumns}, minmax(0, 1fr))`
|
|
3964
|
+
};
|
|
3895
3965
|
const filteredCategories = (0, import_react6.useMemo)(() => {
|
|
3896
3966
|
if (!search.trim()) return EMOJI_LIST;
|
|
3897
3967
|
const query = search.toLowerCase();
|
|
@@ -3931,7 +4001,6 @@ var EmojiPicker = ({
|
|
|
3931
4001
|
(0, import_react6.useEffect)(() => {
|
|
3932
4002
|
isUserScrolling.current = true;
|
|
3933
4003
|
}, []);
|
|
3934
|
-
const gridColsClass = `grid-cols-${columns}`;
|
|
3935
4004
|
const renderEmojiCategory = (category, assignRef2 = false) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3936
4005
|
"div",
|
|
3937
4006
|
{
|
|
@@ -3940,7 +4009,7 @@ var EmojiPicker = ({
|
|
|
3940
4009
|
} : void 0,
|
|
3941
4010
|
children: [
|
|
3942
4011
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "sticky top-0 z-10 bg-card py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: category.name }),
|
|
3943
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className:
|
|
4012
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "grid gap-1", style: gridStyle, children: category.emojis.map((emoji) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3944
4013
|
EmojiGridButton,
|
|
3945
4014
|
{
|
|
3946
4015
|
emoji: emoji.emoji,
|
|
@@ -3973,50 +4042,60 @@ var EmojiPicker = ({
|
|
|
3973
4042
|
isUserScrolling.current = true;
|
|
3974
4043
|
}, 500);
|
|
3975
4044
|
};
|
|
3976
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
"
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
placeholder: resolvedSearchPlaceholder,
|
|
3984
|
-
value: search,
|
|
3985
|
-
onChange: (e) => setSearch(e.target.value),
|
|
3986
|
-
className: cn(
|
|
3987
|
-
"w-full rounded-lg border border-border bg-background py-2 pl-9 pr-9 text-sm",
|
|
3988
|
-
"placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
3989
|
-
)
|
|
3990
|
-
}
|
|
4045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
4046
|
+
"div",
|
|
4047
|
+
{
|
|
4048
|
+
className: cn(
|
|
4049
|
+
"flex max-h-128 w-96 flex-col overflow-hidden",
|
|
4050
|
+
isEmbedded ? "bg-transparent" : "rounded-2xl border border-border bg-card shadow-xl",
|
|
4051
|
+
className
|
|
3991
4052
|
),
|
|
3992
|
-
|
|
3993
|
-
"
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
{
|
|
4008
|
-
type: "button",
|
|
4009
|
-
onClick: () => handleCategoryClick(category.id),
|
|
4010
|
-
className: cn(
|
|
4011
|
-
"rounded-lg p-2 transition-colors",
|
|
4012
|
-
activeCategory === category.id ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"
|
|
4053
|
+
children: [
|
|
4054
|
+
showSearch && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: cn("shrink-0 border-b p-3", isEmbedded ? "bg-transparent" : "bg-muted/30"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative", children: [
|
|
4055
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react4.Search, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
4056
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4057
|
+
"input",
|
|
4058
|
+
{
|
|
4059
|
+
type: "text",
|
|
4060
|
+
placeholder: resolvedSearchPlaceholder,
|
|
4061
|
+
value: search,
|
|
4062
|
+
onChange: (e) => setSearch(e.target.value),
|
|
4063
|
+
className: cn(
|
|
4064
|
+
"w-full rounded-lg border border-border bg-background py-2 pl-9 pr-9 text-sm",
|
|
4065
|
+
"placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
4066
|
+
)
|
|
4067
|
+
}
|
|
4013
4068
|
),
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4069
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4070
|
+
"button",
|
|
4071
|
+
{
|
|
4072
|
+
type: "button",
|
|
4073
|
+
onClick: () => setSearch(""),
|
|
4074
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
|
|
4075
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react4.X, { className: "h-4 w-4" })
|
|
4076
|
+
}
|
|
4077
|
+
)
|
|
4078
|
+
] }) }),
|
|
4079
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: scrollContainerRef, className: "shrink overflow-y-auto px-3 py-2", style: { height: maxHeight }, children: search ? searchResultContent : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-4", children: EMOJI_LIST.map((category) => renderEmojiCategory(category, true)) }) }),
|
|
4080
|
+
!search && showCategoryNav && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: cn("flex shrink-0 items-center justify-around border-t px-2 py-2", isEmbedded ? "bg-transparent" : "bg-muted/30"), children: EMOJI_LIST.map((category) => {
|
|
4081
|
+
const IconComponent = CATEGORY_ICONS[category.id] || import_lucide_react4.Smile;
|
|
4082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4083
|
+
"button",
|
|
4084
|
+
{
|
|
4085
|
+
type: "button",
|
|
4086
|
+
onClick: () => handleCategoryClick(category.id),
|
|
4087
|
+
className: cn(
|
|
4088
|
+
"rounded-lg p-2 transition-colors",
|
|
4089
|
+
activeCategory === category.id ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"
|
|
4090
|
+
),
|
|
4091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip, { placement: "top", content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-xs font-medium", children: category.name }), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(IconComponent, { className: "h-5 w-5" }) }) })
|
|
4092
|
+
},
|
|
4093
|
+
category.id
|
|
4094
|
+
);
|
|
4095
|
+
}) })
|
|
4096
|
+
]
|
|
4097
|
+
}
|
|
4098
|
+
);
|
|
4020
4099
|
};
|
|
4021
4100
|
var EmojiPicker_default = EmojiPicker;
|
|
4022
4101
|
|
|
@@ -22190,7 +22269,6 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
|
22190
22269
|
var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
|
|
22191
22270
|
var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
22192
22271
|
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
22193
|
-
var import_extension_table = require("@tiptap/extension-table");
|
|
22194
22272
|
var import_extension_table_cell = __toESM(require("@tiptap/extension-table-cell"), 1);
|
|
22195
22273
|
var import_extension_table_header = __toESM(require("@tiptap/extension-table-header"), 1);
|
|
22196
22274
|
var import_extension_character_count = __toESM(require("@tiptap/extension-character-count"), 1);
|
|
@@ -23158,6 +23236,283 @@ var UEditorTableRow = import_extension_table_row.default.extend({
|
|
|
23158
23236
|
});
|
|
23159
23237
|
var table_row_default = UEditorTableRow;
|
|
23160
23238
|
|
|
23239
|
+
// src/components/UEditor/font-family.ts
|
|
23240
|
+
var import_core6 = require("@tiptap/core");
|
|
23241
|
+
var FontFamily = import_core6.Extension.create({
|
|
23242
|
+
name: "fontFamily",
|
|
23243
|
+
addOptions() {
|
|
23244
|
+
return {
|
|
23245
|
+
types: ["textStyle"]
|
|
23246
|
+
};
|
|
23247
|
+
},
|
|
23248
|
+
addGlobalAttributes() {
|
|
23249
|
+
return [
|
|
23250
|
+
{
|
|
23251
|
+
types: this.options.types,
|
|
23252
|
+
attributes: {
|
|
23253
|
+
fontFamily: {
|
|
23254
|
+
default: null,
|
|
23255
|
+
parseHTML: (element) => element.style.fontFamily || null,
|
|
23256
|
+
renderHTML: (attributes) => {
|
|
23257
|
+
const fontFamily = typeof attributes.fontFamily === "string" ? attributes.fontFamily.trim() : "";
|
|
23258
|
+
if (!fontFamily) return {};
|
|
23259
|
+
return { style: `font-family: ${fontFamily}` };
|
|
23260
|
+
}
|
|
23261
|
+
}
|
|
23262
|
+
}
|
|
23263
|
+
}
|
|
23264
|
+
];
|
|
23265
|
+
},
|
|
23266
|
+
addCommands() {
|
|
23267
|
+
return {
|
|
23268
|
+
setFontFamily: (fontFamily) => ({ chain }) => chain().setMark("textStyle", { fontFamily }).run(),
|
|
23269
|
+
unsetFontFamily: () => ({ chain }) => chain().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run()
|
|
23270
|
+
};
|
|
23271
|
+
}
|
|
23272
|
+
});
|
|
23273
|
+
var font_family_default = FontFamily;
|
|
23274
|
+
|
|
23275
|
+
// src/components/UEditor/font-size.ts
|
|
23276
|
+
var import_core7 = require("@tiptap/core");
|
|
23277
|
+
var FontSize = import_core7.Extension.create({
|
|
23278
|
+
name: "fontSize",
|
|
23279
|
+
addOptions() {
|
|
23280
|
+
return {
|
|
23281
|
+
types: ["textStyle"]
|
|
23282
|
+
};
|
|
23283
|
+
},
|
|
23284
|
+
addGlobalAttributes() {
|
|
23285
|
+
return [
|
|
23286
|
+
{
|
|
23287
|
+
types: this.options.types,
|
|
23288
|
+
attributes: {
|
|
23289
|
+
fontSize: {
|
|
23290
|
+
default: null,
|
|
23291
|
+
parseHTML: (element) => element.style.fontSize || null,
|
|
23292
|
+
renderHTML: (attributes) => {
|
|
23293
|
+
const fontSize = typeof attributes.fontSize === "string" ? attributes.fontSize.trim() : "";
|
|
23294
|
+
if (!fontSize) return {};
|
|
23295
|
+
return { style: `font-size: ${fontSize}` };
|
|
23296
|
+
}
|
|
23297
|
+
}
|
|
23298
|
+
}
|
|
23299
|
+
}
|
|
23300
|
+
];
|
|
23301
|
+
},
|
|
23302
|
+
addCommands() {
|
|
23303
|
+
return {
|
|
23304
|
+
setFontSize: (fontSize) => ({ chain }) => chain().setMark("textStyle", { fontSize }).run(),
|
|
23305
|
+
unsetFontSize: () => ({ chain }) => chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
23306
|
+
};
|
|
23307
|
+
}
|
|
23308
|
+
});
|
|
23309
|
+
var font_size_default = FontSize;
|
|
23310
|
+
|
|
23311
|
+
// src/components/UEditor/line-height.ts
|
|
23312
|
+
var import_core8 = require("@tiptap/core");
|
|
23313
|
+
var LineHeight = import_core8.Extension.create({
|
|
23314
|
+
name: "lineHeight",
|
|
23315
|
+
addOptions() {
|
|
23316
|
+
return {
|
|
23317
|
+
types: ["textStyle"]
|
|
23318
|
+
};
|
|
23319
|
+
},
|
|
23320
|
+
addGlobalAttributes() {
|
|
23321
|
+
return [
|
|
23322
|
+
{
|
|
23323
|
+
types: this.options.types,
|
|
23324
|
+
attributes: {
|
|
23325
|
+
lineHeight: {
|
|
23326
|
+
default: null,
|
|
23327
|
+
parseHTML: (element) => element.style.lineHeight || null,
|
|
23328
|
+
renderHTML: (attributes) => {
|
|
23329
|
+
const lineHeight = typeof attributes.lineHeight === "string" ? attributes.lineHeight.trim() : "";
|
|
23330
|
+
if (!lineHeight) return {};
|
|
23331
|
+
return { style: `line-height: ${lineHeight}` };
|
|
23332
|
+
}
|
|
23333
|
+
}
|
|
23334
|
+
}
|
|
23335
|
+
}
|
|
23336
|
+
];
|
|
23337
|
+
},
|
|
23338
|
+
addCommands() {
|
|
23339
|
+
return {
|
|
23340
|
+
setLineHeight: (lineHeight) => ({ chain }) => chain().setMark("textStyle", { lineHeight }).run(),
|
|
23341
|
+
unsetLineHeight: () => ({ chain }) => chain().setMark("textStyle", { lineHeight: null }).removeEmptyTextStyle().run()
|
|
23342
|
+
};
|
|
23343
|
+
}
|
|
23344
|
+
});
|
|
23345
|
+
var line_height_default = LineHeight;
|
|
23346
|
+
|
|
23347
|
+
// src/components/UEditor/letter-spacing.ts
|
|
23348
|
+
var import_core9 = require("@tiptap/core");
|
|
23349
|
+
var LetterSpacing = import_core9.Extension.create({
|
|
23350
|
+
name: "letterSpacing",
|
|
23351
|
+
addOptions() {
|
|
23352
|
+
return {
|
|
23353
|
+
types: ["textStyle"]
|
|
23354
|
+
};
|
|
23355
|
+
},
|
|
23356
|
+
addGlobalAttributes() {
|
|
23357
|
+
return [
|
|
23358
|
+
{
|
|
23359
|
+
types: this.options.types,
|
|
23360
|
+
attributes: {
|
|
23361
|
+
letterSpacing: {
|
|
23362
|
+
default: null,
|
|
23363
|
+
parseHTML: (element) => element.style.letterSpacing || null,
|
|
23364
|
+
renderHTML: (attributes) => {
|
|
23365
|
+
const letterSpacing = typeof attributes.letterSpacing === "string" ? attributes.letterSpacing.trim() : "";
|
|
23366
|
+
if (!letterSpacing) return {};
|
|
23367
|
+
return { style: `letter-spacing: ${letterSpacing}` };
|
|
23368
|
+
}
|
|
23369
|
+
}
|
|
23370
|
+
}
|
|
23371
|
+
}
|
|
23372
|
+
];
|
|
23373
|
+
},
|
|
23374
|
+
addCommands() {
|
|
23375
|
+
return {
|
|
23376
|
+
setLetterSpacing: (letterSpacing) => ({ chain }) => chain().setMark("textStyle", { letterSpacing }).run(),
|
|
23377
|
+
unsetLetterSpacing: () => ({ chain }) => chain().setMark("textStyle", { letterSpacing: null }).removeEmptyTextStyle().run()
|
|
23378
|
+
};
|
|
23379
|
+
}
|
|
23380
|
+
});
|
|
23381
|
+
var letter_spacing_default = LetterSpacing;
|
|
23382
|
+
|
|
23383
|
+
// src/components/UEditor/table-align.ts
|
|
23384
|
+
var import_extension_table = require("@tiptap/extension-table");
|
|
23385
|
+
|
|
23386
|
+
// src/components/UEditor/table-align-utils.ts
|
|
23387
|
+
function findTableNodeInfoAtResolvedPos($pos) {
|
|
23388
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
23389
|
+
const node = $pos.node(depth);
|
|
23390
|
+
if (node.type.name === "table") {
|
|
23391
|
+
return {
|
|
23392
|
+
depth,
|
|
23393
|
+
pos: $pos.before(depth),
|
|
23394
|
+
node
|
|
23395
|
+
};
|
|
23396
|
+
}
|
|
23397
|
+
}
|
|
23398
|
+
return null;
|
|
23399
|
+
}
|
|
23400
|
+
function findTableNodeInfoFromState(state, anchorPos) {
|
|
23401
|
+
if (typeof anchorPos === "number" && Number.isFinite(anchorPos)) {
|
|
23402
|
+
const safePos = Math.max(0, Math.min(anchorPos, state.doc.content.size));
|
|
23403
|
+
return findTableNodeInfoAtResolvedPos(state.doc.resolve(safePos));
|
|
23404
|
+
}
|
|
23405
|
+
return findTableNodeInfoAtResolvedPos(state.selection.$from);
|
|
23406
|
+
}
|
|
23407
|
+
function applyTableAlignment(editor, tableAlign, anchorPos) {
|
|
23408
|
+
const tableInfo = findTableNodeInfoFromState(editor.state, anchorPos);
|
|
23409
|
+
if (!tableInfo) return false;
|
|
23410
|
+
editor.view.dispatch(
|
|
23411
|
+
editor.state.tr.setNodeMarkup(tableInfo.pos, tableInfo.node.type, {
|
|
23412
|
+
...tableInfo.node.attrs,
|
|
23413
|
+
tableAlign
|
|
23414
|
+
})
|
|
23415
|
+
);
|
|
23416
|
+
const tableDom = editor.view.nodeDOM(tableInfo.pos);
|
|
23417
|
+
const tableElement = tableDom instanceof HTMLTableElement ? tableDom : tableDom instanceof HTMLElement ? tableDom.querySelector("table") : null;
|
|
23418
|
+
if (tableElement instanceof HTMLTableElement) {
|
|
23419
|
+
if (tableAlign) {
|
|
23420
|
+
tableElement.setAttribute("data-table-align", tableAlign);
|
|
23421
|
+
tableElement.style.width = "max-content";
|
|
23422
|
+
tableElement.style.maxWidth = "100%";
|
|
23423
|
+
tableElement.style.marginLeft = tableAlign === "center" || tableAlign === "right" ? "auto" : "0";
|
|
23424
|
+
tableElement.style.marginRight = tableAlign === "center" ? "auto" : tableAlign === "right" ? "0" : "auto";
|
|
23425
|
+
} else {
|
|
23426
|
+
tableElement.removeAttribute("data-table-align");
|
|
23427
|
+
tableElement.style.removeProperty("width");
|
|
23428
|
+
tableElement.style.removeProperty("max-width");
|
|
23429
|
+
tableElement.style.removeProperty("margin-left");
|
|
23430
|
+
tableElement.style.removeProperty("margin-right");
|
|
23431
|
+
}
|
|
23432
|
+
}
|
|
23433
|
+
return true;
|
|
23434
|
+
}
|
|
23435
|
+
|
|
23436
|
+
// src/components/UEditor/table-align.ts
|
|
23437
|
+
function normalizeTableAlign(value) {
|
|
23438
|
+
if (value === "left" || value === "center" || value === "right") {
|
|
23439
|
+
return value;
|
|
23440
|
+
}
|
|
23441
|
+
return null;
|
|
23442
|
+
}
|
|
23443
|
+
function parseTableAlign(element) {
|
|
23444
|
+
const dataAlign = normalizeTableAlign(element.getAttribute("data-table-align"));
|
|
23445
|
+
if (dataAlign) return dataAlign;
|
|
23446
|
+
const marginLeft = element.style.marginLeft?.trim();
|
|
23447
|
+
const marginRight = element.style.marginRight?.trim();
|
|
23448
|
+
if (marginLeft === "auto" && marginRight === "auto") return "center";
|
|
23449
|
+
if (marginLeft === "auto" && (marginRight === "0px" || marginRight === "0")) return "right";
|
|
23450
|
+
if ((marginLeft === "0px" || marginLeft === "0") && marginRight === "auto") return "left";
|
|
23451
|
+
return null;
|
|
23452
|
+
}
|
|
23453
|
+
function renderTableAlignStyle(tableAlign) {
|
|
23454
|
+
switch (tableAlign) {
|
|
23455
|
+
case "center":
|
|
23456
|
+
return "width: max-content; max-width: 100%; margin-left: auto; margin-right: auto;";
|
|
23457
|
+
case "right":
|
|
23458
|
+
return "width: max-content; max-width: 100%; margin-left: auto; margin-right: 0;";
|
|
23459
|
+
case "left":
|
|
23460
|
+
return "width: max-content; max-width: 100%; margin-left: 0; margin-right: auto;";
|
|
23461
|
+
default:
|
|
23462
|
+
return "";
|
|
23463
|
+
}
|
|
23464
|
+
}
|
|
23465
|
+
var UEditorTable = import_extension_table.Table.extend({
|
|
23466
|
+
addAttributes() {
|
|
23467
|
+
return {
|
|
23468
|
+
...this.parent?.(),
|
|
23469
|
+
tableAlign: {
|
|
23470
|
+
default: null,
|
|
23471
|
+
parseHTML: (element) => {
|
|
23472
|
+
if (!(element instanceof HTMLElement)) return null;
|
|
23473
|
+
return parseTableAlign(element);
|
|
23474
|
+
},
|
|
23475
|
+
renderHTML: (attributes) => {
|
|
23476
|
+
const tableAlign = normalizeTableAlign(attributes.tableAlign);
|
|
23477
|
+
if (!tableAlign) return {};
|
|
23478
|
+
return {
|
|
23479
|
+
"data-table-align": tableAlign,
|
|
23480
|
+
style: renderTableAlignStyle(tableAlign)
|
|
23481
|
+
};
|
|
23482
|
+
}
|
|
23483
|
+
}
|
|
23484
|
+
};
|
|
23485
|
+
},
|
|
23486
|
+
addCommands() {
|
|
23487
|
+
return {
|
|
23488
|
+
...this.parent?.(),
|
|
23489
|
+
setTableAlign: (tableAlign) => ({ state, dispatch }) => {
|
|
23490
|
+
const tableInfo = findTableNodeInfoFromState(state);
|
|
23491
|
+
if (!tableInfo) return false;
|
|
23492
|
+
dispatch?.(
|
|
23493
|
+
state.tr.setNodeMarkup(tableInfo.pos, tableInfo.node.type, {
|
|
23494
|
+
...tableInfo.node.attrs,
|
|
23495
|
+
tableAlign
|
|
23496
|
+
})
|
|
23497
|
+
);
|
|
23498
|
+
return true;
|
|
23499
|
+
},
|
|
23500
|
+
unsetTableAlign: () => ({ state, dispatch }) => {
|
|
23501
|
+
const tableInfo = findTableNodeInfoFromState(state);
|
|
23502
|
+
if (!tableInfo) return false;
|
|
23503
|
+
dispatch?.(
|
|
23504
|
+
state.tr.setNodeMarkup(tableInfo.pos, tableInfo.node.type, {
|
|
23505
|
+
...tableInfo.node.attrs,
|
|
23506
|
+
tableAlign: null
|
|
23507
|
+
})
|
|
23508
|
+
);
|
|
23509
|
+
return true;
|
|
23510
|
+
}
|
|
23511
|
+
};
|
|
23512
|
+
}
|
|
23513
|
+
});
|
|
23514
|
+
var table_align_default = UEditorTable;
|
|
23515
|
+
|
|
23161
23516
|
// src/components/UEditor/extensions.ts
|
|
23162
23517
|
var lowlight = (0, import_lowlight.createLowlight)(import_lowlight.common);
|
|
23163
23518
|
function buildUEditorExtensions({
|
|
@@ -23213,7 +23568,7 @@ function buildUEditorExtensions({
|
|
|
23213
23568
|
import_extension_code_block_lowlight.default.configure({
|
|
23214
23569
|
lowlight,
|
|
23215
23570
|
HTMLAttributes: {
|
|
23216
|
-
class: "rounded-lg bg-
|
|
23571
|
+
class: "rounded-lg border border-border/60 bg-muted/40 text-foreground p-4 font-mono text-sm overflow-x-auto"
|
|
23217
23572
|
}
|
|
23218
23573
|
}),
|
|
23219
23574
|
import_extension_horizontal_rule.default,
|
|
@@ -23226,6 +23581,10 @@ function buildUEditorExtensions({
|
|
|
23226
23581
|
resizable_image_default,
|
|
23227
23582
|
ClipboardImages.configure({ upload: uploadImage, insertMode: imageInsertMode }),
|
|
23228
23583
|
import_extension_text_style.TextStyle,
|
|
23584
|
+
font_family_default,
|
|
23585
|
+
font_size_default,
|
|
23586
|
+
line_height_default,
|
|
23587
|
+
letter_spacing_default,
|
|
23229
23588
|
import_extension_color.default,
|
|
23230
23589
|
import_extension_highlight.default.configure({
|
|
23231
23590
|
multicolor: true
|
|
@@ -23233,7 +23592,7 @@ function buildUEditorExtensions({
|
|
|
23233
23592
|
import_extension_text_align.default.configure({
|
|
23234
23593
|
types: ["heading", "paragraph", "image"]
|
|
23235
23594
|
}),
|
|
23236
|
-
|
|
23595
|
+
table_align_default.configure({
|
|
23237
23596
|
resizable: true,
|
|
23238
23597
|
handleWidth: 10,
|
|
23239
23598
|
allowTableNodeSelection: true,
|
|
@@ -23538,9 +23897,51 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
23538
23897
|
// src/components/UEditor/emoji-picker.tsx
|
|
23539
23898
|
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
23540
23899
|
var EmojiPicker2 = ({ onSelect }) => {
|
|
23541
|
-
return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(EmojiPicker, { onEmojiSelect: onSelect });
|
|
23900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(EmojiPicker, { onEmojiSelect: onSelect, chrome: "embedded" });
|
|
23542
23901
|
};
|
|
23543
23902
|
|
|
23903
|
+
// src/components/UEditor/typography-options.ts
|
|
23904
|
+
function normalizeStyleValue(value) {
|
|
23905
|
+
return typeof value === "string" ? value.trim().replace(/^['"]|['"]$/g, "") : "";
|
|
23906
|
+
}
|
|
23907
|
+
function getDefaultFontFamilies(t) {
|
|
23908
|
+
return [
|
|
23909
|
+
{ label: "Inter", value: "Inter, ui-sans-serif, system-ui, sans-serif" },
|
|
23910
|
+
{ label: "System UI", value: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" },
|
|
23911
|
+
{ label: "Georgia", value: "Georgia, 'Times New Roman', serif" },
|
|
23912
|
+
{ label: "Palatino", value: "'Palatino Linotype', Palatino, Georgia, serif" },
|
|
23913
|
+
{ label: "Times", value: "'Times New Roman', Times, serif" },
|
|
23914
|
+
{ label: "JetBrains Mono", value: "'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, monospace" }
|
|
23915
|
+
];
|
|
23916
|
+
}
|
|
23917
|
+
function getDefaultFontSizes() {
|
|
23918
|
+
return [
|
|
23919
|
+
{ label: "12", value: "12px" },
|
|
23920
|
+
{ label: "14", value: "14px" },
|
|
23921
|
+
{ label: "16", value: "16px" },
|
|
23922
|
+
{ label: "18", value: "18px" },
|
|
23923
|
+
{ label: "24", value: "24px" },
|
|
23924
|
+
{ label: "32", value: "32px" }
|
|
23925
|
+
];
|
|
23926
|
+
}
|
|
23927
|
+
function getDefaultLineHeights() {
|
|
23928
|
+
return [
|
|
23929
|
+
{ label: "1.2", value: "1.2" },
|
|
23930
|
+
{ label: "1.5", value: "1.5" },
|
|
23931
|
+
{ label: "1.75", value: "1.75" },
|
|
23932
|
+
{ label: "2", value: "2" }
|
|
23933
|
+
];
|
|
23934
|
+
}
|
|
23935
|
+
function getDefaultLetterSpacings() {
|
|
23936
|
+
return [
|
|
23937
|
+
{ label: "-0.02em", value: "-0.02em" },
|
|
23938
|
+
{ label: "0", value: "0" },
|
|
23939
|
+
{ label: "0.02em", value: "0.02em" },
|
|
23940
|
+
{ label: "0.05em", value: "0.05em" },
|
|
23941
|
+
{ label: "0.08em", value: "0.08em" }
|
|
23942
|
+
];
|
|
23943
|
+
}
|
|
23944
|
+
|
|
23544
23945
|
// src/components/UEditor/toolbar.tsx
|
|
23545
23946
|
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
23546
23947
|
function fileToDataUrl2(file) {
|
|
@@ -23551,12 +23952,16 @@ function fileToDataUrl2(file) {
|
|
|
23551
23952
|
reader.readAsDataURL(file);
|
|
23552
23953
|
});
|
|
23553
23954
|
}
|
|
23955
|
+
function formatTableInsertLabel(template, rows, cols) {
|
|
23956
|
+
return template.replace("{rows}", String(rows)).replace("{cols}", String(cols));
|
|
23957
|
+
}
|
|
23554
23958
|
var ToolbarButton = import_react49.default.forwardRef(({ onClick, onMouseDown, active, disabled, children, title, className }, ref) => {
|
|
23555
23959
|
const button = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
23556
23960
|
"button",
|
|
23557
23961
|
{
|
|
23558
23962
|
ref,
|
|
23559
23963
|
type: "button",
|
|
23964
|
+
"aria-label": title,
|
|
23560
23965
|
onMouseDown: (e) => {
|
|
23561
23966
|
onMouseDown?.(e);
|
|
23562
23967
|
e.preventDefault();
|
|
@@ -23581,22 +23986,115 @@ var ToolbarButton = import_react49.default.forwardRef(({ onClick, onMouseDown, a
|
|
|
23581
23986
|
});
|
|
23582
23987
|
ToolbarButton.displayName = "ToolbarButton";
|
|
23583
23988
|
var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" });
|
|
23989
|
+
var TableInsertGrid = ({
|
|
23990
|
+
insertLabel,
|
|
23991
|
+
previewTemplate,
|
|
23992
|
+
onInsert
|
|
23993
|
+
}) => {
|
|
23994
|
+
const [selection, setSelection] = import_react49.default.useState({ rows: 3, cols: 3 });
|
|
23995
|
+
const maxRows = 8;
|
|
23996
|
+
const maxCols = 8;
|
|
23997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "mb-2 rounded-xl border border-border/60 bg-muted/20 p-2", children: [
|
|
23998
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "mb-2 text-sm font-medium text-foreground", children: formatTableInsertLabel(previewTemplate, selection.rows, selection.cols) }),
|
|
23999
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24000
|
+
"div",
|
|
24001
|
+
{
|
|
24002
|
+
className: "grid grid-cols-8 gap-1",
|
|
24003
|
+
onMouseLeave: () => setSelection((prev) => prev),
|
|
24004
|
+
children: Array.from({ length: maxRows }).map(
|
|
24005
|
+
(_, rowIndex) => Array.from({ length: maxCols }).map((__, colIndex) => {
|
|
24006
|
+
const rows = rowIndex + 1;
|
|
24007
|
+
const cols = colIndex + 1;
|
|
24008
|
+
const active = rows <= selection.rows && cols <= selection.cols;
|
|
24009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24010
|
+
"button",
|
|
24011
|
+
{
|
|
24012
|
+
type: "button",
|
|
24013
|
+
"aria-label": formatTableInsertLabel(previewTemplate, rows, cols),
|
|
24014
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
24015
|
+
onMouseEnter: () => setSelection({ rows, cols }),
|
|
24016
|
+
onFocus: () => setSelection({ rows, cols }),
|
|
24017
|
+
onClick: () => onInsert(rows, cols),
|
|
24018
|
+
className: cn(
|
|
24019
|
+
"h-5 w-5 rounded-[4px] border transition-colors",
|
|
24020
|
+
active ? "border-primary bg-primary/20" : "border-border/70 bg-background hover:border-primary/60 hover:bg-primary/10"
|
|
24021
|
+
)
|
|
24022
|
+
},
|
|
24023
|
+
`${rows}-${cols}`
|
|
24024
|
+
);
|
|
24025
|
+
})
|
|
24026
|
+
)
|
|
24027
|
+
}
|
|
24028
|
+
),
|
|
24029
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "mt-2 text-xs text-muted-foreground", children: insertLabel })
|
|
24030
|
+
] });
|
|
24031
|
+
};
|
|
23584
24032
|
var EditorToolbar = ({
|
|
23585
24033
|
editor,
|
|
23586
24034
|
variant,
|
|
23587
24035
|
uploadImage,
|
|
23588
|
-
imageInsertMode = "base64"
|
|
24036
|
+
imageInsertMode = "base64",
|
|
24037
|
+
fontFamilies,
|
|
24038
|
+
fontSizes,
|
|
24039
|
+
lineHeights,
|
|
24040
|
+
letterSpacings
|
|
23589
24041
|
}) => {
|
|
23590
24042
|
const t = useSmartTranslations("UEditor");
|
|
23591
24043
|
const { textColors, highlightColors } = useEditorColors();
|
|
23592
24044
|
const [showImageInput, setShowImageInput] = (0, import_react49.useState)(false);
|
|
24045
|
+
const [isTableMenuOpen, setIsTableMenuOpen] = (0, import_react49.useState)(false);
|
|
24046
|
+
const tableCommandAnchorPosRef = (0, import_react49.useRef)(null);
|
|
23593
24047
|
const fileInputRef = (0, import_react49.useRef)(null);
|
|
23594
24048
|
const [isUploadingImage, setIsUploadingImage] = (0, import_react49.useState)(false);
|
|
23595
24049
|
const [imageUploadError, setImageUploadError] = (0, import_react49.useState)(null);
|
|
24050
|
+
const [fontSizeDraft, setFontSizeDraft] = (0, import_react49.useState)("");
|
|
23596
24051
|
const isImageSelected = editor.isActive("image");
|
|
23597
24052
|
const imageAttrs = editor.getAttributes("image");
|
|
24053
|
+
const tableAttrs = editor.getAttributes("table");
|
|
24054
|
+
const textStyleAttrs = editor.getAttributes("textStyle");
|
|
23598
24055
|
const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
|
|
23599
24056
|
const imageWidthPreset = imageAttrs.imageWidthPreset === "sm" || imageAttrs.imageWidthPreset === "md" || imageAttrs.imageWidthPreset === "lg" ? imageAttrs.imageWidthPreset : null;
|
|
24057
|
+
const currentTableAlign = tableAttrs.tableAlign === "center" || tableAttrs.tableAlign === "right" ? tableAttrs.tableAlign : "left";
|
|
24058
|
+
const isTableSelected = editor.isActive("table");
|
|
24059
|
+
const hasTableContext = isTableSelected || tableCommandAnchorPosRef.current !== null;
|
|
24060
|
+
const currentFontFamily = normalizeStyleValue(textStyleAttrs.fontFamily);
|
|
24061
|
+
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
24062
|
+
const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
|
|
24063
|
+
const currentLetterSpacing = normalizeStyleValue(textStyleAttrs.letterSpacing);
|
|
24064
|
+
const availableFontFamilies = import_react49.default.useMemo(
|
|
24065
|
+
() => fontFamilies ?? getDefaultFontFamilies(t),
|
|
24066
|
+
[fontFamilies, t]
|
|
24067
|
+
);
|
|
24068
|
+
const availableFontSizes = import_react49.default.useMemo(
|
|
24069
|
+
() => fontSizes ?? getDefaultFontSizes(),
|
|
24070
|
+
[fontSizes]
|
|
24071
|
+
);
|
|
24072
|
+
const availableLineHeights = import_react49.default.useMemo(
|
|
24073
|
+
() => lineHeights ?? getDefaultLineHeights(),
|
|
24074
|
+
[lineHeights]
|
|
24075
|
+
);
|
|
24076
|
+
const availableLetterSpacings = import_react49.default.useMemo(
|
|
24077
|
+
() => letterSpacings ?? getDefaultLetterSpacings(),
|
|
24078
|
+
[letterSpacings]
|
|
24079
|
+
);
|
|
24080
|
+
const currentFontFamilyLabel = availableFontFamilies.find((option) => normalizeStyleValue(option.value) === currentFontFamily)?.label ?? t("toolbar.fontDefault");
|
|
24081
|
+
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? t("toolbar.sizeDefault");
|
|
24082
|
+
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
24083
|
+
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
24084
|
+
import_react49.default.useEffect(() => {
|
|
24085
|
+
setFontSizeDraft(currentFontSize.replace(/px$/i, ""));
|
|
24086
|
+
}, [currentFontSize]);
|
|
24087
|
+
const applyFontSizeDraft = () => {
|
|
24088
|
+
const normalized = fontSizeDraft.trim();
|
|
24089
|
+
if (!normalized) {
|
|
24090
|
+
editor.chain().focus().unsetFontSize().run();
|
|
24091
|
+
return;
|
|
24092
|
+
}
|
|
24093
|
+
const parsed = Number.parseFloat(normalized);
|
|
24094
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return;
|
|
24095
|
+
const clamped = Math.min(96, Math.max(8, parsed));
|
|
24096
|
+
editor.chain().focus().setFontSize(`${clamped}px`).run();
|
|
24097
|
+
};
|
|
23600
24098
|
const insertImageFiles = async (files) => {
|
|
23601
24099
|
if (files.length === 0) return;
|
|
23602
24100
|
setIsUploadingImage(true);
|
|
@@ -23633,6 +24131,7 @@ var EditorToolbar = ({
|
|
|
23633
24131
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
23634
24132
|
DropdownMenu,
|
|
23635
24133
|
{
|
|
24134
|
+
contentClassName: "p-2",
|
|
23636
24135
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(ToolbarButton, { onClick: () => {
|
|
23637
24136
|
}, title: t("toolbar.textStyle"), className: "px-2 w-auto gap-1", children: [
|
|
23638
24137
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Type, { className: "w-4 h-4" }),
|
|
@@ -23681,6 +24180,183 @@ var EditorToolbar = ({
|
|
|
23681
24180
|
]
|
|
23682
24181
|
}
|
|
23683
24182
|
),
|
|
24183
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24184
|
+
DropdownMenu,
|
|
24185
|
+
{
|
|
24186
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24187
|
+
ToolbarButton,
|
|
24188
|
+
{
|
|
24189
|
+
onClick: () => {
|
|
24190
|
+
},
|
|
24191
|
+
title: t("toolbar.fontFamily"),
|
|
24192
|
+
className: "relative",
|
|
24193
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Type, { className: "w-4 h-4" })
|
|
24194
|
+
}
|
|
24195
|
+
),
|
|
24196
|
+
contentClassName: "max-h-80 overflow-y-auto min-w-56 p-2",
|
|
24197
|
+
children: [
|
|
24198
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24199
|
+
DropdownMenuItem,
|
|
24200
|
+
{
|
|
24201
|
+
icon: import_lucide_react44.Type,
|
|
24202
|
+
label: t("toolbar.fontDefault"),
|
|
24203
|
+
onClick: () => editor.chain().focus().unsetFontFamily().run(),
|
|
24204
|
+
active: !currentFontFamily
|
|
24205
|
+
}
|
|
24206
|
+
),
|
|
24207
|
+
availableFontFamilies.map((option) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24208
|
+
DropdownMenuItem,
|
|
24209
|
+
{
|
|
24210
|
+
label: option.label,
|
|
24211
|
+
onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
|
|
24212
|
+
active: normalizeStyleValue(option.value) === currentFontFamily,
|
|
24213
|
+
className: "font-medium"
|
|
24214
|
+
},
|
|
24215
|
+
option.value
|
|
24216
|
+
))
|
|
24217
|
+
]
|
|
24218
|
+
}
|
|
24219
|
+
),
|
|
24220
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24221
|
+
DropdownMenu,
|
|
24222
|
+
{
|
|
24223
|
+
closeOnSelect: false,
|
|
24224
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24225
|
+
ToolbarButton,
|
|
24226
|
+
{
|
|
24227
|
+
onClick: () => {
|
|
24228
|
+
},
|
|
24229
|
+
title: t("toolbar.fontSize"),
|
|
24230
|
+
className: "px-2 w-auto min-w-9",
|
|
24231
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "text-[10px] font-semibold leading-none", children: currentFontSize.replace(/px$/i, "") || "T" })
|
|
24232
|
+
}
|
|
24233
|
+
),
|
|
24234
|
+
contentClassName: "max-h-80 overflow-y-auto min-w-44 p-2",
|
|
24235
|
+
children: [
|
|
24236
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "mb-2 rounded-lg border border-border/60 bg-muted/30 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
24237
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24238
|
+
"input",
|
|
24239
|
+
{
|
|
24240
|
+
type: "number",
|
|
24241
|
+
min: 8,
|
|
24242
|
+
max: 96,
|
|
24243
|
+
step: 1,
|
|
24244
|
+
value: fontSizeDraft,
|
|
24245
|
+
onChange: (e) => setFontSizeDraft(e.target.value),
|
|
24246
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
24247
|
+
onClick: (e) => e.stopPropagation(),
|
|
24248
|
+
onKeyDown: (e) => {
|
|
24249
|
+
e.stopPropagation();
|
|
24250
|
+
if (e.key === "Enter") {
|
|
24251
|
+
e.preventDefault();
|
|
24252
|
+
applyFontSizeDraft();
|
|
24253
|
+
}
|
|
24254
|
+
},
|
|
24255
|
+
"aria-label": t("toolbar.fontSize"),
|
|
24256
|
+
className: "h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus:ring-2 focus:ring-primary/20"
|
|
24257
|
+
}
|
|
24258
|
+
),
|
|
24259
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "text-xs text-muted-foreground", children: "px" })
|
|
24260
|
+
] }) }),
|
|
24261
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24262
|
+
DropdownMenuItem,
|
|
24263
|
+
{
|
|
24264
|
+
icon: import_lucide_react44.Type,
|
|
24265
|
+
label: t("toolbar.sizeDefault"),
|
|
24266
|
+
onClick: () => editor.chain().focus().unsetFontSize().run(),
|
|
24267
|
+
active: !currentFontSize
|
|
24268
|
+
}
|
|
24269
|
+
),
|
|
24270
|
+
availableFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24271
|
+
DropdownMenuItem,
|
|
24272
|
+
{
|
|
24273
|
+
label: option.label,
|
|
24274
|
+
onClick: () => editor.chain().focus().setFontSize(option.value).run(),
|
|
24275
|
+
active: normalizeStyleValue(option.value) === currentFontSize
|
|
24276
|
+
},
|
|
24277
|
+
option.value
|
|
24278
|
+
))
|
|
24279
|
+
]
|
|
24280
|
+
}
|
|
24281
|
+
),
|
|
24282
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24283
|
+
DropdownMenu,
|
|
24284
|
+
{
|
|
24285
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24286
|
+
ToolbarButton,
|
|
24287
|
+
{
|
|
24288
|
+
onClick: () => {
|
|
24289
|
+
},
|
|
24290
|
+
title: t("toolbar.lineHeight"),
|
|
24291
|
+
className: "gap-0.5",
|
|
24292
|
+
children: [
|
|
24293
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.ArrowUp, { className: "w-3 h-3" }),
|
|
24294
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.ArrowDown, { className: "w-3 h-3" })
|
|
24295
|
+
]
|
|
24296
|
+
}
|
|
24297
|
+
),
|
|
24298
|
+
contentClassName: "max-h-72 overflow-y-auto p-2",
|
|
24299
|
+
children: [
|
|
24300
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24301
|
+
DropdownMenuItem,
|
|
24302
|
+
{
|
|
24303
|
+
icon: import_lucide_react44.Type,
|
|
24304
|
+
label: t("toolbar.lineHeightDefault"),
|
|
24305
|
+
onClick: () => editor.chain().focus().unsetLineHeight().run(),
|
|
24306
|
+
active: !currentLineHeight
|
|
24307
|
+
}
|
|
24308
|
+
),
|
|
24309
|
+
availableLineHeights.map((option) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24310
|
+
DropdownMenuItem,
|
|
24311
|
+
{
|
|
24312
|
+
label: option.label,
|
|
24313
|
+
onClick: () => editor.chain().focus().setLineHeight(option.value).run(),
|
|
24314
|
+
active: normalizeStyleValue(option.value) === currentLineHeight
|
|
24315
|
+
},
|
|
24316
|
+
option.value
|
|
24317
|
+
))
|
|
24318
|
+
]
|
|
24319
|
+
}
|
|
24320
|
+
),
|
|
24321
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24322
|
+
DropdownMenu,
|
|
24323
|
+
{
|
|
24324
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24325
|
+
ToolbarButton,
|
|
24326
|
+
{
|
|
24327
|
+
onClick: () => {
|
|
24328
|
+
},
|
|
24329
|
+
title: t("toolbar.letterSpacing"),
|
|
24330
|
+
className: "gap-0.5",
|
|
24331
|
+
children: [
|
|
24332
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.ArrowLeft, { className: "w-3 h-3" }),
|
|
24333
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.ArrowRight, { className: "w-3 h-3" })
|
|
24334
|
+
]
|
|
24335
|
+
}
|
|
24336
|
+
),
|
|
24337
|
+
contentClassName: "max-h-72 overflow-y-auto p-2",
|
|
24338
|
+
children: [
|
|
24339
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24340
|
+
DropdownMenuItem,
|
|
24341
|
+
{
|
|
24342
|
+
icon: import_lucide_react44.Type,
|
|
24343
|
+
label: t("toolbar.letterSpacingDefault"),
|
|
24344
|
+
onClick: () => editor.chain().focus().unsetLetterSpacing().run(),
|
|
24345
|
+
active: !currentLetterSpacing
|
|
24346
|
+
}
|
|
24347
|
+
),
|
|
24348
|
+
availableLetterSpacings.map((option) => /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24349
|
+
DropdownMenuItem,
|
|
24350
|
+
{
|
|
24351
|
+
label: option.label,
|
|
24352
|
+
onClick: () => editor.chain().focus().setLetterSpacing(option.value).run(),
|
|
24353
|
+
active: normalizeStyleValue(option.value) === currentLetterSpacing
|
|
24354
|
+
},
|
|
24355
|
+
option.value
|
|
24356
|
+
))
|
|
24357
|
+
]
|
|
24358
|
+
}
|
|
24359
|
+
),
|
|
23684
24360
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToolbarDivider, {}),
|
|
23685
24361
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Bold, { className: "w-4 h-4" }) }),
|
|
23686
24362
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Italic, { className: "w-4 h-4" }) }),
|
|
@@ -23750,6 +24426,7 @@ var EditorToolbar = ({
|
|
|
23750
24426
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
23751
24427
|
DropdownMenu,
|
|
23752
24428
|
{
|
|
24429
|
+
contentClassName: "p-0 overflow-hidden",
|
|
23753
24430
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ToolbarButton, { onClick: () => {
|
|
23754
24431
|
}, title: t("toolbar.emoji"), children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Smile, { className: "w-4 h-4" }) }),
|
|
23755
24432
|
children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24015,18 +24692,58 @@ var EditorToolbar = ({
|
|
|
24015
24692
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
|
|
24016
24693
|
DropdownMenu,
|
|
24017
24694
|
{
|
|
24695
|
+
isOpen: isTableMenuOpen,
|
|
24696
|
+
onOpenChange: (open) => {
|
|
24697
|
+
setIsTableMenuOpen(open);
|
|
24698
|
+
tableCommandAnchorPosRef.current = open && editor.isActive("table") ? editor.state.selection.$from.pos : null;
|
|
24699
|
+
},
|
|
24018
24700
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(ToolbarButton, { onClick: () => {
|
|
24019
24701
|
}, title: t("toolbar.table"), children: [
|
|
24020
24702
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.Table, { className: "w-4 h-4" }),
|
|
24021
24703
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_lucide_react44.ChevronDown, { className: "w-3 h-3" })
|
|
24022
24704
|
] }),
|
|
24705
|
+
contentClassName: "p-2 min-w-56",
|
|
24023
24706
|
children: [
|
|
24707
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24708
|
+
TableInsertGrid,
|
|
24709
|
+
{
|
|
24710
|
+
insertLabel: t("tableMenu.insertTable"),
|
|
24711
|
+
previewTemplate: t("tableMenu.gridPreview"),
|
|
24712
|
+
onInsert: (rows, cols) => {
|
|
24713
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
24714
|
+
setIsTableMenuOpen(false);
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
),
|
|
24718
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "my-1 border-t" }),
|
|
24024
24719
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24025
24720
|
DropdownMenuItem,
|
|
24026
24721
|
{
|
|
24027
|
-
icon: import_lucide_react44.
|
|
24028
|
-
label: t("tableMenu.
|
|
24029
|
-
onClick: () => editor
|
|
24722
|
+
icon: import_lucide_react44.AlignLeft,
|
|
24723
|
+
label: t("tableMenu.alignLeft"),
|
|
24724
|
+
onClick: () => applyTableAlignment(editor, "left", tableCommandAnchorPosRef.current ?? void 0),
|
|
24725
|
+
active: hasTableContext && currentTableAlign === "left",
|
|
24726
|
+
disabled: !hasTableContext
|
|
24727
|
+
}
|
|
24728
|
+
),
|
|
24729
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24730
|
+
DropdownMenuItem,
|
|
24731
|
+
{
|
|
24732
|
+
icon: import_lucide_react44.AlignCenter,
|
|
24733
|
+
label: t("tableMenu.alignCenter"),
|
|
24734
|
+
onClick: () => applyTableAlignment(editor, "center", tableCommandAnchorPosRef.current ?? void 0),
|
|
24735
|
+
active: hasTableContext && currentTableAlign === "center",
|
|
24736
|
+
disabled: !hasTableContext
|
|
24737
|
+
}
|
|
24738
|
+
),
|
|
24739
|
+
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
24740
|
+
DropdownMenuItem,
|
|
24741
|
+
{
|
|
24742
|
+
icon: import_lucide_react44.AlignRight,
|
|
24743
|
+
label: t("tableMenu.alignRight"),
|
|
24744
|
+
onClick: () => applyTableAlignment(editor, "right", tableCommandAnchorPosRef.current ?? void 0),
|
|
24745
|
+
active: hasTableContext && currentTableAlign === "right",
|
|
24746
|
+
disabled: !hasTableContext
|
|
24030
24747
|
}
|
|
24031
24748
|
),
|
|
24032
24749
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "my-1 border-t" }),
|
|
@@ -24036,7 +24753,7 @@ var EditorToolbar = ({
|
|
|
24036
24753
|
icon: import_lucide_react44.ArrowLeft,
|
|
24037
24754
|
label: t("tableMenu.addColumnBefore"),
|
|
24038
24755
|
onClick: () => editor.chain().focus().addColumnBefore().run(),
|
|
24039
|
-
disabled: !editor.can().addColumnBefore()
|
|
24756
|
+
disabled: !hasTableContext || !editor.can().addColumnBefore()
|
|
24040
24757
|
}
|
|
24041
24758
|
),
|
|
24042
24759
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24045,7 +24762,7 @@ var EditorToolbar = ({
|
|
|
24045
24762
|
icon: import_lucide_react44.ArrowDown,
|
|
24046
24763
|
label: t("tableMenu.addColumnAfter"),
|
|
24047
24764
|
onClick: () => editor.chain().focus().addColumnAfter().run(),
|
|
24048
|
-
disabled: !editor.can().addColumnAfter()
|
|
24765
|
+
disabled: !hasTableContext || !editor.can().addColumnAfter()
|
|
24049
24766
|
}
|
|
24050
24767
|
),
|
|
24051
24768
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24054,7 +24771,7 @@ var EditorToolbar = ({
|
|
|
24054
24771
|
icon: import_lucide_react44.ArrowUp,
|
|
24055
24772
|
label: t("tableMenu.addRowBefore"),
|
|
24056
24773
|
onClick: () => editor.chain().focus().addRowBefore().run(),
|
|
24057
|
-
disabled: !editor.can().addRowBefore()
|
|
24774
|
+
disabled: !hasTableContext || !editor.can().addRowBefore()
|
|
24058
24775
|
}
|
|
24059
24776
|
),
|
|
24060
24777
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24063,7 +24780,7 @@ var EditorToolbar = ({
|
|
|
24063
24780
|
icon: import_lucide_react44.ArrowRight,
|
|
24064
24781
|
label: t("tableMenu.addRowAfter"),
|
|
24065
24782
|
onClick: () => editor.chain().focus().addRowAfter().run(),
|
|
24066
|
-
disabled: !editor.can().addRowAfter()
|
|
24783
|
+
disabled: !hasTableContext || !editor.can().addRowAfter()
|
|
24067
24784
|
}
|
|
24068
24785
|
),
|
|
24069
24786
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "my-1 border-t" }),
|
|
@@ -24073,7 +24790,7 @@ var EditorToolbar = ({
|
|
|
24073
24790
|
icon: import_lucide_react44.Table,
|
|
24074
24791
|
label: t("tableMenu.toggleHeaderRow"),
|
|
24075
24792
|
onClick: () => editor.chain().focus().toggleHeaderRow().run(),
|
|
24076
|
-
disabled: !editor.can().toggleHeaderRow()
|
|
24793
|
+
disabled: !hasTableContext || !editor.can().toggleHeaderRow()
|
|
24077
24794
|
}
|
|
24078
24795
|
),
|
|
24079
24796
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24082,7 +24799,7 @@ var EditorToolbar = ({
|
|
|
24082
24799
|
icon: import_lucide_react44.Table,
|
|
24083
24800
|
label: t("tableMenu.toggleHeaderColumn"),
|
|
24084
24801
|
onClick: () => editor.chain().focus().toggleHeaderColumn().run(),
|
|
24085
|
-
disabled: !editor.can().toggleHeaderColumn()
|
|
24802
|
+
disabled: !hasTableContext || !editor.can().toggleHeaderColumn()
|
|
24086
24803
|
}
|
|
24087
24804
|
),
|
|
24088
24805
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "my-1 border-t" }),
|
|
@@ -24092,7 +24809,7 @@ var EditorToolbar = ({
|
|
|
24092
24809
|
icon: import_lucide_react44.Trash2,
|
|
24093
24810
|
label: t("tableMenu.deleteColumn"),
|
|
24094
24811
|
onClick: () => editor.chain().focus().deleteColumn().run(),
|
|
24095
|
-
disabled: !editor.can().deleteColumn()
|
|
24812
|
+
disabled: !hasTableContext || !editor.can().deleteColumn()
|
|
24096
24813
|
}
|
|
24097
24814
|
),
|
|
24098
24815
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24101,7 +24818,7 @@ var EditorToolbar = ({
|
|
|
24101
24818
|
icon: import_lucide_react44.Trash2,
|
|
24102
24819
|
label: t("tableMenu.deleteRow"),
|
|
24103
24820
|
onClick: () => editor.chain().focus().deleteRow().run(),
|
|
24104
|
-
disabled: !editor.can().deleteRow()
|
|
24821
|
+
disabled: !hasTableContext || !editor.can().deleteRow()
|
|
24105
24822
|
}
|
|
24106
24823
|
),
|
|
24107
24824
|
/* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
@@ -24110,7 +24827,7 @@ var EditorToolbar = ({
|
|
|
24110
24827
|
icon: import_lucide_react44.Trash2,
|
|
24111
24828
|
label: t("tableMenu.deleteTable"),
|
|
24112
24829
|
onClick: () => editor.chain().focus().deleteTable().run(),
|
|
24113
|
-
disabled: !editor.can().deleteTable()
|
|
24830
|
+
disabled: !hasTableContext || !editor.can().deleteTable()
|
|
24114
24831
|
}
|
|
24115
24832
|
)
|
|
24116
24833
|
]
|
|
@@ -24200,7 +24917,9 @@ var FloatingMenuContent = ({ editor }) => {
|
|
|
24200
24917
|
};
|
|
24201
24918
|
var BubbleMenuContent = ({
|
|
24202
24919
|
editor,
|
|
24203
|
-
onKeepOpenChange
|
|
24920
|
+
onKeepOpenChange,
|
|
24921
|
+
fontSizes,
|
|
24922
|
+
lineHeights
|
|
24204
24923
|
}) => {
|
|
24205
24924
|
const t = useSmartTranslations("UEditor");
|
|
24206
24925
|
const { textColors, highlightColors } = useEditorColors();
|
|
@@ -24210,6 +24929,17 @@ var BubbleMenuContent = ({
|
|
|
24210
24929
|
const imageAttrs = editor.getAttributes("image");
|
|
24211
24930
|
const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
|
|
24212
24931
|
const imageWidthPreset = imageAttrs.imageWidthPreset === "sm" || imageAttrs.imageWidthPreset === "md" || imageAttrs.imageWidthPreset === "lg" ? imageAttrs.imageWidthPreset : null;
|
|
24932
|
+
const textStyleAttrs = editor.getAttributes("textStyle");
|
|
24933
|
+
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
24934
|
+
const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
|
|
24935
|
+
const quickFontSizes = (0, import_react50.useMemo)(
|
|
24936
|
+
() => (fontSizes ?? getDefaultFontSizes()).filter((option) => ["14px", "16px", "24px"].includes(option.value)),
|
|
24937
|
+
[fontSizes]
|
|
24938
|
+
);
|
|
24939
|
+
const quickLineHeights = (0, import_react50.useMemo)(
|
|
24940
|
+
() => (lineHeights ?? getDefaultLineHeights()).filter((option) => ["1.2", "1.5", "1.75"].includes(option.value)),
|
|
24941
|
+
[lineHeights]
|
|
24942
|
+
);
|
|
24213
24943
|
(0, import_react50.useEffect)(() => {
|
|
24214
24944
|
onKeepOpenChange?.(showLinkInput);
|
|
24215
24945
|
}, [onKeepOpenChange, showLinkInput]);
|
|
@@ -24329,6 +25059,50 @@ var BubbleMenuContent = ({
|
|
|
24329
25059
|
),
|
|
24330
25060
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => setShowEditorColorPalette(true), title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react45.Palette, { className: "w-4 h-4" }) }),
|
|
24331
25061
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
25062
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25063
|
+
ToolbarButton,
|
|
25064
|
+
{
|
|
25065
|
+
onClick: () => editor.chain().focus().unsetFontSize().run(),
|
|
25066
|
+
active: !currentFontSize,
|
|
25067
|
+
title: t("toolbar.sizeDefault"),
|
|
25068
|
+
className: "px-2 w-auto",
|
|
25069
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-[10px] font-semibold", children: "A" })
|
|
25070
|
+
}
|
|
25071
|
+
),
|
|
25072
|
+
quickFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25073
|
+
ToolbarButton,
|
|
25074
|
+
{
|
|
25075
|
+
onClick: () => editor.chain().focus().setFontSize(option.value).run(),
|
|
25076
|
+
active: normalizeStyleValue(option.value) === currentFontSize,
|
|
25077
|
+
title: `${t("toolbar.fontSize")} ${option.label}`,
|
|
25078
|
+
className: "px-2 w-auto",
|
|
25079
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-[10px] font-semibold", children: option.label })
|
|
25080
|
+
},
|
|
25081
|
+
option.value
|
|
25082
|
+
)),
|
|
25083
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
25084
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25085
|
+
ToolbarButton,
|
|
25086
|
+
{
|
|
25087
|
+
onClick: () => editor.chain().focus().unsetLineHeight().run(),
|
|
25088
|
+
active: !currentLineHeight,
|
|
25089
|
+
title: t("toolbar.lineHeightDefault"),
|
|
25090
|
+
className: "px-2 w-auto",
|
|
25091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-[10px] font-semibold leading-none", children: "LH" })
|
|
25092
|
+
}
|
|
25093
|
+
),
|
|
25094
|
+
quickLineHeights.map((option) => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25095
|
+
ToolbarButton,
|
|
25096
|
+
{
|
|
25097
|
+
onClick: () => editor.chain().focus().setLineHeight(option.value).run(),
|
|
25098
|
+
active: normalizeStyleValue(option.value) === currentLineHeight,
|
|
25099
|
+
title: `${t("toolbar.lineHeight")} ${option.label}`,
|
|
25100
|
+
className: "px-2 w-auto",
|
|
25101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-[10px] font-semibold", children: option.label })
|
|
25102
|
+
},
|
|
25103
|
+
option.value
|
|
25104
|
+
)),
|
|
25105
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
24332
25106
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
24333
25107
|
ToolbarButton,
|
|
24334
25108
|
{
|
|
@@ -24349,8 +25123,13 @@ var BubbleMenuContent = ({
|
|
|
24349
25123
|
)
|
|
24350
25124
|
] });
|
|
24351
25125
|
};
|
|
24352
|
-
var CustomBubbleMenu = ({
|
|
25126
|
+
var CustomBubbleMenu = ({
|
|
25127
|
+
editor,
|
|
25128
|
+
fontSizes,
|
|
25129
|
+
lineHeights
|
|
25130
|
+
}) => {
|
|
24353
25131
|
const SHOW_DELAY_MS = 180;
|
|
25132
|
+
const BUBBLE_MENU_OFFSET = 16;
|
|
24354
25133
|
const [isVisible, setIsVisible] = (0, import_react50.useState)(false);
|
|
24355
25134
|
const [position, setPosition] = (0, import_react50.useState)({ top: 0, left: 0 });
|
|
24356
25135
|
const menuRef = (0, import_react50.useRef)(null);
|
|
@@ -24378,7 +25157,7 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
24378
25157
|
const start = view.coordsAtPos(from);
|
|
24379
25158
|
const end = view.coordsAtPos(to);
|
|
24380
25159
|
const left = (start.left + end.left) / 2;
|
|
24381
|
-
const top = start.top -
|
|
25160
|
+
const top = start.top - BUBBLE_MENU_OFFSET;
|
|
24382
25161
|
setPosition({ top, left });
|
|
24383
25162
|
if (keepOpenRef.current) {
|
|
24384
25163
|
clearShowTimeout();
|
|
@@ -24424,7 +25203,9 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
24424
25203
|
BubbleMenuContent,
|
|
24425
25204
|
{
|
|
24426
25205
|
editor,
|
|
24427
|
-
onKeepOpenChange: setKeepOpen
|
|
25206
|
+
onKeepOpenChange: setKeepOpen,
|
|
25207
|
+
fontSizes,
|
|
25208
|
+
lineHeights
|
|
24428
25209
|
}
|
|
24429
25210
|
)
|
|
24430
25211
|
}
|
|
@@ -24433,6 +25214,7 @@ var CustomBubbleMenu = ({ editor }) => {
|
|
|
24433
25214
|
);
|
|
24434
25215
|
};
|
|
24435
25216
|
var CustomFloatingMenu = ({ editor }) => {
|
|
25217
|
+
const FLOATING_MENU_OFFSET = 16;
|
|
24436
25218
|
const [isVisible, setIsVisible] = (0, import_react50.useState)(false);
|
|
24437
25219
|
const [position, setPosition] = (0, import_react50.useState)({ top: 0, left: 0 });
|
|
24438
25220
|
(0, import_react50.useEffect)(() => {
|
|
@@ -24445,7 +25227,7 @@ var CustomFloatingMenu = ({ editor }) => {
|
|
|
24445
25227
|
return;
|
|
24446
25228
|
}
|
|
24447
25229
|
const coords = view.coordsAtPos($from.pos);
|
|
24448
|
-
setPosition({ top: coords.top -
|
|
25230
|
+
setPosition({ top: coords.top - FLOATING_MENU_OFFSET, left: coords.left });
|
|
24449
25231
|
setIsVisible(true);
|
|
24450
25232
|
};
|
|
24451
25233
|
const handleBlur = () => setIsVisible(false);
|
|
@@ -28921,9 +29703,16 @@ var FALLBACK_TABLE_COLUMN_WIDTH = 160;
|
|
|
28921
29703
|
var MENU_HOVER_PADDING = 18;
|
|
28922
29704
|
var ROW_HANDLE_HOVER_WIDTH = 28;
|
|
28923
29705
|
var COLUMN_HANDLE_HOVER_HEIGHT = 28;
|
|
29706
|
+
var ROW_HANDLE_GUTTER = 20;
|
|
29707
|
+
var TABLE_MENU_TOP_OFFSET = 10;
|
|
29708
|
+
var COLUMN_HANDLE_TOP_OFFSET = 8;
|
|
29709
|
+
var ADD_COLUMN_RAIL_GAP = 4;
|
|
29710
|
+
var ADD_ROW_RAIL_GAP = 4;
|
|
28924
29711
|
var ADD_COLUMN_HOVER_WIDTH = 24;
|
|
28925
29712
|
var ADD_ROW_HOVER_HEIGHT = 24;
|
|
28926
29713
|
var HANDLE_HOVER_RADIUS = 14;
|
|
29714
|
+
var IDLE_HANDLE_OPACITY = "0.4";
|
|
29715
|
+
var IDLE_HANDLE_SCALE = "0.78";
|
|
28927
29716
|
var DEFAULT_HOVER_STATE = {
|
|
28928
29717
|
menuVisible: false,
|
|
28929
29718
|
addColumnVisible: false,
|
|
@@ -29165,8 +29954,8 @@ function TableControls({ editor, containerRef }) {
|
|
|
29165
29954
|
const rowHandleIndex = Number.isFinite(directRowHandleIndex) ? directRowHandleIndex : activeLayout.rowHandles.find((rowHandle) => relativeX >= activeLayout.tableLeft - ROW_HANDLE_HOVER_WIDTH && relativeX <= activeLayout.tableLeft && Math.abs(relativeY - rowHandle.center) <= HANDLE_HOVER_RADIUS)?.index ?? null;
|
|
29166
29955
|
const columnHandleIndex = Number.isFinite(directColumnHandleIndex) ? directColumnHandleIndex : activeLayout.columnHandles.find((columnHandle) => relativeY >= activeLayout.tableTop - COLUMN_HANDLE_HOVER_HEIGHT && relativeY <= activeLayout.tableTop && Math.abs(relativeX - columnHandle.center) <= HANDLE_HOVER_RADIUS)?.index ?? null;
|
|
29167
29956
|
const menuVisible = Boolean(directTableMenu) || relativeX >= activeLayout.tableLeft - MENU_HOVER_PADDING && relativeX <= activeLayout.tableLeft + 42 && relativeY >= activeLayout.tableTop - COLUMN_HANDLE_HOVER_HEIGHT && relativeY <= activeLayout.tableTop + MENU_HOVER_PADDING;
|
|
29168
|
-
const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.
|
|
29169
|
-
const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.
|
|
29957
|
+
const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.tableLeft + visibleTableWidth2 && relativeX <= activeLayout.tableLeft + visibleTableWidth2 + ADD_COLUMN_HOVER_WIDTH && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2;
|
|
29958
|
+
const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.tableTop + visibleTableHeight2 && relativeY <= activeLayout.tableTop + visibleTableHeight2 + ADD_ROW_HOVER_HEIGHT && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2;
|
|
29170
29959
|
setHoverState((prev) => {
|
|
29171
29960
|
if (prev.menuVisible === menuVisible && prev.addColumnVisible === addColumnVisible && prev.addRowVisible === addRowVisible && prev.rowHandleIndex === rowHandleIndex && prev.columnHandleIndex === columnHandleIndex) {
|
|
29172
29961
|
return prev;
|
|
@@ -29406,6 +30195,21 @@ function TableControls({ editor, containerRef }) {
|
|
|
29406
30195
|
const menuItems = import_react51.default.useMemo(() => {
|
|
29407
30196
|
if (!layout) return [];
|
|
29408
30197
|
return [
|
|
30198
|
+
{
|
|
30199
|
+
label: t("tableMenu.alignLeft"),
|
|
30200
|
+
icon: import_lucide_react46.AlignLeft,
|
|
30201
|
+
onClick: () => applyTableAlignment(editor, "left", layout.cellPos)
|
|
30202
|
+
},
|
|
30203
|
+
{
|
|
30204
|
+
label: t("tableMenu.alignCenter"),
|
|
30205
|
+
icon: import_lucide_react46.AlignCenter,
|
|
30206
|
+
onClick: () => applyTableAlignment(editor, "center", layout.cellPos)
|
|
30207
|
+
},
|
|
30208
|
+
{
|
|
30209
|
+
label: t("tableMenu.alignRight"),
|
|
30210
|
+
icon: import_lucide_react46.AlignRight,
|
|
30211
|
+
onClick: () => applyTableAlignment(editor, "right", layout.cellPos)
|
|
30212
|
+
},
|
|
29409
30213
|
{
|
|
29410
30214
|
label: t("tableMenu.addColumnBefore"),
|
|
29411
30215
|
icon: import_lucide_react46.ArrowLeft,
|
|
@@ -29515,16 +30319,16 @@ function TableControls({ editor, containerRef }) {
|
|
|
29515
30319
|
if (!layout) {
|
|
29516
30320
|
return null;
|
|
29517
30321
|
}
|
|
29518
|
-
const menuTop = Math.max(8, layout.tableTop -
|
|
30322
|
+
const menuTop = Math.max(8, layout.tableTop - TABLE_MENU_TOP_OFFSET);
|
|
29519
30323
|
const menuLeft = Math.max(8, layout.tableLeft);
|
|
29520
|
-
const rowHandleLeft = Math.max(8, layout.tableLeft -
|
|
29521
|
-
const columnHandleTop = Math.max(8, layout.tableTop -
|
|
30324
|
+
const rowHandleLeft = Math.max(8, layout.tableLeft - ROW_HANDLE_GUTTER);
|
|
30325
|
+
const columnHandleTop = Math.max(8, layout.tableTop - COLUMN_HANDLE_TOP_OFFSET);
|
|
29522
30326
|
const visibleTableWidth = Math.min(layout.tableWidth, layout.viewportWidth);
|
|
29523
30327
|
const visibleTableHeight = Math.min(layout.tableHeight, layout.viewportHeight);
|
|
29524
|
-
const columnRailTop = layout.
|
|
29525
|
-
const columnRailLeft = layout.
|
|
29526
|
-
const rowRailTop = layout.
|
|
29527
|
-
const rowRailLeft = layout.
|
|
30328
|
+
const columnRailTop = layout.tableTop;
|
|
30329
|
+
const columnRailLeft = layout.tableLeft + visibleTableWidth + ADD_COLUMN_RAIL_GAP;
|
|
30330
|
+
const rowRailTop = layout.tableTop + visibleTableHeight + ADD_ROW_RAIL_GAP;
|
|
30331
|
+
const rowRailLeft = layout.tableLeft;
|
|
29528
30332
|
const expandPreviewWidth = dragPreview?.kind === "add-column" ? layout.tableWidth + dragPreview.previewCols * layout.avgColumnWidth : layout.tableWidth;
|
|
29529
30333
|
const expandPreviewHeight = dragPreview?.kind === "add-row" ? layout.tableHeight + dragPreview.previewRows * layout.avgRowHeight : layout.tableHeight;
|
|
29530
30334
|
const dragStatusText = dragPreview?.kind === "row" ? `${t("tableMenu.dragRow")} ${dragPreview.originIndex + 1} -> ${dragPreview.targetIndex + 1}` : dragPreview?.kind === "column" ? `${t("tableMenu.dragColumn")} ${dragPreview.originIndex + 1} -> ${dragPreview.targetIndex + 1}` : dragPreview?.kind === "add-row" ? `+${dragPreview.previewRows}R` : dragPreview?.kind === "add-column" ? `+${dragPreview.previewCols}C` : null;
|
|
@@ -29532,7 +30336,6 @@ function TableControls({ editor, containerRef }) {
|
|
|
29532
30336
|
layout.rowHandles.map((rowHandle) => {
|
|
29533
30337
|
const menuKey = getRowMenuKey(rowHandle.index);
|
|
29534
30338
|
const visible = controlsVisible || hoverState.rowHandleIndex === rowHandle.index || openMenuKey === menuKey;
|
|
29535
|
-
if (!visible) return null;
|
|
29536
30339
|
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29537
30340
|
"div",
|
|
29538
30341
|
{
|
|
@@ -29546,6 +30349,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29546
30349
|
Tooltip,
|
|
29547
30350
|
{
|
|
29548
30351
|
placement: "right",
|
|
30352
|
+
disabled: openMenuKey === menuKey,
|
|
29549
30353
|
content: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-xs font-medium", children: `${t("tableMenu.dragRow")} ${rowHandle.index + 1}` }),
|
|
29550
30354
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29551
30355
|
DropdownMenu,
|
|
@@ -29555,6 +30359,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29555
30359
|
onOpenChange: (open) => {
|
|
29556
30360
|
setOpenMenuKey((prev) => open ? menuKey : prev === menuKey ? null : prev);
|
|
29557
30361
|
},
|
|
30362
|
+
contentClassName: "p-2",
|
|
29558
30363
|
items: getRowHandleMenuItems(rowHandle),
|
|
29559
30364
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29560
30365
|
"button",
|
|
@@ -29583,8 +30388,13 @@ function TableControls({ editor, containerRef }) {
|
|
|
29583
30388
|
className: cn(
|
|
29584
30389
|
"inline-flex h-6 w-6 items-center justify-center rounded-full",
|
|
29585
30390
|
"border border-border/70 bg-background/95 text-muted-foreground shadow-sm backdrop-blur",
|
|
30391
|
+
"cursor-grab active:cursor-grabbing",
|
|
29586
30392
|
"transition-[opacity,transform,colors] duration-150 hover:bg-accent hover:text-foreground"
|
|
29587
30393
|
),
|
|
30394
|
+
style: {
|
|
30395
|
+
opacity: visible ? 1 : Number(IDLE_HANDLE_OPACITY),
|
|
30396
|
+
transform: visible ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`
|
|
30397
|
+
},
|
|
29588
30398
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_lucide_react46.GripVertical, { className: "h-3.5 w-3.5" })
|
|
29589
30399
|
}
|
|
29590
30400
|
)
|
|
@@ -29599,7 +30409,6 @@ function TableControls({ editor, containerRef }) {
|
|
|
29599
30409
|
layout.columnHandles.map((columnHandle) => {
|
|
29600
30410
|
const menuKey = getColumnMenuKey(columnHandle.index);
|
|
29601
30411
|
const visible = controlsVisible || hoverState.columnHandleIndex === columnHandle.index || openMenuKey === menuKey;
|
|
29602
|
-
if (!visible) return null;
|
|
29603
30412
|
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29604
30413
|
"div",
|
|
29605
30414
|
{
|
|
@@ -29613,6 +30422,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29613
30422
|
Tooltip,
|
|
29614
30423
|
{
|
|
29615
30424
|
placement: "top",
|
|
30425
|
+
disabled: openMenuKey === menuKey,
|
|
29616
30426
|
content: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-xs font-medium", children: `${t("tableMenu.dragColumn")} ${columnHandle.index + 1}` }),
|
|
29617
30427
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29618
30428
|
DropdownMenu,
|
|
@@ -29622,6 +30432,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29622
30432
|
onOpenChange: (open) => {
|
|
29623
30433
|
setOpenMenuKey((prev) => open ? menuKey : prev === menuKey ? null : prev);
|
|
29624
30434
|
},
|
|
30435
|
+
contentClassName: "p-2",
|
|
29625
30436
|
items: getColumnHandleMenuItems(columnHandle),
|
|
29626
30437
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29627
30438
|
"button",
|
|
@@ -29650,8 +30461,13 @@ function TableControls({ editor, containerRef }) {
|
|
|
29650
30461
|
className: cn(
|
|
29651
30462
|
"inline-flex h-6 w-6 items-center justify-center rounded-full",
|
|
29652
30463
|
"border border-border/70 bg-background/95 text-muted-foreground shadow-sm backdrop-blur",
|
|
30464
|
+
"cursor-grab active:cursor-grabbing",
|
|
29653
30465
|
"transition-[opacity,transform,colors] duration-150 hover:bg-accent hover:text-foreground"
|
|
29654
30466
|
),
|
|
30467
|
+
style: {
|
|
30468
|
+
opacity: visible ? 1 : Number(IDLE_HANDLE_OPACITY),
|
|
30469
|
+
transform: visible ? "scale(1)" : `scale(${IDLE_HANDLE_SCALE})`
|
|
30470
|
+
},
|
|
29655
30471
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_lucide_react46.GripHorizontal, { className: "h-3.5 w-3.5" })
|
|
29656
30472
|
}
|
|
29657
30473
|
)
|
|
@@ -29663,7 +30479,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29663
30479
|
`column-handle-${columnHandle.index}`
|
|
29664
30480
|
);
|
|
29665
30481
|
}),
|
|
29666
|
-
|
|
30482
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29667
30483
|
"div",
|
|
29668
30484
|
{
|
|
29669
30485
|
className: "absolute z-30",
|
|
@@ -29676,6 +30492,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29676
30492
|
Tooltip,
|
|
29677
30493
|
{
|
|
29678
30494
|
placement: "top",
|
|
30495
|
+
disabled: tableMenuOpen,
|
|
29679
30496
|
content: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-xs font-medium", children: t("tableMenu.openControls") }),
|
|
29680
30497
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29681
30498
|
DropdownMenu,
|
|
@@ -29685,6 +30502,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29685
30502
|
onOpenChange: (open) => {
|
|
29686
30503
|
setOpenMenuKey((prev) => open ? "table" : prev === "table" ? null : prev);
|
|
29687
30504
|
},
|
|
30505
|
+
contentClassName: "p-2",
|
|
29688
30506
|
items: menuItems,
|
|
29689
30507
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29690
30508
|
"button",
|
|
@@ -29697,6 +30515,10 @@ function TableControls({ editor, containerRef }) {
|
|
|
29697
30515
|
"border border-border/70 bg-background/95 text-muted-foreground shadow-sm backdrop-blur",
|
|
29698
30516
|
"transition-[opacity,transform,colors] duration-150 hover:bg-accent hover:text-foreground"
|
|
29699
30517
|
),
|
|
30518
|
+
style: {
|
|
30519
|
+
opacity: controlsVisible || hoverState.menuVisible || tableMenuOpen ? 1 : 0.5,
|
|
30520
|
+
transform: controlsVisible || hoverState.menuVisible || tableMenuOpen ? "scale(1)" : "scale(0.82)"
|
|
30521
|
+
},
|
|
29700
30522
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_lucide_react46.MoreHorizontal, { className: "h-4 w-4" })
|
|
29701
30523
|
}
|
|
29702
30524
|
)
|
|
@@ -29706,7 +30528,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
29706
30528
|
)
|
|
29707
30529
|
}
|
|
29708
30530
|
),
|
|
29709
|
-
|
|
30531
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29710
30532
|
Tooltip,
|
|
29711
30533
|
{
|
|
29712
30534
|
placement: "right",
|
|
@@ -29733,17 +30555,19 @@ function TableControls({ editor, containerRef }) {
|
|
|
29733
30555
|
"transition-[opacity,transform,colors] duration-150 hover:bg-accent hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed"
|
|
29734
30556
|
),
|
|
29735
30557
|
style: {
|
|
29736
|
-
top: columnRailTop,
|
|
30558
|
+
top: controlsVisible || hoverState.addColumnVisible ? columnRailTop : columnRailTop + Math.max(0, visibleTableHeight / 2 - 24),
|
|
29737
30559
|
left: columnRailLeft,
|
|
29738
|
-
width: 18,
|
|
29739
|
-
height: visibleTableHeight
|
|
30560
|
+
width: controlsVisible || hoverState.addColumnVisible ? 18 : 12,
|
|
30561
|
+
height: controlsVisible || hoverState.addColumnVisible ? visibleTableHeight : 48,
|
|
30562
|
+
opacity: controlsVisible || hoverState.addColumnVisible ? 1 : 0.45,
|
|
30563
|
+
transform: controlsVisible || hoverState.addColumnVisible ? "scale(1)" : "scale(0.92)"
|
|
29740
30564
|
},
|
|
29741
30565
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
29742
30566
|
}
|
|
29743
30567
|
)
|
|
29744
30568
|
}
|
|
29745
30569
|
),
|
|
29746
|
-
|
|
30570
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
29747
30571
|
Tooltip,
|
|
29748
30572
|
{
|
|
29749
30573
|
placement: "bottom",
|
|
@@ -29771,9 +30595,11 @@ function TableControls({ editor, containerRef }) {
|
|
|
29771
30595
|
),
|
|
29772
30596
|
style: {
|
|
29773
30597
|
top: rowRailTop,
|
|
29774
|
-
left: rowRailLeft,
|
|
29775
|
-
width: visibleTableWidth,
|
|
29776
|
-
height: 16
|
|
30598
|
+
left: controlsVisible || hoverState.addRowVisible ? rowRailLeft : rowRailLeft + Math.max(0, visibleTableWidth / 2 - 24),
|
|
30599
|
+
width: controlsVisible || hoverState.addRowVisible ? visibleTableWidth : 48,
|
|
30600
|
+
height: controlsVisible || hoverState.addRowVisible ? 16 : 12,
|
|
30601
|
+
opacity: controlsVisible || hoverState.addRowVisible ? 1 : 0.45,
|
|
30602
|
+
transform: controlsVisible || hoverState.addRowVisible ? "scale(1)" : "scale(0.92)"
|
|
29777
30603
|
},
|
|
29778
30604
|
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-sm font-medium leading-none", children: "+" })
|
|
29779
30605
|
}
|
|
@@ -29960,6 +30786,32 @@ function getRelativeCellMetrics(surface, cell) {
|
|
|
29960
30786
|
height: cellRect.height
|
|
29961
30787
|
};
|
|
29962
30788
|
}
|
|
30789
|
+
function getRelativeSelectedCellsMetrics(surface) {
|
|
30790
|
+
const selectedCells = Array.from(
|
|
30791
|
+
surface.querySelectorAll("td.selectedCell, th.selectedCell")
|
|
30792
|
+
);
|
|
30793
|
+
if (selectedCells.length === 0) {
|
|
30794
|
+
return null;
|
|
30795
|
+
}
|
|
30796
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
30797
|
+
let left = Number.POSITIVE_INFINITY;
|
|
30798
|
+
let top = Number.POSITIVE_INFINITY;
|
|
30799
|
+
let right = Number.NEGATIVE_INFINITY;
|
|
30800
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
30801
|
+
selectedCells.forEach((cell) => {
|
|
30802
|
+
const rect = cell.getBoundingClientRect();
|
|
30803
|
+
left = Math.min(left, rect.left);
|
|
30804
|
+
top = Math.min(top, rect.top);
|
|
30805
|
+
right = Math.max(right, rect.right);
|
|
30806
|
+
bottom = Math.max(bottom, rect.bottom);
|
|
30807
|
+
});
|
|
30808
|
+
return {
|
|
30809
|
+
left: left - surfaceRect.left + surface.scrollLeft,
|
|
30810
|
+
top: top - surfaceRect.top + surface.scrollTop,
|
|
30811
|
+
width: right - left,
|
|
30812
|
+
height: bottom - top
|
|
30813
|
+
};
|
|
30814
|
+
}
|
|
29963
30815
|
var UEditor = import_react52.default.forwardRef(({
|
|
29964
30816
|
content = "",
|
|
29965
30817
|
onChange,
|
|
@@ -29979,7 +30831,11 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
29979
30831
|
maxCharacters,
|
|
29980
30832
|
minHeight = "200px",
|
|
29981
30833
|
maxHeight = "auto",
|
|
29982
|
-
variant = "default"
|
|
30834
|
+
variant = "default",
|
|
30835
|
+
fontFamilies,
|
|
30836
|
+
fontSizes,
|
|
30837
|
+
lineHeights,
|
|
30838
|
+
letterSpacings
|
|
29983
30839
|
}, ref) => {
|
|
29984
30840
|
const t = useSmartTranslations("UEditor");
|
|
29985
30841
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
@@ -30024,7 +30880,7 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
30024
30880
|
highlight.style.display = "none";
|
|
30025
30881
|
return;
|
|
30026
30882
|
}
|
|
30027
|
-
const metrics = getRelativeCellMetrics(surface, cell);
|
|
30883
|
+
const metrics = getRelativeSelectedCellsMetrics(surface) ?? getRelativeCellMetrics(surface, cell);
|
|
30028
30884
|
highlight.style.display = "block";
|
|
30029
30885
|
highlight.style.left = `${metrics.left}px`;
|
|
30030
30886
|
highlight.style.top = `${metrics.top}px`;
|
|
@@ -30127,8 +30983,10 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
30127
30983
|
"[&_ul[data-type='taskList']_li>label>input]:border-2",
|
|
30128
30984
|
"[&_ul[data-type='taskList']_li>label>input]:border-primary/50",
|
|
30129
30985
|
"[&_ul[data-type='taskList']_li>label>input]:accent-primary",
|
|
30130
|
-
"[&_pre]:bg-
|
|
30131
|
-
"[&_pre]:text-
|
|
30986
|
+
"[&_pre]:bg-muted/40!",
|
|
30987
|
+
"[&_pre]:text-foreground!",
|
|
30988
|
+
"[&_pre]:border!",
|
|
30989
|
+
"[&_pre]:border-border/60!",
|
|
30132
30990
|
"[&_pre_code]:bg-transparent!",
|
|
30133
30991
|
"[&_.tableWrapper]:overflow-x-auto",
|
|
30134
30992
|
"[&_.tableWrapper]:pb-1.5",
|
|
@@ -30148,6 +31006,11 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
30148
31006
|
"[&_table]:table-fixed",
|
|
30149
31007
|
"[&_table]:overflow-hidden",
|
|
30150
31008
|
"[&_table]:select-text",
|
|
31009
|
+
"[&_table[data-table-align]]:w-max",
|
|
31010
|
+
"[&_table[data-table-align]]:max-w-full",
|
|
31011
|
+
"[&_table[data-table-align='center']]:mx-auto",
|
|
31012
|
+
"[&_table[data-table-align='right']]:ml-auto",
|
|
31013
|
+
"[&_table[data-table-align='right']]:mr-0",
|
|
30151
31014
|
"[&_td]:relative",
|
|
30152
31015
|
"[&_td]:align-top",
|
|
30153
31016
|
"[&_td]:box-border",
|
|
@@ -30510,8 +31373,27 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
30510
31373
|
className
|
|
30511
31374
|
),
|
|
30512
31375
|
children: [
|
|
30513
|
-
editable && showToolbar && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
30514
|
-
|
|
31376
|
+
editable && showToolbar && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
31377
|
+
EditorToolbar,
|
|
31378
|
+
{
|
|
31379
|
+
editor,
|
|
31380
|
+
variant,
|
|
31381
|
+
uploadImage,
|
|
31382
|
+
imageInsertMode,
|
|
31383
|
+
fontFamilies,
|
|
31384
|
+
fontSizes,
|
|
31385
|
+
lineHeights,
|
|
31386
|
+
letterSpacings
|
|
31387
|
+
}
|
|
31388
|
+
),
|
|
31389
|
+
editable && showBubbleMenu && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
31390
|
+
CustomBubbleMenu,
|
|
31391
|
+
{
|
|
31392
|
+
editor,
|
|
31393
|
+
fontSizes,
|
|
31394
|
+
lineHeights
|
|
31395
|
+
}
|
|
31396
|
+
),
|
|
30515
31397
|
editable && showFloatingMenu && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(CustomFloatingMenu, { editor }),
|
|
30516
31398
|
/* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
|
|
30517
31399
|
"div",
|
|
@@ -30544,7 +31426,7 @@ var UEditor = import_react52.default.forwardRef(({
|
|
|
30544
31426
|
{
|
|
30545
31427
|
ref: activeTableCellHighlightRef,
|
|
30546
31428
|
"aria-hidden": "true",
|
|
30547
|
-
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-
|
|
31429
|
+
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10 transition-[left,top,width,height] duration-100"
|
|
30548
31430
|
}
|
|
30549
31431
|
),
|
|
30550
31432
|
editable && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(TableControls, { editor, containerRef: editorContentRef }),
|