@npm-questionpro/wick-ui-editor 0.12.1 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,491 +1,497 @@
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 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,
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
+ wuFormatCode: Tt,
28
+ wuCodeEditorPreview: St,
29
+ wuCodeEditorInput: xt
30
+ }, Ft = [
31
+ mt.configure({
28
32
  link: {
29
33
  openOnClick: !1,
30
34
  autolink: !0,
31
35
  defaultProtocol: "https",
32
36
  protocols: ["http", "https"],
33
- isAllowedUri: (t, n) => {
37
+ isAllowedUri: (t, o) => {
34
38
  try {
35
- const e = t.includes(":") ? new URL(t) : new URL(`${n.defaultProtocol}://${t}`);
36
- if (!n.defaultValidate(e.href))
39
+ const n = t.includes(":") ? new URL(t) : new URL(`${o.defaultProtocol}://${t}`);
40
+ if (!o.defaultValidate(n.href))
37
41
  return !1;
38
- const i = ["ftp", "file", "mailto"], l = e.protocol.replace(":", "");
39
- if (i.includes(l) || !n.protocols.map(
42
+ const i = ["ftp", "file", "mailto"], s = n.protocol.replace(":", "");
43
+ if (i.includes(s) || !o.protocols.map(
40
44
  (r) => typeof r == "string" ? r : r.scheme
41
- ).includes(l))
45
+ ).includes(s))
42
46
  return !1;
43
- const a = [
47
+ const u = [
44
48
  "example-phishing.com",
45
49
  "malicious-site.net"
46
- ], s = e.hostname;
47
- return !a.includes(s);
50
+ ], c = n.hostname;
51
+ return !u.includes(c);
48
52
  } catch {
49
53
  return !1;
50
54
  }
51
55
  },
52
56
  shouldAutoLink: (t) => {
53
57
  try {
54
- const n = t.includes(":") ? new URL(t) : new URL(`https://${t}`), e = [
58
+ const o = t.includes(":") ? new URL(t) : new URL(`https://${t}`), n = [
55
59
  "example-no-autolink.com",
56
60
  "another-no-autolink.com"
57
- ], i = n.hostname;
58
- return !e.includes(i);
61
+ ], i = o.hostname;
62
+ return !n.includes(i);
59
63
  } catch {
60
64
  return !1;
61
65
  }
62
66
  }
63
67
  }
64
68
  }),
65
- Z.configure({
69
+ rt.configure({
66
70
  types: ["heading", "paragraph"]
67
71
  }),
68
- X,
69
- G,
70
- Q,
72
+ nt,
73
+ ot,
74
+ st,
75
+ ct,
76
+ lt,
71
77
  tt,
72
78
  et,
73
- J,
74
- V,
75
- ot,
76
- nt,
77
- it,
78
- K.configure({
79
+ at,
80
+ ut,
81
+ dt,
82
+ Q.configure({
79
83
  resize: {
80
84
  enabled: !0,
81
85
  alwaysPreserveAspectRatio: !0
82
86
  },
83
87
  inline: !0
84
88
  }),
85
- Y.configure({
89
+ it.configure({
86
90
  table: { resizable: !0 }
87
91
  })
88
- ], O = C.createContext(
92
+ ], J = h.createContext(
89
93
  null
90
- ), vt = ({
94
+ ), Lt = ({
91
95
  editor: t,
92
- 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
+ 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);
96
102
  if (!t)
97
103
  throw new Error("useToolbar must be used within a ToolbarProvider");
98
104
  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]
105
+ }, 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]
103
109
  );
104
- return C.useEffect(() => {
110
+ return h.useEffect(() => {
105
111
  i(
106
- n || t.items.find((c) => c.active) || t.items[0]
112
+ o || t.items.find((l) => l.active) || t.items[0]
107
113
  );
108
- }, [t, n]), /* @__PURE__ */ g(M, { children: [
109
- /* @__PURE__ */ o(
110
- H,
114
+ }, [t, o]), /* @__PURE__ */ v(j, { children: [
115
+ /* @__PURE__ */ e(
116
+ $,
111
117
  {
112
- className: d.wuContentEditorAction,
118
+ className: a.wuContentEditorAction,
113
119
  "data-active": t.active,
114
- children: /* @__PURE__ */ o(h, { icon: e.icon })
120
+ children: /* @__PURE__ */ e(f, { icon: n.icon })
115
121
  }
116
122
  ),
117
- /* @__PURE__ */ o(
118
- z,
123
+ /* @__PURE__ */ e(
124
+ K,
119
125
  {
120
126
  align: "start",
121
- onCloseAutoFocus: (c) => c.preventDefault(),
122
- className: d.wuContentEditorDropdown,
127
+ onCloseAutoFocus: (l) => l.preventDefault(),
128
+ className: a.wuContentEditorDropdown,
123
129
  "data-inline": !0,
124
- children: (l = t.items) == null ? void 0 : l.map((c) => /* @__PURE__ */ o(
125
- B,
130
+ children: (s = t.items) == null ? void 0 : s.map((l) => /* @__PURE__ */ e(
131
+ U,
126
132
  {
127
133
  onClick: () => {
128
- c.event(), i(c);
134
+ l.event(), i(l);
129
135
  },
130
- title: c.tooltip,
131
- children: /* @__PURE__ */ o(
136
+ title: l.tooltip,
137
+ children: /* @__PURE__ */ e(
132
138
  "button",
133
139
  {
134
- className: d.wuContentEditorAction,
135
- "data-active": c.active,
136
- children: /* @__PURE__ */ o(h, { icon: c.icon })
140
+ className: a.wuContentEditorAction,
141
+ "data-active": l.active,
142
+ children: /* @__PURE__ */ e(f, { icon: l.icon })
137
143
  }
138
144
  )
139
145
  },
140
- c.id
146
+ l.id
141
147
  ))
142
148
  }
143
149
  )
144
150
  ] });
145
- }, bt = () => {
146
- const { editor: t } = m(), n = f({
151
+ }, _t = () => {
152
+ const { editor: t } = g(), o = p({
147
153
  editor: t,
148
154
  selector: (i) => {
149
- var l, c, a, s, r, u, p;
155
+ var s, l, u, c, r, d, w;
150
156
  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" }))
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" }))
156
162
  };
157
163
  }
158
- }), e = [
164
+ }), n = [
159
165
  {
160
166
  id: "left",
161
167
  icon: "wm-format-align-left",
162
168
  event: () => t.chain().focus().setTextAlign("left").run(),
163
169
  tooltip: "Align Left",
164
- active: n.isLeft
170
+ active: o.isLeft
165
171
  },
166
172
  {
167
173
  id: "center",
168
174
  icon: "wm-format-align-center",
169
175
  event: () => t.chain().focus().setTextAlign("center").run(),
170
176
  tooltip: "Align Center",
171
- active: n.isCenter
177
+ active: o.isCenter
172
178
  },
173
179
  {
174
180
  id: "right",
175
181
  icon: "wm-format-align-right",
176
182
  event: () => t.chain().focus().setTextAlign("right").run(),
177
183
  tooltip: "Align Right",
178
- active: n.isRight
184
+ active: o.isRight
179
185
  },
180
186
  {
181
187
  id: "justify",
182
188
  icon: "wm-format-align-justify",
183
189
  event: () => t.chain().focus().setTextAlign("justify").run(),
184
190
  tooltip: "Justify",
185
- active: n.isJustify
191
+ active: o.isJustify
186
192
  }
187
193
  ];
188
- return /* @__PURE__ */ o(
189
- L,
194
+ return /* @__PURE__ */ e(
195
+ M,
190
196
  {
191
197
  action: {
192
198
  id: "style",
193
- active: n.isAligned,
199
+ active: o.isAligned,
194
200
  icon: "wm-format-paragraph",
195
- items: e
201
+ items: n
196
202
  }
197
203
  }
198
204
  );
199
- }, At = () => {
200
- const { editor: t } = m(), n = f({
205
+ }, Nt = () => {
206
+ const { editor: t } = g(), o = p({
201
207
  editor: t,
202
- selector: ({ editor: e }) => ({
203
- bgColor: e.getAttributes("textStyle").backgroundColor
208
+ selector: ({ editor: n }) => ({
209
+ bgColor: n.getAttributes("textStyle").backgroundColor
204
210
  })
205
211
  });
206
- return /* @__PURE__ */ g(
212
+ return /* @__PURE__ */ v(
207
213
  "label",
208
214
  {
209
- className: d.wuContentEditorAction,
215
+ className: a.wuContentEditorAction,
210
216
  htmlFor: "bg-color",
211
217
  title: "Background Color",
212
218
  children: [
213
- /* @__PURE__ */ o(h, { icon: "wm-border-color", style: { color: n.bgColor } }),
214
- /* @__PURE__ */ o(
219
+ /* @__PURE__ */ e(f, { icon: "wm-border-color", style: { color: o.bgColor } }),
220
+ /* @__PURE__ */ e(
215
221
  "input",
216
222
  {
217
223
  type: "color",
218
224
  id: "bg-color",
219
225
  name: "bg-color",
220
226
  defaultValue: "#fff",
221
- onChange: (e) => t.chain().focus().setBackgroundColor(e.target.value).run()
227
+ onChange: (n) => t.chain().focus().setBackgroundColor(n.target.value).run()
222
228
  }
223
229
  )
224
230
  ]
225
231
  }
226
232
  );
227
- }, kt = () => {
228
- const { editor: t } = m(), n = f({
233
+ }, It = () => {
234
+ const { editor: t } = g(), o = p({
229
235
  editor: t,
230
236
  selector: (i) => {
231
- var l, c, a, s, r, u;
237
+ var s, l, u, c, r, d;
232
238
  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 }),
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 }),
237
243
  isH4: (r = i.editor) == null ? void 0 : r.isActive("heading", { level: 4 }),
238
- isStyle: (u = i.editor) == null ? void 0 : u.isActive("heading")
244
+ isStyle: (d = i.editor) == null ? void 0 : d.isActive("heading")
239
245
  };
240
246
  }
241
- }), e = [
247
+ }), n = [
242
248
  {
243
249
  id: "paragraph",
244
250
  icon: "wm-format-paragraph",
245
251
  event: () => t.chain().focus().setParagraph().run(),
246
- active: n.isParagraph
252
+ active: o.isParagraph
247
253
  },
248
254
  {
249
255
  id: "h1",
250
256
  icon: "wm-format-h1",
251
257
  event: () => t.chain().focus().setHeading({ level: 1 }).run(),
252
- active: n.isH1
258
+ active: o.isH1
253
259
  },
254
260
  {
255
261
  id: "h2",
256
262
  icon: "wm-format-h2",
257
263
  event: () => t.chain().focus().setHeading({ level: 2 }).run(),
258
- active: n.isH2
264
+ active: o.isH2
259
265
  },
260
266
  {
261
267
  id: "h3",
262
268
  icon: "wm-format-h3",
263
269
  event: () => t.chain().focus().setHeading({ level: 3 }).run(),
264
- active: n.isH3
270
+ active: o.isH3
265
271
  },
266
272
  {
267
273
  id: "h4",
268
274
  icon: "wm-format-h4",
269
275
  event: () => t.chain().focus().setHeading({ level: 4 }).run(),
270
- active: n.isH4
276
+ active: o.isH4
271
277
  }
272
278
  ];
273
- return /* @__PURE__ */ o(
274
- L,
279
+ return /* @__PURE__ */ e(
280
+ M,
275
281
  {
276
282
  action: {
277
283
  id: "style",
278
- active: n.isStyle,
284
+ active: o.isStyle,
279
285
  icon: "wm-format-paragraph",
280
- items: e
286
+ items: n
281
287
  },
282
- defaultValue: e.find((i) => i.active)
288
+ defaultValue: n.find((i) => i.active)
283
289
  }
284
290
  );
285
- }, Et = () => {
286
- const { editor: t } = m(), n = f({
291
+ }, Dt = () => {
292
+ const { editor: t } = g(), o = p({
287
293
  editor: t,
288
- selector: (e) => {
294
+ selector: (n) => {
289
295
  var i;
290
296
  return {
291
- blockquote: (i = e.editor) == null ? void 0 : i.isActive("blockquote")
297
+ blockquote: (i = n.editor) == null ? void 0 : i.isActive("blockquote")
292
298
  };
293
299
  }
294
300
  });
295
- return /* @__PURE__ */ o(
301
+ return /* @__PURE__ */ e(
296
302
  "button",
297
303
  {
298
304
  title: "quote",
299
- className: d.wuContentEditorAction,
300
- "data-active": n.blockquote,
301
- onClick: (e) => {
302
- e.preventDefault(), t.chain().focus().toggleBlockquote().run();
305
+ className: a.wuContentEditorAction,
306
+ "data-active": o.blockquote,
307
+ onClick: (n) => {
308
+ n.preventDefault(), t.chain().focus().toggleBlockquote().run();
303
309
  },
304
- children: /* @__PURE__ */ o(h, { icon: "wm-format-quote" })
310
+ children: /* @__PURE__ */ e(f, { icon: "wm-format-quote" })
305
311
  }
306
312
  );
307
- }, yt = () => {
308
- const { editor: t } = m(), n = f({
313
+ }, Ht = () => {
314
+ const { editor: t } = g(), o = p({
309
315
  editor: t,
310
- selector: (e) => {
316
+ selector: (n) => {
311
317
  var i;
312
318
  return {
313
- bold: (i = e.editor) == null ? void 0 : i.isActive("bold")
319
+ bold: (i = n.editor) == null ? void 0 : i.isActive("bold")
314
320
  };
315
321
  }
316
322
  });
317
- return /* @__PURE__ */ o(
323
+ return /* @__PURE__ */ e(
318
324
  "button",
319
325
  {
320
326
  title: "Bold",
321
- className: d.wuContentEditorAction,
322
- "data-active": n.bold,
323
- onClick: (e) => {
324
- e.preventDefault(), t.chain().focus().toggleBold().run();
327
+ className: a.wuContentEditorAction,
328
+ "data-active": o.bold,
329
+ onClick: (n) => {
330
+ n.preventDefault(), t.chain().focus().toggleBold().run();
325
331
  },
326
- children: /* @__PURE__ */ o(h, { icon: "wm-format-bold" })
332
+ children: /* @__PURE__ */ e(f, { icon: "wm-format-bold" })
327
333
  }
328
334
  );
329
- }, Tt = () => {
330
- const { editor: t } = m();
331
- return /* @__PURE__ */ o(R, { children: [
335
+ }, zt = () => {
336
+ const { editor: t } = g();
337
+ return /* @__PURE__ */ e(F, { children: [
332
338
  {
333
339
  id: "clear",
334
340
  icon: "wm-format-clear",
335
341
  event: () => t.chain().focus().clearNodes().unsetAllMarks().run(),
336
342
  tooltip: "Clear Formatting"
337
343
  }
338
- ].map((e) => /* @__PURE__ */ o(
344
+ ].map((n) => /* @__PURE__ */ e(
339
345
  "button",
340
346
  {
341
- title: e.tooltip,
342
- className: d.wuContentEditorAction,
347
+ title: n.tooltip,
348
+ className: a.wuContentEditorAction,
343
349
  onClick: (i) => {
344
- i.preventDefault(), e.event();
350
+ i.preventDefault(), n.event();
345
351
  },
346
- children: /* @__PURE__ */ o(h, { icon: e.icon })
352
+ children: /* @__PURE__ */ e(f, { icon: n.icon })
347
353
  },
348
- e.id
354
+ n.id
349
355
  )) });
350
- }, St = () => {
351
- const { editor: t } = m(), n = f({
356
+ }, Rt = () => {
357
+ const { editor: t } = g(), o = p({
352
358
  editor: t,
353
- selector: (e) => ({
354
- code: e.editor.isActive("code")
359
+ selector: (n) => ({
360
+ code: n.editor.isActive("code")
355
361
  })
356
362
  });
357
- return /* @__PURE__ */ o(
363
+ return /* @__PURE__ */ e(
358
364
  "button",
359
365
  {
360
- className: d.wuContentEditorAction,
361
- "data-active": n.code,
366
+ className: a.wuContentEditorAction,
367
+ "data-active": o.code,
362
368
  title: "Code line",
363
- onMouseDown: (e) => {
364
- e.preventDefault(), t.chain().focus().toggleCode().run();
369
+ onMouseDown: (n) => {
370
+ n.preventDefault(), t.chain().focus().toggleCode().run();
365
371
  },
366
- children: /* @__PURE__ */ o(h, { icon: "wm-code" })
372
+ children: /* @__PURE__ */ e(f, { icon: "wm-code" })
367
373
  }
368
374
  );
369
- }, xt = () => {
370
- const { editor: t } = m(), n = f({
375
+ }, Mt = () => {
376
+ const { editor: t } = g(), o = p({
371
377
  editor: t,
372
- selector: (s) => {
373
- var r, u;
378
+ selector: (c) => {
379
+ var r, d;
374
380
  return {
375
- isImage: (r = s.editor) == null ? void 0 : r.isActive("image"),
376
- imageAttrs: (u = s.editor) == null ? void 0 : u.getAttributes("image")
381
+ isImage: (r = c.editor) == null ? void 0 : r.isActive("image"),
382
+ imageAttrs: (d = c.editor) == null ? void 0 : d.getAttributes("image")
377
383
  };
378
384
  }
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();
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();
381
387
  };
382
- return /* @__PURE__ */ g(
383
- y,
388
+ return /* @__PURE__ */ v(
389
+ D,
384
390
  {
385
- Trigger: /* @__PURE__ */ o(
391
+ Trigger: /* @__PURE__ */ e(
386
392
  "button",
387
393
  {
388
- className: d.wuContentEditorAction,
389
- "data-active": n.isImage,
390
- children: /* @__PURE__ */ o(h, { icon: "wm-image" })
394
+ className: a.wuContentEditorAction,
395
+ "data-active": o.isImage,
396
+ children: /* @__PURE__ */ e(f, { icon: "wm-image" })
391
397
  }
392
398
  ),
393
399
  maxWidth: "400px",
394
400
  children: [
395
- /* @__PURE__ */ o(T, { style: { display: "none" } }),
396
- /* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
397
- /* @__PURE__ */ o(
398
- k,
401
+ /* @__PURE__ */ e(H, { style: { display: "none" } }),
402
+ /* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
403
+ /* @__PURE__ */ e(
404
+ L,
399
405
  {
400
406
  Label: "Image URL",
401
407
  type: "url",
402
- value: e,
403
- onChange: (s) => i(s.target.value),
408
+ value: n,
409
+ onChange: (c) => i(c.target.value),
404
410
  required: !0
405
411
  }
406
412
  ),
407
- /* @__PURE__ */ o(
408
- k,
413
+ /* @__PURE__ */ e(
414
+ L,
409
415
  {
410
416
  Label: "Alt Text",
411
417
  type: "text",
412
- value: l,
413
- onChange: (s) => c(s.target.value)
418
+ value: s,
419
+ onChange: (c) => l(c.target.value)
414
420
  }
415
421
  )
416
422
  ] }),
417
- /* @__PURE__ */ g(x, { children: [
418
- /* @__PURE__ */ o(b, { variant: "secondary", children: "Cancel" }),
419
- /* @__PURE__ */ o(b, { onClick: a, disabled: !e, children: "Save" })
423
+ /* @__PURE__ */ v(R, { children: [
424
+ /* @__PURE__ */ e(x, { variant: "secondary", children: "Cancel" }),
425
+ /* @__PURE__ */ e(x, { onClick: u, disabled: !n, children: "Save" })
420
426
  ] })
421
427
  ]
422
428
  }
423
429
  );
424
- }, Lt = () => {
425
- const { editor: t } = m(), n = f({
430
+ }, Ot = () => {
431
+ const { editor: t } = g(), o = p({
426
432
  editor: t,
427
433
  selector: (r) => {
428
- var u, p;
434
+ var d, w;
429
435
  return {
430
- isLink: (u = r.editor) == null ? void 0 : u.isActive("link"),
431
- linkAttrs: (p = r.editor) == null ? void 0 : p.getAttributes("link")
436
+ isLink: (d = r.editor) == null ? void 0 : d.isActive("link"),
437
+ linkAttrs: (w = r.editor) == null ? void 0 : w.getAttributes("link")
432
438
  };
433
439
  }
434
- }), [e, i] = C.useState(n.linkAttrs.href || ""), [l, c] = C.useState(n.linkAttrs.alt || ""), a = () => {
440
+ }), [n, i] = h.useState(o.linkAttrs.href || ""), [s, l] = h.useState(o.linkAttrs.alt || ""), u = () => {
435
441
  t.chain().focus().insertContent({
436
442
  type: "text",
437
- text: l || e,
438
- marks: [{ type: "link", attrs: { href: e } }]
443
+ text: s || n,
444
+ marks: [{ type: "link", attrs: { href: n } }]
439
445
  }).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 || "");
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 || "");
449
455
  };
450
- return /* @__PURE__ */ g(
451
- y,
456
+ return /* @__PURE__ */ v(
457
+ D,
452
458
  {
453
- Trigger: /* @__PURE__ */ o(
459
+ Trigger: /* @__PURE__ */ e(
454
460
  "button",
455
461
  {
456
- className: d.wuContentEditorAction,
457
- "data-active": n.isLink,
458
- children: /* @__PURE__ */ o(h, { icon: "wm-link" })
462
+ className: a.wuContentEditorAction,
463
+ "data-active": o.isLink,
464
+ children: /* @__PURE__ */ e(f, { icon: "wm-link" })
459
465
  }
460
466
  ),
461
467
  maxWidth: "400px",
462
- onOpenChange: (r) => r && s(),
468
+ onOpenChange: (r) => r && c(),
463
469
  children: [
464
- /* @__PURE__ */ o(T, { style: { display: "none" } }),
465
- /* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
466
- /* @__PURE__ */ o(
467
- k,
470
+ /* @__PURE__ */ e(H, { style: { display: "none" } }),
471
+ /* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
472
+ /* @__PURE__ */ e(
473
+ L,
468
474
  {
469
475
  Label: "Link",
470
476
  type: "url",
471
- value: e,
477
+ value: n,
472
478
  onChange: (r) => i(r.target.value),
473
479
  required: !0
474
480
  }
475
481
  ),
476
- /* @__PURE__ */ o(
477
- k,
482
+ /* @__PURE__ */ e(
483
+ L,
478
484
  {
479
485
  Label: "Text to display",
480
486
  type: "text",
481
- value: l,
482
- onChange: (r) => c(r.target.value)
487
+ value: s,
488
+ onChange: (r) => l(r.target.value)
483
489
  }
484
490
  )
485
491
  ] }),
486
- /* @__PURE__ */ g(x, { children: [
487
- n.isLink && /* @__PURE__ */ o(
488
- b,
492
+ /* @__PURE__ */ v(R, { children: [
493
+ o.isLink && /* @__PURE__ */ e(
494
+ x,
489
495
  {
490
496
  color: "error",
491
497
  onClick: () => t.chain().focus().unsetLink().run(),
@@ -493,27 +499,27 @@ const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut
493
499
  children: "Remove"
494
500
  }
495
501
  ),
496
- /* @__PURE__ */ o(b, { onClick: a, disabled: !e, children: "Save" })
502
+ /* @__PURE__ */ e(x, { onClick: u, disabled: !n, children: "Save" })
497
503
  ] })
498
504
  ]
499
505
  }
500
506
  );
501
- }, Ft = () => {
502
- const { editor: t } = m(), n = f({
507
+ }, Bt = () => {
508
+ const { editor: t } = g(), o = p({
503
509
  editor: t,
504
510
  selector: (r) => ({
505
511
  isTable: r.editor.isActive("table"),
506
512
  tableAttrs: r.editor.getAttributes("table")
507
513
  })
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();
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();
511
517
  }, 100);
512
- }, [t, e]), a = _(() => {
513
- i((r) => !r), l.current = setTimeout(() => {
518
+ }, [t, n]), u = B(() => {
519
+ i((r) => !r), s.current = setTimeout(() => {
514
520
  t.chain().focus().toggleHeaderRow().run();
515
521
  }, 100);
516
- }, [t]), s = [
522
+ }, [t]), c = [
517
523
  {
518
524
  text: "Column left",
519
525
  icon: "wm-add",
@@ -545,67 +551,67 @@ const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut
545
551
  event: () => t.chain().focus().deleteRow().run()
546
552
  }
547
553
  ];
548
- return n.isTable ? /* @__PURE__ */ g(
549
- y,
554
+ return o.isTable ? /* @__PURE__ */ v(
555
+ D,
550
556
  {
551
- Trigger: /* @__PURE__ */ o(
557
+ Trigger: /* @__PURE__ */ e(
552
558
  "button",
553
559
  {
554
- className: d.wuContentEditorAction,
555
- "data-active": n.isTable,
556
- children: /* @__PURE__ */ o(h, { icon: "wm-table" })
560
+ className: a.wuContentEditorAction,
561
+ "data-active": o.isTable,
562
+ children: /* @__PURE__ */ e(f, { icon: "wm-table" })
557
563
  }
558
564
  ),
559
565
  maxWidth: "320px",
560
566
  children: [
561
- /* @__PURE__ */ o(T, { style: { display: "none" } }),
562
- /* @__PURE__ */ g(S, { className: d.wuContentEditorModal, children: [
563
- /* @__PURE__ */ o(
564
- st,
567
+ /* @__PURE__ */ e(H, { style: { display: "none" } }),
568
+ /* @__PURE__ */ v(z, { className: a.wuContentEditorModal, children: [
569
+ /* @__PURE__ */ e(
570
+ ht,
565
571
  {
566
- checked: e,
567
- onClick: a,
572
+ checked: n,
573
+ onClick: u,
568
574
  Label: "Title Row",
569
575
  labelPosition: "left"
570
576
  }
571
577
  ),
572
- /* @__PURE__ */ o("div", { className: d.wuContentEditorTable, children: s.map(({ text: r, icon: u, event: p }) => /* @__PURE__ */ o(
573
- ct,
578
+ /* @__PURE__ */ e("div", { className: a.wuContentEditorTable, children: c.map(({ text: r, icon: d, event: w }) => /* @__PURE__ */ e(
579
+ q,
574
580
  {
575
- onClick: p,
581
+ onClick: w,
576
582
  variant: "secondary",
577
- Icon: /* @__PURE__ */ o(h, { icon: u }),
583
+ Icon: /* @__PURE__ */ e(f, { icon: d }),
578
584
  children: r
579
585
  },
580
586
  r
581
587
  )) })
582
588
  ] }),
583
- /* @__PURE__ */ o(x, { children: /* @__PURE__ */ o(
584
- b,
589
+ /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(
590
+ x,
585
591
  {
586
592
  onClick: () => t.chain().focus().deleteTable().run(),
587
593
  variant: "outline",
588
594
  color: "error",
589
- Icon: /* @__PURE__ */ o("span", { className: "wm-delete" }),
595
+ Icon: /* @__PURE__ */ e("span", { className: "wm-delete" }),
590
596
  iconPosition: "left",
591
597
  children: "Delete Table"
592
598
  }
593
599
  ) })
594
600
  ]
595
601
  }
596
- ) : /* @__PURE__ */ o(
602
+ ) : /* @__PURE__ */ e(
597
603
  "button",
598
604
  {
599
- onClick: c,
600
- className: d.wuContentEditorAction,
601
- children: /* @__PURE__ */ o(h, { icon: "wm-table" })
605
+ onClick: l,
606
+ className: a.wuContentEditorAction,
607
+ children: /* @__PURE__ */ e(f, { icon: "wm-table" })
602
608
  }
603
609
  );
604
- }, Nt = () => {
605
- const { editor: t, customFonts: n } = m(), e = f({
610
+ }, Pt = () => {
611
+ const { editor: t, customFonts: o } = g(), n = p({
606
612
  editor: t,
607
- selector: (a) => ({
608
- currentFontFamily: a.editor.getAttributes("textStyle").fontFamily || ""
613
+ selector: (u) => ({
614
+ currentFontFamily: u.editor.getAttributes("textStyle").fontFamily || ""
609
615
  })
610
616
  }), i = [
611
617
  "Fira Sans",
@@ -613,310 +619,326 @@ const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut
613
619
  "Poppins",
614
620
  "JetBrains Mono",
615
621
  "Montserrat",
616
- ...n || []
617
- ], [l, c] = E(
618
- e.currentFontFamily || i[0]
622
+ ...o || []
623
+ ], [s, l] = I(
624
+ n.currentFontFamily || i[0]
619
625
  );
620
- return C.useEffect(() => {
621
- var a;
622
- c(
623
- ((a = e.currentFontFamily) == null ? void 0 : a.replace(/"/g, "")) || i[0]
626
+ return h.useEffect(() => {
627
+ var u;
628
+ l(
629
+ ((u = n.currentFontFamily) == null ? void 0 : u.replace(/"/g, "")) || i[0]
624
630
  );
625
- }, [e.currentFontFamily]), /* @__PURE__ */ g(M, { children: [
626
- /* @__PURE__ */ o(
627
- H,
631
+ }, [n.currentFontFamily]), /* @__PURE__ */ v(j, { children: [
632
+ /* @__PURE__ */ e(
633
+ $,
628
634
  {
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]
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]
634
640
  }
635
641
  ),
636
- /* @__PURE__ */ o(
637
- z,
642
+ /* @__PURE__ */ e(
643
+ K,
638
644
  {
639
645
  align: "start",
640
- className: d.wuContentEditorDropdown,
646
+ className: a.wuContentEditorDropdown,
641
647
  "data-block": !0,
642
- onCloseAutoFocus: (a) => a.preventDefault(),
643
- children: i.map((a) => /* @__PURE__ */ o(
644
- B,
648
+ onCloseAutoFocus: (u) => u.preventDefault(),
649
+ children: i.map((u) => /* @__PURE__ */ e(
650
+ U,
645
651
  {
646
- title: a,
647
- className: d.wuContentEditorDropdownItem,
652
+ title: u,
653
+ className: a.wuContentEditorDropdownItem,
648
654
  onSelect: () => {
649
- t.chain().focus().setFontFamily(a).run(), c(a);
655
+ t.chain().focus().setFontFamily(u).run(), l(u);
650
656
  },
651
- children: a
657
+ children: u
652
658
  },
653
- a
659
+ u
654
660
  ))
655
661
  }
656
662
  )
657
663
  ] });
658
- }, Dt = () => {
659
- const { editor: t } = m(), n = f({
664
+ }, Wt = () => {
665
+ const { editor: t } = g(), o = p({
660
666
  editor: t,
661
- selector: (e) => {
667
+ selector: (n) => {
662
668
  var i;
663
669
  return {
664
- italic: (i = e.editor) == null ? void 0 : i.isActive("italic")
670
+ italic: (i = n.editor) == null ? void 0 : i.isActive("italic")
665
671
  };
666
672
  }
667
673
  });
668
- return /* @__PURE__ */ o(
674
+ return /* @__PURE__ */ e(
669
675
  "button",
670
676
  {
671
677
  title: "Italic",
672
- className: d.wuContentEditorAction,
673
- "data-active": n.italic,
674
- onClick: (e) => {
675
- e.preventDefault(), t.chain().focus().toggleItalic().run();
678
+ className: a.wuContentEditorAction,
679
+ "data-active": o.italic,
680
+ onClick: (n) => {
681
+ n.preventDefault(), t.chain().focus().toggleItalic().run();
676
682
  },
677
- children: /* @__PURE__ */ o(h, { icon: "wm-format-italic" })
683
+ children: /* @__PURE__ */ e(f, { icon: "wm-format-italic" })
678
684
  }
679
685
  );
680
- }, _t = () => {
681
- const { editor: t } = m(), n = f({
686
+ }, qt = () => {
687
+ const { editor: t } = g(), o = p({
682
688
  editor: t,
683
689
  selector: (i) => {
684
- var l, c, a, s, r, u;
690
+ var s, l, u, c, r, d;
685
691
  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"))
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"))
690
696
  };
691
697
  }
692
- }), e = [
698
+ }), n = [
693
699
  {
694
700
  id: "ul",
695
701
  icon: "wm-format-list-bulleted",
696
702
  event: () => t.chain().focus().toggleBulletList().run(),
697
- active: n.isUl,
703
+ active: o.isUl,
698
704
  tooltip: "Bulleted List"
699
705
  },
700
706
  {
701
707
  id: "ol",
702
708
  icon: "wm-format-list-numbered",
703
709
  event: () => t.chain().focus().toggleOrderedList().run(),
704
- active: n.isOl,
710
+ active: o.isOl,
705
711
  tooltip: "Numbered List"
706
712
  },
707
713
  {
708
714
  id: "todo",
709
715
  icon: "wm-checklist",
710
716
  event: () => t.chain().focus().toggleTaskList().run(),
711
- active: n.isTodo,
717
+ active: o.isTodo,
712
718
  tooltip: "To-Do List"
713
719
  }
714
720
  ];
715
- return /* @__PURE__ */ o(
716
- L,
721
+ return /* @__PURE__ */ e(
722
+ M,
717
723
  {
718
724
  action: {
719
725
  id: "style",
720
- active: n.isList,
726
+ active: o.isList,
721
727
  icon: "wm-format-paragraph",
722
- items: e
728
+ items: n
723
729
  }
724
730
  }
725
731
  );
726
- }, It = ["e", "E", "+", "-"], I = 1, Rt = () => {
727
- const { editor: t } = m(), [n, e] = E(16), i = f({
732
+ }, jt = ["e", "E", "+", "-"], P = 1, $t = () => {
733
+ const { editor: t } = g(), [o, n] = I(16), i = p({
728
734
  editor: t,
729
- selector: (s) => ({
730
- fontSize: s.editor.getAttributes("textStyle").fontSize
735
+ selector: (c) => ({
736
+ fontSize: c.editor.getAttributes("textStyle").fontSize
731
737
  })
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);
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);
739
745
  };
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(
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(
745
751
  "button",
746
752
  {
747
- className: d.wuContentEditorAction,
748
- onClick: () => c(n - 1),
749
- disabled: n <= I,
753
+ className: a.wuContentEditorAction,
754
+ onClick: () => l(o - 1),
755
+ disabled: o <= P,
750
756
  children: "−"
751
757
  }
752
758
  ),
753
- /* @__PURE__ */ o(
759
+ /* @__PURE__ */ e(
754
760
  "input",
755
761
  {
756
762
  type: "number",
757
763
  inputMode: "numeric",
758
764
  pattern: "[0-9]*",
759
- value: n,
760
- onKeyDown: a,
761
- onChange: (s) => e(s.target.valueAsNumber),
762
- onBlur: () => l(n)
765
+ value: o,
766
+ onKeyDown: u,
767
+ onChange: (c) => n(c.target.valueAsNumber),
768
+ onBlur: () => s(o)
763
769
  }
764
770
  ),
765
- /* @__PURE__ */ o(
771
+ /* @__PURE__ */ e(
766
772
  "button",
767
773
  {
768
- className: d.wuContentEditorAction,
769
- onClick: () => c(n + 1),
770
- disabled: n >= 128,
774
+ className: a.wuContentEditorAction,
775
+ onClick: () => l(o + 1),
776
+ disabled: o >= 128,
771
777
  children: "+"
772
778
  }
773
779
  )
774
780
  ] });
775
- }, Mt = () => {
776
- const { editor: t } = m(), n = f({
781
+ }, Kt = () => {
782
+ const { editor: t } = g(), o = p({
777
783
  editor: t,
778
- selector: (e) => {
784
+ selector: (n) => {
779
785
  var i;
780
786
  return {
781
- strikethrough: (i = e.editor) == null ? void 0 : i.isActive("strike")
787
+ strikethrough: (i = n.editor) == null ? void 0 : i.isActive("strike")
782
788
  };
783
789
  }
784
790
  });
785
- return /* @__PURE__ */ o(
791
+ return /* @__PURE__ */ e(
786
792
  "button",
787
793
  {
788
794
  title: "strikethrough",
789
- className: d.wuContentEditorAction,
790
- "data-active": n.strikethrough,
791
- onClick: (e) => {
792
- e.preventDefault(), t.chain().focus().toggleStrike().run();
795
+ className: a.wuContentEditorAction,
796
+ "data-active": o.strikethrough,
797
+ onClick: (n) => {
798
+ n.preventDefault(), t.chain().focus().toggleStrike().run();
793
799
  },
794
- children: /* @__PURE__ */ o(h, { icon: "wm-format-strikethrough" })
800
+ children: /* @__PURE__ */ e(f, { icon: "wm-format-strikethrough" })
795
801
  }
796
802
  );
797
- }, Ht = () => {
798
- const { editor: t } = m(), n = f({
803
+ }, Ut = () => {
804
+ const { editor: t } = g(), o = p({
799
805
  editor: t,
800
- selector: (e) => {
806
+ selector: (n) => {
801
807
  var i;
802
808
  return {
803
- subscript: (i = e.editor) == null ? void 0 : i.isActive("subscript")
809
+ subscript: (i = n.editor) == null ? void 0 : i.isActive("subscript")
804
810
  };
805
811
  }
806
812
  });
807
- return /* @__PURE__ */ o(
813
+ return /* @__PURE__ */ e(
808
814
  "button",
809
815
  {
810
816
  title: "Subscript",
811
- className: d.wuContentEditorAction,
812
- "data-active": n.subscript,
813
- onClick: (e) => {
814
- e.preventDefault(), t.chain().focus().toggleSubscript().run();
817
+ className: a.wuContentEditorAction,
818
+ "data-active": o.subscript,
819
+ onClick: (n) => {
820
+ n.preventDefault(), t.chain().focus().toggleSubscript().run();
815
821
  },
816
- children: /* @__PURE__ */ o(h, { icon: "wm-subscript" })
822
+ children: /* @__PURE__ */ e(f, { icon: "wm-subscript" })
817
823
  }
818
824
  );
819
- }, zt = () => {
820
- const { editor: t } = m(), n = f({
825
+ }, Jt = () => {
826
+ const { editor: t } = g(), o = p({
821
827
  editor: t,
822
- selector: (e) => {
828
+ selector: (n) => {
823
829
  var i;
824
830
  return {
825
- superscript: (i = e.editor) == null ? void 0 : i.isActive("superscript")
831
+ superscript: (i = n.editor) == null ? void 0 : i.isActive("superscript")
826
832
  };
827
833
  }
828
834
  });
829
- return /* @__PURE__ */ o(
835
+ return /* @__PURE__ */ e(
830
836
  "button",
831
837
  {
832
838
  title: "Superscript",
833
- className: d.wuContentEditorAction,
834
- "data-active": n.superscript,
835
- onClick: (e) => {
836
- e.preventDefault(), t.chain().focus().toggleSuperscript().run();
839
+ className: a.wuContentEditorAction,
840
+ "data-active": o.superscript,
841
+ onClick: (n) => {
842
+ n.preventDefault(), t.chain().focus().toggleSuperscript().run();
837
843
  },
838
- children: /* @__PURE__ */ o(h, { icon: "wm-superscript" })
844
+ children: /* @__PURE__ */ e(f, { icon: "wm-superscript" })
839
845
  }
840
846
  );
841
- }, Bt = () => {
842
- const { editor: t } = m(), n = f({
847
+ }, Gt = () => {
848
+ const { editor: t } = g(), o = p({
843
849
  editor: t,
844
- selector: ({ editor: e }) => ({
845
- textColor: e.getAttributes("textStyle").color
850
+ selector: ({ editor: n }) => ({
851
+ textColor: n.getAttributes("textStyle").color
846
852
  })
847
853
  });
848
- return /* @__PURE__ */ g(
854
+ return /* @__PURE__ */ v(
849
855
  "label",
850
856
  {
851
- className: d.wuContentEditorAction,
857
+ className: a.wuContentEditorAction,
852
858
  htmlFor: "text-color",
853
859
  title: "Text Color",
854
860
  children: [
855
- /* @__PURE__ */ o(
856
- h,
861
+ /* @__PURE__ */ e(
862
+ f,
857
863
  {
858
864
  icon: "wm-format-color-text",
859
- className: d.bgColorCursorPointer,
860
- style: { color: n.textColor }
865
+ className: a.bgColorCursorPointer,
866
+ style: { color: o.textColor }
861
867
  }
862
868
  ),
863
- /* @__PURE__ */ o(
869
+ /* @__PURE__ */ e(
864
870
  "input",
865
871
  {
866
872
  type: "color",
867
- className: d.bgColorHiddenInput,
873
+ className: a.bgColorHiddenInput,
868
874
  id: "text-color",
869
875
  defaultValue: "#545E6B",
870
- onChange: (e) => t.chain().focus().setColor(e.target.value).run()
876
+ onChange: (n) => t.chain().focus().setColor(n.target.value).run()
871
877
  }
872
878
  )
873
879
  ]
874
880
  }
875
881
  );
876
- }, Ot = () => {
877
- const { editor: t } = m(), n = f({
882
+ }, Vt = () => {
883
+ const { editor: t } = g(), o = p({
878
884
  editor: t,
879
- selector: (e) => {
885
+ selector: (n) => {
880
886
  var i;
881
887
  return {
882
- underline: (i = e.editor) == null ? void 0 : i.isActive("underline")
888
+ underline: (i = n.editor) == null ? void 0 : i.isActive("underline")
883
889
  };
884
890
  }
885
891
  });
886
- return /* @__PURE__ */ o(
892
+ return /* @__PURE__ */ e(
887
893
  "button",
888
894
  {
889
895
  title: "Underline",
890
- className: d.wuContentEditorAction,
891
- "data-active": n.underline,
892
- onClick: (e) => {
893
- e.preventDefault(), t.chain().focus().toggleUnderline().run();
896
+ className: a.wuContentEditorAction,
897
+ "data-active": o.underline,
898
+ onClick: (n) => {
899
+ n.preventDefault(), t.chain().focus().toggleUnderline().run();
894
900
  },
895
- children: /* @__PURE__ */ o(h, { icon: "wm-format-underlined" })
901
+ children: /* @__PURE__ */ e(f, { icon: "wm-format-underlined" })
896
902
  }
897
903
  );
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, {}),
904
+ };
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
+ );
919
+ }
920
+ const W = {
921
+ block: /* @__PURE__ */ e(It, {}),
922
+ fontFamily: /* @__PURE__ */ e(Pt, {}),
923
+ fontSize: /* @__PURE__ */ e($t, {}),
924
+ bold: /* @__PURE__ */ e(Ht, {}),
925
+ italic: /* @__PURE__ */ e(Wt, {}),
926
+ underline: /* @__PURE__ */ e(Vt, {}),
927
+ strike: /* @__PURE__ */ e(Kt, {}),
928
+ color: /* @__PURE__ */ e(Gt, {}),
929
+ bgColor: /* @__PURE__ */ e(Nt, {}),
930
+ list: /* @__PURE__ */ e(qt, {}),
931
+ alignment: /* @__PURE__ */ e(_t, {}),
932
+ image: /* @__PURE__ */ e(Mt, {}),
933
+ link: /* @__PURE__ */ e(Ot, {}),
934
+ table: /* @__PURE__ */ e(Bt, {}),
935
+ blockquote: /* @__PURE__ */ e(Dt, {}),
936
+ superscript: /* @__PURE__ */ e(Jt, {}),
937
+ subscript: /* @__PURE__ */ e(Ut, {}),
938
+ codeline: /* @__PURE__ */ e(Rt, {}),
939
+ clear: /* @__PURE__ */ e(zt, {}),
918
940
  // eslint-disable-next-line @typescript-eslint/naming-convention
919
- "|": /* @__PURE__ */ o(
941
+ "|": /* @__PURE__ */ e(
920
942
  "div",
921
943
  {
922
944
  style: {
@@ -925,8 +947,9 @@ const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut
925
947
  background: "rgb(var(--wu-gray-40))"
926
948
  }
927
949
  }
928
- )
929
- }, Wt = [
950
+ ),
951
+ html: /* @__PURE__ */ e(Xt, {})
952
+ }, Yt = [
930
953
  "block",
931
954
  "fontFamily",
932
955
  "|",
@@ -952,15 +975,33 @@ const at = "_wuContentEditor_399u0_8", dt = "_wuContentEditorTable_399u0_1", ut
952
975
  "subscript",
953
976
  "codeline",
954
977
  "|",
978
+ "html",
955
979
  "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)),
960
- i
961
- ] }) });
962
- }, F = lt();
963
- F.setConfig({
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
+ {
993
+ editor: o,
994
+ 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({
964
1005
  USE_PROFILES: { html: !0 },
965
1006
  ALLOWED_TAGS: [
966
1007
  "div",
@@ -1012,72 +1053,169 @@ F.setConfig({
1012
1053
  ],
1013
1054
  ALLOW_DATA_ATTR: !0
1014
1055
  });
1015
- F.addHook("uponSanitizeAttribute", (t, n) => {
1016
- if (n.attrName === "style") {
1017
- const e = n.attrValue.toLowerCase();
1018
- (e.includes("expression") || e.includes("javascript:") || e.includes("url(")) && (n.keepAttr = !1);
1056
+ O.addHook("uponSanitizeAttribute", (t, o) => {
1057
+ if (o.attrName === "style") {
1058
+ const n = o.attrValue.toLowerCase();
1059
+ (n.includes("expression") || n.includes("javascript:") || n.includes("url(")) && (o.keepAttr = !1);
1019
1060
  }
1020
1061
  });
1021
- function A(t) {
1022
- return t ? F.sanitize(t) : "";
1062
+ function S(t) {
1063
+ return t ? O.sanitize(t) : "";
1064
+ }
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;
1073
+ }
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 || " ", {
1100
+ lang: "html",
1101
+ theme: "github-light"
1102
+ });
1103
+ u(T);
1104
+ }).catch((m) => console.error("Highlight error:", m));
1105
+ }, []);
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;
1121
+ });
1122
+ }
1123
+ };
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
+ ] }) }) });
1023
1153
  }
1024
- function ie({
1154
+ function pe({
1025
1155
  defaultValue: t,
1026
- onUpdate: n,
1027
- className: e,
1156
+ onUpdate: o,
1157
+ className: n,
1028
1158
  toolbarPosition: i = "top",
1029
- customToolbarChildren: l,
1030
- toolbarItems: c,
1031
- hideToolbar: a,
1032
- readonly: s,
1159
+ customToolbarChildren: s,
1160
+ toolbarItems: l,
1161
+ hideToolbar: u,
1162
+ readonly: c,
1033
1163
  customFonts: r,
1034
- renderDefaultOnly: u,
1035
- ...p
1164
+ isHtml: d,
1165
+ setIsHtml: w,
1166
+ ...k
1036
1167
  }) {
1037
- const w = q({
1038
- extensions: Ct,
1039
- content: A(t || ""),
1040
- onUpdate: ({ editor: v }) => {
1041
- n && n(A(v.getHTML()));
1168
+ const [A, y] = h.useState(d ?? !1), E = h.useRef(t || ""), b = V({
1169
+ editable: !c,
1170
+ extensions: Ft,
1171
+ content: S(t || ""),
1172
+ onUpdate: ({ editor: m }) => {
1173
+ o && o(S(m.getHTML()));
1042
1174
  }
1043
- });
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(
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);
1177
+ };
1178
+ return /* @__PURE__ */ v(
1054
1179
  "div",
1055
1180
  {
1056
- className: D(d.wuContentEditorContainer, e),
1181
+ className: Y(a.wuContentEditorContainer, n),
1057
1182
  "data-position": i,
1058
1183
  "data-slot": "wu-content-editor-container",
1059
1184
  onClick: () => {
1060
- w == null || w.chain().focus().run();
1185
+ A || b == null || b.chain().focus().run();
1061
1186
  },
1062
- ...p,
1187
+ ...k,
1063
1188
  children: [
1064
- !a && /* @__PURE__ */ o(
1065
- Ut,
1189
+ !u && /* @__PURE__ */ e(
1190
+ Zt,
1066
1191
  {
1067
- editor: w,
1192
+ editor: b,
1068
1193
  customFonts: r,
1069
- className: d.wuContentEditorToolbar,
1070
- items: c,
1194
+ className: a.wuContentEditorToolbar,
1195
+ items: l,
1196
+ isHtml: A,
1197
+ setIsHtml: C,
1071
1198
  "data-slot": "wu-content-editor-toolbar",
1072
1199
  "data-position": i,
1073
- children: l
1200
+ children: s
1074
1201
  }
1075
1202
  ),
1076
- /* @__PURE__ */ o(
1077
- $,
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,
1078
1216
  {
1079
- editor: w,
1080
- className: d.wuContentEditor,
1217
+ editor: b,
1218
+ className: a.wuContentEditor,
1081
1219
  "data-slot": "wu-content-editor"
1082
1220
  }
1083
1221
  )
@@ -1086,5 +1224,5 @@ function ie({
1086
1224
  );
1087
1225
  }
1088
1226
  export {
1089
- ie as WuContentEditor
1227
+ pe as WuContentEditor
1090
1228
  };