@farmzone/fz-react-ui 1.1.9 → 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 +253 -51
- 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 +254 -52
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1311,6 +1311,7 @@ interface RichEditorToolbarConfig {
|
|
|
1311
1311
|
mention?: boolean;
|
|
1312
1312
|
mentionAll?: boolean;
|
|
1313
1313
|
table?: boolean;
|
|
1314
|
+
textColor?: boolean | string[];
|
|
1314
1315
|
placeholder?: string;
|
|
1315
1316
|
}
|
|
1316
1317
|
interface RichEditorHandle {
|
|
@@ -1339,6 +1340,11 @@ interface RichEditorProps {
|
|
|
1339
1340
|
bodyClassName?: string;
|
|
1340
1341
|
editorClassName?: string;
|
|
1341
1342
|
mentionClassName?: string;
|
|
1343
|
+
mentionListClassName?: string;
|
|
1344
|
+
mentionTagClassName?: string;
|
|
1345
|
+
accentColor?: string;
|
|
1346
|
+
accentTextColor?: string;
|
|
1347
|
+
zIndex?: number;
|
|
1342
1348
|
editable?: boolean;
|
|
1343
1349
|
autofocus?: boolean | "start" | "end" | "all" | null;
|
|
1344
1350
|
onSubmit?: () => void;
|
|
@@ -1349,6 +1355,11 @@ interface UseRichEditorOptions {
|
|
|
1349
1355
|
mentionUsers?: MentionItem[];
|
|
1350
1356
|
onMentionSearch?: (query: string) => MentionItem[] | Promise<MentionItem[]>;
|
|
1351
1357
|
mentionClassName?: string;
|
|
1358
|
+
mentionListClassName?: string;
|
|
1359
|
+
mentionTagClassName?: string;
|
|
1360
|
+
accentColor?: string;
|
|
1361
|
+
accentTextColor?: string;
|
|
1362
|
+
zIndex?: number;
|
|
1352
1363
|
editable?: boolean;
|
|
1353
1364
|
autofocus?: boolean | "start" | "end" | "all" | null;
|
|
1354
1365
|
editorClassName?: string;
|
|
@@ -1367,6 +1378,7 @@ interface RichEditorToolbarProps {
|
|
|
1367
1378
|
editor: _tiptap_core.Editor | null;
|
|
1368
1379
|
toolbar?: RichEditorToolbarConfig;
|
|
1369
1380
|
className?: string;
|
|
1381
|
+
zIndex?: number;
|
|
1370
1382
|
}
|
|
1371
1383
|
|
|
1372
1384
|
interface UseRichEditorReturn {
|
|
@@ -1630,6 +1642,7 @@ declare const Z_INDEX: {
|
|
|
1630
1642
|
readonly CALENDAR_PORTAL: 60;
|
|
1631
1643
|
readonly TOOLTIP: 70;
|
|
1632
1644
|
readonly SELECT_CONTENT: 100;
|
|
1645
|
+
readonly OVERLAY_POPUP: 9998;
|
|
1633
1646
|
readonly TOP: 9999;
|
|
1634
1647
|
readonly MODAL_Z_STEP: 10;
|
|
1635
1648
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1311,6 +1311,7 @@ interface RichEditorToolbarConfig {
|
|
|
1311
1311
|
mention?: boolean;
|
|
1312
1312
|
mentionAll?: boolean;
|
|
1313
1313
|
table?: boolean;
|
|
1314
|
+
textColor?: boolean | string[];
|
|
1314
1315
|
placeholder?: string;
|
|
1315
1316
|
}
|
|
1316
1317
|
interface RichEditorHandle {
|
|
@@ -1339,6 +1340,11 @@ interface RichEditorProps {
|
|
|
1339
1340
|
bodyClassName?: string;
|
|
1340
1341
|
editorClassName?: string;
|
|
1341
1342
|
mentionClassName?: string;
|
|
1343
|
+
mentionListClassName?: string;
|
|
1344
|
+
mentionTagClassName?: string;
|
|
1345
|
+
accentColor?: string;
|
|
1346
|
+
accentTextColor?: string;
|
|
1347
|
+
zIndex?: number;
|
|
1342
1348
|
editable?: boolean;
|
|
1343
1349
|
autofocus?: boolean | "start" | "end" | "all" | null;
|
|
1344
1350
|
onSubmit?: () => void;
|
|
@@ -1349,6 +1355,11 @@ interface UseRichEditorOptions {
|
|
|
1349
1355
|
mentionUsers?: MentionItem[];
|
|
1350
1356
|
onMentionSearch?: (query: string) => MentionItem[] | Promise<MentionItem[]>;
|
|
1351
1357
|
mentionClassName?: string;
|
|
1358
|
+
mentionListClassName?: string;
|
|
1359
|
+
mentionTagClassName?: string;
|
|
1360
|
+
accentColor?: string;
|
|
1361
|
+
accentTextColor?: string;
|
|
1362
|
+
zIndex?: number;
|
|
1352
1363
|
editable?: boolean;
|
|
1353
1364
|
autofocus?: boolean | "start" | "end" | "all" | null;
|
|
1354
1365
|
editorClassName?: string;
|
|
@@ -1367,6 +1378,7 @@ interface RichEditorToolbarProps {
|
|
|
1367
1378
|
editor: _tiptap_core.Editor | null;
|
|
1368
1379
|
toolbar?: RichEditorToolbarConfig;
|
|
1369
1380
|
className?: string;
|
|
1381
|
+
zIndex?: number;
|
|
1370
1382
|
}
|
|
1371
1383
|
|
|
1372
1384
|
interface UseRichEditorReturn {
|
|
@@ -1630,6 +1642,7 @@ declare const Z_INDEX: {
|
|
|
1630
1642
|
readonly CALENDAR_PORTAL: 60;
|
|
1631
1643
|
readonly TOOLTIP: 70;
|
|
1632
1644
|
readonly SELECT_CONTENT: 100;
|
|
1645
|
+
readonly OVERLAY_POPUP: 9998;
|
|
1633
1646
|
readonly TOP: 9999;
|
|
1634
1647
|
readonly MODAL_Z_STEP: 10;
|
|
1635
1648
|
};
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as React6 from 'react';
|
|
|
6
6
|
import React6__default, { forwardRef, useState, useRef, useEffect, useImperativeHandle, useCallback, memo, createContext, useContext, useMemo, useId, useLayoutEffect, useDeferredValue, Fragment as Fragment$1 } from 'react';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
8
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
9
|
-
import { ChevronLeft, ChevronRight, FileText, ZoomIn, ZoomOut, RotateCcw, RotateCw, Download, X, Heading1, Heading2, Heading3, Heading4, Bold, Italic, Strikethrough, Code, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Quote, FileCode, Table as Table$1, Plus, Minus, Trash2, CircleX, EyeOff, Eye,
|
|
9
|
+
import { ChevronLeft, ChevronRight, FileText, ZoomIn, ZoomOut, RotateCcw, RotateCw, Download, X, Heading1, Heading2, Heading3, Heading4, Bold, Italic, Strikethrough, Code, Baseline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Quote, FileCode, Table as Table$1, Plus, Minus, Trash2, Check, CircleX, EyeOff, Eye, ChevronDown, Calendar, CircleIcon, ChevronUp, Search, TriangleAlert, Info, Pencil, BadgePlus, FileSearch2, Upload, FileUp, PanelRightClose, PanelLeftClose, ChevronFirst, ChevronLast, MoreHorizontal } from 'lucide-react';
|
|
10
10
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
11
11
|
import * as RadixSlider from '@radix-ui/react-slider';
|
|
12
12
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
@@ -242,6 +242,9 @@ var Z_INDEX = {
|
|
|
242
242
|
CALENDAR_PORTAL: 60,
|
|
243
243
|
TOOLTIP: 70,
|
|
244
244
|
SELECT_CONTENT: 100,
|
|
245
|
+
// body에 직접 mount되는 플로팅 메뉴(예: 에디터 멘션 제안 목록)가
|
|
246
|
+
// Modal(55) 안에서 열려도 가려지지 않도록 TOP(Toast) 바로 아래 배치
|
|
247
|
+
OVERLAY_POPUP: 9998,
|
|
245
248
|
TOP: 9999,
|
|
246
249
|
MODAL_Z_STEP: 10
|
|
247
250
|
};
|
|
@@ -1248,7 +1251,7 @@ function PopoverContent({
|
|
|
1248
1251
|
side: position,
|
|
1249
1252
|
sideOffset,
|
|
1250
1253
|
className: cn(
|
|
1251
|
-
"z-
|
|
1254
|
+
"z-100 w-72 rounded-md border border-neutral-200 bg-white p-4 text-neutral-950 shadow-md outline-none",
|
|
1252
1255
|
"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",
|
|
1253
1256
|
"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",
|
|
1254
1257
|
className
|
|
@@ -10033,7 +10036,7 @@ var LIGHT = {
|
|
|
10033
10036
|
toolbar: {
|
|
10034
10037
|
wrapper: "border-b border-gray-200 bg-white",
|
|
10035
10038
|
btnIdle: "text-gray-700 hover:bg-gray-100",
|
|
10036
|
-
btnActive: "bg-
|
|
10039
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,#e0e7ff)] text-[var(--rich-editor-accent-text,#4f46e5)]",
|
|
10037
10040
|
btnDestructive: "text-red-400 hover:bg-red-50 hover:text-red-600",
|
|
10038
10041
|
divider: "bg-gray-200",
|
|
10039
10042
|
rText: "text-gray-700"
|
|
@@ -10054,16 +10057,16 @@ var LIGHT = {
|
|
|
10054
10057
|
container: "border-gray-200 bg-white",
|
|
10055
10058
|
emptyText: "text-gray-400",
|
|
10056
10059
|
btnIdle: "text-gray-700 hover:bg-gray-100 hover:text-gray-900",
|
|
10057
|
-
btnSelected: "bg-
|
|
10060
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,#dbeafe)] text-[var(--rich-editor-accent-text,#1e3a8a)]",
|
|
10058
10061
|
badgeIdle: "bg-gray-100 text-gray-500",
|
|
10059
|
-
badgeSelected: "bg-
|
|
10062
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#bfdbfe)] text-[var(--rich-editor-accent-text,#1e40af)]"
|
|
10060
10063
|
}
|
|
10061
10064
|
};
|
|
10062
10065
|
var DARK = {
|
|
10063
10066
|
toolbar: {
|
|
10064
10067
|
wrapper: "border-b border-gray-800 bg-gray-900",
|
|
10065
10068
|
btnIdle: "text-gray-400 hover:bg-gray-800 hover:text-gray-200",
|
|
10066
|
-
btnActive: "bg-
|
|
10069
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,rgba(49,46,129,0.5))] text-[var(--rich-editor-accent-text,#818cf8)]",
|
|
10067
10070
|
btnDestructive: "text-red-400 hover:bg-red-900/30 hover:text-red-300",
|
|
10068
10071
|
divider: "bg-gray-800",
|
|
10069
10072
|
rText: "text-gray-400"
|
|
@@ -10084,9 +10087,9 @@ var DARK = {
|
|
|
10084
10087
|
container: "border-gray-700 bg-gray-900",
|
|
10085
10088
|
emptyText: "text-gray-500",
|
|
10086
10089
|
btnIdle: "text-gray-300 hover:bg-gray-800 hover:text-gray-100",
|
|
10087
|
-
btnSelected: "bg-
|
|
10090
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,rgba(30,58,138,0.5))] text-[var(--rich-editor-accent-text,#bfdbfe)]",
|
|
10088
10091
|
badgeIdle: "bg-gray-800 text-gray-400",
|
|
10089
|
-
badgeSelected: "bg-
|
|
10092
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#1e40af)] text-[var(--rich-editor-accent-text,#bfdbfe)]"
|
|
10090
10093
|
}
|
|
10091
10094
|
};
|
|
10092
10095
|
var RICH_EDITOR_THEMES = {
|
|
@@ -10099,8 +10102,12 @@ function useRichEditorTheme() {
|
|
|
10099
10102
|
return useContext(RichEditorThemeContext);
|
|
10100
10103
|
}
|
|
10101
10104
|
var MentionList = forwardRef((props, ref) => {
|
|
10102
|
-
const { items, command, loading, className } = props;
|
|
10105
|
+
const { items, command, loading, className, listClassName, accentColor, accentTextColor } = props;
|
|
10103
10106
|
const theme = useRichEditorTheme();
|
|
10107
|
+
const accentStyle = {
|
|
10108
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
10109
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
10110
|
+
};
|
|
10104
10111
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
10105
10112
|
const selectedRef = useRef(null);
|
|
10106
10113
|
const selectItem = (index) => {
|
|
@@ -10130,41 +10137,58 @@ var MentionList = forwardRef((props, ref) => {
|
|
|
10130
10137
|
return false;
|
|
10131
10138
|
}
|
|
10132
10139
|
}));
|
|
10133
|
-
return /* @__PURE__ */ jsx(
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
"
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10140
|
+
return /* @__PURE__ */ jsx(
|
|
10141
|
+
"div",
|
|
10142
|
+
{
|
|
10143
|
+
className: cn("rich-editor-mention-list z-50 overflow-hidden rounded-md border shadow-md", theme.mention.container, className),
|
|
10144
|
+
style: accentStyle,
|
|
10145
|
+
children: loading ? /* @__PURE__ */ jsx("div", { className: cn("px-3 py-2 text-sm", theme.mention.emptyText), children: "\uAC80\uC0C9 \uC911..." }) : items.length === 0 ? /* @__PURE__ */ jsx("div", { className: cn("px-3 py-2 text-sm", theme.mention.emptyText), children: "\uAC80\uC0C9 \uACB0\uACFC \uC5C6\uC74C" }) : /* @__PURE__ */ jsx("div", { className: cn("max-h-68 overflow-y-auto p-1", listClassName), children: items.map((item, index) => {
|
|
10146
|
+
const isSelected = index === selectedIndex;
|
|
10147
|
+
return /* @__PURE__ */ jsxs(
|
|
10148
|
+
"button",
|
|
10149
|
+
{
|
|
10150
|
+
ref: isSelected ? selectedRef : null,
|
|
10151
|
+
type: "button",
|
|
10152
|
+
onClick: () => selectItem(index),
|
|
10153
|
+
className: cn(
|
|
10154
|
+
"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",
|
|
10155
|
+
isSelected ? theme.mention.btnSelected : theme.mention.btnIdle
|
|
10156
|
+
),
|
|
10157
|
+
children: [
|
|
10158
|
+
/* @__PURE__ */ jsx(
|
|
10159
|
+
"span",
|
|
10160
|
+
{
|
|
10161
|
+
className: cn(
|
|
10162
|
+
"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold",
|
|
10163
|
+
isSelected ? theme.mention.badgeSelected : theme.mention.badgeIdle
|
|
10164
|
+
),
|
|
10165
|
+
children: item.label[0]?.toUpperCase()
|
|
10166
|
+
}
|
|
10152
10167
|
),
|
|
10153
|
-
children: item.label
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
}
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
}) }) });
|
|
10168
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: item.label })
|
|
10169
|
+
]
|
|
10170
|
+
},
|
|
10171
|
+
item.id
|
|
10172
|
+
);
|
|
10173
|
+
}) })
|
|
10174
|
+
}
|
|
10175
|
+
);
|
|
10162
10176
|
});
|
|
10163
10177
|
MentionList.displayName = "MentionList";
|
|
10164
10178
|
|
|
10165
10179
|
// src/components/RichEditor/config/extensions.ts
|
|
10166
10180
|
function buildExtensions(config) {
|
|
10167
|
-
const {
|
|
10181
|
+
const {
|
|
10182
|
+
toolbar,
|
|
10183
|
+
mentionUsers = [],
|
|
10184
|
+
onMentionSearch,
|
|
10185
|
+
mentionClassName,
|
|
10186
|
+
mentionListClassName,
|
|
10187
|
+
mentionTagClassName,
|
|
10188
|
+
accentColor,
|
|
10189
|
+
accentTextColor,
|
|
10190
|
+
zIndex
|
|
10191
|
+
} = config;
|
|
10168
10192
|
const exts = [TextStyleKit, buildMarkResetOnEnter()];
|
|
10169
10193
|
const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
|
|
10170
10194
|
exts.push(
|
|
@@ -10205,7 +10229,7 @@ function buildExtensions(config) {
|
|
|
10205
10229
|
const ALL_ITEM = { id: "__all__", label: "\uBAA8\uB450" };
|
|
10206
10230
|
exts.push(
|
|
10207
10231
|
Mention.configure({
|
|
10208
|
-
HTMLAttributes: { class: "rich-editor-mention" },
|
|
10232
|
+
HTMLAttributes: { class: cn("rich-editor-mention", mentionTagClassName) },
|
|
10209
10233
|
suggestion: {
|
|
10210
10234
|
items: async ({ query }) => {
|
|
10211
10235
|
let items;
|
|
@@ -10221,18 +10245,25 @@ function buildExtensions(config) {
|
|
|
10221
10245
|
render: () => {
|
|
10222
10246
|
let component;
|
|
10223
10247
|
let unmount;
|
|
10248
|
+
const extraProps = {
|
|
10249
|
+
className: mentionClassName,
|
|
10250
|
+
listClassName: mentionListClassName,
|
|
10251
|
+
accentColor,
|
|
10252
|
+
accentTextColor
|
|
10253
|
+
};
|
|
10224
10254
|
return {
|
|
10225
10255
|
onStart: (props) => {
|
|
10226
10256
|
component = new ReactRenderer(MentionList, {
|
|
10227
|
-
props:
|
|
10257
|
+
props: { ...props, ...extraProps },
|
|
10228
10258
|
editor: props.editor
|
|
10229
10259
|
});
|
|
10230
10260
|
unmount = props.mount(component.element);
|
|
10261
|
+
if (component.element instanceof HTMLElement) {
|
|
10262
|
+
component.element.style.zIndex = String(zIndex ?? Z_INDEX.OVERLAY_POPUP);
|
|
10263
|
+
}
|
|
10231
10264
|
},
|
|
10232
10265
|
onUpdate: (props) => {
|
|
10233
|
-
component.updateProps(
|
|
10234
|
-
mentionClassName ? { ...props, className: mentionClassName } : props
|
|
10235
|
-
);
|
|
10266
|
+
component.updateProps({ ...props, ...extraProps });
|
|
10236
10267
|
},
|
|
10237
10268
|
onKeyDown: ({ event }) => {
|
|
10238
10269
|
return component.ref?.onKeyDown({ event }) ?? false;
|
|
@@ -10423,6 +10454,11 @@ function useRichEditor(options = {}) {
|
|
|
10423
10454
|
mentionUsers = [],
|
|
10424
10455
|
onMentionSearch,
|
|
10425
10456
|
mentionClassName,
|
|
10457
|
+
mentionListClassName,
|
|
10458
|
+
mentionTagClassName,
|
|
10459
|
+
accentColor,
|
|
10460
|
+
accentTextColor,
|
|
10461
|
+
zIndex,
|
|
10426
10462
|
editable = true,
|
|
10427
10463
|
autofocus,
|
|
10428
10464
|
editorClassName,
|
|
@@ -10440,7 +10476,12 @@ function useRichEditor(options = {}) {
|
|
|
10440
10476
|
toolbar,
|
|
10441
10477
|
mentionUsers,
|
|
10442
10478
|
onMentionSearch,
|
|
10443
|
-
mentionClassName
|
|
10479
|
+
mentionClassName,
|
|
10480
|
+
mentionListClassName,
|
|
10481
|
+
mentionTagClassName,
|
|
10482
|
+
accentColor,
|
|
10483
|
+
accentTextColor,
|
|
10484
|
+
zIndex
|
|
10444
10485
|
}),
|
|
10445
10486
|
...additionalExtensions
|
|
10446
10487
|
];
|
|
@@ -10542,6 +10583,97 @@ function RowIcon() {
|
|
|
10542
10583
|
/* @__PURE__ */ jsx("rect", { x: "1", y: "8", width: "12", height: "5", rx: "1", fill: "currentColor", opacity: "0.15" })
|
|
10543
10584
|
] });
|
|
10544
10585
|
}
|
|
10586
|
+
var DEFAULT_COLOR_ROWS = [
|
|
10587
|
+
["#9CA3AF", "#60A5FA", "#2DD4BF", "#4ADE80", "#FACC15", "#FB923C", "#F472B6", "#C084FC"],
|
|
10588
|
+
["#4B5563", "#2563EB", "#0D9488", "#16A34A", "#CA8A04", "#EA580C", "#DC2626", "#9333EA"],
|
|
10589
|
+
["#1F2937", "#1E3A8A", "#134E4A", "#14532D", "#713F12", "#7C2D12", "#7F1D1D", "#581C87"]
|
|
10590
|
+
];
|
|
10591
|
+
function isLightColor(hex) {
|
|
10592
|
+
const normalized = hex.replace("#", "");
|
|
10593
|
+
if (normalized.length !== 6) return true;
|
|
10594
|
+
const r = parseInt(normalized.slice(0, 2), 16) / 255;
|
|
10595
|
+
const g = parseInt(normalized.slice(2, 4), 16) / 255;
|
|
10596
|
+
const b = parseInt(normalized.slice(4, 6), 16) / 255;
|
|
10597
|
+
const toLinear = (c) => c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
10598
|
+
const luminance = 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
10599
|
+
return luminance > 0.55;
|
|
10600
|
+
}
|
|
10601
|
+
function TextColorPicker({ editor, colors, currentColor, onClose }) {
|
|
10602
|
+
const [customColor, setCustomColor] = useState(currentColor ?? "#000000");
|
|
10603
|
+
const rows = colors ? Array.isArray(colors[0]) ? colors : [colors] : DEFAULT_COLOR_ROWS;
|
|
10604
|
+
const applyColor = (color) => {
|
|
10605
|
+
editor.chain().focus().setColor(color).run();
|
|
10606
|
+
onClose();
|
|
10607
|
+
};
|
|
10608
|
+
const clearColor = () => {
|
|
10609
|
+
editor.chain().focus().unsetColor().run();
|
|
10610
|
+
onClose();
|
|
10611
|
+
};
|
|
10612
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-64 p-3", children: [
|
|
10613
|
+
/* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-medium text-gray-400", children: "\uD14D\uC2A4\uD2B8 \uC0C9\uC0C1" }),
|
|
10614
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: rows.map((row, rowIdx) => /* @__PURE__ */ jsx("div", { className: "flex gap-1", children: row.map((color) => {
|
|
10615
|
+
const isSelected = currentColor?.toLowerCase() === color.toLowerCase();
|
|
10616
|
+
return /* @__PURE__ */ jsx(
|
|
10617
|
+
"button",
|
|
10618
|
+
{
|
|
10619
|
+
type: "button",
|
|
10620
|
+
"aria-label": `\uAE00\uC790 \uC0C9\uC0C1 ${color}`,
|
|
10621
|
+
onClick: () => applyColor(color),
|
|
10622
|
+
className: cn(
|
|
10623
|
+
"flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full border transition-transform hover:scale-110",
|
|
10624
|
+
color.toLowerCase() === "#ffffff" ? "border-gray-300" : "border-black/10"
|
|
10625
|
+
),
|
|
10626
|
+
style: { backgroundColor: color },
|
|
10627
|
+
children: isSelected && /* @__PURE__ */ jsx(
|
|
10628
|
+
Check,
|
|
10629
|
+
{
|
|
10630
|
+
size: 12,
|
|
10631
|
+
strokeWidth: 3,
|
|
10632
|
+
className: isLightColor(color) ? "text-gray-900" : "text-white"
|
|
10633
|
+
}
|
|
10634
|
+
)
|
|
10635
|
+
},
|
|
10636
|
+
color
|
|
10637
|
+
);
|
|
10638
|
+
}) }, rowIdx)) }),
|
|
10639
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center gap-2 border-t border-gray-100 pt-3", children: [
|
|
10640
|
+
/* @__PURE__ */ jsx("label", { className: "relative size-7 shrink-0 cursor-pointer overflow-hidden rounded-full border border-gray-200", children: /* @__PURE__ */ jsx(
|
|
10641
|
+
"input",
|
|
10642
|
+
{
|
|
10643
|
+
type: "color",
|
|
10644
|
+
value: customColor,
|
|
10645
|
+
onChange: (e) => {
|
|
10646
|
+
setCustomColor(e.target.value);
|
|
10647
|
+
applyColor(e.target.value);
|
|
10648
|
+
},
|
|
10649
|
+
className: "absolute -left-1 -top-1 size-9 cursor-pointer"
|
|
10650
|
+
}
|
|
10651
|
+
) }),
|
|
10652
|
+
/* @__PURE__ */ jsx(
|
|
10653
|
+
"input",
|
|
10654
|
+
{
|
|
10655
|
+
type: "text",
|
|
10656
|
+
value: customColor,
|
|
10657
|
+
onChange: (e) => setCustomColor(e.target.value),
|
|
10658
|
+
onKeyDown: (e) => {
|
|
10659
|
+
if (e.key === "Enter") applyColor(customColor);
|
|
10660
|
+
},
|
|
10661
|
+
placeholder: "#RRGGBB",
|
|
10662
|
+
className: "h-7 flex-1 rounded border border-gray-200 px-2 text-xs text-gray-700 outline-none focus:border-indigo-400"
|
|
10663
|
+
}
|
|
10664
|
+
)
|
|
10665
|
+
] }),
|
|
10666
|
+
/* @__PURE__ */ jsx(
|
|
10667
|
+
"button",
|
|
10668
|
+
{
|
|
10669
|
+
type: "button",
|
|
10670
|
+
onClick: clearColor,
|
|
10671
|
+
className: "mt-2 w-full cursor-pointer rounded py-1 text-xs font-medium text-gray-500 hover:bg-gray-100",
|
|
10672
|
+
children: "\uC0C9\uC0C1 \uC9C0\uC6B0\uAE30"
|
|
10673
|
+
}
|
|
10674
|
+
)
|
|
10675
|
+
] });
|
|
10676
|
+
}
|
|
10545
10677
|
function ToolbarButton(props) {
|
|
10546
10678
|
const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
|
|
10547
10679
|
const theme = useRichEditorTheme();
|
|
@@ -10574,9 +10706,11 @@ function cmd(fn) {
|
|
|
10574
10706
|
};
|
|
10575
10707
|
}
|
|
10576
10708
|
function RichEditorToolbar(props) {
|
|
10577
|
-
const { editor, toolbar = {}, className } = props;
|
|
10709
|
+
const { editor, toolbar = {}, className, zIndex } = props;
|
|
10710
|
+
const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
|
|
10578
10711
|
const theme = useRichEditorTheme();
|
|
10579
10712
|
const [tablePickerOpen, setTablePickerOpen] = useState(false);
|
|
10713
|
+
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
|
10580
10714
|
const stateOrNull = useEditorState({
|
|
10581
10715
|
editor,
|
|
10582
10716
|
selector: ({ editor: e }) => ({
|
|
@@ -10595,7 +10729,8 @@ function RichEditorToolbar(props) {
|
|
|
10595
10729
|
isOrderedList: e?.isActive("orderedList") ?? false,
|
|
10596
10730
|
isBlockquote: e?.isActive("blockquote") ?? false,
|
|
10597
10731
|
isCodeBlock: e?.isActive("codeBlock") ?? false,
|
|
10598
|
-
isTable: e?.isActive("table") ?? false
|
|
10732
|
+
isTable: e?.isActive("table") ?? false,
|
|
10733
|
+
textColor: e?.getAttributes("textStyle").color ?? null
|
|
10599
10734
|
})
|
|
10600
10735
|
});
|
|
10601
10736
|
if (!editor) return null;
|
|
@@ -10615,7 +10750,8 @@ function RichEditorToolbar(props) {
|
|
|
10615
10750
|
isOrderedList: false,
|
|
10616
10751
|
isBlockquote: false,
|
|
10617
10752
|
isCodeBlock: false,
|
|
10618
|
-
isTable: false
|
|
10753
|
+
isTable: false,
|
|
10754
|
+
textColor: null
|
|
10619
10755
|
};
|
|
10620
10756
|
const showHeadingGroup = toolbar.heading !== false && (Array.isArray(toolbar.heading) ? toolbar.heading.length > 0 : true);
|
|
10621
10757
|
const showInlineGroup = toolbar.bold !== false || toolbar.italic !== false || toolbar.strike !== false || toolbar.code !== false;
|
|
@@ -10713,8 +10849,44 @@ function RichEditorToolbar(props) {
|
|
|
10713
10849
|
children: /* @__PURE__ */ jsx(Code, { size: 16 })
|
|
10714
10850
|
}
|
|
10715
10851
|
),
|
|
10716
|
-
|
|
10852
|
+
toolbar.textColor && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10717
10853
|
showInlineGroup && /* @__PURE__ */ jsx(Divider, {}),
|
|
10854
|
+
/* @__PURE__ */ jsxs(Popover, { open: colorPickerOpen, onOpenChange: setColorPickerOpen, children: [
|
|
10855
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
10856
|
+
"button",
|
|
10857
|
+
{
|
|
10858
|
+
type: "button",
|
|
10859
|
+
"aria-label": "\uAE00\uC790 \uC0C9\uC0C1",
|
|
10860
|
+
className: cn(
|
|
10861
|
+
"flex h-8 w-8 cursor-pointer flex-col items-center justify-center gap-0.5 rounded text-sm transition-colors",
|
|
10862
|
+
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
10863
|
+
state.textColor ? theme.toolbar.btnActive : theme.toolbar.btnIdle
|
|
10864
|
+
),
|
|
10865
|
+
children: [
|
|
10866
|
+
/* @__PURE__ */ jsx(Baseline, { size: 16 }),
|
|
10867
|
+
/* @__PURE__ */ jsx(
|
|
10868
|
+
"span",
|
|
10869
|
+
{
|
|
10870
|
+
className: "h-0.5 w-4 rounded-full",
|
|
10871
|
+
style: { backgroundColor: state.textColor ?? "currentColor" }
|
|
10872
|
+
}
|
|
10873
|
+
)
|
|
10874
|
+
]
|
|
10875
|
+
}
|
|
10876
|
+
) }),
|
|
10877
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", style: popoverStyle, children: editor && /* @__PURE__ */ jsx(
|
|
10878
|
+
TextColorPicker,
|
|
10879
|
+
{
|
|
10880
|
+
editor,
|
|
10881
|
+
currentColor: state.textColor,
|
|
10882
|
+
colors: Array.isArray(toolbar.textColor) ? toolbar.textColor : void 0,
|
|
10883
|
+
onClose: () => setColorPickerOpen(false)
|
|
10884
|
+
}
|
|
10885
|
+
) })
|
|
10886
|
+
] })
|
|
10887
|
+
] }),
|
|
10888
|
+
showAlignGroup && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10889
|
+
(showInlineGroup || toolbar.textColor) && /* @__PURE__ */ jsx(Divider, {}),
|
|
10718
10890
|
/* @__PURE__ */ jsx(
|
|
10719
10891
|
ToolbarButton,
|
|
10720
10892
|
{
|
|
@@ -10812,7 +10984,7 @@ function RichEditorToolbar(props) {
|
|
|
10812
10984
|
children: /* @__PURE__ */ jsx(Table$1, { size: 16 })
|
|
10813
10985
|
}
|
|
10814
10986
|
) }),
|
|
10815
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", children: editor && /* @__PURE__ */ jsx(TableGridPicker, { editor, onClose: () => setTablePickerOpen(false) }) })
|
|
10987
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", position: "bottom", style: popoverStyle, children: editor && /* @__PURE__ */ jsx(TableGridPicker, { editor, onClose: () => setTablePickerOpen(false) }) })
|
|
10816
10988
|
] }),
|
|
10817
10989
|
state.isTable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10818
10990
|
/* @__PURE__ */ jsx(
|
|
@@ -10907,7 +11079,8 @@ var DEFAULT_TOOLBAR = {
|
|
|
10907
11079
|
bulletList: true,
|
|
10908
11080
|
orderedList: true,
|
|
10909
11081
|
blockquote: true,
|
|
10910
|
-
code: true
|
|
11082
|
+
code: true,
|
|
11083
|
+
textColor: true
|
|
10911
11084
|
};
|
|
10912
11085
|
function RichEditorContent(props) {
|
|
10913
11086
|
const { editor, className, editorClassName, minHeight, maxHeight } = props;
|
|
@@ -10917,7 +11090,20 @@ function RichEditorContent(props) {
|
|
|
10917
11090
|
style.maxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
10918
11091
|
style.overflowY = "auto";
|
|
10919
11092
|
}
|
|
10920
|
-
return /* @__PURE__ */ jsx(
|
|
11093
|
+
return /* @__PURE__ */ jsx(
|
|
11094
|
+
"div",
|
|
11095
|
+
{
|
|
11096
|
+
className: cn("rich-editor-content cursor-text", className),
|
|
11097
|
+
style,
|
|
11098
|
+
onMouseDown: (e) => {
|
|
11099
|
+
if (!editor) return;
|
|
11100
|
+
if (e.target.closest(".ProseMirror")) return;
|
|
11101
|
+
e.preventDefault();
|
|
11102
|
+
editor.commands.focus("end");
|
|
11103
|
+
},
|
|
11104
|
+
children: /* @__PURE__ */ jsx(EditorContent, { editor, className: cn("h-full", editorClassName) })
|
|
11105
|
+
}
|
|
11106
|
+
);
|
|
10921
11107
|
}
|
|
10922
11108
|
var RichEditor = forwardRef(function RichEditor2({
|
|
10923
11109
|
value,
|
|
@@ -10936,6 +11122,11 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
10936
11122
|
bodyClassName,
|
|
10937
11123
|
editorClassName,
|
|
10938
11124
|
mentionClassName,
|
|
11125
|
+
mentionListClassName,
|
|
11126
|
+
mentionTagClassName,
|
|
11127
|
+
accentColor,
|
|
11128
|
+
accentTextColor,
|
|
11129
|
+
zIndex,
|
|
10939
11130
|
themeTokens,
|
|
10940
11131
|
editable = true,
|
|
10941
11132
|
autofocus
|
|
@@ -10961,6 +11152,11 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
10961
11152
|
mentionUsers,
|
|
10962
11153
|
onMentionSearch,
|
|
10963
11154
|
mentionClassName,
|
|
11155
|
+
mentionListClassName,
|
|
11156
|
+
mentionTagClassName,
|
|
11157
|
+
accentColor,
|
|
11158
|
+
accentTextColor,
|
|
11159
|
+
zIndex,
|
|
10964
11160
|
additionalExtensions,
|
|
10965
11161
|
editable,
|
|
10966
11162
|
autofocus,
|
|
@@ -11006,17 +11202,23 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
11006
11202
|
...themeTokens.toolbar && { toolbar: { ...baseTheme.toolbar, ...themeTokens.toolbar } },
|
|
11007
11203
|
...themeTokens.mention && { mention: { ...baseTheme.mention, ...themeTokens.mention } }
|
|
11008
11204
|
} : baseTheme;
|
|
11205
|
+
const accentStyle = {
|
|
11206
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
11207
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
11208
|
+
};
|
|
11009
11209
|
return /* @__PURE__ */ jsx(RichEditorThemeProvider, { value: resolvedTheme, children: /* @__PURE__ */ jsxs(
|
|
11010
11210
|
"div",
|
|
11011
11211
|
{
|
|
11012
11212
|
className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
|
|
11013
11213
|
"data-rich-editor-theme": theme,
|
|
11214
|
+
style: accentStyle,
|
|
11014
11215
|
children: [
|
|
11015
11216
|
isToolbarVisible && /* @__PURE__ */ jsx(
|
|
11016
11217
|
RichEditorToolbar,
|
|
11017
11218
|
{
|
|
11018
11219
|
editor,
|
|
11019
|
-
toolbar: activeToolbar
|
|
11220
|
+
toolbar: activeToolbar,
|
|
11221
|
+
zIndex
|
|
11020
11222
|
}
|
|
11021
11223
|
),
|
|
11022
11224
|
/* @__PURE__ */ jsx(
|