@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.
@@ -1,166 +1,134 @@
1
- import { jsx as e, jsxs as v, Fragment as F } from "react/jsx-runtime";
2
- import { useEditorState as p, useEditor as V, EditorContent as X } from "@tiptap/react";
3
- import Y from "clsx";
4
- import h, { useState as I, useRef as Z, useCallback as B } from "react";
5
- import Q from "@tiptap/extension-image";
6
- import { TaskList as tt, TaskItem as et } from "@tiptap/extension-list";
7
- import ot from "@tiptap/extension-subscript";
8
- import nt from "@tiptap/extension-superscript";
9
- import { TableKit as it } from "@tiptap/extension-table";
10
- import rt from "@tiptap/extension-text-align";
11
- import { TextStyle as st, Color as ct, BackgroundColor as lt, LineHeight as at, FontSize as ut, FontFamily as dt } from "@tiptap/extension-text-style";
12
- import mt from "@tiptap/starter-kit";
13
- import { WuIcon as f, WuModal as D, WuModalHeader as H, WuModalContent as z, WuInput as L, WuModalFooter as R, WuModalClose as x, WuToggle as ht, WuButton as q } from "@npm-questionpro/wick-ui-lib";
14
- import { DropdownMenu as j, DropdownMenuTrigger as $, DropdownMenuContent as K, DropdownMenuItem as U } from "@radix-ui/react-dropdown-menu";
15
- import ft from "dompurify";
16
- const gt = "_wuContentEditor_1kzbo_8", pt = "_wuContentEditorTable_1kzbo_1", wt = "_wuContentEditorContainer_1kzbo_8", Ct = "_wuContentEditorToolbar_1kzbo_80", vt = "_wuContentEditorAction_1kzbo_107", bt = "_wuContentEditorDropdown_1kzbo_133", At = "_wuContentEditorDropdownItem_1kzbo_146", kt = "_wuContentEditorFontSize_1kzbo_157", Et = "_wuContentEditorModal_1kzbo_171", yt = "_wuCodeEditor_1kzbo_175", Tt = "_wuFormatCode_1kzbo_185", St = "_wuCodeEditorPreview_1kzbo_198", xt = "_wuCodeEditorInput_1kzbo_213", a = {
17
- wuContentEditor: gt,
18
- wuContentEditorTable: pt,
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: vt,
22
- wuContentEditorDropdown: bt,
23
- wuContentEditorDropdownItem: At,
25
+ wuContentEditorAction: bt,
26
+ wuContentEditorDropdown: At,
27
+ wuContentEditorDropdownItem: yt,
24
28
  wuContentEditorFontSize: kt,
25
29
  wuContentEditorModal: Et,
26
- wuCodeEditor: yt,
27
- wuFormatCode: Tt,
28
- wuCodeEditorPreview: St,
30
+ wuCodeEditor: Tt,
31
+ wuFormatCode: St,
32
+ wuCodeEditorPreview: _t,
29
33
  wuCodeEditorInput: xt
30
34
  }, Ft = [
31
- mt.configure({
32
- link: {
33
- openOnClick: !1,
34
- autolink: !0,
35
- defaultProtocol: "https",
36
- protocols: ["http", "https"],
37
- isAllowedUri: (t, o) => {
38
- try {
39
- const n = t.includes(":") ? new URL(t) : new URL(`${o.defaultProtocol}://${t}`);
40
- if (!o.defaultValidate(n.href))
41
- return !1;
42
- const i = ["ftp", "file", "mailto"], s = n.protocol.replace(":", "");
43
- if (i.includes(s) || !o.protocols.map(
44
- (r) => typeof r == "string" ? r : r.scheme
45
- ).includes(s))
46
- return !1;
47
- const u = [
48
- "example-phishing.com",
49
- "malicious-site.net"
50
- ], 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 = [
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
- rt.configure({
70
- types: ["heading", "paragraph"]
71
- }),
72
- nt,
64
+ } }),
65
+ it.configure({ types: ["heading", "paragraph"] }),
73
66
  ot,
74
- st,
75
- ct,
67
+ et,
68
+ ut,
76
69
  lt,
70
+ rt,
77
71
  tt,
78
- et,
72
+ Q,
73
+ ct,
74
+ st,
79
75
  at,
80
- ut,
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
- it.configure({
90
- table: { resizable: !0 }
91
- })
92
- ], J = h.createContext(
93
- null
94
- ), Lt = ({
95
- editor: t,
96
- children: o,
97
- customFonts: n,
98
- isHtml: i,
99
- setIsHtml: s
100
- }) => /* @__PURE__ */ e(J.Provider, { value: { editor: t, customFonts: n, isHtml: i, setIsHtml: s }, children: o }), g = () => {
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
- var s;
107
- const [n, i] = h.useState(
108
- o || t.items.find((l) => l.active) || t.items[0]
109
- );
110
- return h.useEffect(() => {
111
- i(
112
- o || t.items.find((l) => l.active) || t.items[0]
113
- );
114
- }, [t, o]), /* @__PURE__ */ v(j, { children: [
115
- /* @__PURE__ */ e(
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": t.active,
120
- children: /* @__PURE__ */ e(f, { icon: n.icon })
121
- }
122
- ),
123
- /* @__PURE__ */ e(
124
- K,
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
- var s, l, u, c, r, d, w;
156
- return {
157
- isLeft: (s = i.editor) == null ? void 0 : s.isActive({ textAlign: "left" }),
158
- isCenter: (l = i.editor) == null ? void 0 : l.isActive({ textAlign: "center" }),
159
- isRight: (u = i.editor) == null ? void 0 : u.isActive({ textAlign: "right" }),
160
- isJustify: (c = i.editor) == null ? void 0 : c.isActive({ textAlign: "justify" }),
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
- M,
196
- {
197
- action: {
198
- id: "style",
199
- active: o.isAligned,
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 } = g(), o = p({
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
- "label",
214
- {
215
- className: a.wuContentEditorAction,
216
- htmlFor: "bg-color",
217
- title: "Background Color",
218
- children: [
219
- /* @__PURE__ */ e(f, { icon: "wm-border-color", style: { color: o.bgColor } }),
220
- /* @__PURE__ */ e(
221
- "input",
222
- {
223
- type: "color",
224
- id: "bg-color",
225
- name: "bg-color",
226
- defaultValue: "#fff",
227
- onChange: (n) => t.chain().focus().setBackgroundColor(n.target.value).run()
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
- var s, l, u, c, r, d;
238
- return {
239
- isParagraph: (s = i.editor) == null ? void 0 : s.isActive("paragraph"),
240
- isH1: (l = i.editor) == null ? void 0 : l.isActive("heading", { level: 1 }),
241
- isH2: (u = i.editor) == null ? void 0 : u.isActive("heading", { level: 2 }),
242
- isH3: (c = i.editor) == null ? void 0 : c.isActive("heading", { level: 3 }),
243
- isH4: (r = i.editor) == null ? void 0 : r.isActive("heading", { level: 4 }),
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
- M,
281
- {
282
- action: {
283
- id: "style",
284
- active: o.isStyle,
285
- icon: "wm-format-paragraph",
286
- items: n
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 } = g(), o = p({
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
- title: "quote",
305
- className: a.wuContentEditorAction,
306
- "data-active": o.blockquote,
307
- onClick: (n) => {
308
- n.preventDefault(), t.chain().focus().toggleBlockquote().run();
309
- },
310
- children: /* @__PURE__ */ e(f, { icon: "wm-format-quote" })
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
- var i;
318
- return {
319
- bold: (i = n.editor) == null ? void 0 : i.isActive("bold")
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 } = g();
337
- return /* @__PURE__ */ e(F, { children: [
338
- {
339
- id: "clear",
340
- icon: "wm-format-clear",
341
- event: () => t.chain().focus().clearNodes().unsetAllMarks().run(),
342
- tooltip: "Clear Formatting"
343
- }
344
- ].map((n) => /* @__PURE__ */ e(
345
- "button",
346
- {
347
- title: n.tooltip,
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
- n.id
355
- )) });
356
- }, Rt = () => {
357
- const { editor: t } = g(), o = p({
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
- className: a.wuContentEditorAction,
367
- "data-active": o.code,
368
- title: "Code line",
369
- onMouseDown: (n) => {
370
- n.preventDefault(), t.chain().focus().toggleCode().run();
371
- },
372
- children: /* @__PURE__ */ e(f, { icon: "wm-code" })
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: (c) => {
379
- var r, d;
380
- return {
381
- isImage: (r = c.editor) == null ? void 0 : r.isActive("image"),
382
- imageAttrs: (d = c.editor) == null ? void 0 : d.getAttributes("image")
383
- };
384
- }
385
- }), [n, i] = h.useState(o.imageAttrs.src || ""), [s, l] = h.useState(o.imageAttrs.alt || ""), u = () => {
386
- t.chain().focus().setImage({ src: n, alt: s }).run();
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
- D,
390
- {
391
- Trigger: /* @__PURE__ */ e(
392
- "button",
393
- {
394
- className: a.wuContentEditorAction,
395
- "data-active": o.isImage,
396
- children: /* @__PURE__ */ e(f, { icon: "wm-image" })
397
- }
398
- ),
399
- maxWidth: "400px",
400
- children: [
401
- /* @__PURE__ */ e(H, { style: { display: "none" } }),
402
- /* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
403
- /* @__PURE__ */ e(
404
- L,
405
- {
406
- Label: "Image URL",
407
- type: "url",
408
- value: n,
409
- onChange: (c) => i(c.target.value),
410
- required: !0
411
- }
412
- ),
413
- /* @__PURE__ */ e(
414
- L,
415
- {
416
- Label: "Alt Text",
417
- type: "text",
418
- value: s,
419
- onChange: (c) => l(c.target.value)
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 } = g(), o = p({
350
+ const { editor: t } = p(), o = f({
432
351
  editor: t,
433
- selector: (r) => {
434
- var d, w;
435
- return {
436
- isLink: (d = r.editor) == null ? void 0 : d.isActive("link"),
437
- linkAttrs: (w = r.editor) == null ? void 0 : w.getAttributes("link")
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: s || n,
444
- marks: [{ type: "link", attrs: { href: n } }]
359
+ text: r || n,
360
+ marks: [{
361
+ type: "link",
362
+ attrs: { href: n }
363
+ }]
445
364
  }).run();
446
- }, c = () => {
447
- const { $from: r } = t.state.selection, d = r.parent.textContent, w = r.parentOffset;
448
- let k = w, A = w;
449
- for (; k > 0 && !/\s/.test(d[k - 1]); )
450
- k--;
451
- for (; A < d.length && !/\s/.test(d[A]); )
452
- A++;
453
- const y = r.start(), E = y + k, b = y + A, C = d.slice(k, A);
454
- t.commands.setTextSelection({ from: E, to: b }), i(o.linkAttrs.href || ""), l(C || o.linkAttrs.alt || "");
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
- D,
458
- {
459
- Trigger: /* @__PURE__ */ e(
460
- "button",
461
- {
462
- className: a.wuContentEditorAction,
463
- "data-active": o.isLink,
464
- children: /* @__PURE__ */ e(f, { icon: "wm-link" })
465
- }
466
- ),
467
- maxWidth: "400px",
468
- onOpenChange: (r) => r && c(),
469
- children: [
470
- /* @__PURE__ */ e(H, { style: { display: "none" } }),
471
- /* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
472
- /* @__PURE__ */ e(
473
- L,
474
- {
475
- Label: "Link",
476
- type: "url",
477
- value: n,
478
- onChange: (r) => i(r.target.value),
479
- required: !0
480
- }
481
- ),
482
- /* @__PURE__ */ e(
483
- L,
484
- {
485
- Label: "Text to display",
486
- type: "text",
487
- value: s,
488
- onChange: (r) => l(r.target.value)
489
- }
490
- )
491
- ] }),
492
- /* @__PURE__ */ v(R, { children: [
493
- o.isLink && /* @__PURE__ */ e(
494
- x,
495
- {
496
- color: "error",
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: (r) => ({
511
- isTable: r.editor.isActive("table"),
512
- tableAttrs: r.editor.getAttributes("table")
418
+ selector: (l) => ({
419
+ isTable: l.editor.isActive("table"),
420
+ tableAttrs: l.editor.getAttributes("table")
513
421
  })
514
- }), [n, i] = I(!1), s = Z(null), l = B(() => {
515
- s.current = setTimeout(() => {
516
- t.chain().focus().insertTable({ rows: 2, cols: 4, withHeaderRow: n }).run();
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]), u = B(() => {
519
- i((r) => !r), s.current = setTimeout(() => {
430
+ }, [t, n]), c = O(() => {
431
+ i((l) => !l), r.current = setTimeout(() => {
520
432
  t.chain().focus().toggleHeaderRow().run();
521
433
  }, 100);
522
- }, [t]), c = [
523
- {
524
- text: "Column left",
525
- icon: "wm-add",
526
- event: () => t.chain().focus().addColumnBefore().run()
527
- },
528
- {
529
- text: "Row above",
530
- icon: "wm-add",
531
- event: () => t.chain().focus().addRowBefore().run()
532
- },
533
- {
534
- text: "Column right",
535
- icon: "wm-add",
536
- event: () => t.chain().focus().addColumnAfter().run()
537
- },
538
- {
539
- text: "Row below",
540
- icon: "wm-add",
541
- event: () => t.chain().focus().addRowAfter().run()
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
- checked: n,
573
- onClick: u,
574
- Label: "Title Row",
575
- labelPosition: "left"
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
- onClick: w,
582
- variant: "secondary",
583
- Icon: /* @__PURE__ */ e(f, { icon: d }),
584
- children: r
462
+ text: "Row above",
463
+ icon: "wm-add",
464
+ event: () => t.chain().focus().addRowBefore().run()
585
465
  },
586
- r
587
- )) })
588
- ] }),
589
- /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(
590
- x,
591
- {
592
- onClick: () => t.chain().focus().deleteTable().run(),
593
- variant: "outline",
594
- color: "error",
595
- Icon: /* @__PURE__ */ e("span", { className: "wm-delete" }),
596
- iconPosition: "left",
597
- children: "Delete Table"
598
- }
599
- ) })
600
- ]
601
- }
602
- ) : /* @__PURE__ */ e(
603
- "button",
604
- {
605
- onClick: l,
606
- className: a.wuContentEditorAction,
607
- children: /* @__PURE__ */ e(f, { icon: "wm-table" })
608
- }
609
- );
610
- }, Pt = () => {
611
- const { editor: t, customFonts: o } = g(), n = p({
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: (u) => ({
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
- ], [s, l] = I(
624
- n.currentFontFamily || i[0]
625
- );
626
- return h.useEffect(() => {
627
- var u;
628
- l(
629
- ((u = n.currentFontFamily) == null ? void 0 : u.replace(/"/g, "")) || i[0]
630
- );
631
- }, [n.currentFontFamily]), /* @__PURE__ */ v(j, { children: [
632
- /* @__PURE__ */ e(
633
- $,
634
- {
635
- className: a.wuContentEditorAction,
636
- "data-active": s !== "Fira Sans",
637
- style: { fontFamily: s },
638
- title: s || "Font Family",
639
- children: s == null ? void 0 : s[0]
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: /* @__PURE__ */ e(f, { icon: "wm-format-italic" })
684
- }
685
- );
541
+ children: c
542
+ }, c))
543
+ })] });
686
544
  }, qt = () => {
687
- const { editor: t } = g(), o = p({
545
+ const { editor: t } = p(), o = f({
688
546
  editor: t,
689
- selector: (i) => {
690
- var s, l, u, c, r, d;
691
- return {
692
- isUl: (s = i.editor) == null ? void 0 : s.isActive("bulletList"),
693
- isOl: (l = i.editor) == null ? void 0 : l.isActive("orderedList"),
694
- isTodo: (u = i.editor) == null ? void 0 : u.isActive("taskList"),
695
- isList: ((c = i.editor) == null ? void 0 : c.isActive("bulletList")) || ((r = i.editor) == null ? void 0 : r.isActive("orderedList")) || ((d = i.editor) == null ? void 0 : d.isActive("taskList"))
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
- M,
723
- {
724
- action: {
725
- id: "style",
726
- active: o.isList,
727
- icon: "wm-format-paragraph",
728
- items: n
729
- }
730
- }
731
- );
732
- }, jt = ["e", "E", "+", "-"], P = 1, $t = () => {
733
- const { editor: t } = g(), [o, n] = I(16), i = p({
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: (c) => ({
736
- fontSize: c.editor.getAttributes("textStyle").fontSize
737
- })
738
- }), s = (c) => {
739
- t.chain().focus().setFontSize(c + "px").run();
740
- }, l = (c) => {
741
- const r = Math.max(P, c);
742
- n(r), s(r);
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 h.useEffect(() => {
747
- var c;
748
- n(Number((c = i.fontSize) == null ? void 0 : c.replace("px", "")) || 16);
749
- }, [i.fontSize]), /* @__PURE__ */ v("div", { className: a.wuContentEditorFontSize, children: [
750
- /* @__PURE__ */ e(
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: () => l(o - 1),
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: u,
767
- onChange: (c) => n(c.target.valueAsNumber),
768
- onBlur: () => s(o)
769
- }
770
- ),
771
- /* @__PURE__ */ e(
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: () => l(o + 1),
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 } = g(), o = p({
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
- title: "strikethrough",
795
- className: a.wuContentEditorAction,
796
- "data-active": o.strikethrough,
797
- onClick: (n) => {
798
- n.preventDefault(), t.chain().focus().toggleStrike().run();
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 } = g(), o = p({
660
+ const { editor: t } = p(), o = f({
827
661
  editor: t,
828
- selector: (n) => {
829
- var i;
830
- return {
831
- superscript: (i = n.editor) == null ? void 0 : i.isActive("superscript")
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 } = g(), o = p({
675
+ const { editor: t } = p(), o = f({
849
676
  editor: t,
850
- selector: ({ editor: n }) => ({
851
- textColor: n.getAttributes("textStyle").color
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 } = g(), o = p({
690
+ const { editor: t } = p(), o = f({
884
691
  editor: t,
885
- selector: (n) => {
886
- var i;
887
- return {
888
- underline: (i = n.editor) == null ? void 0 : i.isActive("underline")
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 Xt() {
906
- const { isHtml: t, setIsHtml: o } = g();
907
- return /* @__PURE__ */ e(
908
- "button",
909
- {
910
- title: "HTML source",
911
- className: a.wuContentEditorAction,
912
- "data-active": t,
913
- onClick: (n) => {
914
- n.preventDefault(), o(!t);
915
- },
916
- children: /* @__PURE__ */ e(f, { icon: "wm-html" })
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
- const W = {
921
- block: /* @__PURE__ */ e(It, {}),
922
- fontFamily: /* @__PURE__ */ e(Pt, {}),
739
+ var B = {
740
+ block: /* @__PURE__ */ e(Ht, {}),
741
+ fontFamily: /* @__PURE__ */ e(Bt, {}),
923
742
  fontSize: /* @__PURE__ */ e($t, {}),
924
- bold: /* @__PURE__ */ e(Ht, {}),
925
- italic: /* @__PURE__ */ e(Wt, {}),
926
- underline: /* @__PURE__ */ e(Vt, {}),
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(Gt, {}),
747
+ color: /* @__PURE__ */ e(Vt, {}),
929
748
  bgColor: /* @__PURE__ */ e(Nt, {}),
930
- list: /* @__PURE__ */ e(qt, {}),
931
- alignment: /* @__PURE__ */ e(_t, {}),
932
- image: /* @__PURE__ */ e(Mt, {}),
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(Bt, {}),
753
+ table: /* @__PURE__ */ e(Pt, {}),
935
754
  blockquote: /* @__PURE__ */ e(Dt, {}),
936
- superscript: /* @__PURE__ */ e(Jt, {}),
937
- subscript: /* @__PURE__ */ e(Ut, {}),
938
- codeline: /* @__PURE__ */ e(Rt, {}),
755
+ superscript: /* @__PURE__ */ e(Gt, {}),
756
+ subscript: /* @__PURE__ */ e(Jt, {}),
757
+ codeline: /* @__PURE__ */ e(Mt, {}),
939
758
  clear: /* @__PURE__ */ e(zt, {}),
940
- // eslint-disable-next-line @typescript-eslint/naming-convention
941
- "|": /* @__PURE__ */ e(
942
- "div",
943
- {
944
- style: {
945
- height: 16,
946
- width: 1,
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
- ], Zt = (t) => {
981
- const {
982
- editor: o,
983
- customFonts: n,
984
- children: i,
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: l,
996
- setIsHtml: u,
997
- children: [
998
- s.map((r, d) => /* @__PURE__ */ e(F, { children: l && r !== "html" ? /* @__PURE__ */ e("span", { style: { pointerEvents: "none", opacity: 0.4 }, children: W[r] }) : W[r] }, r + d)),
999
- i
1000
- ]
1001
- }
1002
- ) });
1003
- }, O = ft();
1004
- O.setConfig({
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
- O.addHook("uponSanitizeAttribute", (t, o) => {
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 ? O.sanitize(t) : "";
871
+ return t ? W.sanitize(t) : "";
1064
872
  }
1065
- let N = null;
1066
- function Qt() {
1067
- return N || (N = import("shiki").then(
1068
- ({ createHighlighter: t }) => t({
1069
- themes: ["github-light"],
1070
- langs: ["html"]
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 te({
1075
- defaultValue: t,
1076
- onUpdate: o,
1077
- readonly: n
1078
- }) {
1079
- const [i, s] = h.useState(t || ""), [l, u] = h.useState(""), [c, r] = h.useState(!1), [d, w] = h.useState(!1), k = h.useRef(!1), A = h.useCallback(
1080
- async (C) => {
1081
- try {
1082
- const [{ format: m }, { default: T }] = await Promise.all([
1083
- import("../../standalone-uA6N_bR1.js"),
1084
- import("../../html-asrO2y6j.js")
1085
- ]), _ = await m(C, {
1086
- parser: "html",
1087
- plugins: [T],
1088
- htmlWhitespaceSensitivity: "css",
1089
- printWidth: 80
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
- u(T);
1104
- }).catch((m) => console.error("Highlight error:", m));
898
+ }));
899
+ }).catch((d) => console.error("Highlight error:", d));
1105
900
  }, []);
1106
- h.useEffect(() => {
1107
- y(i), o == null || o(S(i));
1108
- }, [i, y, o]), h.useEffect(() => {
1109
- k.current || !t || (k.current = !0, A(t).then(s));
1110
- }, [t, A]);
1111
- const E = async (C) => {
1112
- C.preventDefault(), w(!0);
1113
- const m = await A(i);
1114
- s(m), w(!1);
1115
- }, b = (C) => {
1116
- if (C.key === "Tab") {
1117
- C.preventDefault();
1118
- const m = C.currentTarget, T = m.selectionStart, _ = m.selectionEnd, G = i.substring(0, T) + " " + i.substring(_);
1119
- s(G), requestAnimationFrame(() => {
1120
- m.selectionStart = T + 2, m.selectionEnd = T + 2;
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(F, { children: d ? /* @__PURE__ */ e(F, { children: "Formatting..." }) : /* @__PURE__ */ e("div", { className: a.wuContentEditor, children: /* @__PURE__ */ v("div", { className: a.wuCodeEditor, children: [
1125
- /* @__PURE__ */ e(
1126
- q,
1127
- {
1128
- variant: "iconOnly",
1129
- Icon: /* @__PURE__ */ e(f, { icon: "wm-data-object" }),
1130
- onClick: E,
1131
- className: a.wuFormatCode,
1132
- style: { color: c ? "red" : "" }
1133
- }
1134
- ),
1135
- /* @__PURE__ */ e(
1136
- "div",
1137
- {
1138
- dangerouslySetInnerHTML: { __html: l },
1139
- className: a.wuCodeEditorPreview
1140
- }
1141
- ),
1142
- /* @__PURE__ */ e(
1143
- "textarea",
1144
- {
1145
- value: i,
1146
- onChange: (C) => s(C.target.value),
1147
- onKeyDown: b,
1148
- className: a.wuCodeEditorInput,
1149
- disabled: n
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 pe({
1155
- defaultValue: t,
1156
- onUpdate: o,
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: m }) => {
1173
- o && o(S(m.getHTML()));
953
+ onUpdate: ({ editor: d }) => {
954
+ o && o(S(d.getHTML()));
1174
955
  }
1175
- }), C = (m) => {
1176
- m ? E.current = (b == null ? void 0 : b.getHTML()) ?? "" : b == null || b.commands.setContent(S(E.current)), o && o(S(E.current)), y(m), w == null || w(m);
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
- "div",
1180
- {
1181
- className: Y(a.wuContentEditorContainer, n),
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
- "data-slot": "wu-content-editor-container",
1184
- onClick: () => {
1185
- A || b == null || b.chain().focus().run();
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
- ...k,
1188
- children: [
1189
- !u && /* @__PURE__ */ e(
1190
- Zt,
1191
- {
1192
- editor: b,
1193
- customFonts: r,
1194
- className: a.wuContentEditorToolbar,
1195
- items: l,
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
- pe as WuContentEditor
993
+ ve as WuContentEditor
1228
994
  };