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