@npm-questionpro/wick-ui-editor 2.0.0-next.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,768 +1,848 @@
1
- import { EditorContent as G, useEditor as V, useEditorState as f } from "@tiptap/react";
2
- import X from "clsx";
3
- import m, { useCallback as O, useRef as Y, useState as N } from "react";
4
- import Z from "@tiptap/extension-image";
5
- import { TaskItem as Q, TaskList as tt } from "@tiptap/extension-list";
6
- import et from "@tiptap/extension-subscript";
7
- import ot from "@tiptap/extension-superscript";
8
- import { TableKit as nt } from "@tiptap/extension-table";
9
- import it from "@tiptap/extension-text-align";
10
- import { BackgroundColor as rt, Color as lt, FontFamily as at, FontSize as st, LineHeight as ct, TextStyle as ut } from "@tiptap/extension-text-style";
11
- import dt from "@tiptap/starter-kit";
12
- import { Fragment as x, jsx as e, jsxs as v } from "react/jsx-runtime";
13
- import { WuButton as q, WuIcon as h, WuInput as F, WuModal as H, WuModalClose as _, WuModalContent as D, WuModalFooter as R, WuModalHeader as z, WuToggle as mt } from "@npm-questionpro/wick-ui-lib";
14
- import { DropdownMenu as U, DropdownMenuContent as j, DropdownMenuItem as $, DropdownMenuTrigger as K } from "@radix-ui/react-dropdown-menu";
15
- import ht from "dompurify";
16
- var pt = "_wuContentEditor_cl3h6_7", ft = "_wuContentEditorTable_cl3h6_1", gt = "_selectedCell_cl3h6_1", vt = "_tableWrapper_cl3h6_1", wt = "_wuContentEditorContainer_cl3h6_7", Ct = "_wuContentEditorToolbar_cl3h6_82", bt = "_wuContentEditorAction_cl3h6_110", At = "_wuContentEditorDropdown_cl3h6_136", yt = "_wuContentEditorDropdownItem_cl3h6_150", kt = "_wuContentEditorFontSize_cl3h6_162", Et = "_wuContentEditorModal_cl3h6_176", Tt = "_wuCodeEditor_cl3h6_180", St = "_wuFormatCode_cl3h6_190", _t = "_wuCodeEditorPreview_cl3h6_205", xt = "_wuCodeEditorInput_cl3h6_222", a = {
17
- wuContentEditor: pt,
18
- wuContentEditorTable: ft,
19
- selectedCell: gt,
20
- "column-resize-handle": "_column-resize-handle_cl3h6_1",
21
- tableWrapper: vt,
22
- "resize-cursor": "_resize-cursor_cl3h6_1",
23
- wuContentEditorContainer: wt,
24
- wuContentEditorToolbar: Ct,
25
- wuContentEditorAction: bt,
26
- wuContentEditorDropdown: At,
27
- wuContentEditorDropdownItem: yt,
28
- wuContentEditorFontSize: kt,
29
- wuContentEditorModal: Et,
30
- wuCodeEditor: Tt,
31
- wuFormatCode: St,
32
- wuCodeEditorPreview: _t,
33
- wuCodeEditorInput: xt
34
- }, Ft = [
35
- dt.configure({ link: {
1
+ import { A as K, C as J, D as de, E as ue, M as he, O as fe, S as ve, T as Q, _ as V, a as X, b as pe, c as ge, d as me, f as be, g as Y, h as Z, i as G, j as ke, k as Ce, l as ee, m as D, n as R, o as te, r as oe, s as _e, t as F, u as Ae, v as ie, w as re, x as we, y as Ie } from "../../sanitize-BZ0U7q7z.js";
2
+ import { EditorContent as Te, useEditor as ye, useEditorState as v } from "@tiptap/react";
3
+ import u, { useCallback as B, useRef as Se, useState as O } from "react";
4
+ import xe from "@tiptap/extension-image";
5
+ import { TaskItem as He, TaskList as Le } from "@tiptap/extension-list";
6
+ import Re from "@tiptap/extension-subscript";
7
+ import Fe from "@tiptap/extension-superscript";
8
+ import { TableKit as Ee } from "@tiptap/extension-table";
9
+ import Ne from "@tiptap/extension-text-align";
10
+ import { BackgroundColor as De, Color as Be, FontFamily as ze, FontSize as Pe, LineHeight as Oe, TextStyle as Me } from "@tiptap/extension-text-style";
11
+ import qe from "@tiptap/starter-kit";
12
+ import { Fragment as N, jsx as e, jsxs as f } from "react/jsx-runtime";
13
+ import { Menu as g } from "@base-ui/react/menu";
14
+ import { Dialog as w } from "@base-ui/react/dialog";
15
+ import { Switch as ne } from "@base-ui/react/switch";
16
+ var $e = [
17
+ qe.configure({ link: {
36
18
  openOnClick: !1,
37
19
  autolink: !0,
38
20
  defaultProtocol: "https",
39
21
  protocols: ["http", "https"],
40
- isAllowedUri: (t, o) => {
22
+ isAllowedUri: (o, t) => {
41
23
  try {
42
- const n = t.includes(":") ? new URL(t) : new URL(`${o.defaultProtocol}://${t}`);
43
- if (!o.defaultValidate(n.href)) return !1;
44
- const i = [
24
+ const i = o.includes(":") ? new URL(o) : new URL(`${t.defaultProtocol}://${o}`);
25
+ if (!t.defaultValidate(i.href)) return !1;
26
+ const r = [
45
27
  "ftp",
46
28
  "file",
47
29
  "mailto"
48
- ], r = n.protocol.replace(":", "");
49
- if (i.includes(r) || !o.protocols.map((l) => typeof l == "string" ? l : l.scheme).includes(r)) return !1;
50
- const u = ["example-phishing.com", "malicious-site.net"], c = n.hostname;
51
- return !u.includes(c);
30
+ ], n = i.protocol.replace(":", "");
31
+ if (r.includes(n) || !t.protocols.map((s) => typeof s == "string" ? s : s.scheme).includes(n)) return !1;
32
+ const c = ["example-phishing.com", "malicious-site.net"], l = i.hostname;
33
+ return !c.includes(l);
52
34
  } catch {
53
35
  return !1;
54
36
  }
55
37
  },
56
- shouldAutoLink: (t) => {
38
+ shouldAutoLink: (o) => {
57
39
  try {
58
- const o = t.includes(":") ? new URL(t) : new URL(`https://${t}`), n = ["example-no-autolink.com", "another-no-autolink.com"], i = o.hostname;
59
- return !n.includes(i);
40
+ const t = o.includes(":") ? new URL(o) : new URL(`https://${o}`), i = ["example-no-autolink.com", "another-no-autolink.com"], r = t.hostname;
41
+ return !i.includes(r);
60
42
  } catch {
61
43
  return !1;
62
44
  }
63
45
  }
64
46
  } }),
65
- it.configure({ types: ["heading", "paragraph"] }),
66
- ot,
67
- et,
68
- ut,
69
- lt,
70
- rt,
71
- tt,
72
- Q,
73
- ct,
74
- st,
75
- at,
76
- Z.configure({
47
+ Ne.configure({ types: ["heading", "paragraph"] }),
48
+ Fe,
49
+ Re,
50
+ Me,
51
+ Be,
52
+ De,
53
+ Le,
54
+ He,
55
+ Oe,
56
+ Pe,
57
+ ze,
58
+ xe.configure({
77
59
  resize: {
78
60
  enabled: !0,
79
61
  alwaysPreserveAspectRatio: !0
80
62
  },
81
63
  inline: !0
82
64
  }),
83
- nt.configure({ table: { resizable: !0 } })
84
- ], J = m.createContext(null), Lt = ({ editor: t, children: o, customFonts: n, isHtml: i, setIsHtml: r }) => /* @__PURE__ */ e(J.Provider, {
65
+ Ee.configure({ table: { resizable: !0 } })
66
+ ], M = u.createContext(null), Ue = ({ editor: o, children: t, customFonts: i, isHtml: r, setIsHtml: n, htmlSourceEnabled: c }) => /* @__PURE__ */ e(M.Provider, {
85
67
  value: {
86
- editor: t,
87
- customFonts: n,
88
- isHtml: i,
89
- setIsHtml: r
68
+ editor: o,
69
+ customFonts: i,
70
+ isHtml: r,
71
+ setIsHtml: n,
72
+ htmlSourceEnabled: c
90
73
  },
74
+ children: t
75
+ }), h = () => {
76
+ const o = u.useContext(M);
77
+ if (!o) throw new Error("useToolbar must be used within a ToolbarProvider");
78
+ return o;
79
+ }, We = "_dropdown_k3z4n_1", je = "_dropdownItem_k3z4n_17", se = {
80
+ dropdown: We,
81
+ dropdownItem: je
82
+ }, Ke = "_item_wqnwe_1", Je = { item: Ke }, d = u.forwardRef(function({ Icon: t, children: i, ...r }, n) {
83
+ return /* @__PURE__ */ f("button", {
84
+ ref: n,
85
+ ...r,
86
+ className: Je.item,
87
+ children: [
88
+ t,
89
+ " ",
90
+ i
91
+ ]
92
+ });
93
+ }), q = u.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
94
+ ref: i,
95
+ className: se.dropdown,
96
+ ...t,
91
97
  children: o
92
- }), p = () => {
93
- const t = m.useContext(J);
94
- if (!t) throw new Error("useToolbar must be used within a ToolbarProvider");
95
- return t;
96
- }, M = ({ action: t, defaultValue: o }) => {
97
- const [n, i] = m.useState(o || t.items.find((r) => r.active) || t.items[0]);
98
- return m.useEffect(() => {
99
- i(o || t.items.find((r) => r.active) || t.items[0]);
100
- }, [t, o]), /* @__PURE__ */ v(U, { children: [/* @__PURE__ */ e(K, {
101
- className: a.wuContentEditorAction,
102
- "data-active": t.active,
103
- children: /* @__PURE__ */ e(h, { icon: n.icon })
104
- }), /* @__PURE__ */ e(j, {
105
- align: "start",
106
- onCloseAutoFocus: (r) => r.preventDefault(),
107
- className: a.wuContentEditorDropdown,
108
- "data-inline": !0,
109
- children: t.items?.map((r) => /* @__PURE__ */ e($, {
110
- onClick: () => {
111
- r.event(), i(r);
112
- },
113
- title: r.tooltip,
114
- children: /* @__PURE__ */ e("button", {
115
- type: "button",
116
- className: a.wuContentEditorAction,
117
- "data-active": r.active,
118
- children: /* @__PURE__ */ e(h, { icon: r.icon })
119
- })
120
- }, r.id))
121
- })] });
122
- }, It = () => {
123
- const { editor: t } = p(), o = f({
124
- editor: t,
125
- selector: (i) => ({
126
- isLeft: i.editor?.isActive({ textAlign: "left" }),
127
- isCenter: i.editor?.isActive({ textAlign: "center" }),
128
- isRight: i.editor?.isActive({ textAlign: "right" }),
129
- isJustify: i.editor?.isActive({ textAlign: "justify" }),
130
- isAligned: i.editor?.isActive({ textAlign: "center" }) || i.editor?.isActive({ textAlign: "right" }) || i.editor?.isActive({ textAlign: "justify" })
98
+ }));
99
+ q.displayName = "DropdownPopup";
100
+ var $ = u.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
101
+ ref: i,
102
+ className: se.dropdownItem,
103
+ ...t,
104
+ children: o
105
+ }));
106
+ $.displayName = "DropdownItem";
107
+ function U({ trigger: o, triggerTitle: t, active: i, items: r, align: n = "start", direction: c = "inline" }) {
108
+ return /* @__PURE__ */ f(g.Root, { children: [/* @__PURE__ */ e(g.Trigger, {
109
+ render: /* @__PURE__ */ e(d, {}),
110
+ "data-active": i,
111
+ title: t,
112
+ children: o
113
+ }), /* @__PURE__ */ e(g.Portal, { children: /* @__PURE__ */ e(g.Positioner, {
114
+ align: n,
115
+ sideOffset: 4,
116
+ children: /* @__PURE__ */ e(g.Popup, {
117
+ render: /* @__PURE__ */ e(q, {}),
118
+ "data-inline": c === "inline" ? !0 : void 0,
119
+ "data-block": c === "block" ? !0 : void 0,
120
+ finalFocus: !1,
121
+ children: r.map((l) => c === "block" ? /* @__PURE__ */ e(g.Item, {
122
+ render: /* @__PURE__ */ e($, {}),
123
+ title: l.tooltip,
124
+ "data-active": l.active,
125
+ style: l.style,
126
+ onClick: l.event,
127
+ children: l.icon ?? l.label
128
+ }, l.id) : /* @__PURE__ */ e(g.Item, {
129
+ render: /* @__PURE__ */ e(d, {}),
130
+ "data-active": l.active,
131
+ title: l.tooltip,
132
+ onClick: l.event,
133
+ children: l.icon ?? l.label
134
+ }, l.id))
131
135
  })
132
- }), n = [
133
- {
134
- id: "left",
135
- icon: "wm-format-align-left",
136
- event: () => t.chain().focus().setTextAlign("left").run(),
137
- tooltip: "Align Left",
138
- active: o.isLeft
139
- },
140
- {
141
- id: "center",
142
- icon: "wm-format-align-center",
143
- event: () => t.chain().focus().setTextAlign("center").run(),
144
- tooltip: "Align Center",
145
- active: o.isCenter
146
- },
147
- {
148
- id: "right",
149
- icon: "wm-format-align-right",
150
- event: () => t.chain().focus().setTextAlign("right").run(),
151
- tooltip: "Align Right",
152
- active: o.isRight
153
- },
154
- {
155
- id: "justify",
156
- icon: "wm-format-align-justify",
157
- event: () => t.chain().focus().setTextAlign("justify").run(),
158
- tooltip: "Justify",
159
- active: o.isJustify
160
- }
161
- ];
162
- return /* @__PURE__ */ e(M, { action: {
163
- id: "style",
164
- active: o.isAligned,
165
- icon: "wm-format-paragraph",
166
- items: n
167
- } });
168
- }, Nt = () => {
169
- const { editor: t } = p(), o = f({
170
- editor: t,
171
- selector: ({ editor: n }) => ({ bgColor: n.getAttributes("textStyle").backgroundColor })
172
- });
173
- return /* @__PURE__ */ v("label", {
174
- className: a.wuContentEditorAction,
175
- htmlFor: "bg-color",
176
- title: "Background Color",
177
- children: [/* @__PURE__ */ e(h, {
178
- icon: "wm-border-color",
179
- style: { color: o.bgColor }
180
- }), /* @__PURE__ */ e("input", {
181
- type: "color",
182
- id: "bg-color",
183
- name: "bg-color",
184
- defaultValue: "#fff",
185
- onChange: (n) => t.chain().focus().setBackgroundColor(n.target.value).run()
186
- })]
187
- });
188
- }, Ht = () => {
189
- const { editor: t } = p(), o = f({
190
- editor: t,
191
- selector: (i) => ({
192
- isParagraph: i.editor?.isActive("paragraph"),
193
- isH1: i.editor?.isActive("heading", { level: 1 }),
194
- isH2: i.editor?.isActive("heading", { level: 2 }),
195
- isH3: i.editor?.isActive("heading", { level: 3 }),
196
- isH4: i.editor?.isActive("heading", { level: 4 }),
197
- isStyle: i.editor?.isActive("heading")
136
+ }) })] });
137
+ }
138
+ var Qe = () => {
139
+ const { editor: o } = h(), t = v({
140
+ editor: o,
141
+ selector: (r) => ({
142
+ isParagraph: r.editor?.isActive("paragraph"),
143
+ isH1: r.editor?.isActive("heading", { level: 1 }),
144
+ isH2: r.editor?.isActive("heading", { level: 2 }),
145
+ isH3: r.editor?.isActive("heading", { level: 3 }),
146
+ isH4: r.editor?.isActive("heading", { level: 4 }),
147
+ isHeading: r.editor?.isActive("heading")
198
148
  })
199
- }), n = [
149
+ }), i = [
200
150
  {
201
151
  id: "paragraph",
202
- icon: "wm-format-paragraph",
203
- event: () => t.chain().focus().setParagraph().run(),
204
- active: o.isParagraph
152
+ icon: /* @__PURE__ */ e(Q, {}),
153
+ event: () => o.chain().focus().setParagraph().run(),
154
+ tooltip: "Paragraph",
155
+ active: t.isParagraph
205
156
  },
206
157
  {
207
158
  id: "h1",
208
- icon: "wm-format-h1",
209
- event: () => t.chain().focus().setHeading({ level: 1 }).run(),
210
- active: o.isH1
159
+ icon: /* @__PURE__ */ e(Z, {}),
160
+ event: () => o.chain().focus().setHeading({ level: 1 }).run(),
161
+ tooltip: "Heading 1",
162
+ active: t.isH1
211
163
  },
212
164
  {
213
165
  id: "h2",
214
- icon: "wm-format-h2",
215
- event: () => t.chain().focus().setHeading({ level: 2 }).run(),
216
- active: o.isH2
166
+ icon: /* @__PURE__ */ e(Y, {}),
167
+ event: () => o.chain().focus().setHeading({ level: 2 }).run(),
168
+ tooltip: "Heading 2",
169
+ active: t.isH2
217
170
  },
218
171
  {
219
172
  id: "h3",
220
- icon: "wm-format-h3",
221
- event: () => t.chain().focus().setHeading({ level: 3 }).run(),
222
- active: o.isH3
173
+ icon: /* @__PURE__ */ e(V, {}),
174
+ event: () => o.chain().focus().setHeading({ level: 3 }).run(),
175
+ tooltip: "Heading 3",
176
+ active: t.isH3
223
177
  },
224
178
  {
225
179
  id: "h4",
226
- icon: "wm-format-h4",
227
- event: () => t.chain().focus().setHeading({ level: 4 }).run(),
228
- active: o.isH4
180
+ icon: /* @__PURE__ */ e(ie, {}),
181
+ event: () => o.chain().focus().setHeading({ level: 4 }).run(),
182
+ tooltip: "Heading 4",
183
+ active: t.isH4
229
184
  }
230
185
  ];
231
- return /* @__PURE__ */ e(M, {
232
- action: {
233
- id: "style",
234
- active: o.isStyle,
235
- icon: "wm-format-paragraph",
236
- items: n
237
- },
238
- defaultValue: n.find((i) => i.active)
239
- });
240
- }, Dt = () => {
241
- const { editor: t } = p(), o = f({
242
- editor: t,
243
- selector: (n) => ({ blockquote: n.editor?.isActive("blockquote") })
244
- });
245
- return /* @__PURE__ */ e("button", {
246
- type: "button",
247
- title: "quote",
248
- className: a.wuContentEditorAction,
249
- "data-active": o.blockquote,
250
- onClick: (n) => {
251
- n.preventDefault(), t.chain().focus().toggleBlockquote().run();
252
- },
253
- children: /* @__PURE__ */ e(h, { icon: "wm-format-quote" })
254
- });
255
- }, Rt = () => {
256
- const { editor: t } = p(), o = f({
257
- editor: t,
258
- selector: (n) => ({ bold: n.editor?.isActive("bold") })
186
+ return /* @__PURE__ */ e(U, {
187
+ trigger: t.isH1 ? /* @__PURE__ */ e(Z, {}) : t.isH2 ? /* @__PURE__ */ e(Y, {}) : t.isH3 ? /* @__PURE__ */ e(V, {}) : t.isH4 ? /* @__PURE__ */ e(ie, {}) : /* @__PURE__ */ e(Q, {}),
188
+ triggerTitle: "Block Style",
189
+ active: t.isHeading,
190
+ items: i
259
191
  });
260
- return /* @__PURE__ */ e("button", {
261
- type: "button",
192
+ }, Ve = () => {
193
+ const { editor: o } = h();
194
+ return /* @__PURE__ */ e(d, {
262
195
  title: "Bold",
263
- className: a.wuContentEditorAction,
264
- "data-active": o.bold,
265
- onClick: (n) => {
266
- n.preventDefault(), t.chain().focus().toggleBold().run();
196
+ "data-active": v({
197
+ editor: o,
198
+ selector: (t) => ({ bold: t.editor?.isActive("bold") })
199
+ }).bold,
200
+ onClick: (t) => {
201
+ t.preventDefault(), o.chain().focus().toggleBold().run();
267
202
  },
268
- children: /* @__PURE__ */ e(h, { icon: "wm-format-bold" })
203
+ children: /* @__PURE__ */ e(ge, {})
269
204
  });
270
- }, zt = () => {
271
- const { editor: t } = p();
272
- return /* @__PURE__ */ e(x, { children: [{
205
+ }, Xe = () => {
206
+ const { editor: o } = h();
207
+ return /* @__PURE__ */ e(N, { children: [{
273
208
  id: "clear",
274
- icon: "wm-format-clear",
275
- event: () => t.chain().focus().clearNodes().unsetAllMarks().run(),
209
+ icon: /* @__PURE__ */ e(Ae, {}),
210
+ event: () => o.chain().focus().clearNodes().unsetAllMarks().run(),
276
211
  tooltip: "Clear Formatting"
277
- }].map((o) => /* @__PURE__ */ e("button", {
278
- type: "button",
279
- title: o.tooltip,
280
- className: a.wuContentEditorAction,
281
- onClick: (n) => {
282
- n.preventDefault(), o.event();
212
+ }].map((t) => /* @__PURE__ */ e(d, {
213
+ title: t.tooltip,
214
+ onClick: (i) => {
215
+ i.preventDefault(), t.event();
283
216
  },
284
- children: /* @__PURE__ */ e(h, { icon: o.icon })
285
- }, o.id)) });
286
- }, Mt = () => {
287
- const { editor: t } = p(), o = f({
288
- editor: t,
289
- selector: (n) => ({ code: n.editor.isActive("code") })
290
- });
291
- return /* @__PURE__ */ e("button", {
292
- type: "button",
293
- className: a.wuContentEditorAction,
294
- "data-active": o.code,
217
+ children: t.icon
218
+ }, t.id)) });
219
+ }, Ye = () => {
220
+ const { editor: o } = h();
221
+ return /* @__PURE__ */ e(d, {
222
+ "data-active": v({
223
+ editor: o,
224
+ selector: (t) => ({ code: t.editor.isActive("code") })
225
+ }).code,
295
226
  title: "Code line",
296
- onMouseDown: (n) => {
297
- n.preventDefault(), t.chain().focus().toggleCode().run();
227
+ onMouseDown: (t) => {
228
+ t.preventDefault(), o.chain().focus().toggleCode().run();
298
229
  },
299
- children: /* @__PURE__ */ e(h, { icon: "wm-code" })
230
+ children: /* @__PURE__ */ e(be, {})
300
231
  });
301
- }, Wt = () => {
302
- const { editor: t } = p(), o = f({
303
- editor: t,
304
- selector: (l) => ({
305
- isImage: l.editor?.isActive("image"),
306
- imageAttrs: l.editor?.getAttributes("image")
307
- })
308
- }), [n, i] = m.useState(o.imageAttrs.src || ""), [r, u] = m.useState(o.imageAttrs.alt || ""), c = () => {
309
- t.chain().focus().setImage({
310
- src: n,
311
- alt: r
312
- }).run();
313
- };
314
- return /* @__PURE__ */ v(H, {
315
- Trigger: /* @__PURE__ */ e("button", {
316
- type: "button",
317
- className: a.wuContentEditorAction,
318
- "data-active": o.isImage,
319
- children: /* @__PURE__ */ e(h, { icon: "wm-image" })
320
- }),
321
- maxWidth: "400px",
322
- children: [
323
- /* @__PURE__ */ e(z, { style: { display: "none" } }),
324
- /* @__PURE__ */ v(D, {
325
- className: a.wuContentEditorModal,
326
- children: [/* @__PURE__ */ e(F, {
327
- Label: "Image URL",
328
- type: "url",
329
- value: n,
330
- onChange: (l) => i(l.target.value),
331
- required: !0
332
- }), /* @__PURE__ */ e(F, {
333
- Label: "Alt Text",
334
- type: "text",
335
- value: r,
336
- onChange: (l) => u(l.target.value)
337
- })]
338
- }),
339
- /* @__PURE__ */ v(R, { children: [/* @__PURE__ */ e(_, {
340
- variant: "secondary",
341
- children: "Cancel"
342
- }), /* @__PURE__ */ e(_, {
343
- onClick: c,
344
- disabled: !n,
345
- children: "Save"
346
- })] })
347
- ]
232
+ }, Ze = () => {
233
+ const { editor: o } = h();
234
+ return /* @__PURE__ */ e(d, {
235
+ title: "Italic",
236
+ "data-active": v({
237
+ editor: o,
238
+ selector: (t) => ({ italic: t.editor?.isActive("italic") })
239
+ }).italic,
240
+ onClick: (t) => {
241
+ t.preventDefault(), o.chain().focus().toggleItalic().run();
242
+ },
243
+ children: /* @__PURE__ */ e(we, {})
348
244
  });
349
- }, Ot = () => {
350
- const { editor: t } = p(), o = f({
351
- editor: t,
352
- selector: (s) => ({
353
- isLink: s.editor?.isActive("link"),
354
- linkAttrs: s.editor?.getAttributes("link")
245
+ }, Ge = () => {
246
+ const { editor: o } = h(), t = v({
247
+ editor: o,
248
+ selector: (r) => ({
249
+ isUl: r.editor?.isActive("bulletList"),
250
+ isOl: r.editor?.isActive("orderedList"),
251
+ isTodo: r.editor?.isActive("taskList"),
252
+ isList: r.editor?.isActive("bulletList") || r.editor?.isActive("orderedList") || r.editor?.isActive("taskList")
355
253
  })
356
- }), [n, i] = m.useState(o.linkAttrs.href || ""), [r, u] = m.useState(o.linkAttrs.alt || ""), c = () => {
357
- t.chain().focus().insertContent({
358
- type: "text",
359
- text: r || n,
360
- marks: [{
361
- type: "link",
362
- attrs: { href: n }
363
- }]
364
- }).run();
365
- }, l = () => {
366
- const { $from: s } = t.state.selection, C = s.parent.textContent, k = s.parentOffset;
367
- let b = k, w = k;
368
- for (; b > 0 && !/\s/.test(C[b - 1]); ) b--;
369
- for (; w < C.length && !/\s/.test(C[w]); ) w++;
370
- const E = s.start(), A = E + b, y = E + w, g = C.slice(b, w);
371
- t.commands.setTextSelection({
372
- from: A,
373
- to: y
374
- }), i(o.linkAttrs.href || ""), u(g || o.linkAttrs.alt || "");
375
- };
376
- return /* @__PURE__ */ v(H, {
377
- Trigger: /* @__PURE__ */ e("button", {
378
- type: "button",
379
- title: "Link",
380
- className: a.wuContentEditorAction,
381
- "data-active": o.isLink,
382
- children: /* @__PURE__ */ e(h, { icon: "wm-link" })
383
- }),
384
- maxWidth: "400px",
385
- onOpenChange: (s) => s && l(),
386
- children: [
387
- /* @__PURE__ */ e(z, { style: { display: "none" } }),
388
- /* @__PURE__ */ v(D, {
389
- className: a.wuContentEditorModal,
390
- children: [/* @__PURE__ */ e(F, {
391
- Label: "Link",
392
- type: "url",
393
- value: n,
394
- onChange: (s) => i(s.target.value),
395
- required: !0
396
- }), /* @__PURE__ */ e(F, {
397
- Label: "Text to display",
398
- type: "text",
399
- value: r,
400
- onChange: (s) => u(s.target.value)
401
- })]
402
- }),
403
- /* @__PURE__ */ v(R, { children: [o.isLink && /* @__PURE__ */ e(_, {
404
- color: "error",
405
- onClick: () => t.chain().focus().unsetLink().run(),
406
- variant: "secondary",
407
- children: "Remove"
408
- }), /* @__PURE__ */ e(_, {
409
- onClick: c,
410
- disabled: !n,
411
- children: "Save"
412
- })] })
413
- ]
254
+ }), i = [
255
+ {
256
+ id: "ul",
257
+ icon: /* @__PURE__ */ e(J, {}),
258
+ event: () => o.chain().focus().toggleBulletList().run(),
259
+ tooltip: "Bulleted List",
260
+ active: t.isUl
261
+ },
262
+ {
263
+ id: "ol",
264
+ icon: /* @__PURE__ */ e(re, {}),
265
+ event: () => o.chain().focus().toggleOrderedList().run(),
266
+ tooltip: "Numbered List",
267
+ active: t.isOl
268
+ },
269
+ {
270
+ id: "todo",
271
+ icon: /* @__PURE__ */ e(ee, {}),
272
+ event: () => o.chain().focus().toggleTaskList().run(),
273
+ tooltip: "To-Do List",
274
+ active: t.isTodo
275
+ }
276
+ ];
277
+ return /* @__PURE__ */ e(U, {
278
+ trigger: t.isOl ? /* @__PURE__ */ e(re, {}) : t.isTodo ? /* @__PURE__ */ e(ee, {}) : /* @__PURE__ */ e(J, {}),
279
+ triggerTitle: "List Style",
280
+ active: t.isList,
281
+ items: i
414
282
  });
415
- }, Pt = () => {
416
- const { editor: t } = p(), o = f({
417
- editor: t,
418
- selector: (l) => ({
419
- isTable: l.editor.isActive("table"),
420
- tableAttrs: l.editor.getAttributes("table")
421
- })
422
- }), [n, i] = N(!1), r = Y(null), u = O(() => {
423
- r.current = setTimeout(() => {
424
- t.chain().focus().insertTable({
425
- rows: 2,
426
- cols: 4,
427
- withHeaderRow: n
428
- }).run();
429
- }, 100);
430
- }, [t, n]), c = O(() => {
431
- i((l) => !l), r.current = setTimeout(() => {
432
- t.chain().focus().toggleHeaderRow().run();
433
- }, 100);
434
- }, [t]);
435
- return o.isTable ? /* @__PURE__ */ v(H, {
436
- Trigger: /* @__PURE__ */ e("button", {
437
- type: "button",
438
- title: "Table",
439
- className: a.wuContentEditorAction,
440
- "data-active": o.isTable,
441
- children: /* @__PURE__ */ e(h, { icon: "wm-table" })
442
- }),
443
- maxWidth: "320px",
444
- children: [
445
- /* @__PURE__ */ e(z, { style: { display: "none" } }),
446
- /* @__PURE__ */ v(D, {
447
- className: a.wuContentEditorModal,
448
- children: [/* @__PURE__ */ e(mt, {
449
- checked: n,
450
- onClick: c,
451
- Label: "Title Row",
452
- labelPosition: "left"
453
- }), /* @__PURE__ */ e("div", {
454
- className: a.wuContentEditorTable,
455
- children: [
456
- {
457
- text: "Column left",
458
- icon: "wm-add",
459
- event: () => t.chain().focus().addColumnBefore().run()
460
- },
461
- {
462
- text: "Row above",
463
- icon: "wm-add",
464
- event: () => t.chain().focus().addRowBefore().run()
465
- },
466
- {
467
- text: "Column right",
468
- icon: "wm-add",
469
- event: () => t.chain().focus().addColumnAfter().run()
470
- },
471
- {
472
- text: "Row below",
473
- icon: "wm-add",
474
- event: () => t.chain().focus().addRowAfter().run()
475
- },
476
- {
477
- text: "Delete Column",
478
- icon: "wm-delete",
479
- event: () => t.chain().focus().deleteColumn().run()
480
- },
481
- {
482
- text: "Delete Row",
483
- icon: "wm-delete",
484
- event: () => t.chain().focus().deleteRow().run()
485
- }
486
- ].map(({ text: l, icon: s, event: C }) => /* @__PURE__ */ e(q, {
487
- onClick: C,
488
- variant: "secondary",
489
- Icon: /* @__PURE__ */ e(h, { icon: s }),
490
- children: l
491
- }, l))
492
- })]
493
- }),
494
- /* @__PURE__ */ e(R, { children: /* @__PURE__ */ e(_, {
495
- onClick: () => t.chain().focus().deleteTable().run(),
496
- variant: "outline",
497
- color: "error",
498
- Icon: /* @__PURE__ */ e("span", { className: "wm-delete" }),
499
- iconPosition: "left",
500
- children: "Delete Table"
501
- }) })
502
- ]
503
- }) : /* @__PURE__ */ e("button", {
504
- type: "button",
505
- title: "Table",
506
- onClick: u,
507
- className: a.wuContentEditorAction,
508
- children: /* @__PURE__ */ e(h, { icon: "wm-table" })
283
+ }, et = () => {
284
+ const { editor: o } = h();
285
+ return /* @__PURE__ */ e(d, {
286
+ title: "strikethrough",
287
+ "data-active": v({
288
+ editor: o,
289
+ selector: (t) => ({ strikethrough: t.editor?.isActive("strike") })
290
+ }).strikethrough,
291
+ onClick: (t) => {
292
+ t.preventDefault(), o.chain().focus().toggleStrike().run();
293
+ },
294
+ children: /* @__PURE__ */ e(de, {})
509
295
  });
510
- }, Bt = () => {
511
- const { editor: t, customFonts: o } = p(), n = f({
512
- editor: t,
513
- selector: (c) => ({ currentFontFamily: c.editor.getAttributes("textStyle").fontFamily || "" })
514
- }), i = [
515
- "Fira Sans",
516
- "Inter",
517
- "Poppins",
518
- "JetBrains Mono",
519
- "Montserrat",
520
- ...o || []
521
- ], [r, u] = N(n.currentFontFamily || i[0]);
522
- return m.useEffect(() => {
523
- u(n.currentFontFamily?.replace(/"/g, "") || i[0]);
524
- }, [n.currentFontFamily]), /* @__PURE__ */ v(U, { children: [/* @__PURE__ */ e(K, {
525
- className: a.wuContentEditorAction,
526
- "data-active": r !== "Fira Sans",
527
- style: { fontFamily: r },
528
- title: r || "Font Family",
529
- children: r?.[0]
530
- }), /* @__PURE__ */ e(j, {
531
- align: "start",
532
- className: a.wuContentEditorDropdown,
533
- "data-block": !0,
534
- onCloseAutoFocus: (c) => c.preventDefault(),
535
- children: i.map((c) => /* @__PURE__ */ e($, {
536
- title: c,
537
- className: a.wuContentEditorDropdownItem,
538
- onSelect: () => {
539
- t.chain().focus().setFontFamily(c).run(), u(c);
540
- },
541
- children: c
542
- }, c))
543
- })] });
544
- }, qt = () => {
545
- const { editor: t } = p(), o = f({
546
- editor: t,
547
- selector: (n) => ({ italic: n.editor?.isActive("italic") })
296
+ }, tt = () => {
297
+ const { editor: o } = h();
298
+ return /* @__PURE__ */ e(d, {
299
+ title: "Subscript",
300
+ "data-active": v({
301
+ editor: o,
302
+ selector: (t) => ({ subscript: t.editor?.isActive("subscript") })
303
+ }).subscript,
304
+ onClick: (t) => {
305
+ t.preventDefault(), o.chain().focus().toggleSubscript().run();
306
+ },
307
+ children: /* @__PURE__ */ e(fe, {})
548
308
  });
549
- return /* @__PURE__ */ e("button", {
550
- type: "button",
551
- title: "Italic",
552
- className: a.wuContentEditorAction,
553
- "data-active": o.italic,
554
- onClick: (n) => {
555
- n.preventDefault(), t.chain().focus().toggleItalic().run();
309
+ }, ot = () => {
310
+ const { editor: o } = h();
311
+ return /* @__PURE__ */ e(d, {
312
+ title: "Superscript",
313
+ "data-active": v({
314
+ editor: o,
315
+ selector: (t) => ({ superscript: t.editor?.isActive("superscript") })
316
+ }).superscript,
317
+ onClick: (t) => {
318
+ t.preventDefault(), o.chain().focus().toggleSuperscript().run();
319
+ },
320
+ children: /* @__PURE__ */ e(Ce, {})
321
+ });
322
+ }, it = () => {
323
+ const { editor: o } = h(), t = v({
324
+ editor: o,
325
+ selector: ({ editor: r }) => ({ textColor: r.getAttributes("textStyle").color })
326
+ }), i = u.useRef(null);
327
+ return /* @__PURE__ */ f(d, {
328
+ title: "Text Color",
329
+ onClick: () => i.current?.click(),
330
+ children: [/* @__PURE__ */ e(ke, { style: { color: t.textColor } }), /* @__PURE__ */ e("input", {
331
+ ref: i,
332
+ type: "color",
333
+ defaultValue: "#545E6B",
334
+ onChange: (r) => o.chain().focus().setColor(r.target.value).run()
335
+ })]
336
+ });
337
+ }, rt = () => {
338
+ const { editor: o } = h();
339
+ return /* @__PURE__ */ e(d, {
340
+ title: "Underline",
341
+ "data-active": v({
342
+ editor: o,
343
+ selector: (t) => ({ underline: t.editor?.isActive("underline") })
344
+ }).underline,
345
+ onClick: (t) => {
346
+ t.preventDefault(), o.chain().focus().toggleUnderline().run();
347
+ },
348
+ children: /* @__PURE__ */ e(he, {})
349
+ });
350
+ }, nt = () => {
351
+ const { editor: o } = h(), t = v({
352
+ editor: o,
353
+ selector: ({ editor: r }) => ({ bgColor: r.getAttributes("textStyle").backgroundColor })
354
+ }), i = u.useRef(null);
355
+ return /* @__PURE__ */ f(d, {
356
+ title: "Background Color",
357
+ onClick: () => i.current?.click(),
358
+ children: [/* @__PURE__ */ e(_e, { style: { color: t.bgColor } }), /* @__PURE__ */ e("input", {
359
+ ref: i,
360
+ type: "color",
361
+ defaultValue: "#fff",
362
+ onChange: (r) => o.chain().focus().setBackgroundColor(r.target.value).run()
363
+ })]
364
+ });
365
+ }, lt = () => {
366
+ const { editor: o } = h();
367
+ return /* @__PURE__ */ e(d, {
368
+ title: "quote",
369
+ "data-active": v({
370
+ editor: o,
371
+ selector: (t) => ({ blockquote: t.editor?.isActive("blockquote") })
372
+ }).blockquote,
373
+ onClick: (t) => {
374
+ t.preventDefault(), o.chain().focus().toggleBlockquote().run();
556
375
  },
557
- children: /* @__PURE__ */ e(h, { icon: "wm-format-italic" })
376
+ children: /* @__PURE__ */ e(ue, {})
558
377
  });
559
- }, Ut = () => {
560
- const { editor: t } = p(), o = f({
561
- editor: t,
562
- selector: (i) => ({
563
- isUl: i.editor?.isActive("bulletList"),
564
- isOl: i.editor?.isActive("orderedList"),
565
- isTodo: i.editor?.isActive("taskList"),
566
- isList: i.editor?.isActive("bulletList") || i.editor?.isActive("orderedList") || i.editor?.isActive("taskList")
378
+ };
379
+ function at() {
380
+ const { isHtml: o, setIsHtml: t, htmlSourceEnabled: i } = h();
381
+ return i ? /* @__PURE__ */ e(d, {
382
+ title: "HTML source",
383
+ "data-active": o,
384
+ onClick: (r) => {
385
+ r.preventDefault(), t(!o);
386
+ },
387
+ children: /* @__PURE__ */ e(Ie, {})
388
+ }) : null;
389
+ }
390
+ var st = () => {
391
+ const { editor: o } = h(), t = v({
392
+ editor: o,
393
+ selector: (r) => ({
394
+ isLeft: r.editor?.isActive({ textAlign: "left" }),
395
+ isCenter: r.editor?.isActive({ textAlign: "center" }),
396
+ isRight: r.editor?.isActive({ textAlign: "right" }),
397
+ isJustify: r.editor?.isActive({ textAlign: "justify" }),
398
+ isAligned: r.editor?.isActive({ textAlign: "center" }) || r.editor?.isActive({ textAlign: "right" }) || r.editor?.isActive({ textAlign: "justify" })
567
399
  })
568
- }), n = [
400
+ }), i = [
569
401
  {
570
- id: "ul",
571
- icon: "wm-format-list-bulleted",
572
- event: () => t.chain().focus().toggleBulletList().run(),
573
- active: o.isUl,
574
- tooltip: "Bulleted List"
402
+ id: "left",
403
+ icon: /* @__PURE__ */ e(X, {}),
404
+ event: () => o.chain().focus().setTextAlign("left").run(),
405
+ tooltip: "Align Left",
406
+ active: t.isLeft
575
407
  },
576
408
  {
577
- id: "ol",
578
- icon: "wm-format-list-numbered",
579
- event: () => t.chain().focus().toggleOrderedList().run(),
580
- active: o.isOl,
581
- tooltip: "Numbered List"
409
+ id: "center",
410
+ icon: /* @__PURE__ */ e(oe, {}),
411
+ event: () => o.chain().focus().setTextAlign("center").run(),
412
+ tooltip: "Align Center",
413
+ active: t.isCenter
582
414
  },
583
415
  {
584
- id: "todo",
585
- icon: "wm-checklist",
586
- event: () => t.chain().focus().toggleTaskList().run(),
587
- active: o.isTodo,
588
- tooltip: "To-Do List"
416
+ id: "right",
417
+ icon: /* @__PURE__ */ e(te, {}),
418
+ event: () => o.chain().focus().setTextAlign("right").run(),
419
+ tooltip: "Align Right",
420
+ active: t.isRight
421
+ },
422
+ {
423
+ id: "justify",
424
+ icon: /* @__PURE__ */ e(G, {}),
425
+ event: () => o.chain().focus().setTextAlign("justify").run(),
426
+ tooltip: "Justify",
427
+ active: t.isJustify
589
428
  }
590
429
  ];
591
- return /* @__PURE__ */ e(M, { action: {
592
- id: "style",
593
- active: o.isList,
594
- icon: "wm-format-paragraph",
595
- items: n
596
- } });
597
- }, jt = [
430
+ return /* @__PURE__ */ e(U, {
431
+ trigger: t.isCenter ? /* @__PURE__ */ e(oe, {}) : t.isRight ? /* @__PURE__ */ e(te, {}) : t.isJustify ? /* @__PURE__ */ e(G, {}) : /* @__PURE__ */ e(X, {}),
432
+ triggerTitle: "Text Alignment",
433
+ active: t.isAligned,
434
+ items: i
435
+ });
436
+ }, ct = "_wuContentEditor_1w25e_3", dt = "_selectedCell_1w25e_1", ut = "_tableWrapper_1w25e_1", ht = "_wuContentEditorRoot_1w25e_3", ft = "_wuContentEditorToolbar_1w25e_17", vt = "_fontSize_1w25e_38", pt = "_wuContentEditorTable_1w25e_56", S = {
437
+ wuContentEditor: ct,
438
+ selectedCell: dt,
439
+ "column-resize-handle": "_column-resize-handle_1w25e_1",
440
+ tableWrapper: ut,
441
+ "resize-cursor": "_resize-cursor_1w25e_1",
442
+ wuContentEditorRoot: ht,
443
+ wuContentEditorToolbar: ft,
444
+ fontSize: vt,
445
+ wuContentEditorTable: pt
446
+ }, gt = [
598
447
  "e",
599
448
  "E",
600
449
  "+",
601
450
  "-"
602
- ], P = 1, $t = () => {
603
- const { editor: t } = p(), [o, n] = N(16), i = f({
604
- editor: t,
605
- selector: (l) => ({ fontSize: l.editor.getAttributes("textStyle").fontSize })
606
- }), r = (l) => {
607
- t.chain().focus().setFontSize(l + "px").run();
608
- }, u = (l) => {
609
- const s = Math.max(P, l);
610
- n(s), r(s);
611
- }, c = (l) => {
612
- jt.includes(l.key) ? l.preventDefault() : l.key === "Enter" && r(o);
451
+ ], le = 1, mt = () => {
452
+ const { editor: o } = h(), [t, i] = O(16), r = v({
453
+ editor: o,
454
+ selector: (s) => ({ fontSize: s.editor.getAttributes("textStyle").fontSize })
455
+ }), n = (s) => {
456
+ o.chain().focus().setFontSize(s + "px").run();
457
+ }, c = (s) => {
458
+ const C = Math.max(le, s);
459
+ i(C), n(C);
460
+ }, l = (s) => {
461
+ gt.includes(s.key) ? s.preventDefault() : s.key === "Enter" && n(t);
613
462
  };
614
- return m.useEffect(() => {
615
- n(Number(i.fontSize?.replace("px", "")) || 16);
616
- }, [i.fontSize]), /* @__PURE__ */ v("div", {
617
- className: a.wuContentEditorFontSize,
463
+ return u.useEffect(() => {
464
+ i(Number(r.fontSize?.replace("px", "")) || 16);
465
+ }, [r.fontSize]), /* @__PURE__ */ f("div", {
466
+ className: S.fontSize,
618
467
  children: [
619
- /* @__PURE__ */ e("button", {
620
- type: "button",
621
- className: a.wuContentEditorAction,
622
- onClick: () => u(o - 1),
623
- disabled: o <= P,
468
+ /* @__PURE__ */ e(d, {
469
+ onClick: () => c(t - 1),
470
+ disabled: t <= le,
624
471
  children: "−"
625
472
  }),
626
473
  /* @__PURE__ */ e("input", {
627
474
  type: "number",
628
475
  inputMode: "numeric",
629
476
  pattern: "[0-9]*",
630
- value: o,
631
- onKeyDown: c,
632
- onChange: (l) => n(l.target.valueAsNumber),
633
- onBlur: () => r(o)
477
+ value: t,
478
+ onKeyDown: l,
479
+ onChange: (s) => i(s.target.valueAsNumber),
480
+ onBlur: () => n(t)
634
481
  }),
635
- /* @__PURE__ */ e("button", {
636
- type: "button",
637
- className: a.wuContentEditorAction,
638
- onClick: () => u(o + 1),
639
- disabled: o >= 128,
482
+ /* @__PURE__ */ e(d, {
483
+ onClick: () => c(t + 1),
484
+ disabled: t >= 128,
640
485
  children: "+"
641
486
  })
642
487
  ]
643
488
  });
644
- }, Kt = () => {
645
- const { editor: t } = p(), o = f({
646
- editor: t,
647
- selector: (n) => ({ strikethrough: n.editor?.isActive("strike") })
648
- });
649
- return /* @__PURE__ */ e("button", {
650
- type: "button",
651
- title: "strikethrough",
652
- className: a.wuContentEditorAction,
653
- "data-active": o.strikethrough,
654
- onClick: (n) => {
655
- n.preventDefault(), t.chain().focus().toggleStrike().run();
656
- },
657
- children: /* @__PURE__ */ e(h, { icon: "wm-format-strikethrough" })
658
- });
659
- }, Jt = () => {
660
- const { editor: t } = p(), o = f({
661
- editor: t,
662
- selector: (n) => ({ subscript: n.editor?.isActive("subscript") })
663
- });
664
- return /* @__PURE__ */ e("button", {
665
- type: "button",
666
- title: "Subscript",
667
- className: a.wuContentEditorAction,
668
- "data-active": o.subscript,
669
- onClick: (n) => {
670
- n.preventDefault(), t.chain().focus().toggleSubscript().run();
671
- },
672
- children: /* @__PURE__ */ e(h, { icon: "wm-subscript" })
673
- });
674
- }, Gt = () => {
675
- const { editor: t } = p(), o = f({
676
- editor: t,
677
- selector: (n) => ({ superscript: n.editor?.isActive("superscript") })
489
+ }, bt = () => {
490
+ const { editor: o, customFonts: t } = h(), i = v({
491
+ editor: o,
492
+ selector: (l) => ({ currentFontFamily: l.editor.getAttributes("textStyle").fontFamily || "" })
493
+ }), r = [
494
+ "Fira Sans",
495
+ "Inter",
496
+ "Poppins",
497
+ "JetBrains Mono",
498
+ "Montserrat",
499
+ ...t || []
500
+ ], [n, c] = O(i.currentFontFamily || r[0]);
501
+ return u.useEffect(() => {
502
+ c(i.currentFontFamily?.replace(/"/g, "") || r[0]);
503
+ }, [i.currentFontFamily]), /* @__PURE__ */ f(g.Root, { children: [/* @__PURE__ */ e(g.Trigger, {
504
+ "data-active": n !== "Fira Sans",
505
+ style: { fontFamily: n },
506
+ title: n || "Font Family",
507
+ render: /* @__PURE__ */ e(d, {}),
508
+ children: n?.[0]
509
+ }), /* @__PURE__ */ e(g.Portal, { children: /* @__PURE__ */ e(g.Positioner, {
510
+ align: "start",
511
+ sideOffset: 4,
512
+ children: /* @__PURE__ */ e(g.Popup, {
513
+ render: /* @__PURE__ */ e(q, {}),
514
+ "data-block": !0,
515
+ finalFocus: !1,
516
+ children: r.map((l) => /* @__PURE__ */ e(g.Item, {
517
+ title: l,
518
+ render: /* @__PURE__ */ e($, {}),
519
+ onClick: () => {
520
+ o.chain().focus().setFontFamily(l).run(), c(l);
521
+ },
522
+ children: l
523
+ }, l))
524
+ })
525
+ }) })] });
526
+ }, kt = "_button_583n5_1", Ct = { button: kt }, ce = u.forwardRef(function({ children: t, variant: i, color: r, icon: n, ...c }, l) {
527
+ return /* @__PURE__ */ f("button", {
528
+ ref: l,
529
+ className: Ct.button,
530
+ "data-variant": i,
531
+ "data-color": r,
532
+ ...c,
533
+ children: [n, t]
678
534
  });
679
- return /* @__PURE__ */ e("button", {
680
- type: "button",
681
- title: "Superscript",
682
- className: a.wuContentEditorAction,
683
- "data-active": o.superscript,
684
- onClick: (n) => {
685
- n.preventDefault(), t.chain().focus().toggleSuperscript().run();
686
- },
687
- children: /* @__PURE__ */ e(h, { icon: "wm-superscript" })
535
+ }), _t = "_dialog_1k05x_1", At = "_backdrop_1k05x_27", wt = "_content_1k05x_46", It = "_footer_1k05x_52", Tt = "_close_1k05x_59", y = {
536
+ dialog: _t,
537
+ backdrop: At,
538
+ content: wt,
539
+ footer: It,
540
+ close: Tt
541
+ };
542
+ function W({ Trigger: o, children: t, maxWidth: i, onOpenChange: r, footer: n }) {
543
+ const c = u.useContext(M), l = u.useCallback((s) => {
544
+ c?.editor.setEditable(!s, !1), r?.(s);
545
+ }, [c, r]);
546
+ return /* @__PURE__ */ f(w.Root, {
547
+ modal: !0,
548
+ onOpenChange: l,
549
+ children: [/* @__PURE__ */ e("span", {
550
+ onClick: (s) => s.stopPropagation(),
551
+ children: /* @__PURE__ */ e(w.Trigger, { render: o })
552
+ }), /* @__PURE__ */ f(w.Portal, { children: [/* @__PURE__ */ e(w.Backdrop, { className: y.backdrop }), /* @__PURE__ */ f(w.Popup, {
553
+ className: y.dialog,
554
+ style: i ? { maxWidth: i } : void 0,
555
+ children: [
556
+ /* @__PURE__ */ e(w.Close, {
557
+ className: y.close,
558
+ "aria-label": "Close",
559
+ children: /* @__PURE__ */ e(me, {
560
+ width: 10,
561
+ height: 10
562
+ })
563
+ }),
564
+ /* @__PURE__ */ e("div", {
565
+ className: y.content,
566
+ children: t
567
+ }),
568
+ n && /* @__PURE__ */ e("footer", {
569
+ className: y.footer,
570
+ children: n
571
+ })
572
+ ]
573
+ })] })]
688
574
  });
689
- }, Vt = () => {
690
- const { editor: t } = p(), o = f({
691
- editor: t,
692
- selector: ({ editor: n }) => ({ textColor: n.getAttributes("textStyle").color })
575
+ }
576
+ function x({ children: o, variant: t, color: i, icon: r, ...n }) {
577
+ return /* @__PURE__ */ e(w.Close, {
578
+ render: /* @__PURE__ */ e(ce, {
579
+ variant: t,
580
+ color: i,
581
+ icon: r
582
+ }),
583
+ ...n,
584
+ children: o
693
585
  });
694
- return /* @__PURE__ */ v("label", {
695
- className: a.wuContentEditorAction,
696
- htmlFor: "text-color",
697
- title: "Text Color",
698
- children: [/* @__PURE__ */ e(h, {
699
- icon: "wm-format-color-text",
700
- className: a.bgColorCursorPointer,
701
- style: { color: o.textColor }
586
+ }
587
+ var yt = "_group_56lao_1", St = "_label_56lao_8", xt = "_input_56lao_14", z = {
588
+ group: yt,
589
+ label: St,
590
+ input: xt
591
+ };
592
+ function E({ label: o, id: t, ...i }) {
593
+ return /* @__PURE__ */ f("div", {
594
+ className: z.group,
595
+ children: [o && /* @__PURE__ */ e("label", {
596
+ className: z.label,
597
+ htmlFor: t,
598
+ children: o
702
599
  }), /* @__PURE__ */ e("input", {
703
- type: "color",
704
- className: a.bgColorHiddenInput,
705
- id: "text-color",
706
- defaultValue: "#545E6B",
707
- onChange: (n) => t.chain().focus().setColor(n.target.value).run()
600
+ id: t,
601
+ className: z.input,
602
+ ...i
708
603
  })]
709
604
  });
710
- }, Xt = () => {
711
- const { editor: t } = p(), o = f({
712
- editor: t,
713
- selector: (n) => ({ underline: n.editor?.isActive("underline") })
605
+ }
606
+ var Ht = () => {
607
+ const { editor: o } = h(), t = v({
608
+ editor: o,
609
+ selector: (s) => ({
610
+ isImage: s.editor?.isActive("image"),
611
+ imageAttrs: s.editor?.getAttributes("image")
612
+ })
613
+ }), [i, r] = u.useState(t.imageAttrs.src || ""), [n, c] = u.useState(t.imageAttrs.alt || ""), l = () => {
614
+ o.chain().focus().setImage({
615
+ src: i,
616
+ alt: n
617
+ }).run();
618
+ };
619
+ return /* @__PURE__ */ f(W, {
620
+ Trigger: /* @__PURE__ */ e(d, {
621
+ title: "Image",
622
+ "data-active": t.isImage,
623
+ children: /* @__PURE__ */ e(pe, {})
624
+ }),
625
+ maxWidth: "400px",
626
+ footer: /* @__PURE__ */ f(N, { children: [/* @__PURE__ */ e(x, {
627
+ variant: "secondary",
628
+ children: "Cancel"
629
+ }), /* @__PURE__ */ e(x, {
630
+ onClick: l,
631
+ disabled: !i,
632
+ children: "Save"
633
+ })] }),
634
+ children: [/* @__PURE__ */ e(E, {
635
+ label: "Image URL",
636
+ type: "url",
637
+ value: i,
638
+ onChange: (s) => r(s.target.value),
639
+ required: !0
640
+ }), /* @__PURE__ */ e(E, {
641
+ label: "Alt Text",
642
+ type: "text",
643
+ value: n,
644
+ onChange: (s) => c(s.target.value)
645
+ })]
714
646
  });
715
- return /* @__PURE__ */ e("button", {
716
- type: "button",
717
- title: "Underline",
718
- className: a.wuContentEditorAction,
719
- "data-active": o.underline,
720
- onClick: (n) => {
721
- n.preventDefault(), t.chain().focus().toggleUnderline().run();
722
- },
723
- children: /* @__PURE__ */ e(h, { icon: "wm-format-underlined" })
647
+ }, Lt = () => {
648
+ const { editor: o } = h(), t = v({
649
+ editor: o,
650
+ selector: (a) => ({
651
+ isLink: a.editor?.isActive("link"),
652
+ linkAttrs: a.editor?.getAttributes("link")
653
+ })
654
+ }), [i, r] = u.useState(t.linkAttrs.href || ""), [n, c] = u.useState(t.linkAttrs.alt || ""), l = (a) => !a || a.startsWith("http://") || a.startsWith("https://") ? a : `https://${a}`, s = () => {
655
+ const a = l(i);
656
+ o.chain().focus().insertContent({
657
+ type: "text",
658
+ text: n || a,
659
+ marks: [{
660
+ type: "link",
661
+ attrs: { href: a }
662
+ }]
663
+ }).run();
664
+ }, C = () => {
665
+ const a = o.getAttributes("link"), { from: m, to: A, $from: T } = o.state.selection;
666
+ let I;
667
+ if (m !== A) I = o.state.doc.textBetween(m, A);
668
+ else {
669
+ const _ = T.parent.textContent, H = T.parentOffset;
670
+ let b = H, k = H;
671
+ for (; b > 0 && !/\s/.test(_[b - 1]); ) b--;
672
+ for (; k < _.length && !/\s/.test(_[k]); ) k++;
673
+ if (I = _.slice(b, k), I) {
674
+ const L = T.start();
675
+ o.commands.setTextSelection({
676
+ from: L + b,
677
+ to: L + k
678
+ });
679
+ }
680
+ }
681
+ r(a.href || ""), c(I || a.alt || "");
682
+ };
683
+ return /* @__PURE__ */ f(W, {
684
+ Trigger: /* @__PURE__ */ e(d, {
685
+ title: "Link",
686
+ "data-active": t.isLink,
687
+ children: /* @__PURE__ */ e(ve, {})
688
+ }),
689
+ maxWidth: "400px",
690
+ onOpenChange: (a) => a && C(),
691
+ footer: /* @__PURE__ */ f(N, { children: [t.isLink && /* @__PURE__ */ e(x, {
692
+ color: "error",
693
+ variant: "secondary",
694
+ onClick: () => o.chain().focus().unsetLink().run(),
695
+ children: "Remove"
696
+ }), /* @__PURE__ */ e(x, {
697
+ onClick: s,
698
+ disabled: !i,
699
+ children: "Save"
700
+ })] }),
701
+ children: [/* @__PURE__ */ e(E, {
702
+ label: "Link",
703
+ type: "url",
704
+ value: i,
705
+ onChange: (a) => r(a.target.value),
706
+ required: !0
707
+ }), /* @__PURE__ */ e(E, {
708
+ label: "Text to display",
709
+ type: "text",
710
+ value: n,
711
+ onChange: (a) => c(a.target.value)
712
+ })]
724
713
  });
714
+ }, Rt = "_label_1kiov_1", Ft = "_root_1kiov_11", Et = "_thumb_1kiov_44", P = {
715
+ label: Rt,
716
+ root: Ft,
717
+ thumb: Et
725
718
  };
726
- function Yt() {
727
- const { isHtml: t, setIsHtml: o } = p();
728
- return /* @__PURE__ */ e("button", {
729
- type: "button",
730
- title: "HTML source",
731
- className: a.wuContentEditorAction,
732
- "data-active": t,
733
- onClick: (n) => {
734
- n.preventDefault(), o(!t);
735
- },
736
- children: /* @__PURE__ */ e(h, { icon: "wm-html" })
719
+ function Nt({ checked: o, onCheckedChange: t, label: i }) {
720
+ return /* @__PURE__ */ f("label", {
721
+ className: P.label,
722
+ children: [/* @__PURE__ */ e("span", { children: i }), /* @__PURE__ */ e(ne.Root, {
723
+ className: P.root,
724
+ checked: o,
725
+ onCheckedChange: t,
726
+ children: /* @__PURE__ */ e(ne.Thumb, { className: P.thumb })
727
+ })]
737
728
  });
738
729
  }
739
- var B = {
740
- block: /* @__PURE__ */ e(Ht, {}),
741
- fontFamily: /* @__PURE__ */ e(Bt, {}),
742
- fontSize: /* @__PURE__ */ e($t, {}),
743
- bold: /* @__PURE__ */ e(Rt, {}),
744
- italic: /* @__PURE__ */ e(qt, {}),
745
- underline: /* @__PURE__ */ e(Xt, {}),
746
- strike: /* @__PURE__ */ e(Kt, {}),
747
- color: /* @__PURE__ */ e(Vt, {}),
748
- bgColor: /* @__PURE__ */ e(Nt, {}),
749
- list: /* @__PURE__ */ e(Ut, {}),
750
- alignment: /* @__PURE__ */ e(It, {}),
751
- image: /* @__PURE__ */ e(Wt, {}),
752
- link: /* @__PURE__ */ e(Ot, {}),
753
- table: /* @__PURE__ */ e(Pt, {}),
754
- blockquote: /* @__PURE__ */ e(Dt, {}),
755
- superscript: /* @__PURE__ */ e(Gt, {}),
756
- subscript: /* @__PURE__ */ e(Jt, {}),
757
- codeline: /* @__PURE__ */ e(Mt, {}),
758
- clear: /* @__PURE__ */ e(zt, {}),
730
+ var Dt = () => {
731
+ const { editor: o } = h(), t = v({
732
+ editor: o,
733
+ selector: (a) => ({
734
+ isTable: a.editor.isActive("table"),
735
+ tableAttrs: a.editor.getAttributes("table")
736
+ })
737
+ }), [i, r] = O(!1), n = Se(null), c = B((a) => {
738
+ n.current && clearTimeout(n.current), n.current = setTimeout(a, 100);
739
+ }, []);
740
+ u.useEffect(() => () => {
741
+ n.current && clearTimeout(n.current);
742
+ }, []);
743
+ const l = B(() => {
744
+ c(() => o.chain().focus().insertTable({
745
+ rows: 2,
746
+ cols: 4,
747
+ withHeaderRow: i
748
+ }).run());
749
+ }, [
750
+ o,
751
+ i,
752
+ c
753
+ ]), s = B(() => {
754
+ r((a) => !a), c(() => o.chain().focus().toggleHeaderRow().run());
755
+ }, [o, c]), C = [
756
+ {
757
+ text: "Column left",
758
+ icon: /* @__PURE__ */ e(R, {}),
759
+ event: () => o.chain().focus().addColumnBefore().run()
760
+ },
761
+ {
762
+ text: "Row above",
763
+ icon: /* @__PURE__ */ e(R, {}),
764
+ event: () => o.chain().focus().addRowBefore().run()
765
+ },
766
+ {
767
+ text: "Column right",
768
+ icon: /* @__PURE__ */ e(R, {}),
769
+ event: () => o.chain().focus().addColumnAfter().run()
770
+ },
771
+ {
772
+ text: "Row below",
773
+ icon: /* @__PURE__ */ e(R, {}),
774
+ event: () => o.chain().focus().addRowAfter().run()
775
+ },
776
+ {
777
+ text: "Delete Column",
778
+ icon: /* @__PURE__ */ e(D, {}),
779
+ event: () => o.chain().focus().deleteColumn().run()
780
+ },
781
+ {
782
+ text: "Delete Row",
783
+ icon: /* @__PURE__ */ e(D, {}),
784
+ event: () => o.chain().focus().deleteRow().run()
785
+ }
786
+ ];
787
+ return t.isTable ? /* @__PURE__ */ f(W, {
788
+ Trigger: /* @__PURE__ */ e(d, {
789
+ title: "Table",
790
+ "data-active": t.isTable,
791
+ children: /* @__PURE__ */ e(K, {})
792
+ }),
793
+ maxWidth: "320px",
794
+ footer: /* @__PURE__ */ e(x, {
795
+ variant: "secondary",
796
+ color: "error",
797
+ icon: /* @__PURE__ */ e(D, {}),
798
+ onClick: () => o.chain().focus().deleteTable().run(),
799
+ children: "Delete Table"
800
+ }),
801
+ children: [/* @__PURE__ */ e(Nt, {
802
+ checked: i,
803
+ onCheckedChange: s,
804
+ label: "Title Row"
805
+ }), /* @__PURE__ */ e("div", {
806
+ className: S.wuContentEditorTable,
807
+ children: C.map(({ text: a, icon: m, event: A }) => /* @__PURE__ */ e(ce, {
808
+ onClick: A,
809
+ variant: "secondary",
810
+ icon: m,
811
+ children: a
812
+ }, a))
813
+ })]
814
+ }) : /* @__PURE__ */ e(d, {
815
+ title: "Table",
816
+ onClick: l,
817
+ children: /* @__PURE__ */ e(K, {})
818
+ });
819
+ }, ae = {
820
+ block: /* @__PURE__ */ e(Qe, {}),
821
+ fontFamily: /* @__PURE__ */ e(bt, {}),
822
+ fontSize: /* @__PURE__ */ e(mt, {}),
823
+ bold: /* @__PURE__ */ e(Ve, {}),
824
+ italic: /* @__PURE__ */ e(Ze, {}),
825
+ underline: /* @__PURE__ */ e(rt, {}),
826
+ strike: /* @__PURE__ */ e(et, {}),
827
+ color: /* @__PURE__ */ e(it, {}),
828
+ bgColor: /* @__PURE__ */ e(nt, {}),
829
+ list: /* @__PURE__ */ e(Ge, {}),
830
+ alignment: /* @__PURE__ */ e(st, {}),
831
+ image: /* @__PURE__ */ e(Ht, {}),
832
+ link: /* @__PURE__ */ e(Lt, {}),
833
+ table: /* @__PURE__ */ e(Dt, {}),
834
+ blockquote: /* @__PURE__ */ e(lt, {}),
835
+ superscript: /* @__PURE__ */ e(ot, {}),
836
+ subscript: /* @__PURE__ */ e(tt, {}),
837
+ codeline: /* @__PURE__ */ e(Ye, {}),
838
+ clear: /* @__PURE__ */ e(Xe, {}),
759
839
  "|": /* @__PURE__ */ e("div", { style: {
760
840
  height: 16,
761
841
  width: 1,
762
- background: "rgb(var(--wu-gray-40))"
842
+ background: "var(--we-border)"
763
843
  } }),
764
- html: /* @__PURE__ */ e(Yt, {})
765
- }, Zt = [
844
+ html: /* @__PURE__ */ e(at, {})
845
+ }, Bt = [
766
846
  "block",
767
847
  "fontFamily",
768
848
  "|",
@@ -790,205 +870,83 @@ var B = {
790
870
  "|",
791
871
  "html",
792
872
  "clear"
793
- ], Qt = (t) => {
794
- const { editor: o, customFonts: n, children: i, items: r = Zt, isHtml: u, setIsHtml: c, ...l } = t;
873
+ ], zt = (o) => {
874
+ const { editor: t, customFonts: i, children: r, items: n = Bt, isHtml: c, setIsHtml: l, htmlSourceEnabled: s, ...C } = o;
795
875
  return /* @__PURE__ */ e("div", {
796
- ...l,
797
- children: /* @__PURE__ */ v(Lt, {
798
- editor: o,
799
- customFonts: n,
800
- isHtml: u,
801
- setIsHtml: c,
802
- children: [r.map((s, C) => /* @__PURE__ */ e(x, { children: u && s !== "html" ? /* @__PURE__ */ e("span", {
876
+ ...C,
877
+ children: /* @__PURE__ */ f(Ue, {
878
+ editor: t,
879
+ customFonts: i,
880
+ isHtml: c,
881
+ setIsHtml: l,
882
+ htmlSourceEnabled: s,
883
+ children: [n.map((a, m) => /* @__PURE__ */ e(N, { children: c && a !== "html" ? /* @__PURE__ */ e("span", {
803
884
  style: {
804
885
  pointerEvents: "none",
805
886
  opacity: 0.4
806
887
  },
807
- children: B[s]
808
- }) : B[s] }, s + C)), i]
888
+ children: ae[a]
889
+ }) : ae[a] }, a + m)), r]
809
890
  })
810
891
  });
811
- }, W = ht();
812
- W.setConfig({
813
- USE_PROFILES: { html: !0 },
814
- ALLOWED_TAGS: [
815
- "div",
816
- "p",
817
- "br",
818
- "strong",
819
- "b",
820
- "em",
821
- "i",
822
- "u",
823
- "s",
824
- "code",
825
- "pre",
826
- "blockquote",
827
- "h1",
828
- "h2",
829
- "h3",
830
- "h4",
831
- "h5",
832
- "h6",
833
- "ul",
834
- "ol",
835
- "li",
836
- "a",
837
- "img",
838
- "table",
839
- "thead",
840
- "tbody",
841
- "tr",
842
- "th",
843
- "td",
844
- "sup",
845
- "sub"
846
- ],
847
- ALLOWED_ATTR: [
848
- "href",
849
- "target",
850
- "rel",
851
- "src",
852
- "alt",
853
- "title",
854
- "width",
855
- "height",
856
- "colspan",
857
- "rowspan",
858
- "data-*",
859
- "style",
860
- "class"
861
- ],
862
- ALLOW_DATA_ATTR: !0
863
- });
864
- W.addHook("uponSanitizeAttribute", (t, o) => {
865
- if (o.attrName === "style") {
866
- const n = o.attrValue.toLowerCase();
867
- (n.includes("expression") || n.includes("javascript:") || n.includes("url(")) && (o.keepAttr = !1);
868
- }
869
- });
870
- function S(t) {
871
- return t ? W.sanitize(t) : "";
872
- }
873
- var I = null;
874
- function te() {
875
- return I || (I = import("shiki").then(({ createHighlighter: t }) => t({
876
- themes: ["github-light"],
877
- langs: ["html"]
878
- }))), I;
892
+ };
893
+ function Pt(...o) {
894
+ return o.filter(Boolean).join(" ");
879
895
  }
880
- function ee({ defaultValue: t, onUpdate: o, readonly: n }) {
881
- const [i, r] = m.useState(t || ""), [u, c] = m.useState(""), [l, s] = m.useState(!1), [C, k] = m.useState(!1), b = m.useRef(!1), w = m.useCallback(async (g) => {
882
- try {
883
- const [{ format: d }, { default: T }] = await Promise.all([import("../../standalone-DSxjHhed.js"), import("../../html-Ccb8eKR4.js")]), L = await d(g, {
884
- parser: "html",
885
- plugins: [T],
886
- htmlWhitespaceSensitivity: "css",
887
- printWidth: 80
888
- });
889
- return s(!1), L;
890
- } catch (d) {
891
- return console.error("Format error:", d), s(!0), g;
892
- }
893
- }, []), E = m.useCallback((g) => {
894
- te().then((d) => {
895
- c(d.codeToHtml(g || " ", {
896
- lang: "html",
897
- theme: "github-light"
898
- }));
899
- }).catch((d) => console.error("Highlight error:", d));
896
+ function eo({ defaultValue: o, onUpdate: t, className: i, toolbarPosition: r = "top", customToolbarChildren: n, toolbarItems: c, hideToolbar: l, readonly: s, autoFocus: C, customFonts: a, htmlSource: m, isHtml: A, setIsHtml: T, ...I }) {
897
+ const [_, H] = u.useState((A ?? !1) && !!m);
898
+ u.useEffect(() => {
899
+ process.env.NODE_ENV !== "production" && A && !m && console.warn('[WuContentEditor]: `isHtml` has no effect without an `htmlSource` component. Import {WuHtmlSource} from "@npm-questionpro/wick-ui-editor/html" and pass it as `htmlSource`.');
900
900
  }, []);
901
- m.useEffect(() => {
902
- E(i), o?.(S(i));
903
- }, [
904
- i,
905
- E,
906
- o
907
- ]), m.useEffect(() => {
908
- b.current || !t || (b.current = !0, w(t).then(r));
909
- }, [t, w]);
910
- const A = async (g) => {
911
- g.preventDefault(), k(!0), r(await w(i)), k(!1);
912
- }, y = (g) => {
913
- if (g.key === "Tab") {
914
- g.preventDefault();
915
- const d = g.currentTarget, T = d.selectionStart, L = d.selectionEnd;
916
- r(i.substring(0, T) + " " + i.substring(L)), requestAnimationFrame(() => {
917
- d.selectionStart = T + 2, d.selectionEnd = T + 2;
918
- });
901
+ const b = u.useRef(o || ""), k = ye({
902
+ editable: !s,
903
+ autofocus: C ? "end" : !1,
904
+ extensions: $e,
905
+ content: F(o || ""),
906
+ onUpdate: ({ editor: p }) => {
907
+ t && t(F(p.getHTML()));
919
908
  }
909
+ }), L = (p) => {
910
+ p ? b.current = k?.getHTML() ?? "" : k?.commands.setContent(F(b.current)), t && t(F(b.current)), H(p), T?.(p);
920
911
  };
921
- return /* @__PURE__ */ e(x, { children: C ? /* @__PURE__ */ e(x, { children: "Formatting..." }) : /* @__PURE__ */ e("div", {
922
- className: a.wuContentEditor,
923
- children: /* @__PURE__ */ v("div", {
924
- className: a.wuCodeEditor,
925
- children: [
926
- /* @__PURE__ */ e(q, {
927
- variant: "iconOnly",
928
- Icon: /* @__PURE__ */ e(h, { icon: "wm-data-object" }),
929
- onClick: A,
930
- className: a.wuFormatCode,
931
- style: { color: l ? "red" : "" }
932
- }),
933
- /* @__PURE__ */ e("div", {
934
- dangerouslySetInnerHTML: { __html: u },
935
- className: a.wuCodeEditorPreview
936
- }),
937
- /* @__PURE__ */ e("textarea", {
938
- value: i,
939
- onChange: (g) => r(g.target.value),
940
- onKeyDown: y,
941
- className: a.wuCodeEditorInput,
942
- disabled: n
943
- })
944
- ]
945
- })
946
- }) });
947
- }
948
- function ve({ defaultValue: t, onUpdate: o, className: n, toolbarPosition: i = "top", customToolbarChildren: r, toolbarItems: u, hideToolbar: c, readonly: l, customFonts: s, isHtml: C, setIsHtml: k, ...b }) {
949
- const [w, E] = m.useState(C ?? !1), A = m.useRef(t || ""), y = V({
950
- editable: !l,
951
- extensions: Ft,
952
- content: S(t || ""),
953
- onUpdate: ({ editor: d }) => {
954
- o && o(S(d.getHTML()));
955
- }
956
- }), g = (d) => {
957
- d ? A.current = y?.getHTML() ?? "" : y?.commands.setContent(S(A.current)), o && o(S(A.current)), E(d), k?.(d);
958
- };
959
- return /* @__PURE__ */ v("div", {
960
- className: X(a.wuContentEditorContainer, n),
961
- "data-position": i,
962
- "data-slot": "wu-content-editor-container",
963
- onClick: () => {
964
- w || y?.chain().focus().run();
912
+ return /* @__PURE__ */ f("div", {
913
+ className: Pt(S.wuContentEditorRoot, i),
914
+ "data-position": r,
915
+ "data-slot": "wu-content-editor-root",
916
+ onClick: (p) => {
917
+ if ((p.ctrlKey || p.metaKey) && p.target instanceof HTMLElement) {
918
+ const j = p.target.closest("a");
919
+ if (j?.href) {
920
+ window.open(j.href, "_blank", "noopener,noreferrer");
921
+ return;
922
+ }
923
+ }
924
+ _ || k?.chain().focus().run();
965
925
  },
966
- ...b,
967
- children: [!c && /* @__PURE__ */ e(Qt, {
968
- editor: y,
969
- customFonts: s,
970
- className: a.wuContentEditorToolbar,
971
- items: u,
972
- isHtml: w,
973
- setIsHtml: g,
926
+ ...I,
927
+ children: [!l && /* @__PURE__ */ e(zt, {
928
+ editor: k,
929
+ customFonts: a,
930
+ className: S.wuContentEditorToolbar,
931
+ items: c,
932
+ isHtml: _,
933
+ setIsHtml: L,
934
+ htmlSourceEnabled: !!m,
974
935
  "data-slot": "wu-content-editor-toolbar",
975
- "data-position": i,
976
- children: r
977
- }), w ? /* @__PURE__ */ e(ee, {
978
- defaultValue: A.current,
979
- onUpdate: (d) => {
980
- A.current = d ?? "", o && o(d ?? "");
936
+ children: n
937
+ }), _ && m ? /* @__PURE__ */ e(m, {
938
+ defaultValue: b.current,
939
+ onUpdate: (p) => {
940
+ b.current = p ?? "", t && t(p ?? "");
981
941
  },
982
- "data-position": i,
983
- "data-slot": "wu-content-editor",
984
- readonly: l
985
- }) : /* @__PURE__ */ e(G, {
986
- editor: y,
987
- className: a.wuContentEditor,
942
+ readonly: s
943
+ }) : /* @__PURE__ */ e(Te, {
944
+ editor: k,
945
+ className: S.wuContentEditor,
988
946
  "data-slot": "wu-content-editor"
989
947
  })]
990
948
  });
991
949
  }
992
950
  export {
993
- ve as WuContentEditor
951
+ eo as WuContentEditor
994
952
  };