hazo_ui 2.2.3 → 2.3.0
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/README.md +255 -0
- package/dist/index.cjs +2685 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -13
- package/dist/index.d.ts +60 -13
- package/dist/index.js +2650 -35
- package/dist/index.js.map +1 -1
- package/dist/styles.css +41 -49
- package/package.json +29 -3
- package/tailwind.preset.js +6 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import * as React23 from 'react';
|
|
2
|
+
import React23__default, { useRef, useState, useCallback, useEffect, useMemo, Fragment } from 'react';
|
|
4
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
5
4
|
import { cva } from 'class-variance-authority';
|
|
6
5
|
import { clsx } from 'clsx';
|
|
7
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
8
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
9
9
|
import { X, ChevronDown, ChevronUp, Check, Circle, Filter, Plus, ChevronsUpDown, ArrowUpDown, Trash2, GripVertical, Calendar as Calendar$1, ChevronRight, ChevronLeft } from 'lucide-react';
|
|
10
10
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
@@ -28,10 +28,88 @@ import * as IoIcons from 'react-icons/io5';
|
|
|
28
28
|
import * as RiIcons from 'react-icons/ri';
|
|
29
29
|
import * as TbIcons from 'react-icons/tb';
|
|
30
30
|
import * as CiIcons from 'react-icons/ci';
|
|
31
|
+
import { ReactNodeViewRenderer, NodeViewWrapper, useEditor, EditorContent } from '@tiptap/react';
|
|
32
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
33
|
+
import { TextStyle } from '@tiptap/extension-text-style';
|
|
34
|
+
import FontFamily from '@tiptap/extension-font-family';
|
|
35
|
+
import Underline from '@tiptap/extension-underline';
|
|
36
|
+
import Subscript from '@tiptap/extension-subscript';
|
|
37
|
+
import Superscript from '@tiptap/extension-superscript';
|
|
38
|
+
import Link from '@tiptap/extension-link';
|
|
39
|
+
import TextAlign from '@tiptap/extension-text-align';
|
|
40
|
+
import Highlight from '@tiptap/extension-highlight';
|
|
41
|
+
import Color from '@tiptap/extension-color';
|
|
42
|
+
import Image from '@tiptap/extension-image';
|
|
43
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
44
|
+
import HorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
45
|
+
import { Table } from '@tiptap/extension-table';
|
|
46
|
+
import TableRow from '@tiptap/extension-table-row';
|
|
47
|
+
import TableCell from '@tiptap/extension-table-cell';
|
|
48
|
+
import TableHeader from '@tiptap/extension-table-header';
|
|
49
|
+
import TaskList from '@tiptap/extension-task-list';
|
|
50
|
+
import TaskItem from '@tiptap/extension-task-item';
|
|
51
|
+
import { LuUndo2, LuRedo2, LuMinus, LuPlus, LuBold, LuItalic, LuUnderline, LuStrikethrough, LuSubscript, LuSuperscript, LuLink, LuRemoveFormatting, LuPalette, LuHighlighter, LuAlignLeft, LuAlignCenter, LuAlignRight, LuAlignJustify, LuList, LuListOrdered, LuListChecks, LuIndentDecrease, LuIndentIncrease, LuImage, LuTable, LuTableRowsSplit, LuTableColumnsSplit, LuTrash2, LuGrid3X3, LuVariable, LuPaperclip, LuX, LuFileText, LuFileCode, LuFile } from 'react-icons/lu';
|
|
52
|
+
import { RxDividerHorizontal } from 'react-icons/rx';
|
|
53
|
+
import { Extension, Node, mergeAttributes } from '@tiptap/core';
|
|
54
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
31
55
|
|
|
32
|
-
var
|
|
33
|
-
|
|
56
|
+
var __create = Object.create;
|
|
57
|
+
var __defProp = Object.defineProperty;
|
|
58
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
59
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
60
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
61
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
62
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
63
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
64
|
+
};
|
|
65
|
+
var __copyProps = (to, from, except, desc) => {
|
|
66
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
67
|
+
for (let key of __getOwnPropNames(from))
|
|
68
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
69
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
70
|
+
}
|
|
71
|
+
return to;
|
|
34
72
|
};
|
|
73
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
74
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
75
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
76
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
77
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
78
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
79
|
+
mod
|
|
80
|
+
));
|
|
81
|
+
|
|
82
|
+
// node_modules/@babel/runtime/helpers/extends.js
|
|
83
|
+
var require_extends = __commonJS({
|
|
84
|
+
"node_modules/@babel/runtime/helpers/extends.js"(exports$1, module) {
|
|
85
|
+
function _extends11() {
|
|
86
|
+
return module.exports = _extends11 = Object.assign ? Object.assign.bind() : function(n) {
|
|
87
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
88
|
+
var t = arguments[e];
|
|
89
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
90
|
+
}
|
|
91
|
+
return n;
|
|
92
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _extends11.apply(null, arguments);
|
|
93
|
+
}
|
|
94
|
+
module.exports = _extends11, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js
|
|
99
|
+
var require_objectWithoutPropertiesLoose = __commonJS({
|
|
100
|
+
"node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js"(exports$1, module) {
|
|
101
|
+
function _objectWithoutPropertiesLoose10(r, e) {
|
|
102
|
+
if (null == r) return {};
|
|
103
|
+
var t = {};
|
|
104
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
105
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
106
|
+
t[n] = r[n];
|
|
107
|
+
}
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
module.exports = _objectWithoutPropertiesLoose10, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
35
113
|
function cn(...inputs) {
|
|
36
114
|
return twMerge(clsx(inputs));
|
|
37
115
|
}
|
|
@@ -60,7 +138,7 @@ var buttonVariants = cva(
|
|
|
60
138
|
}
|
|
61
139
|
}
|
|
62
140
|
);
|
|
63
|
-
var Button =
|
|
141
|
+
var Button = React23.forwardRef(
|
|
64
142
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
65
143
|
const Comp = asChild ? Slot : "button";
|
|
66
144
|
return /* @__PURE__ */ jsx(
|
|
@@ -77,7 +155,7 @@ Button.displayName = "Button";
|
|
|
77
155
|
var Dialog = DialogPrimitive.Root;
|
|
78
156
|
var DialogTrigger = DialogPrimitive.Trigger;
|
|
79
157
|
var DialogPortal = DialogPrimitive.Portal;
|
|
80
|
-
var DialogOverlay =
|
|
158
|
+
var DialogOverlay = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
81
159
|
DialogPrimitive.Overlay,
|
|
82
160
|
{
|
|
83
161
|
ref,
|
|
@@ -89,7 +167,7 @@ var DialogOverlay = React6.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
89
167
|
}
|
|
90
168
|
));
|
|
91
169
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
92
|
-
var DialogContent =
|
|
170
|
+
var DialogContent = React23.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
93
171
|
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
94
172
|
/* @__PURE__ */ jsxs(
|
|
95
173
|
DialogPrimitive.Content,
|
|
@@ -139,7 +217,7 @@ var DialogFooter = ({
|
|
|
139
217
|
}
|
|
140
218
|
);
|
|
141
219
|
DialogFooter.displayName = "DialogFooter";
|
|
142
|
-
var DialogTitle =
|
|
220
|
+
var DialogTitle = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
143
221
|
DialogPrimitive.Title,
|
|
144
222
|
{
|
|
145
223
|
ref,
|
|
@@ -151,7 +229,7 @@ var DialogTitle = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
151
229
|
}
|
|
152
230
|
));
|
|
153
231
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
154
|
-
var DialogDescription =
|
|
232
|
+
var DialogDescription = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
155
233
|
DialogPrimitive.Description,
|
|
156
234
|
{
|
|
157
235
|
ref,
|
|
@@ -160,7 +238,7 @@ var DialogDescription = React6.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
160
238
|
}
|
|
161
239
|
));
|
|
162
240
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
163
|
-
var Command =
|
|
241
|
+
var Command = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
164
242
|
"div",
|
|
165
243
|
{
|
|
166
244
|
ref,
|
|
@@ -172,7 +250,7 @@ var Command = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
172
250
|
}
|
|
173
251
|
));
|
|
174
252
|
Command.displayName = "Command";
|
|
175
|
-
var CommandInput =
|
|
253
|
+
var CommandInput = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
176
254
|
"input",
|
|
177
255
|
{
|
|
178
256
|
ref,
|
|
@@ -184,7 +262,7 @@ var CommandInput = React6.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
184
262
|
}
|
|
185
263
|
));
|
|
186
264
|
CommandInput.displayName = "CommandInput";
|
|
187
|
-
var CommandList =
|
|
265
|
+
var CommandList = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
188
266
|
"div",
|
|
189
267
|
{
|
|
190
268
|
ref,
|
|
@@ -193,7 +271,7 @@ var CommandList = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
193
271
|
}
|
|
194
272
|
));
|
|
195
273
|
CommandList.displayName = "CommandList";
|
|
196
|
-
var CommandEmpty =
|
|
274
|
+
var CommandEmpty = React23.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
197
275
|
"div",
|
|
198
276
|
{
|
|
199
277
|
ref,
|
|
@@ -202,7 +280,7 @@ var CommandEmpty = React6.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
|
202
280
|
}
|
|
203
281
|
));
|
|
204
282
|
CommandEmpty.displayName = "CommandEmpty";
|
|
205
|
-
var CommandGroup =
|
|
283
|
+
var CommandGroup = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
206
284
|
"div",
|
|
207
285
|
{
|
|
208
286
|
ref,
|
|
@@ -214,7 +292,7 @@ var CommandGroup = React6.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
214
292
|
}
|
|
215
293
|
));
|
|
216
294
|
CommandGroup.displayName = "CommandGroup";
|
|
217
|
-
var CommandItem =
|
|
295
|
+
var CommandItem = React23.forwardRef(({ className, onSelect, value, ...props }, ref) => {
|
|
218
296
|
const handleClick = () => {
|
|
219
297
|
if (onSelect && value) {
|
|
220
298
|
onSelect(value);
|
|
@@ -236,7 +314,7 @@ var CommandItem = React6.forwardRef(({ className, onSelect, value, ...props }, r
|
|
|
236
314
|
CommandItem.displayName = "CommandItem";
|
|
237
315
|
var Popover = PopoverPrimitive.Root;
|
|
238
316
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
239
|
-
var PopoverContent =
|
|
317
|
+
var PopoverContent = React23.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
240
318
|
PopoverPrimitive.Content,
|
|
241
319
|
{
|
|
242
320
|
ref,
|
|
@@ -250,7 +328,7 @@ var PopoverContent = React6.forwardRef(({ className, align = "center", sideOffse
|
|
|
250
328
|
}
|
|
251
329
|
) }));
|
|
252
330
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
253
|
-
var Input =
|
|
331
|
+
var Input = React23.forwardRef(
|
|
254
332
|
({ className, type, ...props }, ref) => {
|
|
255
333
|
return /* @__PURE__ */ jsx(
|
|
256
334
|
"input",
|
|
@@ -269,7 +347,7 @@ var Input = React6.forwardRef(
|
|
|
269
347
|
Input.displayName = "Input";
|
|
270
348
|
var Select = SelectPrimitive.Root;
|
|
271
349
|
var SelectValue = SelectPrimitive.Value;
|
|
272
|
-
var SelectTrigger =
|
|
350
|
+
var SelectTrigger = React23.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
273
351
|
SelectPrimitive.Trigger,
|
|
274
352
|
{
|
|
275
353
|
ref,
|
|
@@ -285,7 +363,7 @@ var SelectTrigger = React6.forwardRef(({ className, children, ...props }, ref) =
|
|
|
285
363
|
}
|
|
286
364
|
));
|
|
287
365
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
288
|
-
var SelectScrollUpButton =
|
|
366
|
+
var SelectScrollUpButton = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
289
367
|
SelectPrimitive.ScrollUpButton,
|
|
290
368
|
{
|
|
291
369
|
ref,
|
|
@@ -298,7 +376,7 @@ var SelectScrollUpButton = React6.forwardRef(({ className, ...props }, ref) => /
|
|
|
298
376
|
}
|
|
299
377
|
));
|
|
300
378
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
301
|
-
var SelectScrollDownButton =
|
|
379
|
+
var SelectScrollDownButton = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
302
380
|
SelectPrimitive.ScrollDownButton,
|
|
303
381
|
{
|
|
304
382
|
ref,
|
|
@@ -311,7 +389,7 @@ var SelectScrollDownButton = React6.forwardRef(({ className, ...props }, ref) =>
|
|
|
311
389
|
}
|
|
312
390
|
));
|
|
313
391
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
314
|
-
var SelectContent =
|
|
392
|
+
var SelectContent = React23.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
315
393
|
SelectPrimitive.Content,
|
|
316
394
|
{
|
|
317
395
|
ref,
|
|
@@ -339,7 +417,7 @@ var SelectContent = React6.forwardRef(({ className, children, position = "popper
|
|
|
339
417
|
}
|
|
340
418
|
) }));
|
|
341
419
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
342
|
-
var SelectLabel =
|
|
420
|
+
var SelectLabel = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
343
421
|
SelectPrimitive.Label,
|
|
344
422
|
{
|
|
345
423
|
ref,
|
|
@@ -348,7 +426,7 @@ var SelectLabel = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
348
426
|
}
|
|
349
427
|
));
|
|
350
428
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
351
|
-
var SelectItem =
|
|
429
|
+
var SelectItem = React23.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
352
430
|
SelectPrimitive.Item,
|
|
353
431
|
{
|
|
354
432
|
ref,
|
|
@@ -364,7 +442,7 @@ var SelectItem = React6.forwardRef(({ className, children, ...props }, ref) => /
|
|
|
364
442
|
}
|
|
365
443
|
));
|
|
366
444
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
367
|
-
var SelectSeparator =
|
|
445
|
+
var SelectSeparator = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
368
446
|
SelectPrimitive.Separator,
|
|
369
447
|
{
|
|
370
448
|
ref,
|
|
@@ -376,7 +454,7 @@ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
|
376
454
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
377
455
|
var Tooltip = TooltipPrimitive.Root;
|
|
378
456
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
379
|
-
var TooltipContent =
|
|
457
|
+
var TooltipContent = React23.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
380
458
|
TooltipPrimitive.Content,
|
|
381
459
|
{
|
|
382
460
|
ref,
|
|
@@ -847,7 +925,7 @@ function HazoUiMultiFilterDialog({
|
|
|
847
925
|
] })
|
|
848
926
|
] });
|
|
849
927
|
}
|
|
850
|
-
var Switch =
|
|
928
|
+
var Switch = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
851
929
|
SwitchPrimitives.Root,
|
|
852
930
|
{
|
|
853
931
|
className: cn(
|
|
@@ -867,7 +945,7 @@ var Switch = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
867
945
|
}
|
|
868
946
|
));
|
|
869
947
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
870
|
-
var Label2 =
|
|
948
|
+
var Label2 = React23.forwardRef(
|
|
871
949
|
({ className, ...props }, ref) => {
|
|
872
950
|
return /* @__PURE__ */ jsx(
|
|
873
951
|
"label",
|
|
@@ -1161,7 +1239,7 @@ function HazoUiMultiSortDialog({
|
|
|
1161
1239
|
] })
|
|
1162
1240
|
] });
|
|
1163
1241
|
}
|
|
1164
|
-
var RadioGroup =
|
|
1242
|
+
var RadioGroup = React23.forwardRef(({ className, ...props }, ref) => {
|
|
1165
1243
|
return /* @__PURE__ */ jsx(
|
|
1166
1244
|
RadioGroupPrimitive.Root,
|
|
1167
1245
|
{
|
|
@@ -1172,7 +1250,7 @@ var RadioGroup = React6.forwardRef(({ className, ...props }, ref) => {
|
|
|
1172
1250
|
);
|
|
1173
1251
|
});
|
|
1174
1252
|
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
1175
|
-
var RadioGroupItem =
|
|
1253
|
+
var RadioGroupItem = React23.forwardRef(({ className, ...props }, ref) => {
|
|
1176
1254
|
return /* @__PURE__ */ jsx(
|
|
1177
1255
|
RadioGroupPrimitive.Item,
|
|
1178
1256
|
{
|
|
@@ -1526,7 +1604,7 @@ function filterInputValue(value, input_type, num_decimals) {
|
|
|
1526
1604
|
}
|
|
1527
1605
|
}
|
|
1528
1606
|
}
|
|
1529
|
-
var HazoUiFlexInput =
|
|
1607
|
+
var HazoUiFlexInput = React23.forwardRef(
|
|
1530
1608
|
({
|
|
1531
1609
|
className,
|
|
1532
1610
|
input_type = "mixed",
|
|
@@ -1543,13 +1621,13 @@ var HazoUiFlexInput = React6.forwardRef(
|
|
|
1543
1621
|
onBlur,
|
|
1544
1622
|
...props
|
|
1545
1623
|
}, ref) => {
|
|
1546
|
-
const [internalValue, setInternalValue] =
|
|
1624
|
+
const [internalValue, setInternalValue] = React23.useState(
|
|
1547
1625
|
typeof controlledValue === "string" ? controlledValue : typeof controlledValue === "number" ? String(controlledValue) : ""
|
|
1548
1626
|
);
|
|
1549
|
-
const [errorMessage, setErrorMessage] =
|
|
1627
|
+
const [errorMessage, setErrorMessage] = React23.useState();
|
|
1550
1628
|
const isControlled = controlledValue !== void 0;
|
|
1551
1629
|
const currentValue = isControlled ? typeof controlledValue === "string" ? controlledValue : String(controlledValue || "") : internalValue;
|
|
1552
|
-
|
|
1630
|
+
React23.useEffect(() => {
|
|
1553
1631
|
if (isControlled) {
|
|
1554
1632
|
const newValue = typeof controlledValue === "string" ? controlledValue : String(controlledValue || "");
|
|
1555
1633
|
if (newValue !== internalValue) {
|
|
@@ -1629,7 +1707,2544 @@ var HazoUiFlexInput = React6.forwardRef(
|
|
|
1629
1707
|
}
|
|
1630
1708
|
);
|
|
1631
1709
|
HazoUiFlexInput.displayName = "HazoUiFlexInput";
|
|
1710
|
+
var ToolbarButton = React23.forwardRef(
|
|
1711
|
+
({ onClick, is_active = false, disabled = false, tooltip, className, children }, ref) => {
|
|
1712
|
+
const button = /* @__PURE__ */ jsx(
|
|
1713
|
+
"button",
|
|
1714
|
+
{
|
|
1715
|
+
ref,
|
|
1716
|
+
type: "button",
|
|
1717
|
+
onClick,
|
|
1718
|
+
disabled,
|
|
1719
|
+
className: cn(
|
|
1720
|
+
"cls_rte_toolbar_button",
|
|
1721
|
+
"inline-flex items-center justify-center",
|
|
1722
|
+
"h-8 w-8 rounded-md",
|
|
1723
|
+
"text-sm font-medium",
|
|
1724
|
+
"transition-colors duration-150",
|
|
1725
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1726
|
+
// Default state
|
|
1727
|
+
"bg-transparent text-muted-foreground hover:bg-accent hover:text-accent-foreground",
|
|
1728
|
+
// Active state
|
|
1729
|
+
is_active && "bg-accent text-accent-foreground",
|
|
1730
|
+
// Disabled state
|
|
1731
|
+
disabled && "opacity-50 cursor-not-allowed hover:bg-transparent hover:text-muted-foreground",
|
|
1732
|
+
className
|
|
1733
|
+
),
|
|
1734
|
+
children
|
|
1735
|
+
}
|
|
1736
|
+
);
|
|
1737
|
+
if (tooltip) {
|
|
1738
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1739
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: button }),
|
|
1740
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "bottom", className: "text-xs", children: tooltip })
|
|
1741
|
+
] });
|
|
1742
|
+
}
|
|
1743
|
+
return button;
|
|
1744
|
+
}
|
|
1745
|
+
);
|
|
1746
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
1747
|
+
|
|
1748
|
+
// node_modules/@uiw/react-color-sketch/esm/index.js
|
|
1749
|
+
var import_extends10 = __toESM(require_extends());
|
|
1750
|
+
var import_objectWithoutPropertiesLoose9 = __toESM(require_objectWithoutPropertiesLoose());
|
|
1751
|
+
|
|
1752
|
+
// node_modules/@uiw/react-color-saturation/esm/index.js
|
|
1753
|
+
var import_extends3 = __toESM(require_extends());
|
|
1754
|
+
var import_objectWithoutPropertiesLoose2 = __toESM(require_objectWithoutPropertiesLoose());
|
|
1755
|
+
|
|
1756
|
+
// node_modules/@uiw/color-convert/esm/index.js
|
|
1757
|
+
var import_extends = __toESM(require_extends());
|
|
1758
|
+
var RGB_MAX = 255;
|
|
1759
|
+
var SV_MAX = 100;
|
|
1760
|
+
var rgbaToHsva = (_ref) => {
|
|
1761
|
+
var {
|
|
1762
|
+
r,
|
|
1763
|
+
g,
|
|
1764
|
+
b,
|
|
1765
|
+
a
|
|
1766
|
+
} = _ref;
|
|
1767
|
+
var max = Math.max(r, g, b);
|
|
1768
|
+
var delta = max - Math.min(r, g, b);
|
|
1769
|
+
var hh = delta ? max === r ? (g - b) / delta : max === g ? 2 + (b - r) / delta : 4 + (r - g) / delta : 0;
|
|
1770
|
+
return {
|
|
1771
|
+
h: 60 * (hh < 0 ? hh + 6 : hh),
|
|
1772
|
+
s: max ? delta / max * SV_MAX : 0,
|
|
1773
|
+
v: max / RGB_MAX * SV_MAX,
|
|
1774
|
+
a
|
|
1775
|
+
};
|
|
1776
|
+
};
|
|
1777
|
+
var hsvaToHslaString = (hsva) => {
|
|
1778
|
+
var {
|
|
1779
|
+
h,
|
|
1780
|
+
s,
|
|
1781
|
+
l,
|
|
1782
|
+
a
|
|
1783
|
+
} = hsvaToHsla(hsva);
|
|
1784
|
+
return "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")";
|
|
1785
|
+
};
|
|
1786
|
+
var hsvaToHsla = (_ref5) => {
|
|
1787
|
+
var {
|
|
1788
|
+
h,
|
|
1789
|
+
s,
|
|
1790
|
+
v,
|
|
1791
|
+
a
|
|
1792
|
+
} = _ref5;
|
|
1793
|
+
var hh = (200 - s) * v / SV_MAX;
|
|
1794
|
+
return {
|
|
1795
|
+
h,
|
|
1796
|
+
s: hh > 0 && hh < 200 ? s * v / SV_MAX / (hh <= SV_MAX ? hh : 200 - hh) * SV_MAX : 0,
|
|
1797
|
+
l: hh / 2,
|
|
1798
|
+
a
|
|
1799
|
+
};
|
|
1800
|
+
};
|
|
1801
|
+
var rgbToHex = (_ref7) => {
|
|
1802
|
+
var {
|
|
1803
|
+
r,
|
|
1804
|
+
g,
|
|
1805
|
+
b
|
|
1806
|
+
} = _ref7;
|
|
1807
|
+
var bin = r << 16 | g << 8 | b;
|
|
1808
|
+
return "#" + ((h) => new Array(7 - h.length).join("0") + h)(bin.toString(16));
|
|
1809
|
+
};
|
|
1810
|
+
var rgbaToHexa = (_ref8) => {
|
|
1811
|
+
var {
|
|
1812
|
+
r,
|
|
1813
|
+
g,
|
|
1814
|
+
b,
|
|
1815
|
+
a
|
|
1816
|
+
} = _ref8;
|
|
1817
|
+
var alpha = typeof a === "number" && (a * 255 | 1 << 8).toString(16).slice(1);
|
|
1818
|
+
return "" + rgbToHex({
|
|
1819
|
+
r,
|
|
1820
|
+
g,
|
|
1821
|
+
b
|
|
1822
|
+
}) + (alpha ? alpha : "");
|
|
1823
|
+
};
|
|
1824
|
+
var hexToHsva = (hex) => rgbaToHsva(hexToRgba(hex));
|
|
1825
|
+
var hexToRgba = (hex) => {
|
|
1826
|
+
var htemp = hex.replace("#", "");
|
|
1827
|
+
if (/^#?/.test(hex) && htemp.length === 3) {
|
|
1828
|
+
hex = "#" + htemp.charAt(0) + htemp.charAt(0) + htemp.charAt(1) + htemp.charAt(1) + htemp.charAt(2) + htemp.charAt(2);
|
|
1829
|
+
}
|
|
1830
|
+
var reg = new RegExp("[A-Za-z0-9]{2}", "g");
|
|
1831
|
+
var [r, g, b = 0, a] = hex.match(reg).map((v) => parseInt(v, 16));
|
|
1832
|
+
return {
|
|
1833
|
+
r,
|
|
1834
|
+
g,
|
|
1835
|
+
b,
|
|
1836
|
+
a: (a != null ? a : 255) / RGB_MAX
|
|
1837
|
+
};
|
|
1838
|
+
};
|
|
1839
|
+
var hsvaToRgba = (_ref9) => {
|
|
1840
|
+
var {
|
|
1841
|
+
h,
|
|
1842
|
+
s,
|
|
1843
|
+
v,
|
|
1844
|
+
a
|
|
1845
|
+
} = _ref9;
|
|
1846
|
+
var _h = h / 60, _s = s / SV_MAX, _v = v / SV_MAX, hi = Math.floor(_h) % 6;
|
|
1847
|
+
var f = _h - Math.floor(_h), _p = RGB_MAX * _v * (1 - _s), _q = RGB_MAX * _v * (1 - _s * f), _t = RGB_MAX * _v * (1 - _s * (1 - f));
|
|
1848
|
+
_v *= RGB_MAX;
|
|
1849
|
+
var rgba = {};
|
|
1850
|
+
switch (hi) {
|
|
1851
|
+
case 0:
|
|
1852
|
+
rgba.r = _v;
|
|
1853
|
+
rgba.g = _t;
|
|
1854
|
+
rgba.b = _p;
|
|
1855
|
+
break;
|
|
1856
|
+
case 1:
|
|
1857
|
+
rgba.r = _q;
|
|
1858
|
+
rgba.g = _v;
|
|
1859
|
+
rgba.b = _p;
|
|
1860
|
+
break;
|
|
1861
|
+
case 2:
|
|
1862
|
+
rgba.r = _p;
|
|
1863
|
+
rgba.g = _v;
|
|
1864
|
+
rgba.b = _t;
|
|
1865
|
+
break;
|
|
1866
|
+
case 3:
|
|
1867
|
+
rgba.r = _p;
|
|
1868
|
+
rgba.g = _q;
|
|
1869
|
+
rgba.b = _v;
|
|
1870
|
+
break;
|
|
1871
|
+
case 4:
|
|
1872
|
+
rgba.r = _t;
|
|
1873
|
+
rgba.g = _p;
|
|
1874
|
+
rgba.b = _v;
|
|
1875
|
+
break;
|
|
1876
|
+
case 5:
|
|
1877
|
+
rgba.r = _v;
|
|
1878
|
+
rgba.g = _p;
|
|
1879
|
+
rgba.b = _q;
|
|
1880
|
+
break;
|
|
1881
|
+
}
|
|
1882
|
+
rgba.r = Math.round(rgba.r);
|
|
1883
|
+
rgba.g = Math.round(rgba.g);
|
|
1884
|
+
rgba.b = Math.round(rgba.b);
|
|
1885
|
+
return (0, import_extends.default)({}, rgba, {
|
|
1886
|
+
a
|
|
1887
|
+
});
|
|
1888
|
+
};
|
|
1889
|
+
var hsvaToRgbaString = (hsva) => {
|
|
1890
|
+
var {
|
|
1891
|
+
r,
|
|
1892
|
+
g,
|
|
1893
|
+
b,
|
|
1894
|
+
a
|
|
1895
|
+
} = hsvaToRgba(hsva);
|
|
1896
|
+
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
|
1897
|
+
};
|
|
1898
|
+
var rgbaToRgb = (_ref0) => {
|
|
1899
|
+
var {
|
|
1900
|
+
r,
|
|
1901
|
+
g,
|
|
1902
|
+
b
|
|
1903
|
+
} = _ref0;
|
|
1904
|
+
return {
|
|
1905
|
+
r,
|
|
1906
|
+
g,
|
|
1907
|
+
b
|
|
1908
|
+
};
|
|
1909
|
+
};
|
|
1910
|
+
var hslaToHsl = (_ref1) => {
|
|
1911
|
+
var {
|
|
1912
|
+
h,
|
|
1913
|
+
s,
|
|
1914
|
+
l
|
|
1915
|
+
} = _ref1;
|
|
1916
|
+
return {
|
|
1917
|
+
h,
|
|
1918
|
+
s,
|
|
1919
|
+
l
|
|
1920
|
+
};
|
|
1921
|
+
};
|
|
1922
|
+
var hsvaToHex = (hsva) => rgbToHex(hsvaToRgba(hsva));
|
|
1923
|
+
var hsvaToHsv = (_ref10) => {
|
|
1924
|
+
var {
|
|
1925
|
+
h,
|
|
1926
|
+
s,
|
|
1927
|
+
v
|
|
1928
|
+
} = _ref10;
|
|
1929
|
+
return {
|
|
1930
|
+
h,
|
|
1931
|
+
s,
|
|
1932
|
+
v
|
|
1933
|
+
};
|
|
1934
|
+
};
|
|
1935
|
+
var rgbToXY = (_ref12) => {
|
|
1936
|
+
var {
|
|
1937
|
+
r,
|
|
1938
|
+
g,
|
|
1939
|
+
b
|
|
1940
|
+
} = _ref12;
|
|
1941
|
+
var translateColor = function translateColor2(color2) {
|
|
1942
|
+
return color2 <= 0.04045 ? color2 / 12.92 : Math.pow((color2 + 0.055) / 1.055, 2.4);
|
|
1943
|
+
};
|
|
1944
|
+
var red = translateColor(r / 255);
|
|
1945
|
+
var green = translateColor(g / 255);
|
|
1946
|
+
var blue = translateColor(b / 255);
|
|
1947
|
+
var xyz = {};
|
|
1948
|
+
xyz.x = red * 0.4124 + green * 0.3576 + blue * 0.1805;
|
|
1949
|
+
xyz.y = red * 0.2126 + green * 0.7152 + blue * 0.0722;
|
|
1950
|
+
xyz.bri = red * 0.0193 + green * 0.1192 + blue * 0.9505;
|
|
1951
|
+
return xyz;
|
|
1952
|
+
};
|
|
1953
|
+
var color = (str) => {
|
|
1954
|
+
var rgb;
|
|
1955
|
+
var hsl;
|
|
1956
|
+
var hsv;
|
|
1957
|
+
var rgba;
|
|
1958
|
+
var hsla;
|
|
1959
|
+
var hsva;
|
|
1960
|
+
var xy;
|
|
1961
|
+
var hex;
|
|
1962
|
+
var hexa;
|
|
1963
|
+
if (typeof str === "string" && validHex(str)) {
|
|
1964
|
+
hsva = hexToHsva(str);
|
|
1965
|
+
hex = str;
|
|
1966
|
+
} else if (typeof str !== "string") {
|
|
1967
|
+
hsva = str;
|
|
1968
|
+
}
|
|
1969
|
+
if (hsva) {
|
|
1970
|
+
hsv = hsvaToHsv(hsva);
|
|
1971
|
+
hsla = hsvaToHsla(hsva);
|
|
1972
|
+
rgba = hsvaToRgba(hsva);
|
|
1973
|
+
hexa = rgbaToHexa(rgba);
|
|
1974
|
+
hex = hsvaToHex(hsva);
|
|
1975
|
+
hsl = hslaToHsl(hsla);
|
|
1976
|
+
rgb = rgbaToRgb(rgba);
|
|
1977
|
+
xy = rgbToXY(rgb);
|
|
1978
|
+
}
|
|
1979
|
+
return {
|
|
1980
|
+
rgb,
|
|
1981
|
+
hsl,
|
|
1982
|
+
hsv,
|
|
1983
|
+
rgba,
|
|
1984
|
+
hsla,
|
|
1985
|
+
hsva,
|
|
1986
|
+
hex,
|
|
1987
|
+
hexa,
|
|
1988
|
+
xy
|
|
1989
|
+
};
|
|
1990
|
+
};
|
|
1991
|
+
var validHex = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
1992
|
+
|
|
1993
|
+
// node_modules/@uiw/react-drag-event-interactive/esm/index.js
|
|
1994
|
+
var import_extends2 = __toESM(require_extends());
|
|
1995
|
+
var import_objectWithoutPropertiesLoose = __toESM(require_objectWithoutPropertiesLoose());
|
|
1996
|
+
function useEventCallback(handler) {
|
|
1997
|
+
var callbackRef = useRef(handler);
|
|
1998
|
+
useEffect(() => {
|
|
1999
|
+
callbackRef.current = handler;
|
|
2000
|
+
});
|
|
2001
|
+
return useCallback((value, event) => callbackRef.current && callbackRef.current(value, event), []);
|
|
2002
|
+
}
|
|
2003
|
+
var isTouch = (event) => "touches" in event;
|
|
2004
|
+
var preventDefaultMove = (event) => {
|
|
2005
|
+
!isTouch(event) && event.preventDefault && event.preventDefault();
|
|
2006
|
+
};
|
|
2007
|
+
var clamp = function clamp2(number, min, max) {
|
|
2008
|
+
if (min === void 0) {
|
|
2009
|
+
min = 0;
|
|
2010
|
+
}
|
|
2011
|
+
if (max === void 0) {
|
|
2012
|
+
max = 1;
|
|
2013
|
+
}
|
|
2014
|
+
return number > max ? max : number < min ? min : number;
|
|
2015
|
+
};
|
|
2016
|
+
var getRelativePosition = (node, event) => {
|
|
2017
|
+
var rect = node.getBoundingClientRect();
|
|
2018
|
+
var pointer = isTouch(event) ? event.touches[0] : event;
|
|
2019
|
+
return {
|
|
2020
|
+
left: clamp((pointer.pageX - (rect.left + window.pageXOffset)) / rect.width),
|
|
2021
|
+
top: clamp((pointer.pageY - (rect.top + window.pageYOffset)) / rect.height),
|
|
2022
|
+
width: rect.width,
|
|
2023
|
+
height: rect.height,
|
|
2024
|
+
x: pointer.pageX - (rect.left + window.pageXOffset),
|
|
2025
|
+
y: pointer.pageY - (rect.top + window.pageYOffset)
|
|
2026
|
+
};
|
|
2027
|
+
};
|
|
2028
|
+
var _excluded = ["prefixCls", "className", "onMove", "onDown"];
|
|
2029
|
+
var Interactive = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2030
|
+
var {
|
|
2031
|
+
prefixCls = "w-color-interactive",
|
|
2032
|
+
className,
|
|
2033
|
+
onMove,
|
|
2034
|
+
onDown
|
|
2035
|
+
} = props, reset = (0, import_objectWithoutPropertiesLoose.default)(props, _excluded);
|
|
2036
|
+
var container = useRef(null);
|
|
2037
|
+
var hasTouched = useRef(false);
|
|
2038
|
+
var [isDragging, setDragging] = useState(false);
|
|
2039
|
+
var onMoveCallback = useEventCallback(onMove);
|
|
2040
|
+
var onKeyCallback = useEventCallback(onDown);
|
|
2041
|
+
var isValid = (event) => {
|
|
2042
|
+
if (hasTouched.current && !isTouch(event)) return false;
|
|
2043
|
+
hasTouched.current = isTouch(event);
|
|
2044
|
+
return true;
|
|
2045
|
+
};
|
|
2046
|
+
var handleMove = useCallback((event) => {
|
|
2047
|
+
preventDefaultMove(event);
|
|
2048
|
+
if (!container.current) return;
|
|
2049
|
+
var isDown = isTouch(event) ? event.touches.length > 0 : event.buttons > 0;
|
|
2050
|
+
if (!isDown) {
|
|
2051
|
+
setDragging(false);
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
onMoveCallback == null || onMoveCallback(getRelativePosition(container.current, event), event);
|
|
2055
|
+
}, [onMoveCallback]);
|
|
2056
|
+
var handleMoveEnd = useCallback(() => setDragging(false), []);
|
|
2057
|
+
var toggleDocumentEvents = useCallback((state) => {
|
|
2058
|
+
if (state) {
|
|
2059
|
+
window.addEventListener(hasTouched.current ? "touchmove" : "mousemove", handleMove);
|
|
2060
|
+
window.addEventListener(hasTouched.current ? "touchend" : "mouseup", handleMoveEnd);
|
|
2061
|
+
} else {
|
|
2062
|
+
window.removeEventListener("mousemove", handleMove);
|
|
2063
|
+
window.removeEventListener("mouseup", handleMoveEnd);
|
|
2064
|
+
window.removeEventListener("touchmove", handleMove);
|
|
2065
|
+
window.removeEventListener("touchend", handleMoveEnd);
|
|
2066
|
+
}
|
|
2067
|
+
}, [handleMove, handleMoveEnd]);
|
|
2068
|
+
useEffect(() => {
|
|
2069
|
+
toggleDocumentEvents(isDragging);
|
|
2070
|
+
return () => {
|
|
2071
|
+
toggleDocumentEvents(false);
|
|
2072
|
+
};
|
|
2073
|
+
}, [isDragging, handleMove, handleMoveEnd, toggleDocumentEvents]);
|
|
2074
|
+
var handleMoveStart = useCallback((event) => {
|
|
2075
|
+
var activeEl = document.activeElement;
|
|
2076
|
+
activeEl == null || activeEl.blur();
|
|
2077
|
+
preventDefaultMove(event.nativeEvent);
|
|
2078
|
+
if (!isValid(event.nativeEvent)) return;
|
|
2079
|
+
if (!container.current) return;
|
|
2080
|
+
onKeyCallback == null || onKeyCallback(getRelativePosition(container.current, event.nativeEvent), event.nativeEvent);
|
|
2081
|
+
setDragging(true);
|
|
2082
|
+
}, [onKeyCallback]);
|
|
2083
|
+
return /* @__PURE__ */ jsx("div", (0, import_extends2.default)({}, reset, {
|
|
2084
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2085
|
+
style: (0, import_extends2.default)({}, reset.style, {
|
|
2086
|
+
touchAction: "none"
|
|
2087
|
+
}),
|
|
2088
|
+
ref: container,
|
|
2089
|
+
tabIndex: 0,
|
|
2090
|
+
onMouseDown: handleMoveStart,
|
|
2091
|
+
onTouchStart: handleMoveStart
|
|
2092
|
+
}));
|
|
2093
|
+
});
|
|
2094
|
+
Interactive.displayName = "Interactive";
|
|
2095
|
+
var esm_default = Interactive;
|
|
2096
|
+
var Pointer = (_ref) => {
|
|
2097
|
+
var {
|
|
2098
|
+
className,
|
|
2099
|
+
color: color2,
|
|
2100
|
+
left,
|
|
2101
|
+
top,
|
|
2102
|
+
prefixCls
|
|
2103
|
+
} = _ref;
|
|
2104
|
+
var style = {
|
|
2105
|
+
position: "absolute",
|
|
2106
|
+
top,
|
|
2107
|
+
left
|
|
2108
|
+
};
|
|
2109
|
+
var stylePointer = {
|
|
2110
|
+
"--saturation-pointer-box-shadow": "rgb(255 255 255) 0px 0px 0px 1.5px, rgb(0 0 0 / 30%) 0px 0px 1px 1px inset, rgb(0 0 0 / 40%) 0px 0px 1px 2px",
|
|
2111
|
+
width: 6,
|
|
2112
|
+
height: 6,
|
|
2113
|
+
transform: "translate(-3px, -3px)",
|
|
2114
|
+
boxShadow: "var(--saturation-pointer-box-shadow)",
|
|
2115
|
+
borderRadius: "50%",
|
|
2116
|
+
backgroundColor: color2
|
|
2117
|
+
};
|
|
2118
|
+
return useMemo(() => /* @__PURE__ */ jsx("div", {
|
|
2119
|
+
className: prefixCls + "-pointer " + (className || ""),
|
|
2120
|
+
style,
|
|
2121
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
2122
|
+
className: prefixCls + "-fill",
|
|
2123
|
+
style: stylePointer
|
|
2124
|
+
})
|
|
2125
|
+
}), [top, left, color2, className, prefixCls]);
|
|
2126
|
+
};
|
|
2127
|
+
var _excluded2 = ["prefixCls", "radius", "pointer", "className", "hue", "style", "hsva", "onChange"];
|
|
2128
|
+
var Saturation = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2129
|
+
var _hsva$h;
|
|
2130
|
+
var {
|
|
2131
|
+
prefixCls = "w-color-saturation",
|
|
2132
|
+
radius = 0,
|
|
2133
|
+
pointer,
|
|
2134
|
+
className,
|
|
2135
|
+
hue = 0,
|
|
2136
|
+
style,
|
|
2137
|
+
hsva,
|
|
2138
|
+
onChange
|
|
2139
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose2.default)(props, _excluded2);
|
|
2140
|
+
var containerStyle = (0, import_extends3.default)({
|
|
2141
|
+
width: 200,
|
|
2142
|
+
height: 200,
|
|
2143
|
+
borderRadius: radius
|
|
2144
|
+
}, style, {
|
|
2145
|
+
position: "relative"
|
|
2146
|
+
});
|
|
2147
|
+
var handleChange = (interaction, event) => {
|
|
2148
|
+
onChange && hsva && onChange({
|
|
2149
|
+
h: hsva.h,
|
|
2150
|
+
s: interaction.left * 100,
|
|
2151
|
+
v: (1 - interaction.top) * 100,
|
|
2152
|
+
a: hsva.a
|
|
2153
|
+
// source: 'hsv',
|
|
2154
|
+
});
|
|
2155
|
+
};
|
|
2156
|
+
var handleKeyDown = useCallback((event) => {
|
|
2157
|
+
if (!hsva || !onChange) return;
|
|
2158
|
+
var step = 1;
|
|
2159
|
+
var newS = hsva.s;
|
|
2160
|
+
var newV = hsva.v;
|
|
2161
|
+
var changed = false;
|
|
2162
|
+
switch (event.key) {
|
|
2163
|
+
case "ArrowLeft":
|
|
2164
|
+
newS = Math.max(0, hsva.s - step);
|
|
2165
|
+
changed = true;
|
|
2166
|
+
event.preventDefault();
|
|
2167
|
+
break;
|
|
2168
|
+
case "ArrowRight":
|
|
2169
|
+
newS = Math.min(100, hsva.s + step);
|
|
2170
|
+
changed = true;
|
|
2171
|
+
event.preventDefault();
|
|
2172
|
+
break;
|
|
2173
|
+
case "ArrowUp":
|
|
2174
|
+
newV = Math.min(100, hsva.v + step);
|
|
2175
|
+
changed = true;
|
|
2176
|
+
event.preventDefault();
|
|
2177
|
+
break;
|
|
2178
|
+
case "ArrowDown":
|
|
2179
|
+
newV = Math.max(0, hsva.v - step);
|
|
2180
|
+
changed = true;
|
|
2181
|
+
event.preventDefault();
|
|
2182
|
+
break;
|
|
2183
|
+
default:
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if (changed) {
|
|
2187
|
+
onChange({
|
|
2188
|
+
h: hsva.h,
|
|
2189
|
+
s: newS,
|
|
2190
|
+
v: newV,
|
|
2191
|
+
a: hsva.a
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
}, [hsva, onChange]);
|
|
2195
|
+
var pointerElement = useMemo(() => {
|
|
2196
|
+
if (!hsva) return null;
|
|
2197
|
+
var comProps = {
|
|
2198
|
+
top: 100 - hsva.v + "%",
|
|
2199
|
+
left: hsva.s + "%",
|
|
2200
|
+
color: hsvaToHslaString(hsva)
|
|
2201
|
+
};
|
|
2202
|
+
if (pointer && typeof pointer === "function") {
|
|
2203
|
+
return pointer((0, import_extends3.default)({
|
|
2204
|
+
prefixCls
|
|
2205
|
+
}, comProps));
|
|
2206
|
+
}
|
|
2207
|
+
return /* @__PURE__ */ jsx(Pointer, (0, import_extends3.default)({
|
|
2208
|
+
prefixCls
|
|
2209
|
+
}, comProps));
|
|
2210
|
+
}, [hsva, pointer, prefixCls]);
|
|
2211
|
+
var handleClick = useCallback((event) => {
|
|
2212
|
+
event.target.focus();
|
|
2213
|
+
}, []);
|
|
2214
|
+
return /* @__PURE__ */ jsx(esm_default, (0, import_extends3.default)({
|
|
2215
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" ")
|
|
2216
|
+
}, other, {
|
|
2217
|
+
style: (0, import_extends3.default)({
|
|
2218
|
+
position: "absolute",
|
|
2219
|
+
inset: 0,
|
|
2220
|
+
cursor: "crosshair",
|
|
2221
|
+
backgroundImage: "linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, hsl(" + ((_hsva$h = hsva == null ? void 0 : hsva.h) != null ? _hsva$h : hue) + ", 100%, 50%))"
|
|
2222
|
+
}, containerStyle, {
|
|
2223
|
+
outline: "none"
|
|
2224
|
+
}),
|
|
2225
|
+
ref,
|
|
2226
|
+
onMove: handleChange,
|
|
2227
|
+
onDown: handleChange,
|
|
2228
|
+
onKeyDown: handleKeyDown,
|
|
2229
|
+
onClick: handleClick,
|
|
2230
|
+
children: pointerElement
|
|
2231
|
+
}));
|
|
2232
|
+
});
|
|
2233
|
+
Saturation.displayName = "Saturation";
|
|
2234
|
+
var esm_default2 = Saturation;
|
|
2235
|
+
|
|
2236
|
+
// node_modules/@uiw/react-color-alpha/esm/index.js
|
|
2237
|
+
var import_extends5 = __toESM(require_extends());
|
|
2238
|
+
var import_objectWithoutPropertiesLoose4 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2239
|
+
|
|
2240
|
+
// node_modules/@uiw/react-color-alpha/esm/Pointer.js
|
|
2241
|
+
var import_extends4 = __toESM(require_extends());
|
|
2242
|
+
var import_objectWithoutPropertiesLoose3 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2243
|
+
var _excluded3 = ["className", "prefixCls", "left", "top", "style", "fillProps"];
|
|
2244
|
+
var Pointer2 = (_ref) => {
|
|
2245
|
+
var {
|
|
2246
|
+
className,
|
|
2247
|
+
prefixCls,
|
|
2248
|
+
left,
|
|
2249
|
+
top,
|
|
2250
|
+
style,
|
|
2251
|
+
fillProps
|
|
2252
|
+
} = _ref, reset = (0, import_objectWithoutPropertiesLoose3.default)(_ref, _excluded3);
|
|
2253
|
+
var styleWrapper = (0, import_extends4.default)({}, style, {
|
|
2254
|
+
position: "absolute",
|
|
2255
|
+
left,
|
|
2256
|
+
top
|
|
2257
|
+
});
|
|
2258
|
+
var stylePointer = (0, import_extends4.default)({
|
|
2259
|
+
width: 18,
|
|
2260
|
+
height: 18,
|
|
2261
|
+
boxShadow: "var(--alpha-pointer-box-shadow)",
|
|
2262
|
+
borderRadius: "50%",
|
|
2263
|
+
backgroundColor: "var(--alpha-pointer-background-color)"
|
|
2264
|
+
}, fillProps == null ? void 0 : fillProps.style, {
|
|
2265
|
+
transform: left ? "translate(-9px, -1px)" : "translate(-1px, -9px)"
|
|
2266
|
+
});
|
|
2267
|
+
return /* @__PURE__ */ jsx("div", (0, import_extends4.default)({
|
|
2268
|
+
className: prefixCls + "-pointer " + (className || ""),
|
|
2269
|
+
style: styleWrapper
|
|
2270
|
+
}, reset, {
|
|
2271
|
+
children: /* @__PURE__ */ jsx("div", (0, import_extends4.default)({
|
|
2272
|
+
className: prefixCls + "-fill"
|
|
2273
|
+
}, fillProps, {
|
|
2274
|
+
style: stylePointer
|
|
2275
|
+
}))
|
|
2276
|
+
}));
|
|
2277
|
+
};
|
|
2278
|
+
var _excluded4 = ["prefixCls", "className", "hsva", "background", "bgProps", "innerProps", "pointerProps", "radius", "width", "height", "direction", "style", "onChange", "pointer"];
|
|
2279
|
+
var BACKGROUND_IMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==";
|
|
2280
|
+
var Alpha = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2281
|
+
var {
|
|
2282
|
+
prefixCls = "w-color-alpha",
|
|
2283
|
+
className,
|
|
2284
|
+
hsva,
|
|
2285
|
+
background,
|
|
2286
|
+
bgProps = {},
|
|
2287
|
+
innerProps = {},
|
|
2288
|
+
pointerProps = {},
|
|
2289
|
+
radius = 0,
|
|
2290
|
+
width,
|
|
2291
|
+
height = 16,
|
|
2292
|
+
direction = "horizontal",
|
|
2293
|
+
style,
|
|
2294
|
+
onChange,
|
|
2295
|
+
pointer
|
|
2296
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose4.default)(props, _excluded4);
|
|
2297
|
+
var handleChange = (offset) => {
|
|
2298
|
+
onChange && onChange((0, import_extends5.default)({}, hsva, {
|
|
2299
|
+
a: direction === "horizontal" ? offset.left : offset.top
|
|
2300
|
+
}), offset);
|
|
2301
|
+
};
|
|
2302
|
+
var colorTo = hsvaToHslaString(Object.assign({}, hsva, {
|
|
2303
|
+
a: 1
|
|
2304
|
+
}));
|
|
2305
|
+
var innerBackground = "linear-gradient(to " + (direction === "horizontal" ? "right" : "bottom") + ", rgba(244, 67, 54, 0) 0%, " + colorTo + " 100%)";
|
|
2306
|
+
var comProps = {};
|
|
2307
|
+
if (direction === "horizontal") {
|
|
2308
|
+
comProps.left = hsva.a * 100 + "%";
|
|
2309
|
+
} else {
|
|
2310
|
+
comProps.top = hsva.a * 100 + "%";
|
|
2311
|
+
}
|
|
2312
|
+
var styleWrapper = (0, import_extends5.default)({
|
|
2313
|
+
"--alpha-background-color": "#fff",
|
|
2314
|
+
"--alpha-pointer-background-color": "rgb(248, 248, 248)",
|
|
2315
|
+
"--alpha-pointer-box-shadow": "rgb(0 0 0 / 37%) 0px 1px 4px 0px",
|
|
2316
|
+
borderRadius: radius,
|
|
2317
|
+
background: "url(" + BACKGROUND_IMG + ") left center",
|
|
2318
|
+
backgroundColor: "var(--alpha-background-color)"
|
|
2319
|
+
}, {
|
|
2320
|
+
width,
|
|
2321
|
+
height
|
|
2322
|
+
}, style, {
|
|
2323
|
+
position: "relative"
|
|
2324
|
+
});
|
|
2325
|
+
var handleKeyDown = useCallback((event) => {
|
|
2326
|
+
var step = 0.01;
|
|
2327
|
+
var currentAlpha = hsva.a;
|
|
2328
|
+
var newAlpha = currentAlpha;
|
|
2329
|
+
switch (event.key) {
|
|
2330
|
+
case "ArrowLeft":
|
|
2331
|
+
if (direction === "horizontal") {
|
|
2332
|
+
newAlpha = Math.max(0, currentAlpha - step);
|
|
2333
|
+
event.preventDefault();
|
|
2334
|
+
}
|
|
2335
|
+
break;
|
|
2336
|
+
case "ArrowRight":
|
|
2337
|
+
if (direction === "horizontal") {
|
|
2338
|
+
newAlpha = Math.min(1, currentAlpha + step);
|
|
2339
|
+
event.preventDefault();
|
|
2340
|
+
}
|
|
2341
|
+
break;
|
|
2342
|
+
case "ArrowUp":
|
|
2343
|
+
if (direction === "vertical") {
|
|
2344
|
+
newAlpha = Math.max(0, currentAlpha - step);
|
|
2345
|
+
event.preventDefault();
|
|
2346
|
+
}
|
|
2347
|
+
break;
|
|
2348
|
+
case "ArrowDown":
|
|
2349
|
+
if (direction === "vertical") {
|
|
2350
|
+
newAlpha = Math.min(1, currentAlpha + step);
|
|
2351
|
+
event.preventDefault();
|
|
2352
|
+
}
|
|
2353
|
+
break;
|
|
2354
|
+
default:
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
if (newAlpha !== currentAlpha) {
|
|
2358
|
+
var syntheticOffset = {
|
|
2359
|
+
left: direction === "horizontal" ? newAlpha : hsva.a,
|
|
2360
|
+
top: direction === "vertical" ? newAlpha : hsva.a,
|
|
2361
|
+
width: 0,
|
|
2362
|
+
height: 0,
|
|
2363
|
+
x: 0,
|
|
2364
|
+
y: 0
|
|
2365
|
+
};
|
|
2366
|
+
onChange && onChange((0, import_extends5.default)({}, hsva, {
|
|
2367
|
+
a: newAlpha
|
|
2368
|
+
}), syntheticOffset);
|
|
2369
|
+
}
|
|
2370
|
+
}, [hsva, direction, onChange]);
|
|
2371
|
+
var handleClick = useCallback((event) => {
|
|
2372
|
+
event.target.focus();
|
|
2373
|
+
}, []);
|
|
2374
|
+
var pointerElement = pointer && typeof pointer === "function" ? pointer((0, import_extends5.default)({
|
|
2375
|
+
prefixCls
|
|
2376
|
+
}, pointerProps, comProps)) : /* @__PURE__ */ jsx(Pointer2, (0, import_extends5.default)({}, pointerProps, {
|
|
2377
|
+
prefixCls
|
|
2378
|
+
}, comProps));
|
|
2379
|
+
return /* @__PURE__ */ jsxs("div", (0, import_extends5.default)({}, other, {
|
|
2380
|
+
className: [prefixCls, prefixCls + "-" + direction, className || ""].filter(Boolean).join(" "),
|
|
2381
|
+
style: styleWrapper,
|
|
2382
|
+
ref,
|
|
2383
|
+
children: [/* @__PURE__ */ jsx("div", (0, import_extends5.default)({}, bgProps, {
|
|
2384
|
+
style: (0, import_extends5.default)({
|
|
2385
|
+
inset: 0,
|
|
2386
|
+
position: "absolute",
|
|
2387
|
+
background: background || innerBackground,
|
|
2388
|
+
borderRadius: radius
|
|
2389
|
+
}, bgProps.style)
|
|
2390
|
+
})), /* @__PURE__ */ jsx(esm_default, (0, import_extends5.default)({}, innerProps, {
|
|
2391
|
+
style: (0, import_extends5.default)({}, innerProps.style, {
|
|
2392
|
+
inset: 0,
|
|
2393
|
+
zIndex: 1,
|
|
2394
|
+
position: "absolute",
|
|
2395
|
+
outline: "none"
|
|
2396
|
+
}),
|
|
2397
|
+
onMove: handleChange,
|
|
2398
|
+
onDown: handleChange,
|
|
2399
|
+
onClick: handleClick,
|
|
2400
|
+
onKeyDown: handleKeyDown,
|
|
2401
|
+
children: pointerElement
|
|
2402
|
+
}))]
|
|
2403
|
+
}));
|
|
2404
|
+
});
|
|
2405
|
+
Alpha.displayName = "Alpha";
|
|
2406
|
+
var esm_default3 = Alpha;
|
|
2407
|
+
|
|
2408
|
+
// node_modules/@uiw/react-color-editable-input/esm/index.js
|
|
2409
|
+
var import_extends6 = __toESM(require_extends());
|
|
2410
|
+
var import_objectWithoutPropertiesLoose5 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2411
|
+
var _excluded5 = ["prefixCls", "placement", "label", "value", "className", "style", "labelStyle", "inputStyle", "onChange", "onBlur", "renderInput"];
|
|
2412
|
+
var validHex2 = (hex) => /^#?([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
2413
|
+
var getNumberValue = (value) => Number(String(value).replace(/%/g, ""));
|
|
2414
|
+
var EditableInput = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2415
|
+
var {
|
|
2416
|
+
prefixCls = "w-color-editable-input",
|
|
2417
|
+
placement = "bottom",
|
|
2418
|
+
label,
|
|
2419
|
+
value: initValue,
|
|
2420
|
+
className,
|
|
2421
|
+
style,
|
|
2422
|
+
labelStyle,
|
|
2423
|
+
inputStyle,
|
|
2424
|
+
onChange,
|
|
2425
|
+
onBlur,
|
|
2426
|
+
renderInput
|
|
2427
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose5.default)(props, _excluded5);
|
|
2428
|
+
var [value, setValue] = useState(initValue);
|
|
2429
|
+
var isFocus = useRef(false);
|
|
2430
|
+
useEffect(() => {
|
|
2431
|
+
if (props.value !== value) {
|
|
2432
|
+
if (!isFocus.current) {
|
|
2433
|
+
setValue(props.value);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}, [props.value]);
|
|
2437
|
+
function handleChange(evn, valInit) {
|
|
2438
|
+
var value2 = (valInit || evn.target.value).trim().replace(/^#/, "");
|
|
2439
|
+
if (validHex2(value2)) {
|
|
2440
|
+
onChange && onChange(evn, value2);
|
|
2441
|
+
}
|
|
2442
|
+
var val = getNumberValue(value2);
|
|
2443
|
+
if (!isNaN(val)) {
|
|
2444
|
+
onChange && onChange(evn, val);
|
|
2445
|
+
}
|
|
2446
|
+
setValue(value2);
|
|
2447
|
+
}
|
|
2448
|
+
function handleBlur(evn) {
|
|
2449
|
+
isFocus.current = false;
|
|
2450
|
+
setValue(props.value);
|
|
2451
|
+
onBlur && onBlur(evn);
|
|
2452
|
+
}
|
|
2453
|
+
var placementStyle = {};
|
|
2454
|
+
if (placement === "bottom") {
|
|
2455
|
+
placementStyle["flexDirection"] = "column";
|
|
2456
|
+
}
|
|
2457
|
+
if (placement === "top") {
|
|
2458
|
+
placementStyle["flexDirection"] = "column-reverse";
|
|
2459
|
+
}
|
|
2460
|
+
if (placement === "left") {
|
|
2461
|
+
placementStyle["flexDirection"] = "row-reverse";
|
|
2462
|
+
}
|
|
2463
|
+
var wrapperStyle = (0, import_extends6.default)({
|
|
2464
|
+
"--editable-input-label-color": "rgb(153, 153, 153)",
|
|
2465
|
+
"--editable-input-box-shadow": "rgb(204 204 204) 0px 0px 0px 1px inset",
|
|
2466
|
+
"--editable-input-color": "#666",
|
|
2467
|
+
position: "relative",
|
|
2468
|
+
alignItems: "center",
|
|
2469
|
+
display: "flex",
|
|
2470
|
+
fontSize: 11
|
|
2471
|
+
}, placementStyle, style);
|
|
2472
|
+
var editableStyle = (0, import_extends6.default)({
|
|
2473
|
+
width: "100%",
|
|
2474
|
+
paddingTop: 2,
|
|
2475
|
+
paddingBottom: 2,
|
|
2476
|
+
paddingLeft: 3,
|
|
2477
|
+
paddingRight: 3,
|
|
2478
|
+
fontSize: 11,
|
|
2479
|
+
background: "transparent",
|
|
2480
|
+
boxSizing: "border-box",
|
|
2481
|
+
border: "none",
|
|
2482
|
+
color: "var(--editable-input-color)",
|
|
2483
|
+
boxShadow: "var(--editable-input-box-shadow)"
|
|
2484
|
+
}, inputStyle);
|
|
2485
|
+
var inputProps = (0, import_extends6.default)({
|
|
2486
|
+
value,
|
|
2487
|
+
onChange: handleChange,
|
|
2488
|
+
onBlur: handleBlur,
|
|
2489
|
+
autoComplete: "off",
|
|
2490
|
+
onFocus: () => isFocus.current = true
|
|
2491
|
+
}, other, {
|
|
2492
|
+
style: editableStyle,
|
|
2493
|
+
onFocusCapture: (e) => {
|
|
2494
|
+
var elm = e.target;
|
|
2495
|
+
elm.setSelectionRange(elm.value.length, elm.value.length);
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2499
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2500
|
+
style: wrapperStyle,
|
|
2501
|
+
children: [renderInput ? renderInput(inputProps, ref) : /* @__PURE__ */ jsx("input", (0, import_extends6.default)({
|
|
2502
|
+
ref
|
|
2503
|
+
}, inputProps)), label && /* @__PURE__ */ jsx("span", {
|
|
2504
|
+
style: (0, import_extends6.default)({
|
|
2505
|
+
color: "var(--editable-input-label-color)",
|
|
2506
|
+
textTransform: "capitalize"
|
|
2507
|
+
}, labelStyle),
|
|
2508
|
+
children: label
|
|
2509
|
+
})]
|
|
2510
|
+
});
|
|
2511
|
+
});
|
|
2512
|
+
EditableInput.displayName = "EditableInput";
|
|
2513
|
+
var esm_default4 = EditableInput;
|
|
2514
|
+
|
|
2515
|
+
// node_modules/@uiw/react-color-editable-input-rgba/esm/index.js
|
|
2516
|
+
var import_extends7 = __toESM(require_extends());
|
|
2517
|
+
var import_objectWithoutPropertiesLoose6 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2518
|
+
var _excluded6 = ["prefixCls", "hsva", "placement", "rProps", "gProps", "bProps", "aProps", "className", "style", "onChange"];
|
|
2519
|
+
var EditableInputRGBA = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2520
|
+
var {
|
|
2521
|
+
prefixCls = "w-color-editable-input-rgba",
|
|
2522
|
+
hsva,
|
|
2523
|
+
placement = "bottom",
|
|
2524
|
+
rProps = {},
|
|
2525
|
+
gProps = {},
|
|
2526
|
+
bProps = {},
|
|
2527
|
+
aProps = {},
|
|
2528
|
+
className,
|
|
2529
|
+
style,
|
|
2530
|
+
onChange
|
|
2531
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose6.default)(props, _excluded6);
|
|
2532
|
+
var rgba = hsva ? hsvaToRgba(hsva) : {};
|
|
2533
|
+
function handleBlur(evn) {
|
|
2534
|
+
var value = Number(evn.target.value);
|
|
2535
|
+
if (value && value > 255) {
|
|
2536
|
+
evn.target.value = "255";
|
|
2537
|
+
}
|
|
2538
|
+
if (value && value < 0) {
|
|
2539
|
+
evn.target.value = "0";
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
var handleAlphaBlur = (evn) => {
|
|
2543
|
+
var value = Number(evn.target.value);
|
|
2544
|
+
if (value && value > 100) {
|
|
2545
|
+
evn.target.value = "100";
|
|
2546
|
+
}
|
|
2547
|
+
if (value && value < 0) {
|
|
2548
|
+
evn.target.value = "0";
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
var handleChange = (value, type, evn) => {
|
|
2552
|
+
if (typeof value === "number") {
|
|
2553
|
+
if (type === "a") {
|
|
2554
|
+
if (value < 0) value = 0;
|
|
2555
|
+
if (value > 100) value = 100;
|
|
2556
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2557
|
+
a: value / 100
|
|
2558
|
+
}))));
|
|
2559
|
+
}
|
|
2560
|
+
if (value > 255) {
|
|
2561
|
+
value = 255;
|
|
2562
|
+
evn.target.value = "255";
|
|
2563
|
+
}
|
|
2564
|
+
if (value < 0) {
|
|
2565
|
+
value = 0;
|
|
2566
|
+
evn.target.value = "0";
|
|
2567
|
+
}
|
|
2568
|
+
if (type === "r") {
|
|
2569
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2570
|
+
r: value
|
|
2571
|
+
}))));
|
|
2572
|
+
}
|
|
2573
|
+
if (type === "g") {
|
|
2574
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2575
|
+
g: value
|
|
2576
|
+
}))));
|
|
2577
|
+
}
|
|
2578
|
+
if (type === "b") {
|
|
2579
|
+
onChange && onChange(color(rgbaToHsva((0, import_extends7.default)({}, rgba, {
|
|
2580
|
+
b: value
|
|
2581
|
+
}))));
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
var roundedAlpha = rgba.a ? Math.round(rgba.a * 100) / 100 : 0;
|
|
2586
|
+
return /* @__PURE__ */ jsxs("div", (0, import_extends7.default)({
|
|
2587
|
+
ref,
|
|
2588
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" ")
|
|
2589
|
+
}, other, {
|
|
2590
|
+
style: (0, import_extends7.default)({
|
|
2591
|
+
fontSize: 11,
|
|
2592
|
+
display: "flex"
|
|
2593
|
+
}, style),
|
|
2594
|
+
children: [/* @__PURE__ */ jsx(esm_default4, (0, import_extends7.default)({
|
|
2595
|
+
label: "R",
|
|
2596
|
+
value: rgba.r || 0,
|
|
2597
|
+
onBlur: handleBlur,
|
|
2598
|
+
placement,
|
|
2599
|
+
onChange: (evn, val) => handleChange(val, "r", evn)
|
|
2600
|
+
}, rProps, {
|
|
2601
|
+
style: (0, import_extends7.default)({}, rProps.style)
|
|
2602
|
+
})), /* @__PURE__ */ jsx(esm_default4, (0, import_extends7.default)({
|
|
2603
|
+
label: "G",
|
|
2604
|
+
value: rgba.g || 0,
|
|
2605
|
+
onBlur: handleBlur,
|
|
2606
|
+
placement,
|
|
2607
|
+
onChange: (evn, val) => handleChange(val, "g", evn)
|
|
2608
|
+
}, gProps, {
|
|
2609
|
+
style: (0, import_extends7.default)({
|
|
2610
|
+
marginLeft: 5
|
|
2611
|
+
}, rProps.style)
|
|
2612
|
+
})), /* @__PURE__ */ jsx(esm_default4, (0, import_extends7.default)({
|
|
2613
|
+
label: "B",
|
|
2614
|
+
value: rgba.b || 0,
|
|
2615
|
+
onBlur: handleBlur,
|
|
2616
|
+
placement,
|
|
2617
|
+
onChange: (evn, val) => handleChange(val, "b", evn)
|
|
2618
|
+
}, bProps, {
|
|
2619
|
+
style: (0, import_extends7.default)({
|
|
2620
|
+
marginLeft: 5
|
|
2621
|
+
}, bProps.style)
|
|
2622
|
+
})), aProps && /* @__PURE__ */ jsx(esm_default4, (0, import_extends7.default)({
|
|
2623
|
+
label: "A",
|
|
2624
|
+
value: parseInt(String(roundedAlpha * 100), 10),
|
|
2625
|
+
onBlur: handleAlphaBlur,
|
|
2626
|
+
placement,
|
|
2627
|
+
onChange: (evn, val) => handleChange(val, "a", evn)
|
|
2628
|
+
}, aProps, {
|
|
2629
|
+
style: (0, import_extends7.default)({
|
|
2630
|
+
marginLeft: 5
|
|
2631
|
+
}, aProps.style)
|
|
2632
|
+
}))]
|
|
2633
|
+
}));
|
|
2634
|
+
});
|
|
2635
|
+
EditableInputRGBA.displayName = "EditableInputRGBA";
|
|
2636
|
+
var esm_default5 = EditableInputRGBA;
|
|
2637
|
+
|
|
2638
|
+
// node_modules/@uiw/react-color-hue/esm/index.js
|
|
2639
|
+
var import_extends8 = __toESM(require_extends());
|
|
2640
|
+
var import_objectWithoutPropertiesLoose7 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2641
|
+
var _excluded7 = ["prefixCls", "className", "hue", "onChange", "direction"];
|
|
2642
|
+
var Hue = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2643
|
+
var {
|
|
2644
|
+
prefixCls = "w-color-hue",
|
|
2645
|
+
className,
|
|
2646
|
+
hue = 0,
|
|
2647
|
+
onChange: _onChange,
|
|
2648
|
+
direction = "horizontal"
|
|
2649
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose7.default)(props, _excluded7);
|
|
2650
|
+
return /* @__PURE__ */ jsx(esm_default3, (0, import_extends8.default)({
|
|
2651
|
+
ref,
|
|
2652
|
+
className: prefixCls + " " + (className || "")
|
|
2653
|
+
}, other, {
|
|
2654
|
+
direction,
|
|
2655
|
+
background: "linear-gradient(to " + (direction === "horizontal" ? "right" : "bottom") + ", rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)",
|
|
2656
|
+
hsva: {
|
|
2657
|
+
h: hue,
|
|
2658
|
+
s: 100,
|
|
2659
|
+
v: 100,
|
|
2660
|
+
a: hue / 360
|
|
2661
|
+
},
|
|
2662
|
+
onChange: (_, interaction) => {
|
|
2663
|
+
_onChange && _onChange({
|
|
2664
|
+
h: direction === "horizontal" ? 360 * interaction.left : 360 * interaction.top
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
}));
|
|
2668
|
+
});
|
|
2669
|
+
Hue.displayName = "Hue";
|
|
2670
|
+
var esm_default6 = Hue;
|
|
2671
|
+
|
|
2672
|
+
// node_modules/@uiw/react-color-swatch/esm/index.js
|
|
2673
|
+
var import_extends9 = __toESM(require_extends());
|
|
2674
|
+
var import_objectWithoutPropertiesLoose8 = __toESM(require_objectWithoutPropertiesLoose());
|
|
2675
|
+
var _excluded8 = ["prefixCls", "className", "color", "colors", "style", "rectProps", "onChange", "addonAfter", "addonBefore", "rectRender"];
|
|
2676
|
+
var Swatch = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2677
|
+
var {
|
|
2678
|
+
prefixCls = "w-color-swatch",
|
|
2679
|
+
className,
|
|
2680
|
+
color: color2,
|
|
2681
|
+
colors = [],
|
|
2682
|
+
style,
|
|
2683
|
+
rectProps = {},
|
|
2684
|
+
onChange,
|
|
2685
|
+
addonAfter,
|
|
2686
|
+
addonBefore,
|
|
2687
|
+
rectRender
|
|
2688
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose8.default)(props, _excluded8);
|
|
2689
|
+
var rectStyle = (0, import_extends9.default)({
|
|
2690
|
+
"--swatch-background-color": "rgb(144, 19, 254)",
|
|
2691
|
+
background: "var(--swatch-background-color)",
|
|
2692
|
+
height: 15,
|
|
2693
|
+
width: 15,
|
|
2694
|
+
marginRight: 5,
|
|
2695
|
+
marginBottom: 5,
|
|
2696
|
+
cursor: "pointer",
|
|
2697
|
+
position: "relative",
|
|
2698
|
+
outline: "none",
|
|
2699
|
+
borderRadius: 2
|
|
2700
|
+
}, rectProps.style);
|
|
2701
|
+
var handleClick = (hex, evn) => {
|
|
2702
|
+
onChange && onChange(hexToHsva(hex), color(hexToHsva(hex)), evn);
|
|
2703
|
+
};
|
|
2704
|
+
return /* @__PURE__ */ jsxs("div", (0, import_extends9.default)({
|
|
2705
|
+
ref
|
|
2706
|
+
}, other, {
|
|
2707
|
+
className: [prefixCls, className || ""].filter(Boolean).join(" "),
|
|
2708
|
+
style: (0, import_extends9.default)({
|
|
2709
|
+
display: "flex",
|
|
2710
|
+
flexWrap: "wrap",
|
|
2711
|
+
position: "relative"
|
|
2712
|
+
}, style),
|
|
2713
|
+
children: [addonBefore && /* @__PURE__ */ React23__default.isValidElement(addonBefore) && addonBefore, colors && Array.isArray(colors) && colors.map((item, idx) => {
|
|
2714
|
+
var title = "";
|
|
2715
|
+
var background = "";
|
|
2716
|
+
if (typeof item === "string") {
|
|
2717
|
+
title = item;
|
|
2718
|
+
background = item;
|
|
2719
|
+
}
|
|
2720
|
+
if (typeof item === "object" && item.color) {
|
|
2721
|
+
title = item.title || item.color;
|
|
2722
|
+
background = item.color;
|
|
2723
|
+
}
|
|
2724
|
+
var checked = color2 && color2.toLocaleLowerCase() === background.toLocaleLowerCase();
|
|
2725
|
+
var render = rectRender && rectRender({
|
|
2726
|
+
title,
|
|
2727
|
+
color: background,
|
|
2728
|
+
checked: !!checked,
|
|
2729
|
+
style: (0, import_extends9.default)({}, rectStyle, {
|
|
2730
|
+
background
|
|
2731
|
+
}),
|
|
2732
|
+
onClick: (evn) => handleClick(background, evn)
|
|
2733
|
+
});
|
|
2734
|
+
if (render) {
|
|
2735
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
2736
|
+
children: render
|
|
2737
|
+
}, idx);
|
|
2738
|
+
}
|
|
2739
|
+
var child = rectProps.children && /* @__PURE__ */ React23__default.isValidElement(rectProps.children) ? /* @__PURE__ */ React23__default.cloneElement(rectProps.children, {
|
|
2740
|
+
color: background,
|
|
2741
|
+
checked
|
|
2742
|
+
}) : null;
|
|
2743
|
+
return /* @__PURE__ */ jsx("div", (0, import_extends9.default)({
|
|
2744
|
+
tabIndex: 0,
|
|
2745
|
+
title,
|
|
2746
|
+
onClick: (evn) => handleClick(background, evn)
|
|
2747
|
+
}, rectProps, {
|
|
2748
|
+
children: child,
|
|
2749
|
+
style: (0, import_extends9.default)({}, rectStyle, {
|
|
2750
|
+
background
|
|
2751
|
+
})
|
|
2752
|
+
}), idx);
|
|
2753
|
+
}), addonAfter && /* @__PURE__ */ React23__default.isValidElement(addonAfter) && addonAfter]
|
|
2754
|
+
}));
|
|
2755
|
+
});
|
|
2756
|
+
Swatch.displayName = "Swatch";
|
|
2757
|
+
var esm_default7 = Swatch;
|
|
2758
|
+
var _excluded9 = ["prefixCls", "className", "onChange", "width", "presetColors", "color", "editableDisable", "disableAlpha", "style"];
|
|
2759
|
+
var PRESET_COLORS = ["#D0021B", "#F5A623", "#f8e61b", "#8B572A", "#7ED321", "#417505", "#BD10E0", "#9013FE", "#4A90E2", "#50E3C2", "#B8E986", "#000000", "#4A4A4A", "#9B9B9B", "#FFFFFF"];
|
|
2760
|
+
var Bar = (props) => /* @__PURE__ */ jsx("div", {
|
|
2761
|
+
style: {
|
|
2762
|
+
boxShadow: "rgb(0 0 0 / 60%) 0px 0px 2px",
|
|
2763
|
+
width: 4,
|
|
2764
|
+
top: 1,
|
|
2765
|
+
bottom: 1,
|
|
2766
|
+
left: props.left,
|
|
2767
|
+
borderRadius: 1,
|
|
2768
|
+
position: "absolute",
|
|
2769
|
+
backgroundColor: "#fff"
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
var Sketch = /* @__PURE__ */ React23__default.forwardRef((props, ref) => {
|
|
2773
|
+
var {
|
|
2774
|
+
prefixCls = "w-color-sketch",
|
|
2775
|
+
className,
|
|
2776
|
+
onChange,
|
|
2777
|
+
width = 218,
|
|
2778
|
+
presetColors = PRESET_COLORS,
|
|
2779
|
+
color: color2,
|
|
2780
|
+
editableDisable = true,
|
|
2781
|
+
disableAlpha = false,
|
|
2782
|
+
style
|
|
2783
|
+
} = props, other = (0, import_objectWithoutPropertiesLoose9.default)(props, _excluded9);
|
|
2784
|
+
var [hsva, setHsva] = useState({
|
|
2785
|
+
h: 209,
|
|
2786
|
+
s: 36,
|
|
2787
|
+
v: 90,
|
|
2788
|
+
a: 1
|
|
2789
|
+
});
|
|
2790
|
+
useEffect(() => {
|
|
2791
|
+
if (typeof color2 === "string" && validHex(color2)) {
|
|
2792
|
+
setHsva(hexToHsva(color2));
|
|
2793
|
+
}
|
|
2794
|
+
if (typeof color2 === "object") {
|
|
2795
|
+
setHsva(color2);
|
|
2796
|
+
}
|
|
2797
|
+
}, [color2]);
|
|
2798
|
+
var handleChange = (hsv) => {
|
|
2799
|
+
setHsva(hsv);
|
|
2800
|
+
onChange && onChange(color(hsv));
|
|
2801
|
+
};
|
|
2802
|
+
var handleHex = (value, evn) => {
|
|
2803
|
+
if (typeof value === "string" && validHex(value) && /(3|6)/.test(String(value.length))) {
|
|
2804
|
+
handleChange(hexToHsva(value));
|
|
2805
|
+
}
|
|
2806
|
+
};
|
|
2807
|
+
var handleAlphaChange = (newAlpha) => handleChange((0, import_extends10.default)({}, hsva, {
|
|
2808
|
+
a: newAlpha.a
|
|
2809
|
+
}));
|
|
2810
|
+
var handleSaturationChange = (newColor) => handleChange((0, import_extends10.default)({}, hsva, newColor, {
|
|
2811
|
+
a: hsva.a
|
|
2812
|
+
}));
|
|
2813
|
+
var styleMain = (0, import_extends10.default)({
|
|
2814
|
+
"--sketch-background": "rgb(255, 255, 255)",
|
|
2815
|
+
"--sketch-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px, rgb(0 0 0 / 15%) 0px 8px 16px",
|
|
2816
|
+
"--sketch-swatch-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px inset",
|
|
2817
|
+
"--sketch-alpha-box-shadow": "rgb(0 0 0 / 15%) 0px 0px 0px 1px inset, rgb(0 0 0 / 25%) 0px 0px 4px inset",
|
|
2818
|
+
"--sketch-swatch-border-top": "1px solid rgb(238, 238, 238)",
|
|
2819
|
+
background: "var(--sketch-background)",
|
|
2820
|
+
borderRadius: 4,
|
|
2821
|
+
boxShadow: "var(--sketch-box-shadow)",
|
|
2822
|
+
width
|
|
2823
|
+
}, style);
|
|
2824
|
+
var styleAlpha = {
|
|
2825
|
+
borderRadius: 2,
|
|
2826
|
+
background: hsvaToRgbaString(hsva),
|
|
2827
|
+
boxShadow: "var(--sketch-alpha-box-shadow)"
|
|
2828
|
+
};
|
|
2829
|
+
var styleSwatch = {
|
|
2830
|
+
borderTop: "var(--sketch-swatch-border-top)",
|
|
2831
|
+
paddingTop: 10,
|
|
2832
|
+
paddingLeft: 10
|
|
2833
|
+
};
|
|
2834
|
+
var styleSwatchRect = {
|
|
2835
|
+
marginRight: 10,
|
|
2836
|
+
marginBottom: 10,
|
|
2837
|
+
borderRadius: 3,
|
|
2838
|
+
boxShadow: "var(--sketch-swatch-box-shadow)"
|
|
2839
|
+
};
|
|
2840
|
+
return /* @__PURE__ */ jsxs("div", (0, import_extends10.default)({}, other, {
|
|
2841
|
+
className: prefixCls + " " + (className || ""),
|
|
2842
|
+
ref,
|
|
2843
|
+
style: styleMain,
|
|
2844
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2845
|
+
style: {
|
|
2846
|
+
padding: "10px 10px 8px"
|
|
2847
|
+
},
|
|
2848
|
+
children: [/* @__PURE__ */ jsx(esm_default2, {
|
|
2849
|
+
hsva,
|
|
2850
|
+
style: {
|
|
2851
|
+
width: "auto",
|
|
2852
|
+
height: 150
|
|
2853
|
+
},
|
|
2854
|
+
onChange: handleSaturationChange
|
|
2855
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2856
|
+
style: {
|
|
2857
|
+
display: "flex",
|
|
2858
|
+
marginTop: 4
|
|
2859
|
+
},
|
|
2860
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2861
|
+
style: {
|
|
2862
|
+
flex: 1
|
|
2863
|
+
},
|
|
2864
|
+
children: [/* @__PURE__ */ jsx(esm_default6, {
|
|
2865
|
+
width: "auto",
|
|
2866
|
+
height: 10,
|
|
2867
|
+
hue: hsva.h,
|
|
2868
|
+
pointer: Bar,
|
|
2869
|
+
innerProps: {
|
|
2870
|
+
style: {
|
|
2871
|
+
marginLeft: 1,
|
|
2872
|
+
marginRight: 5
|
|
2873
|
+
}
|
|
2874
|
+
},
|
|
2875
|
+
onChange: (newHue) => handleChange((0, import_extends10.default)({}, hsva, newHue))
|
|
2876
|
+
}), !disableAlpha && /* @__PURE__ */ jsx(esm_default3, {
|
|
2877
|
+
width: "auto",
|
|
2878
|
+
height: 10,
|
|
2879
|
+
hsva,
|
|
2880
|
+
pointer: Bar,
|
|
2881
|
+
style: {
|
|
2882
|
+
marginTop: 4
|
|
2883
|
+
},
|
|
2884
|
+
innerProps: {
|
|
2885
|
+
style: {
|
|
2886
|
+
marginLeft: 1,
|
|
2887
|
+
marginRight: 5
|
|
2888
|
+
}
|
|
2889
|
+
},
|
|
2890
|
+
onChange: handleAlphaChange
|
|
2891
|
+
})]
|
|
2892
|
+
}), !disableAlpha && /* @__PURE__ */ jsx(esm_default3, {
|
|
2893
|
+
width: 24,
|
|
2894
|
+
height: 24,
|
|
2895
|
+
hsva,
|
|
2896
|
+
radius: 2,
|
|
2897
|
+
style: {
|
|
2898
|
+
marginLeft: 4
|
|
2899
|
+
},
|
|
2900
|
+
bgProps: {
|
|
2901
|
+
style: {
|
|
2902
|
+
background: "transparent"
|
|
2903
|
+
}
|
|
2904
|
+
},
|
|
2905
|
+
innerProps: {
|
|
2906
|
+
style: styleAlpha
|
|
2907
|
+
},
|
|
2908
|
+
pointer: () => /* @__PURE__ */ jsx(Fragment, {})
|
|
2909
|
+
})]
|
|
2910
|
+
})]
|
|
2911
|
+
}), editableDisable && /* @__PURE__ */ jsxs("div", {
|
|
2912
|
+
style: {
|
|
2913
|
+
display: "flex",
|
|
2914
|
+
margin: "0 10px 3px 10px"
|
|
2915
|
+
},
|
|
2916
|
+
children: [/* @__PURE__ */ jsx(esm_default4, {
|
|
2917
|
+
label: "Hex",
|
|
2918
|
+
value: hsvaToHex(hsva).replace(/^#/, "").toLocaleUpperCase(),
|
|
2919
|
+
onChange: (evn, val) => handleHex(val),
|
|
2920
|
+
style: {
|
|
2921
|
+
minWidth: 58
|
|
2922
|
+
}
|
|
2923
|
+
}), /* @__PURE__ */ jsx(esm_default5, {
|
|
2924
|
+
hsva,
|
|
2925
|
+
style: {
|
|
2926
|
+
marginLeft: 6
|
|
2927
|
+
},
|
|
2928
|
+
aProps: !disableAlpha ? {} : false,
|
|
2929
|
+
onChange: (result) => handleChange(result.hsva)
|
|
2930
|
+
})]
|
|
2931
|
+
}), presetColors && presetColors.length > 0 && /* @__PURE__ */ jsx(esm_default7, {
|
|
2932
|
+
style: styleSwatch,
|
|
2933
|
+
colors: presetColors,
|
|
2934
|
+
color: hsvaToHex(hsva),
|
|
2935
|
+
onChange: (hsvColor) => handleChange(hsvColor),
|
|
2936
|
+
rectProps: {
|
|
2937
|
+
style: styleSwatchRect
|
|
2938
|
+
}
|
|
2939
|
+
})]
|
|
2940
|
+
}));
|
|
2941
|
+
});
|
|
2942
|
+
Sketch.displayName = "Sketch";
|
|
2943
|
+
var esm_default8 = Sketch;
|
|
2944
|
+
|
|
2945
|
+
// src/components/hazo_ui_rte/types.ts
|
|
2946
|
+
var FONT_FAMILIES = [
|
|
2947
|
+
{ label: "Arial", value: "Arial, sans-serif" },
|
|
2948
|
+
{ label: "Verdana", value: "Verdana, sans-serif" },
|
|
2949
|
+
{ label: "Times New Roman", value: "Times New Roman, serif" },
|
|
2950
|
+
{ label: "Georgia", value: "Georgia, serif" },
|
|
2951
|
+
{ label: "Courier New", value: "Courier New, monospace" },
|
|
2952
|
+
{ label: "Trebuchet MS", value: "Trebuchet MS, sans-serif" }
|
|
2953
|
+
];
|
|
2954
|
+
var FONT_SIZE_CONFIG = {
|
|
2955
|
+
default: 16,
|
|
2956
|
+
min: 8,
|
|
2957
|
+
max: 72,
|
|
2958
|
+
step: 2
|
|
2959
|
+
};
|
|
2960
|
+
var BLOCK_TYPES = [
|
|
2961
|
+
{ label: "Paragraph", value: "paragraph", icon: "paragraph" },
|
|
2962
|
+
{ label: "Heading 1", value: "heading-1", icon: "h1" },
|
|
2963
|
+
{ label: "Heading 2", value: "heading-2", icon: "h2" },
|
|
2964
|
+
{ label: "Heading 3", value: "heading-3", icon: "h3" },
|
|
2965
|
+
{ label: "Numbered List", value: "ordered-list", icon: "list-ordered" },
|
|
2966
|
+
{ label: "Bulleted List", value: "bullet-list", icon: "list" },
|
|
2967
|
+
{ label: "Check List", value: "task-list", icon: "list-checks" },
|
|
2968
|
+
{ label: "Code Block", value: "code-block", icon: "code" },
|
|
2969
|
+
{ label: "Quote", value: "blockquote", icon: "quote" }
|
|
2970
|
+
];
|
|
2971
|
+
|
|
2972
|
+
// src/components/hazo_ui_rte/utils.ts
|
|
2973
|
+
function file_to_base64(file) {
|
|
2974
|
+
return new Promise((resolve, reject) => {
|
|
2975
|
+
const reader = new FileReader();
|
|
2976
|
+
reader.onload = () => {
|
|
2977
|
+
const result = reader.result;
|
|
2978
|
+
const base64 = result.split(",")[1];
|
|
2979
|
+
resolve(base64);
|
|
2980
|
+
};
|
|
2981
|
+
reader.onerror = reject;
|
|
2982
|
+
reader.readAsDataURL(file);
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
async function file_to_attachment(file) {
|
|
2986
|
+
const data = await file_to_base64(file);
|
|
2987
|
+
return {
|
|
2988
|
+
filename: file.name,
|
|
2989
|
+
mime_type: file.type || "application/octet-stream",
|
|
2990
|
+
data
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
function file_to_data_url(file) {
|
|
2994
|
+
return new Promise((resolve, reject) => {
|
|
2995
|
+
const reader = new FileReader();
|
|
2996
|
+
reader.onload = () => resolve(reader.result);
|
|
2997
|
+
reader.onerror = reject;
|
|
2998
|
+
reader.readAsDataURL(file);
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
function format_file_size(bytes) {
|
|
3002
|
+
if (bytes === 0) return "0 B";
|
|
3003
|
+
const k = 1024;
|
|
3004
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
3005
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
3006
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
3007
|
+
}
|
|
3008
|
+
function get_file_extension(filename) {
|
|
3009
|
+
const parts = filename.split(".");
|
|
3010
|
+
return parts.length > 1 ? parts.pop()?.toLowerCase() || "" : "";
|
|
3011
|
+
}
|
|
3012
|
+
function is_image_file(mime_type) {
|
|
3013
|
+
return mime_type.startsWith("image/");
|
|
3014
|
+
}
|
|
3015
|
+
var ToolbarSeparator = () => /* @__PURE__ */ jsx("div", { className: "cls_rte_toolbar_separator mx-1 h-6 w-px bg-border" });
|
|
3016
|
+
var Toolbar = ({
|
|
3017
|
+
editor,
|
|
3018
|
+
variables = [],
|
|
3019
|
+
attachments,
|
|
3020
|
+
on_attachments_change,
|
|
3021
|
+
disabled = false
|
|
3022
|
+
}) => {
|
|
3023
|
+
const [link_url, set_link_url] = React23.useState("https://");
|
|
3024
|
+
const [link_popover_open, set_link_popover_open] = React23.useState(false);
|
|
3025
|
+
const [text_color_open, set_text_color_open] = React23.useState(false);
|
|
3026
|
+
const [highlight_color_open, set_highlight_color_open] = React23.useState(false);
|
|
3027
|
+
const [variables_menu_open, set_variables_menu_open] = React23.useState(false);
|
|
3028
|
+
const [table_menu_open, set_table_menu_open] = React23.useState(false);
|
|
3029
|
+
const [text_color, set_text_color] = React23.useState("#000000");
|
|
3030
|
+
const [highlight_color, set_highlight_color] = React23.useState("#ffff00");
|
|
3031
|
+
const [table_rows, set_table_rows] = React23.useState(3);
|
|
3032
|
+
const [table_cols, set_table_cols] = React23.useState(3);
|
|
3033
|
+
const [hovered_cell, set_hovered_cell] = React23.useState(null);
|
|
3034
|
+
const file_input_ref = React23.useRef(null);
|
|
3035
|
+
const image_input_ref = React23.useRef(null);
|
|
3036
|
+
if (!editor) {
|
|
3037
|
+
return null;
|
|
3038
|
+
}
|
|
3039
|
+
const get_current_font_size = () => {
|
|
3040
|
+
const attrs = editor.getAttributes("textStyle");
|
|
3041
|
+
return attrs.fontSize || FONT_SIZE_CONFIG.default;
|
|
3042
|
+
};
|
|
3043
|
+
const get_current_font_family = () => {
|
|
3044
|
+
const attrs = editor.getAttributes("textStyle");
|
|
3045
|
+
return attrs.fontFamily || FONT_FAMILIES[0].value;
|
|
3046
|
+
};
|
|
3047
|
+
const get_current_block_type = () => {
|
|
3048
|
+
if (editor.isActive("heading", { level: 1 })) return "heading-1";
|
|
3049
|
+
if (editor.isActive("heading", { level: 2 })) return "heading-2";
|
|
3050
|
+
if (editor.isActive("heading", { level: 3 })) return "heading-3";
|
|
3051
|
+
if (editor.isActive("bulletList")) return "bullet-list";
|
|
3052
|
+
if (editor.isActive("orderedList")) return "ordered-list";
|
|
3053
|
+
if (editor.isActive("taskList")) return "task-list";
|
|
3054
|
+
if (editor.isActive("codeBlock")) return "code-block";
|
|
3055
|
+
if (editor.isActive("blockquote")) return "blockquote";
|
|
3056
|
+
return "paragraph";
|
|
3057
|
+
};
|
|
3058
|
+
const handle_block_type_change = (value) => {
|
|
3059
|
+
switch (value) {
|
|
3060
|
+
case "paragraph":
|
|
3061
|
+
editor.chain().focus().setParagraph().run();
|
|
3062
|
+
break;
|
|
3063
|
+
case "heading-1":
|
|
3064
|
+
editor.chain().focus().toggleHeading({ level: 1 }).run();
|
|
3065
|
+
break;
|
|
3066
|
+
case "heading-2":
|
|
3067
|
+
editor.chain().focus().toggleHeading({ level: 2 }).run();
|
|
3068
|
+
break;
|
|
3069
|
+
case "heading-3":
|
|
3070
|
+
editor.chain().focus().toggleHeading({ level: 3 }).run();
|
|
3071
|
+
break;
|
|
3072
|
+
case "bullet-list":
|
|
3073
|
+
editor.chain().focus().toggleBulletList().run();
|
|
3074
|
+
break;
|
|
3075
|
+
case "ordered-list":
|
|
3076
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
3077
|
+
break;
|
|
3078
|
+
case "task-list":
|
|
3079
|
+
editor.chain().focus().toggleTaskList().run();
|
|
3080
|
+
break;
|
|
3081
|
+
case "code-block":
|
|
3082
|
+
editor.chain().focus().toggleCodeBlock().run();
|
|
3083
|
+
break;
|
|
3084
|
+
case "blockquote":
|
|
3085
|
+
editor.chain().focus().toggleBlockquote().run();
|
|
3086
|
+
break;
|
|
3087
|
+
}
|
|
3088
|
+
};
|
|
3089
|
+
const handle_font_family_change = (value) => {
|
|
3090
|
+
editor.chain().focus().setFontFamily(value).run();
|
|
3091
|
+
};
|
|
3092
|
+
const handle_font_size_change = (delta) => {
|
|
3093
|
+
const current = get_current_font_size();
|
|
3094
|
+
const new_size = Math.min(
|
|
3095
|
+
FONT_SIZE_CONFIG.max,
|
|
3096
|
+
Math.max(FONT_SIZE_CONFIG.min, current + delta)
|
|
3097
|
+
);
|
|
3098
|
+
editor.chain().focus().setFontSizeNum(new_size).run();
|
|
3099
|
+
};
|
|
3100
|
+
const handle_set_link = () => {
|
|
3101
|
+
if (link_url && link_url !== "https://") {
|
|
3102
|
+
editor.chain().focus().setLink({ href: link_url }).run();
|
|
3103
|
+
set_link_url("https://");
|
|
3104
|
+
set_link_popover_open(false);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
const handle_remove_link = () => {
|
|
3108
|
+
editor.chain().focus().unsetLink().run();
|
|
3109
|
+
set_link_popover_open(false);
|
|
3110
|
+
};
|
|
3111
|
+
const handle_text_color_change = (color2) => {
|
|
3112
|
+
set_text_color(color2.hex);
|
|
3113
|
+
editor.chain().focus().setColor(color2.hex).run();
|
|
3114
|
+
};
|
|
3115
|
+
const handle_highlight_color_change = (color2) => {
|
|
3116
|
+
set_highlight_color(color2.hex);
|
|
3117
|
+
editor.chain().focus().setHighlight({ color: color2.hex }).run();
|
|
3118
|
+
};
|
|
3119
|
+
const handle_image_insert = async (e) => {
|
|
3120
|
+
const file = e.target.files?.[0];
|
|
3121
|
+
if (file && file.type.startsWith("image/")) {
|
|
3122
|
+
const data_url = await file_to_data_url(file);
|
|
3123
|
+
editor.chain().focus().setImage({ src: data_url }).run();
|
|
3124
|
+
}
|
|
3125
|
+
if (image_input_ref.current) {
|
|
3126
|
+
image_input_ref.current.value = "";
|
|
3127
|
+
}
|
|
3128
|
+
};
|
|
3129
|
+
const handle_file_attach = async (e) => {
|
|
3130
|
+
const file = e.target.files?.[0];
|
|
3131
|
+
if (file) {
|
|
3132
|
+
const attachment = await file_to_attachment(file);
|
|
3133
|
+
on_attachments_change([...attachments, attachment]);
|
|
3134
|
+
}
|
|
3135
|
+
if (file_input_ref.current) {
|
|
3136
|
+
file_input_ref.current.value = "";
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
const handle_table_insert = (rows, cols) => {
|
|
3140
|
+
editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
|
|
3141
|
+
set_table_menu_open(false);
|
|
3142
|
+
set_table_rows(3);
|
|
3143
|
+
set_table_cols(3);
|
|
3144
|
+
set_hovered_cell(null);
|
|
3145
|
+
};
|
|
3146
|
+
const handle_add_row_before = () => {
|
|
3147
|
+
editor.chain().focus().addRowBefore().run();
|
|
3148
|
+
};
|
|
3149
|
+
const handle_add_row_after = () => {
|
|
3150
|
+
editor.chain().focus().addRowAfter().run();
|
|
3151
|
+
};
|
|
3152
|
+
const handle_delete_row = () => {
|
|
3153
|
+
editor.chain().focus().deleteRow().run();
|
|
3154
|
+
};
|
|
3155
|
+
const handle_add_col_before = () => {
|
|
3156
|
+
editor.chain().focus().addColumnBefore().run();
|
|
3157
|
+
};
|
|
3158
|
+
const handle_add_col_after = () => {
|
|
3159
|
+
editor.chain().focus().addColumnAfter().run();
|
|
3160
|
+
};
|
|
3161
|
+
const handle_delete_col = () => {
|
|
3162
|
+
editor.chain().focus().deleteColumn().run();
|
|
3163
|
+
};
|
|
3164
|
+
const handle_delete_table = () => {
|
|
3165
|
+
editor.chain().focus().deleteTable().run();
|
|
3166
|
+
};
|
|
3167
|
+
const handle_hr_insert = () => {
|
|
3168
|
+
editor.chain().focus().setHorizontalRule().run();
|
|
3169
|
+
};
|
|
3170
|
+
const handle_variable_insert = (variable_name) => {
|
|
3171
|
+
editor.chain().focus().insertVariable(variable_name).run();
|
|
3172
|
+
set_variables_menu_open(false);
|
|
3173
|
+
};
|
|
3174
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxs(
|
|
3175
|
+
"div",
|
|
3176
|
+
{
|
|
3177
|
+
className: cn(
|
|
3178
|
+
"cls_rte_toolbar",
|
|
3179
|
+
"flex flex-wrap items-center gap-0.5",
|
|
3180
|
+
"p-1.5 rounded-t-md",
|
|
3181
|
+
"bg-muted border-b border-border",
|
|
3182
|
+
disabled && "opacity-50 pointer-events-none"
|
|
3183
|
+
),
|
|
3184
|
+
children: [
|
|
3185
|
+
/* @__PURE__ */ jsx(
|
|
3186
|
+
ToolbarButton,
|
|
3187
|
+
{
|
|
3188
|
+
onClick: () => editor.chain().focus().undo().run(),
|
|
3189
|
+
disabled: !editor.can().undo(),
|
|
3190
|
+
tooltip: "Undo",
|
|
3191
|
+
children: /* @__PURE__ */ jsx(LuUndo2, { className: "h-4 w-4" })
|
|
3192
|
+
}
|
|
3193
|
+
),
|
|
3194
|
+
/* @__PURE__ */ jsx(
|
|
3195
|
+
ToolbarButton,
|
|
3196
|
+
{
|
|
3197
|
+
onClick: () => editor.chain().focus().redo().run(),
|
|
3198
|
+
disabled: !editor.can().redo(),
|
|
3199
|
+
tooltip: "Redo",
|
|
3200
|
+
children: /* @__PURE__ */ jsx(LuRedo2, { className: "h-4 w-4" })
|
|
3201
|
+
}
|
|
3202
|
+
),
|
|
3203
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3204
|
+
/* @__PURE__ */ jsxs(Select, { value: get_current_block_type(), onValueChange: handle_block_type_change, children: [
|
|
3205
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[130px] text-xs", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3206
|
+
/* @__PURE__ */ jsx(SelectContent, { children: BLOCK_TYPES.map((type) => /* @__PURE__ */ jsx(SelectItem, { value: type.value, className: "text-xs", children: type.label }, type.value)) })
|
|
3207
|
+
] }),
|
|
3208
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3209
|
+
/* @__PURE__ */ jsxs(Select, { value: get_current_font_family(), onValueChange: handle_font_family_change, children: [
|
|
3210
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-[120px] text-xs", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3211
|
+
/* @__PURE__ */ jsx(SelectContent, { children: FONT_FAMILIES.map((font) => /* @__PURE__ */ jsx(
|
|
3212
|
+
SelectItem,
|
|
3213
|
+
{
|
|
3214
|
+
value: font.value,
|
|
3215
|
+
className: "text-xs",
|
|
3216
|
+
style: { fontFamily: font.value },
|
|
3217
|
+
children: font.label
|
|
3218
|
+
},
|
|
3219
|
+
font.value
|
|
3220
|
+
)) })
|
|
3221
|
+
] }),
|
|
3222
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
3223
|
+
/* @__PURE__ */ jsx(
|
|
3224
|
+
ToolbarButton,
|
|
3225
|
+
{
|
|
3226
|
+
onClick: () => handle_font_size_change(-2),
|
|
3227
|
+
tooltip: "Decrease font size",
|
|
3228
|
+
children: /* @__PURE__ */ jsx(LuMinus, { className: "h-3 w-3" })
|
|
3229
|
+
}
|
|
3230
|
+
),
|
|
3231
|
+
/* @__PURE__ */ jsx("span", { className: "w-8 text-center text-xs tabular-nums", children: get_current_font_size() }),
|
|
3232
|
+
/* @__PURE__ */ jsx(
|
|
3233
|
+
ToolbarButton,
|
|
3234
|
+
{
|
|
3235
|
+
onClick: () => handle_font_size_change(FONT_SIZE_CONFIG.step),
|
|
3236
|
+
tooltip: "Increase font size",
|
|
3237
|
+
children: /* @__PURE__ */ jsx(LuPlus, { className: "h-3 w-3" })
|
|
3238
|
+
}
|
|
3239
|
+
)
|
|
3240
|
+
] }),
|
|
3241
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3242
|
+
/* @__PURE__ */ jsx(
|
|
3243
|
+
ToolbarButton,
|
|
3244
|
+
{
|
|
3245
|
+
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
3246
|
+
is_active: editor.isActive("bold"),
|
|
3247
|
+
tooltip: "Bold",
|
|
3248
|
+
children: /* @__PURE__ */ jsx(LuBold, { className: "h-4 w-4" })
|
|
3249
|
+
}
|
|
3250
|
+
),
|
|
3251
|
+
/* @__PURE__ */ jsx(
|
|
3252
|
+
ToolbarButton,
|
|
3253
|
+
{
|
|
3254
|
+
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
3255
|
+
is_active: editor.isActive("italic"),
|
|
3256
|
+
tooltip: "Italic",
|
|
3257
|
+
children: /* @__PURE__ */ jsx(LuItalic, { className: "h-4 w-4" })
|
|
3258
|
+
}
|
|
3259
|
+
),
|
|
3260
|
+
/* @__PURE__ */ jsx(
|
|
3261
|
+
ToolbarButton,
|
|
3262
|
+
{
|
|
3263
|
+
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
3264
|
+
is_active: editor.isActive("underline"),
|
|
3265
|
+
tooltip: "Underline",
|
|
3266
|
+
children: /* @__PURE__ */ jsx(LuUnderline, { className: "h-4 w-4" })
|
|
3267
|
+
}
|
|
3268
|
+
),
|
|
3269
|
+
/* @__PURE__ */ jsx(
|
|
3270
|
+
ToolbarButton,
|
|
3271
|
+
{
|
|
3272
|
+
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
3273
|
+
is_active: editor.isActive("strike"),
|
|
3274
|
+
tooltip: "Strikethrough",
|
|
3275
|
+
children: /* @__PURE__ */ jsx(LuStrikethrough, { className: "h-4 w-4" })
|
|
3276
|
+
}
|
|
3277
|
+
),
|
|
3278
|
+
/* @__PURE__ */ jsx(
|
|
3279
|
+
ToolbarButton,
|
|
3280
|
+
{
|
|
3281
|
+
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
3282
|
+
is_active: editor.isActive("subscript"),
|
|
3283
|
+
tooltip: "Subscript",
|
|
3284
|
+
children: /* @__PURE__ */ jsx(LuSubscript, { className: "h-4 w-4" })
|
|
3285
|
+
}
|
|
3286
|
+
),
|
|
3287
|
+
/* @__PURE__ */ jsx(
|
|
3288
|
+
ToolbarButton,
|
|
3289
|
+
{
|
|
3290
|
+
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
3291
|
+
is_active: editor.isActive("superscript"),
|
|
3292
|
+
tooltip: "Superscript",
|
|
3293
|
+
children: /* @__PURE__ */ jsx(LuSuperscript, { className: "h-4 w-4" })
|
|
3294
|
+
}
|
|
3295
|
+
),
|
|
3296
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3297
|
+
/* @__PURE__ */ jsxs(Popover, { open: link_popover_open, onOpenChange: set_link_popover_open, children: [
|
|
3298
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(ToolbarButton, { is_active: editor.isActive("link"), tooltip: "Link", children: /* @__PURE__ */ jsx(LuLink, { className: "h-4 w-4" }) }) }),
|
|
3299
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-80 p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3300
|
+
/* @__PURE__ */ jsx(
|
|
3301
|
+
Input,
|
|
3302
|
+
{
|
|
3303
|
+
value: link_url,
|
|
3304
|
+
onChange: (e) => set_link_url(e.target.value),
|
|
3305
|
+
placeholder: "https://example.com",
|
|
3306
|
+
className: "h-8 text-sm"
|
|
3307
|
+
}
|
|
3308
|
+
),
|
|
3309
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3310
|
+
/* @__PURE__ */ jsxs(Button, { size: "sm", onClick: handle_set_link, className: "flex-1", children: [
|
|
3311
|
+
editor.isActive("link") ? "Update" : "Add",
|
|
3312
|
+
" Link"
|
|
3313
|
+
] }),
|
|
3314
|
+
editor.isActive("link") && /* @__PURE__ */ jsx(
|
|
3315
|
+
Button,
|
|
3316
|
+
{
|
|
3317
|
+
size: "sm",
|
|
3318
|
+
variant: "destructive",
|
|
3319
|
+
onClick: handle_remove_link,
|
|
3320
|
+
children: "Remove"
|
|
3321
|
+
}
|
|
3322
|
+
)
|
|
3323
|
+
] })
|
|
3324
|
+
] }) })
|
|
3325
|
+
] }),
|
|
3326
|
+
/* @__PURE__ */ jsx(
|
|
3327
|
+
ToolbarButton,
|
|
3328
|
+
{
|
|
3329
|
+
onClick: () => editor.chain().focus().unsetAllMarks().clearNodes().run(),
|
|
3330
|
+
tooltip: "Clear formatting",
|
|
3331
|
+
children: /* @__PURE__ */ jsx(LuRemoveFormatting, { className: "h-4 w-4" })
|
|
3332
|
+
}
|
|
3333
|
+
),
|
|
3334
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3335
|
+
/* @__PURE__ */ jsxs(Popover, { open: text_color_open, onOpenChange: set_text_color_open, children: [
|
|
3336
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(ToolbarButton, { tooltip: "Text color", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
3337
|
+
/* @__PURE__ */ jsx(LuPalette, { className: "h-4 w-4" }),
|
|
3338
|
+
/* @__PURE__ */ jsx(
|
|
3339
|
+
"div",
|
|
3340
|
+
{
|
|
3341
|
+
className: "h-0.5 w-4 mt-0.5 rounded-full",
|
|
3342
|
+
style: { backgroundColor: text_color }
|
|
3343
|
+
}
|
|
3344
|
+
)
|
|
3345
|
+
] }) }) }),
|
|
3346
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
3347
|
+
esm_default8,
|
|
3348
|
+
{
|
|
3349
|
+
color: text_color,
|
|
3350
|
+
onChange: handle_text_color_change,
|
|
3351
|
+
presetColors: [
|
|
3352
|
+
"#000000",
|
|
3353
|
+
"#434343",
|
|
3354
|
+
"#666666",
|
|
3355
|
+
"#999999",
|
|
3356
|
+
"#cccccc",
|
|
3357
|
+
"#ffffff",
|
|
3358
|
+
"#ff0000",
|
|
3359
|
+
"#ff9900",
|
|
3360
|
+
"#ffff00",
|
|
3361
|
+
"#00ff00",
|
|
3362
|
+
"#00ffff",
|
|
3363
|
+
"#0000ff",
|
|
3364
|
+
"#9900ff",
|
|
3365
|
+
"#ff00ff",
|
|
3366
|
+
"#f4cccc",
|
|
3367
|
+
"#fce5cd",
|
|
3368
|
+
"#fff2cc",
|
|
3369
|
+
"#d9ead3"
|
|
3370
|
+
]
|
|
3371
|
+
}
|
|
3372
|
+
) })
|
|
3373
|
+
] }),
|
|
3374
|
+
/* @__PURE__ */ jsxs(Popover, { open: highlight_color_open, onOpenChange: set_highlight_color_open, children: [
|
|
3375
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(ToolbarButton, { tooltip: "Highlight color", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
3376
|
+
/* @__PURE__ */ jsx(LuHighlighter, { className: "h-4 w-4" }),
|
|
3377
|
+
/* @__PURE__ */ jsx(
|
|
3378
|
+
"div",
|
|
3379
|
+
{
|
|
3380
|
+
className: "h-0.5 w-4 mt-0.5 rounded-full",
|
|
3381
|
+
style: { backgroundColor: highlight_color }
|
|
3382
|
+
}
|
|
3383
|
+
)
|
|
3384
|
+
] }) }) }),
|
|
3385
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
3386
|
+
esm_default8,
|
|
3387
|
+
{
|
|
3388
|
+
color: highlight_color,
|
|
3389
|
+
onChange: handle_highlight_color_change,
|
|
3390
|
+
presetColors: [
|
|
3391
|
+
"#ffff00",
|
|
3392
|
+
"#00ff00",
|
|
3393
|
+
"#00ffff",
|
|
3394
|
+
"#ff00ff",
|
|
3395
|
+
"#ff0000",
|
|
3396
|
+
"#0000ff",
|
|
3397
|
+
"#fff2cc",
|
|
3398
|
+
"#d9ead3",
|
|
3399
|
+
"#cfe2f3",
|
|
3400
|
+
"#ead1dc",
|
|
3401
|
+
"#fce5cd",
|
|
3402
|
+
"#d0e0e3"
|
|
3403
|
+
]
|
|
3404
|
+
}
|
|
3405
|
+
) })
|
|
3406
|
+
] }),
|
|
3407
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3408
|
+
/* @__PURE__ */ jsx(
|
|
3409
|
+
ToolbarButton,
|
|
3410
|
+
{
|
|
3411
|
+
onClick: () => editor.chain().focus().setTextAlign("left").run(),
|
|
3412
|
+
is_active: editor.isActive({ textAlign: "left" }),
|
|
3413
|
+
tooltip: "Align left",
|
|
3414
|
+
children: /* @__PURE__ */ jsx(LuAlignLeft, { className: "h-4 w-4" })
|
|
3415
|
+
}
|
|
3416
|
+
),
|
|
3417
|
+
/* @__PURE__ */ jsx(
|
|
3418
|
+
ToolbarButton,
|
|
3419
|
+
{
|
|
3420
|
+
onClick: () => editor.chain().focus().setTextAlign("center").run(),
|
|
3421
|
+
is_active: editor.isActive({ textAlign: "center" }),
|
|
3422
|
+
tooltip: "Align center",
|
|
3423
|
+
children: /* @__PURE__ */ jsx(LuAlignCenter, { className: "h-4 w-4" })
|
|
3424
|
+
}
|
|
3425
|
+
),
|
|
3426
|
+
/* @__PURE__ */ jsx(
|
|
3427
|
+
ToolbarButton,
|
|
3428
|
+
{
|
|
3429
|
+
onClick: () => editor.chain().focus().setTextAlign("right").run(),
|
|
3430
|
+
is_active: editor.isActive({ textAlign: "right" }),
|
|
3431
|
+
tooltip: "Align right",
|
|
3432
|
+
children: /* @__PURE__ */ jsx(LuAlignRight, { className: "h-4 w-4" })
|
|
3433
|
+
}
|
|
3434
|
+
),
|
|
3435
|
+
/* @__PURE__ */ jsx(
|
|
3436
|
+
ToolbarButton,
|
|
3437
|
+
{
|
|
3438
|
+
onClick: () => editor.chain().focus().setTextAlign("justify").run(),
|
|
3439
|
+
is_active: editor.isActive({ textAlign: "justify" }),
|
|
3440
|
+
tooltip: "Justify",
|
|
3441
|
+
children: /* @__PURE__ */ jsx(LuAlignJustify, { className: "h-4 w-4" })
|
|
3442
|
+
}
|
|
3443
|
+
),
|
|
3444
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3445
|
+
/* @__PURE__ */ jsx(
|
|
3446
|
+
ToolbarButton,
|
|
3447
|
+
{
|
|
3448
|
+
onClick: () => editor.chain().focus().toggleBulletList().run(),
|
|
3449
|
+
is_active: editor.isActive("bulletList"),
|
|
3450
|
+
tooltip: "Bullet list",
|
|
3451
|
+
children: /* @__PURE__ */ jsx(LuList, { className: "h-4 w-4" })
|
|
3452
|
+
}
|
|
3453
|
+
),
|
|
3454
|
+
/* @__PURE__ */ jsx(
|
|
3455
|
+
ToolbarButton,
|
|
3456
|
+
{
|
|
3457
|
+
onClick: () => editor.chain().focus().toggleOrderedList().run(),
|
|
3458
|
+
is_active: editor.isActive("orderedList"),
|
|
3459
|
+
tooltip: "Numbered list",
|
|
3460
|
+
children: /* @__PURE__ */ jsx(LuListOrdered, { className: "h-4 w-4" })
|
|
3461
|
+
}
|
|
3462
|
+
),
|
|
3463
|
+
/* @__PURE__ */ jsx(
|
|
3464
|
+
ToolbarButton,
|
|
3465
|
+
{
|
|
3466
|
+
onClick: () => editor.chain().focus().toggleTaskList().run(),
|
|
3467
|
+
is_active: editor.isActive("taskList"),
|
|
3468
|
+
tooltip: "Checklist",
|
|
3469
|
+
children: /* @__PURE__ */ jsx(LuListChecks, { className: "h-4 w-4" })
|
|
3470
|
+
}
|
|
3471
|
+
),
|
|
3472
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3473
|
+
/* @__PURE__ */ jsx(
|
|
3474
|
+
ToolbarButton,
|
|
3475
|
+
{
|
|
3476
|
+
onClick: () => {
|
|
3477
|
+
if (editor.isActive("listItem")) {
|
|
3478
|
+
editor.chain().focus().liftListItem("listItem").run();
|
|
3479
|
+
} else if (editor.isActive("taskItem")) {
|
|
3480
|
+
editor.chain().focus().liftListItem("taskItem").run();
|
|
3481
|
+
}
|
|
3482
|
+
},
|
|
3483
|
+
disabled: !editor.can().liftListItem("listItem") && !editor.can().liftListItem("taskItem"),
|
|
3484
|
+
tooltip: "Decrease indent",
|
|
3485
|
+
children: /* @__PURE__ */ jsx(LuIndentDecrease, { className: "h-4 w-4" })
|
|
3486
|
+
}
|
|
3487
|
+
),
|
|
3488
|
+
/* @__PURE__ */ jsx(
|
|
3489
|
+
ToolbarButton,
|
|
3490
|
+
{
|
|
3491
|
+
onClick: () => {
|
|
3492
|
+
if (editor.isActive("listItem")) {
|
|
3493
|
+
editor.chain().focus().sinkListItem("listItem").run();
|
|
3494
|
+
} else if (editor.isActive("taskItem")) {
|
|
3495
|
+
editor.chain().focus().sinkListItem("taskItem").run();
|
|
3496
|
+
}
|
|
3497
|
+
},
|
|
3498
|
+
disabled: !editor.can().sinkListItem("listItem") && !editor.can().sinkListItem("taskItem"),
|
|
3499
|
+
tooltip: "Increase indent",
|
|
3500
|
+
children: /* @__PURE__ */ jsx(LuIndentIncrease, { className: "h-4 w-4" })
|
|
3501
|
+
}
|
|
3502
|
+
),
|
|
3503
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3504
|
+
/* @__PURE__ */ jsx(
|
|
3505
|
+
ToolbarButton,
|
|
3506
|
+
{
|
|
3507
|
+
onClick: handle_hr_insert,
|
|
3508
|
+
tooltip: "Horizontal rule",
|
|
3509
|
+
children: /* @__PURE__ */ jsx(RxDividerHorizontal, { className: "h-4 w-4" })
|
|
3510
|
+
}
|
|
3511
|
+
),
|
|
3512
|
+
/* @__PURE__ */ jsx(
|
|
3513
|
+
ToolbarButton,
|
|
3514
|
+
{
|
|
3515
|
+
onClick: () => image_input_ref.current?.click(),
|
|
3516
|
+
tooltip: "Insert image",
|
|
3517
|
+
children: /* @__PURE__ */ jsx(LuImage, { className: "h-4 w-4" })
|
|
3518
|
+
}
|
|
3519
|
+
),
|
|
3520
|
+
/* @__PURE__ */ jsxs(Popover, { open: table_menu_open, onOpenChange: set_table_menu_open, children: [
|
|
3521
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
3522
|
+
ToolbarButton,
|
|
3523
|
+
{
|
|
3524
|
+
is_active: editor.isActive("table"),
|
|
3525
|
+
tooltip: "Table",
|
|
3526
|
+
children: /* @__PURE__ */ jsx(LuTable, { className: "h-4 w-4" })
|
|
3527
|
+
}
|
|
3528
|
+
) }),
|
|
3529
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-3", align: "start", children: editor.isActive("table") ? (
|
|
3530
|
+
// Table editing controls when inside a table
|
|
3531
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3532
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs font-medium mb-1", children: "Table Operations" }),
|
|
3533
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-1", children: [
|
|
3534
|
+
/* @__PURE__ */ jsxs(
|
|
3535
|
+
Button,
|
|
3536
|
+
{
|
|
3537
|
+
variant: "ghost",
|
|
3538
|
+
size: "sm",
|
|
3539
|
+
className: "justify-start text-xs h-7",
|
|
3540
|
+
onClick: handle_add_row_before,
|
|
3541
|
+
children: [
|
|
3542
|
+
/* @__PURE__ */ jsx(LuTableRowsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3543
|
+
"Add row above"
|
|
3544
|
+
]
|
|
3545
|
+
}
|
|
3546
|
+
),
|
|
3547
|
+
/* @__PURE__ */ jsxs(
|
|
3548
|
+
Button,
|
|
3549
|
+
{
|
|
3550
|
+
variant: "ghost",
|
|
3551
|
+
size: "sm",
|
|
3552
|
+
className: "justify-start text-xs h-7",
|
|
3553
|
+
onClick: handle_add_row_after,
|
|
3554
|
+
children: [
|
|
3555
|
+
/* @__PURE__ */ jsx(LuTableRowsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3556
|
+
"Add row below"
|
|
3557
|
+
]
|
|
3558
|
+
}
|
|
3559
|
+
),
|
|
3560
|
+
/* @__PURE__ */ jsxs(
|
|
3561
|
+
Button,
|
|
3562
|
+
{
|
|
3563
|
+
variant: "ghost",
|
|
3564
|
+
size: "sm",
|
|
3565
|
+
className: "justify-start text-xs h-7",
|
|
3566
|
+
onClick: handle_add_col_before,
|
|
3567
|
+
children: [
|
|
3568
|
+
/* @__PURE__ */ jsx(LuTableColumnsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3569
|
+
"Add col left"
|
|
3570
|
+
]
|
|
3571
|
+
}
|
|
3572
|
+
),
|
|
3573
|
+
/* @__PURE__ */ jsxs(
|
|
3574
|
+
Button,
|
|
3575
|
+
{
|
|
3576
|
+
variant: "ghost",
|
|
3577
|
+
size: "sm",
|
|
3578
|
+
className: "justify-start text-xs h-7",
|
|
3579
|
+
onClick: handle_add_col_after,
|
|
3580
|
+
children: [
|
|
3581
|
+
/* @__PURE__ */ jsx(LuTableColumnsSplit, { className: "h-3 w-3 mr-1" }),
|
|
3582
|
+
"Add col right"
|
|
3583
|
+
]
|
|
3584
|
+
}
|
|
3585
|
+
),
|
|
3586
|
+
/* @__PURE__ */ jsxs(
|
|
3587
|
+
Button,
|
|
3588
|
+
{
|
|
3589
|
+
variant: "ghost",
|
|
3590
|
+
size: "sm",
|
|
3591
|
+
className: "justify-start text-xs h-7 text-destructive hover:text-destructive",
|
|
3592
|
+
onClick: handle_delete_row,
|
|
3593
|
+
children: [
|
|
3594
|
+
/* @__PURE__ */ jsx(LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3595
|
+
"Delete row"
|
|
3596
|
+
]
|
|
3597
|
+
}
|
|
3598
|
+
),
|
|
3599
|
+
/* @__PURE__ */ jsxs(
|
|
3600
|
+
Button,
|
|
3601
|
+
{
|
|
3602
|
+
variant: "ghost",
|
|
3603
|
+
size: "sm",
|
|
3604
|
+
className: "justify-start text-xs h-7 text-destructive hover:text-destructive",
|
|
3605
|
+
onClick: handle_delete_col,
|
|
3606
|
+
children: [
|
|
3607
|
+
/* @__PURE__ */ jsx(LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3608
|
+
"Delete col"
|
|
3609
|
+
]
|
|
3610
|
+
}
|
|
3611
|
+
)
|
|
3612
|
+
] }),
|
|
3613
|
+
/* @__PURE__ */ jsxs(
|
|
3614
|
+
Button,
|
|
3615
|
+
{
|
|
3616
|
+
variant: "destructive",
|
|
3617
|
+
size: "sm",
|
|
3618
|
+
className: "justify-center text-xs h-7 mt-1",
|
|
3619
|
+
onClick: handle_delete_table,
|
|
3620
|
+
children: [
|
|
3621
|
+
/* @__PURE__ */ jsx(LuTrash2, { className: "h-3 w-3 mr-1" }),
|
|
3622
|
+
"Delete table"
|
|
3623
|
+
]
|
|
3624
|
+
}
|
|
3625
|
+
)
|
|
3626
|
+
] })
|
|
3627
|
+
) : (
|
|
3628
|
+
// Table size picker when not in a table
|
|
3629
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3630
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs font-medium mb-1", children: "Insert Table" }),
|
|
3631
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-0.5", children: Array.from({ length: 6 }).map((_, row_idx) => /* @__PURE__ */ jsx("div", { className: "flex gap-0.5", children: Array.from({ length: 6 }).map((_2, col_idx) => /* @__PURE__ */ jsx(
|
|
3632
|
+
"div",
|
|
3633
|
+
{
|
|
3634
|
+
className: cn(
|
|
3635
|
+
"w-5 h-5 border rounded-sm cursor-pointer transition-colors",
|
|
3636
|
+
hovered_cell && row_idx < hovered_cell.row && col_idx < hovered_cell.col ? "bg-primary border-primary" : "border-border hover:border-primary/50"
|
|
3637
|
+
),
|
|
3638
|
+
onMouseEnter: () => set_hovered_cell({ row: row_idx + 1, col: col_idx + 1 }),
|
|
3639
|
+
onMouseLeave: () => set_hovered_cell(null),
|
|
3640
|
+
onClick: () => handle_table_insert(row_idx + 1, col_idx + 1)
|
|
3641
|
+
},
|
|
3642
|
+
col_idx
|
|
3643
|
+
)) }, row_idx)) }),
|
|
3644
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-center text-muted-foreground", children: hovered_cell ? `${hovered_cell.col} x ${hovered_cell.row}` : "Select size" }),
|
|
3645
|
+
/* @__PURE__ */ jsxs("div", { className: "border-t pt-2 mt-1", children: [
|
|
3646
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground mb-2", children: "Custom size" }),
|
|
3647
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3648
|
+
/* @__PURE__ */ jsx(
|
|
3649
|
+
Input,
|
|
3650
|
+
{
|
|
3651
|
+
type: "number",
|
|
3652
|
+
min: 1,
|
|
3653
|
+
max: 20,
|
|
3654
|
+
value: table_cols,
|
|
3655
|
+
onChange: (e) => set_table_cols(Math.max(1, Math.min(20, parseInt(e.target.value) || 1))),
|
|
3656
|
+
className: "h-7 w-14 text-xs"
|
|
3657
|
+
}
|
|
3658
|
+
),
|
|
3659
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "x" }),
|
|
3660
|
+
/* @__PURE__ */ jsx(
|
|
3661
|
+
Input,
|
|
3662
|
+
{
|
|
3663
|
+
type: "number",
|
|
3664
|
+
min: 1,
|
|
3665
|
+
max: 20,
|
|
3666
|
+
value: table_rows,
|
|
3667
|
+
onChange: (e) => set_table_rows(Math.max(1, Math.min(20, parseInt(e.target.value) || 1))),
|
|
3668
|
+
className: "h-7 w-14 text-xs"
|
|
3669
|
+
}
|
|
3670
|
+
),
|
|
3671
|
+
/* @__PURE__ */ jsxs(
|
|
3672
|
+
Button,
|
|
3673
|
+
{
|
|
3674
|
+
size: "sm",
|
|
3675
|
+
className: "h-7 text-xs",
|
|
3676
|
+
onClick: () => handle_table_insert(table_rows, table_cols),
|
|
3677
|
+
children: [
|
|
3678
|
+
/* @__PURE__ */ jsx(LuGrid3X3, { className: "h-3 w-3 mr-1" }),
|
|
3679
|
+
"Insert"
|
|
3680
|
+
]
|
|
3681
|
+
}
|
|
3682
|
+
)
|
|
3683
|
+
] })
|
|
3684
|
+
] })
|
|
3685
|
+
] })
|
|
3686
|
+
) })
|
|
3687
|
+
] }),
|
|
3688
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
3689
|
+
variables.length > 0 && /* @__PURE__ */ jsxs(Popover, { open: variables_menu_open, onOpenChange: set_variables_menu_open, children: [
|
|
3690
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(ToolbarButton, { tooltip: "Insert variable", children: /* @__PURE__ */ jsx(LuVariable, { className: "h-4 w-4" }) }) }),
|
|
3691
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-64 p-0", align: "start", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
3692
|
+
/* @__PURE__ */ jsx(CommandInput, { placeholder: "Search variables...", className: "h-8 text-xs" }),
|
|
3693
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
3694
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No variables found." }),
|
|
3695
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: variables.map((variable) => /* @__PURE__ */ jsx(
|
|
3696
|
+
CommandItem,
|
|
3697
|
+
{
|
|
3698
|
+
value: variable.name,
|
|
3699
|
+
onSelect: () => handle_variable_insert(variable.name),
|
|
3700
|
+
className: "text-xs",
|
|
3701
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
3702
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: `{{${variable.name}}}` }),
|
|
3703
|
+
variable.description && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-[10px]", children: variable.description })
|
|
3704
|
+
] })
|
|
3705
|
+
},
|
|
3706
|
+
variable.name
|
|
3707
|
+
)) })
|
|
3708
|
+
] })
|
|
3709
|
+
] }) })
|
|
3710
|
+
] }),
|
|
3711
|
+
/* @__PURE__ */ jsx(
|
|
3712
|
+
ToolbarButton,
|
|
3713
|
+
{
|
|
3714
|
+
onClick: () => file_input_ref.current?.click(),
|
|
3715
|
+
tooltip: "Attach file",
|
|
3716
|
+
children: /* @__PURE__ */ jsx(LuPaperclip, { className: "h-4 w-4" })
|
|
3717
|
+
}
|
|
3718
|
+
),
|
|
3719
|
+
/* @__PURE__ */ jsx(
|
|
3720
|
+
"input",
|
|
3721
|
+
{
|
|
3722
|
+
ref: file_input_ref,
|
|
3723
|
+
type: "file",
|
|
3724
|
+
className: "hidden",
|
|
3725
|
+
onChange: handle_file_attach
|
|
3726
|
+
}
|
|
3727
|
+
),
|
|
3728
|
+
/* @__PURE__ */ jsx(
|
|
3729
|
+
"input",
|
|
3730
|
+
{
|
|
3731
|
+
ref: image_input_ref,
|
|
3732
|
+
type: "file",
|
|
3733
|
+
accept: "image/*",
|
|
3734
|
+
className: "hidden",
|
|
3735
|
+
onChange: handle_image_insert
|
|
3736
|
+
}
|
|
3737
|
+
)
|
|
3738
|
+
]
|
|
3739
|
+
}
|
|
3740
|
+
) });
|
|
3741
|
+
};
|
|
3742
|
+
var get_file_icon = (mime_type, filename) => {
|
|
3743
|
+
if (is_image_file(mime_type)) {
|
|
3744
|
+
return /* @__PURE__ */ jsx(LuImage, { className: "h-4 w-4" });
|
|
3745
|
+
}
|
|
3746
|
+
const ext = get_file_extension(filename);
|
|
3747
|
+
if (["txt", "md", "doc", "docx", "pdf"].includes(ext)) {
|
|
3748
|
+
return /* @__PURE__ */ jsx(LuFileText, { className: "h-4 w-4" });
|
|
3749
|
+
}
|
|
3750
|
+
if (["js", "ts", "jsx", "tsx", "json", "html", "css"].includes(ext)) {
|
|
3751
|
+
return /* @__PURE__ */ jsx(LuFileCode, { className: "h-4 w-4" });
|
|
3752
|
+
}
|
|
3753
|
+
return /* @__PURE__ */ jsx(LuFile, { className: "h-4 w-4" });
|
|
3754
|
+
};
|
|
3755
|
+
var get_base64_size = (base64) => {
|
|
3756
|
+
const padding = (base64.match(/=+$/) || [""])[0].length;
|
|
3757
|
+
return Math.floor(base64.length * 3 / 4) - padding;
|
|
3758
|
+
};
|
|
3759
|
+
var AttachmentsList = ({
|
|
3760
|
+
attachments,
|
|
3761
|
+
on_remove,
|
|
3762
|
+
disabled = false
|
|
3763
|
+
}) => {
|
|
3764
|
+
if (attachments.length === 0) {
|
|
3765
|
+
return null;
|
|
3766
|
+
}
|
|
3767
|
+
return /* @__PURE__ */ jsx(
|
|
3768
|
+
"div",
|
|
3769
|
+
{
|
|
3770
|
+
className: cn(
|
|
3771
|
+
"cls_rte_attachments",
|
|
3772
|
+
"flex flex-wrap gap-2 p-2",
|
|
3773
|
+
"border-t border-border bg-muted/50 rounded-b-md"
|
|
3774
|
+
),
|
|
3775
|
+
children: attachments.map((attachment, index) => {
|
|
3776
|
+
const size = get_base64_size(attachment.data);
|
|
3777
|
+
const is_image = is_image_file(attachment.mime_type);
|
|
3778
|
+
return /* @__PURE__ */ jsxs(
|
|
3779
|
+
"div",
|
|
3780
|
+
{
|
|
3781
|
+
className: cn(
|
|
3782
|
+
"cls_rte_attachment_item",
|
|
3783
|
+
"flex items-center gap-2",
|
|
3784
|
+
"px-2 py-1.5 rounded-md",
|
|
3785
|
+
"bg-background border border-border",
|
|
3786
|
+
"text-xs"
|
|
3787
|
+
),
|
|
3788
|
+
children: [
|
|
3789
|
+
is_image ? /* @__PURE__ */ jsx(
|
|
3790
|
+
"img",
|
|
3791
|
+
{
|
|
3792
|
+
src: `data:${attachment.mime_type};base64,${attachment.data}`,
|
|
3793
|
+
alt: attachment.filename,
|
|
3794
|
+
className: "h-8 w-8 rounded object-cover"
|
|
3795
|
+
}
|
|
3796
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded bg-muted", children: get_file_icon(attachment.mime_type, attachment.filename) }),
|
|
3797
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
3798
|
+
/* @__PURE__ */ jsx("span", { className: "truncate max-w-[120px] font-medium", children: attachment.filename }),
|
|
3799
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-[10px]", children: format_file_size(size) })
|
|
3800
|
+
] }),
|
|
3801
|
+
/* @__PURE__ */ jsx(
|
|
3802
|
+
Button,
|
|
3803
|
+
{
|
|
3804
|
+
variant: "ghost",
|
|
3805
|
+
size: "icon",
|
|
3806
|
+
className: "h-5 w-5 ml-1",
|
|
3807
|
+
onClick: () => on_remove(index),
|
|
3808
|
+
disabled,
|
|
3809
|
+
children: /* @__PURE__ */ jsx(LuX, { className: "h-3 w-3" })
|
|
3810
|
+
}
|
|
3811
|
+
)
|
|
3812
|
+
]
|
|
3813
|
+
},
|
|
3814
|
+
`${attachment.filename}-${index}`
|
|
3815
|
+
);
|
|
3816
|
+
})
|
|
3817
|
+
}
|
|
3818
|
+
);
|
|
3819
|
+
};
|
|
3820
|
+
var FontSizeExtension = Extension.create({
|
|
3821
|
+
name: "fontSizeCustom",
|
|
3822
|
+
addOptions() {
|
|
3823
|
+
return {
|
|
3824
|
+
types: ["textStyle"],
|
|
3825
|
+
default_size: 16,
|
|
3826
|
+
min_size: 8,
|
|
3827
|
+
max_size: 72,
|
|
3828
|
+
step: 2
|
|
3829
|
+
};
|
|
3830
|
+
},
|
|
3831
|
+
addGlobalAttributes() {
|
|
3832
|
+
return [
|
|
3833
|
+
{
|
|
3834
|
+
types: this.options.types,
|
|
3835
|
+
attributes: {
|
|
3836
|
+
fontSize: {
|
|
3837
|
+
default: null,
|
|
3838
|
+
parseHTML: (element) => {
|
|
3839
|
+
const size = element.style.fontSize?.replace(/['"px]/g, "");
|
|
3840
|
+
return size ? parseInt(size, 10) : null;
|
|
3841
|
+
},
|
|
3842
|
+
renderHTML: (attributes) => {
|
|
3843
|
+
if (!attributes.fontSize) {
|
|
3844
|
+
return {};
|
|
3845
|
+
}
|
|
3846
|
+
return {
|
|
3847
|
+
style: `font-size: ${attributes.fontSize}px`
|
|
3848
|
+
};
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
];
|
|
3854
|
+
},
|
|
3855
|
+
addCommands() {
|
|
3856
|
+
return {
|
|
3857
|
+
setFontSizeNum: (size) => ({ chain }) => {
|
|
3858
|
+
const clampedSize = Math.min(
|
|
3859
|
+
this.options.max_size,
|
|
3860
|
+
Math.max(this.options.min_size, size)
|
|
3861
|
+
);
|
|
3862
|
+
return chain().setMark("textStyle", { fontSize: clampedSize }).run();
|
|
3863
|
+
},
|
|
3864
|
+
unsetFontSizeNum: () => ({ chain }) => {
|
|
3865
|
+
return chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run();
|
|
3866
|
+
}
|
|
3867
|
+
};
|
|
3868
|
+
}
|
|
3869
|
+
});
|
|
3870
|
+
var VariablePill = ({ node, selected }) => {
|
|
3871
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { as: "span", className: "inline", children: /* @__PURE__ */ jsx(
|
|
3872
|
+
"span",
|
|
3873
|
+
{
|
|
3874
|
+
className: cn(
|
|
3875
|
+
"cls_rte_variable_pill",
|
|
3876
|
+
"inline-flex items-center",
|
|
3877
|
+
"px-2 py-0.5 mx-0.5",
|
|
3878
|
+
"rounded-full",
|
|
3879
|
+
"text-sm font-medium",
|
|
3880
|
+
"bg-primary/10 text-primary",
|
|
3881
|
+
"border border-primary/20",
|
|
3882
|
+
"cursor-default select-none",
|
|
3883
|
+
selected && "ring-2 ring-primary ring-offset-1"
|
|
3884
|
+
),
|
|
3885
|
+
contentEditable: false,
|
|
3886
|
+
"data-variable": node.attrs.name,
|
|
3887
|
+
children: `{{${node.attrs.name}}}`
|
|
3888
|
+
}
|
|
3889
|
+
) });
|
|
3890
|
+
};
|
|
3891
|
+
var VariableExtension = Node.create({
|
|
3892
|
+
name: "variable",
|
|
3893
|
+
group: "inline",
|
|
3894
|
+
inline: true,
|
|
3895
|
+
// Atomic means the node cannot be split or merged
|
|
3896
|
+
atom: true,
|
|
3897
|
+
// Draggable in the editor
|
|
3898
|
+
draggable: true,
|
|
3899
|
+
// Selectable as a whole unit
|
|
3900
|
+
selectable: true,
|
|
3901
|
+
addAttributes() {
|
|
3902
|
+
return {
|
|
3903
|
+
name: {
|
|
3904
|
+
default: null,
|
|
3905
|
+
parseHTML: (element) => element.getAttribute("data-variable"),
|
|
3906
|
+
renderHTML: (attributes) => ({
|
|
3907
|
+
"data-variable": attributes.name
|
|
3908
|
+
})
|
|
3909
|
+
}
|
|
3910
|
+
};
|
|
3911
|
+
},
|
|
3912
|
+
parseHTML() {
|
|
3913
|
+
return [
|
|
3914
|
+
{
|
|
3915
|
+
tag: "span[data-variable]"
|
|
3916
|
+
}
|
|
3917
|
+
];
|
|
3918
|
+
},
|
|
3919
|
+
renderHTML({ HTMLAttributes }) {
|
|
3920
|
+
return [
|
|
3921
|
+
"span",
|
|
3922
|
+
mergeAttributes(HTMLAttributes, {
|
|
3923
|
+
class: "cls_rte_variable_pill",
|
|
3924
|
+
contenteditable: "false"
|
|
3925
|
+
}),
|
|
3926
|
+
`{{${HTMLAttributes["data-variable"]}}}`
|
|
3927
|
+
];
|
|
3928
|
+
},
|
|
3929
|
+
renderText({ node }) {
|
|
3930
|
+
return `{{${node.attrs.name}}}`;
|
|
3931
|
+
},
|
|
3932
|
+
addNodeView() {
|
|
3933
|
+
return ReactNodeViewRenderer(VariablePill);
|
|
3934
|
+
},
|
|
3935
|
+
addCommands() {
|
|
3936
|
+
return {
|
|
3937
|
+
insertVariable: (name) => ({ commands }) => {
|
|
3938
|
+
return commands.insertContent({
|
|
3939
|
+
type: this.name,
|
|
3940
|
+
attrs: { name }
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3943
|
+
};
|
|
3944
|
+
},
|
|
3945
|
+
// Keyboard behavior - delete entire node on backspace
|
|
3946
|
+
addKeyboardShortcuts() {
|
|
3947
|
+
return {
|
|
3948
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
3949
|
+
let is_variable = false;
|
|
3950
|
+
const { selection } = state;
|
|
3951
|
+
const { empty, anchor } = selection;
|
|
3952
|
+
if (!empty) {
|
|
3953
|
+
return false;
|
|
3954
|
+
}
|
|
3955
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
3956
|
+
if (node.type.name === this.name) {
|
|
3957
|
+
is_variable = true;
|
|
3958
|
+
tr.insertText("", pos, pos + node.nodeSize);
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3961
|
+
});
|
|
3962
|
+
return is_variable;
|
|
3963
|
+
})
|
|
3964
|
+
};
|
|
3965
|
+
}
|
|
3966
|
+
});
|
|
3967
|
+
var Tabs = TabsPrimitive.Root;
|
|
3968
|
+
var TabsList = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3969
|
+
TabsPrimitive.List,
|
|
3970
|
+
{
|
|
3971
|
+
ref,
|
|
3972
|
+
className: cn(
|
|
3973
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
3974
|
+
className
|
|
3975
|
+
),
|
|
3976
|
+
...props
|
|
3977
|
+
}
|
|
3978
|
+
));
|
|
3979
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
3980
|
+
var TabsTrigger = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3981
|
+
TabsPrimitive.Trigger,
|
|
3982
|
+
{
|
|
3983
|
+
ref,
|
|
3984
|
+
className: cn(
|
|
3985
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
3986
|
+
className
|
|
3987
|
+
),
|
|
3988
|
+
...props
|
|
3989
|
+
}
|
|
3990
|
+
));
|
|
3991
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
3992
|
+
var TabsContent = React23.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
3993
|
+
TabsPrimitive.Content,
|
|
3994
|
+
{
|
|
3995
|
+
ref,
|
|
3996
|
+
className: cn(
|
|
3997
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
3998
|
+
className
|
|
3999
|
+
),
|
|
4000
|
+
...props
|
|
4001
|
+
}
|
|
4002
|
+
));
|
|
4003
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
4004
|
+
function debounce_fn(func, wait) {
|
|
4005
|
+
let timeout_id = null;
|
|
4006
|
+
return (output) => {
|
|
4007
|
+
if (timeout_id) {
|
|
4008
|
+
clearTimeout(timeout_id);
|
|
4009
|
+
}
|
|
4010
|
+
timeout_id = setTimeout(() => {
|
|
4011
|
+
func(output);
|
|
4012
|
+
}, wait);
|
|
4013
|
+
};
|
|
4014
|
+
}
|
|
4015
|
+
var HazoUiRte = ({
|
|
4016
|
+
html = "",
|
|
4017
|
+
attachments: initial_attachments = [],
|
|
4018
|
+
variables = [],
|
|
4019
|
+
on_change,
|
|
4020
|
+
placeholder = "Start typing...",
|
|
4021
|
+
min_height = "200px",
|
|
4022
|
+
max_height = "400px",
|
|
4023
|
+
disabled = false,
|
|
4024
|
+
className,
|
|
4025
|
+
show_output_viewer = false
|
|
4026
|
+
}) => {
|
|
4027
|
+
const [attachments, set_attachments] = React23.useState(
|
|
4028
|
+
initial_attachments
|
|
4029
|
+
);
|
|
4030
|
+
const [active_tab, set_active_tab] = React23.useState("html");
|
|
4031
|
+
const is_view_only = active_tab !== "html";
|
|
4032
|
+
const attachments_ref = React23.useRef(attachments);
|
|
4033
|
+
attachments_ref.current = attachments;
|
|
4034
|
+
const debounced_on_change = React23.useMemo(
|
|
4035
|
+
() => debounce_fn((output) => {
|
|
4036
|
+
if (on_change) {
|
|
4037
|
+
on_change(output);
|
|
4038
|
+
}
|
|
4039
|
+
}, 300),
|
|
4040
|
+
[on_change]
|
|
4041
|
+
);
|
|
4042
|
+
const editor = useEditor({
|
|
4043
|
+
extensions: [
|
|
4044
|
+
StarterKit.configure({
|
|
4045
|
+
heading: {
|
|
4046
|
+
levels: [1, 2, 3]
|
|
4047
|
+
}
|
|
4048
|
+
}),
|
|
4049
|
+
TextStyle,
|
|
4050
|
+
FontFamily,
|
|
4051
|
+
FontSizeExtension,
|
|
4052
|
+
Underline,
|
|
4053
|
+
Subscript,
|
|
4054
|
+
Superscript,
|
|
4055
|
+
Link.configure({
|
|
4056
|
+
openOnClick: false,
|
|
4057
|
+
HTMLAttributes: {
|
|
4058
|
+
class: "cls_rte_link text-primary underline cursor-pointer"
|
|
4059
|
+
}
|
|
4060
|
+
}),
|
|
4061
|
+
TextAlign.configure({
|
|
4062
|
+
types: ["heading", "paragraph"]
|
|
4063
|
+
}),
|
|
4064
|
+
Highlight.configure({
|
|
4065
|
+
multicolor: true
|
|
4066
|
+
}),
|
|
4067
|
+
Color,
|
|
4068
|
+
Image.configure({
|
|
4069
|
+
inline: true,
|
|
4070
|
+
allowBase64: true,
|
|
4071
|
+
HTMLAttributes: {
|
|
4072
|
+
class: "cls_rte_image max-w-full h-auto rounded"
|
|
4073
|
+
}
|
|
4074
|
+
}),
|
|
4075
|
+
Placeholder.configure({
|
|
4076
|
+
placeholder
|
|
4077
|
+
}),
|
|
4078
|
+
HorizontalRule,
|
|
4079
|
+
Table.configure({
|
|
4080
|
+
resizable: true,
|
|
4081
|
+
HTMLAttributes: {
|
|
4082
|
+
class: "cls_rte_table border-collapse w-full"
|
|
4083
|
+
}
|
|
4084
|
+
}),
|
|
4085
|
+
TableRow,
|
|
4086
|
+
TableCell.configure({
|
|
4087
|
+
HTMLAttributes: {
|
|
4088
|
+
class: "border border-border p-2"
|
|
4089
|
+
}
|
|
4090
|
+
}),
|
|
4091
|
+
TableHeader.configure({
|
|
4092
|
+
HTMLAttributes: {
|
|
4093
|
+
class: "border border-border p-2 bg-muted font-semibold"
|
|
4094
|
+
}
|
|
4095
|
+
}),
|
|
4096
|
+
TaskList.configure({
|
|
4097
|
+
HTMLAttributes: {
|
|
4098
|
+
class: "cls_rte_task_list list-none pl-0"
|
|
4099
|
+
}
|
|
4100
|
+
}),
|
|
4101
|
+
TaskItem.configure({
|
|
4102
|
+
nested: true,
|
|
4103
|
+
HTMLAttributes: {
|
|
4104
|
+
class: "cls_rte_task_item flex items-start gap-2"
|
|
4105
|
+
}
|
|
4106
|
+
}),
|
|
4107
|
+
VariableExtension
|
|
4108
|
+
],
|
|
4109
|
+
content: html,
|
|
4110
|
+
editable: !disabled,
|
|
4111
|
+
editorProps: {
|
|
4112
|
+
attributes: {
|
|
4113
|
+
class: cn(
|
|
4114
|
+
"cls_rte_editor",
|
|
4115
|
+
"prose prose-sm dark:prose-invert max-w-none",
|
|
4116
|
+
"p-4 focus:outline-none",
|
|
4117
|
+
"min-h-[inherit] overflow-auto"
|
|
4118
|
+
),
|
|
4119
|
+
style: `min-height: ${min_height}; max-height: ${max_height}`
|
|
4120
|
+
}
|
|
4121
|
+
},
|
|
4122
|
+
onUpdate: ({ editor: editor2 }) => {
|
|
4123
|
+
const output = {
|
|
4124
|
+
html: editor2.getHTML(),
|
|
4125
|
+
plain_text: editor2.getText(),
|
|
4126
|
+
attachments: attachments_ref.current
|
|
4127
|
+
};
|
|
4128
|
+
debounced_on_change(output);
|
|
4129
|
+
}
|
|
4130
|
+
});
|
|
4131
|
+
React23.useEffect(() => {
|
|
4132
|
+
if (editor && html !== void 0) {
|
|
4133
|
+
const current_html = editor.getHTML();
|
|
4134
|
+
if (html !== current_html && !editor.isFocused) {
|
|
4135
|
+
editor.commands.setContent(html, { emitUpdate: false });
|
|
4136
|
+
}
|
|
4137
|
+
}
|
|
4138
|
+
}, [html, editor]);
|
|
4139
|
+
React23.useEffect(() => {
|
|
4140
|
+
if (editor) {
|
|
4141
|
+
editor.setEditable(!disabled);
|
|
4142
|
+
}
|
|
4143
|
+
}, [disabled, editor]);
|
|
4144
|
+
const attachments_from_props_ref = React23.useRef(false);
|
|
4145
|
+
const prev_initial_attachments_ref = React23.useRef(initial_attachments);
|
|
4146
|
+
React23.useEffect(() => {
|
|
4147
|
+
if (JSON.stringify(initial_attachments) !== JSON.stringify(prev_initial_attachments_ref.current)) {
|
|
4148
|
+
prev_initial_attachments_ref.current = initial_attachments;
|
|
4149
|
+
attachments_from_props_ref.current = true;
|
|
4150
|
+
set_attachments(initial_attachments);
|
|
4151
|
+
}
|
|
4152
|
+
}, [initial_attachments]);
|
|
4153
|
+
React23.useEffect(() => {
|
|
4154
|
+
if (attachments_from_props_ref.current) {
|
|
4155
|
+
attachments_from_props_ref.current = false;
|
|
4156
|
+
return;
|
|
4157
|
+
}
|
|
4158
|
+
if (editor && on_change) {
|
|
4159
|
+
const output = {
|
|
4160
|
+
html: editor.getHTML(),
|
|
4161
|
+
plain_text: editor.getText(),
|
|
4162
|
+
attachments
|
|
4163
|
+
};
|
|
4164
|
+
on_change(output);
|
|
4165
|
+
}
|
|
4166
|
+
}, [attachments]);
|
|
4167
|
+
const handle_remove_attachment = (index) => {
|
|
4168
|
+
set_attachments((prev) => prev.filter((_, i) => i !== index));
|
|
4169
|
+
};
|
|
4170
|
+
const handle_attachments_change = (new_attachments) => {
|
|
4171
|
+
set_attachments(new_attachments);
|
|
4172
|
+
};
|
|
4173
|
+
const format_html = (html_str) => {
|
|
4174
|
+
let formatted = "";
|
|
4175
|
+
let indent = 0;
|
|
4176
|
+
const tags = html_str.split(/(<[^>]+>)/g).filter(Boolean);
|
|
4177
|
+
for (const tag of tags) {
|
|
4178
|
+
if (tag.startsWith("</")) {
|
|
4179
|
+
indent = Math.max(0, indent - 1);
|
|
4180
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4181
|
+
} else if (tag.startsWith("<") && !tag.startsWith("<!") && !tag.endsWith("/>")) {
|
|
4182
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4183
|
+
if (!tag.includes("br") && !tag.includes("hr") && !tag.includes("img")) {
|
|
4184
|
+
indent++;
|
|
4185
|
+
}
|
|
4186
|
+
} else if (tag.startsWith("<")) {
|
|
4187
|
+
formatted += " ".repeat(indent) + tag + "\n";
|
|
4188
|
+
} else if (tag.trim()) {
|
|
4189
|
+
formatted += " ".repeat(indent) + tag.trim() + "\n";
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
return formatted.trim();
|
|
4193
|
+
};
|
|
4194
|
+
return /* @__PURE__ */ jsxs(
|
|
4195
|
+
"div",
|
|
4196
|
+
{
|
|
4197
|
+
className: cn(
|
|
4198
|
+
"cls_rte_container",
|
|
4199
|
+
"rounded-md border border-input bg-background",
|
|
4200
|
+
"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
4201
|
+
disabled && "opacity-50 cursor-not-allowed",
|
|
4202
|
+
className
|
|
4203
|
+
),
|
|
4204
|
+
children: [
|
|
4205
|
+
/* @__PURE__ */ jsx(
|
|
4206
|
+
Toolbar,
|
|
4207
|
+
{
|
|
4208
|
+
editor,
|
|
4209
|
+
variables,
|
|
4210
|
+
attachments,
|
|
4211
|
+
on_attachments_change: handle_attachments_change,
|
|
4212
|
+
disabled: disabled || is_view_only
|
|
4213
|
+
}
|
|
4214
|
+
),
|
|
4215
|
+
show_output_viewer && editor && /* @__PURE__ */ jsx("div", { className: "cls_rte_tabs border-b border-border px-2 pt-2", children: /* @__PURE__ */ jsx(Tabs, { value: active_tab, onValueChange: (v) => set_active_tab(v), children: /* @__PURE__ */ jsxs(TabsList, { className: "h-9", children: [
|
|
4216
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "html", className: "text-sm", children: "HTML" }),
|
|
4217
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "plain_text", className: "text-sm", children: "Plain Text" }),
|
|
4218
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "raw_html", className: "text-sm", children: "Raw HTML" })
|
|
4219
|
+
] }) }) }),
|
|
4220
|
+
/* @__PURE__ */ jsxs("div", { style: { minHeight: min_height, maxHeight: max_height }, className: "overflow-auto", children: [
|
|
4221
|
+
active_tab === "html" && /* @__PURE__ */ jsx(
|
|
4222
|
+
EditorContent,
|
|
4223
|
+
{
|
|
4224
|
+
editor,
|
|
4225
|
+
className: cn(
|
|
4226
|
+
"cls_rte_content",
|
|
4227
|
+
disabled && "pointer-events-none"
|
|
4228
|
+
)
|
|
4229
|
+
}
|
|
4230
|
+
),
|
|
4231
|
+
active_tab === "plain_text" && /* @__PURE__ */ jsx("pre", { className: "cls_rte_plain_text p-4 text-sm whitespace-pre-wrap font-mono h-full", children: editor?.getText() || "(empty)" }),
|
|
4232
|
+
active_tab === "raw_html" && /* @__PURE__ */ jsx("pre", { className: "cls_rte_raw_html p-4 text-xs whitespace-pre-wrap font-mono text-muted-foreground h-full", children: format_html(editor?.getHTML() || "") || "(empty)" })
|
|
4233
|
+
] }),
|
|
4234
|
+
/* @__PURE__ */ jsx(
|
|
4235
|
+
AttachmentsList,
|
|
4236
|
+
{
|
|
4237
|
+
attachments,
|
|
4238
|
+
on_remove: handle_remove_attachment,
|
|
4239
|
+
disabled
|
|
4240
|
+
}
|
|
4241
|
+
)
|
|
4242
|
+
]
|
|
4243
|
+
}
|
|
4244
|
+
);
|
|
4245
|
+
};
|
|
4246
|
+
HazoUiRte.displayName = "HazoUiRte";
|
|
1632
4247
|
|
|
1633
|
-
export {
|
|
4248
|
+
export { HazoUiFlexInput, HazoUiFlexRadio, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiRte };
|
|
1634
4249
|
//# sourceMappingURL=index.js.map
|
|
1635
4250
|
//# sourceMappingURL=index.js.map
|