@npm-questionpro/wick-ui-editor 0.11.0 → 0.12.1
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 +16 -14
- package/dist/index.d.ts +3 -3
- package/dist/wick-ui-editor/es/index.js +272 -274
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @npm-questionpro/wick-ui-editor
|
|
2
2
|
|
|
3
|
-
A rich text editor component built with React and TipTap. Part of the Wick UI
|
|
3
|
+
A rich text editor component built with React and TipTap. Part of the Wick UI
|
|
4
|
+
design system.
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/@npm-questionpro/wick-ui-editor)
|
|
6
7
|
[](https://opensource.org/licenses/ISC)
|
|
@@ -37,22 +38,23 @@ function App() {
|
|
|
37
38
|
|
|
38
39
|
## Props
|
|
39
40
|
|
|
40
|
-
| Prop
|
|
41
|
-
|
|
|
42
|
-
| `defaultValue`
|
|
43
|
-
| `onUpdate`
|
|
44
|
-
| `readonly`
|
|
45
|
-
| `renderHtml`
|
|
46
|
-
| `toolbarPosition`
|
|
47
|
-
| `toolbarItems`
|
|
48
|
-
| `hideToolbar`
|
|
49
|
-
| `customFonts`
|
|
50
|
-
| `customToolbarChildren` | `ReactNode`
|
|
51
|
-
| `className`
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
| ----------------------- | ------------------------ | ----------- | ------------------------------------- |
|
|
43
|
+
| `defaultValue` | `string` | `undefined` | Initial HTML content (auto-sanitized) |
|
|
44
|
+
| `onUpdate` | `(html: string) => void` | `undefined` | Fires when content changes |
|
|
45
|
+
| `readonly` | `boolean` | `false` | Disable editing |
|
|
46
|
+
| `renderHtml` | `boolean` | `false` | Render raw HTML in read-only mode |
|
|
47
|
+
| `toolbarPosition` | `'top' \| 'bottom'` | `'top'` | Toolbar placement |
|
|
48
|
+
| `toolbarItems` | `IToolbarExtensionKey[]` | all | Toolbar buttons to show |
|
|
49
|
+
| `hideToolbar` | `boolean` | `false` | Hide the toolbar |
|
|
50
|
+
| `customFonts` | `string[]` | `undefined` | Extra font families in font picker |
|
|
51
|
+
| `customToolbarChildren` | `ReactNode` | `undefined` | Custom elements appended to toolbar |
|
|
52
|
+
| `className` | `string` | `undefined` | Class on the root container |
|
|
52
53
|
|
|
53
54
|
## Documentation
|
|
54
55
|
|
|
55
|
-
Full documentation and interactive examples:
|
|
56
|
+
Full documentation and interactive examples:
|
|
57
|
+
[wick-ui-lib.pages.dev](https://wick-ui-lib.pages.dev)
|
|
56
58
|
|
|
57
59
|
## License
|
|
58
60
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ export declare interface IWuContentEditorProps extends default_2.HTMLAttributes<
|
|
|
7
7
|
defaultValue?: string;
|
|
8
8
|
onUpdate?: (content: string) => void;
|
|
9
9
|
customFonts?: string[];
|
|
10
|
-
readonly?: boolean;
|
|
11
10
|
toolbarPosition?: 'top' | 'bottom';
|
|
12
11
|
customToolbarChildren?: default_2.ReactNode;
|
|
13
12
|
toolbarItems?: IToolbarExtensionKey[];
|
|
14
13
|
hideToolbar?: boolean;
|
|
15
|
-
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
renderDefaultOnly?: boolean;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
declare const TOOLBAR_EXTENSIONS: {
|
|
@@ -38,6 +38,6 @@ declare const TOOLBAR_EXTENSIONS: {
|
|
|
38
38
|
'|': JSX.Element;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export declare function WuContentEditor({ defaultValue, onUpdate, className,
|
|
41
|
+
export declare function WuContentEditor({ defaultValue, onUpdate, className, toolbarPosition, customToolbarChildren, toolbarItems, hideToolbar, readonly, customFonts, renderDefaultOnly, ...props }: IWuContentEditorProps): default_2.JSX.Element;
|
|
42
42
|
|
|
43
43
|
export { }
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { useEditorState as
|
|
3
|
-
import
|
|
4
|
-
import C, { useState as E, useRef as
|
|
5
|
-
import
|
|
6
|
-
import { TaskList as
|
|
1
|
+
import { jsx as o, jsxs as g, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import { useEditorState as f, useEditor as q, EditorContent as $ } from "@tiptap/react";
|
|
3
|
+
import D from "clsx";
|
|
4
|
+
import C, { useState as E, useRef as j, useCallback as _ } from "react";
|
|
5
|
+
import K from "@tiptap/extension-image";
|
|
6
|
+
import { TaskList as J, TaskItem as V } from "@tiptap/extension-list";
|
|
7
7
|
import G from "@tiptap/extension-subscript";
|
|
8
|
-
import
|
|
9
|
-
import { TableKit as
|
|
10
|
-
import
|
|
11
|
-
import { TextStyle as
|
|
12
|
-
import
|
|
13
|
-
import { WuIcon as h, WuModal as y, WuModalHeader as T, WuModalContent as S, WuInput as k, WuModalFooter as x, WuModalClose as
|
|
14
|
-
import { DropdownMenu as
|
|
15
|
-
import
|
|
16
|
-
const
|
|
17
|
-
wuContentEditor:
|
|
18
|
-
wuContentEditorTable:
|
|
19
|
-
wuContentEditorContainer:
|
|
20
|
-
wuContentEditorToolbar:
|
|
21
|
-
wuContentEditorAction:
|
|
22
|
-
wuContentEditorDropdown:
|
|
8
|
+
import X from "@tiptap/extension-superscript";
|
|
9
|
+
import { TableKit as Y } from "@tiptap/extension-table";
|
|
10
|
+
import Z from "@tiptap/extension-text-align";
|
|
11
|
+
import { TextStyle as Q, Color as tt, BackgroundColor as et, LineHeight as ot, FontSize as nt, FontFamily as it } from "@tiptap/extension-text-style";
|
|
12
|
+
import rt from "@tiptap/starter-kit";
|
|
13
|
+
import { WuIcon as h, WuModal as y, WuModalHeader as T, WuModalContent as S, WuInput as k, WuModalFooter as x, WuModalClose as b, WuToggle as st, WuButton as ct } from "@npm-questionpro/wick-ui-lib";
|
|
14
|
+
import { DropdownMenu as M, DropdownMenuTrigger as H, DropdownMenuContent as z, DropdownMenuItem as B } from "@radix-ui/react-dropdown-menu";
|
|
15
|
+
import lt from "dompurify";
|
|
16
|
+
const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut = "_wuContentEditorContainer_399u0_8", mt = "_wuContentEditorToolbar_399u0_80", ht = "_wuContentEditorAction_399u0_106", ft = "_wuContentEditorDropdown_399u0_132", gt = "_wuContentEditorDropdownItem_399u0_145", pt = "_wuContentEditorFontSize_399u0_156", wt = "_wuContentEditorModal_399u0_170", d = {
|
|
17
|
+
wuContentEditor: at,
|
|
18
|
+
wuContentEditorTable: dt,
|
|
19
|
+
wuContentEditorContainer: ut,
|
|
20
|
+
wuContentEditorToolbar: mt,
|
|
21
|
+
wuContentEditorAction: ht,
|
|
22
|
+
wuContentEditorDropdown: ft,
|
|
23
23
|
wuContentEditorDropdownItem: gt,
|
|
24
24
|
wuContentEditorFontSize: pt,
|
|
25
|
-
wuContentEditorModal:
|
|
26
|
-
},
|
|
27
|
-
|
|
25
|
+
wuContentEditorModal: wt
|
|
26
|
+
}, Ct = [
|
|
27
|
+
rt.configure({
|
|
28
28
|
link: {
|
|
29
29
|
openOnClick: !1,
|
|
30
30
|
autolink: !0,
|
|
@@ -35,16 +35,16 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
35
35
|
const e = t.includes(":") ? new URL(t) : new URL(`${n.defaultProtocol}://${t}`);
|
|
36
36
|
if (!n.defaultValidate(e.href))
|
|
37
37
|
return !1;
|
|
38
|
-
const i = ["ftp", "file", "mailto"],
|
|
39
|
-
if (i.includes(
|
|
38
|
+
const i = ["ftp", "file", "mailto"], l = e.protocol.replace(":", "");
|
|
39
|
+
if (i.includes(l) || !n.protocols.map(
|
|
40
40
|
(r) => typeof r == "string" ? r : r.scheme
|
|
41
|
-
).includes(
|
|
41
|
+
).includes(l))
|
|
42
42
|
return !1;
|
|
43
43
|
const a = [
|
|
44
44
|
"example-phishing.com",
|
|
45
45
|
"malicious-site.net"
|
|
46
|
-
],
|
|
47
|
-
return !a.includes(
|
|
46
|
+
], s = e.hostname;
|
|
47
|
+
return !a.includes(s);
|
|
48
48
|
} catch {
|
|
49
49
|
return !1;
|
|
50
50
|
}
|
|
@@ -62,52 +62,52 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}),
|
|
65
|
-
|
|
65
|
+
Z.configure({
|
|
66
66
|
types: ["heading", "paragraph"]
|
|
67
67
|
}),
|
|
68
|
-
|
|
68
|
+
X,
|
|
69
69
|
G,
|
|
70
|
-
Z,
|
|
71
70
|
Q,
|
|
72
71
|
tt,
|
|
73
|
-
K,
|
|
74
|
-
J,
|
|
75
72
|
et,
|
|
73
|
+
J,
|
|
74
|
+
V,
|
|
76
75
|
ot,
|
|
77
76
|
nt,
|
|
78
|
-
|
|
77
|
+
it,
|
|
78
|
+
K.configure({
|
|
79
79
|
resize: {
|
|
80
80
|
enabled: !0,
|
|
81
81
|
alwaysPreserveAspectRatio: !0
|
|
82
82
|
},
|
|
83
83
|
inline: !0
|
|
84
84
|
}),
|
|
85
|
-
|
|
85
|
+
Y.configure({
|
|
86
86
|
table: { resizable: !0 }
|
|
87
87
|
})
|
|
88
|
-
],
|
|
88
|
+
], O = C.createContext(
|
|
89
89
|
null
|
|
90
|
-
),
|
|
90
|
+
), vt = ({
|
|
91
91
|
editor: t,
|
|
92
92
|
children: n,
|
|
93
93
|
customFonts: e
|
|
94
|
-
}) => /* @__PURE__ */ o(
|
|
95
|
-
const t = C.useContext(
|
|
94
|
+
}) => /* @__PURE__ */ o(O.Provider, { value: { editor: t, customFonts: e }, children: n }), m = () => {
|
|
95
|
+
const t = C.useContext(O);
|
|
96
96
|
if (!t)
|
|
97
97
|
throw new Error("useToolbar must be used within a ToolbarProvider");
|
|
98
98
|
return t;
|
|
99
99
|
}, L = ({ action: t, defaultValue: n }) => {
|
|
100
|
-
var
|
|
100
|
+
var l;
|
|
101
101
|
const [e, i] = C.useState(
|
|
102
|
-
n || t.items.find((
|
|
102
|
+
n || t.items.find((c) => c.active) || t.items[0]
|
|
103
103
|
);
|
|
104
104
|
return C.useEffect(() => {
|
|
105
105
|
i(
|
|
106
|
-
n || t.items.find((
|
|
106
|
+
n || t.items.find((c) => c.active) || t.items[0]
|
|
107
107
|
);
|
|
108
|
-
}, [t, n]), /* @__PURE__ */
|
|
108
|
+
}, [t, n]), /* @__PURE__ */ g(M, { children: [
|
|
109
109
|
/* @__PURE__ */ o(
|
|
110
|
-
|
|
110
|
+
H,
|
|
111
111
|
{
|
|
112
112
|
className: d.wuContentEditorAction,
|
|
113
113
|
"data-active": t.active,
|
|
@@ -118,41 +118,41 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
118
118
|
z,
|
|
119
119
|
{
|
|
120
120
|
align: "start",
|
|
121
|
-
onCloseAutoFocus: (
|
|
121
|
+
onCloseAutoFocus: (c) => c.preventDefault(),
|
|
122
122
|
className: d.wuContentEditorDropdown,
|
|
123
123
|
"data-inline": !0,
|
|
124
|
-
children: (
|
|
125
|
-
|
|
124
|
+
children: (l = t.items) == null ? void 0 : l.map((c) => /* @__PURE__ */ o(
|
|
125
|
+
B,
|
|
126
126
|
{
|
|
127
127
|
onClick: () => {
|
|
128
|
-
|
|
128
|
+
c.event(), i(c);
|
|
129
129
|
},
|
|
130
|
-
title:
|
|
130
|
+
title: c.tooltip,
|
|
131
131
|
children: /* @__PURE__ */ o(
|
|
132
132
|
"button",
|
|
133
133
|
{
|
|
134
134
|
className: d.wuContentEditorAction,
|
|
135
|
-
"data-active":
|
|
136
|
-
children: /* @__PURE__ */ o(h, { icon:
|
|
135
|
+
"data-active": c.active,
|
|
136
|
+
children: /* @__PURE__ */ o(h, { icon: c.icon })
|
|
137
137
|
}
|
|
138
138
|
)
|
|
139
139
|
},
|
|
140
|
-
|
|
140
|
+
c.id
|
|
141
141
|
))
|
|
142
142
|
}
|
|
143
143
|
)
|
|
144
144
|
] });
|
|
145
|
-
},
|
|
146
|
-
const { editor: t } = m(), n =
|
|
145
|
+
}, bt = () => {
|
|
146
|
+
const { editor: t } = m(), n = f({
|
|
147
147
|
editor: t,
|
|
148
148
|
selector: (i) => {
|
|
149
|
-
var
|
|
149
|
+
var l, c, a, s, r, u, p;
|
|
150
150
|
return {
|
|
151
|
-
isLeft: (
|
|
152
|
-
isCenter: (
|
|
151
|
+
isLeft: (l = i.editor) == null ? void 0 : l.isActive({ textAlign: "left" }),
|
|
152
|
+
isCenter: (c = i.editor) == null ? void 0 : c.isActive({ textAlign: "center" }),
|
|
153
153
|
isRight: (a = i.editor) == null ? void 0 : a.isActive({ textAlign: "right" }),
|
|
154
|
-
isJustify: (
|
|
155
|
-
isAligned: ((r = i.editor) == null ? void 0 : r.isActive({ textAlign: "center" })) || ((u = i.editor) == null ? void 0 : u.isActive({ textAlign: "right" })) || ((
|
|
154
|
+
isJustify: (s = i.editor) == null ? void 0 : s.isActive({ textAlign: "justify" }),
|
|
155
|
+
isAligned: ((r = i.editor) == null ? void 0 : r.isActive({ textAlign: "center" })) || ((u = i.editor) == null ? void 0 : u.isActive({ textAlign: "right" })) || ((p = i.editor) == null ? void 0 : p.isActive({ textAlign: "justify" }))
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
}), e = [
|
|
@@ -196,14 +196,14 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
|
-
},
|
|
200
|
-
const { editor: t } = m(), n =
|
|
199
|
+
}, At = () => {
|
|
200
|
+
const { editor: t } = m(), n = f({
|
|
201
201
|
editor: t,
|
|
202
202
|
selector: ({ editor: e }) => ({
|
|
203
203
|
bgColor: e.getAttributes("textStyle").backgroundColor
|
|
204
204
|
})
|
|
205
205
|
});
|
|
206
|
-
return /* @__PURE__ */
|
|
206
|
+
return /* @__PURE__ */ g(
|
|
207
207
|
"label",
|
|
208
208
|
{
|
|
209
209
|
className: d.wuContentEditorAction,
|
|
@@ -224,16 +224,16 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
224
224
|
]
|
|
225
225
|
}
|
|
226
226
|
);
|
|
227
|
-
},
|
|
228
|
-
const { editor: t } = m(), n =
|
|
227
|
+
}, kt = () => {
|
|
228
|
+
const { editor: t } = m(), n = f({
|
|
229
229
|
editor: t,
|
|
230
230
|
selector: (i) => {
|
|
231
|
-
var
|
|
231
|
+
var l, c, a, s, r, u;
|
|
232
232
|
return {
|
|
233
|
-
isParagraph: (
|
|
234
|
-
isH1: (
|
|
233
|
+
isParagraph: (l = i.editor) == null ? void 0 : l.isActive("paragraph"),
|
|
234
|
+
isH1: (c = i.editor) == null ? void 0 : c.isActive("heading", { level: 1 }),
|
|
235
235
|
isH2: (a = i.editor) == null ? void 0 : a.isActive("heading", { level: 2 }),
|
|
236
|
-
isH3: (
|
|
236
|
+
isH3: (s = i.editor) == null ? void 0 : s.isActive("heading", { level: 3 }),
|
|
237
237
|
isH4: (r = i.editor) == null ? void 0 : r.isActive("heading", { level: 4 }),
|
|
238
238
|
isStyle: (u = i.editor) == null ? void 0 : u.isActive("heading")
|
|
239
239
|
};
|
|
@@ -282,8 +282,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
282
282
|
defaultValue: e.find((i) => i.active)
|
|
283
283
|
}
|
|
284
284
|
);
|
|
285
|
-
},
|
|
286
|
-
const { editor: t } = m(), n =
|
|
285
|
+
}, Et = () => {
|
|
286
|
+
const { editor: t } = m(), n = f({
|
|
287
287
|
editor: t,
|
|
288
288
|
selector: (e) => {
|
|
289
289
|
var i;
|
|
@@ -304,8 +304,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
304
304
|
children: /* @__PURE__ */ o(h, { icon: "wm-format-quote" })
|
|
305
305
|
}
|
|
306
306
|
);
|
|
307
|
-
},
|
|
308
|
-
const { editor: t } = m(), n =
|
|
307
|
+
}, yt = () => {
|
|
308
|
+
const { editor: t } = m(), n = f({
|
|
309
309
|
editor: t,
|
|
310
310
|
selector: (e) => {
|
|
311
311
|
var i;
|
|
@@ -326,9 +326,9 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
326
326
|
children: /* @__PURE__ */ o(h, { icon: "wm-format-bold" })
|
|
327
327
|
}
|
|
328
328
|
);
|
|
329
|
-
},
|
|
329
|
+
}, Tt = () => {
|
|
330
330
|
const { editor: t } = m();
|
|
331
|
-
return /* @__PURE__ */ o(
|
|
331
|
+
return /* @__PURE__ */ o(R, { children: [
|
|
332
332
|
{
|
|
333
333
|
id: "clear",
|
|
334
334
|
icon: "wm-format-clear",
|
|
@@ -347,8 +347,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
347
347
|
},
|
|
348
348
|
e.id
|
|
349
349
|
)) });
|
|
350
|
-
},
|
|
351
|
-
const { editor: t } = m(), n =
|
|
350
|
+
}, St = () => {
|
|
351
|
+
const { editor: t } = m(), n = f({
|
|
352
352
|
editor: t,
|
|
353
353
|
selector: (e) => ({
|
|
354
354
|
code: e.editor.isActive("code")
|
|
@@ -366,20 +366,20 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
366
366
|
children: /* @__PURE__ */ o(h, { icon: "wm-code" })
|
|
367
367
|
}
|
|
368
368
|
);
|
|
369
|
-
},
|
|
370
|
-
const { editor: t } = m(), n =
|
|
369
|
+
}, xt = () => {
|
|
370
|
+
const { editor: t } = m(), n = f({
|
|
371
371
|
editor: t,
|
|
372
|
-
selector: (
|
|
372
|
+
selector: (s) => {
|
|
373
373
|
var r, u;
|
|
374
374
|
return {
|
|
375
|
-
isImage: (r =
|
|
376
|
-
imageAttrs: (u =
|
|
375
|
+
isImage: (r = s.editor) == null ? void 0 : r.isActive("image"),
|
|
376
|
+
imageAttrs: (u = s.editor) == null ? void 0 : u.getAttributes("image")
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
-
}), [e, i] = C.useState(n.imageAttrs.src || ""), [
|
|
380
|
-
t.chain().focus().setImage({ src: e, alt:
|
|
379
|
+
}), [e, i] = C.useState(n.imageAttrs.src || ""), [l, c] = C.useState(n.imageAttrs.alt || ""), a = () => {
|
|
380
|
+
t.chain().focus().setImage({ src: e, alt: l }).run();
|
|
381
381
|
};
|
|
382
|
-
return /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ g(
|
|
383
383
|
y,
|
|
384
384
|
{
|
|
385
385
|
Trigger: /* @__PURE__ */ o(
|
|
@@ -393,14 +393,14 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
393
393
|
maxWidth: "400px",
|
|
394
394
|
children: [
|
|
395
395
|
/* @__PURE__ */ o(T, { style: { display: "none" } }),
|
|
396
|
-
/* @__PURE__ */
|
|
396
|
+
/* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
|
|
397
397
|
/* @__PURE__ */ o(
|
|
398
398
|
k,
|
|
399
399
|
{
|
|
400
400
|
Label: "Image URL",
|
|
401
401
|
type: "url",
|
|
402
402
|
value: e,
|
|
403
|
-
onChange: (
|
|
403
|
+
onChange: (s) => i(s.target.value),
|
|
404
404
|
required: !0
|
|
405
405
|
}
|
|
406
406
|
),
|
|
@@ -409,45 +409,45 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
409
409
|
{
|
|
410
410
|
Label: "Alt Text",
|
|
411
411
|
type: "text",
|
|
412
|
-
value:
|
|
413
|
-
onChange: (
|
|
412
|
+
value: l,
|
|
413
|
+
onChange: (s) => c(s.target.value)
|
|
414
414
|
}
|
|
415
415
|
)
|
|
416
416
|
] }),
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
/* @__PURE__ */ o(
|
|
419
|
-
/* @__PURE__ */ o(
|
|
417
|
+
/* @__PURE__ */ g(x, { children: [
|
|
418
|
+
/* @__PURE__ */ o(b, { variant: "secondary", children: "Cancel" }),
|
|
419
|
+
/* @__PURE__ */ o(b, { onClick: a, disabled: !e, children: "Save" })
|
|
420
420
|
] })
|
|
421
421
|
]
|
|
422
422
|
}
|
|
423
423
|
);
|
|
424
|
-
},
|
|
425
|
-
const { editor: t } = m(), n =
|
|
424
|
+
}, Lt = () => {
|
|
425
|
+
const { editor: t } = m(), n = f({
|
|
426
426
|
editor: t,
|
|
427
427
|
selector: (r) => {
|
|
428
|
-
var u,
|
|
428
|
+
var u, p;
|
|
429
429
|
return {
|
|
430
430
|
isLink: (u = r.editor) == null ? void 0 : u.isActive("link"),
|
|
431
|
-
linkAttrs: (
|
|
431
|
+
linkAttrs: (p = r.editor) == null ? void 0 : p.getAttributes("link")
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
|
-
}), [e, i] = C.useState(n.linkAttrs.href || ""), [
|
|
434
|
+
}), [e, i] = C.useState(n.linkAttrs.href || ""), [l, c] = C.useState(n.linkAttrs.alt || ""), a = () => {
|
|
435
435
|
t.chain().focus().insertContent({
|
|
436
436
|
type: "text",
|
|
437
|
-
text:
|
|
437
|
+
text: l || e,
|
|
438
438
|
marks: [{ type: "link", attrs: { href: e } }]
|
|
439
439
|
}).run();
|
|
440
|
-
},
|
|
441
|
-
const { $from: r } = t.state.selection, u = r.parent.textContent,
|
|
442
|
-
let
|
|
443
|
-
for (;
|
|
444
|
-
|
|
445
|
-
for (;
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
t.commands.setTextSelection({ from:
|
|
440
|
+
}, s = () => {
|
|
441
|
+
const { $from: r } = t.state.selection, u = r.parent.textContent, p = r.parentOffset;
|
|
442
|
+
let w = p, v = p;
|
|
443
|
+
for (; w > 0 && !/\s/.test(u[w - 1]); )
|
|
444
|
+
w--;
|
|
445
|
+
for (; v < u.length && !/\s/.test(u[v]); )
|
|
446
|
+
v++;
|
|
447
|
+
const N = r.start(), P = N + w, W = N + v, U = u.slice(w, v);
|
|
448
|
+
t.commands.setTextSelection({ from: P, to: W }), i(n.linkAttrs.href || ""), c(U || n.linkAttrs.alt || "");
|
|
449
449
|
};
|
|
450
|
-
return /* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ g(
|
|
451
451
|
y,
|
|
452
452
|
{
|
|
453
453
|
Trigger: /* @__PURE__ */ o(
|
|
@@ -459,10 +459,10 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
459
459
|
}
|
|
460
460
|
),
|
|
461
461
|
maxWidth: "400px",
|
|
462
|
-
onOpenChange: (r) => r &&
|
|
462
|
+
onOpenChange: (r) => r && s(),
|
|
463
463
|
children: [
|
|
464
464
|
/* @__PURE__ */ o(T, { style: { display: "none" } }),
|
|
465
|
-
/* @__PURE__ */
|
|
465
|
+
/* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
|
|
466
466
|
/* @__PURE__ */ o(
|
|
467
467
|
k,
|
|
468
468
|
{
|
|
@@ -478,14 +478,14 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
478
478
|
{
|
|
479
479
|
Label: "Text to display",
|
|
480
480
|
type: "text",
|
|
481
|
-
value:
|
|
482
|
-
onChange: (r) =>
|
|
481
|
+
value: l,
|
|
482
|
+
onChange: (r) => c(r.target.value)
|
|
483
483
|
}
|
|
484
484
|
)
|
|
485
485
|
] }),
|
|
486
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ g(x, { children: [
|
|
487
487
|
n.isLink && /* @__PURE__ */ o(
|
|
488
|
-
|
|
488
|
+
b,
|
|
489
489
|
{
|
|
490
490
|
color: "error",
|
|
491
491
|
onClick: () => t.chain().focus().unsetLink().run(),
|
|
@@ -493,27 +493,27 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
493
493
|
children: "Remove"
|
|
494
494
|
}
|
|
495
495
|
),
|
|
496
|
-
/* @__PURE__ */ o(
|
|
496
|
+
/* @__PURE__ */ o(b, { onClick: a, disabled: !e, children: "Save" })
|
|
497
497
|
] })
|
|
498
498
|
]
|
|
499
499
|
}
|
|
500
500
|
);
|
|
501
|
-
},
|
|
502
|
-
const { editor: t } = m(), n =
|
|
501
|
+
}, Ft = () => {
|
|
502
|
+
const { editor: t } = m(), n = f({
|
|
503
503
|
editor: t,
|
|
504
504
|
selector: (r) => ({
|
|
505
505
|
isTable: r.editor.isActive("table"),
|
|
506
506
|
tableAttrs: r.editor.getAttributes("table")
|
|
507
507
|
})
|
|
508
|
-
}), [e, i] = E(!1),
|
|
509
|
-
|
|
508
|
+
}), [e, i] = E(!1), l = j(null), c = _(() => {
|
|
509
|
+
l.current = setTimeout(() => {
|
|
510
510
|
t.chain().focus().insertTable({ rows: 2, cols: 4, withHeaderRow: e }).run();
|
|
511
511
|
}, 100);
|
|
512
|
-
}, [t, e]), a =
|
|
513
|
-
i((r) => !r),
|
|
512
|
+
}, [t, e]), a = _(() => {
|
|
513
|
+
i((r) => !r), l.current = setTimeout(() => {
|
|
514
514
|
t.chain().focus().toggleHeaderRow().run();
|
|
515
515
|
}, 100);
|
|
516
|
-
}, [t]),
|
|
516
|
+
}, [t]), s = [
|
|
517
517
|
{
|
|
518
518
|
text: "Column left",
|
|
519
519
|
icon: "wm-add",
|
|
@@ -545,7 +545,7 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
545
545
|
event: () => t.chain().focus().deleteRow().run()
|
|
546
546
|
}
|
|
547
547
|
];
|
|
548
|
-
return n.isTable ? /* @__PURE__ */
|
|
548
|
+
return n.isTable ? /* @__PURE__ */ g(
|
|
549
549
|
y,
|
|
550
550
|
{
|
|
551
551
|
Trigger: /* @__PURE__ */ o(
|
|
@@ -559,9 +559,9 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
559
559
|
maxWidth: "320px",
|
|
560
560
|
children: [
|
|
561
561
|
/* @__PURE__ */ o(T, { style: { display: "none" } }),
|
|
562
|
-
/* @__PURE__ */
|
|
562
|
+
/* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
|
|
563
563
|
/* @__PURE__ */ o(
|
|
564
|
-
|
|
564
|
+
st,
|
|
565
565
|
{
|
|
566
566
|
checked: e,
|
|
567
567
|
onClick: a,
|
|
@@ -569,10 +569,10 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
569
569
|
labelPosition: "left"
|
|
570
570
|
}
|
|
571
571
|
),
|
|
572
|
-
/* @__PURE__ */ o("div", { className: d.wuContentEditorTable, children:
|
|
573
|
-
|
|
572
|
+
/* @__PURE__ */ o("div", { className: d.wuContentEditorTable, children: s.map(({ text: r, icon: u, event: p }) => /* @__PURE__ */ o(
|
|
573
|
+
ct,
|
|
574
574
|
{
|
|
575
|
-
onClick:
|
|
575
|
+
onClick: p,
|
|
576
576
|
variant: "secondary",
|
|
577
577
|
Icon: /* @__PURE__ */ o(h, { icon: u }),
|
|
578
578
|
children: r
|
|
@@ -581,7 +581,7 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
581
581
|
)) })
|
|
582
582
|
] }),
|
|
583
583
|
/* @__PURE__ */ o(x, { children: /* @__PURE__ */ o(
|
|
584
|
-
|
|
584
|
+
b,
|
|
585
585
|
{
|
|
586
586
|
onClick: () => t.chain().focus().deleteTable().run(),
|
|
587
587
|
variant: "outline",
|
|
@@ -596,13 +596,13 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
596
596
|
) : /* @__PURE__ */ o(
|
|
597
597
|
"button",
|
|
598
598
|
{
|
|
599
|
-
onClick:
|
|
599
|
+
onClick: c,
|
|
600
600
|
className: d.wuContentEditorAction,
|
|
601
601
|
children: /* @__PURE__ */ o(h, { icon: "wm-table" })
|
|
602
602
|
}
|
|
603
603
|
);
|
|
604
|
-
},
|
|
605
|
-
const { editor: t, customFonts: n } = m(), e =
|
|
604
|
+
}, Nt = () => {
|
|
605
|
+
const { editor: t, customFonts: n } = m(), e = f({
|
|
606
606
|
editor: t,
|
|
607
607
|
selector: (a) => ({
|
|
608
608
|
currentFontFamily: a.editor.getAttributes("textStyle").fontFamily || ""
|
|
@@ -614,23 +614,23 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
614
614
|
"JetBrains Mono",
|
|
615
615
|
"Montserrat",
|
|
616
616
|
...n || []
|
|
617
|
-
], [
|
|
617
|
+
], [l, c] = E(
|
|
618
618
|
e.currentFontFamily || i[0]
|
|
619
619
|
);
|
|
620
620
|
return C.useEffect(() => {
|
|
621
621
|
var a;
|
|
622
|
-
|
|
622
|
+
c(
|
|
623
623
|
((a = e.currentFontFamily) == null ? void 0 : a.replace(/"/g, "")) || i[0]
|
|
624
624
|
);
|
|
625
|
-
}, [e.currentFontFamily]), /* @__PURE__ */
|
|
625
|
+
}, [e.currentFontFamily]), /* @__PURE__ */ g(M, { children: [
|
|
626
626
|
/* @__PURE__ */ o(
|
|
627
|
-
|
|
627
|
+
H,
|
|
628
628
|
{
|
|
629
629
|
className: d.wuContentEditorAction,
|
|
630
|
-
"data-active":
|
|
631
|
-
style: { fontFamily:
|
|
632
|
-
title:
|
|
633
|
-
children:
|
|
630
|
+
"data-active": l !== "Fira Sans",
|
|
631
|
+
style: { fontFamily: l },
|
|
632
|
+
title: l || "Font Family",
|
|
633
|
+
children: l == null ? void 0 : l[0]
|
|
634
634
|
}
|
|
635
635
|
),
|
|
636
636
|
/* @__PURE__ */ o(
|
|
@@ -641,12 +641,12 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
641
641
|
"data-block": !0,
|
|
642
642
|
onCloseAutoFocus: (a) => a.preventDefault(),
|
|
643
643
|
children: i.map((a) => /* @__PURE__ */ o(
|
|
644
|
-
|
|
644
|
+
B,
|
|
645
645
|
{
|
|
646
646
|
title: a,
|
|
647
647
|
className: d.wuContentEditorDropdownItem,
|
|
648
648
|
onSelect: () => {
|
|
649
|
-
t.chain().focus().setFontFamily(a).run(),
|
|
649
|
+
t.chain().focus().setFontFamily(a).run(), c(a);
|
|
650
650
|
},
|
|
651
651
|
children: a
|
|
652
652
|
},
|
|
@@ -655,8 +655,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
655
655
|
}
|
|
656
656
|
)
|
|
657
657
|
] });
|
|
658
|
-
},
|
|
659
|
-
const { editor: t } = m(), n =
|
|
658
|
+
}, Dt = () => {
|
|
659
|
+
const { editor: t } = m(), n = f({
|
|
660
660
|
editor: t,
|
|
661
661
|
selector: (e) => {
|
|
662
662
|
var i;
|
|
@@ -677,16 +677,16 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
677
677
|
children: /* @__PURE__ */ o(h, { icon: "wm-format-italic" })
|
|
678
678
|
}
|
|
679
679
|
);
|
|
680
|
-
},
|
|
681
|
-
const { editor: t } = m(), n =
|
|
680
|
+
}, _t = () => {
|
|
681
|
+
const { editor: t } = m(), n = f({
|
|
682
682
|
editor: t,
|
|
683
683
|
selector: (i) => {
|
|
684
|
-
var
|
|
684
|
+
var l, c, a, s, r, u;
|
|
685
685
|
return {
|
|
686
|
-
isUl: (
|
|
687
|
-
isOl: (
|
|
686
|
+
isUl: (l = i.editor) == null ? void 0 : l.isActive("bulletList"),
|
|
687
|
+
isOl: (c = i.editor) == null ? void 0 : c.isActive("orderedList"),
|
|
688
688
|
isTodo: (a = i.editor) == null ? void 0 : a.isActive("taskList"),
|
|
689
|
-
isList: ((
|
|
689
|
+
isList: ((s = i.editor) == null ? void 0 : s.isActive("bulletList")) || ((r = i.editor) == null ? void 0 : r.isActive("orderedList")) || ((u = i.editor) == null ? void 0 : u.isActive("taskList"))
|
|
690
690
|
};
|
|
691
691
|
}
|
|
692
692
|
}), e = [
|
|
@@ -723,30 +723,30 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
725
|
);
|
|
726
|
-
}, It = ["e", "E", "+", "-"],
|
|
727
|
-
const { editor: t } = m(), [n, e] = E(16), i =
|
|
726
|
+
}, It = ["e", "E", "+", "-"], I = 1, Rt = () => {
|
|
727
|
+
const { editor: t } = m(), [n, e] = E(16), i = f({
|
|
728
728
|
editor: t,
|
|
729
|
-
selector: (
|
|
730
|
-
fontSize:
|
|
729
|
+
selector: (s) => ({
|
|
730
|
+
fontSize: s.editor.getAttributes("textStyle").fontSize
|
|
731
731
|
})
|
|
732
|
-
}),
|
|
733
|
-
t.chain().focus().setFontSize(
|
|
734
|
-
},
|
|
735
|
-
const r = Math.max(
|
|
736
|
-
e(r),
|
|
737
|
-
}, a = (
|
|
738
|
-
It.includes(
|
|
732
|
+
}), l = (s) => {
|
|
733
|
+
t.chain().focus().setFontSize(s + "px").run();
|
|
734
|
+
}, c = (s) => {
|
|
735
|
+
const r = Math.max(I, s);
|
|
736
|
+
e(r), l(r);
|
|
737
|
+
}, a = (s) => {
|
|
738
|
+
It.includes(s.key) ? s.preventDefault() : s.key === "Enter" && l(n);
|
|
739
739
|
};
|
|
740
740
|
return C.useEffect(() => {
|
|
741
|
-
var
|
|
742
|
-
e(Number((
|
|
743
|
-
}, [i.fontSize]), /* @__PURE__ */
|
|
741
|
+
var s;
|
|
742
|
+
e(Number((s = i.fontSize) == null ? void 0 : s.replace("px", "")) || 16);
|
|
743
|
+
}, [i.fontSize]), /* @__PURE__ */ g("div", { className: d.wuContentEditorFontSize, children: [
|
|
744
744
|
/* @__PURE__ */ o(
|
|
745
745
|
"button",
|
|
746
746
|
{
|
|
747
747
|
className: d.wuContentEditorAction,
|
|
748
|
-
onClick: () =>
|
|
749
|
-
disabled: n <=
|
|
748
|
+
onClick: () => c(n - 1),
|
|
749
|
+
disabled: n <= I,
|
|
750
750
|
children: "−"
|
|
751
751
|
}
|
|
752
752
|
),
|
|
@@ -758,22 +758,22 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
758
758
|
pattern: "[0-9]*",
|
|
759
759
|
value: n,
|
|
760
760
|
onKeyDown: a,
|
|
761
|
-
onChange: (
|
|
762
|
-
onBlur: () =>
|
|
761
|
+
onChange: (s) => e(s.target.valueAsNumber),
|
|
762
|
+
onBlur: () => l(n)
|
|
763
763
|
}
|
|
764
764
|
),
|
|
765
765
|
/* @__PURE__ */ o(
|
|
766
766
|
"button",
|
|
767
767
|
{
|
|
768
768
|
className: d.wuContentEditorAction,
|
|
769
|
-
onClick: () =>
|
|
769
|
+
onClick: () => c(n + 1),
|
|
770
770
|
disabled: n >= 128,
|
|
771
771
|
children: "+"
|
|
772
772
|
}
|
|
773
773
|
)
|
|
774
774
|
] });
|
|
775
|
-
},
|
|
776
|
-
const { editor: t } = m(), n =
|
|
775
|
+
}, Mt = () => {
|
|
776
|
+
const { editor: t } = m(), n = f({
|
|
777
777
|
editor: t,
|
|
778
778
|
selector: (e) => {
|
|
779
779
|
var i;
|
|
@@ -794,8 +794,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
794
794
|
children: /* @__PURE__ */ o(h, { icon: "wm-format-strikethrough" })
|
|
795
795
|
}
|
|
796
796
|
);
|
|
797
|
-
},
|
|
798
|
-
const { editor: t } = m(), n =
|
|
797
|
+
}, Ht = () => {
|
|
798
|
+
const { editor: t } = m(), n = f({
|
|
799
799
|
editor: t,
|
|
800
800
|
selector: (e) => {
|
|
801
801
|
var i;
|
|
@@ -817,7 +817,7 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
817
817
|
}
|
|
818
818
|
);
|
|
819
819
|
}, zt = () => {
|
|
820
|
-
const { editor: t } = m(), n =
|
|
820
|
+
const { editor: t } = m(), n = f({
|
|
821
821
|
editor: t,
|
|
822
822
|
selector: (e) => {
|
|
823
823
|
var i;
|
|
@@ -838,14 +838,14 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
838
838
|
children: /* @__PURE__ */ o(h, { icon: "wm-superscript" })
|
|
839
839
|
}
|
|
840
840
|
);
|
|
841
|
-
},
|
|
842
|
-
const { editor: t } = m(), n =
|
|
841
|
+
}, Bt = () => {
|
|
842
|
+
const { editor: t } = m(), n = f({
|
|
843
843
|
editor: t,
|
|
844
844
|
selector: ({ editor: e }) => ({
|
|
845
845
|
textColor: e.getAttributes("textStyle").color
|
|
846
846
|
})
|
|
847
847
|
});
|
|
848
|
-
return /* @__PURE__ */
|
|
848
|
+
return /* @__PURE__ */ g(
|
|
849
849
|
"label",
|
|
850
850
|
{
|
|
851
851
|
className: d.wuContentEditorAction,
|
|
@@ -873,8 +873,8 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
873
873
|
]
|
|
874
874
|
}
|
|
875
875
|
);
|
|
876
|
-
},
|
|
877
|
-
const { editor: t } = m(), n =
|
|
876
|
+
}, Ot = () => {
|
|
877
|
+
const { editor: t } = m(), n = f({
|
|
878
878
|
editor: t,
|
|
879
879
|
selector: (e) => {
|
|
880
880
|
var i;
|
|
@@ -895,26 +895,26 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
895
895
|
children: /* @__PURE__ */ o(h, { icon: "wm-format-underlined" })
|
|
896
896
|
}
|
|
897
897
|
);
|
|
898
|
-
},
|
|
899
|
-
block: /* @__PURE__ */ o(
|
|
900
|
-
fontFamily: /* @__PURE__ */ o(
|
|
901
|
-
fontSize: /* @__PURE__ */ o(
|
|
902
|
-
bold: /* @__PURE__ */ o(
|
|
903
|
-
italic: /* @__PURE__ */ o(
|
|
904
|
-
underline: /* @__PURE__ */ o(
|
|
905
|
-
strike: /* @__PURE__ */ o(
|
|
906
|
-
color: /* @__PURE__ */ o(
|
|
907
|
-
bgColor: /* @__PURE__ */ o(
|
|
908
|
-
list: /* @__PURE__ */ o(
|
|
909
|
-
alignment: /* @__PURE__ */ o(
|
|
910
|
-
image: /* @__PURE__ */ o(
|
|
911
|
-
link: /* @__PURE__ */ o(
|
|
912
|
-
table: /* @__PURE__ */ o(
|
|
913
|
-
blockquote: /* @__PURE__ */ o(
|
|
898
|
+
}, Pt = {
|
|
899
|
+
block: /* @__PURE__ */ o(kt, {}),
|
|
900
|
+
fontFamily: /* @__PURE__ */ o(Nt, {}),
|
|
901
|
+
fontSize: /* @__PURE__ */ o(Rt, {}),
|
|
902
|
+
bold: /* @__PURE__ */ o(yt, {}),
|
|
903
|
+
italic: /* @__PURE__ */ o(Dt, {}),
|
|
904
|
+
underline: /* @__PURE__ */ o(Ot, {}),
|
|
905
|
+
strike: /* @__PURE__ */ o(Mt, {}),
|
|
906
|
+
color: /* @__PURE__ */ o(Bt, {}),
|
|
907
|
+
bgColor: /* @__PURE__ */ o(At, {}),
|
|
908
|
+
list: /* @__PURE__ */ o(_t, {}),
|
|
909
|
+
alignment: /* @__PURE__ */ o(bt, {}),
|
|
910
|
+
image: /* @__PURE__ */ o(xt, {}),
|
|
911
|
+
link: /* @__PURE__ */ o(Lt, {}),
|
|
912
|
+
table: /* @__PURE__ */ o(Ft, {}),
|
|
913
|
+
blockquote: /* @__PURE__ */ o(Et, {}),
|
|
914
914
|
superscript: /* @__PURE__ */ o(zt, {}),
|
|
915
|
-
subscript: /* @__PURE__ */ o(
|
|
916
|
-
codeline: /* @__PURE__ */ o(
|
|
917
|
-
clear: /* @__PURE__ */ o(
|
|
915
|
+
subscript: /* @__PURE__ */ o(Ht, {}),
|
|
916
|
+
codeline: /* @__PURE__ */ o(St, {}),
|
|
917
|
+
clear: /* @__PURE__ */ o(Tt, {}),
|
|
918
918
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
919
919
|
"|": /* @__PURE__ */ o(
|
|
920
920
|
"div",
|
|
@@ -926,7 +926,7 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
)
|
|
929
|
-
},
|
|
929
|
+
}, Wt = [
|
|
930
930
|
"block",
|
|
931
931
|
"fontFamily",
|
|
932
932
|
"|",
|
|
@@ -953,22 +953,28 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
953
953
|
"codeline",
|
|
954
954
|
"|",
|
|
955
955
|
"clear"
|
|
956
|
-
],
|
|
957
|
-
const { editor: n, customFonts: e, children: i, items:
|
|
958
|
-
return /* @__PURE__ */ o("div", { ...
|
|
959
|
-
|
|
956
|
+
], Ut = (t) => {
|
|
957
|
+
const { editor: n, customFonts: e, children: i, items: l = Wt, ...c } = t;
|
|
958
|
+
return /* @__PURE__ */ o("div", { ...c, children: /* @__PURE__ */ g(vt, { editor: n, customFonts: e, children: [
|
|
959
|
+
l.map((a, s) => /* @__PURE__ */ o(R, { children: Pt[a] }, a + s)),
|
|
960
960
|
i
|
|
961
961
|
] }) });
|
|
962
|
-
},
|
|
963
|
-
|
|
962
|
+
}, F = lt();
|
|
963
|
+
F.setConfig({
|
|
964
|
+
USE_PROFILES: { html: !0 },
|
|
965
|
+
ALLOWED_TAGS: [
|
|
966
|
+
"div",
|
|
964
967
|
"p",
|
|
965
968
|
"br",
|
|
966
969
|
"strong",
|
|
970
|
+
"b",
|
|
967
971
|
"em",
|
|
972
|
+
"i",
|
|
968
973
|
"u",
|
|
969
974
|
"s",
|
|
970
975
|
"code",
|
|
971
976
|
"pre",
|
|
977
|
+
"blockquote",
|
|
972
978
|
"h1",
|
|
973
979
|
"h2",
|
|
974
980
|
"h3",
|
|
@@ -978,7 +984,6 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
978
984
|
"ul",
|
|
979
985
|
"ol",
|
|
980
986
|
"li",
|
|
981
|
-
"blockquote",
|
|
982
987
|
"a",
|
|
983
988
|
"img",
|
|
984
989
|
"table",
|
|
@@ -988,97 +993,90 @@ const lt = "_wuContentEditor_399u0_8", at = "_wuContentEditorTable_399u0_1", dt
|
|
|
988
993
|
"th",
|
|
989
994
|
"td",
|
|
990
995
|
"sup",
|
|
991
|
-
"sub"
|
|
992
|
-
"span",
|
|
993
|
-
"div"
|
|
996
|
+
"sub"
|
|
994
997
|
],
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
)
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
998
|
+
ALLOWED_ATTR: [
|
|
999
|
+
"href",
|
|
1000
|
+
"target",
|
|
1001
|
+
"rel",
|
|
1002
|
+
"src",
|
|
1003
|
+
"alt",
|
|
1004
|
+
"title",
|
|
1005
|
+
"width",
|
|
1006
|
+
"height",
|
|
1007
|
+
"colspan",
|
|
1008
|
+
"rowspan",
|
|
1009
|
+
"data-*",
|
|
1010
|
+
"style",
|
|
1011
|
+
"class"
|
|
1012
|
+
],
|
|
1013
|
+
ALLOW_DATA_ATTR: !0
|
|
1014
|
+
});
|
|
1015
|
+
F.addHook("uponSanitizeAttribute", (t, n) => {
|
|
1016
|
+
if (n.attrName === "style") {
|
|
1017
|
+
const e = n.attrValue.toLowerCase();
|
|
1018
|
+
(e.includes("expression") || e.includes("javascript:") || e.includes("url(")) && (n.keepAttr = !1);
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
function A(t) {
|
|
1022
|
+
return t ? F.sanitize(t) : "";
|
|
1023
|
+
}
|
|
1023
1024
|
function ie({
|
|
1024
1025
|
defaultValue: t,
|
|
1025
1026
|
onUpdate: n,
|
|
1026
1027
|
className: e,
|
|
1027
|
-
|
|
1028
|
-
toolbarPosition: s = "top",
|
|
1028
|
+
toolbarPosition: i = "top",
|
|
1029
1029
|
customToolbarChildren: l,
|
|
1030
|
-
toolbarItems:
|
|
1031
|
-
hideToolbar:
|
|
1032
|
-
|
|
1033
|
-
customFonts:
|
|
1034
|
-
|
|
1030
|
+
toolbarItems: c,
|
|
1031
|
+
hideToolbar: a,
|
|
1032
|
+
readonly: s,
|
|
1033
|
+
customFonts: r,
|
|
1034
|
+
renderDefaultOnly: u,
|
|
1035
|
+
...p
|
|
1035
1036
|
}) {
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
n && n(b.getHTML());
|
|
1037
|
+
const w = q({
|
|
1038
|
+
extensions: Ct,
|
|
1039
|
+
content: A(t || ""),
|
|
1040
|
+
onUpdate: ({ editor: v }) => {
|
|
1041
|
+
n && n(A(v.getHTML()));
|
|
1042
1042
|
}
|
|
1043
1043
|
});
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
{
|
|
1049
|
-
"
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1055
|
-
return /* @__PURE__ */ p(
|
|
1044
|
+
return s ? (console.log(w.getHTML()), /* @__PURE__ */ o(
|
|
1045
|
+
"div",
|
|
1046
|
+
{
|
|
1047
|
+
className: D(d.wuContentEditor, e),
|
|
1048
|
+
dangerouslySetInnerHTML: {
|
|
1049
|
+
__html: A(u ? t || "" : w.getHTML())
|
|
1050
|
+
},
|
|
1051
|
+
...p
|
|
1052
|
+
}
|
|
1053
|
+
)) : /* @__PURE__ */ g(
|
|
1056
1054
|
"div",
|
|
1057
1055
|
{
|
|
1058
|
-
className:
|
|
1059
|
-
"data-position":
|
|
1056
|
+
className: D(d.wuContentEditorContainer, e),
|
|
1057
|
+
"data-position": i,
|
|
1060
1058
|
"data-slot": "wu-content-editor-container",
|
|
1061
1059
|
onClick: () => {
|
|
1062
|
-
|
|
1060
|
+
w == null || w.chain().focus().run();
|
|
1063
1061
|
},
|
|
1064
|
-
...
|
|
1062
|
+
...p,
|
|
1065
1063
|
children: [
|
|
1066
|
-
!
|
|
1067
|
-
|
|
1064
|
+
!a && /* @__PURE__ */ o(
|
|
1065
|
+
Ut,
|
|
1068
1066
|
{
|
|
1069
|
-
editor:
|
|
1070
|
-
customFonts:
|
|
1067
|
+
editor: w,
|
|
1068
|
+
customFonts: r,
|
|
1071
1069
|
className: d.wuContentEditorToolbar,
|
|
1072
|
-
items:
|
|
1070
|
+
items: c,
|
|
1073
1071
|
"data-slot": "wu-content-editor-toolbar",
|
|
1074
|
-
"data-position":
|
|
1072
|
+
"data-position": i,
|
|
1075
1073
|
children: l
|
|
1076
1074
|
}
|
|
1077
1075
|
),
|
|
1078
1076
|
/* @__PURE__ */ o(
|
|
1079
|
-
|
|
1077
|
+
$,
|
|
1080
1078
|
{
|
|
1081
|
-
editor:
|
|
1079
|
+
editor: w,
|
|
1082
1080
|
className: d.wuContentEditor,
|
|
1083
1081
|
"data-slot": "wu-content-editor"
|
|
1084
1082
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npm-questionpro/wick-ui-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Wick Editor is a powerful and intuitive content editing component built with React. It provides a rich set of features for creating and managing content, making it ideal for applications that require dynamic and interactive content creation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@eslint/js": "^9.39.1",
|
|
62
|
-
"@npm-questionpro/wick-ui-icon": "
|
|
63
|
-
"@npm-questionpro/wick-ui-lib": "
|
|
62
|
+
"@npm-questionpro/wick-ui-icon": "latest",
|
|
63
|
+
"@npm-questionpro/wick-ui-lib": "latest",
|
|
64
64
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
65
65
|
"clsx": "^2.1.1",
|
|
66
66
|
"@storybook/addon-a11y": "10.1.5",
|