@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.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
|
};
|
|
@@ -478,6 +481,7 @@ function Input2(props) {
|
|
|
478
481
|
const handlePasswordToggle = () => setShowPassword((prev) => !prev);
|
|
479
482
|
const handleClear = () => onClear?.();
|
|
480
483
|
const shouldShowClearButton = clearable && !disabled && typeof rest.value === "string" && rest.value.length > 0;
|
|
484
|
+
const hasRightSlot = Boolean(rightIcon) || clearable && !disabled || shouldShowPasswordToggle;
|
|
481
485
|
const finalRightIcon = rightIcon || (shouldShowClearButton ? /* @__PURE__ */ jsx(
|
|
482
486
|
"div",
|
|
483
487
|
{
|
|
@@ -524,7 +528,7 @@ function Input2(props) {
|
|
|
524
528
|
{
|
|
525
529
|
id: inputId,
|
|
526
530
|
type: actualType === "money" || actualType === "number" ? "text" : actualType,
|
|
527
|
-
className: cn("w-full", leftIcon && "pl-10",
|
|
531
|
+
className: cn("w-full", leftIcon && "pl-10", hasRightSlot && "pr-10", getStatusStyles(), className),
|
|
528
532
|
placeholder,
|
|
529
533
|
disabled,
|
|
530
534
|
ref,
|
|
@@ -1247,7 +1251,7 @@ function PopoverContent({
|
|
|
1247
1251
|
side: position,
|
|
1248
1252
|
sideOffset,
|
|
1249
1253
|
className: cn(
|
|
1250
|
-
"z-
|
|
1254
|
+
"z-100 w-72 rounded-md border border-neutral-200 bg-white p-4 text-neutral-950 shadow-md outline-none",
|
|
1251
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",
|
|
1252
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",
|
|
1253
1257
|
className
|
|
@@ -10032,7 +10036,7 @@ var LIGHT = {
|
|
|
10032
10036
|
toolbar: {
|
|
10033
10037
|
wrapper: "border-b border-gray-200 bg-white",
|
|
10034
10038
|
btnIdle: "text-gray-700 hover:bg-gray-100",
|
|
10035
|
-
btnActive: "bg-
|
|
10039
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,#e0e7ff)] text-[var(--rich-editor-accent-text,#4f46e5)]",
|
|
10036
10040
|
btnDestructive: "text-red-400 hover:bg-red-50 hover:text-red-600",
|
|
10037
10041
|
divider: "bg-gray-200",
|
|
10038
10042
|
rText: "text-gray-700"
|
|
@@ -10053,16 +10057,16 @@ var LIGHT = {
|
|
|
10053
10057
|
container: "border-gray-200 bg-white",
|
|
10054
10058
|
emptyText: "text-gray-400",
|
|
10055
10059
|
btnIdle: "text-gray-700 hover:bg-gray-100 hover:text-gray-900",
|
|
10056
|
-
btnSelected: "bg-
|
|
10060
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,#dbeafe)] text-[var(--rich-editor-accent-text,#1e3a8a)]",
|
|
10057
10061
|
badgeIdle: "bg-gray-100 text-gray-500",
|
|
10058
|
-
badgeSelected: "bg-
|
|
10062
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#bfdbfe)] text-[var(--rich-editor-accent-text,#1e40af)]"
|
|
10059
10063
|
}
|
|
10060
10064
|
};
|
|
10061
10065
|
var DARK = {
|
|
10062
10066
|
toolbar: {
|
|
10063
10067
|
wrapper: "border-b border-gray-800 bg-gray-900",
|
|
10064
10068
|
btnIdle: "text-gray-400 hover:bg-gray-800 hover:text-gray-200",
|
|
10065
|
-
btnActive: "bg-
|
|
10069
|
+
btnActive: "bg-[var(--rich-editor-accent-bg,rgba(49,46,129,0.5))] text-[var(--rich-editor-accent-text,#818cf8)]",
|
|
10066
10070
|
btnDestructive: "text-red-400 hover:bg-red-900/30 hover:text-red-300",
|
|
10067
10071
|
divider: "bg-gray-800",
|
|
10068
10072
|
rText: "text-gray-400"
|
|
@@ -10083,9 +10087,9 @@ var DARK = {
|
|
|
10083
10087
|
container: "border-gray-700 bg-gray-900",
|
|
10084
10088
|
emptyText: "text-gray-500",
|
|
10085
10089
|
btnIdle: "text-gray-300 hover:bg-gray-800 hover:text-gray-100",
|
|
10086
|
-
btnSelected: "bg-
|
|
10090
|
+
btnSelected: "bg-[var(--rich-editor-accent-bg,rgba(30,58,138,0.5))] text-[var(--rich-editor-accent-text,#bfdbfe)]",
|
|
10087
10091
|
badgeIdle: "bg-gray-800 text-gray-400",
|
|
10088
|
-
badgeSelected: "bg-
|
|
10092
|
+
badgeSelected: "bg-[var(--rich-editor-accent-bg,#1e40af)] text-[var(--rich-editor-accent-text,#bfdbfe)]"
|
|
10089
10093
|
}
|
|
10090
10094
|
};
|
|
10091
10095
|
var RICH_EDITOR_THEMES = {
|
|
@@ -10098,8 +10102,12 @@ function useRichEditorTheme() {
|
|
|
10098
10102
|
return useContext(RichEditorThemeContext);
|
|
10099
10103
|
}
|
|
10100
10104
|
var MentionList = forwardRef((props, ref) => {
|
|
10101
|
-
const { items, command, loading, className } = props;
|
|
10105
|
+
const { items, command, loading, className, listClassName, accentColor, accentTextColor } = props;
|
|
10102
10106
|
const theme = useRichEditorTheme();
|
|
10107
|
+
const accentStyle = {
|
|
10108
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
10109
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
10110
|
+
};
|
|
10103
10111
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
10104
10112
|
const selectedRef = useRef(null);
|
|
10105
10113
|
const selectItem = (index) => {
|
|
@@ -10129,41 +10137,58 @@ var MentionList = forwardRef((props, ref) => {
|
|
|
10129
10137
|
return false;
|
|
10130
10138
|
}
|
|
10131
10139
|
}));
|
|
10132
|
-
return /* @__PURE__ */ jsx(
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
"
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
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
|
+
}
|
|
10151
10167
|
),
|
|
10152
|
-
children: item.label
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
}
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
}) }) });
|
|
10168
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: item.label })
|
|
10169
|
+
]
|
|
10170
|
+
},
|
|
10171
|
+
item.id
|
|
10172
|
+
);
|
|
10173
|
+
}) })
|
|
10174
|
+
}
|
|
10175
|
+
);
|
|
10161
10176
|
});
|
|
10162
10177
|
MentionList.displayName = "MentionList";
|
|
10163
10178
|
|
|
10164
10179
|
// src/components/RichEditor/config/extensions.ts
|
|
10165
10180
|
function buildExtensions(config) {
|
|
10166
|
-
const {
|
|
10181
|
+
const {
|
|
10182
|
+
toolbar,
|
|
10183
|
+
mentionUsers = [],
|
|
10184
|
+
onMentionSearch,
|
|
10185
|
+
mentionClassName,
|
|
10186
|
+
mentionListClassName,
|
|
10187
|
+
mentionTagClassName,
|
|
10188
|
+
accentColor,
|
|
10189
|
+
accentTextColor,
|
|
10190
|
+
zIndex
|
|
10191
|
+
} = config;
|
|
10167
10192
|
const exts = [TextStyleKit, buildMarkResetOnEnter()];
|
|
10168
10193
|
const headingLevels = toolbar.heading === false ? [] : Array.isArray(toolbar.heading) ? [...toolbar.heading] : [1, 2, 3, 4];
|
|
10169
10194
|
exts.push(
|
|
@@ -10204,7 +10229,7 @@ function buildExtensions(config) {
|
|
|
10204
10229
|
const ALL_ITEM = { id: "__all__", label: "\uBAA8\uB450" };
|
|
10205
10230
|
exts.push(
|
|
10206
10231
|
Mention.configure({
|
|
10207
|
-
HTMLAttributes: { class: "rich-editor-mention" },
|
|
10232
|
+
HTMLAttributes: { class: cn("rich-editor-mention", mentionTagClassName) },
|
|
10208
10233
|
suggestion: {
|
|
10209
10234
|
items: async ({ query }) => {
|
|
10210
10235
|
let items;
|
|
@@ -10220,18 +10245,25 @@ function buildExtensions(config) {
|
|
|
10220
10245
|
render: () => {
|
|
10221
10246
|
let component;
|
|
10222
10247
|
let unmount;
|
|
10248
|
+
const extraProps = {
|
|
10249
|
+
className: mentionClassName,
|
|
10250
|
+
listClassName: mentionListClassName,
|
|
10251
|
+
accentColor,
|
|
10252
|
+
accentTextColor
|
|
10253
|
+
};
|
|
10223
10254
|
return {
|
|
10224
10255
|
onStart: (props) => {
|
|
10225
10256
|
component = new ReactRenderer(MentionList, {
|
|
10226
|
-
props:
|
|
10257
|
+
props: { ...props, ...extraProps },
|
|
10227
10258
|
editor: props.editor
|
|
10228
10259
|
});
|
|
10229
10260
|
unmount = props.mount(component.element);
|
|
10261
|
+
if (component.element instanceof HTMLElement) {
|
|
10262
|
+
component.element.style.zIndex = String(zIndex ?? Z_INDEX.OVERLAY_POPUP);
|
|
10263
|
+
}
|
|
10230
10264
|
},
|
|
10231
10265
|
onUpdate: (props) => {
|
|
10232
|
-
component.updateProps(
|
|
10233
|
-
mentionClassName ? { ...props, className: mentionClassName } : props
|
|
10234
|
-
);
|
|
10266
|
+
component.updateProps({ ...props, ...extraProps });
|
|
10235
10267
|
},
|
|
10236
10268
|
onKeyDown: ({ event }) => {
|
|
10237
10269
|
return component.ref?.onKeyDown({ event }) ?? false;
|
|
@@ -10422,6 +10454,11 @@ function useRichEditor(options = {}) {
|
|
|
10422
10454
|
mentionUsers = [],
|
|
10423
10455
|
onMentionSearch,
|
|
10424
10456
|
mentionClassName,
|
|
10457
|
+
mentionListClassName,
|
|
10458
|
+
mentionTagClassName,
|
|
10459
|
+
accentColor,
|
|
10460
|
+
accentTextColor,
|
|
10461
|
+
zIndex,
|
|
10425
10462
|
editable = true,
|
|
10426
10463
|
autofocus,
|
|
10427
10464
|
editorClassName,
|
|
@@ -10439,7 +10476,12 @@ function useRichEditor(options = {}) {
|
|
|
10439
10476
|
toolbar,
|
|
10440
10477
|
mentionUsers,
|
|
10441
10478
|
onMentionSearch,
|
|
10442
|
-
mentionClassName
|
|
10479
|
+
mentionClassName,
|
|
10480
|
+
mentionListClassName,
|
|
10481
|
+
mentionTagClassName,
|
|
10482
|
+
accentColor,
|
|
10483
|
+
accentTextColor,
|
|
10484
|
+
zIndex
|
|
10443
10485
|
}),
|
|
10444
10486
|
...additionalExtensions
|
|
10445
10487
|
];
|
|
@@ -10541,6 +10583,97 @@ function RowIcon() {
|
|
|
10541
10583
|
/* @__PURE__ */ jsx("rect", { x: "1", y: "8", width: "12", height: "5", rx: "1", fill: "currentColor", opacity: "0.15" })
|
|
10542
10584
|
] });
|
|
10543
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
|
+
}
|
|
10544
10677
|
function ToolbarButton(props) {
|
|
10545
10678
|
const { onMouseDown, active, disabled, title, tooltip, variant = "default", children } = props;
|
|
10546
10679
|
const theme = useRichEditorTheme();
|
|
@@ -10573,9 +10706,11 @@ function cmd(fn) {
|
|
|
10573
10706
|
};
|
|
10574
10707
|
}
|
|
10575
10708
|
function RichEditorToolbar(props) {
|
|
10576
|
-
const { editor, toolbar = {}, className } = props;
|
|
10709
|
+
const { editor, toolbar = {}, className, zIndex } = props;
|
|
10710
|
+
const popoverStyle = zIndex !== void 0 ? { zIndex } : void 0;
|
|
10577
10711
|
const theme = useRichEditorTheme();
|
|
10578
10712
|
const [tablePickerOpen, setTablePickerOpen] = useState(false);
|
|
10713
|
+
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
|
10579
10714
|
const stateOrNull = useEditorState({
|
|
10580
10715
|
editor,
|
|
10581
10716
|
selector: ({ editor: e }) => ({
|
|
@@ -10594,7 +10729,8 @@ function RichEditorToolbar(props) {
|
|
|
10594
10729
|
isOrderedList: e?.isActive("orderedList") ?? false,
|
|
10595
10730
|
isBlockquote: e?.isActive("blockquote") ?? false,
|
|
10596
10731
|
isCodeBlock: e?.isActive("codeBlock") ?? false,
|
|
10597
|
-
isTable: e?.isActive("table") ?? false
|
|
10732
|
+
isTable: e?.isActive("table") ?? false,
|
|
10733
|
+
textColor: e?.getAttributes("textStyle").color ?? null
|
|
10598
10734
|
})
|
|
10599
10735
|
});
|
|
10600
10736
|
if (!editor) return null;
|
|
@@ -10614,7 +10750,8 @@ function RichEditorToolbar(props) {
|
|
|
10614
10750
|
isOrderedList: false,
|
|
10615
10751
|
isBlockquote: false,
|
|
10616
10752
|
isCodeBlock: false,
|
|
10617
|
-
isTable: false
|
|
10753
|
+
isTable: false,
|
|
10754
|
+
textColor: null
|
|
10618
10755
|
};
|
|
10619
10756
|
const showHeadingGroup = toolbar.heading !== false && (Array.isArray(toolbar.heading) ? toolbar.heading.length > 0 : true);
|
|
10620
10757
|
const showInlineGroup = toolbar.bold !== false || toolbar.italic !== false || toolbar.strike !== false || toolbar.code !== false;
|
|
@@ -10712,8 +10849,44 @@ function RichEditorToolbar(props) {
|
|
|
10712
10849
|
children: /* @__PURE__ */ jsx(Code, { size: 16 })
|
|
10713
10850
|
}
|
|
10714
10851
|
),
|
|
10715
|
-
|
|
10852
|
+
toolbar.textColor && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10716
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, {}),
|
|
10717
10890
|
/* @__PURE__ */ jsx(
|
|
10718
10891
|
ToolbarButton,
|
|
10719
10892
|
{
|
|
@@ -10811,7 +10984,7 @@ function RichEditorToolbar(props) {
|
|
|
10811
10984
|
children: /* @__PURE__ */ jsx(Table$1, { size: 16 })
|
|
10812
10985
|
}
|
|
10813
10986
|
) }),
|
|
10814
|
-
/* @__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) }) })
|
|
10815
10988
|
] }),
|
|
10816
10989
|
state.isTable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10817
10990
|
/* @__PURE__ */ jsx(
|
|
@@ -10906,7 +11079,8 @@ var DEFAULT_TOOLBAR = {
|
|
|
10906
11079
|
bulletList: true,
|
|
10907
11080
|
orderedList: true,
|
|
10908
11081
|
blockquote: true,
|
|
10909
|
-
code: true
|
|
11082
|
+
code: true,
|
|
11083
|
+
textColor: true
|
|
10910
11084
|
};
|
|
10911
11085
|
function RichEditorContent(props) {
|
|
10912
11086
|
const { editor, className, editorClassName, minHeight, maxHeight } = props;
|
|
@@ -10916,7 +11090,20 @@ function RichEditorContent(props) {
|
|
|
10916
11090
|
style.maxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
10917
11091
|
style.overflowY = "auto";
|
|
10918
11092
|
}
|
|
10919
|
-
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
|
+
);
|
|
10920
11107
|
}
|
|
10921
11108
|
var RichEditor = forwardRef(function RichEditor2({
|
|
10922
11109
|
value,
|
|
@@ -10935,6 +11122,11 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
10935
11122
|
bodyClassName,
|
|
10936
11123
|
editorClassName,
|
|
10937
11124
|
mentionClassName,
|
|
11125
|
+
mentionListClassName,
|
|
11126
|
+
mentionTagClassName,
|
|
11127
|
+
accentColor,
|
|
11128
|
+
accentTextColor,
|
|
11129
|
+
zIndex,
|
|
10938
11130
|
themeTokens,
|
|
10939
11131
|
editable = true,
|
|
10940
11132
|
autofocus
|
|
@@ -10960,6 +11152,11 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
10960
11152
|
mentionUsers,
|
|
10961
11153
|
onMentionSearch,
|
|
10962
11154
|
mentionClassName,
|
|
11155
|
+
mentionListClassName,
|
|
11156
|
+
mentionTagClassName,
|
|
11157
|
+
accentColor,
|
|
11158
|
+
accentTextColor,
|
|
11159
|
+
zIndex,
|
|
10963
11160
|
additionalExtensions,
|
|
10964
11161
|
editable,
|
|
10965
11162
|
autofocus,
|
|
@@ -11005,17 +11202,23 @@ var RichEditor = forwardRef(function RichEditor2({
|
|
|
11005
11202
|
...themeTokens.toolbar && { toolbar: { ...baseTheme.toolbar, ...themeTokens.toolbar } },
|
|
11006
11203
|
...themeTokens.mention && { mention: { ...baseTheme.mention, ...themeTokens.mention } }
|
|
11007
11204
|
} : baseTheme;
|
|
11205
|
+
const accentStyle = {
|
|
11206
|
+
...accentColor ? { "--rich-editor-accent-bg": accentColor } : {},
|
|
11207
|
+
...accentTextColor ? { "--rich-editor-accent-text": accentTextColor } : {}
|
|
11208
|
+
};
|
|
11008
11209
|
return /* @__PURE__ */ jsx(RichEditorThemeProvider, { value: resolvedTheme, children: /* @__PURE__ */ jsxs(
|
|
11009
11210
|
"div",
|
|
11010
11211
|
{
|
|
11011
11212
|
className: cn("overflow-hidden rounded-lg border border-gray-200 shadow-sm flex flex-col relative", className),
|
|
11012
11213
|
"data-rich-editor-theme": theme,
|
|
11214
|
+
style: accentStyle,
|
|
11013
11215
|
children: [
|
|
11014
11216
|
isToolbarVisible && /* @__PURE__ */ jsx(
|
|
11015
11217
|
RichEditorToolbar,
|
|
11016
11218
|
{
|
|
11017
11219
|
editor,
|
|
11018
|
-
toolbar: activeToolbar
|
|
11220
|
+
toolbar: activeToolbar,
|
|
11221
|
+
zIndex
|
|
11019
11222
|
}
|
|
11020
11223
|
),
|
|
11021
11224
|
/* @__PURE__ */ jsx(
|