eddyter 1.4.16 → 1.4.17
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.
- package/dist/AIChatPlugin-2pIKhzIw.js +871 -0
- package/dist/{CommentBubblePlugin-DZQW1ibY.js → CommentBubblePlugin-J3r4kNGK.js} +1 -1
- package/dist/CommentPlugin-BbuE8_Aj.js +154 -0
- package/dist/LazyCodeMirror-DdCIk-83.js +21374 -0
- package/dist/{LazySignatureCanvas-FKl1mD-T.js → LazySignatureCanvas-D1t8oQDK.js} +1 -1
- package/dist/NotePanelPlugin-C16G36Jd.js +31 -0
- package/dist/TextEnhancePlugin-BShY1r5J.js +198 -0
- package/dist/components/AiPlugin/commands.d.ts +4 -0
- package/dist/components/AiPlugin/index.d.ts +0 -4
- package/dist/{generateDocxThumbnail-DJlPLsdY.js → generateDocxThumbnail-Ve0zlObJ.js} +1 -1
- package/dist/{generatePdfThumbnail-CfDAh39b.js → generatePdfThumbnail-EuSjdwzm.js} +1 -1
- package/dist/{generateXlsxThumbnail-cRIT4Jyf.js → generateXlsxThumbnail-C10kl6qh.js} +1 -1
- package/dist/{html2pdf.bundle.min-BW3dolOS.js → html2pdf.bundle.min-BQaO0VTp.js} +1 -1
- package/dist/{index-W6_ogglw.js → index-B8zPtmsK.js} +24 -24
- package/dist/{index-gjz4wieB.js → index-BSgLtgyt.js} +36 -36
- package/dist/{index-BydXFu_2.js → index-ClsuXAKJ.js} +1 -1
- package/dist/index-CoLO4gm_.js +719 -0
- package/dist/{index-BDDjWwK4.js → index-CxOOJD40.js} +14869 -18049
- package/dist/{index-BmfQcIrc.js → index-D25uusM-.js} +127 -126
- package/dist/{index-BEepnYCf.js → index-gPq4n7_a.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/marked.esm-Tjr8Gfse.js +1114 -0
- package/dist/plugins/AIChatPlugin.commands.d.ts +7 -0
- package/dist/plugins/AIChatPlugin.d.ts +0 -7
- package/dist/plugins/CommentPlugin.commands.d.ts +5 -0
- package/dist/plugins/CommentPlugin.d.ts +0 -5
- package/dist/plugins/NotePanelPlugin.commands.d.ts +6 -0
- package/dist/plugins/NotePanelPlugin.d.ts +0 -6
- package/dist/plugins/TextEnhancePlugin.commands.d.ts +1 -0
- package/dist/plugins/TextEnhancePlugin.d.ts +0 -1
- package/dist/square-DrMKkLmP.js +7 -0
- package/dist/useVoiceToText-DCddJzYF.js +153 -0
- package/package.json +5 -2
- package/dist/LazyCodeMirror-C1bW4mVF.js +0 -44822
|
@@ -0,0 +1,719 @@
|
|
|
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 k, $getSelection as O, $isRangeSelection as R, $insertNodes as de, $getRoot as G } from "lexical";
|
|
4
|
+
import { c as X, D as $, a as F, b as U, d as K, S as J, e as z, L as le, I as ue, f as B, g as H, B as E, u as me, A as fe, h as ge, i as pe, t as a, j as he, p as _, k as ye, $ as xe, l as Ne, m as L, n as be } from "./index-CxOOJD40.js";
|
|
5
|
+
import W, { useState as I, forwardRef as ve, useImperativeHandle as Ie, useRef as A, useEffect as D } from "react";
|
|
6
|
+
const V = X("Globe", [
|
|
7
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
8
|
+
["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
|
|
9
|
+
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
10
|
+
]);
|
|
11
|
+
const Y = X("Volume2", [
|
|
12
|
+
["polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5", key: "16drj5" }],
|
|
13
|
+
["path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07", key: "ltjumu" }],
|
|
14
|
+
["path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14", key: "1kegas" }]
|
|
15
|
+
]), Te = ({
|
|
16
|
+
open: i,
|
|
17
|
+
onOpenChange: y,
|
|
18
|
+
onGenerate: N,
|
|
19
|
+
onInsertImage: h,
|
|
20
|
+
isGenerating: d,
|
|
21
|
+
initialText: x
|
|
22
|
+
}) => {
|
|
23
|
+
const [f, u] = I("");
|
|
24
|
+
W.useEffect(() => {
|
|
25
|
+
i && x && u(x);
|
|
26
|
+
}, [i, x]), W.useEffect(() => {
|
|
27
|
+
i || u("");
|
|
28
|
+
}, [i]);
|
|
29
|
+
const v = async () => {
|
|
30
|
+
if (!f.trim()) return;
|
|
31
|
+
const m = f.trim();
|
|
32
|
+
u(""), y(!1);
|
|
33
|
+
try {
|
|
34
|
+
await N(m);
|
|
35
|
+
} catch (g) {
|
|
36
|
+
console.error("Error generating image:", g);
|
|
37
|
+
}
|
|
38
|
+
}, w = () => {
|
|
39
|
+
d || (u(""), y(!1));
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ e($, { open: i, onOpenChange: w, children: /* @__PURE__ */ n(F, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[90vh] cteditor-overflow-y-auto", children: [
|
|
42
|
+
/* @__PURE__ */ n(U, { children: [
|
|
43
|
+
/* @__PURE__ */ n(K, { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xl", children: [
|
|
44
|
+
/* @__PURE__ */ e(J, {}),
|
|
45
|
+
"Generate Image with AI"
|
|
46
|
+
] }),
|
|
47
|
+
/* @__PURE__ */ e(z, { className: "cteditor-text-base cteditor-pt-2", children: "Describe the image you want to create, and AI will generate it for you." })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ n("div", { className: "cteditor-space-y-4", children: [
|
|
50
|
+
/* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-gap-2 cteditor-flex-col", children: [
|
|
51
|
+
/* @__PURE__ */ e(le, { htmlFor: "image-prompt", children: "What do you want to see?" }),
|
|
52
|
+
/* @__PURE__ */ e(
|
|
53
|
+
ue,
|
|
54
|
+
{
|
|
55
|
+
id: "image-prompt",
|
|
56
|
+
placeholder: "Mountains and rivers with birds flying in the sky",
|
|
57
|
+
value: f,
|
|
58
|
+
onChange: (m) => u(m.target.value),
|
|
59
|
+
disabled: d,
|
|
60
|
+
className: "h-12",
|
|
61
|
+
onKeyDown: (m) => {
|
|
62
|
+
m.key === "Enter" && !d && f.trim() && v();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ n("p", { className: "cteditor-text-muted-foreground cteditor-flex cteditor-gap-1 cteditor-text-xs ", children: [
|
|
67
|
+
/* @__PURE__ */ e(B, { className: "cteditor-h-4 cteditor-w-4" }),
|
|
68
|
+
" Just describe what you want - be specific and detailed for best results"
|
|
69
|
+
] })
|
|
70
|
+
] }),
|
|
71
|
+
d && /* @__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: [
|
|
72
|
+
/* @__PURE__ */ e("div", { className: "h-5 w-5 animate-spin rounded-full border-2 border-blue-600 border-t-transparent" }),
|
|
73
|
+
/* @__PURE__ */ n("div", { children: [
|
|
74
|
+
/* @__PURE__ */ e("p", { className: "text-xs font-medium text-blue-800 dark:text-blue-200", children: "Creating your image..." }),
|
|
75
|
+
/* @__PURE__ */ e("p", { className: "text-xs text-blue-600 dark:text-blue-300 mt-1", children: "This may take 10-30 seconds. Please wait." })
|
|
76
|
+
] })
|
|
77
|
+
] }) }),
|
|
78
|
+
!d && /* @__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: [
|
|
79
|
+
/* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1 cteditor-mb-2", children: [
|
|
80
|
+
/* @__PURE__ */ e(B, { className: "cteditor-h-4 cteditor-w-4" }),
|
|
81
|
+
/* @__PURE__ */ e("h3", { className: "cteditor-text-sm cteditor-font-medium", children: "Good examples:" })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ n("div", { className: "text-xs text-gray-600 dark:text-gray-400", children: [
|
|
84
|
+
/* @__PURE__ */ n("ul", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-space-y-1", children: [
|
|
85
|
+
/* @__PURE__ */ e("li", { children: '. Mountains and rivers at sunset"' }),
|
|
86
|
+
/* @__PURE__ */ e("li", { children: '. A cat sitting on a windowsill"' }),
|
|
87
|
+
/* @__PURE__ */ e("li", { children: '. Modern city skyline at night"' })
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ n("p", { className: "cteditor-mt-2 cteditor-text-xs cteditor-flex cteditor-gap-1 cteditor-text-yellow-500", children: [
|
|
90
|
+
/* @__PURE__ */ e("span", { children: "⚠️" }),
|
|
91
|
+
`Don't include "generate" or "create" - just describe!`
|
|
92
|
+
] })
|
|
93
|
+
] })
|
|
94
|
+
] }) })
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ n(H, { className: "gap-2", children: [
|
|
97
|
+
/* @__PURE__ */ e(
|
|
98
|
+
E,
|
|
99
|
+
{
|
|
100
|
+
variant: "outline",
|
|
101
|
+
onClick: w,
|
|
102
|
+
disabled: d,
|
|
103
|
+
children: "Cancel"
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ e(
|
|
107
|
+
E,
|
|
108
|
+
{
|
|
109
|
+
onClick: v,
|
|
110
|
+
disabled: d || !f.trim(),
|
|
111
|
+
children: d ? /* @__PURE__ */ n(j, { children: [
|
|
112
|
+
/* @__PURE__ */ e("div", { className: "h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent mr-2" }),
|
|
113
|
+
"Generating..."
|
|
114
|
+
] }) : /* @__PURE__ */ n(j, { children: [
|
|
115
|
+
/* @__PURE__ */ e(J, {}),
|
|
116
|
+
"Generate & Insert"
|
|
117
|
+
] })
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] })
|
|
121
|
+
] }) });
|
|
122
|
+
}, Z = ve(({ onGenerate: i, onInsertImage: y }, N) => {
|
|
123
|
+
const [h, d] = I(!1), [x, f] = I(!1), [u, v] = I(void 0);
|
|
124
|
+
return Ie(N, () => ({
|
|
125
|
+
openDialog: (g) => {
|
|
126
|
+
v(g), d(!0);
|
|
127
|
+
},
|
|
128
|
+
setGenerating: (g) => f(g)
|
|
129
|
+
})), /* @__PURE__ */ e(
|
|
130
|
+
Te,
|
|
131
|
+
{
|
|
132
|
+
open: h,
|
|
133
|
+
onOpenChange: d,
|
|
134
|
+
onGenerate: async (g) => {
|
|
135
|
+
f(!0);
|
|
136
|
+
try {
|
|
137
|
+
return await i(g);
|
|
138
|
+
} catch (T) {
|
|
139
|
+
throw console.error("Error generating image:", T), T;
|
|
140
|
+
} finally {
|
|
141
|
+
f(!1);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onInsertImage: (g, T) => {
|
|
145
|
+
y(g, T), d(!1);
|
|
146
|
+
},
|
|
147
|
+
isGenerating: x,
|
|
148
|
+
initialText: u
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
Z.displayName = "ImageGenerationManager";
|
|
153
|
+
const Q = [
|
|
154
|
+
{ code: "en", name: "English", flag: "🇺🇸" },
|
|
155
|
+
{ code: "es", name: "Spanish", flag: "🇪🇸" },
|
|
156
|
+
{ code: "fr", name: "French", flag: "🇫🇷" },
|
|
157
|
+
{ code: "de", name: "German", flag: "🇩🇪" },
|
|
158
|
+
{ code: "it", name: "Italian", flag: "🇮🇹" },
|
|
159
|
+
{ code: "pt", name: "Portuguese", flag: "🇵🇹" },
|
|
160
|
+
{ code: "ru", name: "Russian", flag: "🇷🇺" },
|
|
161
|
+
{ code: "ja", name: "Japanese", flag: "🇯🇵" },
|
|
162
|
+
{ code: "ko", name: "Korean", flag: "🇰🇷" },
|
|
163
|
+
{ code: "zh", name: "Chinese", flag: "🇨🇳" },
|
|
164
|
+
{ code: "ar", name: "Arabic", flag: "🇸🇦" },
|
|
165
|
+
{ code: "hi", name: "Hindi", flag: "🇮🇳" },
|
|
166
|
+
{ code: "bn", name: "Bengali", flag: "🇧🇩" },
|
|
167
|
+
{ code: "tr", name: "Turkish", flag: "🇹🇷" },
|
|
168
|
+
{ code: "vi", name: "Vietnamese", flag: "🇻🇳" },
|
|
169
|
+
{ code: "th", name: "Thai", flag: "🇹🇭" },
|
|
170
|
+
{ code: "pl", name: "Polish", flag: "🇵🇱" },
|
|
171
|
+
{ code: "nl", name: "Dutch", flag: "🇳🇱" },
|
|
172
|
+
{ code: "sv", name: "Swedish", flag: "🇸🇪" }
|
|
173
|
+
], we = ({
|
|
174
|
+
open: i,
|
|
175
|
+
onOpenChange: y,
|
|
176
|
+
onLanguageSelect: N
|
|
177
|
+
}) => {
|
|
178
|
+
const [h, d] = I(""), [x, f] = I(""), u = Q.filter(
|
|
179
|
+
(m) => m.name.toLowerCase().includes(x.toLowerCase())
|
|
180
|
+
), v = () => {
|
|
181
|
+
if (h) {
|
|
182
|
+
const m = Q.find((g) => g.code === h);
|
|
183
|
+
m && (N(m.name), y(!1), d(""), f(""));
|
|
184
|
+
}
|
|
185
|
+
}, w = () => {
|
|
186
|
+
y(!1), d(""), f("");
|
|
187
|
+
};
|
|
188
|
+
return /* @__PURE__ */ e($, { open: i, onOpenChange: w, children: /* @__PURE__ */ n(F, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[600px] cteditor-max-w-[calc(100%-2rem)] cteditor-rounded-lg", children: [
|
|
189
|
+
/* @__PURE__ */ n(U, { children: [
|
|
190
|
+
/* @__PURE__ */ n(K, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
|
|
191
|
+
/* @__PURE__ */ e(V, { className: "cteditor-size-5" }),
|
|
192
|
+
"Select Target Language"
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ e(z, { children: "Choose the language you want to translate your text into. Use English to translate from Hindi, Arabic, or any other language into English." })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ n("div", { children: [
|
|
197
|
+
/* @__PURE__ */ e(
|
|
198
|
+
"input",
|
|
199
|
+
{
|
|
200
|
+
type: "text",
|
|
201
|
+
placeholder: "Search languages...",
|
|
202
|
+
value: x,
|
|
203
|
+
onChange: (m) => f(m.target.value),
|
|
204
|
+
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"
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
/* @__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: u.map((m) => /* @__PURE__ */ n(
|
|
208
|
+
"button",
|
|
209
|
+
{
|
|
210
|
+
type: "button",
|
|
211
|
+
onClick: () => d(m.code),
|
|
212
|
+
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 ${h === m.code ? "cteditor-bg-primary/10 cteditor-border-primary cteditor-ring-2 cteditor-ring-primary/20" : "cteditor-border-input hover:cteditor-border-primary/50"}`,
|
|
213
|
+
children: [
|
|
214
|
+
/* @__PURE__ */ e("span", { className: "cteditor-text-2xl", children: m.flag }),
|
|
215
|
+
/* @__PURE__ */ e("span", { className: "cteditor-font-medium", children: m.name })
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
m.code
|
|
219
|
+
)) }),
|
|
220
|
+
u.length === 0 && /* @__PURE__ */ n("div", { className: "cteditor-text-center cteditor-py-8 cteditor-text-muted-foreground", children: [
|
|
221
|
+
'No languages found matching "',
|
|
222
|
+
x,
|
|
223
|
+
'"'
|
|
224
|
+
] })
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ n(H, { children: [
|
|
227
|
+
/* @__PURE__ */ e(E, { variant: "outline", onClick: w, children: "Cancel" }),
|
|
228
|
+
/* @__PURE__ */ n(
|
|
229
|
+
E,
|
|
230
|
+
{
|
|
231
|
+
onClick: v,
|
|
232
|
+
disabled: !h,
|
|
233
|
+
className: "!cteditor-gap-1",
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ e(V, { className: "!cteditor-size-4" }),
|
|
236
|
+
"Translate"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] })
|
|
241
|
+
] }) });
|
|
242
|
+
}, q = [
|
|
243
|
+
{
|
|
244
|
+
id: "professional",
|
|
245
|
+
name: "Professional",
|
|
246
|
+
icon: "💼",
|
|
247
|
+
description: "Formal and business-appropriate"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: "friendly",
|
|
251
|
+
name: "Friendly",
|
|
252
|
+
icon: "😊",
|
|
253
|
+
description: "Warm and approachable"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "casual",
|
|
257
|
+
name: "Casual",
|
|
258
|
+
icon: "👋",
|
|
259
|
+
description: "Relaxed and conversational"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
id: "formal",
|
|
263
|
+
name: "Formal",
|
|
264
|
+
icon: "🎩",
|
|
265
|
+
description: "Highly polished and proper"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: "confident",
|
|
269
|
+
name: "Confident",
|
|
270
|
+
icon: "💪",
|
|
271
|
+
description: "Assertive and self-assured"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "empathetic",
|
|
275
|
+
name: "Empathetic",
|
|
276
|
+
icon: "❤️",
|
|
277
|
+
description: "Understanding and compassionate"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: "enthusiastic",
|
|
281
|
+
name: "Enthusiastic",
|
|
282
|
+
icon: "🎉",
|
|
283
|
+
description: "Energetic and excited"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: "neutral",
|
|
287
|
+
name: "Neutral",
|
|
288
|
+
icon: "📝",
|
|
289
|
+
description: "Balanced and objective"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
id: "persuasive",
|
|
293
|
+
name: "Persuasive",
|
|
294
|
+
icon: "🎯",
|
|
295
|
+
description: "Convincing and compelling"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: "respectful",
|
|
299
|
+
name: "Respectful",
|
|
300
|
+
icon: "🙏",
|
|
301
|
+
description: "Courteous and considerate"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
id: "witty",
|
|
305
|
+
name: "Witty",
|
|
306
|
+
icon: "😄",
|
|
307
|
+
description: "Clever and humorous"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
id: "concise",
|
|
311
|
+
name: "Concise",
|
|
312
|
+
icon: "✂️",
|
|
313
|
+
description: "Brief and to the point"
|
|
314
|
+
}
|
|
315
|
+
], Ce = ({
|
|
316
|
+
open: i,
|
|
317
|
+
onOpenChange: y,
|
|
318
|
+
onToneSelect: N
|
|
319
|
+
}) => {
|
|
320
|
+
const [h, d] = I(""), x = () => {
|
|
321
|
+
if (h) {
|
|
322
|
+
const u = q.find((v) => v.id === h);
|
|
323
|
+
u && (N(u.name), y(!1), d(""));
|
|
324
|
+
}
|
|
325
|
+
}, f = () => {
|
|
326
|
+
y(!1), d("");
|
|
327
|
+
};
|
|
328
|
+
return /* @__PURE__ */ e($, { open: i, onOpenChange: f, children: /* @__PURE__ */ n(F, { className: "sm:max-w-[600px] cteditor-max-h-[650px]", children: [
|
|
329
|
+
/* @__PURE__ */ n(U, { children: [
|
|
330
|
+
/* @__PURE__ */ n(K, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
|
|
331
|
+
/* @__PURE__ */ e(Y, { className: "cteditor-size-5" }),
|
|
332
|
+
"Adjust Tone"
|
|
333
|
+
] }),
|
|
334
|
+
/* @__PURE__ */ e(z, { children: "Choose the tone style you want to apply to your selected text." })
|
|
335
|
+
] }),
|
|
336
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "cteditor-grid cteditor-grid-cols-2 cteditor-gap-3 cteditor-max-h-[400px] cteditor-overflow-y-auto cteditor-pr-2", children: q.map((u) => /* @__PURE__ */ n(
|
|
337
|
+
"button",
|
|
338
|
+
{
|
|
339
|
+
type: "button",
|
|
340
|
+
onClick: () => d(u.id),
|
|
341
|
+
className: `cteditor-flex cteditor-flex-col cteditor-items-start cteditor-gap-1 cteditor-px-4 cteditor-py-3 cteditor-text-left cteditor-rounded-lg cteditor-border cteditor-transition-all hover:cteditor-bg-accent ${h === u.id ? "cteditor-bg-primary/10 cteditor-border-primary cteditor-ring-2 cteditor-ring-primary/20" : "cteditor-border-input hover:cteditor-border-primary/50"}`,
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ n("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-w-full", children: [
|
|
344
|
+
/* @__PURE__ */ e("span", { className: "cteditor-font-semibold cteditor-text-sm", children: u.name }),
|
|
345
|
+
h === u.id && /* @__PURE__ */ e("div", { className: "cteditor-ml-auto cteditor-flex cteditor-items-center cteditor-justify-center cteditor-w-5 cteditor-h-5 cteditor-rounded-full cteditor-bg-primary cteditor-text-primary-foreground", children: /* @__PURE__ */ e("svg", { className: "cteditor-w-3 cteditor-h-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }) }) })
|
|
346
|
+
] }),
|
|
347
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: u.description })
|
|
348
|
+
]
|
|
349
|
+
},
|
|
350
|
+
u.id
|
|
351
|
+
)) }) }),
|
|
352
|
+
/* @__PURE__ */ n(H, { children: [
|
|
353
|
+
/* @__PURE__ */ e(E, { variant: "outline", onClick: f, children: "Cancel" }),
|
|
354
|
+
/* @__PURE__ */ n(
|
|
355
|
+
E,
|
|
356
|
+
{
|
|
357
|
+
onClick: x,
|
|
358
|
+
disabled: !h,
|
|
359
|
+
className: "cteditor-gap-2",
|
|
360
|
+
children: [
|
|
361
|
+
/* @__PURE__ */ e(Y, { className: "!cteditor-size-5" }),
|
|
362
|
+
"Apply Tone"
|
|
363
|
+
]
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
] })
|
|
367
|
+
] }) });
|
|
368
|
+
}, Pe = () => {
|
|
369
|
+
const [i] = se(), y = A(null), { apiKey: N } = me(), [h, d] = I(!1), [x, f] = I(!1), [u, v] = I(""), [w, m] = I(""), g = A(null), T = A(null), o = A(void 0), ee = async (t) => {
|
|
370
|
+
let r, c = "";
|
|
371
|
+
if (i.getEditorState().read(() => {
|
|
372
|
+
r = O(), R(r) && (c = r.getTextContent().trim());
|
|
373
|
+
}), !c)
|
|
374
|
+
return a.error("Please select text first", {
|
|
375
|
+
description: "Select some text to use AI features"
|
|
376
|
+
}), !1;
|
|
377
|
+
const s = r ? {
|
|
378
|
+
anchor: {
|
|
379
|
+
key: r.anchor.key,
|
|
380
|
+
offset: r.anchor.offset,
|
|
381
|
+
type: r.anchor.type
|
|
382
|
+
},
|
|
383
|
+
focus: {
|
|
384
|
+
key: r.focus.key,
|
|
385
|
+
offset: r.focus.offset,
|
|
386
|
+
type: r.focus.type
|
|
387
|
+
}
|
|
388
|
+
} : null;
|
|
389
|
+
try {
|
|
390
|
+
return await _({
|
|
391
|
+
editor: i,
|
|
392
|
+
selectedText: c,
|
|
393
|
+
transformationType: t,
|
|
394
|
+
apiKey: N || void 0,
|
|
395
|
+
savedSelection: s,
|
|
396
|
+
onLoadingChange: (l) => {
|
|
397
|
+
if (l) {
|
|
398
|
+
const b = {
|
|
399
|
+
SPELLING_GRAMMAR: "Checking grammar and spelling...",
|
|
400
|
+
SIMPLIFY: "Simplifying your text...",
|
|
401
|
+
COMPLETE_SENTENCE: "Completing your sentence...",
|
|
402
|
+
AI_RESPONSE: "AI is thinking...",
|
|
403
|
+
EMOJIFY: "Adding emojis to your text...",
|
|
404
|
+
MAKE_LONGER: "Expanding your text...",
|
|
405
|
+
MAKE_SHORTER: "Condensing your text..."
|
|
406
|
+
};
|
|
407
|
+
if (o.current) return;
|
|
408
|
+
o.current = a.loading(
|
|
409
|
+
b[t] || "Processing...",
|
|
410
|
+
{
|
|
411
|
+
description: "This may take a few seconds. Please wait.",
|
|
412
|
+
duration: 1 / 0
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
} else
|
|
416
|
+
o.current && (a.dismiss(o.current), o.current = void 0);
|
|
417
|
+
},
|
|
418
|
+
onSuccess: (l) => {
|
|
419
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.success(l);
|
|
420
|
+
},
|
|
421
|
+
onError: (l) => {
|
|
422
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.error("Operation failed", {
|
|
423
|
+
description: l
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}), !0;
|
|
427
|
+
} catch (l) {
|
|
428
|
+
return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in AI transformation:", l), a.error("Operation failed", {
|
|
429
|
+
description: l instanceof Error ? l.message : "An error occurred"
|
|
430
|
+
}), !1;
|
|
431
|
+
}
|
|
432
|
+
}, te = async (t) => {
|
|
433
|
+
if (!u || !g.current) return !1;
|
|
434
|
+
try {
|
|
435
|
+
return await _({
|
|
436
|
+
editor: i,
|
|
437
|
+
selectedText: u,
|
|
438
|
+
transformationType: "TRANSLATE",
|
|
439
|
+
apiKey: N || void 0,
|
|
440
|
+
savedSelection: g.current,
|
|
441
|
+
secondaryPrompt: t,
|
|
442
|
+
// Language to translate to
|
|
443
|
+
onLoadingChange: (r) => {
|
|
444
|
+
if (r) {
|
|
445
|
+
if (o.current) return;
|
|
446
|
+
o.current = a.loading(
|
|
447
|
+
`Translating to ${t}...`,
|
|
448
|
+
{
|
|
449
|
+
description: "This may take a few seconds. Please wait.",
|
|
450
|
+
duration: 1 / 0
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
} else
|
|
454
|
+
o.current && (a.dismiss(o.current), o.current = void 0);
|
|
455
|
+
},
|
|
456
|
+
onSuccess: (r) => {
|
|
457
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.success(`Text translated to ${t} successfully!`), g.current = null, v(""), d(!1);
|
|
458
|
+
},
|
|
459
|
+
onError: (r) => {
|
|
460
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.error("Translation failed", {
|
|
461
|
+
description: r
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}), !0;
|
|
465
|
+
} catch (r) {
|
|
466
|
+
return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in translation:", r), a.error("Translation failed", {
|
|
467
|
+
description: r instanceof Error ? r.message : "An error occurred"
|
|
468
|
+
}), !1;
|
|
469
|
+
}
|
|
470
|
+
}, re = async (t) => {
|
|
471
|
+
const r = w, c = T.current;
|
|
472
|
+
if (!r || !c)
|
|
473
|
+
return a.error("No text selected for tone adjustment"), !1;
|
|
474
|
+
try {
|
|
475
|
+
return await _({
|
|
476
|
+
editor: i,
|
|
477
|
+
selectedText: r,
|
|
478
|
+
transformationType: "ADJUST_TONE",
|
|
479
|
+
apiKey: N || void 0,
|
|
480
|
+
savedSelection: c,
|
|
481
|
+
secondaryPrompt: t,
|
|
482
|
+
// Tone to adjust to
|
|
483
|
+
onLoadingChange: (s) => {
|
|
484
|
+
if (s) {
|
|
485
|
+
if (o.current) return;
|
|
486
|
+
o.current = a.loading(
|
|
487
|
+
`Adjusting to ${t} tone...`,
|
|
488
|
+
{
|
|
489
|
+
description: "This may take a few seconds. Please wait.",
|
|
490
|
+
duration: 1 / 0
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
} else
|
|
494
|
+
o.current && (a.dismiss(o.current), o.current = void 0);
|
|
495
|
+
},
|
|
496
|
+
onSuccess: (s) => {
|
|
497
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.success(`Tone adjusted to ${t} successfully!`), T.current = null, m(""), f(!1);
|
|
498
|
+
},
|
|
499
|
+
onError: (s) => {
|
|
500
|
+
o.current && (a.dismiss(o.current), o.current = void 0), a.error("Tone adjustment failed", {
|
|
501
|
+
description: s
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}), !0;
|
|
505
|
+
} catch (s) {
|
|
506
|
+
return o.current && (a.dismiss(o.current), o.current = void 0), console.error("Error in tone adjustment:", s), a.error("Tone adjustment failed", {
|
|
507
|
+
description: s instanceof Error ? s.message : "An error occurred"
|
|
508
|
+
}), !1;
|
|
509
|
+
}
|
|
510
|
+
}, oe = async (t) => (y.current?.openDialog(t), !0), ne = async (t) => {
|
|
511
|
+
const r = crypto.randomUUID();
|
|
512
|
+
i.update(() => {
|
|
513
|
+
const c = xe({ placeholderId: r, prompt: t });
|
|
514
|
+
de([c]);
|
|
515
|
+
}), y.current?.setGenerating(!1);
|
|
516
|
+
try {
|
|
517
|
+
const c = await fetch(`${Ne}/agent/stream`, {
|
|
518
|
+
method: "POST",
|
|
519
|
+
headers: { "Content-Type": "application/json" },
|
|
520
|
+
body: JSON.stringify({
|
|
521
|
+
type: "general",
|
|
522
|
+
query: `Generate Image: ${t}`,
|
|
523
|
+
model: "openai",
|
|
524
|
+
api_key: N || ""
|
|
525
|
+
})
|
|
526
|
+
});
|
|
527
|
+
if (!c.ok) throw new Error(`HTTP ${c.status}`);
|
|
528
|
+
const s = c.body?.getReader();
|
|
529
|
+
if (!s) throw new Error("Stream reader not available");
|
|
530
|
+
const l = new TextDecoder();
|
|
531
|
+
for (; ; ) {
|
|
532
|
+
const { done: b, value: C } = await s.read();
|
|
533
|
+
if (b) break;
|
|
534
|
+
const ce = l.decode(C, { stream: !0 }).split(`
|
|
535
|
+
`);
|
|
536
|
+
for (const M of ce)
|
|
537
|
+
if (!(!M.trim() || !M.startsWith("data: ")))
|
|
538
|
+
try {
|
|
539
|
+
const p = JSON.parse(M.slice(6));
|
|
540
|
+
if (p.type === "image_ready" && p.url)
|
|
541
|
+
return ie(r, p.url, t), s.cancel(), p.url;
|
|
542
|
+
if (p.type === "image_failed")
|
|
543
|
+
throw P(r, p.error || "Image generation failed"), s.cancel(), new Error(p.error || "Image generation failed");
|
|
544
|
+
if (p.type === "error")
|
|
545
|
+
throw P(r, p.error || "Stream error"), s.cancel(), new Error(p.error || "Stream error");
|
|
546
|
+
if (p.type === "stream_end")
|
|
547
|
+
return s.cancel(), "";
|
|
548
|
+
} catch (p) {
|
|
549
|
+
if (p instanceof Error && p.message !== "Stream error" && !p.message.includes("generation failed"))
|
|
550
|
+
continue;
|
|
551
|
+
throw p;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
} catch (c) {
|
|
555
|
+
P(
|
|
556
|
+
r,
|
|
557
|
+
c instanceof Error ? c.message : "Image generation failed"
|
|
558
|
+
), a.error("Image generation failed", {
|
|
559
|
+
description: c instanceof Error ? c.message : "An error occurred"
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
return "";
|
|
563
|
+
}, ie = (t, r, c) => {
|
|
564
|
+
i.update(() => {
|
|
565
|
+
const s = G(), l = (b) => {
|
|
566
|
+
if (L(b) && b.getPlaceholderId() === t) {
|
|
567
|
+
const S = be({
|
|
568
|
+
src: r,
|
|
569
|
+
altText: c,
|
|
570
|
+
originalPrompt: c
|
|
571
|
+
});
|
|
572
|
+
return b.replace(S), !0;
|
|
573
|
+
}
|
|
574
|
+
const C = b.getChildren?.() || [];
|
|
575
|
+
for (const S of C)
|
|
576
|
+
if (l(S)) return !0;
|
|
577
|
+
return !1;
|
|
578
|
+
};
|
|
579
|
+
l(s);
|
|
580
|
+
});
|
|
581
|
+
}, P = (t, r) => {
|
|
582
|
+
i.update(() => {
|
|
583
|
+
const c = G(), s = (l) => {
|
|
584
|
+
if (L(l) && l.getPlaceholderId() === t) {
|
|
585
|
+
l.setError(r);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const b = l.getChildren?.() || [];
|
|
589
|
+
for (const C of b) s(C);
|
|
590
|
+
};
|
|
591
|
+
s(c);
|
|
592
|
+
}), setTimeout(() => {
|
|
593
|
+
i.update(() => {
|
|
594
|
+
const c = G(), s = (l) => {
|
|
595
|
+
if (L(l) && l.getPlaceholderId() === t) {
|
|
596
|
+
l.remove();
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const b = l.getChildren?.() || [];
|
|
600
|
+
for (const C of b) s(C);
|
|
601
|
+
};
|
|
602
|
+
s(c);
|
|
603
|
+
});
|
|
604
|
+
}, 5e3);
|
|
605
|
+
}, ae = (t, r) => {
|
|
606
|
+
try {
|
|
607
|
+
i.dispatchCommand(ye, {
|
|
608
|
+
src: t,
|
|
609
|
+
altText: "Generated image",
|
|
610
|
+
originalPrompt: r
|
|
611
|
+
});
|
|
612
|
+
} catch (c) {
|
|
613
|
+
throw console.error("Error inserting image into editor:", c), c;
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
return D(() => i.registerCommand(
|
|
617
|
+
fe,
|
|
618
|
+
({ type: t }) => ((async () => {
|
|
619
|
+
try {
|
|
620
|
+
await ee(t);
|
|
621
|
+
} catch (r) {
|
|
622
|
+
console.error(`Error on AI stream: ${r}`);
|
|
623
|
+
}
|
|
624
|
+
})(), !0),
|
|
625
|
+
k
|
|
626
|
+
), [i]), D(() => i.registerCommand(
|
|
627
|
+
ge,
|
|
628
|
+
(t) => ((async () => {
|
|
629
|
+
try {
|
|
630
|
+
await oe(t);
|
|
631
|
+
} catch (r) {
|
|
632
|
+
console.error(`Error generating image: ${r}`);
|
|
633
|
+
}
|
|
634
|
+
})(), !0),
|
|
635
|
+
k
|
|
636
|
+
), [i]), D(() => i.registerCommand(
|
|
637
|
+
pe,
|
|
638
|
+
() => (i.getEditorState().read(() => {
|
|
639
|
+
const t = O();
|
|
640
|
+
if (R(t)) {
|
|
641
|
+
const r = t.getTextContent().trim();
|
|
642
|
+
if (!r) {
|
|
643
|
+
a.error("Please select text first", {
|
|
644
|
+
description: "Select some text to translate"
|
|
645
|
+
});
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
g.current = {
|
|
649
|
+
anchor: {
|
|
650
|
+
key: t.anchor.key,
|
|
651
|
+
offset: t.anchor.offset,
|
|
652
|
+
type: t.anchor.type
|
|
653
|
+
},
|
|
654
|
+
focus: {
|
|
655
|
+
key: t.focus.key,
|
|
656
|
+
offset: t.focus.offset,
|
|
657
|
+
type: t.focus.type
|
|
658
|
+
}
|
|
659
|
+
}, v(r), d(!0);
|
|
660
|
+
}
|
|
661
|
+
}), !0),
|
|
662
|
+
k
|
|
663
|
+
), [i]), D(() => i.registerCommand(
|
|
664
|
+
he,
|
|
665
|
+
() => (i.getEditorState().read(() => {
|
|
666
|
+
const t = O();
|
|
667
|
+
if (R(t)) {
|
|
668
|
+
const r = t.getTextContent().trim();
|
|
669
|
+
if (!r) {
|
|
670
|
+
a.error("Please select text first", {
|
|
671
|
+
description: "Select some text to adjust tone"
|
|
672
|
+
});
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
T.current = {
|
|
676
|
+
anchor: {
|
|
677
|
+
key: t.anchor.key,
|
|
678
|
+
offset: t.anchor.offset,
|
|
679
|
+
type: t.anchor.type
|
|
680
|
+
},
|
|
681
|
+
focus: {
|
|
682
|
+
key: t.focus.key,
|
|
683
|
+
offset: t.focus.offset,
|
|
684
|
+
type: t.focus.type
|
|
685
|
+
}
|
|
686
|
+
}, m(r), f(!0);
|
|
687
|
+
}
|
|
688
|
+
}), !0),
|
|
689
|
+
k
|
|
690
|
+
), [i]), /* @__PURE__ */ n(j, { children: [
|
|
691
|
+
/* @__PURE__ */ e(
|
|
692
|
+
Z,
|
|
693
|
+
{
|
|
694
|
+
ref: y,
|
|
695
|
+
onGenerate: ne,
|
|
696
|
+
onInsertImage: ae
|
|
697
|
+
}
|
|
698
|
+
),
|
|
699
|
+
/* @__PURE__ */ e(
|
|
700
|
+
we,
|
|
701
|
+
{
|
|
702
|
+
open: h,
|
|
703
|
+
onOpenChange: d,
|
|
704
|
+
onLanguageSelect: te
|
|
705
|
+
}
|
|
706
|
+
),
|
|
707
|
+
/* @__PURE__ */ e(
|
|
708
|
+
Ce,
|
|
709
|
+
{
|
|
710
|
+
open: x,
|
|
711
|
+
onOpenChange: f,
|
|
712
|
+
onToneSelect: re
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
] });
|
|
716
|
+
};
|
|
717
|
+
export {
|
|
718
|
+
Pe as default
|
|
719
|
+
};
|