@npm-questionpro/wick-ui-editor 2.2.0 → 2.4.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.
@@ -9,6 +9,17 @@ export interface IWuHtmlSourceProps {
9
9
  /** When `true`, the textarea is disabled. */
10
10
  readonly?: boolean;
11
11
  }
12
+ /** Default formatting values applied when no explicit selection overrides them. */
13
+ export interface IWuEditorDefaults {
14
+ /** Default text color (CSS color string, e.g. `'#545E6B'`). */
15
+ color?: string;
16
+ /** Default background/highlight color (CSS color string). */
17
+ bgColor?: string;
18
+ /** Default font size in px (e.g. `16`). */
19
+ fontSize?: number;
20
+ /** Default font family name (must be one of the available fonts). */
21
+ fontFamily?: string;
22
+ }
12
23
  export interface IWuContentEditorProps extends React.HTMLAttributes<HTMLDivElement> {
13
24
  /** Initial HTML content (auto-sanitized on mount). */
14
25
  defaultValue?: string;
@@ -28,6 +39,8 @@ export interface IWuContentEditorProps extends React.HTMLAttributes<HTMLDivEleme
28
39
  readonly?: boolean;
29
40
  /** Moves focus into the editor on mount. */
30
41
  autoFocus?: boolean;
42
+ /** Default formatting values (color, bgColor, fontSize, fontFamily). */
43
+ defaultValues?: IWuEditorDefaults;
31
44
  /**
32
45
  * HTML Source view component, e.g. `WuHtmlSource` from
33
46
  * `@npm-questionpro/wick-ui-editor/html`. When omitted, HTML Source Mode
@@ -44,4 +57,4 @@ export interface IWuContentEditorProps extends React.HTMLAttributes<HTMLDivEleme
44
57
  *
45
58
  * @summary content creation — reach for this when users need to compose or edit formatted HTML content
46
59
  */
47
- export declare function WuContentEditor({ defaultValue, onUpdate, className, toolbarPosition, customToolbarChildren, toolbarItems, hideToolbar, readonly, autoFocus, customFonts, htmlSource: HtmlSourceView, isHtml: isHtmlProp, setIsHtml: setIsHtmlProp, ...props }: IWuContentEditorProps): React.JSX.Element;
60
+ export declare function WuContentEditor({ defaultValue, onUpdate, className, toolbarPosition, customToolbarChildren, toolbarItems, hideToolbar, readonly, autoFocus, customFonts, htmlSource: HtmlSourceView, isHtml: isHtmlProp, setIsHtml: setIsHtmlProp, defaultValues, ...props }: IWuContentEditorProps): React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { Editor } from '@tiptap/react';
2
+ import type { IWuEditorDefaults } from '../WuContentEditor';
2
3
  declare const TOOLBAR_EXTENSIONS: {
3
4
  block: import("react/jsx-runtime").JSX.Element;
4
5
  fontFamily: import("react/jsx-runtime").JSX.Element;
@@ -26,6 +27,7 @@ export type IToolbarExtensionKey = keyof typeof TOOLBAR_EXTENSIONS;
26
27
  export interface IToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
27
28
  editor: Editor;
28
29
  customFonts?: string[];
30
+ defaultValues?: IWuEditorDefaults;
29
31
  items?: IToolbarExtensionKey[];
30
32
  isHtml: boolean;
31
33
  setIsHtml: (isHtml: boolean) => void;
@@ -1,8 +1,10 @@
1
1
  import type { Editor } from '@tiptap/react';
2
2
  import React from 'react';
3
+ import type { IWuEditorDefaults } from '../WuContentEditor';
3
4
  export interface IToolbarContextProps {
4
5
  editor: Editor;
5
6
  customFonts?: string[];
7
+ defaultValues?: IWuEditorDefaults;
6
8
  isHtml: boolean;
7
9
  setIsHtml: (isHtml: boolean) => void;
8
10
  /** Whether an HTML source view is provided via the `htmlSource` prop. */
@@ -13,10 +15,11 @@ interface IToolbarProviderProps {
13
15
  editor: Editor;
14
16
  children: React.ReactNode;
15
17
  customFonts?: string[];
18
+ defaultValues?: IWuEditorDefaults;
16
19
  isHtml: boolean;
17
20
  setIsHtml: (isHtml: boolean) => void;
18
21
  htmlSourceEnabled: boolean;
19
22
  }
20
- export declare const ToolbarProvider: ({ editor, children, customFonts, isHtml, setIsHtml, htmlSourceEnabled, }: IToolbarProviderProps) => React.JSX.Element;
23
+ export declare const ToolbarProvider: ({ editor, children, customFonts, defaultValues, isHtml, setIsHtml, htmlSourceEnabled, }: IToolbarProviderProps) => React.JSX.Element;
21
24
  export declare const useToolbar: () => IToolbarContextProps;
22
25
  export {};
@@ -1,19 +1,19 @@
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";
1
+ import { A as K, C as J, D as ue, E as fe, M as he, O as ve, S as ge, T as Q, _ as X, a as Y, b as pe, c as me, d as be, f as Ce, g as Z, h as G, i as V, j as ke, k as _e, l as ee, m as z, n as L, o as te, r as oe, s as Ae, t as R, u as we, v as ie, w as re, x as Ie, y as ye } from "../../sanitize-BZ0U7q7z.js";
2
+ import { EditorContent as Te, useEditor as Se, useEditorState as p } from "@tiptap/react";
3
+ import d, { useCallback as D, useRef as xe, useState as O } from "react";
4
+ import Fe from "@tiptap/extension-image";
5
5
  import { TaskItem as He, TaskList as Le } from "@tiptap/extension-list";
6
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";
7
+ import Ee from "@tiptap/extension-superscript";
8
+ import { TableKit as Ne } from "@tiptap/extension-table";
9
+ import ze from "@tiptap/extension-text-align";
10
+ import { BackgroundColor as De, Color as Be, FontFamily as Pe, FontSize as Oe, LineHeight as Me, TextStyle as $e } from "@tiptap/extension-text-style";
11
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";
12
+ import { Fragment as N, jsx as e, jsxs as g } from "react/jsx-runtime";
13
+ import { Menu as C } from "@base-ui/react/menu";
14
+ import { Dialog as I } from "@base-ui/react/dialog";
15
15
  import { Switch as ne } from "@base-ui/react/switch";
16
- var $e = [
16
+ var Ue = [
17
17
  qe.configure({ link: {
18
18
  openOnClick: !1,
19
19
  autolink: !0,
@@ -28,9 +28,9 @@ var $e = [
28
28
  "file",
29
29
  "mailto"
30
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);
31
+ if (r.includes(n) || !t.protocols.map((c) => typeof c == "string" ? c : c.scheme).includes(n)) return !1;
32
+ const s = ["example-phishing.com", "malicious-site.net"], l = i.hostname;
33
+ return !s.includes(l);
34
34
  } catch {
35
35
  return !1;
36
36
  }
@@ -44,89 +44,90 @@ var $e = [
44
44
  }
45
45
  }
46
46
  } }),
47
- Ne.configure({ types: ["heading", "paragraph"] }),
48
- Fe,
47
+ ze.configure({ types: ["heading", "paragraph"] }),
48
+ Ee,
49
49
  Re,
50
- Me,
50
+ $e,
51
51
  Be,
52
52
  De,
53
53
  Le,
54
54
  He,
55
+ Me,
55
56
  Oe,
56
57
  Pe,
57
- ze,
58
- xe.configure({
58
+ Fe.configure({
59
59
  resize: {
60
60
  enabled: !0,
61
61
  alwaysPreserveAspectRatio: !0
62
62
  },
63
63
  inline: !0
64
64
  }),
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, {
65
+ Ne.configure({ table: { resizable: !0 } })
66
+ ], M = d.createContext(null), We = ({ editor: o, children: t, customFonts: i, defaultValues: r, isHtml: n, setIsHtml: s, htmlSourceEnabled: l }) => /* @__PURE__ */ e(M.Provider, {
67
67
  value: {
68
68
  editor: o,
69
69
  customFonts: i,
70
- isHtml: r,
71
- setIsHtml: n,
72
- htmlSourceEnabled: c
70
+ defaultValues: r,
71
+ isHtml: n,
72
+ setIsHtml: s,
73
+ htmlSourceEnabled: l
73
74
  },
74
75
  children: t
75
- }), h = () => {
76
- const o = u.useContext(M);
76
+ }), f = () => {
77
+ const o = d.useContext(M);
77
78
  if (!o) throw new Error("useToolbar must be used within a ToolbarProvider");
78
79
  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", {
80
+ }, je = "_dropdown_k3z4n_1", Ke = "_dropdownItem_k3z4n_17", se = {
81
+ dropdown: je,
82
+ dropdownItem: Ke
83
+ }, Je = "_item_wqnwe_1", Qe = { item: Je }, u = d.forwardRef(function({ Icon: t, children: i, ...r }, n) {
84
+ return /* @__PURE__ */ g("button", {
84
85
  ref: n,
85
86
  ...r,
86
- className: Je.item,
87
+ className: Qe.item,
87
88
  children: [
88
89
  t,
89
90
  " ",
90
91
  i
91
92
  ]
92
93
  });
93
- }), q = u.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
94
+ }), $ = d.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
94
95
  ref: i,
95
96
  className: se.dropdown,
96
97
  ...t,
97
98
  children: o
98
99
  }));
99
- q.displayName = "DropdownPopup";
100
- var $ = u.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
100
+ $.displayName = "DropdownPopup";
101
+ var q = d.forwardRef(({ children: o, ...t }, i) => /* @__PURE__ */ e("div", {
101
102
  ref: i,
102
103
  className: se.dropdownItem,
103
104
  ...t,
104
105
  children: o
105
106
  }));
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, {}),
107
+ q.displayName = "DropdownItem";
108
+ function U({ trigger: o, triggerTitle: t, active: i, items: r, align: n = "start", direction: s = "inline" }) {
109
+ return /* @__PURE__ */ g(C.Root, { children: [/* @__PURE__ */ e(C.Trigger, {
110
+ render: /* @__PURE__ */ e(u, {}),
110
111
  "data-active": i,
111
112
  title: t,
112
113
  children: o
113
- }), /* @__PURE__ */ e(g.Portal, { children: /* @__PURE__ */ e(g.Positioner, {
114
+ }), /* @__PURE__ */ e(C.Portal, { children: /* @__PURE__ */ e(C.Positioner, {
114
115
  align: n,
115
116
  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,
117
+ children: /* @__PURE__ */ e(C.Popup, {
118
+ render: /* @__PURE__ */ e($, {}),
119
+ "data-inline": s === "inline" ? !0 : void 0,
120
+ "data-block": s === "block" ? !0 : void 0,
120
121
  finalFocus: !1,
121
- children: r.map((l) => c === "block" ? /* @__PURE__ */ e(g.Item, {
122
- render: /* @__PURE__ */ e($, {}),
122
+ children: r.map((l) => s === "block" ? /* @__PURE__ */ e(C.Item, {
123
+ render: /* @__PURE__ */ e(q, {}),
123
124
  title: l.tooltip,
124
125
  "data-active": l.active,
125
126
  style: l.style,
126
127
  onClick: l.event,
127
128
  children: l.icon ?? l.label
128
- }, l.id) : /* @__PURE__ */ e(g.Item, {
129
- render: /* @__PURE__ */ e(d, {}),
129
+ }, l.id) : /* @__PURE__ */ e(C.Item, {
130
+ render: /* @__PURE__ */ e(u, {}),
130
131
  "data-active": l.active,
131
132
  title: l.tooltip,
132
133
  onClick: l.event,
@@ -135,8 +136,8 @@ function U({ trigger: o, triggerTitle: t, active: i, items: r, align: n = "start
135
136
  })
136
137
  }) })] });
137
138
  }
138
- var Qe = () => {
139
- const { editor: o } = h(), t = v({
139
+ var Xe = () => {
140
+ const { editor: o } = f(), t = p({
140
141
  editor: o,
141
142
  selector: (r) => ({
142
143
  isParagraph: r.editor?.isActive("paragraph"),
@@ -156,21 +157,21 @@ var Qe = () => {
156
157
  },
157
158
  {
158
159
  id: "h1",
159
- icon: /* @__PURE__ */ e(Z, {}),
160
+ icon: /* @__PURE__ */ e(G, {}),
160
161
  event: () => o.chain().focus().setHeading({ level: 1 }).run(),
161
162
  tooltip: "Heading 1",
162
163
  active: t.isH1
163
164
  },
164
165
  {
165
166
  id: "h2",
166
- icon: /* @__PURE__ */ e(Y, {}),
167
+ icon: /* @__PURE__ */ e(Z, {}),
167
168
  event: () => o.chain().focus().setHeading({ level: 2 }).run(),
168
169
  tooltip: "Heading 2",
169
170
  active: t.isH2
170
171
  },
171
172
  {
172
173
  id: "h3",
173
- icon: /* @__PURE__ */ e(V, {}),
174
+ icon: /* @__PURE__ */ e(X, {}),
174
175
  event: () => o.chain().focus().setHeading({ level: 3 }).run(),
175
176
  tooltip: "Heading 3",
176
177
  active: t.isH3
@@ -184,42 +185,42 @@ var Qe = () => {
184
185
  }
185
186
  ];
186
187
  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
+ trigger: t.isH1 ? /* @__PURE__ */ e(G, {}) : t.isH2 ? /* @__PURE__ */ e(Z, {}) : t.isH3 ? /* @__PURE__ */ e(X, {}) : t.isH4 ? /* @__PURE__ */ e(ie, {}) : /* @__PURE__ */ e(Q, {}),
188
189
  triggerTitle: "Block Style",
189
190
  active: t.isHeading,
190
191
  items: i
191
192
  });
192
- }, Ve = () => {
193
- const { editor: o } = h();
194
- return /* @__PURE__ */ e(d, {
193
+ }, Ye = () => {
194
+ const { editor: o } = f();
195
+ return /* @__PURE__ */ e(u, {
195
196
  title: "Bold",
196
- "data-active": v({
197
+ "data-active": p({
197
198
  editor: o,
198
199
  selector: (t) => ({ bold: t.editor?.isActive("bold") })
199
200
  }).bold,
200
201
  onClick: (t) => {
201
202
  t.preventDefault(), o.chain().focus().toggleBold().run();
202
203
  },
203
- children: /* @__PURE__ */ e(ge, {})
204
+ children: /* @__PURE__ */ e(me, {})
204
205
  });
205
- }, Xe = () => {
206
- const { editor: o } = h();
206
+ }, Ze = () => {
207
+ const { editor: o } = f();
207
208
  return /* @__PURE__ */ e(N, { children: [{
208
209
  id: "clear",
209
- icon: /* @__PURE__ */ e(Ae, {}),
210
+ icon: /* @__PURE__ */ e(we, {}),
210
211
  event: () => o.chain().focus().clearNodes().unsetAllMarks().run(),
211
212
  tooltip: "Clear Formatting"
212
- }].map((t) => /* @__PURE__ */ e(d, {
213
+ }].map((t) => /* @__PURE__ */ e(u, {
213
214
  title: t.tooltip,
214
215
  onClick: (i) => {
215
216
  i.preventDefault(), t.event();
216
217
  },
217
218
  children: t.icon
218
219
  }, t.id)) });
219
- }, Ye = () => {
220
- const { editor: o } = h();
221
- return /* @__PURE__ */ e(d, {
222
- "data-active": v({
220
+ }, Ge = () => {
221
+ const { editor: o } = f();
222
+ return /* @__PURE__ */ e(u, {
223
+ "data-active": p({
223
224
  editor: o,
224
225
  selector: (t) => ({ code: t.editor.isActive("code") })
225
226
  }).code,
@@ -227,23 +228,23 @@ var Qe = () => {
227
228
  onMouseDown: (t) => {
228
229
  t.preventDefault(), o.chain().focus().toggleCode().run();
229
230
  },
230
- children: /* @__PURE__ */ e(be, {})
231
+ children: /* @__PURE__ */ e(Ce, {})
231
232
  });
232
- }, Ze = () => {
233
- const { editor: o } = h();
234
- return /* @__PURE__ */ e(d, {
233
+ }, Ve = () => {
234
+ const { editor: o } = f();
235
+ return /* @__PURE__ */ e(u, {
235
236
  title: "Italic",
236
- "data-active": v({
237
+ "data-active": p({
237
238
  editor: o,
238
239
  selector: (t) => ({ italic: t.editor?.isActive("italic") })
239
240
  }).italic,
240
241
  onClick: (t) => {
241
242
  t.preventDefault(), o.chain().focus().toggleItalic().run();
242
243
  },
243
- children: /* @__PURE__ */ e(we, {})
244
+ children: /* @__PURE__ */ e(Ie, {})
244
245
  });
245
- }, Ge = () => {
246
- const { editor: o } = h(), t = v({
246
+ }, et = () => {
247
+ const { editor: o } = f(), t = p({
247
248
  editor: o,
248
249
  selector: (r) => ({
249
250
  isUl: r.editor?.isActive("bulletList"),
@@ -280,65 +281,65 @@ var Qe = () => {
280
281
  active: t.isList,
281
282
  items: i
282
283
  });
283
- }, et = () => {
284
- const { editor: o } = h();
285
- return /* @__PURE__ */ e(d, {
284
+ }, tt = () => {
285
+ const { editor: o } = f();
286
+ return /* @__PURE__ */ e(u, {
286
287
  title: "strikethrough",
287
- "data-active": v({
288
+ "data-active": p({
288
289
  editor: o,
289
290
  selector: (t) => ({ strikethrough: t.editor?.isActive("strike") })
290
291
  }).strikethrough,
291
292
  onClick: (t) => {
292
293
  t.preventDefault(), o.chain().focus().toggleStrike().run();
293
294
  },
294
- children: /* @__PURE__ */ e(de, {})
295
+ children: /* @__PURE__ */ e(ue, {})
295
296
  });
296
- }, tt = () => {
297
- const { editor: o } = h();
298
- return /* @__PURE__ */ e(d, {
297
+ }, ot = () => {
298
+ const { editor: o } = f();
299
+ return /* @__PURE__ */ e(u, {
299
300
  title: "Subscript",
300
- "data-active": v({
301
+ "data-active": p({
301
302
  editor: o,
302
303
  selector: (t) => ({ subscript: t.editor?.isActive("subscript") })
303
304
  }).subscript,
304
305
  onClick: (t) => {
305
306
  t.preventDefault(), o.chain().focus().toggleSubscript().run();
306
307
  },
307
- children: /* @__PURE__ */ e(fe, {})
308
+ children: /* @__PURE__ */ e(ve, {})
308
309
  });
309
- }, ot = () => {
310
- const { editor: o } = h();
311
- return /* @__PURE__ */ e(d, {
310
+ }, it = () => {
311
+ const { editor: o } = f();
312
+ return /* @__PURE__ */ e(u, {
312
313
  title: "Superscript",
313
- "data-active": v({
314
+ "data-active": p({
314
315
  editor: o,
315
316
  selector: (t) => ({ superscript: t.editor?.isActive("superscript") })
316
317
  }).superscript,
317
318
  onClick: (t) => {
318
319
  t.preventDefault(), o.chain().focus().toggleSuperscript().run();
319
320
  },
320
- children: /* @__PURE__ */ e(Ce, {})
321
+ children: /* @__PURE__ */ e(_e, {})
321
322
  });
322
- }, it = () => {
323
- const { editor: o } = h(), t = v({
323
+ }, rt = () => {
324
+ const { editor: o, defaultValues: t } = f(), i = p({
324
325
  editor: o,
325
- selector: ({ editor: r }) => ({ textColor: r.getAttributes("textStyle").color })
326
- }), i = u.useRef(null);
327
- return /* @__PURE__ */ f(d, {
326
+ selector: ({ editor: n }) => ({ textColor: n.getAttributes("textStyle").color })
327
+ }), r = d.useRef(null);
328
+ return /* @__PURE__ */ g(u, {
328
329
  title: "Text Color",
329
- onClick: () => i.current?.click(),
330
- children: [/* @__PURE__ */ e(ke, { style: { color: t.textColor } }), /* @__PURE__ */ e("input", {
331
- ref: i,
330
+ onClick: () => r.current?.click(),
331
+ children: [/* @__PURE__ */ e(ke, { style: { color: i.textColor } }), /* @__PURE__ */ e("input", {
332
+ ref: r,
332
333
  type: "color",
333
- defaultValue: "#545E6B",
334
- onChange: (r) => o.chain().focus().setColor(r.target.value).run()
334
+ defaultValue: t?.color ?? "#545E6B",
335
+ onChange: (n) => o.chain().focus().setColor(n.target.value).run()
335
336
  })]
336
337
  });
337
- }, rt = () => {
338
- const { editor: o } = h();
339
- return /* @__PURE__ */ e(d, {
338
+ }, nt = () => {
339
+ const { editor: o } = f();
340
+ return /* @__PURE__ */ e(u, {
340
341
  title: "Underline",
341
- "data-active": v({
342
+ "data-active": p({
342
343
  editor: o,
343
344
  selector: (t) => ({ underline: t.editor?.isActive("underline") })
344
345
  }).underline,
@@ -347,48 +348,48 @@ var Qe = () => {
347
348
  },
348
349
  children: /* @__PURE__ */ e(he, {})
349
350
  });
350
- }, nt = () => {
351
- const { editor: o } = h(), t = v({
351
+ }, lt = () => {
352
+ const { editor: o, defaultValues: t } = f(), i = p({
352
353
  editor: o,
353
- selector: ({ editor: r }) => ({ bgColor: r.getAttributes("textStyle").backgroundColor })
354
- }), i = u.useRef(null);
355
- return /* @__PURE__ */ f(d, {
354
+ selector: ({ editor: n }) => ({ bgColor: n.getAttributes("textStyle").backgroundColor })
355
+ }), r = d.useRef(null);
356
+ return /* @__PURE__ */ g(u, {
356
357
  title: "Background Color",
357
- onClick: () => i.current?.click(),
358
- children: [/* @__PURE__ */ e(_e, { style: { color: t.bgColor } }), /* @__PURE__ */ e("input", {
359
- ref: i,
358
+ onClick: () => r.current?.click(),
359
+ children: [/* @__PURE__ */ e(Ae, { style: { color: i.bgColor } }), /* @__PURE__ */ e("input", {
360
+ ref: r,
360
361
  type: "color",
361
- defaultValue: "#fff",
362
- onChange: (r) => o.chain().focus().setBackgroundColor(r.target.value).run()
362
+ defaultValue: t?.bgColor ?? "#fff",
363
+ onChange: (n) => o.chain().focus().setBackgroundColor(n.target.value).run()
363
364
  })]
364
365
  });
365
- }, lt = () => {
366
- const { editor: o } = h();
367
- return /* @__PURE__ */ e(d, {
366
+ }, at = () => {
367
+ const { editor: o } = f();
368
+ return /* @__PURE__ */ e(u, {
368
369
  title: "quote",
369
- "data-active": v({
370
+ "data-active": p({
370
371
  editor: o,
371
372
  selector: (t) => ({ blockquote: t.editor?.isActive("blockquote") })
372
373
  }).blockquote,
373
374
  onClick: (t) => {
374
375
  t.preventDefault(), o.chain().focus().toggleBlockquote().run();
375
376
  },
376
- children: /* @__PURE__ */ e(ue, {})
377
+ children: /* @__PURE__ */ e(fe, {})
377
378
  });
378
379
  };
379
- function at() {
380
- const { isHtml: o, setIsHtml: t, htmlSourceEnabled: i } = h();
381
- return i ? /* @__PURE__ */ e(d, {
380
+ function st() {
381
+ const { isHtml: o, setIsHtml: t, htmlSourceEnabled: i } = f();
382
+ return i ? /* @__PURE__ */ e(u, {
382
383
  title: "HTML source",
383
384
  "data-active": o,
384
385
  onClick: (r) => {
385
386
  r.preventDefault(), t(!o);
386
387
  },
387
- children: /* @__PURE__ */ e(Ie, {})
388
+ children: /* @__PURE__ */ e(ye, {})
388
389
  }) : null;
389
390
  }
390
- var st = () => {
391
- const { editor: o } = h(), t = v({
391
+ var ct = () => {
392
+ const { editor: o } = f(), t = p({
392
393
  editor: o,
393
394
  selector: (r) => ({
394
395
  isLeft: r.editor?.isActive({ textAlign: "left" }),
@@ -400,7 +401,7 @@ var st = () => {
400
401
  }), i = [
401
402
  {
402
403
  id: "left",
403
- icon: /* @__PURE__ */ e(X, {}),
404
+ icon: /* @__PURE__ */ e(Y, {}),
404
405
  event: () => o.chain().focus().setTextAlign("left").run(),
405
406
  tooltip: "Align Left",
406
407
  active: t.isLeft
@@ -421,160 +422,160 @@ var st = () => {
421
422
  },
422
423
  {
423
424
  id: "justify",
424
- icon: /* @__PURE__ */ e(G, {}),
425
+ icon: /* @__PURE__ */ e(V, {}),
425
426
  event: () => o.chain().focus().setTextAlign("justify").run(),
426
427
  tooltip: "Justify",
427
428
  active: t.isJustify
428
429
  }
429
430
  ];
430
431
  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
+ trigger: t.isCenter ? /* @__PURE__ */ e(oe, {}) : t.isRight ? /* @__PURE__ */ e(te, {}) : t.isJustify ? /* @__PURE__ */ e(V, {}) : /* @__PURE__ */ e(Y, {}),
432
433
  triggerTitle: "Text Alignment",
433
434
  active: t.isAligned,
434
435
  items: i
435
436
  });
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,
437
+ }, dt = "_wuContentEditor_1w25e_3", ut = "_selectedCell_1w25e_1", ft = "_tableWrapper_1w25e_1", ht = "_wuContentEditorRoot_1w25e_3", vt = "_wuContentEditorToolbar_1w25e_17", gt = "_fontSize_1w25e_38", pt = "_wuContentEditorTable_1w25e_56", F = {
438
+ wuContentEditor: dt,
439
+ selectedCell: ut,
439
440
  "column-resize-handle": "_column-resize-handle_1w25e_1",
440
- tableWrapper: ut,
441
+ tableWrapper: ft,
441
442
  "resize-cursor": "_resize-cursor_1w25e_1",
442
443
  wuContentEditorRoot: ht,
443
- wuContentEditorToolbar: ft,
444
- fontSize: vt,
444
+ wuContentEditorToolbar: vt,
445
+ fontSize: gt,
445
446
  wuContentEditorTable: pt
446
- }, gt = [
447
+ }, mt = [
447
448
  "e",
448
449
  "E",
449
450
  "+",
450
451
  "-"
451
- ], le = 1, mt = () => {
452
- const { editor: o } = h(), [t, i] = O(16), r = v({
452
+ ], le = 1, bt = () => {
453
+ const { editor: o, defaultValues: t } = f(), [i, r] = O(t?.fontSize ?? 16), n = p({
453
454
  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);
455
+ selector: (h) => ({ fontSize: h.editor.getAttributes("textStyle").fontSize })
456
+ }), s = (h) => {
457
+ o.chain().focus().setFontSize(h + "px").run();
458
+ }, l = (h) => {
459
+ const a = Math.max(le, h);
460
+ r(a), s(a);
461
+ }, c = (h) => {
462
+ mt.includes(h.key) ? h.preventDefault() : h.key === "Enter" && s(i);
462
463
  };
463
- return u.useEffect(() => {
464
- i(Number(r.fontSize?.replace("px", "")) || 16);
465
- }, [r.fontSize]), /* @__PURE__ */ f("div", {
466
- className: S.fontSize,
464
+ return d.useEffect(() => {
465
+ r(Number(n.fontSize?.replace("px", "")) || (t?.fontSize ?? 16));
466
+ }, [n.fontSize, t?.fontSize]), /* @__PURE__ */ g("div", {
467
+ className: F.fontSize,
467
468
  children: [
468
- /* @__PURE__ */ e(d, {
469
- onClick: () => c(t - 1),
470
- disabled: t <= le,
469
+ /* @__PURE__ */ e(u, {
470
+ onClick: () => l(i - 1),
471
+ disabled: i <= le,
471
472
  children: "−"
472
473
  }),
473
474
  /* @__PURE__ */ e("input", {
474
475
  type: "number",
475
476
  inputMode: "numeric",
476
477
  pattern: "[0-9]*",
477
- value: t,
478
- onKeyDown: l,
479
- onChange: (s) => i(s.target.valueAsNumber),
480
- onBlur: () => n(t)
478
+ value: i,
479
+ onKeyDown: c,
480
+ onChange: (h) => r(h.target.valueAsNumber),
481
+ onBlur: () => s(i)
481
482
  }),
482
- /* @__PURE__ */ e(d, {
483
- onClick: () => c(t + 1),
484
- disabled: t >= 128,
483
+ /* @__PURE__ */ e(u, {
484
+ onClick: () => l(i + 1),
485
+ disabled: i >= 128,
485
486
  children: "+"
486
487
  })
487
488
  ]
488
489
  });
489
- }, bt = () => {
490
- const { editor: o, customFonts: t } = h(), i = v({
490
+ }, Ct = () => {
491
+ const { editor: o, customFonts: t, defaultValues: i } = f(), r = p({
491
492
  editor: o,
492
- selector: (l) => ({ currentFontFamily: l.editor.getAttributes("textStyle").fontFamily || "" })
493
- }), r = [
493
+ selector: (c) => ({ currentFontFamily: c.editor.getAttributes("textStyle").fontFamily || "" })
494
+ }), n = [
494
495
  "Fira Sans",
495
496
  "Inter",
496
497
  "Poppins",
497
498
  "JetBrains Mono",
498
499
  "Montserrat",
499
500
  ...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, {
501
+ ], [s, l] = O(r.currentFontFamily || i?.fontFamily || n[0]);
502
+ return d.useEffect(() => {
503
+ l(r.currentFontFamily?.replace(/"/g, "") || i?.fontFamily || n[0]);
504
+ }, [r.currentFontFamily]), /* @__PURE__ */ g(C.Root, { children: [/* @__PURE__ */ e(C.Trigger, {
505
+ "data-active": s !== (i?.fontFamily ?? n[0]),
506
+ style: { fontFamily: s },
507
+ title: s || "Font Family",
508
+ render: /* @__PURE__ */ e(u, {}),
509
+ children: s?.[0]
510
+ }), /* @__PURE__ */ e(C.Portal, { children: /* @__PURE__ */ e(C.Positioner, {
510
511
  align: "start",
511
512
  sideOffset: 4,
512
- children: /* @__PURE__ */ e(g.Popup, {
513
- render: /* @__PURE__ */ e(q, {}),
513
+ children: /* @__PURE__ */ e(C.Popup, {
514
+ render: /* @__PURE__ */ e($, {}),
514
515
  "data-block": !0,
515
516
  finalFocus: !1,
516
- children: r.map((l) => /* @__PURE__ */ e(g.Item, {
517
- title: l,
518
- render: /* @__PURE__ */ e($, {}),
517
+ children: n.map((c) => /* @__PURE__ */ e(C.Item, {
518
+ title: c,
519
+ render: /* @__PURE__ */ e(q, {}),
519
520
  onClick: () => {
520
- o.chain().focus().setFontFamily(l).run(), c(l);
521
+ o.chain().focus().setFontFamily(c).run(), l(c);
521
522
  },
522
- children: l
523
- }, l))
523
+ children: c
524
+ }, c))
524
525
  })
525
526
  }) })] });
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", {
527
+ }, kt = "_button_583n5_1", _t = { button: kt }, ce = d.forwardRef(function({ children: t, variant: i, color: r, icon: n, ...s }, l) {
528
+ return /* @__PURE__ */ g("button", {
528
529
  ref: l,
529
- className: Ct.button,
530
+ className: _t.button,
530
531
  "data-variant": i,
531
532
  "data-color": r,
532
- ...c,
533
+ ...s,
533
534
  children: [n, t]
534
535
  });
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,
536
+ }), At = "_dialog_1k05x_1", wt = "_backdrop_1k05x_27", It = "_content_1k05x_46", yt = "_footer_1k05x_52", Tt = "_close_1k05x_59", x = {
537
+ dialog: At,
538
+ backdrop: wt,
539
+ content: It,
540
+ footer: yt,
540
541
  close: Tt
541
542
  };
542
543
  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, {
544
+ const s = d.useContext(M), l = d.useCallback((c) => {
545
+ s?.editor.setEditable(!c, !1), r?.(c);
546
+ }, [s, r]);
547
+ return /* @__PURE__ */ g(I.Root, {
547
548
  modal: !0,
548
549
  onOpenChange: l,
549
550
  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,
551
+ onClick: (c) => c.stopPropagation(),
552
+ children: /* @__PURE__ */ e(I.Trigger, { render: o })
553
+ }), /* @__PURE__ */ g(I.Portal, { children: [/* @__PURE__ */ e(I.Backdrop, { className: x.backdrop }), /* @__PURE__ */ g(I.Popup, {
554
+ className: x.dialog,
554
555
  style: i ? { maxWidth: i } : void 0,
555
556
  children: [
556
- /* @__PURE__ */ e(w.Close, {
557
- className: y.close,
557
+ /* @__PURE__ */ e(I.Close, {
558
+ className: x.close,
558
559
  "aria-label": "Close",
559
- children: /* @__PURE__ */ e(me, {
560
+ children: /* @__PURE__ */ e(be, {
560
561
  width: 10,
561
562
  height: 10
562
563
  })
563
564
  }),
564
565
  /* @__PURE__ */ e("div", {
565
- className: y.content,
566
+ className: x.content,
566
567
  children: t
567
568
  }),
568
569
  n && /* @__PURE__ */ e("footer", {
569
- className: y.footer,
570
+ className: x.footer,
570
571
  children: n
571
572
  })
572
573
  ]
573
574
  })] })]
574
575
  });
575
576
  }
576
- function x({ children: o, variant: t, color: i, icon: r, ...n }) {
577
- return /* @__PURE__ */ e(w.Close, {
577
+ function H({ children: o, variant: t, color: i, icon: r, ...n }) {
578
+ return /* @__PURE__ */ e(I.Close, {
578
579
  render: /* @__PURE__ */ e(ce, {
579
580
  variant: t,
580
581
  color: i,
@@ -584,49 +585,49 @@ function x({ children: o, variant: t, color: i, icon: r, ...n }) {
584
585
  children: o
585
586
  });
586
587
  }
587
- var yt = "_group_56lao_1", St = "_label_56lao_8", xt = "_input_56lao_14", z = {
588
- group: yt,
589
- label: St,
590
- input: xt
588
+ var St = "_group_56lao_1", xt = "_label_56lao_8", Ft = "_input_56lao_14", B = {
589
+ group: St,
590
+ label: xt,
591
+ input: Ft
591
592
  };
592
593
  function E({ label: o, id: t, ...i }) {
593
- return /* @__PURE__ */ f("div", {
594
- className: z.group,
594
+ return /* @__PURE__ */ g("div", {
595
+ className: B.group,
595
596
  children: [o && /* @__PURE__ */ e("label", {
596
- className: z.label,
597
+ className: B.label,
597
598
  htmlFor: t,
598
599
  children: o
599
600
  }), /* @__PURE__ */ e("input", {
600
601
  id: t,
601
- className: z.input,
602
+ className: B.input,
602
603
  ...i
603
604
  })]
604
605
  });
605
606
  }
606
607
  var Ht = () => {
607
- const { editor: o } = h(), t = v({
608
+ const { editor: o } = f(), t = p({
608
609
  editor: o,
609
- selector: (s) => ({
610
- isImage: s.editor?.isActive("image"),
611
- imageAttrs: s.editor?.getAttributes("image")
610
+ selector: (c) => ({
611
+ isImage: c.editor?.isActive("image"),
612
+ imageAttrs: c.editor?.getAttributes("image")
612
613
  })
613
- }), [i, r] = u.useState(t.imageAttrs.src || ""), [n, c] = u.useState(t.imageAttrs.alt || ""), l = () => {
614
+ }), [i, r] = d.useState(t.imageAttrs.src || ""), [n, s] = d.useState(t.imageAttrs.alt || ""), l = () => {
614
615
  o.chain().focus().setImage({
615
616
  src: i,
616
617
  alt: n
617
618
  }).run();
618
619
  };
619
- return /* @__PURE__ */ f(W, {
620
- Trigger: /* @__PURE__ */ e(d, {
620
+ return /* @__PURE__ */ g(W, {
621
+ Trigger: /* @__PURE__ */ e(u, {
621
622
  title: "Image",
622
623
  "data-active": t.isImage,
623
624
  children: /* @__PURE__ */ e(pe, {})
624
625
  }),
625
626
  maxWidth: "400px",
626
- footer: /* @__PURE__ */ f(N, { children: [/* @__PURE__ */ e(x, {
627
+ footer: /* @__PURE__ */ g(N, { children: [/* @__PURE__ */ e(H, {
627
628
  variant: "secondary",
628
629
  children: "Cancel"
629
- }), /* @__PURE__ */ e(x, {
630
+ }), /* @__PURE__ */ e(H, {
630
631
  onClick: l,
631
632
  disabled: !i,
632
633
  children: "Save"
@@ -635,23 +636,23 @@ var Ht = () => {
635
636
  label: "Image URL",
636
637
  type: "url",
637
638
  value: i,
638
- onChange: (s) => r(s.target.value),
639
+ onChange: (c) => r(c.target.value),
639
640
  required: !0
640
641
  }), /* @__PURE__ */ e(E, {
641
642
  label: "Alt Text",
642
643
  type: "text",
643
644
  value: n,
644
- onChange: (s) => c(s.target.value)
645
+ onChange: (c) => s(c.target.value)
645
646
  })]
646
647
  });
647
648
  }, Lt = () => {
648
- const { editor: o } = h(), t = v({
649
+ const { editor: o } = f(), t = p({
649
650
  editor: o,
650
651
  selector: (a) => ({
651
652
  isLink: a.editor?.isActive("link"),
652
653
  linkAttrs: a.editor?.getAttributes("link")
653
654
  })
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
+ }), [i, r] = d.useState(t.linkAttrs.href || ""), [n, s] = d.useState(t.linkAttrs.alt || ""), l = (a) => !a || a.startsWith("http://") || a.startsWith("https://") ? a : `https://${a}`, c = () => {
655
656
  const a = l(i);
656
657
  o.chain().focus().insertContent({
657
658
  type: "text",
@@ -661,40 +662,40 @@ var Ht = () => {
661
662
  attrs: { href: a }
662
663
  }]
663
664
  }).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);
665
+ }, h = () => {
666
+ const a = o.getAttributes("link"), { from: m, to: A, $from: S } = o.state.selection;
667
+ let b;
668
+ if (m !== A) b = o.state.doc.textBetween(m, A);
668
669
  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();
670
+ const y = S.parent.textContent, T = S.parentOffset;
671
+ let w = T, k = T;
672
+ for (; w > 0 && !/\s/.test(y[w - 1]); ) w--;
673
+ for (; k < y.length && !/\s/.test(y[k]); ) k++;
674
+ if (b = y.slice(w, k), b) {
675
+ const _ = S.start();
675
676
  o.commands.setTextSelection({
676
- from: L + b,
677
- to: L + k
677
+ from: _ + w,
678
+ to: _ + k
678
679
  });
679
680
  }
680
681
  }
681
- r(a.href || ""), c(I || a.alt || "");
682
+ r(a.href || ""), s(b || a.alt || "");
682
683
  };
683
- return /* @__PURE__ */ f(W, {
684
- Trigger: /* @__PURE__ */ e(d, {
684
+ return /* @__PURE__ */ g(W, {
685
+ Trigger: /* @__PURE__ */ e(u, {
685
686
  title: "Link",
686
687
  "data-active": t.isLink,
687
- children: /* @__PURE__ */ e(ve, {})
688
+ children: /* @__PURE__ */ e(ge, {})
688
689
  }),
689
690
  maxWidth: "400px",
690
- onOpenChange: (a) => a && C(),
691
- footer: /* @__PURE__ */ f(N, { children: [t.isLink && /* @__PURE__ */ e(x, {
691
+ onOpenChange: (a) => a && h(),
692
+ footer: /* @__PURE__ */ g(N, { children: [t.isLink && /* @__PURE__ */ e(H, {
692
693
  color: "error",
693
694
  variant: "secondary",
694
695
  onClick: () => o.chain().focus().unsetLink().run(),
695
696
  children: "Remove"
696
- }), /* @__PURE__ */ e(x, {
697
- onClick: s,
697
+ }), /* @__PURE__ */ e(H, {
698
+ onClick: c,
698
699
  disabled: !i,
699
700
  children: "Save"
700
701
  })] }),
@@ -708,16 +709,16 @@ var Ht = () => {
708
709
  label: "Text to display",
709
710
  type: "text",
710
711
  value: n,
711
- onChange: (a) => c(a.target.value)
712
+ onChange: (a) => s(a.target.value)
712
713
  })]
713
714
  });
714
- }, Rt = "_label_1kiov_1", Ft = "_root_1kiov_11", Et = "_thumb_1kiov_44", P = {
715
+ }, Rt = "_label_1kiov_1", Et = "_root_1kiov_11", Nt = "_thumb_1kiov_44", P = {
715
716
  label: Rt,
716
- root: Ft,
717
- thumb: Et
717
+ root: Et,
718
+ thumb: Nt
718
719
  };
719
- function Nt({ checked: o, onCheckedChange: t, label: i }) {
720
- return /* @__PURE__ */ f("label", {
720
+ function zt({ checked: o, onCheckedChange: t, label: i }) {
721
+ return /* @__PURE__ */ g("label", {
721
722
  className: P.label,
722
723
  children: [/* @__PURE__ */ e("span", { children: i }), /* @__PURE__ */ e(ne.Root, {
723
724
  className: P.root,
@@ -728,20 +729,20 @@ function Nt({ checked: o, onCheckedChange: t, label: i }) {
728
729
  });
729
730
  }
730
731
  var Dt = () => {
731
- const { editor: o } = h(), t = v({
732
+ const { editor: o } = f(), t = p({
732
733
  editor: o,
733
734
  selector: (a) => ({
734
735
  isTable: a.editor.isActive("table"),
735
736
  tableAttrs: a.editor.getAttributes("table")
736
737
  })
737
- }), [i, r] = O(!1), n = Se(null), c = B((a) => {
738
+ }), [i, r] = O(!1), n = xe(null), s = D((a) => {
738
739
  n.current && clearTimeout(n.current), n.current = setTimeout(a, 100);
739
740
  }, []);
740
- u.useEffect(() => () => {
741
+ d.useEffect(() => () => {
741
742
  n.current && clearTimeout(n.current);
742
743
  }, []);
743
- const l = B(() => {
744
- c(() => o.chain().focus().insertTable({
744
+ const l = D(() => {
745
+ s(() => o.chain().focus().insertTable({
745
746
  rows: 2,
746
747
  cols: 4,
747
748
  withHeaderRow: i
@@ -749,99 +750,99 @@ var Dt = () => {
749
750
  }, [
750
751
  o,
751
752
  i,
752
- c
753
- ]), s = B(() => {
754
- r((a) => !a), c(() => o.chain().focus().toggleHeaderRow().run());
755
- }, [o, c]), C = [
753
+ s
754
+ ]), c = D(() => {
755
+ r((a) => !a), s(() => o.chain().focus().toggleHeaderRow().run());
756
+ }, [o, s]), h = [
756
757
  {
757
758
  text: "Column left",
758
- icon: /* @__PURE__ */ e(R, {}),
759
+ icon: /* @__PURE__ */ e(L, {}),
759
760
  event: () => o.chain().focus().addColumnBefore().run()
760
761
  },
761
762
  {
762
763
  text: "Row above",
763
- icon: /* @__PURE__ */ e(R, {}),
764
+ icon: /* @__PURE__ */ e(L, {}),
764
765
  event: () => o.chain().focus().addRowBefore().run()
765
766
  },
766
767
  {
767
768
  text: "Column right",
768
- icon: /* @__PURE__ */ e(R, {}),
769
+ icon: /* @__PURE__ */ e(L, {}),
769
770
  event: () => o.chain().focus().addColumnAfter().run()
770
771
  },
771
772
  {
772
773
  text: "Row below",
773
- icon: /* @__PURE__ */ e(R, {}),
774
+ icon: /* @__PURE__ */ e(L, {}),
774
775
  event: () => o.chain().focus().addRowAfter().run()
775
776
  },
776
777
  {
777
778
  text: "Delete Column",
778
- icon: /* @__PURE__ */ e(D, {}),
779
+ icon: /* @__PURE__ */ e(z, {}),
779
780
  event: () => o.chain().focus().deleteColumn().run()
780
781
  },
781
782
  {
782
783
  text: "Delete Row",
783
- icon: /* @__PURE__ */ e(D, {}),
784
+ icon: /* @__PURE__ */ e(z, {}),
784
785
  event: () => o.chain().focus().deleteRow().run()
785
786
  }
786
787
  ];
787
- return t.isTable ? /* @__PURE__ */ f(W, {
788
- Trigger: /* @__PURE__ */ e(d, {
788
+ return t.isTable ? /* @__PURE__ */ g(W, {
789
+ Trigger: /* @__PURE__ */ e(u, {
789
790
  title: "Table",
790
791
  "data-active": t.isTable,
791
792
  children: /* @__PURE__ */ e(K, {})
792
793
  }),
793
794
  maxWidth: "320px",
794
- footer: /* @__PURE__ */ e(x, {
795
+ footer: /* @__PURE__ */ e(H, {
795
796
  variant: "secondary",
796
797
  color: "error",
797
- icon: /* @__PURE__ */ e(D, {}),
798
+ icon: /* @__PURE__ */ e(z, {}),
798
799
  onClick: () => o.chain().focus().deleteTable().run(),
799
800
  children: "Delete Table"
800
801
  }),
801
- children: [/* @__PURE__ */ e(Nt, {
802
+ children: [/* @__PURE__ */ e(zt, {
802
803
  checked: i,
803
- onCheckedChange: s,
804
+ onCheckedChange: c,
804
805
  label: "Title Row"
805
806
  }), /* @__PURE__ */ e("div", {
806
- className: S.wuContentEditorTable,
807
- children: C.map(({ text: a, icon: m, event: A }) => /* @__PURE__ */ e(ce, {
807
+ className: F.wuContentEditorTable,
808
+ children: h.map(({ text: a, icon: m, event: A }) => /* @__PURE__ */ e(ce, {
808
809
  onClick: A,
809
810
  variant: "secondary",
810
811
  icon: m,
811
812
  children: a
812
813
  }, a))
813
814
  })]
814
- }) : /* @__PURE__ */ e(d, {
815
+ }) : /* @__PURE__ */ e(u, {
815
816
  title: "Table",
816
817
  onClick: l,
817
818
  children: /* @__PURE__ */ e(K, {})
818
819
  });
819
820
  }, 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, {}),
821
+ block: /* @__PURE__ */ e(Xe, {}),
822
+ fontFamily: /* @__PURE__ */ e(Ct, {}),
823
+ fontSize: /* @__PURE__ */ e(bt, {}),
824
+ bold: /* @__PURE__ */ e(Ye, {}),
825
+ italic: /* @__PURE__ */ e(Ve, {}),
826
+ underline: /* @__PURE__ */ e(nt, {}),
827
+ strike: /* @__PURE__ */ e(tt, {}),
828
+ color: /* @__PURE__ */ e(rt, {}),
829
+ bgColor: /* @__PURE__ */ e(lt, {}),
830
+ list: /* @__PURE__ */ e(et, {}),
831
+ alignment: /* @__PURE__ */ e(ct, {}),
831
832
  image: /* @__PURE__ */ e(Ht, {}),
832
833
  link: /* @__PURE__ */ e(Lt, {}),
833
834
  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, {}),
835
+ blockquote: /* @__PURE__ */ e(at, {}),
836
+ superscript: /* @__PURE__ */ e(it, {}),
837
+ subscript: /* @__PURE__ */ e(ot, {}),
838
+ codeline: /* @__PURE__ */ e(Ge, {}),
839
+ clear: /* @__PURE__ */ e(Ze, {}),
839
840
  "|": /* @__PURE__ */ e("div", { style: {
840
841
  height: 16,
841
842
  width: 1,
842
843
  background: "var(--we-border)"
843
844
  } }),
844
- html: /* @__PURE__ */ e(at, {})
845
+ html: /* @__PURE__ */ e(st, {})
845
846
  }, Bt = [
846
847
  "block",
847
848
  "fontFamily",
@@ -870,83 +871,91 @@ var Dt = () => {
870
871
  "|",
871
872
  "html",
872
873
  "clear"
873
- ], zt = (o) => {
874
- const { editor: t, customFonts: i, children: r, items: n = Bt, isHtml: c, setIsHtml: l, htmlSourceEnabled: s, ...C } = o;
874
+ ], Pt = (o) => {
875
+ const { editor: t, customFonts: i, defaultValues: r, children: n, items: s = Bt, isHtml: l, setIsHtml: c, htmlSourceEnabled: h, ...a } = o;
875
876
  return /* @__PURE__ */ e("div", {
876
- ...C,
877
- children: /* @__PURE__ */ f(Ue, {
877
+ ...a,
878
+ children: /* @__PURE__ */ g(We, {
878
879
  editor: t,
879
880
  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", {
881
+ defaultValues: r,
882
+ isHtml: l,
883
+ setIsHtml: c,
884
+ htmlSourceEnabled: h,
885
+ children: [s.map((m, A) => /* @__PURE__ */ e(N, { children: l && m !== "html" ? /* @__PURE__ */ e("span", {
884
886
  style: {
885
887
  pointerEvents: "none",
886
888
  opacity: 0.4
887
889
  },
888
- children: ae[a]
889
- }) : ae[a] }, a + m)), r]
890
+ children: ae[m]
891
+ }) : ae[m] }, m + A)), n]
890
892
  })
891
893
  });
892
894
  };
893
- function Pt(...o) {
895
+ function Ot(...o) {
894
896
  return o.filter(Boolean).join(" ");
895
897
  }
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(() => {
898
+ function to({ defaultValue: o, onUpdate: t, className: i, toolbarPosition: r = "top", customToolbarChildren: n, toolbarItems: s, hideToolbar: l, readonly: c, autoFocus: h, customFonts: a, htmlSource: m, isHtml: A, setIsHtml: S, defaultValues: b, ...y }) {
899
+ const [T, w] = d.useState((A ?? !1) && !!m);
900
+ d.useEffect(() => {
899
901
  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
902
  }, []);
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()));
903
+ const k = d.useRef(o || ""), _ = Se({
904
+ editable: !c,
905
+ autofocus: h ? "end" : !1,
906
+ extensions: Ue,
907
+ content: R(o || ""),
908
+ onUpdate: ({ editor: v }) => {
909
+ t && t(R(v.getHTML()));
908
910
  }
909
- }), L = (p) => {
910
- p ? b.current = k?.getHTML() ?? "" : k?.commands.setContent(F(b.current)), t && t(F(b.current)), H(p), T?.(p);
911
+ });
912
+ d.useEffect(() => {
913
+ if (!_ || !b) return;
914
+ const v = _.chain();
915
+ b.fontFamily && v.setFontFamily(b.fontFamily), b.fontSize && v.setFontSize(`${b.fontSize}px`), b.color && v.setColor(b.color), b.bgColor && v.setBackgroundColor(b.bgColor), v.run();
916
+ }, [_]);
917
+ const de = (v) => {
918
+ v ? k.current = _?.getHTML() ?? "" : _?.commands.setContent(R(k.current)), t && t(R(k.current)), w(v), S?.(v);
911
919
  };
912
- return /* @__PURE__ */ f("div", {
913
- className: Pt(S.wuContentEditorRoot, i),
920
+ return /* @__PURE__ */ g("div", {
921
+ className: Ot(F.wuContentEditorRoot, i),
914
922
  "data-position": r,
915
923
  "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");
924
+ onClick: (v) => {
925
+ if ((v.ctrlKey || v.metaKey) && v.target instanceof HTMLElement) {
926
+ const j = v.target.closest("a");
919
927
  if (j?.href) {
920
928
  window.open(j.href, "_blank", "noopener,noreferrer");
921
929
  return;
922
930
  }
923
931
  }
924
- _ || k?.chain().focus().run();
932
+ T || _?.chain().focus().run();
925
933
  },
926
- ...I,
927
- children: [!l && /* @__PURE__ */ e(zt, {
928
- editor: k,
934
+ ...y,
935
+ children: [!l && /* @__PURE__ */ e(Pt, {
936
+ editor: _,
929
937
  customFonts: a,
930
- className: S.wuContentEditorToolbar,
931
- items: c,
932
- isHtml: _,
933
- setIsHtml: L,
938
+ defaultValues: b,
939
+ className: F.wuContentEditorToolbar,
940
+ items: s,
941
+ isHtml: T,
942
+ setIsHtml: de,
934
943
  htmlSourceEnabled: !!m,
935
944
  "data-slot": "wu-content-editor-toolbar",
936
945
  children: n
937
- }), _ && m ? /* @__PURE__ */ e(m, {
938
- defaultValue: b.current,
939
- onUpdate: (p) => {
940
- b.current = p ?? "", t && t(p ?? "");
946
+ }), T && m ? /* @__PURE__ */ e(m, {
947
+ defaultValue: k.current,
948
+ onUpdate: (v) => {
949
+ k.current = v ?? "", t && t(v ?? "");
941
950
  },
942
- readonly: s
951
+ readonly: c
943
952
  }) : /* @__PURE__ */ e(Te, {
944
- editor: k,
945
- className: S.wuContentEditor,
953
+ editor: _,
954
+ className: F.wuContentEditor,
946
955
  "data-slot": "wu-content-editor"
947
956
  })]
948
957
  });
949
958
  }
950
959
  export {
951
- eo as WuContentEditor
960
+ to as WuContentEditor
952
961
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npm-questionpro/wick-ui-editor",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Wick Editor is a powerful and intuitive content editing component built with React. It provides a rich set of features for creating and managing content, making it ideal for applications that require dynamic and interactive content creation.",
5
5
  "keywords": [
6
6
  "react",
@@ -97,9 +97,9 @@
97
97
  "vite-bundle-analyzer": "^0.22.3",
98
98
  "vite-plugin-dts": "^4.5.4",
99
99
  "vitest": "^4.1.8",
100
- "@npm-questionpro/wick-ui-eslint-config": "1.0.0",
101
- "@npm-questionpro/wick-ui-lib": "2.2.0",
102
- "@wick-ui/tsconfig": "1.0.0"
100
+ "@npm-questionpro/wick-ui-lib": "2.4.0",
101
+ "@wick-ui/tsconfig": "1.0.0",
102
+ "@npm-questionpro/wick-ui-eslint-config": "1.0.0"
103
103
  },
104
104
  "scripts": {
105
105
  "build": "tsc --noEmit && vite build && tsc -p tsconfig.types.json",