@farmzone/fz-react-ui 1.1.8 → 1.1.10
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/dist/index.cjs +255 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +256 -53
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -279,6 +279,9 @@ var Z_INDEX = {
|
|
|
279
279
|
CALENDAR_PORTAL: 60,
|
|
280
280
|
TOOLTIP: 70,
|
|
281
281
|
SELECT_CONTENT: 100,
|
|
282
|
+
// body에 직접 mount되는 플로팅 메뉴(예: 에디터 멘션 제안 목록)가
|
|
283
|
+
// Modal(55) 안에서 열려도 가려지지 않도록 TOP(Toast) 바로 아래 배치
|
|
284
|
+
OVERLAY_POPUP: 9998,
|
|
282
285
|
TOP: 9999,
|
|
283
286
|
MODAL_Z_STEP: 10
|
|
284
287
|
};
|
|
@@ -515,6 +518,7 @@ function Input2(props) {
|
|
|
515
518
|
const handlePasswordToggle = () => setShowPassword((prev) => !prev);
|
|
516
519
|
const handleClear = () => onClear?.();
|
|
517
520
|
const shouldShowClearButton = clearable && !disabled && typeof rest.value === "string" && rest.value.length > 0;
|
|
521
|
+
const hasRightSlot = Boolean(rightIcon) || clearable && !disabled || shouldShowPasswordToggle;
|
|
518
522
|
const finalRightIcon = rightIcon || (shouldShowClearButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
519
523
|
"div",
|
|
520
524
|
{
|
|
@@ -561,7 +565,7 @@ function Input2(props) {
|
|
|
561
565
|
{
|
|
562
566
|
id: inputId,
|
|
563
567
|
type: actualType === "money" || actualType === "number" ? "text" : actualType,
|
|
564
|
-
className: cn("w-full", leftIcon && "pl-10",
|
|
568
|
+
className: cn("w-full", leftIcon && "pl-10", hasRightSlot && "pr-10", getStatusStyles(), className),
|
|
565
569
|
placeholder,
|
|
566
570
|
disabled,
|
|
567
571
|
ref,
|
|
@@ -1284,7 +1288,7 @@ function PopoverContent({
|
|
|
1284
1288
|
side: position,
|
|
1285
1289
|
sideOffset,
|
|
1286
1290
|
className: cn(
|
|
1287
|
-
"z-
|
|
1291
|
+
"z-100 w-72 rounded-md border border-neutral-200 bg-white p-4 text-neutral-950 shadow-md outline-none",
|
|
1288
1292
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
1289
1293
|
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
1290
1294
|
className
|
|
@@ -10069,7 +10073,7 @@ var LIGHT = {
|
|
|
10069
10073
|
toolbar: {
|
|
10070
10074
|
wrapper: "border-b border-gray-200 bg-white",
|
|
10071
10075
|
btnIdle: "text-gray-700 hover:bg-gray-100",
|
|
10072
|
-
btnActive: "bg-
|
|
10076
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,#e0e7ff)] text-[var(--rich-editor-accent-text,#4f46e5)]",
|
|
10073
10077
|
btnDestructive: "text-red-400 hover:bg-red-50 hover:text-red-600",
|
|
10074
10078
|
divider: "bg-gray-200",
|
|
10075
10079
|
rText: "text-gray-700"
|
|
@@ -10090,16 +10094,16 @@ var LIGHT = {
|
|
|
10090
10094
|
container: "border-gray-200 bg-white",
|
|
10091
10095
|
emptyText: "text-gray-400",
|
|
10092
10096
|
btnIdle: "text-gray-700 hover:bg-gray-100 hover:text-gray-900",
|
|
10093
|
-
btnSelected: "bg-
|
|
10097
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,#dbeafe)] text-[var(--rich-editor-accent-text,#1e3a8a)]",
|
|
10094
10098
|
badgeIdle: "bg-gray-100 text-gray-500",
|
|
10095
|
-
badgeSelected: "bg-
|
|
10099
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#bfdbfe)] text-[var(--rich-editor-accent-text,#1e40af)]"
|
|
10096
10100
|
}
|
|
10097
10101
|
};
|
|
10098
10102
|
var DARK = {
|
|
10099
10103
|
toolbar: {
|
|
10100
10104
|
wrapper: "border-b border-gray-800 bg-gray-900",
|
|
10101
10105
|
btnIdle: "text-gray-400 hover:bg-gray-800 hover:text-gray-200",
|
|
10102
|
-
btnActive: "bg-
|
|
10106
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,rgba(49,46,129,0.5))] text-[var(--rich-editor-accent-text,#818cf8)]",
|
|
10103
10107
|
btnDestructive: "text-red-400 hover:bg-red-900/30 hover:text-red-300",
|
|
10104
10108
|
divider: "bg-gray-800",
|
|
10105
10109
|
rText: "text-gray-400"
|
|
@@ -10120,9 +10124,9 @@ var DARK = {
|
|
|
10120
10124
|
container: "border-gray-700 bg-gray-900",
|
|
10121
10125
|
emptyText: "text-gray-500",
|
|
10122
10126
|
btnIdle: "text-gray-300 hover:bg-gray-800 hover:text-gray-100",
|
|
10123
|
-
btnSelected: "bg-
|
|
10127
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,rgba(30,58,138,0.5))] text-[var(--rich-editor-accent-text,#bfdbfe)]",
|
|
10124
10128
|
badgeIdle: "bg-gray-800 text-gray-400",
|
|
10125
|
-
badgeSelected: "bg-
|
|
10129
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#1e40af)] text-[var(--rich-editor-accent-text,#bfdbfe)]"
|
|
10126
10130
|
}
|
|
10127
10131
|
};
|
|
10128
10132
|
var RICH_EDITOR_THEMES = {
|
|
@@ -10135,8 +10139,12 @@ function useRichEditorTheme() {
|
|
|
10135
10139
|
return React6.useContext(RichEditorThemeContext);
|
|
10136
10140
|
}
|
|
10137
10141
|
var MentionList = React6.forwardRef((props, ref) => {
|
|
10138
|
-
const { items, command, loading, className } = props;
|
|
10142
|
+
const { items, command, loading, className, listClassName, accentColor, accentTextColor } = props;
|
|
10139
10143
|
const theme = useRichEditorTheme();
|
|
10144
|
+
const accentStyle = {
|
|
10145
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
10146
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
10147
|
+
};
|
|
10140
10148
|
const [selectedIndex, setSelectedIndex] = React6.useState(0);
|
|
10141
10149
|
const selectedRef = React6.useRef(null);
|
|
10142
10150
|
const selectItem = (index) => {
|
|
@@ -10166,41 +10174,58 @@ var MentionList = React6.forwardRef((props, ref) => {
|
|
|
10166
10174
|
return false;
|
|
10167
10175
|
}
|
|
10168
10176
|
}));
|
|
10169
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
"
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10177
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10178
|
+
"div",
|
|
10179
|
+
{
|
|
10180
|
+
className: cn("rich-editor-mention-list z-50 overflow-hidden rounded-md border shadow-md", theme.mention.container, className),
|
|
10181
|
+
style: accentStyle,
|
|
10182
|
+
children: loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-3 py-2 text-sm", theme.mention.emptyText), children: "\uAC80\uC0C9 \uC911..." }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-3 py-2 text-sm", theme.mention.emptyText), children: "\uAC80\uC0C9 \uACB0\uACFC \uC5C6\uC74C" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("max-h-68 overflow-y-auto p-1", listClassName), children: items.map((item, index) => {
|
|
10183
|
+
const isSelected = index === selectedIndex;
|
|
10184
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10185
|
+
"button",
|
|
10186
|
+
{
|
|
10187
|
+
ref: isSelected ? selectedRef : null,
|
|
10188
|
+
type: "button",
|
|
10189
|
+
onClick: () => selectItem(index),
|
|
10190
|
+
className: cn(
|
|
10191
|
+
"flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pl-2 pr-4 text-sm text-left select-none transition-colors",
|
|
10192
|
+
isSelected ? theme.mention.btnSelected : theme.mention.btnIdle
|
|
10193
|
+
),
|
|
10194
|
+
children: [
|
|
10195
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10196
|
+
"span",
|
|
10197
|
+
{
|
|
10198
|
+
className: cn(
|
|
10199
|
+
"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold",
|
|
10200
|
+
isSelected ? theme.mention.badgeSelected : theme.mention.badgeIdle
|
|
10201
|
+
),
|
|
10202
|
+
children: item.label[0]?.toUpperCase()
|
|
10203
|
+
}
|
|
10188
10204
|
),
|
|
10189
|
-
children: item.label
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
|
|
10194
|
-
}
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
}) }) });
|
|
10205
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: item.label })
|
|
10206
|
+
]
|
|
10207
|
+
},
|
|
10208
|
+
item.id
|
|
10209
|
+
);
|
|
10210
|
+
}) })
|
|
10211
|
+
}
|
|
10212
|
+
);
|
|
10198
10213
|
});
|
|
10199
10214
|
MentionList.displayName = "MentionList";
|
|
10200
10215
|
|
|
10201
10216
|
// src/components/RichEditor/config/extensions.ts
|
|
10202
10217
|
function buildExtensions(config) {
|
|
10203
|
-
const {
|
|
10218
|
+
const {
|
|
10219
|
+
toolbar,
|
|
10220
|
+
mentionUsers = [],
|
|
10221
|
+
onMentionSearch,
|
|
10222
|
+
mentionClassName,
|
|
10223
|
+
mentionListClassName,
|
|
10224
|
+
mentionTagClassName,
|
|
10225
|
+
accentColor,
|
|
10226
|
+
accentTextColor,
|
|
10227
|
+
zIndex
|
|
10228
|
+
} = config;
|
|
10204
10229
|
const exts = [extensionTextStyle.TextStyleKit, buildMarkResetOnEnter()];
|
|
10205
10230
|
const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
|
|
10206
10231
|
exts.push(
|
|
@@ -10241,7 +10266,7 @@ function buildExtensions(config) {
|
|
|
10241
10266
|
const ALL_ITEM = { id: "__all__", label: "\uBAA8\uB450" };
|
|
10242
10267
|
exts.push(
|
|
10243
10268
|
Mention__default.default.configure({
|
|
10244
|
-
HTMLAttributes: { class: "rich-editor-mention" },
|
|
10269
|
+
HTMLAttributes: { class: cn("rich-editor-mention", mentionTagClassName) },
|
|
10245
10270
|
suggestion: {
|
|
10246
10271
|
items: async ({ query }) => {
|
|
10247
10272
|
let items;
|
|
@@ -10257,18 +10282,25 @@ function buildExtensions(config) {
|
|
|
10257
10282
|
render: () => {
|
|
10258
10283
|
let component;
|
|
10259
10284
|
let unmount;
|
|
10285
|
+
const extraProps = {
|
|
10286
|
+
className: mentionClassName,
|
|
10287
|
+
listClassName: mentionListClassName,
|
|
10288
|
+
accentColor,
|
|
10289
|
+
accentTextColor
|
|
10290
|
+
};
|
|
10260
10291
|
return {
|
|
10261
10292
|
onStart: (props) => {
|
|
10262
10293
|
component = new react.ReactRenderer(MentionList, {
|
|
10263
|
-
props:
|
|
10294
|
+
props: { ...props, ...extraProps },
|
|
10264
10295
|
editor: props.editor
|
|
10265
10296
|
});
|
|
10266
10297
|
unmount = props.mount(component.element);
|
|
10298
|
+
if (component.element instanceof HTMLElement) {
|
|
10299
|
+
component.element.style.zIndex = String(zIndex ?? Z_INDEX.OVERLAY_POPUP);
|
|
10300
|
+
}
|
|
10267
10301
|
},
|
|
10268
10302
|
onUpdate: (props) => {
|
|
10269
|
-
component.updateProps(
|
|
10270
|
-
mentionClassName ? { ...props, className: mentionClassName } : props
|
|
10271
|
-
);
|
|
10303
|
+
component.updateProps({ ...props, ...extraProps });
|
|
10272
10304
|
},
|
|
10273
10305
|
onKeyDown: ({ event }) => {
|
|
10274
10306
|
return component.ref?.onKeyDown({ event }) ?? false;
|
|
@@ -10459,6 +10491,11 @@ function useRichEditor(options = {}) {
|
|
|
10459
10491
|
mentionUsers = [],
|
|
10460
10492
|
onMentionSearch,
|
|
10461
10493
|
mentionClassName,
|
|
10494
|
+
mentionListClassName,
|
|
10495
|
+
mentionTagClassName,
|
|
10496
|
+
accentColor,
|
|
10497
|
+
accentTextColor,
|
|
10498
|
+
zIndex,
|
|
10462
10499
|
editable = true,
|
|
10463
10500
|
autofocus,
|
|
10464
10501
|
editorClassName,
|
|
@@ -10476,7 +10513,12 @@ function useRichEditor(options = {}) {
|
|
|
10476
10513
|
toolbar,
|
|
10477
10514
|
mentionUsers,
|
|
10478
10515
|
onMentionSearch,
|
|
10479
|
-
mentionClassName
|
|
10516
|
+
mentionClassName,
|
|
10517
|
+
mentionListClassName,
|
|
10518
|
+
mentionTagClassName,
|
|
10519
|
+
accentColor,
|
|
10520
|
+
accentTextColor,
|
|
10521
|
+
zIndex
|
|
10480
10522
|
}),
|
|
10481
10523
|
...additionalExtensions
|
|
10482
10524
|
];
|
|
@@ -10578,6 +10620,97 @@ function RowIcon() {
|
|
|
10578
10620
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "8", width: "12", height: "5", rx: "1", fill: "currentColor", opacity: "0.15" })
|
|
10579
10621
|
] });
|
|
10580
10622
|
}
|
|
10623
|
+
var DEFAULT_COLOR_ROWS = [
|
|
10624
|
+
["#9CA3AF", "#60A5FA", "#2DD4BF", "#4ADE80", "#FACC15", "#FB923C", "#F472B6", "#C084FC"],
|
|
10625
|
+
["#4B5563", "#2563EB", "#0D9488", "#16A34A", "#CA8A04", "#EA580C", "#DC2626", "#9333EA"],
|
|
10626
|
+
["#1F2937", "#1E3A8A", "#134E4A", "#14532D", "#713F12", "#7C2D12", "#7F1D1D", "#581C87"]
|
|
10627
|
+
];
|
|
10628
|
+
function isLightColor(hex) {
|
|
10629
|
+
const normalized = hex.replace("#", "");
|
|
10630
|
+
if (normalized.length !== 6) return true;
|
|
10631
|
+
const r = parseInt(normalized.slice(0, 2), 16) / 255;
|
|
10632
|
+
const g = parseInt(normalized.slice(2, 4), 16) / 255;
|
|
10633
|
+
const b = parseInt(normalized.slice(4, 6), 16) / 255;
|
|
10634
|
+
const toLinear = (c) => c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
10635
|
+
const luminance = 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
10636
|
+
return luminance > 0.55;
|
|
10637
|
+
}
|
|
10638
|
+
function TextColorPicker({ editor, colors, currentColor, onClose }) {
|
|
10639
|
+
const [customColor, setCustomColor] = React6.useState(currentColor ?? "#000000");
|
|
10640
|
+
const rows = colors ? Array.isArray(colors[0]) ? colors : [colors] : DEFAULT_COLOR_ROWS;
|
|
10641
|
+
const applyColor = (color) => {
|
|
10642
|
+
editor.chain().focus().setColor(color).run();
|
|
10643
|
+
onClose();
|
|
10644
|
+
};
|
|
10645
|
+
const clearColor = () => {
|
|
10646
|
+
editor.chain().focus().unsetColor().run();
|
|
10647
|
+
onClose();
|
|
10648
|
+
};
|
|
10649
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-64 p-3", children: [
|
|
10650
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-xs font-medium text-gray-400", children: "\uD14D\uC2A4\uD2B8 \uC0C9\uC0C1" }),
|
|
10651
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: rows.map((row, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1", children: row.map((color) => {
|
|
10652
|
+
const isSelected = currentColor?.toLowerCase() === color.toLowerCase();
|
|
10653
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10654
|
+
"button",
|
|
10655
|
+
{
|
|
10656
|
+
type: "button",
|
|
10657
|
+
"aria-label": `\uAE00\uC790 \uC0C9\uC0C1 ${color}`,
|
|
10658
|
+
onClick: () => applyColor(color),
|
|
10659
|
+
className: cn(
|
|
10660
|
+
"flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-transform hover:scale-110",
|
|
10661
|
+
color.toLowerCase() === "#ffffff" ? "border-gray-300" : "border-black/10"
|
|
10662
|
+
),
|
|
10663
|
+
style: { backgroundColor: color },
|
|
10664
|
+
children: isSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
10665
|
+
lucideReact.Check,
|
|
10666
|
+
{
|
|
10667
|
+
size: 12,
|
|
10668
|
+
strokeWidth: 3,
|
|
10669
|
+
className: isLightColor(color) ? "text-gray-900" : "text-white"
|
|
10670
|
+
}
|
|
10671
|
+
)
|
|
10672
|
+
},
|
|
10673
|
+
color
|
|
10674
|
+
);
|
|
10675
|
+
}) }, rowIdx)) }),
|
|
10676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex items-center gap-2 border-t border-gray-100 pt-3", children: [
|
|
10677
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "relative size-7 shrink-0 cursor-pointer overflow-hidden rounded-full border border-gray-200", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10678
|
+
"input",
|
|
10679
|
+
{
|
|
10680
|
+
type: "color",
|
|
10681
|
+
value: customColor,
|
|
10682
|
+
onChange: (e) => {
|
|
10683
|
+
setCustomColor(e.target.value);
|
|
10684
|
+
applyColor(e.target.value);
|
|
10685
|
+
},
|
|
10686
|
+
className: "absolute -left-1 -top-1 size-9 cursor-pointer"
|
|
10687
|
+
}
|
|
10688
|
+
) }),
|
|
10689
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10690
|
+
"input",
|
|
10691
|
+
{
|
|
10692
|
+
type: "text",
|
|
10693
|
+
value: customColor,
|
|
10694
|
+
onChange: (e) => setCustomColor(e.target.value),
|
|
10695
|
+
onKeyDown: (e) => {
|
|
10696
|
+
if (e.key === "Enter") applyColor(customColor);
|
|
10697
|
+
},
|
|
10698
|
+
placeholder: "#RRGGBB",
|
|
10699
|
+
className: "h-7 flex-1 rounded border border-gray-200 px-2 text-xs text-gray-700 outline-none focus:border-indigo-400"
|
|
10700
|
+
}
|
|
10701
|
+
)
|
|
10702
|
+
] }),
|
|
10703
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10704
|
+
"button",
|
|
10705
|
+
{
|
|
10706
|
+
type: "button",
|
|
10707
|
+
onClick: clearColor,
|
|
10708
|
+
className: "mt-2 w-full cursor-pointer rounded py-1 text-xs font-medium text-gray-500 hover:bg-gray-100",
|
|
10709
|
+
children: "\uC0C9\uC0C1 \uC9C0\uC6B0\uAE30"
|
|
10710
|
+
}
|
|
10711
|
+
)
|
|
10712
|
+
] });
|
|
10713
|
+
}
|
|
10581
10714
|
function ToolbarButton(props) {
|
|
10582
10715
|
const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
|
|
10583
10716
|
const theme = useRichEditorTheme();
|
|
@@ -10610,9 +10743,11 @@ function cmd(fn) {
|
|
|
10610
10743
|
};
|
|
10611
10744
|
}
|
|
10612
10745
|
function RichEditorToolbar(props) {
|
|
10613
|
-
const { editor, toolbar = {}, className } = props;
|
|
10746
|
+
const { editor, toolbar = {}, className, zIndex } = props;
|
|
10747
|
+
const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
|
|
10614
10748
|
const theme = useRichEditorTheme();
|
|
10615
10749
|
const [tablePickerOpen, setTablePickerOpen] = React6.useState(false);
|
|
10750
|
+
const [colorPickerOpen, setColorPickerOpen] = React6.useState(false);
|
|
10616
10751
|
const stateOrNull = react.useEditorState({
|
|
10617
10752
|
editor,
|
|
10618
10753
|
selector: ({ editor: e }) => ({
|
|
@@ -10631,7 +10766,8 @@ function RichEditorToolbar(props) {
|
|
|
10631
10766
|
isOrderedList: e?.isActive("orderedList") ?? false,
|
|
10632
10767
|
isBlockquote: e?.isActive("blockquote") ?? false,
|
|
10633
10768
|
isCodeBlock: e?.isActive("codeBlock") ?? false,
|
|
10634
|
-
isTable: e?.isActive("table") ?? false
|
|
10769
|
+
isTable: e?.isActive("table") ?? false,
|
|
10770
|
+
textColor: e?.getAttributes("textStyle").color ?? null
|
|
10635
10771
|
})
|
|
10636
10772
|
});
|
|
10637
10773
|
if (!editor) return null;
|
|
@@ -10651,7 +10787,8 @@ function RichEditorToolbar(props) {
|
|
|
10651
10787
|
isOrderedList: false,
|
|
10652
10788
|
isBlockquote: false,
|
|
10653
10789
|
isCodeBlock: false,
|
|
10654
|
-
isTable: false
|
|
10790
|
+
isTable: false,
|
|
10791
|
+
textColor: null
|
|
10655
10792
|
};
|
|
10656
10793
|
const showHeadingGroup = toolbar.heading !== false && (Array.isArray(toolbar.heading) ? toolbar.heading.length > 0 : true);
|
|
10657
10794
|
const showInlineGroup = toolbar.bold !== false || toolbar.italic !== false || toolbar.strike !== false || toolbar.code !== false;
|
|
@@ -10749,8 +10886,44 @@ function RichEditorToolbar(props) {
|
|
|
10749
10886
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { size: 16 })
|
|
10750
10887
|
}
|
|
10751
10888
|
),
|
|
10752
|
-
|
|
10889
|
+
toolbar.textColor && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10753
10890
|
showInlineGroup && /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
|
|
10891
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open: colorPickerOpen, onOpenChange: setColorPickerOpen, children: [
|
|
10892
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10893
|
+
"button",
|
|
10894
|
+
{
|
|
10895
|
+
type: "button",
|
|
10896
|
+
"aria-label": "\uAE00\uC790 \uC0C9\uC0C1",
|
|
10897
|
+
className: cn(
|
|
10898
|
+
"flex h-8 w-8 cursor-pointer flex-col items-center justify-center gap-0.5 rounded text-sm transition-colors",
|
|
10899
|
+
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
10900
|
+
state.textColor ? theme.toolbar.btnActive : theme.toolbar.btnIdle
|
|
10901
|
+
),
|
|
10902
|
+
children: [
|
|
10903
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Baseline, { size: 16 }),
|
|
10904
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10905
|
+
"span",
|
|
10906
|
+
{
|
|
10907
|
+
className: "h-0.5 w-4 rounded-full",
|
|
10908
|
+
style: { backgroundColor: state.textColor ?? "currentColor" }
|
|
10909
|
+
}
|
|
10910
|
+
)
|
|
10911
|
+
]
|
|
10912
|
+
}
|
|
10913
|
+
) }),
|
|
10914
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", style: popoverStyle, children: editor && /* @__PURE__ */ jsxRuntime.jsx(
|
|
10915
|
+
TextColorPicker,
|
|
10916
|
+
{
|
|
10917
|
+
editor,
|
|
10918
|
+
currentColor: state.textColor,
|
|
10919
|
+
colors: Array.isArray(toolbar.textColor) ? toolbar.textColor : void 0,
|
|
10920
|
+
onClose: () => setColorPickerOpen(false)
|
|
10921
|
+
}
|
|
10922
|
+
) })
|
|
10923
|
+
] })
|
|
10924
|
+
] }),
|
|
10925
|
+
showAlignGroup && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10926
|
+
(showInlineGroup || toolbar.textColor) && /* @__PURE__ */ jsxRuntime.jsx(Divider, {}),
|
|
10754
10927
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10755
10928
|
ToolbarButton,
|
|
10756
10929
|
{
|
|
@@ -10848,7 +11021,7 @@ function RichEditorToolbar(props) {
|
|
|
10848
11021
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Table, { size: 16 })
|
|
10849
11022
|
}
|
|
10850
11023
|
) }),
|
|
10851
|
-
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", children: editor && /* @__PURE__ */ jsxRuntime.jsx(TableGridPicker, { editor, onClose: () => setTablePickerOpen(false) }) })
|
|
11024
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", style: popoverStyle, children: editor && /* @__PURE__ */ jsxRuntime.jsx(TableGridPicker, { editor, onClose: () => setTablePickerOpen(false) }) })
|
|
10852
11025
|
] }),
|
|
10853
11026
|
state.isTable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10854
11027
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -10943,7 +11116,8 @@ var DEFAULT_TOOLBAR = {
|
|
|
10943
11116
|
bulletList: true,
|
|
10944
11117
|
orderedList: true,
|
|
10945
11118
|
blockquote: true,
|
|
10946
|
-
code: true
|
|
11119
|
+
code: true,
|
|
11120
|
+
textColor: true
|
|
10947
11121
|
};
|
|
10948
11122
|
function RichEditorContent(props) {
|
|
10949
11123
|
const { editor, className, editorClassName, minHeight, maxHeight } = props;
|
|
@@ -10953,7 +11127,20 @@ function RichEditorContent(props) {
|
|
|
10953
11127
|
style.maxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
10954
11128
|
style.overflowY = "auto";
|
|
10955
11129
|
}
|
|
10956
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11131
|
+
"div",
|
|
11132
|
+
{
|
|
11133
|
+
className: cn("rich-editor-content cursor-text", className),
|
|
11134
|
+
style,
|
|
11135
|
+
onMouseDown: (e) => {
|
|
11136
|
+
if (!editor) return;
|
|
11137
|
+
if (e.target.closest(".ProseMirror")) return;
|
|
11138
|
+
e.preventDefault();
|
|
11139
|
+
editor.commands.focus("end");
|
|
11140
|
+
},
|
|
11141
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.EditorContent, { editor, className: cn("h-full", editorClassName) })
|
|
11142
|
+
}
|
|
11143
|
+
);
|
|
10957
11144
|
}
|
|
10958
11145
|
var RichEditor = React6.forwardRef(function RichEditor2({
|
|
10959
11146
|
value,
|
|
@@ -10972,6 +11159,11 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
10972
11159
|
bodyClassName,
|
|
10973
11160
|
editorClassName,
|
|
10974
11161
|
mentionClassName,
|
|
11162
|
+
mentionListClassName,
|
|
11163
|
+
mentionTagClassName,
|
|
11164
|
+
accentColor,
|
|
11165
|
+
accentTextColor,
|
|
11166
|
+
zIndex,
|
|
10975
11167
|
themeTokens,
|
|
10976
11168
|
editable = true,
|
|
10977
11169
|
autofocus
|
|
@@ -10997,6 +11189,11 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
10997
11189
|
mentionUsers,
|
|
10998
11190
|
onMentionSearch,
|
|
10999
11191
|
mentionClassName,
|
|
11192
|
+
mentionListClassName,
|
|
11193
|
+
mentionTagClassName,
|
|
11194
|
+
accentColor,
|
|
11195
|
+
accentTextColor,
|
|
11196
|
+
zIndex,
|
|
11000
11197
|
additionalExtensions,
|
|
11001
11198
|
editable,
|
|
11002
11199
|
autofocus,
|
|
@@ -11042,17 +11239,23 @@ var RichEditor = React6.forwardRef(function RichEditor2({
|
|
|
11042
11239
|
...themeTokens.toolbar && { toolbar: { ...baseTheme.toolbar, ...themeTokens.toolbar } },
|
|
11043
11240
|
...themeTokens.mention && { mention: { ...baseTheme.mention, ...themeTokens.mention } }
|
|
11044
11241
|
} : baseTheme;
|
|
11242
|
+
const accentStyle = {
|
|
11243
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
11244
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
11245
|
+
};
|
|
11045
11246
|
return /* @__PURE__ */ jsxRuntime.jsx(RichEditorThemeProvider, { value: resolvedTheme, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11046
11247
|
"div",
|
|
11047
11248
|
{
|
|
11048
11249
|
className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
|
|
11049
11250
|
"data-rich-editor-theme": theme,
|
|
11251
|
+
style: accentStyle,
|
|
11050
11252
|
children: [
|
|
11051
11253
|
isToolbarVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
11052
11254
|
RichEditorToolbar,
|
|
11053
11255
|
{
|
|
11054
11256
|
editor,
|
|
11055
|
-
toolbar: activeToolbar
|
|
11257
|
+
toolbar: activeToolbar,
|
|
11258
|
+
zIndex
|
|
11056
11259
|
}
|
|
11057
11260
|
),
|
|
11058
11261
|
/* @__PURE__ */ jsxRuntime.jsx(
|