@npm-questionpro/wick-ui-editor 0.12.0 → 0.13.0

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