@npm-questionpro/wick-ui-editor 0.14.2 → 2.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html-Ccb8eKR4.js +7158 -0
- package/dist/index.d.ts +0 -44
- package/dist/standalone-DSxjHhed.js +3574 -0
- package/dist/style.css +2 -1
- package/dist/wick-ui-editor/es/index.js +710 -944
- package/llms.txt +31 -0
- package/package.json +40 -49
- package/dist/html-asrO2y6j.js +0 -2893
- package/dist/standalone-uA6N_bR1.js +0 -2458
|
@@ -1,166 +1,134 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import Y from "
|
|
4
|
-
import
|
|
5
|
-
import Q from "@tiptap/extension-
|
|
6
|
-
import
|
|
7
|
-
import ot from "@tiptap/extension-
|
|
8
|
-
import nt from "@tiptap/extension-
|
|
9
|
-
import
|
|
10
|
-
import rt from "@tiptap/extension-text-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { WuIcon as
|
|
14
|
-
import { DropdownMenu as
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
wuContentEditor:
|
|
18
|
-
wuContentEditorTable:
|
|
1
|
+
import { EditorContent as G, useEditor as V, useEditorState as f } from "@tiptap/react";
|
|
2
|
+
import X from "clsx";
|
|
3
|
+
import m, { useCallback as O, useRef as Y, useState as N } from "react";
|
|
4
|
+
import Z from "@tiptap/extension-image";
|
|
5
|
+
import { TaskItem as Q, TaskList as tt } from "@tiptap/extension-list";
|
|
6
|
+
import et from "@tiptap/extension-subscript";
|
|
7
|
+
import ot from "@tiptap/extension-superscript";
|
|
8
|
+
import { TableKit as nt } from "@tiptap/extension-table";
|
|
9
|
+
import it from "@tiptap/extension-text-align";
|
|
10
|
+
import { BackgroundColor as rt, Color as lt, FontFamily as at, FontSize as st, LineHeight as ct, TextStyle as ut } from "@tiptap/extension-text-style";
|
|
11
|
+
import dt from "@tiptap/starter-kit";
|
|
12
|
+
import { Fragment as x, jsx as e, jsxs as v } from "react/jsx-runtime";
|
|
13
|
+
import { WuButton as q, WuIcon as h, WuInput as F, WuModal as H, WuModalClose as _, WuModalContent as D, WuModalFooter as R, WuModalHeader as z, WuToggle as mt } from "@npm-questionpro/wick-ui-lib";
|
|
14
|
+
import { DropdownMenu as U, DropdownMenuContent as j, DropdownMenuItem as $, DropdownMenuTrigger as K } from "@radix-ui/react-dropdown-menu";
|
|
15
|
+
import ht from "dompurify";
|
|
16
|
+
var pt = "_wuContentEditor_cl3h6_7", ft = "_wuContentEditorTable_cl3h6_1", gt = "_selectedCell_cl3h6_1", vt = "_tableWrapper_cl3h6_1", wt = "_wuContentEditorContainer_cl3h6_7", Ct = "_wuContentEditorToolbar_cl3h6_82", bt = "_wuContentEditorAction_cl3h6_110", At = "_wuContentEditorDropdown_cl3h6_136", yt = "_wuContentEditorDropdownItem_cl3h6_150", kt = "_wuContentEditorFontSize_cl3h6_162", Et = "_wuContentEditorModal_cl3h6_176", Tt = "_wuCodeEditor_cl3h6_180", St = "_wuFormatCode_cl3h6_190", _t = "_wuCodeEditorPreview_cl3h6_205", xt = "_wuCodeEditorInput_cl3h6_222", a = {
|
|
17
|
+
wuContentEditor: pt,
|
|
18
|
+
wuContentEditorTable: ft,
|
|
19
|
+
selectedCell: gt,
|
|
20
|
+
"column-resize-handle": "_column-resize-handle_cl3h6_1",
|
|
21
|
+
tableWrapper: vt,
|
|
22
|
+
"resize-cursor": "_resize-cursor_cl3h6_1",
|
|
19
23
|
wuContentEditorContainer: wt,
|
|
20
24
|
wuContentEditorToolbar: Ct,
|
|
21
|
-
wuContentEditorAction:
|
|
22
|
-
wuContentEditorDropdown:
|
|
23
|
-
wuContentEditorDropdownItem:
|
|
25
|
+
wuContentEditorAction: bt,
|
|
26
|
+
wuContentEditorDropdown: At,
|
|
27
|
+
wuContentEditorDropdownItem: yt,
|
|
24
28
|
wuContentEditorFontSize: kt,
|
|
25
29
|
wuContentEditorModal: Et,
|
|
26
|
-
wuCodeEditor:
|
|
27
|
-
wuFormatCode:
|
|
28
|
-
wuCodeEditorPreview:
|
|
30
|
+
wuCodeEditor: Tt,
|
|
31
|
+
wuFormatCode: St,
|
|
32
|
+
wuCodeEditorPreview: _t,
|
|
29
33
|
wuCodeEditorInput: xt
|
|
30
34
|
}, Ft = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const o = t.includes(":") ? new URL(t) : new URL(`https://${t}`), n = [
|
|
59
|
-
"example-no-autolink.com",
|
|
60
|
-
"another-no-autolink.com"
|
|
61
|
-
], i = o.hostname;
|
|
62
|
-
return !n.includes(i);
|
|
63
|
-
} catch {
|
|
64
|
-
return !1;
|
|
65
|
-
}
|
|
35
|
+
dt.configure({ link: {
|
|
36
|
+
openOnClick: !1,
|
|
37
|
+
autolink: !0,
|
|
38
|
+
defaultProtocol: "https",
|
|
39
|
+
protocols: ["http", "https"],
|
|
40
|
+
isAllowedUri: (t, o) => {
|
|
41
|
+
try {
|
|
42
|
+
const n = t.includes(":") ? new URL(t) : new URL(`${o.defaultProtocol}://${t}`);
|
|
43
|
+
if (!o.defaultValidate(n.href)) return !1;
|
|
44
|
+
const i = [
|
|
45
|
+
"ftp",
|
|
46
|
+
"file",
|
|
47
|
+
"mailto"
|
|
48
|
+
], r = n.protocol.replace(":", "");
|
|
49
|
+
if (i.includes(r) || !o.protocols.map((l) => typeof l == "string" ? l : l.scheme).includes(r)) return !1;
|
|
50
|
+
const u = ["example-phishing.com", "malicious-site.net"], c = n.hostname;
|
|
51
|
+
return !u.includes(c);
|
|
52
|
+
} catch {
|
|
53
|
+
return !1;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
shouldAutoLink: (t) => {
|
|
57
|
+
try {
|
|
58
|
+
const o = t.includes(":") ? new URL(t) : new URL(`https://${t}`), n = ["example-no-autolink.com", "another-no-autolink.com"], i = o.hostname;
|
|
59
|
+
return !n.includes(i);
|
|
60
|
+
} catch {
|
|
61
|
+
return !1;
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
}),
|
|
69
|
-
|
|
70
|
-
types: ["heading", "paragraph"]
|
|
71
|
-
}),
|
|
72
|
-
nt,
|
|
64
|
+
} }),
|
|
65
|
+
it.configure({ types: ["heading", "paragraph"] }),
|
|
73
66
|
ot,
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
et,
|
|
68
|
+
ut,
|
|
76
69
|
lt,
|
|
70
|
+
rt,
|
|
77
71
|
tt,
|
|
78
|
-
|
|
72
|
+
Q,
|
|
73
|
+
ct,
|
|
74
|
+
st,
|
|
79
75
|
at,
|
|
80
|
-
|
|
81
|
-
dt,
|
|
82
|
-
Q.configure({
|
|
76
|
+
Z.configure({
|
|
83
77
|
resize: {
|
|
84
78
|
enabled: !0,
|
|
85
79
|
alwaysPreserveAspectRatio: !0
|
|
86
80
|
},
|
|
87
81
|
inline: !0
|
|
88
82
|
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const t = h.useContext(J);
|
|
102
|
-
if (!t)
|
|
103
|
-
throw new Error("useToolbar must be used within a ToolbarProvider");
|
|
83
|
+
nt.configure({ table: { resizable: !0 } })
|
|
84
|
+
], J = m.createContext(null), Lt = ({ editor: t, children: o, customFonts: n, isHtml: i, setIsHtml: r }) => /* @__PURE__ */ e(J.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
editor: t,
|
|
87
|
+
customFonts: n,
|
|
88
|
+
isHtml: i,
|
|
89
|
+
setIsHtml: r
|
|
90
|
+
},
|
|
91
|
+
children: o
|
|
92
|
+
}), p = () => {
|
|
93
|
+
const t = m.useContext(J);
|
|
94
|
+
if (!t) throw new Error("useToolbar must be used within a ToolbarProvider");
|
|
104
95
|
return t;
|
|
105
96
|
}, M = ({ action: t, defaultValue: o }) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
o || t.items.find((
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
const [n, i] = m.useState(o || t.items.find((r) => r.active) || t.items[0]);
|
|
98
|
+
return m.useEffect(() => {
|
|
99
|
+
i(o || t.items.find((r) => r.active) || t.items[0]);
|
|
100
|
+
}, [t, o]), /* @__PURE__ */ v(U, { children: [/* @__PURE__ */ e(K, {
|
|
101
|
+
className: a.wuContentEditorAction,
|
|
102
|
+
"data-active": t.active,
|
|
103
|
+
children: /* @__PURE__ */ e(h, { icon: n.icon })
|
|
104
|
+
}), /* @__PURE__ */ e(j, {
|
|
105
|
+
align: "start",
|
|
106
|
+
onCloseAutoFocus: (r) => r.preventDefault(),
|
|
107
|
+
className: a.wuContentEditorDropdown,
|
|
108
|
+
"data-inline": !0,
|
|
109
|
+
children: t.items?.map((r) => /* @__PURE__ */ e($, {
|
|
110
|
+
onClick: () => {
|
|
111
|
+
r.event(), i(r);
|
|
112
|
+
},
|
|
113
|
+
title: r.tooltip,
|
|
114
|
+
children: /* @__PURE__ */ e("button", {
|
|
115
|
+
type: "button",
|
|
118
116
|
className: a.wuContentEditorAction,
|
|
119
|
-
"data-active":
|
|
120
|
-
children: /* @__PURE__ */ e(
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
align: "start",
|
|
127
|
-
onCloseAutoFocus: (l) => l.preventDefault(),
|
|
128
|
-
className: a.wuContentEditorDropdown,
|
|
129
|
-
"data-inline": !0,
|
|
130
|
-
children: (s = t.items) == null ? void 0 : s.map((l) => /* @__PURE__ */ e(
|
|
131
|
-
U,
|
|
132
|
-
{
|
|
133
|
-
onClick: () => {
|
|
134
|
-
l.event(), i(l);
|
|
135
|
-
},
|
|
136
|
-
title: l.tooltip,
|
|
137
|
-
children: /* @__PURE__ */ e(
|
|
138
|
-
"button",
|
|
139
|
-
{
|
|
140
|
-
className: a.wuContentEditorAction,
|
|
141
|
-
"data-active": l.active,
|
|
142
|
-
children: /* @__PURE__ */ e(f, { icon: l.icon })
|
|
143
|
-
}
|
|
144
|
-
)
|
|
145
|
-
},
|
|
146
|
-
l.id
|
|
147
|
-
))
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
] });
|
|
151
|
-
}, _t = () => {
|
|
152
|
-
const { editor: t } = g(), o = p({
|
|
117
|
+
"data-active": r.active,
|
|
118
|
+
children: /* @__PURE__ */ e(h, { icon: r.icon })
|
|
119
|
+
})
|
|
120
|
+
}, r.id))
|
|
121
|
+
})] });
|
|
122
|
+
}, It = () => {
|
|
123
|
+
const { editor: t } = p(), o = f({
|
|
153
124
|
editor: t,
|
|
154
|
-
selector: (i) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
isAligned: ((r = i.editor) == null ? void 0 : r.isActive({ textAlign: "center" })) || ((d = i.editor) == null ? void 0 : d.isActive({ textAlign: "right" })) || ((w = i.editor) == null ? void 0 : w.isActive({ textAlign: "justify" }))
|
|
162
|
-
};
|
|
163
|
-
}
|
|
125
|
+
selector: (i) => ({
|
|
126
|
+
isLeft: i.editor?.isActive({ textAlign: "left" }),
|
|
127
|
+
isCenter: i.editor?.isActive({ textAlign: "center" }),
|
|
128
|
+
isRight: i.editor?.isActive({ textAlign: "right" }),
|
|
129
|
+
isJustify: i.editor?.isActive({ textAlign: "justify" }),
|
|
130
|
+
isAligned: i.editor?.isActive({ textAlign: "center" }) || i.editor?.isActive({ textAlign: "right" }) || i.editor?.isActive({ textAlign: "justify" })
|
|
131
|
+
})
|
|
164
132
|
}), n = [
|
|
165
133
|
{
|
|
166
134
|
id: "left",
|
|
@@ -191,59 +159,43 @@ const gt = "_wuContentEditor_1kzbo_8", pt = "_wuContentEditorTable_1kzbo_1", wt
|
|
|
191
159
|
active: o.isJustify
|
|
192
160
|
}
|
|
193
161
|
];
|
|
194
|
-
return /* @__PURE__ */ e(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
icon: "wm-format-paragraph",
|
|
201
|
-
items: n
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
);
|
|
162
|
+
return /* @__PURE__ */ e(M, { action: {
|
|
163
|
+
id: "style",
|
|
164
|
+
active: o.isAligned,
|
|
165
|
+
icon: "wm-format-paragraph",
|
|
166
|
+
items: n
|
|
167
|
+
} });
|
|
205
168
|
}, Nt = () => {
|
|
206
|
-
const { editor: t } =
|
|
169
|
+
const { editor: t } = p(), o = f({
|
|
207
170
|
editor: t,
|
|
208
|
-
selector: ({ editor: n }) => ({
|
|
209
|
-
bgColor: n.getAttributes("textStyle").backgroundColor
|
|
210
|
-
})
|
|
171
|
+
selector: ({ editor: n }) => ({ bgColor: n.getAttributes("textStyle").backgroundColor })
|
|
211
172
|
});
|
|
212
|
-
return /* @__PURE__ */ v(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
)
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
);
|
|
233
|
-
}, It = () => {
|
|
234
|
-
const { editor: t } = g(), o = p({
|
|
173
|
+
return /* @__PURE__ */ v("label", {
|
|
174
|
+
className: a.wuContentEditorAction,
|
|
175
|
+
htmlFor: "bg-color",
|
|
176
|
+
title: "Background Color",
|
|
177
|
+
children: [/* @__PURE__ */ e(h, {
|
|
178
|
+
icon: "wm-border-color",
|
|
179
|
+
style: { color: o.bgColor }
|
|
180
|
+
}), /* @__PURE__ */ e("input", {
|
|
181
|
+
type: "color",
|
|
182
|
+
id: "bg-color",
|
|
183
|
+
name: "bg-color",
|
|
184
|
+
defaultValue: "#fff",
|
|
185
|
+
onChange: (n) => t.chain().focus().setBackgroundColor(n.target.value).run()
|
|
186
|
+
})]
|
|
187
|
+
});
|
|
188
|
+
}, Ht = () => {
|
|
189
|
+
const { editor: t } = p(), o = f({
|
|
235
190
|
editor: t,
|
|
236
|
-
selector: (i) => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
isStyle: (d = i.editor) == null ? void 0 : d.isActive("heading")
|
|
245
|
-
};
|
|
246
|
-
}
|
|
191
|
+
selector: (i) => ({
|
|
192
|
+
isParagraph: i.editor?.isActive("paragraph"),
|
|
193
|
+
isH1: i.editor?.isActive("heading", { level: 1 }),
|
|
194
|
+
isH2: i.editor?.isActive("heading", { level: 2 }),
|
|
195
|
+
isH3: i.editor?.isActive("heading", { level: 3 }),
|
|
196
|
+
isH4: i.editor?.isActive("heading", { level: 4 }),
|
|
197
|
+
isStyle: i.editor?.isActive("heading")
|
|
198
|
+
})
|
|
247
199
|
}), n = [
|
|
248
200
|
{
|
|
249
201
|
id: "paragraph",
|
|
@@ -276,343 +228,289 @@ const gt = "_wuContentEditor_1kzbo_8", pt = "_wuContentEditorTable_1kzbo_1", wt
|
|
|
276
228
|
active: o.isH4
|
|
277
229
|
}
|
|
278
230
|
];
|
|
279
|
-
return /* @__PURE__ */ e(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
defaultValue: n.find((i) => i.active)
|
|
289
|
-
}
|
|
290
|
-
);
|
|
231
|
+
return /* @__PURE__ */ e(M, {
|
|
232
|
+
action: {
|
|
233
|
+
id: "style",
|
|
234
|
+
active: o.isStyle,
|
|
235
|
+
icon: "wm-format-paragraph",
|
|
236
|
+
items: n
|
|
237
|
+
},
|
|
238
|
+
defaultValue: n.find((i) => i.active)
|
|
239
|
+
});
|
|
291
240
|
}, Dt = () => {
|
|
292
|
-
const { editor: t } =
|
|
241
|
+
const { editor: t } = p(), o = f({
|
|
293
242
|
editor: t,
|
|
294
|
-
selector: (n) => {
|
|
295
|
-
var i;
|
|
296
|
-
return {
|
|
297
|
-
blockquote: (i = n.editor) == null ? void 0 : i.isActive("blockquote")
|
|
298
|
-
};
|
|
299
|
-
}
|
|
243
|
+
selector: (n) => ({ blockquote: n.editor?.isActive("blockquote") })
|
|
300
244
|
});
|
|
301
|
-
return /* @__PURE__ */ e(
|
|
302
|
-
"button",
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
)
|
|
313
|
-
}, Ht = () => {
|
|
314
|
-
const { editor: t } = g(), o = p({
|
|
245
|
+
return /* @__PURE__ */ e("button", {
|
|
246
|
+
type: "button",
|
|
247
|
+
title: "quote",
|
|
248
|
+
className: a.wuContentEditorAction,
|
|
249
|
+
"data-active": o.blockquote,
|
|
250
|
+
onClick: (n) => {
|
|
251
|
+
n.preventDefault(), t.chain().focus().toggleBlockquote().run();
|
|
252
|
+
},
|
|
253
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-format-quote" })
|
|
254
|
+
});
|
|
255
|
+
}, Rt = () => {
|
|
256
|
+
const { editor: t } = p(), o = f({
|
|
315
257
|
editor: t,
|
|
316
|
-
selector: (n) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
258
|
+
selector: (n) => ({ bold: n.editor?.isActive("bold") })
|
|
259
|
+
});
|
|
260
|
+
return /* @__PURE__ */ e("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
title: "Bold",
|
|
263
|
+
className: a.wuContentEditorAction,
|
|
264
|
+
"data-active": o.bold,
|
|
265
|
+
onClick: (n) => {
|
|
266
|
+
n.preventDefault(), t.chain().focus().toggleBold().run();
|
|
267
|
+
},
|
|
268
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-format-bold" })
|
|
322
269
|
});
|
|
323
|
-
return /* @__PURE__ */ e(
|
|
324
|
-
"button",
|
|
325
|
-
{
|
|
326
|
-
title: "Bold",
|
|
327
|
-
className: a.wuContentEditorAction,
|
|
328
|
-
"data-active": o.bold,
|
|
329
|
-
onClick: (n) => {
|
|
330
|
-
n.preventDefault(), t.chain().focus().toggleBold().run();
|
|
331
|
-
},
|
|
332
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-format-bold" })
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
270
|
}, zt = () => {
|
|
336
|
-
const { editor: t } =
|
|
337
|
-
return /* @__PURE__ */ e(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
{
|
|
347
|
-
|
|
348
|
-
className: a.wuContentEditorAction,
|
|
349
|
-
onClick: (i) => {
|
|
350
|
-
i.preventDefault(), n.event();
|
|
351
|
-
},
|
|
352
|
-
children: /* @__PURE__ */ e(f, { icon: n.icon })
|
|
271
|
+
const { editor: t } = p();
|
|
272
|
+
return /* @__PURE__ */ e(x, { children: [{
|
|
273
|
+
id: "clear",
|
|
274
|
+
icon: "wm-format-clear",
|
|
275
|
+
event: () => t.chain().focus().clearNodes().unsetAllMarks().run(),
|
|
276
|
+
tooltip: "Clear Formatting"
|
|
277
|
+
}].map((o) => /* @__PURE__ */ e("button", {
|
|
278
|
+
type: "button",
|
|
279
|
+
title: o.tooltip,
|
|
280
|
+
className: a.wuContentEditorAction,
|
|
281
|
+
onClick: (n) => {
|
|
282
|
+
n.preventDefault(), o.event();
|
|
353
283
|
},
|
|
354
|
-
|
|
355
|
-
)) });
|
|
356
|
-
},
|
|
357
|
-
const { editor: t } =
|
|
284
|
+
children: /* @__PURE__ */ e(h, { icon: o.icon })
|
|
285
|
+
}, o.id)) });
|
|
286
|
+
}, Mt = () => {
|
|
287
|
+
const { editor: t } = p(), o = f({
|
|
358
288
|
editor: t,
|
|
359
|
-
selector: (n) => ({
|
|
360
|
-
code: n.editor.isActive("code")
|
|
361
|
-
})
|
|
289
|
+
selector: (n) => ({ code: n.editor.isActive("code") })
|
|
362
290
|
});
|
|
363
|
-
return /* @__PURE__ */ e(
|
|
364
|
-
"button",
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
)
|
|
375
|
-
}, Mt = () => {
|
|
376
|
-
const { editor: t } = g(), o = p({
|
|
291
|
+
return /* @__PURE__ */ e("button", {
|
|
292
|
+
type: "button",
|
|
293
|
+
className: a.wuContentEditorAction,
|
|
294
|
+
"data-active": o.code,
|
|
295
|
+
title: "Code line",
|
|
296
|
+
onMouseDown: (n) => {
|
|
297
|
+
n.preventDefault(), t.chain().focus().toggleCode().run();
|
|
298
|
+
},
|
|
299
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-code" })
|
|
300
|
+
});
|
|
301
|
+
}, Wt = () => {
|
|
302
|
+
const { editor: t } = p(), o = f({
|
|
377
303
|
editor: t,
|
|
378
|
-
selector: (
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
304
|
+
selector: (l) => ({
|
|
305
|
+
isImage: l.editor?.isActive("image"),
|
|
306
|
+
imageAttrs: l.editor?.getAttributes("image")
|
|
307
|
+
})
|
|
308
|
+
}), [n, i] = m.useState(o.imageAttrs.src || ""), [r, u] = m.useState(o.imageAttrs.alt || ""), c = () => {
|
|
309
|
+
t.chain().focus().setImage({
|
|
310
|
+
src: n,
|
|
311
|
+
alt: r
|
|
312
|
+
}).run();
|
|
387
313
|
};
|
|
388
|
-
return /* @__PURE__ */ v(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
/* @__PURE__ */ v(R, { children: [
|
|
424
|
-
/* @__PURE__ */ e(x, { variant: "secondary", children: "Cancel" }),
|
|
425
|
-
/* @__PURE__ */ e(x, { onClick: u, disabled: !n, children: "Save" })
|
|
426
|
-
] })
|
|
427
|
-
]
|
|
428
|
-
}
|
|
429
|
-
);
|
|
314
|
+
return /* @__PURE__ */ v(H, {
|
|
315
|
+
Trigger: /* @__PURE__ */ e("button", {
|
|
316
|
+
type: "button",
|
|
317
|
+
className: a.wuContentEditorAction,
|
|
318
|
+
"data-active": o.isImage,
|
|
319
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-image" })
|
|
320
|
+
}),
|
|
321
|
+
maxWidth: "400px",
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ e(z, { style: { display: "none" } }),
|
|
324
|
+
/* @__PURE__ */ v(D, {
|
|
325
|
+
className: a.wuContentEditorModal,
|
|
326
|
+
children: [/* @__PURE__ */ e(F, {
|
|
327
|
+
Label: "Image URL",
|
|
328
|
+
type: "url",
|
|
329
|
+
value: n,
|
|
330
|
+
onChange: (l) => i(l.target.value),
|
|
331
|
+
required: !0
|
|
332
|
+
}), /* @__PURE__ */ e(F, {
|
|
333
|
+
Label: "Alt Text",
|
|
334
|
+
type: "text",
|
|
335
|
+
value: r,
|
|
336
|
+
onChange: (l) => u(l.target.value)
|
|
337
|
+
})]
|
|
338
|
+
}),
|
|
339
|
+
/* @__PURE__ */ v(R, { children: [/* @__PURE__ */ e(_, {
|
|
340
|
+
variant: "secondary",
|
|
341
|
+
children: "Cancel"
|
|
342
|
+
}), /* @__PURE__ */ e(_, {
|
|
343
|
+
onClick: c,
|
|
344
|
+
disabled: !n,
|
|
345
|
+
children: "Save"
|
|
346
|
+
})] })
|
|
347
|
+
]
|
|
348
|
+
});
|
|
430
349
|
}, Ot = () => {
|
|
431
|
-
const { editor: t } =
|
|
350
|
+
const { editor: t } = p(), o = f({
|
|
432
351
|
editor: t,
|
|
433
|
-
selector: (
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
}), [n, i] = h.useState(o.linkAttrs.href || ""), [s, l] = h.useState(o.linkAttrs.alt || ""), u = () => {
|
|
352
|
+
selector: (s) => ({
|
|
353
|
+
isLink: s.editor?.isActive("link"),
|
|
354
|
+
linkAttrs: s.editor?.getAttributes("link")
|
|
355
|
+
})
|
|
356
|
+
}), [n, i] = m.useState(o.linkAttrs.href || ""), [r, u] = m.useState(o.linkAttrs.alt || ""), c = () => {
|
|
441
357
|
t.chain().focus().insertContent({
|
|
442
358
|
type: "text",
|
|
443
|
-
text:
|
|
444
|
-
marks: [{
|
|
359
|
+
text: r || n,
|
|
360
|
+
marks: [{
|
|
361
|
+
type: "link",
|
|
362
|
+
attrs: { href: n }
|
|
363
|
+
}]
|
|
445
364
|
}).run();
|
|
446
|
-
},
|
|
447
|
-
const { $from:
|
|
448
|
-
let
|
|
449
|
-
for (;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
365
|
+
}, l = () => {
|
|
366
|
+
const { $from: s } = t.state.selection, C = s.parent.textContent, k = s.parentOffset;
|
|
367
|
+
let b = k, w = k;
|
|
368
|
+
for (; b > 0 && !/\s/.test(C[b - 1]); ) b--;
|
|
369
|
+
for (; w < C.length && !/\s/.test(C[w]); ) w++;
|
|
370
|
+
const E = s.start(), A = E + b, y = E + w, g = C.slice(b, w);
|
|
371
|
+
t.commands.setTextSelection({
|
|
372
|
+
from: A,
|
|
373
|
+
to: y
|
|
374
|
+
}), i(o.linkAttrs.href || ""), u(g || o.linkAttrs.alt || "");
|
|
455
375
|
};
|
|
456
|
-
return /* @__PURE__ */ v(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
/* @__PURE__ */ e(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
onClick: () => t.chain().focus().unsetLink().run(),
|
|
498
|
-
variant: "secondary",
|
|
499
|
-
children: "Remove"
|
|
500
|
-
}
|
|
501
|
-
),
|
|
502
|
-
/* @__PURE__ */ e(x, { onClick: u, disabled: !n, children: "Save" })
|
|
503
|
-
] })
|
|
504
|
-
]
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
}, Bt = () => {
|
|
508
|
-
const { editor: t } = g(), o = p({
|
|
376
|
+
return /* @__PURE__ */ v(H, {
|
|
377
|
+
Trigger: /* @__PURE__ */ e("button", {
|
|
378
|
+
type: "button",
|
|
379
|
+
title: "Link",
|
|
380
|
+
className: a.wuContentEditorAction,
|
|
381
|
+
"data-active": o.isLink,
|
|
382
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-link" })
|
|
383
|
+
}),
|
|
384
|
+
maxWidth: "400px",
|
|
385
|
+
onOpenChange: (s) => s && l(),
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ e(z, { style: { display: "none" } }),
|
|
388
|
+
/* @__PURE__ */ v(D, {
|
|
389
|
+
className: a.wuContentEditorModal,
|
|
390
|
+
children: [/* @__PURE__ */ e(F, {
|
|
391
|
+
Label: "Link",
|
|
392
|
+
type: "url",
|
|
393
|
+
value: n,
|
|
394
|
+
onChange: (s) => i(s.target.value),
|
|
395
|
+
required: !0
|
|
396
|
+
}), /* @__PURE__ */ e(F, {
|
|
397
|
+
Label: "Text to display",
|
|
398
|
+
type: "text",
|
|
399
|
+
value: r,
|
|
400
|
+
onChange: (s) => u(s.target.value)
|
|
401
|
+
})]
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ v(R, { children: [o.isLink && /* @__PURE__ */ e(_, {
|
|
404
|
+
color: "error",
|
|
405
|
+
onClick: () => t.chain().focus().unsetLink().run(),
|
|
406
|
+
variant: "secondary",
|
|
407
|
+
children: "Remove"
|
|
408
|
+
}), /* @__PURE__ */ e(_, {
|
|
409
|
+
onClick: c,
|
|
410
|
+
disabled: !n,
|
|
411
|
+
children: "Save"
|
|
412
|
+
})] })
|
|
413
|
+
]
|
|
414
|
+
});
|
|
415
|
+
}, Pt = () => {
|
|
416
|
+
const { editor: t } = p(), o = f({
|
|
509
417
|
editor: t,
|
|
510
|
-
selector: (
|
|
511
|
-
isTable:
|
|
512
|
-
tableAttrs:
|
|
418
|
+
selector: (l) => ({
|
|
419
|
+
isTable: l.editor.isActive("table"),
|
|
420
|
+
tableAttrs: l.editor.getAttributes("table")
|
|
513
421
|
})
|
|
514
|
-
}), [n, i] =
|
|
515
|
-
|
|
516
|
-
t.chain().focus().insertTable({
|
|
422
|
+
}), [n, i] = N(!1), r = Y(null), u = O(() => {
|
|
423
|
+
r.current = setTimeout(() => {
|
|
424
|
+
t.chain().focus().insertTable({
|
|
425
|
+
rows: 2,
|
|
426
|
+
cols: 4,
|
|
427
|
+
withHeaderRow: n
|
|
428
|
+
}).run();
|
|
517
429
|
}, 100);
|
|
518
|
-
}, [t, n]),
|
|
519
|
-
i((
|
|
430
|
+
}, [t, n]), c = O(() => {
|
|
431
|
+
i((l) => !l), r.current = setTimeout(() => {
|
|
520
432
|
t.chain().focus().toggleHeaderRow().run();
|
|
521
433
|
}, 100);
|
|
522
|
-
}, [t])
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
text: "Delete Column",
|
|
545
|
-
icon: "wm-delete",
|
|
546
|
-
event: () => t.chain().focus().deleteColumn().run()
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
text: "Delete Row",
|
|
550
|
-
icon: "wm-delete",
|
|
551
|
-
event: () => t.chain().focus().deleteRow().run()
|
|
552
|
-
}
|
|
553
|
-
];
|
|
554
|
-
return o.isTable ? /* @__PURE__ */ v(
|
|
555
|
-
D,
|
|
556
|
-
{
|
|
557
|
-
Trigger: /* @__PURE__ */ e(
|
|
558
|
-
"button",
|
|
559
|
-
{
|
|
560
|
-
className: a.wuContentEditorAction,
|
|
561
|
-
"data-active": o.isTable,
|
|
562
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-table" })
|
|
563
|
-
}
|
|
564
|
-
),
|
|
565
|
-
maxWidth: "320px",
|
|
566
|
-
children: [
|
|
567
|
-
/* @__PURE__ */ e(H, { style: { display: "none" } }),
|
|
568
|
-
/* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
|
|
569
|
-
/* @__PURE__ */ e(
|
|
570
|
-
ht,
|
|
434
|
+
}, [t]);
|
|
435
|
+
return o.isTable ? /* @__PURE__ */ v(H, {
|
|
436
|
+
Trigger: /* @__PURE__ */ e("button", {
|
|
437
|
+
type: "button",
|
|
438
|
+
title: "Table",
|
|
439
|
+
className: a.wuContentEditorAction,
|
|
440
|
+
"data-active": o.isTable,
|
|
441
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-table" })
|
|
442
|
+
}),
|
|
443
|
+
maxWidth: "320px",
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ e(z, { style: { display: "none" } }),
|
|
446
|
+
/* @__PURE__ */ v(D, {
|
|
447
|
+
className: a.wuContentEditorModal,
|
|
448
|
+
children: [/* @__PURE__ */ e(mt, {
|
|
449
|
+
checked: n,
|
|
450
|
+
onClick: c,
|
|
451
|
+
Label: "Title Row",
|
|
452
|
+
labelPosition: "left"
|
|
453
|
+
}), /* @__PURE__ */ e("div", {
|
|
454
|
+
className: a.wuContentEditorTable,
|
|
455
|
+
children: [
|
|
571
456
|
{
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
),
|
|
578
|
-
/* @__PURE__ */ e("div", { className: a.wuContentEditorTable, children: c.map(({ text: r, icon: d, event: w }) => /* @__PURE__ */ e(
|
|
579
|
-
q,
|
|
457
|
+
text: "Column left",
|
|
458
|
+
icon: "wm-add",
|
|
459
|
+
event: () => t.chain().focus().addColumnBefore().run()
|
|
460
|
+
},
|
|
580
461
|
{
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
children: r
|
|
462
|
+
text: "Row above",
|
|
463
|
+
icon: "wm-add",
|
|
464
|
+
event: () => t.chain().focus().addRowBefore().run()
|
|
585
465
|
},
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
466
|
+
{
|
|
467
|
+
text: "Column right",
|
|
468
|
+
icon: "wm-add",
|
|
469
|
+
event: () => t.chain().focus().addColumnAfter().run()
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
text: "Row below",
|
|
473
|
+
icon: "wm-add",
|
|
474
|
+
event: () => t.chain().focus().addRowAfter().run()
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
text: "Delete Column",
|
|
478
|
+
icon: "wm-delete",
|
|
479
|
+
event: () => t.chain().focus().deleteColumn().run()
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
text: "Delete Row",
|
|
483
|
+
icon: "wm-delete",
|
|
484
|
+
event: () => t.chain().focus().deleteRow().run()
|
|
485
|
+
}
|
|
486
|
+
].map(({ text: l, icon: s, event: C }) => /* @__PURE__ */ e(q, {
|
|
487
|
+
onClick: C,
|
|
488
|
+
variant: "secondary",
|
|
489
|
+
Icon: /* @__PURE__ */ e(h, { icon: s }),
|
|
490
|
+
children: l
|
|
491
|
+
}, l))
|
|
492
|
+
})]
|
|
493
|
+
}),
|
|
494
|
+
/* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(_, {
|
|
495
|
+
onClick: () => t.chain().focus().deleteTable().run(),
|
|
496
|
+
variant: "outline",
|
|
497
|
+
color: "error",
|
|
498
|
+
Icon: /* @__PURE__ */ e("span", { className: "wm-delete" }),
|
|
499
|
+
iconPosition: "left",
|
|
500
|
+
children: "Delete Table"
|
|
501
|
+
}) })
|
|
502
|
+
]
|
|
503
|
+
}) : /* @__PURE__ */ e("button", {
|
|
504
|
+
type: "button",
|
|
505
|
+
title: "Table",
|
|
506
|
+
onClick: u,
|
|
507
|
+
className: a.wuContentEditorAction,
|
|
508
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-table" })
|
|
509
|
+
});
|
|
510
|
+
}, Bt = () => {
|
|
511
|
+
const { editor: t, customFonts: o } = p(), n = f({
|
|
612
512
|
editor: t,
|
|
613
|
-
selector: (
|
|
614
|
-
currentFontFamily: u.editor.getAttributes("textStyle").fontFamily || ""
|
|
615
|
-
})
|
|
513
|
+
selector: (c) => ({ currentFontFamily: c.editor.getAttributes("textStyle").fontFamily || "" })
|
|
616
514
|
}), i = [
|
|
617
515
|
"Fira Sans",
|
|
618
516
|
"Inter",
|
|
@@ -620,81 +518,53 @@ const gt = "_wuContentEditor_1kzbo_8", pt = "_wuContentEditorTable_1kzbo_1", wt
|
|
|
620
518
|
"JetBrains Mono",
|
|
621
519
|
"Montserrat",
|
|
622
520
|
...o || []
|
|
623
|
-
], [
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
/* @__PURE__ */ e(
|
|
643
|
-
K,
|
|
644
|
-
{
|
|
645
|
-
align: "start",
|
|
646
|
-
className: a.wuContentEditorDropdown,
|
|
647
|
-
"data-block": !0,
|
|
648
|
-
onCloseAutoFocus: (u) => u.preventDefault(),
|
|
649
|
-
children: i.map((u) => /* @__PURE__ */ e(
|
|
650
|
-
U,
|
|
651
|
-
{
|
|
652
|
-
title: u,
|
|
653
|
-
className: a.wuContentEditorDropdownItem,
|
|
654
|
-
onSelect: () => {
|
|
655
|
-
t.chain().focus().setFontFamily(u).run(), l(u);
|
|
656
|
-
},
|
|
657
|
-
children: u
|
|
658
|
-
},
|
|
659
|
-
u
|
|
660
|
-
))
|
|
661
|
-
}
|
|
662
|
-
)
|
|
663
|
-
] });
|
|
664
|
-
}, Wt = () => {
|
|
665
|
-
const { editor: t } = g(), o = p({
|
|
666
|
-
editor: t,
|
|
667
|
-
selector: (n) => {
|
|
668
|
-
var i;
|
|
669
|
-
return {
|
|
670
|
-
italic: (i = n.editor) == null ? void 0 : i.isActive("italic")
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
return /* @__PURE__ */ e(
|
|
675
|
-
"button",
|
|
676
|
-
{
|
|
677
|
-
title: "Italic",
|
|
678
|
-
className: a.wuContentEditorAction,
|
|
679
|
-
"data-active": o.italic,
|
|
680
|
-
onClick: (n) => {
|
|
681
|
-
n.preventDefault(), t.chain().focus().toggleItalic().run();
|
|
521
|
+
], [r, u] = N(n.currentFontFamily || i[0]);
|
|
522
|
+
return m.useEffect(() => {
|
|
523
|
+
u(n.currentFontFamily?.replace(/"/g, "") || i[0]);
|
|
524
|
+
}, [n.currentFontFamily]), /* @__PURE__ */ v(U, { children: [/* @__PURE__ */ e(K, {
|
|
525
|
+
className: a.wuContentEditorAction,
|
|
526
|
+
"data-active": r !== "Fira Sans",
|
|
527
|
+
style: { fontFamily: r },
|
|
528
|
+
title: r || "Font Family",
|
|
529
|
+
children: r?.[0]
|
|
530
|
+
}), /* @__PURE__ */ e(j, {
|
|
531
|
+
align: "start",
|
|
532
|
+
className: a.wuContentEditorDropdown,
|
|
533
|
+
"data-block": !0,
|
|
534
|
+
onCloseAutoFocus: (c) => c.preventDefault(),
|
|
535
|
+
children: i.map((c) => /* @__PURE__ */ e($, {
|
|
536
|
+
title: c,
|
|
537
|
+
className: a.wuContentEditorDropdownItem,
|
|
538
|
+
onSelect: () => {
|
|
539
|
+
t.chain().focus().setFontFamily(c).run(), u(c);
|
|
682
540
|
},
|
|
683
|
-
children:
|
|
684
|
-
}
|
|
685
|
-
);
|
|
541
|
+
children: c
|
|
542
|
+
}, c))
|
|
543
|
+
})] });
|
|
686
544
|
}, qt = () => {
|
|
687
|
-
const { editor: t } =
|
|
545
|
+
const { editor: t } = p(), o = f({
|
|
688
546
|
editor: t,
|
|
689
|
-
selector: (
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
547
|
+
selector: (n) => ({ italic: n.editor?.isActive("italic") })
|
|
548
|
+
});
|
|
549
|
+
return /* @__PURE__ */ e("button", {
|
|
550
|
+
type: "button",
|
|
551
|
+
title: "Italic",
|
|
552
|
+
className: a.wuContentEditorAction,
|
|
553
|
+
"data-active": o.italic,
|
|
554
|
+
onClick: (n) => {
|
|
555
|
+
n.preventDefault(), t.chain().focus().toggleItalic().run();
|
|
556
|
+
},
|
|
557
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-format-italic" })
|
|
558
|
+
});
|
|
559
|
+
}, Ut = () => {
|
|
560
|
+
const { editor: t } = p(), o = f({
|
|
561
|
+
editor: t,
|
|
562
|
+
selector: (i) => ({
|
|
563
|
+
isUl: i.editor?.isActive("bulletList"),
|
|
564
|
+
isOl: i.editor?.isActive("orderedList"),
|
|
565
|
+
isTodo: i.editor?.isActive("taskList"),
|
|
566
|
+
isList: i.editor?.isActive("bulletList") || i.editor?.isActive("orderedList") || i.editor?.isActive("taskList")
|
|
567
|
+
})
|
|
698
568
|
}), n = [
|
|
699
569
|
{
|
|
700
570
|
id: "ul",
|
|
@@ -718,238 +588,181 @@ const gt = "_wuContentEditor_1kzbo_8", pt = "_wuContentEditorTable_1kzbo_1", wt
|
|
|
718
588
|
tooltip: "To-Do List"
|
|
719
589
|
}
|
|
720
590
|
];
|
|
721
|
-
return /* @__PURE__ */ e(
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const { editor: t } =
|
|
591
|
+
return /* @__PURE__ */ e(M, { action: {
|
|
592
|
+
id: "style",
|
|
593
|
+
active: o.isList,
|
|
594
|
+
icon: "wm-format-paragraph",
|
|
595
|
+
items: n
|
|
596
|
+
} });
|
|
597
|
+
}, jt = [
|
|
598
|
+
"e",
|
|
599
|
+
"E",
|
|
600
|
+
"+",
|
|
601
|
+
"-"
|
|
602
|
+
], P = 1, $t = () => {
|
|
603
|
+
const { editor: t } = p(), [o, n] = N(16), i = f({
|
|
734
604
|
editor: t,
|
|
735
|
-
selector: (
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}, u = (c) => {
|
|
744
|
-
jt.includes(c.key) ? c.preventDefault() : c.key === "Enter" && s(o);
|
|
605
|
+
selector: (l) => ({ fontSize: l.editor.getAttributes("textStyle").fontSize })
|
|
606
|
+
}), r = (l) => {
|
|
607
|
+
t.chain().focus().setFontSize(l + "px").run();
|
|
608
|
+
}, u = (l) => {
|
|
609
|
+
const s = Math.max(P, l);
|
|
610
|
+
n(s), r(s);
|
|
611
|
+
}, c = (l) => {
|
|
612
|
+
jt.includes(l.key) ? l.preventDefault() : l.key === "Enter" && r(o);
|
|
745
613
|
};
|
|
746
|
-
return
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
"button",
|
|
752
|
-
|
|
614
|
+
return m.useEffect(() => {
|
|
615
|
+
n(Number(i.fontSize?.replace("px", "")) || 16);
|
|
616
|
+
}, [i.fontSize]), /* @__PURE__ */ v("div", {
|
|
617
|
+
className: a.wuContentEditorFontSize,
|
|
618
|
+
children: [
|
|
619
|
+
/* @__PURE__ */ e("button", {
|
|
620
|
+
type: "button",
|
|
753
621
|
className: a.wuContentEditorAction,
|
|
754
|
-
onClick: () =>
|
|
622
|
+
onClick: () => u(o - 1),
|
|
755
623
|
disabled: o <= P,
|
|
756
624
|
children: "−"
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/* @__PURE__ */ e(
|
|
760
|
-
"input",
|
|
761
|
-
{
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ e("input", {
|
|
762
627
|
type: "number",
|
|
763
628
|
inputMode: "numeric",
|
|
764
629
|
pattern: "[0-9]*",
|
|
765
630
|
value: o,
|
|
766
|
-
onKeyDown:
|
|
767
|
-
onChange: (
|
|
768
|
-
onBlur: () =>
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
"button",
|
|
773
|
-
{
|
|
631
|
+
onKeyDown: c,
|
|
632
|
+
onChange: (l) => n(l.target.valueAsNumber),
|
|
633
|
+
onBlur: () => r(o)
|
|
634
|
+
}),
|
|
635
|
+
/* @__PURE__ */ e("button", {
|
|
636
|
+
type: "button",
|
|
774
637
|
className: a.wuContentEditorAction,
|
|
775
|
-
onClick: () =>
|
|
638
|
+
onClick: () => u(o + 1),
|
|
776
639
|
disabled: o >= 128,
|
|
777
640
|
children: "+"
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
641
|
+
})
|
|
642
|
+
]
|
|
643
|
+
});
|
|
781
644
|
}, Kt = () => {
|
|
782
|
-
const { editor: t } =
|
|
645
|
+
const { editor: t } = p(), o = f({
|
|
783
646
|
editor: t,
|
|
784
|
-
selector: (n) => {
|
|
785
|
-
var i;
|
|
786
|
-
return {
|
|
787
|
-
strikethrough: (i = n.editor) == null ? void 0 : i.isActive("strike")
|
|
788
|
-
};
|
|
789
|
-
}
|
|
647
|
+
selector: (n) => ({ strikethrough: n.editor?.isActive("strike") })
|
|
790
648
|
});
|
|
791
|
-
return /* @__PURE__ */ e(
|
|
792
|
-
"button",
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-format-strikethrough" })
|
|
801
|
-
}
|
|
802
|
-
);
|
|
803
|
-
}, Ut = () => {
|
|
804
|
-
const { editor: t } = g(), o = p({
|
|
805
|
-
editor: t,
|
|
806
|
-
selector: (n) => {
|
|
807
|
-
var i;
|
|
808
|
-
return {
|
|
809
|
-
subscript: (i = n.editor) == null ? void 0 : i.isActive("subscript")
|
|
810
|
-
};
|
|
811
|
-
}
|
|
649
|
+
return /* @__PURE__ */ e("button", {
|
|
650
|
+
type: "button",
|
|
651
|
+
title: "strikethrough",
|
|
652
|
+
className: a.wuContentEditorAction,
|
|
653
|
+
"data-active": o.strikethrough,
|
|
654
|
+
onClick: (n) => {
|
|
655
|
+
n.preventDefault(), t.chain().focus().toggleStrike().run();
|
|
656
|
+
},
|
|
657
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-format-strikethrough" })
|
|
812
658
|
});
|
|
813
|
-
return /* @__PURE__ */ e(
|
|
814
|
-
"button",
|
|
815
|
-
{
|
|
816
|
-
title: "Subscript",
|
|
817
|
-
className: a.wuContentEditorAction,
|
|
818
|
-
"data-active": o.subscript,
|
|
819
|
-
onClick: (n) => {
|
|
820
|
-
n.preventDefault(), t.chain().focus().toggleSubscript().run();
|
|
821
|
-
},
|
|
822
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-subscript" })
|
|
823
|
-
}
|
|
824
|
-
);
|
|
825
659
|
}, Jt = () => {
|
|
826
|
-
const { editor: t } =
|
|
660
|
+
const { editor: t } = p(), o = f({
|
|
827
661
|
editor: t,
|
|
828
|
-
selector: (n) => {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
662
|
+
selector: (n) => ({ subscript: n.editor?.isActive("subscript") })
|
|
663
|
+
});
|
|
664
|
+
return /* @__PURE__ */ e("button", {
|
|
665
|
+
type: "button",
|
|
666
|
+
title: "Subscript",
|
|
667
|
+
className: a.wuContentEditorAction,
|
|
668
|
+
"data-active": o.subscript,
|
|
669
|
+
onClick: (n) => {
|
|
670
|
+
n.preventDefault(), t.chain().focus().toggleSubscript().run();
|
|
671
|
+
},
|
|
672
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-subscript" })
|
|
834
673
|
});
|
|
835
|
-
return /* @__PURE__ */ e(
|
|
836
|
-
"button",
|
|
837
|
-
{
|
|
838
|
-
title: "Superscript",
|
|
839
|
-
className: a.wuContentEditorAction,
|
|
840
|
-
"data-active": o.superscript,
|
|
841
|
-
onClick: (n) => {
|
|
842
|
-
n.preventDefault(), t.chain().focus().toggleSuperscript().run();
|
|
843
|
-
},
|
|
844
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-superscript" })
|
|
845
|
-
}
|
|
846
|
-
);
|
|
847
674
|
}, Gt = () => {
|
|
848
|
-
const { editor: t } =
|
|
675
|
+
const { editor: t } = p(), o = f({
|
|
849
676
|
editor: t,
|
|
850
|
-
selector: ({
|
|
851
|
-
|
|
852
|
-
|
|
677
|
+
selector: (n) => ({ superscript: n.editor?.isActive("superscript") })
|
|
678
|
+
});
|
|
679
|
+
return /* @__PURE__ */ e("button", {
|
|
680
|
+
type: "button",
|
|
681
|
+
title: "Superscript",
|
|
682
|
+
className: a.wuContentEditorAction,
|
|
683
|
+
"data-active": o.superscript,
|
|
684
|
+
onClick: (n) => {
|
|
685
|
+
n.preventDefault(), t.chain().focus().toggleSuperscript().run();
|
|
686
|
+
},
|
|
687
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-superscript" })
|
|
853
688
|
});
|
|
854
|
-
return /* @__PURE__ */ v(
|
|
855
|
-
"label",
|
|
856
|
-
{
|
|
857
|
-
className: a.wuContentEditorAction,
|
|
858
|
-
htmlFor: "text-color",
|
|
859
|
-
title: "Text Color",
|
|
860
|
-
children: [
|
|
861
|
-
/* @__PURE__ */ e(
|
|
862
|
-
f,
|
|
863
|
-
{
|
|
864
|
-
icon: "wm-format-color-text",
|
|
865
|
-
className: a.bgColorCursorPointer,
|
|
866
|
-
style: { color: o.textColor }
|
|
867
|
-
}
|
|
868
|
-
),
|
|
869
|
-
/* @__PURE__ */ e(
|
|
870
|
-
"input",
|
|
871
|
-
{
|
|
872
|
-
type: "color",
|
|
873
|
-
className: a.bgColorHiddenInput,
|
|
874
|
-
id: "text-color",
|
|
875
|
-
defaultValue: "#545E6B",
|
|
876
|
-
onChange: (n) => t.chain().focus().setColor(n.target.value).run()
|
|
877
|
-
}
|
|
878
|
-
)
|
|
879
|
-
]
|
|
880
|
-
}
|
|
881
|
-
);
|
|
882
689
|
}, Vt = () => {
|
|
883
|
-
const { editor: t } =
|
|
690
|
+
const { editor: t } = p(), o = f({
|
|
884
691
|
editor: t,
|
|
885
|
-
selector: (n) => {
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
692
|
+
selector: ({ editor: n }) => ({ textColor: n.getAttributes("textStyle").color })
|
|
693
|
+
});
|
|
694
|
+
return /* @__PURE__ */ v("label", {
|
|
695
|
+
className: a.wuContentEditorAction,
|
|
696
|
+
htmlFor: "text-color",
|
|
697
|
+
title: "Text Color",
|
|
698
|
+
children: [/* @__PURE__ */ e(h, {
|
|
699
|
+
icon: "wm-format-color-text",
|
|
700
|
+
className: a.bgColorCursorPointer,
|
|
701
|
+
style: { color: o.textColor }
|
|
702
|
+
}), /* @__PURE__ */ e("input", {
|
|
703
|
+
type: "color",
|
|
704
|
+
className: a.bgColorHiddenInput,
|
|
705
|
+
id: "text-color",
|
|
706
|
+
defaultValue: "#545E6B",
|
|
707
|
+
onChange: (n) => t.chain().focus().setColor(n.target.value).run()
|
|
708
|
+
})]
|
|
709
|
+
});
|
|
710
|
+
}, Xt = () => {
|
|
711
|
+
const { editor: t } = p(), o = f({
|
|
712
|
+
editor: t,
|
|
713
|
+
selector: (n) => ({ underline: n.editor?.isActive("underline") })
|
|
714
|
+
});
|
|
715
|
+
return /* @__PURE__ */ e("button", {
|
|
716
|
+
type: "button",
|
|
717
|
+
title: "Underline",
|
|
718
|
+
className: a.wuContentEditorAction,
|
|
719
|
+
"data-active": o.underline,
|
|
720
|
+
onClick: (n) => {
|
|
721
|
+
n.preventDefault(), t.chain().focus().toggleUnderline().run();
|
|
722
|
+
},
|
|
723
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-format-underlined" })
|
|
891
724
|
});
|
|
892
|
-
return /* @__PURE__ */ e(
|
|
893
|
-
"button",
|
|
894
|
-
{
|
|
895
|
-
title: "Underline",
|
|
896
|
-
className: a.wuContentEditorAction,
|
|
897
|
-
"data-active": o.underline,
|
|
898
|
-
onClick: (n) => {
|
|
899
|
-
n.preventDefault(), t.chain().focus().toggleUnderline().run();
|
|
900
|
-
},
|
|
901
|
-
children: /* @__PURE__ */ e(f, { icon: "wm-format-underlined" })
|
|
902
|
-
}
|
|
903
|
-
);
|
|
904
725
|
};
|
|
905
|
-
function
|
|
906
|
-
const { isHtml: t, setIsHtml: o } =
|
|
907
|
-
return /* @__PURE__ */ e(
|
|
908
|
-
"button",
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
);
|
|
726
|
+
function Yt() {
|
|
727
|
+
const { isHtml: t, setIsHtml: o } = p();
|
|
728
|
+
return /* @__PURE__ */ e("button", {
|
|
729
|
+
type: "button",
|
|
730
|
+
title: "HTML source",
|
|
731
|
+
className: a.wuContentEditorAction,
|
|
732
|
+
"data-active": t,
|
|
733
|
+
onClick: (n) => {
|
|
734
|
+
n.preventDefault(), o(!t);
|
|
735
|
+
},
|
|
736
|
+
children: /* @__PURE__ */ e(h, { icon: "wm-html" })
|
|
737
|
+
});
|
|
919
738
|
}
|
|
920
|
-
|
|
921
|
-
block: /* @__PURE__ */ e(
|
|
922
|
-
fontFamily: /* @__PURE__ */ e(
|
|
739
|
+
var B = {
|
|
740
|
+
block: /* @__PURE__ */ e(Ht, {}),
|
|
741
|
+
fontFamily: /* @__PURE__ */ e(Bt, {}),
|
|
923
742
|
fontSize: /* @__PURE__ */ e($t, {}),
|
|
924
|
-
bold: /* @__PURE__ */ e(
|
|
925
|
-
italic: /* @__PURE__ */ e(
|
|
926
|
-
underline: /* @__PURE__ */ e(
|
|
743
|
+
bold: /* @__PURE__ */ e(Rt, {}),
|
|
744
|
+
italic: /* @__PURE__ */ e(qt, {}),
|
|
745
|
+
underline: /* @__PURE__ */ e(Xt, {}),
|
|
927
746
|
strike: /* @__PURE__ */ e(Kt, {}),
|
|
928
|
-
color: /* @__PURE__ */ e(
|
|
747
|
+
color: /* @__PURE__ */ e(Vt, {}),
|
|
929
748
|
bgColor: /* @__PURE__ */ e(Nt, {}),
|
|
930
|
-
list: /* @__PURE__ */ e(
|
|
931
|
-
alignment: /* @__PURE__ */ e(
|
|
932
|
-
image: /* @__PURE__ */ e(
|
|
749
|
+
list: /* @__PURE__ */ e(Ut, {}),
|
|
750
|
+
alignment: /* @__PURE__ */ e(It, {}),
|
|
751
|
+
image: /* @__PURE__ */ e(Wt, {}),
|
|
933
752
|
link: /* @__PURE__ */ e(Ot, {}),
|
|
934
|
-
table: /* @__PURE__ */ e(
|
|
753
|
+
table: /* @__PURE__ */ e(Pt, {}),
|
|
935
754
|
blockquote: /* @__PURE__ */ e(Dt, {}),
|
|
936
|
-
superscript: /* @__PURE__ */ e(
|
|
937
|
-
subscript: /* @__PURE__ */ e(
|
|
938
|
-
codeline: /* @__PURE__ */ e(
|
|
755
|
+
superscript: /* @__PURE__ */ e(Gt, {}),
|
|
756
|
+
subscript: /* @__PURE__ */ e(Jt, {}),
|
|
757
|
+
codeline: /* @__PURE__ */ e(Mt, {}),
|
|
939
758
|
clear: /* @__PURE__ */ e(zt, {}),
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
background: "rgb(var(--wu-gray-40))"
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
),
|
|
951
|
-
html: /* @__PURE__ */ e(Xt, {})
|
|
952
|
-
}, Yt = [
|
|
759
|
+
"|": /* @__PURE__ */ e("div", { style: {
|
|
760
|
+
height: 16,
|
|
761
|
+
width: 1,
|
|
762
|
+
background: "rgb(var(--wu-gray-40))"
|
|
763
|
+
} }),
|
|
764
|
+
html: /* @__PURE__ */ e(Yt, {})
|
|
765
|
+
}, Zt = [
|
|
953
766
|
"block",
|
|
954
767
|
"fontFamily",
|
|
955
768
|
"|",
|
|
@@ -977,31 +790,26 @@ const W = {
|
|
|
977
790
|
"|",
|
|
978
791
|
"html",
|
|
979
792
|
"clear"
|
|
980
|
-
],
|
|
981
|
-
const {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
children:
|
|
985
|
-
items: s = Yt,
|
|
986
|
-
isHtml: l,
|
|
987
|
-
setIsHtml: u,
|
|
988
|
-
...c
|
|
989
|
-
} = t;
|
|
990
|
-
return /* @__PURE__ */ e("div", { ...c, children: /* @__PURE__ */ v(
|
|
991
|
-
Lt,
|
|
992
|
-
{
|
|
793
|
+
], Qt = (t) => {
|
|
794
|
+
const { editor: o, customFonts: n, children: i, items: r = Zt, isHtml: u, setIsHtml: c, ...l } = t;
|
|
795
|
+
return /* @__PURE__ */ e("div", {
|
|
796
|
+
...l,
|
|
797
|
+
children: /* @__PURE__ */ v(Lt, {
|
|
993
798
|
editor: o,
|
|
994
799
|
customFonts: n,
|
|
995
|
-
isHtml:
|
|
996
|
-
setIsHtml:
|
|
997
|
-
children: [
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
},
|
|
1004
|
-
|
|
800
|
+
isHtml: u,
|
|
801
|
+
setIsHtml: c,
|
|
802
|
+
children: [r.map((s, C) => /* @__PURE__ */ e(x, { children: u && s !== "html" ? /* @__PURE__ */ e("span", {
|
|
803
|
+
style: {
|
|
804
|
+
pointerEvents: "none",
|
|
805
|
+
opacity: 0.4
|
|
806
|
+
},
|
|
807
|
+
children: B[s]
|
|
808
|
+
}) : B[s] }, s + C)), i]
|
|
809
|
+
})
|
|
810
|
+
});
|
|
811
|
+
}, W = ht();
|
|
812
|
+
W.setConfig({
|
|
1005
813
|
USE_PROFILES: { html: !0 },
|
|
1006
814
|
ALLOWED_TAGS: [
|
|
1007
815
|
"div",
|
|
@@ -1053,176 +861,134 @@ O.setConfig({
|
|
|
1053
861
|
],
|
|
1054
862
|
ALLOW_DATA_ATTR: !0
|
|
1055
863
|
});
|
|
1056
|
-
|
|
864
|
+
W.addHook("uponSanitizeAttribute", (t, o) => {
|
|
1057
865
|
if (o.attrName === "style") {
|
|
1058
866
|
const n = o.attrValue.toLowerCase();
|
|
1059
867
|
(n.includes("expression") || n.includes("javascript:") || n.includes("url(")) && (o.keepAttr = !1);
|
|
1060
868
|
}
|
|
1061
869
|
});
|
|
1062
870
|
function S(t) {
|
|
1063
|
-
return t ?
|
|
871
|
+
return t ? W.sanitize(t) : "";
|
|
1064
872
|
}
|
|
1065
|
-
|
|
1066
|
-
function
|
|
1067
|
-
return
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
})
|
|
1072
|
-
)), N;
|
|
873
|
+
var I = null;
|
|
874
|
+
function te() {
|
|
875
|
+
return I || (I = import("shiki").then(({ createHighlighter: t }) => t({
|
|
876
|
+
themes: ["github-light"],
|
|
877
|
+
langs: ["html"]
|
|
878
|
+
}))), I;
|
|
1073
879
|
}
|
|
1074
|
-
function
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
});
|
|
1091
|
-
return r(!1), _;
|
|
1092
|
-
} catch (m) {
|
|
1093
|
-
return console.error("Format error:", m), r(!0), C;
|
|
1094
|
-
}
|
|
1095
|
-
},
|
|
1096
|
-
[]
|
|
1097
|
-
), y = h.useCallback((C) => {
|
|
1098
|
-
Qt().then((m) => {
|
|
1099
|
-
const T = m.codeToHtml(C || " ", {
|
|
880
|
+
function ee({ defaultValue: t, onUpdate: o, readonly: n }) {
|
|
881
|
+
const [i, r] = m.useState(t || ""), [u, c] = m.useState(""), [l, s] = m.useState(!1), [C, k] = m.useState(!1), b = m.useRef(!1), w = m.useCallback(async (g) => {
|
|
882
|
+
try {
|
|
883
|
+
const [{ format: d }, { default: T }] = await Promise.all([import("../../standalone-DSxjHhed.js"), import("../../html-Ccb8eKR4.js")]), L = await d(g, {
|
|
884
|
+
parser: "html",
|
|
885
|
+
plugins: [T],
|
|
886
|
+
htmlWhitespaceSensitivity: "css",
|
|
887
|
+
printWidth: 80
|
|
888
|
+
});
|
|
889
|
+
return s(!1), L;
|
|
890
|
+
} catch (d) {
|
|
891
|
+
return console.error("Format error:", d), s(!0), g;
|
|
892
|
+
}
|
|
893
|
+
}, []), E = m.useCallback((g) => {
|
|
894
|
+
te().then((d) => {
|
|
895
|
+
c(d.codeToHtml(g || " ", {
|
|
1100
896
|
lang: "html",
|
|
1101
897
|
theme: "github-light"
|
|
1102
|
-
});
|
|
1103
|
-
|
|
1104
|
-
}).catch((m) => console.error("Highlight error:", m));
|
|
898
|
+
}));
|
|
899
|
+
}).catch((d) => console.error("Highlight error:", d));
|
|
1105
900
|
}, []);
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
}, [
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
901
|
+
m.useEffect(() => {
|
|
902
|
+
E(i), o?.(S(i));
|
|
903
|
+
}, [
|
|
904
|
+
i,
|
|
905
|
+
E,
|
|
906
|
+
o
|
|
907
|
+
]), m.useEffect(() => {
|
|
908
|
+
b.current || !t || (b.current = !0, w(t).then(r));
|
|
909
|
+
}, [t, w]);
|
|
910
|
+
const A = async (g) => {
|
|
911
|
+
g.preventDefault(), k(!0), r(await w(i)), k(!1);
|
|
912
|
+
}, y = (g) => {
|
|
913
|
+
if (g.key === "Tab") {
|
|
914
|
+
g.preventDefault();
|
|
915
|
+
const d = g.currentTarget, T = d.selectionStart, L = d.selectionEnd;
|
|
916
|
+
r(i.substring(0, T) + " " + i.substring(L)), requestAnimationFrame(() => {
|
|
917
|
+
d.selectionStart = T + 2, d.selectionEnd = T + 2;
|
|
1121
918
|
});
|
|
1122
919
|
}
|
|
1123
920
|
};
|
|
1124
|
-
return /* @__PURE__ */ e(
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
)
|
|
1152
|
-
] }) }) });
|
|
921
|
+
return /* @__PURE__ */ e(x, { children: C ? /* @__PURE__ */ e(x, { children: "Formatting..." }) : /* @__PURE__ */ e("div", {
|
|
922
|
+
className: a.wuContentEditor,
|
|
923
|
+
children: /* @__PURE__ */ v("div", {
|
|
924
|
+
className: a.wuCodeEditor,
|
|
925
|
+
children: [
|
|
926
|
+
/* @__PURE__ */ e(q, {
|
|
927
|
+
variant: "iconOnly",
|
|
928
|
+
Icon: /* @__PURE__ */ e(h, { icon: "wm-data-object" }),
|
|
929
|
+
onClick: A,
|
|
930
|
+
className: a.wuFormatCode,
|
|
931
|
+
style: { color: l ? "red" : "" }
|
|
932
|
+
}),
|
|
933
|
+
/* @__PURE__ */ e("div", {
|
|
934
|
+
dangerouslySetInnerHTML: { __html: u },
|
|
935
|
+
className: a.wuCodeEditorPreview
|
|
936
|
+
}),
|
|
937
|
+
/* @__PURE__ */ e("textarea", {
|
|
938
|
+
value: i,
|
|
939
|
+
onChange: (g) => r(g.target.value),
|
|
940
|
+
onKeyDown: y,
|
|
941
|
+
className: a.wuCodeEditorInput,
|
|
942
|
+
disabled: n
|
|
943
|
+
})
|
|
944
|
+
]
|
|
945
|
+
})
|
|
946
|
+
}) });
|
|
1153
947
|
}
|
|
1154
|
-
function
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
className: n,
|
|
1158
|
-
toolbarPosition: i = "top",
|
|
1159
|
-
customToolbarChildren: s,
|
|
1160
|
-
toolbarItems: l,
|
|
1161
|
-
hideToolbar: u,
|
|
1162
|
-
readonly: c,
|
|
1163
|
-
customFonts: r,
|
|
1164
|
-
isHtml: d,
|
|
1165
|
-
setIsHtml: w,
|
|
1166
|
-
...k
|
|
1167
|
-
}) {
|
|
1168
|
-
const [A, y] = h.useState(d ?? !1), E = h.useRef(t || ""), b = V({
|
|
1169
|
-
editable: !c,
|
|
948
|
+
function ve({ defaultValue: t, onUpdate: o, className: n, toolbarPosition: i = "top", customToolbarChildren: r, toolbarItems: u, hideToolbar: c, readonly: l, customFonts: s, isHtml: C, setIsHtml: k, ...b }) {
|
|
949
|
+
const [w, E] = m.useState(C ?? !1), A = m.useRef(t || ""), y = V({
|
|
950
|
+
editable: !l,
|
|
1170
951
|
extensions: Ft,
|
|
1171
952
|
content: S(t || ""),
|
|
1172
|
-
onUpdate: ({ editor:
|
|
1173
|
-
o && o(S(
|
|
953
|
+
onUpdate: ({ editor: d }) => {
|
|
954
|
+
o && o(S(d.getHTML()));
|
|
1174
955
|
}
|
|
1175
|
-
}),
|
|
1176
|
-
|
|
956
|
+
}), g = (d) => {
|
|
957
|
+
d ? A.current = y?.getHTML() ?? "" : y?.commands.setContent(S(A.current)), o && o(S(A.current)), E(d), k?.(d);
|
|
1177
958
|
};
|
|
1178
|
-
return /* @__PURE__ */ v(
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
959
|
+
return /* @__PURE__ */ v("div", {
|
|
960
|
+
className: X(a.wuContentEditorContainer, n),
|
|
961
|
+
"data-position": i,
|
|
962
|
+
"data-slot": "wu-content-editor-container",
|
|
963
|
+
onClick: () => {
|
|
964
|
+
w || y?.chain().focus().run();
|
|
965
|
+
},
|
|
966
|
+
...b,
|
|
967
|
+
children: [!c && /* @__PURE__ */ e(Qt, {
|
|
968
|
+
editor: y,
|
|
969
|
+
customFonts: s,
|
|
970
|
+
className: a.wuContentEditorToolbar,
|
|
971
|
+
items: u,
|
|
972
|
+
isHtml: w,
|
|
973
|
+
setIsHtml: g,
|
|
974
|
+
"data-slot": "wu-content-editor-toolbar",
|
|
1182
975
|
"data-position": i,
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
976
|
+
children: r
|
|
977
|
+
}), w ? /* @__PURE__ */ e(ee, {
|
|
978
|
+
defaultValue: A.current,
|
|
979
|
+
onUpdate: (d) => {
|
|
980
|
+
A.current = d ?? "", o && o(d ?? "");
|
|
1186
981
|
},
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
isHtml: A,
|
|
1197
|
-
setIsHtml: C,
|
|
1198
|
-
"data-slot": "wu-content-editor-toolbar",
|
|
1199
|
-
"data-position": i,
|
|
1200
|
-
children: s
|
|
1201
|
-
}
|
|
1202
|
-
),
|
|
1203
|
-
A ? /* @__PURE__ */ e(
|
|
1204
|
-
te,
|
|
1205
|
-
{
|
|
1206
|
-
defaultValue: E.current,
|
|
1207
|
-
onUpdate: (m) => {
|
|
1208
|
-
E.current = m ?? "", o && o(m ?? "");
|
|
1209
|
-
},
|
|
1210
|
-
"data-position": i,
|
|
1211
|
-
"data-slot": "wu-content-editor",
|
|
1212
|
-
readonly: c
|
|
1213
|
-
}
|
|
1214
|
-
) : /* @__PURE__ */ e(
|
|
1215
|
-
X,
|
|
1216
|
-
{
|
|
1217
|
-
editor: b,
|
|
1218
|
-
className: a.wuContentEditor,
|
|
1219
|
-
"data-slot": "wu-content-editor"
|
|
1220
|
-
}
|
|
1221
|
-
)
|
|
1222
|
-
]
|
|
1223
|
-
}
|
|
1224
|
-
);
|
|
982
|
+
"data-position": i,
|
|
983
|
+
"data-slot": "wu-content-editor",
|
|
984
|
+
readonly: l
|
|
985
|
+
}) : /* @__PURE__ */ e(G, {
|
|
986
|
+
editor: y,
|
|
987
|
+
className: a.wuContentEditor,
|
|
988
|
+
"data-slot": "wu-content-editor"
|
|
989
|
+
})]
|
|
990
|
+
});
|
|
1225
991
|
}
|
|
1226
992
|
export {
|
|
1227
|
-
|
|
993
|
+
ve as WuContentEditor
|
|
1228
994
|
};
|