eddyter 1.4.18 → 1.4.19

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.
Files changed (60) hide show
  1. package/dist/AIChatPlugin-BUWq8ixX.js +1042 -0
  2. package/dist/{CombinedAutocompletGrammarPlugin-BXOz6IRb.js → CombinedAutocompletGrammarPlugin-Dq25w8tq.js} +388 -337
  3. package/dist/{CommentBubblePlugin-kiMehQkL.js → CommentBubblePlugin-B77d3Qq6.js} +4 -4
  4. package/dist/CommentPlugin-BJQyKmrN.js +212 -0
  5. package/dist/{NotePanelPlugin-FirMseLu.js → NotePanelPlugin-BqOdcg07.js} +3 -3
  6. package/dist/{TextEnhancePlugin-oXbL_F1i.js → TextEnhancePlugin-BnmdRgUu.js} +2 -2
  7. package/dist/assets/style.css +1 -1
  8. package/dist/components/AnimatedPlaceholderText.d.ts +2 -0
  9. package/dist/components/DividerPicker/DividerPicker.d.ts +17 -0
  10. package/dist/components/EditorialDivider/EditorialDividerView.d.ts +23 -0
  11. package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +1 -1
  12. package/dist/components/LockedFeature/LockedFeature.d.ts +4 -0
  13. package/dist/components/Toolbar/styles.d.ts +19 -1
  14. package/dist/components/UnifiedColorPicker/UnifiedColorPicker.d.ts +1 -0
  15. package/dist/components/ui/button.d.ts +1 -1
  16. package/dist/components/ui/separator.d.ts +4 -1
  17. package/dist/constants.d.ts +12 -1
  18. package/dist/editorConfig.d.ts +7 -0
  19. package/dist/{generateDocxThumbnail-RE7yNAXP.js → generateDocxThumbnail-DBMxjZ83.js} +1 -1
  20. package/dist/{generatePdfThumbnail-CnldK2yE.js → generatePdfThumbnail-Cv2-ZCzh.js} +4 -4
  21. package/dist/{generateXlsxThumbnail-BpBB4ePK.js → generateXlsxThumbnail-UHmNc7Fa.js} +1 -1
  22. package/dist/hooks/useEditorToolbar.d.ts +1 -1
  23. package/dist/{index-CL0adQ5R.js → index-BaWQzoL2.js} +11 -11
  24. package/dist/{index-CXyZgoBl.js → index-Bex3G_eE.js} +18704 -15777
  25. package/dist/index-C_mjLQUF.js +796 -0
  26. package/dist/{index-C8ZUqYRj.js → index-ChSepytp.js} +26 -26
  27. package/dist/index-Cl_A9eof.js +1508 -0
  28. package/dist/{index-B4W_mfNI.js → index-DcHU8PlQ.js} +120 -123
  29. package/dist/{index-CKRp6axU.js → index-q_TW8dU1.js} +19 -19
  30. package/dist/index.js +7 -7
  31. package/dist/nodes/AsterismNode.d.ts +22 -0
  32. package/dist/nodes/ButtonNode.d.ts +37 -0
  33. package/dist/nodes/ColumnNode.d.ts +44 -0
  34. package/dist/nodes/ColumnsNode.d.ts +45 -0
  35. package/dist/nodes/EditorialFieldNode.d.ts +32 -0
  36. package/dist/nodes/FaqNode.d.ts +28 -0
  37. package/dist/nodes/ImagePlaceholderNode.d.ts +15 -0
  38. package/dist/nodes/LabeledRuleNode.d.ts +33 -0
  39. package/dist/nodes/OrnamentDividerNode.d.ts +22 -0
  40. package/dist/nodes/PullQuoteRulesNode.d.ts +32 -0
  41. package/dist/nodes/SectionNumberHeadingNode.d.ts +42 -0
  42. package/dist/plugins/BlockLayoutPlugin.d.ts +29 -0
  43. package/dist/plugins/ColumnAddButtonPlugin.d.ts +12 -0
  44. package/dist/plugins/CommentPlugin.commands.d.ts +1 -0
  45. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +12 -2
  46. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +2 -1
  47. package/dist/plugins/CustomHorizontalRulePlugin/styles.d.ts +38 -0
  48. package/dist/plugins/EditorialFloatingToolbarPlugin.d.ts +8 -0
  49. package/dist/plugins/EditorialTypographyPlugin.d.ts +18 -0
  50. package/dist/plugins/PatternsPlugin.d.ts +12 -0
  51. package/dist/{sparkles-CTAYmQOE.js → sparkles-C-XoMho5.js} +1 -1
  52. package/dist/types.d.ts +11 -0
  53. package/dist/ui/Icons.d.ts +34 -9
  54. package/dist/{useVoiceToText-U0yKgS5Q.js → useVoiceToText-BzaLSbRi.js} +17 -17
  55. package/package.json +1 -1
  56. package/dist/AIChatPlugin-DsUPycjT.js +0 -872
  57. package/dist/CommentPlugin-DIuM-Jao.js +0 -154
  58. package/dist/index-DZAvLKar.js +0 -1431
  59. package/dist/index-F2-F96Nx.js +0 -720
  60. package/dist/square-CupR-YWR.js +0 -7
@@ -0,0 +1,796 @@
1
+ import { jsx as e, jsxs as n, Fragment as j } from "react/jsx-runtime";
2
+ import { useLexicalComposerContext as se } from "@lexical/react/LexicalComposerContext";
3
+ import { COMMAND_PRIORITY_LOW as S, $getSelection as _, $isRangeSelection as O, $insertNodes as de, $getRoot as L } from "lexical";
4
+ import { c as F, D as U, a as K, b as H, d as J, e as W, L as le, I as ue, f as B, g as z, B as T, P as me, F as fe, C as ge, h as pe, i as he, E as xe, j as ye, N as be, k as Ne, R as we, S as ve, l as Ie, u as ke, A as Ce, m as Te, n as Ee, t as a, o as Se, p as R, q as Ae, $ as Pe, r as Me, s as G, v as De } from "./index-Bex3G_eE.js";
5
+ import Q, { useState as v, forwardRef as _e, useImperativeHandle as Oe, useRef as A, useEffect as P } from "react";
6
+ import { S as $ } from "./sparkles-C-XoMho5.js";
7
+ const q = F("Globe", [
8
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
9
+ ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
10
+ ["path", { d: "M2 12h20", key: "9i4pu4" }]
11
+ ]);
12
+ const Le = F("Scissors", [
13
+ ["circle", { cx: "6", cy: "6", r: "3", key: "1lh9wr" }],
14
+ ["path", { d: "M8.12 8.12 12 12", key: "1alkpv" }],
15
+ ["path", { d: "M20 4 8.12 15.88", key: "xgtan2" }],
16
+ ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
17
+ ["path", { d: "M14.8 14.8 20 20", key: "ptml3r" }]
18
+ ]);
19
+ const V = F("Volume2", [
20
+ ["polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5", key: "16drj5" }],
21
+ ["path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07", key: "ltjumu" }],
22
+ ["path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14", key: "1kegas" }]
23
+ ]), Re = ({
24
+ open: c,
25
+ onOpenChange: y,
26
+ onGenerate: N,
27
+ onInsertImage: b,
28
+ isGenerating: l,
29
+ initialText: g
30
+ }) => {
31
+ const [m, p] = v("");
32
+ Q.useEffect(() => {
33
+ c && g && p(g);
34
+ }, [c, g]), Q.useEffect(() => {
35
+ c || p("");
36
+ }, [c]);
37
+ const I = async () => {
38
+ if (!m.trim()) return;
39
+ const i = m.trim();
40
+ p(""), y(!1);
41
+ try {
42
+ await N(i);
43
+ } catch (f) {
44
+ console.error("Error generating image:", f);
45
+ }
46
+ }, k = () => {
47
+ l || (p(""), y(!1));
48
+ };
49
+ return /* @__PURE__ */ e(U, { open: c, onOpenChange: k, children: /* @__PURE__ */ n(K, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[90vh] cteditor-overflow-y-auto", children: [
50
+ /* @__PURE__ */ n(H, { children: [
51
+ /* @__PURE__ */ n(J, { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xl", children: [
52
+ /* @__PURE__ */ e($, {}),
53
+ "Generate Image with AI"
54
+ ] }),
55
+ /* @__PURE__ */ e(W, { className: "cteditor-text-base cteditor-pt-2", children: "Describe the image you want to create, and AI will generate it for you." })
56
+ ] }),
57
+ /* @__PURE__ */ n("div", { className: "cteditor-space-y-4", children: [
58
+ /* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-gap-2 cteditor-flex-col", children: [
59
+ /* @__PURE__ */ e(le, { htmlFor: "image-prompt", children: "What do you want to see?" }),
60
+ /* @__PURE__ */ e(
61
+ ue,
62
+ {
63
+ id: "image-prompt",
64
+ placeholder: "Mountains and rivers with birds flying in the sky",
65
+ value: m,
66
+ onChange: (i) => p(i.target.value),
67
+ disabled: l,
68
+ className: "h-12",
69
+ onKeyDown: (i) => {
70
+ i.key === "Enter" && !l && m.trim() && I();
71
+ }
72
+ }
73
+ ),
74
+ /* @__PURE__ */ n("p", { className: "cteditor-text-muted-foreground cteditor-flex cteditor-gap-1 cteditor-text-xs ", children: [
75
+ /* @__PURE__ */ e(B, { className: "cteditor-h-4 cteditor-w-4" }),
76
+ " Just describe what you want - be specific and detailed for best results"
77
+ ] })
78
+ ] }),
79
+ l && /* @__PURE__ */ e("div", { className: "p-4 rounded-lg bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
80
+ /* @__PURE__ */ e("div", { className: "h-5 w-5 animate-spin rounded-full border-2 border-blue-600 border-t-transparent" }),
81
+ /* @__PURE__ */ n("div", { children: [
82
+ /* @__PURE__ */ e("p", { className: "text-xs font-medium text-blue-800 dark:text-blue-200", children: "Creating your image..." }),
83
+ /* @__PURE__ */ e("p", { className: "text-xs text-blue-600 dark:text-blue-300 mt-1", children: "This may take 10-30 seconds. Please wait." })
84
+ ] })
85
+ ] }) }),
86
+ !l && /* @__PURE__ */ e("div", { className: "cteditor-p-3 cteditor-bg-muted/50 cteditor-rounded-lg", children: /* @__PURE__ */ n("div", { className: "flex items-start cteditor-flex-col", children: [
87
+ /* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1 cteditor-mb-2", children: [
88
+ /* @__PURE__ */ e(B, { className: "cteditor-h-4 cteditor-w-4" }),
89
+ /* @__PURE__ */ e("h3", { className: "cteditor-text-sm cteditor-font-medium", children: "Good examples:" })
90
+ ] }),
91
+ /* @__PURE__ */ n("div", { className: "text-xs text-gray-600 dark:text-gray-400", children: [
92
+ /* @__PURE__ */ n("ul", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-space-y-1", children: [
93
+ /* @__PURE__ */ e("li", { children: '. Mountains and rivers at sunset"' }),
94
+ /* @__PURE__ */ e("li", { children: '. A cat sitting on a windowsill"' }),
95
+ /* @__PURE__ */ e("li", { children: '. Modern city skyline at night"' })
96
+ ] }),
97
+ /* @__PURE__ */ n("p", { className: "cteditor-mt-2 cteditor-text-xs cteditor-flex cteditor-gap-1 cteditor-text-yellow-500", children: [
98
+ /* @__PURE__ */ e("span", { children: "⚠️" }),
99
+ `Don't include "generate" or "create" - just describe!`
100
+ ] })
101
+ ] })
102
+ ] }) })
103
+ ] }),
104
+ /* @__PURE__ */ n(z, { className: "gap-2", children: [
105
+ /* @__PURE__ */ e(
106
+ T,
107
+ {
108
+ variant: "outline",
109
+ onClick: k,
110
+ disabled: l,
111
+ children: "Cancel"
112
+ }
113
+ ),
114
+ /* @__PURE__ */ e(
115
+ T,
116
+ {
117
+ onClick: I,
118
+ disabled: l || !m.trim(),
119
+ children: l ? /* @__PURE__ */ n(j, { children: [
120
+ /* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent mr-2" }),
121
+ "Generating..."
122
+ ] }) : /* @__PURE__ */ n(j, { children: [
123
+ /* @__PURE__ */ e($, {}),
124
+ "Generate & Insert"
125
+ ] })
126
+ }
127
+ )
128
+ ] })
129
+ ] }) });
130
+ }, Z = _e(({ onGenerate: c, onInsertImage: y }, N) => {
131
+ const [b, l] = v(!1), [g, m] = v(!1), [p, I] = v(void 0);
132
+ return Oe(N, () => ({
133
+ openDialog: (f) => {
134
+ I(f), l(!0);
135
+ },
136
+ setGenerating: (f) => m(f)
137
+ })), /* @__PURE__ */ e(
138
+ Re,
139
+ {
140
+ open: b,
141
+ onOpenChange: l,
142
+ onGenerate: async (f) => {
143
+ m(!0);
144
+ try {
145
+ return await c(f);
146
+ } catch (h) {
147
+ throw console.error("Error generating image:", h), h;
148
+ } finally {
149
+ m(!1);
150
+ }
151
+ },
152
+ onInsertImage: (f, h) => {
153
+ y(f, h), l(!1);
154
+ },
155
+ isGenerating: g,
156
+ initialText: p
157
+ }
158
+ );
159
+ });
160
+ Z.displayName = "ImageGenerationManager";
161
+ const Y = [
162
+ { code: "en", name: "English", flag: "🇺🇸" },
163
+ { code: "es", name: "Spanish", flag: "🇪🇸" },
164
+ { code: "fr", name: "French", flag: "🇫🇷" },
165
+ { code: "de", name: "German", flag: "🇩🇪" },
166
+ { code: "it", name: "Italian", flag: "🇮🇹" },
167
+ { code: "pt", name: "Portuguese", flag: "🇵🇹" },
168
+ { code: "ru", name: "Russian", flag: "🇷🇺" },
169
+ { code: "ja", name: "Japanese", flag: "🇯🇵" },
170
+ { code: "ko", name: "Korean", flag: "🇰🇷" },
171
+ { code: "zh", name: "Chinese", flag: "🇨🇳" },
172
+ { code: "ar", name: "Arabic", flag: "🇸🇦" },
173
+ { code: "hi", name: "Hindi", flag: "🇮🇳" },
174
+ { code: "bn", name: "Bengali", flag: "🇧🇩" },
175
+ { code: "tr", name: "Turkish", flag: "🇹🇷" },
176
+ { code: "vi", name: "Vietnamese", flag: "🇻🇳" },
177
+ { code: "th", name: "Thai", flag: "🇹🇭" },
178
+ { code: "pl", name: "Polish", flag: "🇵🇱" },
179
+ { code: "nl", name: "Dutch", flag: "🇳🇱" },
180
+ { code: "sv", name: "Swedish", flag: "🇸🇪" }
181
+ ], Ge = ({
182
+ open: c,
183
+ onOpenChange: y,
184
+ onLanguageSelect: N
185
+ }) => {
186
+ const [b, l] = v(""), [g, m] = v(""), p = Y.filter(
187
+ (i) => i.name.toLowerCase().includes(g.toLowerCase())
188
+ ), I = () => {
189
+ if (b) {
190
+ const i = Y.find((f) => f.code === b);
191
+ i && (N(i.name), y(!1), l(""), m(""));
192
+ }
193
+ }, k = () => {
194
+ y(!1), l(""), m("");
195
+ };
196
+ return /* @__PURE__ */ e(U, { open: c, onOpenChange: k, children: /* @__PURE__ */ n(K, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[600px] cteditor-max-w-[calc(100%-2rem)] cteditor-rounded-lg", children: [
197
+ /* @__PURE__ */ n(H, { children: [
198
+ /* @__PURE__ */ n(J, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
199
+ /* @__PURE__ */ e(q, { className: "cteditor-size-5" }),
200
+ "Select Target Language"
201
+ ] }),
202
+ /* @__PURE__ */ e(W, { children: "Choose the language you want to translate your text into. Use English to translate from Hindi, Arabic, or any other language into English." })
203
+ ] }),
204
+ /* @__PURE__ */ n("div", { children: [
205
+ /* @__PURE__ */ e(
206
+ "input",
207
+ {
208
+ type: "text",
209
+ placeholder: "Search languages...",
210
+ value: g,
211
+ onChange: (i) => m(i.target.value),
212
+ className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-mb-4 cteditor-text-sm cteditor-border cteditor-border-input cteditor-rounded-md focus:cteditor-outline-none focus:cteditor-ring-2 focus:cteditor-ring-ring cteditor-bg-background"
213
+ }
214
+ ),
215
+ /* @__PURE__ */ e("div", { className: "cteditor-grid cteditor-grid-cols-2 cteditor-gap-2 cteditor-max-h-[350px] cteditor-overflow-y-auto cteditor-pr-2", children: p.map((i) => /* @__PURE__ */ n(
216
+ "button",
217
+ {
218
+ type: "button",
219
+ onClick: () => l(i.code),
220
+ className: `cteditor-flex cteditor-items-center cteditor-gap-3 cteditor-px-4 cteditor-py-2 cteditor-text-sm cteditor-rounded-lg cteditor-border cteditor-transition-all hover:cteditor-bg-accent ${b === i.code ? "cteditor-bg-primary/10 cteditor-border-primary cteditor-ring-2 cteditor-ring-primary/20" : "cteditor-border-input hover:cteditor-border-primary/50"}`,
221
+ children: [
222
+ /* @__PURE__ */ e("span", { className: "cteditor-text-2xl", children: i.flag }),
223
+ /* @__PURE__ */ e("span", { className: "cteditor-font-medium", children: i.name })
224
+ ]
225
+ },
226
+ i.code
227
+ )) }),
228
+ p.length === 0 && /* @__PURE__ */ n("div", { className: "cteditor-text-center cteditor-py-8 cteditor-text-muted-foreground", children: [
229
+ 'No languages found matching "',
230
+ g,
231
+ '"'
232
+ ] })
233
+ ] }),
234
+ /* @__PURE__ */ n(z, { children: [
235
+ /* @__PURE__ */ e(T, { variant: "outline", onClick: k, children: "Cancel" }),
236
+ /* @__PURE__ */ n(
237
+ T,
238
+ {
239
+ onClick: I,
240
+ disabled: !b,
241
+ className: "!cteditor-gap-1",
242
+ children: [
243
+ /* @__PURE__ */ e(q, { className: "!cteditor-size-4" }),
244
+ "Translate"
245
+ ]
246
+ }
247
+ )
248
+ ] })
249
+ ] }) });
250
+ }, X = [
251
+ {
252
+ id: "professional",
253
+ name: "Professional",
254
+ icon: me,
255
+ tags: "formal business technical",
256
+ description: "Formal, polished, business-appropriate."
257
+ },
258
+ {
259
+ id: "friendly",
260
+ name: "Friendly",
261
+ icon: fe,
262
+ tags: "warm approachable conversational",
263
+ description: "Warm and approachable, still concise."
264
+ },
265
+ {
266
+ id: "casual",
267
+ name: "Casual",
268
+ icon: ge,
269
+ tags: "relaxed conversational easy",
270
+ description: "Relaxed and conversational. Second person."
271
+ },
272
+ {
273
+ id: "formal",
274
+ name: "Formal",
275
+ icon: pe,
276
+ tags: "formal proper polished",
277
+ description: "Highly polished. Measured cadence."
278
+ },
279
+ {
280
+ id: "confident",
281
+ name: "Confident",
282
+ icon: he,
283
+ tags: "assertive bold direct",
284
+ description: "Assertive, self-assured, no hedging."
285
+ },
286
+ {
287
+ id: "empathetic",
288
+ name: "Empathetic",
289
+ icon: xe,
290
+ tags: "understanding kind compassionate",
291
+ description: "Understanding and compassionate."
292
+ },
293
+ {
294
+ id: "enthusiastic",
295
+ name: "Enthusiastic",
296
+ icon: ye,
297
+ tags: "energetic excited upbeat",
298
+ description: "Energetic and excited. Forward-leaning."
299
+ },
300
+ {
301
+ id: "neutral",
302
+ name: "Neutral",
303
+ icon: be,
304
+ tags: "balanced objective even",
305
+ description: "Balanced and objective. No spin."
306
+ },
307
+ {
308
+ id: "persuasive",
309
+ name: "Persuasive",
310
+ icon: Ne,
311
+ tags: "convincing compelling marketing",
312
+ description: "Convincing and compelling. CTA-ready."
313
+ },
314
+ {
315
+ id: "respectful",
316
+ name: "Respectful",
317
+ icon: we,
318
+ tags: "courteous considerate polite",
319
+ description: "Courteous and considerate. Even-handed."
320
+ },
321
+ {
322
+ id: "witty",
323
+ name: "Witty",
324
+ icon: $,
325
+ tags: "clever humorous funny",
326
+ description: "Clever and humorous."
327
+ },
328
+ {
329
+ id: "concise",
330
+ name: "Concise",
331
+ icon: Le,
332
+ tags: "brief short clear",
333
+ description: "Brief and to the point."
334
+ }
335
+ ], je = ({
336
+ open: c,
337
+ onOpenChange: y,
338
+ onToneSelect: N
339
+ }) => {
340
+ const [b, l] = v(""), [g, m] = v(""), p = X.filter(
341
+ (i) => i.name.toLowerCase().includes(g.toLowerCase()) || i.tags.toLowerCase().includes(g.toLowerCase())
342
+ ), I = () => {
343
+ if (b) {
344
+ const i = X.find((f) => f.id === b);
345
+ i && (N(i.name), y(!1), l(""), m(""));
346
+ }
347
+ }, k = () => {
348
+ y(!1), l(""), m("");
349
+ };
350
+ return /* @__PURE__ */ e(U, { open: c, onOpenChange: k, children: /* @__PURE__ */ n(K, { className: "!cteditor-max-w-[680px] cteditor-w-[min(680px,calc(100vw-32px))] cteditor-max-h-[calc(100dvh-32px)] cteditor-flex cteditor-flex-col cteditor-overflow-y-auto", children: [
351
+ /* @__PURE__ */ n(H, { className: "!cteditor-text-left", children: [
352
+ /* @__PURE__ */ n(J, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
353
+ /* @__PURE__ */ e(V, { className: "cteditor-size-5" }),
354
+ "Adjust Tone"
355
+ ] }),
356
+ /* @__PURE__ */ e(W, { children: "Choose the tone style you want to apply to your selected text." })
357
+ ] }),
358
+ /* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-4 cteditor-flex-1", children: [
359
+ /* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-flex-col sm:cteditor-flex-row sm:cteditor-items-center cteditor-justify-between cteditor-gap-3 cteditor-shrink-0", children: [
360
+ /* @__PURE__ */ e("span", { className: "cteditor-font-mono cteditor-text-[10.5px] cteditor-font-medium cteditor-tracking-[0.18em] cteditor-uppercase cteditor-text-foreground/50 cteditor-shrink-0", children: "Tone library" }),
361
+ /* @__PURE__ */ n("div", { className: "cteditor-relative cteditor-flex cteditor-items-center cteditor-w-full sm:cteditor-w-[240px] cteditor-h-[30px] cteditor-rounded-[8px] dark:cteditor-bg-black/30 cteditor-border cteditor-border-foreground/10 dark:focus-within:cteditor-bg-black/40 focus-within:cteditor-bg-black/10 focus-within:cteditor-border-[#b59cff]/45 focus-within:cteditor-ring-[3px] focus-within:cteditor-ring-[#b59cff]/10 cteditor-transition-all", children: [
362
+ /* @__PURE__ */ e(ve, { className: "cteditor-absolute cteditor-left-[10px] cteditor-w-[13px] cteditor-h-[13px] cteditor-text-foreground/40" }),
363
+ /* @__PURE__ */ e(
364
+ "input",
365
+ {
366
+ id: "toneSearch",
367
+ type: "text",
368
+ placeholder: "Filter tones — e.g. warm, technical",
369
+ "aria-label": "Filter tones",
370
+ className: "cteditor-w-full cteditor-h-full cteditor-pl-[30px] cteditor-pr-[30px] cteditor-bg-transparent cteditor-border-none cteditor-outline-none cteditor-text-[12.5px] cteditor-text-foreground placeholder:cteditor-text-foreground/40",
371
+ value: g,
372
+ onChange: (i) => m(i.target.value)
373
+ }
374
+ ),
375
+ /* @__PURE__ */ e("kbd", { className: "cteditor-absolute cteditor-right-[6px] cteditor-pointer-events-none cteditor-inline-flex cteditor-h-[18px] cteditor-min-w-[18px] cteditor-select-none cteditor-items-center cteditor-justify-center cteditor-rounded-[4px] cteditor-border cteditor-border-foreground/10 cteditor-bg-white/5 cteditor-px-[5px] cteditor-font-mono cteditor-text-[10px] cteditor-text-foreground/40", children: "/" })
376
+ ] })
377
+ ] }),
378
+ /* @__PURE__ */ n(
379
+ "div",
380
+ {
381
+ className: "cteditor-grid cteditor-grid-cols-1 sm:cteditor-grid-cols-2 cteditor-gap-3 cteditor-pr-2 cteditor-pb-2",
382
+ role: "radiogroup",
383
+ "aria-label": "Select tone",
384
+ children: [
385
+ p.map((i) => {
386
+ const f = i.icon, h = b === i.id;
387
+ return /* @__PURE__ */ n(
388
+ "button",
389
+ {
390
+ type: "button",
391
+ role: "radio",
392
+ "aria-checked": h,
393
+ "data-key": i.id,
394
+ "data-tags": i.tags,
395
+ onClick: () => l(i.id),
396
+ className: `group cteditor-grid cteditor-grid-cols-[36px_1fr_auto] cteditor-items-start cteditor-gap-3 cteditor-px-[14px] cteditor-py-[12px] cteditor-text-left cteditor-rounded-[12px] cteditor-border cteditor-min-h-[70px] cteditor-transition-all hover:cteditor-bg-foreground/5 ${h ? "cteditor-crop-btn-glow" : "cteditor-bg-background cteditor-border-foreground/10 hover:cteditor-border-foreground/20"}`,
397
+ children: [
398
+ /* @__PURE__ */ e("span", { className: `cteditor-flex cteditor-items-center cteditor-justify-center cteditor-w-9 cteditor-h-9 cteditor-rounded-[10px] cteditor-border cteditor-transition-colors ${h ? "cteditor-border-[#8a7df4] cteditor-text-[#fff] cteditor-bg-[rgba(138,125,244,0.1)]" : "cteditor-border-foreground/10 cteditor-bg-foreground/5 cteditor-text-foreground/80 group-hover:cteditor-border-[#8a7df4] group-hover:cteditor-text-[#8a7df4]"}`, children: /* @__PURE__ */ e(f, { className: "cteditor-w-[18px] cteditor-h-[18px]" }) }),
399
+ /* @__PURE__ */ n("span", { className: "cteditor-flex cteditor-flex-col cteditor-gap-[3px] cteditor-pt-[1px] cteditor-min-w-0", children: [
400
+ /* @__PURE__ */ e("span", { className: `cteditor-text-[14px] cteditor-font-semibold cteditor-leading-[1.2] cteditor-truncate cteditor-transition-colors ${h ? "cteditor-text-foreground" : "cteditor-text-foreground/90"}`, children: i.name }),
401
+ /* @__PURE__ */ e("span", { className: `cteditor-text-[12.5px] cteditor-leading-[1.4] cteditor-transition-colors cteditor-text-wrap-pretty ${h ? "cteditor-text-foreground/80" : "cteditor-text-foreground/50"}`, children: i.description })
402
+ ] }),
403
+ /* @__PURE__ */ e(
404
+ "span",
405
+ {
406
+ className: `cteditor-flex cteditor-items-center cteditor-justify-center cteditor-w-5 cteditor-h-5 cteditor-rounded-full cteditor-border-[1.4px] cteditor-mt-[6px] cteditor-shrink-0 cteditor-transition-all ${h ? "cteditor-bg-gradient-to-b cteditor-from-[#b59cff] cteditor-to-[#8c74f7] cteditor-border-[#b59cff]/70 cteditor-text-[#0e0a1f] cteditor-shadow-[0_6px_16px_-6px_rgba(99,82,232,0.45)]" : "cteditor-bg-foreground/5 cteditor-border-foreground/15 cteditor-text-transparent"}`,
407
+ "aria-hidden": "true",
408
+ children: /* @__PURE__ */ e(Ie, { className: "cteditor-w-3 cteditor-h-3", strokeWidth: 3 })
409
+ }
410
+ )
411
+ ]
412
+ },
413
+ i.id
414
+ );
415
+ }),
416
+ p.length === 0 && /* @__PURE__ */ n("div", { className: "cteditor-col-span-full cteditor-py-8 cteditor-text-center cteditor-text-sm cteditor-text-muted-foreground", children: [
417
+ "No tones match ",
418
+ /* @__PURE__ */ n("em", { className: "cteditor-text-foreground cteditor-font-medium", children: [
419
+ '"',
420
+ g,
421
+ '"'
422
+ ] }),
423
+ "."
424
+ ] })
425
+ ]
426
+ }
427
+ )
428
+ ] }),
429
+ /* @__PURE__ */ n(z, { className: "cteditor-mt-2 cteditor-gap-2", children: [
430
+ /* @__PURE__ */ e(T, { variant: "outline", onClick: k, children: "Cancel" }),
431
+ /* @__PURE__ */ n(
432
+ T,
433
+ {
434
+ onClick: I,
435
+ disabled: !b,
436
+ className: "cteditor-gap-2",
437
+ children: [
438
+ /* @__PURE__ */ e(V, { className: "!cteditor-size-5" }),
439
+ "Apply Tone"
440
+ ]
441
+ }
442
+ )
443
+ ] })
444
+ ] }) });
445
+ }, We = () => {
446
+ const [c] = se(), y = A(null), { apiKey: N } = ke(), [b, l] = v(!1), [g, m] = v(!1), [p, I] = v(""), [k, i] = v(""), f = A(null), h = A(null), o = A(void 0), ee = async (t) => {
447
+ let r, s = "";
448
+ if (c.getEditorState().read(() => {
449
+ r = _(), O(r) && (s = r.getTextContent().trim());
450
+ }), !s)
451
+ return a.error("Please select text first", {
452
+ description: "Select some text to use AI features"
453
+ }), !1;
454
+ const d = r ? {
455
+ anchor: {
456
+ key: r.anchor.key,
457
+ offset: r.anchor.offset,
458
+ type: r.anchor.type
459
+ },
460
+ focus: {
461
+ key: r.focus.key,
462
+ offset: r.focus.offset,
463
+ type: r.focus.type
464
+ }
465
+ } : null;
466
+ try {
467
+ return await R({
468
+ editor: c,
469
+ selectedText: s,
470
+ transformationType: t,
471
+ apiKey: N || void 0,
472
+ savedSelection: d,
473
+ onLoadingChange: (u) => {
474
+ if (u) {
475
+ const w = {
476
+ SPELLING_GRAMMAR: "Checking grammar and spelling...",
477
+ SIMPLIFY: "Simplifying your text...",
478
+ COMPLETE_SENTENCE: "Completing your sentence...",
479
+ AI_RESPONSE: "AI is thinking...",
480
+ EMOJIFY: "Adding emojis to your text...",
481
+ MAKE_LONGER: "Expanding your text...",
482
+ MAKE_SHORTER: "Condensing your text..."
483
+ };
484
+ if (o.current) return;
485
+ o.current = a.loading(
486
+ w[t] || "Processing...",
487
+ {
488
+ description: "This may take a few seconds. Please wait.",
489
+ duration: 1 / 0
490
+ }
491
+ );
492
+ } else
493
+ o.current && (a.dismiss(o.current), o.current = void 0);
494
+ },
495
+ onSuccess: (u) => {
496
+ o.current && (a.dismiss(o.current), o.current = void 0), a.success(u);
497
+ },
498
+ onError: (u) => {
499
+ o.current && (a.dismiss(o.current), o.current = void 0), a.error("Operation failed", {
500
+ description: u
501
+ });
502
+ }
503
+ }), !0;
504
+ } catch (u) {
505
+ return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in AI transformation:", u), a.error("Operation failed", {
506
+ description: u instanceof Error ? u.message : "An error occurred"
507
+ }), !1;
508
+ }
509
+ }, te = async (t) => {
510
+ if (!p || !f.current) return !1;
511
+ try {
512
+ return await R({
513
+ editor: c,
514
+ selectedText: p,
515
+ transformationType: "TRANSLATE",
516
+ apiKey: N || void 0,
517
+ savedSelection: f.current,
518
+ secondaryPrompt: t,
519
+ // Language to translate to
520
+ onLoadingChange: (r) => {
521
+ if (r) {
522
+ if (o.current) return;
523
+ o.current = a.loading(
524
+ `Translating to ${t}...`,
525
+ {
526
+ description: "This may take a few seconds. Please wait.",
527
+ duration: 1 / 0
528
+ }
529
+ );
530
+ } else
531
+ o.current && (a.dismiss(o.current), o.current = void 0);
532
+ },
533
+ onSuccess: (r) => {
534
+ o.current && (a.dismiss(o.current), o.current = void 0), a.success(`Text translated to ${t} successfully!`), f.current = null, I(""), l(!1);
535
+ },
536
+ onError: (r) => {
537
+ o.current && (a.dismiss(o.current), o.current = void 0), a.error("Translation failed", {
538
+ description: r
539
+ });
540
+ }
541
+ }), !0;
542
+ } catch (r) {
543
+ return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in translation:", r), a.error("Translation failed", {
544
+ description: r instanceof Error ? r.message : "An error occurred"
545
+ }), !1;
546
+ }
547
+ }, re = async (t) => {
548
+ const r = k, s = h.current;
549
+ if (!r || !s)
550
+ return a.error("No text selected for tone adjustment"), !1;
551
+ try {
552
+ return await R({
553
+ editor: c,
554
+ selectedText: r,
555
+ transformationType: "ADJUST_TONE",
556
+ apiKey: N || void 0,
557
+ savedSelection: s,
558
+ secondaryPrompt: t,
559
+ // Tone to adjust to
560
+ onLoadingChange: (d) => {
561
+ if (d) {
562
+ if (o.current) return;
563
+ o.current = a.loading(
564
+ `Adjusting to ${t} tone...`,
565
+ {
566
+ description: "This may take a few seconds. Please wait.",
567
+ duration: 1 / 0
568
+ }
569
+ );
570
+ } else
571
+ o.current && (a.dismiss(o.current), o.current = void 0);
572
+ },
573
+ onSuccess: (d) => {
574
+ o.current && (a.dismiss(o.current), o.current = void 0), a.success(`Tone adjusted to ${t} successfully!`), h.current = null, i(""), m(!1);
575
+ },
576
+ onError: (d) => {
577
+ o.current && (a.dismiss(o.current), o.current = void 0), a.error("Tone adjustment failed", {
578
+ description: d
579
+ });
580
+ }
581
+ }), !0;
582
+ } catch (d) {
583
+ return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in tone adjustment:", d), a.error("Tone adjustment failed", {
584
+ description: d instanceof Error ? d.message : "An error occurred"
585
+ }), !1;
586
+ }
587
+ }, oe = async (t) => (y.current?.openDialog(t), !0), ie = async (t) => {
588
+ const r = crypto.randomUUID();
589
+ c.update(() => {
590
+ const s = Pe({ placeholderId: r, prompt: t });
591
+ de([s]);
592
+ }), y.current?.setGenerating(!1);
593
+ try {
594
+ const s = await fetch(`${Me}/agent/stream`, {
595
+ method: "POST",
596
+ headers: { "Content-Type": "application/json" },
597
+ body: JSON.stringify({
598
+ type: "general",
599
+ query: `Generate Image: ${t}`,
600
+ model: "openai",
601
+ api_key: N || ""
602
+ })
603
+ });
604
+ if (!s.ok) throw new Error(`HTTP ${s.status}`);
605
+ const d = s.body?.getReader();
606
+ if (!d) throw new Error("Stream reader not available");
607
+ const u = new TextDecoder();
608
+ for (; ; ) {
609
+ const { done: w, value: C } = await d.read();
610
+ if (w) break;
611
+ const ae = u.decode(C, { stream: !0 }).split(`
612
+ `);
613
+ for (const D of ae)
614
+ if (!(!D.trim() || !D.startsWith("data: ")))
615
+ try {
616
+ const x = JSON.parse(D.slice(6));
617
+ if (x.type === "image_ready" && x.url)
618
+ return ne(r, x.url, t), d.cancel(), x.url;
619
+ if (x.type === "image_failed")
620
+ throw M(r, x.error || "Image generation failed"), d.cancel(), new Error(x.error || "Image generation failed");
621
+ if (x.type === "error")
622
+ throw M(r, x.error || "Stream error"), d.cancel(), new Error(x.error || "Stream error");
623
+ if (x.type === "stream_end")
624
+ return d.cancel(), "";
625
+ } catch (x) {
626
+ if (x instanceof Error && x.message !== "Stream error" && !x.message.includes("generation failed"))
627
+ continue;
628
+ throw x;
629
+ }
630
+ }
631
+ } catch (s) {
632
+ M(
633
+ r,
634
+ s instanceof Error ? s.message : "Image generation failed"
635
+ ), a.error("Image generation failed", {
636
+ description: s instanceof Error ? s.message : "An error occurred"
637
+ });
638
+ }
639
+ return "";
640
+ }, ne = (t, r, s) => {
641
+ c.update(() => {
642
+ const d = L(), u = (w) => {
643
+ if (G(w) && w.getPlaceholderId() === t) {
644
+ const E = De({
645
+ src: r,
646
+ altText: s,
647
+ originalPrompt: s
648
+ });
649
+ return w.replace(E), !0;
650
+ }
651
+ const C = w.getChildren?.() || [];
652
+ for (const E of C)
653
+ if (u(E)) return !0;
654
+ return !1;
655
+ };
656
+ u(d);
657
+ });
658
+ }, M = (t, r) => {
659
+ c.update(() => {
660
+ const s = L(), d = (u) => {
661
+ if (G(u) && u.getPlaceholderId() === t) {
662
+ u.setError(r);
663
+ return;
664
+ }
665
+ const w = u.getChildren?.() || [];
666
+ for (const C of w) d(C);
667
+ };
668
+ d(s);
669
+ }), setTimeout(() => {
670
+ c.update(() => {
671
+ const s = L(), d = (u) => {
672
+ if (G(u) && u.getPlaceholderId() === t) {
673
+ u.remove();
674
+ return;
675
+ }
676
+ const w = u.getChildren?.() || [];
677
+ for (const C of w) d(C);
678
+ };
679
+ d(s);
680
+ });
681
+ }, 5e3);
682
+ }, ce = (t, r) => {
683
+ try {
684
+ c.dispatchCommand(Ae, {
685
+ src: t,
686
+ altText: "Generated image",
687
+ originalPrompt: r
688
+ });
689
+ } catch (s) {
690
+ throw console.error("Error inserting image into editor:", s), s;
691
+ }
692
+ };
693
+ return P(() => c.registerCommand(
694
+ Ce,
695
+ ({ type: t }) => ((async () => {
696
+ try {
697
+ await ee(t);
698
+ } catch (r) {
699
+ console.error(`Error on AI stream: ${r}`);
700
+ }
701
+ })(), !0),
702
+ S
703
+ ), [c]), P(() => c.registerCommand(
704
+ Te,
705
+ (t) => ((async () => {
706
+ try {
707
+ await oe(t);
708
+ } catch (r) {
709
+ console.error(`Error generating image: ${r}`);
710
+ }
711
+ })(), !0),
712
+ S
713
+ ), [c]), P(() => c.registerCommand(
714
+ Ee,
715
+ () => (c.getEditorState().read(() => {
716
+ const t = _();
717
+ if (O(t)) {
718
+ const r = t.getTextContent().trim();
719
+ if (!r) {
720
+ a.error("Please select text first", {
721
+ description: "Select some text to translate"
722
+ });
723
+ return;
724
+ }
725
+ f.current = {
726
+ anchor: {
727
+ key: t.anchor.key,
728
+ offset: t.anchor.offset,
729
+ type: t.anchor.type
730
+ },
731
+ focus: {
732
+ key: t.focus.key,
733
+ offset: t.focus.offset,
734
+ type: t.focus.type
735
+ }
736
+ }, I(r), l(!0);
737
+ }
738
+ }), !0),
739
+ S
740
+ ), [c]), P(() => c.registerCommand(
741
+ Se,
742
+ () => (c.getEditorState().read(() => {
743
+ const t = _();
744
+ if (O(t)) {
745
+ const r = t.getTextContent().trim();
746
+ if (!r) {
747
+ a.error("Please select text first", {
748
+ description: "Select some text to adjust tone"
749
+ });
750
+ return;
751
+ }
752
+ h.current = {
753
+ anchor: {
754
+ key: t.anchor.key,
755
+ offset: t.anchor.offset,
756
+ type: t.anchor.type
757
+ },
758
+ focus: {
759
+ key: t.focus.key,
760
+ offset: t.focus.offset,
761
+ type: t.focus.type
762
+ }
763
+ }, i(r), m(!0);
764
+ }
765
+ }), !0),
766
+ S
767
+ ), [c]), /* @__PURE__ */ n(j, { children: [
768
+ /* @__PURE__ */ e(
769
+ Z,
770
+ {
771
+ ref: y,
772
+ onGenerate: ie,
773
+ onInsertImage: ce
774
+ }
775
+ ),
776
+ /* @__PURE__ */ e(
777
+ Ge,
778
+ {
779
+ open: b,
780
+ onOpenChange: l,
781
+ onLanguageSelect: te
782
+ }
783
+ ),
784
+ /* @__PURE__ */ e(
785
+ je,
786
+ {
787
+ open: g,
788
+ onOpenChange: m,
789
+ onToneSelect: re
790
+ }
791
+ )
792
+ ] });
793
+ };
794
+ export {
795
+ We as default
796
+ };