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,871 @@
|
|
|
1
|
+
import { jsxs as e, Fragment as tt, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { c as kt, T as Gt, o as Dt, q as Nt, r as Ct, D as Ht, a as jt, b as Kt, d as qt, s as Vt, v as wt, w as St, x as It, y as At, z as q, L as Bt, C as _t, E as Ut, F as Wt, B as mt, G as Yt, S as Pt, P as Ft, H as Jt, J as Qt, K as Xt, X as gt, M as Zt, N as te, O as Tt, t as ht } from "./index-CxOOJD40.js";
|
|
3
|
+
import { useLexicalComposerContext as ee } from "@lexical/react/LexicalComposerContext";
|
|
4
|
+
import { $getSelection as ct, COMMAND_PRIORITY_LOW as bt, $isRangeSelection as yt } from "lexical";
|
|
5
|
+
import { useState as c, useRef as V, useCallback as H, useEffect as R, useMemo as Mt } from "react";
|
|
6
|
+
import { u as re, M as oe } from "./useVoiceToText-DCddJzYF.js";
|
|
7
|
+
import { S as vt } from "./square-DrMKkLmP.js";
|
|
8
|
+
const ie = kt("ArrowUpRight", [
|
|
9
|
+
["path", { d: "M7 7h10v10", key: "1tivn9" }],
|
|
10
|
+
["path", { d: "M7 17 17 7", key: "1vkiza" }]
|
|
11
|
+
]);
|
|
12
|
+
const ce = kt("Send", [
|
|
13
|
+
["path", { d: "m22 2-7 20-4-9-9-4Z", key: "1q3vgg" }],
|
|
14
|
+
["path", { d: "M22 2 11 13", key: "nzbqef" }]
|
|
15
|
+
]);
|
|
16
|
+
function de({
|
|
17
|
+
open: d,
|
|
18
|
+
onOpenChange: C,
|
|
19
|
+
editor: dt,
|
|
20
|
+
apiKey: w,
|
|
21
|
+
initialText: L,
|
|
22
|
+
onShowInEditor: j,
|
|
23
|
+
onStreamStart: B,
|
|
24
|
+
onStreamEnd: z,
|
|
25
|
+
selectedTextForInline: et,
|
|
26
|
+
savedSelection: A
|
|
27
|
+
}) {
|
|
28
|
+
const [a, p] = c(""), [i, f] = c(""), [n, P] = c(!1), [y, T] = c(null), [S, k] = c("chatgpt"), [W, Y] = c(0), [O, K] = c(0), [_, $] = c(!1), [F, x] = c(!0), [m, l] = c("idle"), [G, E] = c(!1), [g, J] = c([]), [Q, st] = c(!1), [rt, nt] = c(!1), X = V(A ?? null), U = V(null), o = Nt(), I = o?.isByokPlan ?? !1, h = o?.byokApiKeys, s = Mt(() => {
|
|
29
|
+
if (!I || !h)
|
|
30
|
+
return ["chatgpt", "claude", "grok", "gemini"];
|
|
31
|
+
const r = [];
|
|
32
|
+
return h.hasOpenaiKey && r.push("chatgpt"), h.hasAnthropicKey && r.push("claude"), h.hasGrokKey && r.push("grok"), h.hasGeminiKey && r.push("gemini"), r;
|
|
33
|
+
}, [I, h]), u = I && s.length === 0, Z = I && !h?.hasAssemblyaiKey;
|
|
34
|
+
R(() => {
|
|
35
|
+
X.current = A ?? null;
|
|
36
|
+
}, [A]), R(() => {
|
|
37
|
+
I && s.length > 0 && !s.includes(S) && k(s[0]);
|
|
38
|
+
}, [I, s, S]), R(() => {
|
|
39
|
+
d && L ? (f(L), p("")) : d || (f(""), p("")), d && w && (nt(!0), Ct(w).then(J).catch(() => {
|
|
40
|
+
}).finally(() => nt(!1)));
|
|
41
|
+
}, [d, L, w]);
|
|
42
|
+
const {
|
|
43
|
+
isRecording: b,
|
|
44
|
+
isPaused: D,
|
|
45
|
+
isLoading: v,
|
|
46
|
+
error: at,
|
|
47
|
+
elapsedTime: Rt,
|
|
48
|
+
toggleRecording: pt,
|
|
49
|
+
pauseRecording: Lt,
|
|
50
|
+
resumeRecording: zt
|
|
51
|
+
} = re({
|
|
52
|
+
onTranscriptUpdate: (r) => {
|
|
53
|
+
p(r);
|
|
54
|
+
},
|
|
55
|
+
apiKey: w
|
|
56
|
+
}), Et = (r) => {
|
|
57
|
+
const N = Math.floor(r / 60), M = r % 60;
|
|
58
|
+
return `${N.toString().padStart(2, "0")}:${M.toString().padStart(2, "0")}`;
|
|
59
|
+
};
|
|
60
|
+
R(() => {
|
|
61
|
+
let r = !0;
|
|
62
|
+
return (async () => {
|
|
63
|
+
try {
|
|
64
|
+
const M = await te({ apiKey: w });
|
|
65
|
+
r && M && ($(!!M.unlimited), Y(Number(M.remainingCredits ?? 0)), K(Number(M.purchasedCredits ?? 0)));
|
|
66
|
+
} catch {
|
|
67
|
+
r && ($(!1), Y(0), K(0));
|
|
68
|
+
} finally {
|
|
69
|
+
r && x(!1);
|
|
70
|
+
}
|
|
71
|
+
})(), () => {
|
|
72
|
+
r = !1;
|
|
73
|
+
};
|
|
74
|
+
}, [w]);
|
|
75
|
+
const ft = (r) => {
|
|
76
|
+
const N = r.toLowerCase();
|
|
77
|
+
return [
|
|
78
|
+
"generate image",
|
|
79
|
+
"generate an image",
|
|
80
|
+
"create image",
|
|
81
|
+
"create an image",
|
|
82
|
+
"make image",
|
|
83
|
+
"make an image",
|
|
84
|
+
"draw",
|
|
85
|
+
"illustration",
|
|
86
|
+
"picture of",
|
|
87
|
+
"image of",
|
|
88
|
+
"photo of",
|
|
89
|
+
"generate picture",
|
|
90
|
+
"create picture",
|
|
91
|
+
"visualize",
|
|
92
|
+
"render image",
|
|
93
|
+
"design image",
|
|
94
|
+
"produce image"
|
|
95
|
+
].some((it) => N.includes(it));
|
|
96
|
+
}, Ot = H(() => {
|
|
97
|
+
U.current && (U.current.abort(), U.current = null);
|
|
98
|
+
}, []), xt = async () => {
|
|
99
|
+
if (!a.trim() || n) return;
|
|
100
|
+
const r = i && i.trim() !== "";
|
|
101
|
+
let N;
|
|
102
|
+
const M = ft(a) || i && ft(i);
|
|
103
|
+
M ? N = r ? `${a}: ${i}` : a : r ? N = `${a}
|
|
104
|
+
IMPORTANT: Return ONLY the modified/transformed text. Do NOT include any labels, prefixes, explanations, or formatting like "Simplified:", "Result:", "Here is", etc. Just return the pure result text.
|
|
105
|
+
Text to transform:
|
|
106
|
+
"${i}"
|
|
107
|
+
` : N = a;
|
|
108
|
+
const it = new AbortController();
|
|
109
|
+
U.current = it, await Tt({
|
|
110
|
+
editor: dt,
|
|
111
|
+
query: N,
|
|
112
|
+
model: S,
|
|
113
|
+
apiKey: w || "",
|
|
114
|
+
originalPrompt: a,
|
|
115
|
+
savedSelection: X.current,
|
|
116
|
+
abortSignal: it.signal,
|
|
117
|
+
onStatusChange: (ut) => l(ut),
|
|
118
|
+
onLoadingChange: P,
|
|
119
|
+
onStreamStart: () => {
|
|
120
|
+
C(!1), B && B(it, S, !!M);
|
|
121
|
+
},
|
|
122
|
+
onInputClear: () => {
|
|
123
|
+
p(""), f("");
|
|
124
|
+
},
|
|
125
|
+
onError: (ut) => {
|
|
126
|
+
ht.error(ut), E(!0), P(!1), z && z(), ot(!0);
|
|
127
|
+
},
|
|
128
|
+
onSuccess: () => {
|
|
129
|
+
E(!0), P(!1), z && z(), ot(!0);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}, ot = (r) => {
|
|
133
|
+
if (n && !r) {
|
|
134
|
+
Ot();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
U.current = null, p(""), f(""), T(null), C(!1);
|
|
138
|
+
}, $t = (r) => {
|
|
139
|
+
switch (r) {
|
|
140
|
+
case "chatgpt":
|
|
141
|
+
return "OpenAI ChatGPT";
|
|
142
|
+
case "claude":
|
|
143
|
+
return "Anthropic Claude";
|
|
144
|
+
case "grok":
|
|
145
|
+
return "xAI Grok";
|
|
146
|
+
case "gemini":
|
|
147
|
+
return "Google Gemini";
|
|
148
|
+
default:
|
|
149
|
+
return "OpenAI ChatGPT";
|
|
150
|
+
}
|
|
151
|
+
}, lt = V(null);
|
|
152
|
+
return R(() => {
|
|
153
|
+
if (lt.current) {
|
|
154
|
+
const r = lt.current;
|
|
155
|
+
r.style.height = "auto", r.style.height = `${r.scrollHeight}px`;
|
|
156
|
+
}
|
|
157
|
+
}, [a]), /* @__PURE__ */ t(tt, { children: /* @__PURE__ */ t(Ht, { open: d, onOpenChange: () => ot(), children: /* @__PURE__ */ e(jt, { className: "sm:cteditor-max-w-[60rem] cteditor-max-w-[calc(100%-2rem)] cteditor-rounded-lg [&>.closeDialog]:cteditor-top-1.5 [&>.closeDialog]:cteditor-right-1.5 !cteditor-gap-3", children: [
|
|
158
|
+
/* @__PURE__ */ t(Kt, { children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-gap-4 cteditor-flex-col", children: [
|
|
159
|
+
/* @__PURE__ */ e(qt, { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xl cteditor-mb-1 !cteditor-font-medium", children: [
|
|
160
|
+
/* @__PURE__ */ t(Vt, {}),
|
|
161
|
+
/* @__PURE__ */ e("div", { children: [
|
|
162
|
+
/* @__PURE__ */ t("span", { children: "Ask AI" }),
|
|
163
|
+
/* @__PURE__ */ t("div", { className: "cteditor-text-xs cteditor-pt-1 cteditor-text-foreground/50", children: "Quick assistance for improving, translating, or explaining your content." })
|
|
164
|
+
] })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-gap-3 cteditor-justify-between cteditor-items-center", children: [
|
|
167
|
+
/* @__PURE__ */ e("div", { children: [
|
|
168
|
+
/* @__PURE__ */ t("label", { className: "cteditor-block cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-1 cteditor-font-medium", children: "Choose AI Provider" }),
|
|
169
|
+
/* @__PURE__ */ t("div", { className: "cteditor-min-w-[160px]", children: /* @__PURE__ */ t("div", { className: "cteditor-relative", children: /* @__PURE__ */ e(
|
|
170
|
+
wt,
|
|
171
|
+
{
|
|
172
|
+
value: s.includes(S) ? S : s[0] ?? "chatgpt",
|
|
173
|
+
onValueChange: (r) => k(r),
|
|
174
|
+
disabled: u,
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ t(St, { className: "cteditor-w-full cteditor-text-xs !cteditor-py-1 !cteditor-h-8", children: /* @__PURE__ */ t(It, { placeholder: "Select provider" }) }),
|
|
177
|
+
/* @__PURE__ */ e(At, { children: [
|
|
178
|
+
s.includes("chatgpt") && /* @__PURE__ */ t(q, { value: "chatgpt", children: "OpenAI ChatGPT" }),
|
|
179
|
+
s.includes("claude") && /* @__PURE__ */ t(q, { value: "claude", children: "Anthropic Claude" }),
|
|
180
|
+
s.includes("grok") && /* @__PURE__ */ t(q, { value: "grok", children: "xAI Grok" }),
|
|
181
|
+
s.includes("gemini") && /* @__PURE__ */ t(q, { value: "gemini", children: "Google Gemini" })
|
|
182
|
+
] })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
) }) })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5 cteditor-text-xs", children: F ? /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-accent cteditor-rounded-md cteditor-px-3 cteditor-py-1.5 cteditor-animate-pulse cteditor-min-w-[90px]", children: [
|
|
188
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-16 cteditor-bg-foreground/15 cteditor-rounded cteditor-mb-1" }),
|
|
189
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-4 cteditor-w-12 cteditor-bg-foreground/15 cteditor-rounded" })
|
|
190
|
+
] }) : _ ? /* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-rounded-md cteditor-bg-green-500/10 cteditor-px-3 cteditor-py-1.5 cteditor-min-h-11", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-leading-none cteditor-gap-0.5", children: [
|
|
191
|
+
/* @__PURE__ */ t("span", { className: "cteditor-font-medium cteditor-text-green-600 cteditor-text-[11px]", children: "Your API Key" }),
|
|
192
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-muted-foreground cteditor-text-[10px]", children: "No credit usage" })
|
|
193
|
+
] }) }) : /* @__PURE__ */ e(tt, { children: [
|
|
194
|
+
/* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-accent/80 cteditor-rounded-md cteditor-px-3 cteditor-py-1.5 cteditor-min-w-[90px] cteditor-justify-center", children: [
|
|
195
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-[11px] cteditor-font-medium cteditor-text-muted-foreground cteditor-mb-0.5", children: "Credits Left" }),
|
|
196
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground cteditor-leading-none", children: W + O })
|
|
197
|
+
] }),
|
|
198
|
+
O > 0 && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-flex-col cteditor-bg-green-500/10 cteditor-border-l-2 cteditor-border-green-600 cteditor-rounded-r-md cteditor-rounded-l-sm cteditor-px-3 cteditor-py-1.5 cteditor-min-w-[90px] cteditor-justify-center", children: [
|
|
199
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-[11px] cteditor-font-medium cteditor-text-muted-foreground cteditor-mb-0.5", children: "Purchased" }),
|
|
200
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-green-500 cteditor-leading-none", children: O })
|
|
201
|
+
] })
|
|
202
|
+
] }) })
|
|
203
|
+
] }) })
|
|
204
|
+
] }) }),
|
|
205
|
+
u && /* @__PURE__ */ t("div", { className: "cteditor-rounded-md cteditor-bg-amber-500/10 cteditor-border cteditor-border-amber-500/30 cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-text-amber-800 dark:cteditor-text-amber-200", children: "Add at least one AI provider key in License Section > Manage API Keys to use AI Chat." }),
|
|
206
|
+
/* @__PURE__ */ e("div", { className: "cteditor-space-y-4 ", children: [
|
|
207
|
+
/* @__PURE__ */ e("div", { children: [
|
|
208
|
+
/* @__PURE__ */ t("div", { className: "cteditor-flex cteditor-justify-between cteditor-gap-1 cteditor-min-h-8 cteditor-items-center", children: /* @__PURE__ */ t(
|
|
209
|
+
Bt,
|
|
210
|
+
{
|
|
211
|
+
htmlFor: "ai-prompt",
|
|
212
|
+
className: "cteditor-text-sm cteditor-font-medium cteditor-mb-0 cteditor-block",
|
|
213
|
+
children: i && i.trim() !== "" ? "Your Instruction" : "Your Question"
|
|
214
|
+
}
|
|
215
|
+
) }),
|
|
216
|
+
/* @__PURE__ */ t("div", { className: "cteditor-relative cteditor-mb-2 ", children: /* @__PURE__ */ e("div", { className: `cteditor-border cteditor-border-foreground/15 cteditor-bg-background cteditor-rounded-md cteditor-pb-14
|
|
217
|
+
${b && !D ? "!cteditor-border-rose-400" : ""}
|
|
218
|
+
${D ? "!cteditor-border-amber-400" : ""}
|
|
219
|
+
`, children: [
|
|
220
|
+
/* @__PURE__ */ t(
|
|
221
|
+
"textarea",
|
|
222
|
+
{
|
|
223
|
+
ref: lt,
|
|
224
|
+
id: "ai-prompt",
|
|
225
|
+
placeholder: v ? "Initializing microphone..." : b ? D ? "Paused..." : "Listening..." : i && i.trim() !== "" ? "e.g., Improve this, translate to Spanish, summarize, fix grammar..." : "e.g., Write a paragraph about..., Generate an image of...",
|
|
226
|
+
value: a,
|
|
227
|
+
onChange: (r) => p(r.target.value),
|
|
228
|
+
disabled: n || b || v || u,
|
|
229
|
+
rows: 1,
|
|
230
|
+
onInput: (r) => {
|
|
231
|
+
if (r.currentTarget.value === "") return;
|
|
232
|
+
const N = r.currentTarget;
|
|
233
|
+
N.style.height = "auto", N.style.height = `${N.scrollHeight}px`;
|
|
234
|
+
},
|
|
235
|
+
onKeyDown: (r) => {
|
|
236
|
+
r.key === "Enter" && !r.shiftKey && !n && a.trim() && (r.preventDefault(), xt());
|
|
237
|
+
},
|
|
238
|
+
className: `cteditor-w-full cteditor-block cteditor-transition-all cteditor-border-none cteditor-bg-transparent cteditor-resize-none cteditor-outline-0 cteditor-outline-none cteditor-p-2 cteditor-min-h-52 cteditor-text-xs cteditor-overflow-clip
|
|
239
|
+
${b ? "" : "cteditor-max-h-[47vh] cteditor-overflow-y-auto"}`
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
/* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-right-4 cteditor-bottom-4 cteditor-gap-1 cteditor-flex", children: [
|
|
243
|
+
/* @__PURE__ */ t(_t, { delayDuration: 200, children: /* @__PURE__ */ e(Ut, { children: [
|
|
244
|
+
/* @__PURE__ */ t(Wt, { asChild: !0, children: /* @__PURE__ */ e(
|
|
245
|
+
mt,
|
|
246
|
+
{
|
|
247
|
+
variant: "link",
|
|
248
|
+
onClick: () => {
|
|
249
|
+
j && (j(S, et), ot());
|
|
250
|
+
},
|
|
251
|
+
disabled: n,
|
|
252
|
+
className: "md:cteditor-mr-auto [&>svg]:!cteditor-size-3 !cteditor-px-2 cteditor-text-xs !cteditor-h-8 cteditor-no-underline",
|
|
253
|
+
children: [
|
|
254
|
+
"Show in Editor",
|
|
255
|
+
/* @__PURE__ */ t(ie, {})
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
) }),
|
|
259
|
+
/* @__PURE__ */ t(Yt, { children: /* @__PURE__ */ t("p", { children: "Show AI prompt in the editor text area" }) })
|
|
260
|
+
] }) }),
|
|
261
|
+
/* @__PURE__ */ t(
|
|
262
|
+
mt,
|
|
263
|
+
{
|
|
264
|
+
variant: "outline",
|
|
265
|
+
onClick: () => ot(),
|
|
266
|
+
disabled: n,
|
|
267
|
+
className: "[&>svg]:!cteditor-size-3 !cteditor-px-3 cteditor-text-xs !cteditor-h-8",
|
|
268
|
+
children: "Cancel"
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
/* @__PURE__ */ e(
|
|
272
|
+
mt,
|
|
273
|
+
{
|
|
274
|
+
onClick: xt,
|
|
275
|
+
disabled: !a.trim() || u,
|
|
276
|
+
className: "[&>svg]:!cteditor-size-3 !cteditor-px-3 cteditor-text-xs !cteditor-h-8 !gap-1",
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ t(Pt, {}),
|
|
279
|
+
"Ask AI"
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
] }),
|
|
284
|
+
!b && /* @__PURE__ */ t("div", { className: "cteditor-absolute cteditor-left-4 cteditor-bottom-4 ", children: /* @__PURE__ */ t(
|
|
285
|
+
"button",
|
|
286
|
+
{
|
|
287
|
+
type: "button",
|
|
288
|
+
onClick: pt,
|
|
289
|
+
disabled: n || v || Z,
|
|
290
|
+
className: `cteditor-rounded-full cteditor-transition-all cteditor-size-6 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center ${!v && !Z && ""} ${Z ? "cteditor-opacity-60 cteditor-cursor-not-allowed" : v ? "cteditor-text-gray-500 dark:cteditor-text-gray-400 cteditor-cursor-not-allowed" : b ? "cteditor-text-rose-600 dark:cteditor-text-rose-400 hover:cteditor-bg-rose-100 dark:hover:cteditor-bg-rose-900/30 " + (D ? "" : "cteditor-animate-pulse") : "cteditor-text-foreground hover:cteditor-bg-foreground hover:cteditor-text-background"}`,
|
|
291
|
+
title: Z ? "Add your AssemblyAI key in License Section > Manage API Keys to use voice input." : v ? "Initializing microphone..." : b ? "Stop recording" : "Start voice input",
|
|
292
|
+
children: v ? /* @__PURE__ */ e(
|
|
293
|
+
"svg",
|
|
294
|
+
{
|
|
295
|
+
className: "cteditor-w-5 cteditor-h-5 cteditor-animate-spin",
|
|
296
|
+
fill: "none",
|
|
297
|
+
viewBox: "0 0 24 24",
|
|
298
|
+
children: [
|
|
299
|
+
/* @__PURE__ */ t(
|
|
300
|
+
"circle",
|
|
301
|
+
{
|
|
302
|
+
className: "cteditor-opacity-25",
|
|
303
|
+
cx: "12",
|
|
304
|
+
cy: "12",
|
|
305
|
+
r: "10",
|
|
306
|
+
stroke: "currentColor",
|
|
307
|
+
strokeWidth: "4"
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
/* @__PURE__ */ t(
|
|
311
|
+
"path",
|
|
312
|
+
{
|
|
313
|
+
className: "cteditor-opacity-75",
|
|
314
|
+
fill: "currentColor",
|
|
315
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
) : b ? null : /* @__PURE__ */ t(oe, { size: 18 })
|
|
321
|
+
}
|
|
322
|
+
) }),
|
|
323
|
+
b && /* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-left-4 cteditor-bottom-4 cteditor-flex cteditor-gap-1 cteditor-justify-end cteditor-items-center", children: [
|
|
324
|
+
/* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1", children: [
|
|
325
|
+
b && /* @__PURE__ */ t(
|
|
326
|
+
"button",
|
|
327
|
+
{
|
|
328
|
+
type: "button",
|
|
329
|
+
onClick: D ? zt : Lt,
|
|
330
|
+
disabled: n || v,
|
|
331
|
+
className: ` cteditor-rounded-full cteditor-transition-all cteditor-size-6 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center [&>svg]:cteditor-w-full [&>svg]:cteditor-h-full ${D ? "cteditor-text-amber-600 dark:cteditor-text-amber-400 hover:cteditor-bg-amber-100 dark:hover:cteditor-bg-amber-900/30" : "cteditor-text-gray-600 dark:cteditor-text-gray-400 hover:cteditor-bg-gray-200 dark:hover:cteditor-bg-gray-800"}`,
|
|
332
|
+
title: D ? "Resume recording" : "Pause recording",
|
|
333
|
+
children: D ? /* @__PURE__ */ t(Ft, {}) : /* @__PURE__ */ t(Jt, {})
|
|
334
|
+
}
|
|
335
|
+
),
|
|
336
|
+
b && !v && /* @__PURE__ */ t(
|
|
337
|
+
"button",
|
|
338
|
+
{
|
|
339
|
+
type: "button",
|
|
340
|
+
onClick: pt,
|
|
341
|
+
disabled: n || v,
|
|
342
|
+
className: `cteditor-rounded-full cteditor-transition-all cteditor-size-6 cteditor-flex-none cteditor-flex cteditor-items-center cteditor-justify-center [&>svg]:cteditor-w-full [&>svg]:cteditor-h-full
|
|
343
|
+
${v ? "cteditor-text-gray-500 dark:cteditor-text-gray-400 cteditor-cursor-not-allowed" : b ? "cteditor-text-rose-600 dark:cteditor-text-rose-400 hover:cteditor-bg-rose-100 dark:hover:cteditor-bg-rose-900/30 " + (D ? "" : "cteditor-animate-pulse") : "cteditor-text-foreground hover:cteditor-bg-foreground hover:cteditor-text-background"}`,
|
|
344
|
+
title: v ? "Initializing microphone..." : b ? "Stop recording" : "Start voice input",
|
|
345
|
+
children: /* @__PURE__ */ t(Qt, {})
|
|
346
|
+
}
|
|
347
|
+
)
|
|
348
|
+
] }),
|
|
349
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-xs", children: Et(Rt) })
|
|
350
|
+
] })
|
|
351
|
+
] }) }),
|
|
352
|
+
!b && !at && !v && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-text-xs cteditor-text-muted-foreground", children: [
|
|
353
|
+
/* @__PURE__ */ t(
|
|
354
|
+
"svg",
|
|
355
|
+
{
|
|
356
|
+
className: "cteditor-w-4 cteditor-h-4 cteditor-opacity-60",
|
|
357
|
+
fill: "none",
|
|
358
|
+
stroke: "currentColor",
|
|
359
|
+
viewBox: "0 0 24 24",
|
|
360
|
+
children: /* @__PURE__ */ t(
|
|
361
|
+
"path",
|
|
362
|
+
{
|
|
363
|
+
strokeLinecap: "round",
|
|
364
|
+
strokeLinejoin: "round",
|
|
365
|
+
strokeWidth: 2,
|
|
366
|
+
d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ t("span", { children: i && i.trim() !== "" ? "Enter what you want to do with the selected text, or use voice input" : "Type your question or click the microphone icon to use voice input" })
|
|
372
|
+
] }),
|
|
373
|
+
!b && !n && (!i || i.trim() === "") && /* @__PURE__ */ e(tt, { children: [
|
|
374
|
+
rt && /* @__PURE__ */ t("div", { className: "cteditor-mt-3 cteditor-rounded-lg cteditor-border cteditor-border-foreground/10 cteditor-bg-accent/30 cteditor-p-3 cteditor-animate-pulse", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-3", children: [
|
|
375
|
+
/* @__PURE__ */ e("div", { className: "cteditor-flex-1 cteditor-space-y-1.5", children: [
|
|
376
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-full cteditor-bg-foreground/10 cteditor-rounded" }),
|
|
377
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-2/3 cteditor-bg-foreground/10 cteditor-rounded" })
|
|
378
|
+
] }),
|
|
379
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-7 cteditor-w-20 cteditor-bg-foreground/10 cteditor-rounded-md" })
|
|
380
|
+
] }) }),
|
|
381
|
+
!rt && g.length > 0 && /* @__PURE__ */ e("div", { className: "cteditor-mt-3 cteditor-space-y-2", children: [
|
|
382
|
+
/* @__PURE__ */ e("div", { className: "cteditor-rounded-lg cteditor-border cteditor-border-foreground/10 cteditor-bg-accent/30 cteditor-p-3 cteditor-flex cteditor-gap-3 cteditor-items-center", children: [
|
|
383
|
+
/* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-start cteditor-flex-col cteditor-gap-0.5", children: [
|
|
384
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground cteditor-truncate", children: "Last Prompt" }),
|
|
385
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-foreground/60 cteditor-flex-1 cteditor-leading-relaxed cteditor-line-clamp-1", children: g[0].prompt })
|
|
386
|
+
] }),
|
|
387
|
+
/* @__PURE__ */ t(
|
|
388
|
+
"button",
|
|
389
|
+
{
|
|
390
|
+
type: "button",
|
|
391
|
+
onClick: () => p(g[0].prompt),
|
|
392
|
+
className: "cteditor-shrink-0 cteditor-text-[11px] cteditor-font-medium cteditor-px-2 cteditor-py-1.5 cteditor-rounded-md cteditor-border cteditor-border-foreground/10 cteditor-bg-background hover:cteditor-bg-accent cteditor-text-foreground cteditor-transition-colors cteditor-ml-auto",
|
|
393
|
+
children: "Use prompt"
|
|
394
|
+
}
|
|
395
|
+
)
|
|
396
|
+
] }),
|
|
397
|
+
g.length > 1 && /* @__PURE__ */ e(tt, { children: [
|
|
398
|
+
/* @__PURE__ */ e(
|
|
399
|
+
"button",
|
|
400
|
+
{
|
|
401
|
+
type: "button",
|
|
402
|
+
onClick: () => st((r) => !r),
|
|
403
|
+
className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-1.5 cteditor-w-full cteditor-text-xs cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-py-1",
|
|
404
|
+
children: [
|
|
405
|
+
/* @__PURE__ */ t(
|
|
406
|
+
Xt,
|
|
407
|
+
{
|
|
408
|
+
size: 14,
|
|
409
|
+
className: `cteditor-transition-transform cteditor-duration-200 ${Q ? "cteditor-rotate-180" : ""}`
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
Q ? "Hide Prompts" : "View More Prompts"
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
Q && /* @__PURE__ */ t("div", { className: "cteditor-space-y-2", children: g.slice(1).map((r) => /* @__PURE__ */ t(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: "cteditor-rounded-lg cteditor-border cteditor-border-foreground/10 cteditor-bg-accent/30 cteditor-p-3",
|
|
420
|
+
children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-start cteditor-gap-3", children: [
|
|
421
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-flex-1 cteditor-leading-relaxed", children: r.prompt }),
|
|
422
|
+
/* @__PURE__ */ t(
|
|
423
|
+
"button",
|
|
424
|
+
{
|
|
425
|
+
type: "button",
|
|
426
|
+
onClick: () => p(r.prompt),
|
|
427
|
+
className: "cteditor-shrink-0 cteditor-text-xs cteditor-font-medium cteditor-px-3 cteditor-py-1.5 cteditor-rounded-md cteditor-border cteditor-border-foreground/15 cteditor-bg-background hover:cteditor-bg-accent cteditor-text-foreground cteditor-transition-colors",
|
|
428
|
+
children: "Use prompt"
|
|
429
|
+
}
|
|
430
|
+
)
|
|
431
|
+
] })
|
|
432
|
+
},
|
|
433
|
+
r.id
|
|
434
|
+
)) })
|
|
435
|
+
] })
|
|
436
|
+
] })
|
|
437
|
+
] }),
|
|
438
|
+
i && i.trim() !== "" && /* @__PURE__ */ e("div", { className: "cteditor-space-y-2 cteditor-mt-2", children: [
|
|
439
|
+
/* @__PURE__ */ e("div", { className: "cteditor-p-3 cteditor-rounded-md cteditor-bg-accent/50 cteditor-relative cteditor-max-h-24 cteditor-overflow-y-auto cteditor-pr-12", children: [
|
|
440
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground cteditor-truncate", children: "Selected Text" }),
|
|
441
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-foreground/60 cteditor-flex-1 cteditor-leading-relaxed cteditor-line-clamp-1", children: i.length > 300 ? i.substring(0, 300) + "..." : i }),
|
|
442
|
+
/* @__PURE__ */ t(
|
|
443
|
+
"button",
|
|
444
|
+
{
|
|
445
|
+
type: "button",
|
|
446
|
+
onClick: () => f(""),
|
|
447
|
+
className: "cteditor-right-2 cteditor-top-1/2 cteditor--translate-y-1/2 cteditor-p-1 cteditor-text-xs cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-absolute ",
|
|
448
|
+
title: "Clear selected text",
|
|
449
|
+
children: /* @__PURE__ */ t(gt, { size: 14 })
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
] }),
|
|
453
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: "Your prompt will be applied to this selected text" })
|
|
454
|
+
] })
|
|
455
|
+
] }),
|
|
456
|
+
v && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-gray-100 dark:cteditor-bg-gray-900/50 cteditor-border cteditor-border-gray-300 dark:cteditor-border-gray-700", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
|
|
457
|
+
/* @__PURE__ */ e(
|
|
458
|
+
"svg",
|
|
459
|
+
{
|
|
460
|
+
className: "cteditor-w-4 cteditor-h-4 cteditor-animate-spin cteditor-text-gray-600 dark:cteditor-text-gray-400",
|
|
461
|
+
fill: "none",
|
|
462
|
+
viewBox: "0 0 24 24",
|
|
463
|
+
children: [
|
|
464
|
+
/* @__PURE__ */ t(
|
|
465
|
+
"circle",
|
|
466
|
+
{
|
|
467
|
+
className: "cteditor-opacity-25",
|
|
468
|
+
cx: "12",
|
|
469
|
+
cy: "12",
|
|
470
|
+
r: "10",
|
|
471
|
+
stroke: "currentColor",
|
|
472
|
+
strokeWidth: "4"
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
/* @__PURE__ */ t(
|
|
476
|
+
"path",
|
|
477
|
+
{
|
|
478
|
+
className: "cteditor-opacity-75",
|
|
479
|
+
fill: "currentColor",
|
|
480
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
481
|
+
}
|
|
482
|
+
)
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
),
|
|
486
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-gray-700 dark:cteditor-text-gray-300", children: "Initializing microphone... Please allow microphone access." })
|
|
487
|
+
] }) }),
|
|
488
|
+
at && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-red-50 dark:cteditor-bg-red-950/20 cteditor-border cteditor-border-red-200 dark:cteditor-border-red-800", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
|
|
489
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-red-600 dark:cteditor-text-red-400", children: "⚠️" }),
|
|
490
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-red-700 dark:cteditor-text-red-300", children: at })
|
|
491
|
+
] }) }),
|
|
492
|
+
y && /* @__PURE__ */ t("div", { className: "cteditor-p-3 cteditor-rounded-lg cteditor-bg-destructive/10 cteditor-border cteditor-border-destructive/20", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
|
|
493
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-destructive", children: "⚠️" }),
|
|
494
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-sm cteditor-text-destructive", children: y })
|
|
495
|
+
] }) }),
|
|
496
|
+
n && /* @__PURE__ */ t("div", { className: "cteditor-p-4 cteditor-rounded-lg cteditor-bg-gray-100 dark:cteditor-bg-gray-900/50 cteditor-border cteditor-border-gray-300 dark:cteditor-border-gray-700", children: /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-3", children: [
|
|
497
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-5 cteditor-w-5 cteditor-animate-spin cteditor-rounded-full cteditor-border-2 cteditor-border-gray-700 dark:cteditor-border-gray-300 cteditor-border-t-transparent" }),
|
|
498
|
+
/* @__PURE__ */ e("div", { children: [
|
|
499
|
+
/* @__PURE__ */ e("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-text-gray-900 dark:cteditor-text-gray-100", children: [
|
|
500
|
+
$t(S),
|
|
501
|
+
" is thinking..."
|
|
502
|
+
] }),
|
|
503
|
+
/* @__PURE__ */ t("p", { className: "cteditor-text-xs cteditor-text-gray-600 dark:cteditor-text-gray-400 cteditor-mt-1", children: "This may take a few seconds. Please wait." })
|
|
504
|
+
] })
|
|
505
|
+
] }) })
|
|
506
|
+
] })
|
|
507
|
+
] }) }) });
|
|
508
|
+
}
|
|
509
|
+
function ne({
|
|
510
|
+
editor: d,
|
|
511
|
+
apiKey: C,
|
|
512
|
+
initialProvider: dt,
|
|
513
|
+
selectedText: w,
|
|
514
|
+
onClose: L,
|
|
515
|
+
anchorElem: j,
|
|
516
|
+
isStreamingFromModal: B = !1,
|
|
517
|
+
isImageStreaming: z = !1,
|
|
518
|
+
onStopStreaming: et,
|
|
519
|
+
onReopenModal: A
|
|
520
|
+
}) {
|
|
521
|
+
const [a, p] = c(dt), [i, f] = c(""), [n, P] = c(!1), [y, T] = c("idle"), [S, k] = c(!0), [W, Y] = c([]), [O, K] = c(!1), _ = V(null), $ = V(null), F = Nt(), x = F?.isByokPlan ?? !1, m = F?.byokApiKeys, l = Mt(() => {
|
|
522
|
+
if (!x || !m)
|
|
523
|
+
return ["chatgpt", "claude", "grok", "gemini"];
|
|
524
|
+
const o = [];
|
|
525
|
+
return m.hasOpenaiKey && o.push("chatgpt"), m.hasAnthropicKey && o.push("claude"), m.hasGrokKey && o.push("grok"), m.hasGeminiKey && o.push("gemini"), o;
|
|
526
|
+
}, [x, m]), G = x && l.length === 0;
|
|
527
|
+
R(() => {
|
|
528
|
+
x && l.length > 0 && !l.includes(a) && p(l[0]);
|
|
529
|
+
}, [x, l, a]);
|
|
530
|
+
const E = V(null), [g, J] = c(w);
|
|
531
|
+
R(() => {
|
|
532
|
+
d.getEditorState().read(() => {
|
|
533
|
+
const o = ct();
|
|
534
|
+
o && (E.current = o.clone());
|
|
535
|
+
});
|
|
536
|
+
}, [d]), R(() => {
|
|
537
|
+
const o = d.registerUpdateListener(({ editorState: I }) => {
|
|
538
|
+
I.read(() => {
|
|
539
|
+
const h = ct();
|
|
540
|
+
if (h && yt(h) && h.getTextContent().trim()) {
|
|
541
|
+
const s = h.getTextContent();
|
|
542
|
+
s.trim() !== "" && (J(s), E.current = h.clone(), T("idle"), k(!0));
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
return () => {
|
|
547
|
+
o();
|
|
548
|
+
};
|
|
549
|
+
}, [d]), R(() => {
|
|
550
|
+
_.current && _.current.focus(), C && Ct(C).then(Y).catch(() => {
|
|
551
|
+
});
|
|
552
|
+
}, [C]), R(() => {
|
|
553
|
+
if (!O) return;
|
|
554
|
+
const o = () => K(!1);
|
|
555
|
+
return document.addEventListener("click", o), () => document.removeEventListener("click", o);
|
|
556
|
+
}, [O]);
|
|
557
|
+
const Q = (o) => {
|
|
558
|
+
const I = o.toLowerCase();
|
|
559
|
+
return [
|
|
560
|
+
"generate image",
|
|
561
|
+
"generate an image",
|
|
562
|
+
"create image",
|
|
563
|
+
"create an image",
|
|
564
|
+
"make image",
|
|
565
|
+
"make an image",
|
|
566
|
+
"draw",
|
|
567
|
+
"illustration",
|
|
568
|
+
"picture of",
|
|
569
|
+
"image of",
|
|
570
|
+
"photo of",
|
|
571
|
+
"generate picture",
|
|
572
|
+
"create picture",
|
|
573
|
+
"visualize",
|
|
574
|
+
"render image",
|
|
575
|
+
"design image",
|
|
576
|
+
"produce image"
|
|
577
|
+
].some((s) => I.includes(s));
|
|
578
|
+
}, st = H(() => {
|
|
579
|
+
$.current && ($.current.abort(), $.current = null);
|
|
580
|
+
}, []), rt = async () => {
|
|
581
|
+
if (!i.trim() || n) return;
|
|
582
|
+
d.getEditorState().read(() => {
|
|
583
|
+
const u = ct();
|
|
584
|
+
u && yt(u) && (E.current = u.clone());
|
|
585
|
+
});
|
|
586
|
+
const o = new AbortController();
|
|
587
|
+
$.current = o, P(!0);
|
|
588
|
+
const I = Q(i) || g && Q(g), h = g && g.trim() !== "";
|
|
589
|
+
i.length + (h ? g.length : 0);
|
|
590
|
+
let s;
|
|
591
|
+
I ? h ? s = `${i}: ${g}` : s = i : h ? s = `${i}
|
|
592
|
+
|
|
593
|
+
IMPORTANT: Return ONLY the modified/transformed text. Do NOT include any labels, prefixes, explanations, or formatting like "Simplified:", "Result:", "Here is", etc. Just return the pure result text.
|
|
594
|
+
|
|
595
|
+
Text to transform:
|
|
596
|
+
"${g}"` : s = i;
|
|
597
|
+
try {
|
|
598
|
+
await Tt({
|
|
599
|
+
editor: d,
|
|
600
|
+
query: s,
|
|
601
|
+
model: a === "chatgpt" ? "chatgpt" : a,
|
|
602
|
+
apiKey: C || "",
|
|
603
|
+
type: "general",
|
|
604
|
+
savedSelection: E.current,
|
|
605
|
+
originalPrompt: i,
|
|
606
|
+
abortSignal: o.signal,
|
|
607
|
+
onStreamStart: () => {
|
|
608
|
+
},
|
|
609
|
+
onInputClear: () => {
|
|
610
|
+
f(""), J("");
|
|
611
|
+
},
|
|
612
|
+
onStatusChange: (u) => {
|
|
613
|
+
u !== "loading" && (T(u), k(!0));
|
|
614
|
+
},
|
|
615
|
+
onLoadingChange: (u) => {
|
|
616
|
+
P(u);
|
|
617
|
+
},
|
|
618
|
+
onSuccess: () => {
|
|
619
|
+
f(""), J(""), T("success"), k(!0), P(!1), d.focus();
|
|
620
|
+
},
|
|
621
|
+
onError: (u) => {
|
|
622
|
+
ht.error(u), T("error"), k(!0), P(!1);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
} catch (u) {
|
|
626
|
+
console.error("Error processing AI action:", u);
|
|
627
|
+
const Z = u instanceof Error ? u.message : "Error processing your request. Please try again.";
|
|
628
|
+
ht.error(Z), T("error"), k(!0), P(!1);
|
|
629
|
+
}
|
|
630
|
+
}, nt = (o) => {
|
|
631
|
+
o.key === "Enter" && !o.shiftKey && !n && i.trim() && (o.preventDefault(), rt()), o.key === "Escape" && L();
|
|
632
|
+
}, X = g && g.trim() !== "", U = X ? g.length > 50 ? g.substring(0, 50) + "..." : g : "";
|
|
633
|
+
return /* @__PURE__ */ e("div", { className: "cteditor-absolute cteditor-bottom-1 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-flex cteditor-flex-col cteditor-gap-2 cteditor-bg-main-background cteditor-px-2 cteditor-py-2 cteditor-rounded-md cteditor-border cteditor-border-border cteditor-shadow-lg cteditor-z-10 cteditor-max-w-[550px] cteditor-w-full", children: [
|
|
634
|
+
B && /* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-2 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-bg-blue-500/10 cteditor-border cteditor-border-blue-500/20", children: [
|
|
635
|
+
/* @__PURE__ */ t("div", { className: "cteditor-h-3 cteditor-w-3 cteditor-rounded-full cteditor-bg-blue-500 cteditor-animate-pulse cteditor-shrink-0" }),
|
|
636
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-blue-600 dark:cteditor-text-blue-300 cteditor-flex-1", children: z ? "AI is generating image..." : "AI is writing content..." }),
|
|
637
|
+
!z && /* @__PURE__ */ e(
|
|
638
|
+
"button",
|
|
639
|
+
{
|
|
640
|
+
type: "button",
|
|
641
|
+
onClick: et,
|
|
642
|
+
className: "cteditor-h-6 cteditor-px-2 cteditor-bg-red-600 cteditor-text-white cteditor-rounded cteditor-text-xs cteditor-flex cteditor-items-center cteditor-gap-1 cteditor-shrink-0 cteditor-cursor-pointer hover:cteditor-bg-red-700 cteditor-transition-colors",
|
|
643
|
+
title: "Stop generating",
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ t(vt, { size: 10 }),
|
|
646
|
+
"Stop"
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
)
|
|
650
|
+
] }),
|
|
651
|
+
S && !B && /* @__PURE__ */ e(
|
|
652
|
+
"div",
|
|
653
|
+
{
|
|
654
|
+
className: `cteditor-relative cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-6 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-text-muted-foreground ${y === "success" ? "cteditor-bg-green-500/10 cteditor-border cteditor-border-green-500/20" : y === "error" ? "cteditor-bg-red-500/10 cteditor-border cteditor-border-red-500/20" : "cteditor-bg-muted"}`,
|
|
655
|
+
children: [
|
|
656
|
+
y === "success" ? /* @__PURE__ */ t("span", { className: "cteditor-text-green-600 dark:cteditor-text-green-400", children: "✓ Content inserted! Select new text or enter another prompt" }) : y === "error" ? /* @__PURE__ */ t("span", { className: "cteditor-text-red-600 dark:cteditor-text-red-400", children: "✗ Request failed. Try again or select different text" }) : X ? /* @__PURE__ */ e(tt, { children: [
|
|
657
|
+
/* @__PURE__ */ t("span", { className: "cteditor-text-muted-foreground/60", children: "Selected:" }),
|
|
658
|
+
/* @__PURE__ */ e("span", { className: "cteditor-text-foreground cteditor-italic", children: [
|
|
659
|
+
'"',
|
|
660
|
+
U,
|
|
661
|
+
'"'
|
|
662
|
+
] })
|
|
663
|
+
] }) : /* @__PURE__ */ t("span", { className: "cteditor-text-foreground", children: "Ask AI anything or select text to transform" }),
|
|
664
|
+
/* @__PURE__ */ t(
|
|
665
|
+
"button",
|
|
666
|
+
{
|
|
667
|
+
type: "button",
|
|
668
|
+
onClick: () => {
|
|
669
|
+
k(!1), J("");
|
|
670
|
+
},
|
|
671
|
+
className: "cteditor-absolute cteditor-right-1 cteditor-top-1/2 cteditor--translate-y-1/2 cteditor-size-4 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-duration-200 cteditor-cursor-pointer",
|
|
672
|
+
title: "Close message",
|
|
673
|
+
children: /* @__PURE__ */ t(gt, { size: 12 })
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
]
|
|
677
|
+
}
|
|
678
|
+
),
|
|
679
|
+
/* @__PURE__ */ e("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5", children: [
|
|
680
|
+
/* @__PURE__ */ e(
|
|
681
|
+
wt,
|
|
682
|
+
{
|
|
683
|
+
value: l.includes(a) ? a : l[0] ?? "chatgpt",
|
|
684
|
+
onValueChange: (o) => p(o),
|
|
685
|
+
disabled: G,
|
|
686
|
+
children: [
|
|
687
|
+
/* @__PURE__ */ t(St, { className: "cteditor-max-w-[90px] !cteditor-h-8 cteditor-text-xs cteditor-font-medium cteditor-border-border cteditor-bg-muted cteditor-text-foreground !cteditor-px-2 !cteditor-py-1", children: /* @__PURE__ */ t(It, { placeholder: "Select provider" }) }),
|
|
688
|
+
/* @__PURE__ */ e(At, { children: [
|
|
689
|
+
l.includes("chatgpt") && /* @__PURE__ */ t(q, { value: "chatgpt", children: "ChatGPT" }),
|
|
690
|
+
l.includes("claude") && /* @__PURE__ */ t(q, { value: "claude", children: "Claude" }),
|
|
691
|
+
l.includes("grok") && /* @__PURE__ */ t(q, { value: "grok", children: "Grok" }),
|
|
692
|
+
l.includes("gemini") && /* @__PURE__ */ t(q, { value: "gemini", children: "Gemini" })
|
|
693
|
+
] })
|
|
694
|
+
]
|
|
695
|
+
}
|
|
696
|
+
),
|
|
697
|
+
W.length > 0 && /* @__PURE__ */ e("div", { className: "cteditor-relative", onClick: (o) => o.stopPropagation(), children: [
|
|
698
|
+
/* @__PURE__ */ t(
|
|
699
|
+
"button",
|
|
700
|
+
{
|
|
701
|
+
type: "button",
|
|
702
|
+
onClick: () => K((o) => !o),
|
|
703
|
+
className: "cteditor-h-8 cteditor-w-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-border cteditor-border-border cteditor-bg-muted cteditor-text-muted-foreground hover:cteditor-text-foreground cteditor-transition-colors cteditor-shrink-0",
|
|
704
|
+
title: "Recent prompts",
|
|
705
|
+
children: /* @__PURE__ */ t(Zt, { size: 14 })
|
|
706
|
+
}
|
|
707
|
+
),
|
|
708
|
+
O && /* @__PURE__ */ t("div", { className: "cteditor-absolute cteditor-bottom-full cteditor-left-0 cteditor-mb-1 cteditor-bg-popover cteditor-border cteditor-border-border cteditor-rounded-md cteditor-shadow-lg cteditor-z-20 cteditor-min-w-[200px] cteditor-max-w-[300px]", children: W.map((o) => /* @__PURE__ */ t(
|
|
709
|
+
"button",
|
|
710
|
+
{
|
|
711
|
+
type: "button",
|
|
712
|
+
className: "cteditor-w-full cteditor-text-left cteditor-px-3 cteditor-py-2 cteditor-text-xs cteditor-text-foreground hover:cteditor-bg-muted cteditor-transition-colors cteditor-truncate cteditor-border-b cteditor-border-border last:cteditor-border-b-0",
|
|
713
|
+
onClick: () => {
|
|
714
|
+
f(o.prompt), K(!1), y !== "idle" && T("idle"), k(!0);
|
|
715
|
+
},
|
|
716
|
+
title: o.prompt,
|
|
717
|
+
children: o.prompt.length > 50 ? o.prompt.substring(0, 50) + "..." : o.prompt
|
|
718
|
+
},
|
|
719
|
+
o.id
|
|
720
|
+
)) })
|
|
721
|
+
] }),
|
|
722
|
+
/* @__PURE__ */ t(
|
|
723
|
+
"input",
|
|
724
|
+
{
|
|
725
|
+
ref: _,
|
|
726
|
+
type: "text",
|
|
727
|
+
value: i,
|
|
728
|
+
onChange: (o) => {
|
|
729
|
+
f(o.target.value), y !== "idle" && T("idle");
|
|
730
|
+
},
|
|
731
|
+
onKeyDown: nt,
|
|
732
|
+
placeholder: G ? "Add API keys in License > Manage API Keys to use AI..." : X ? "What do you want to do with this text?" : "Ask AI anything...",
|
|
733
|
+
disabled: n || G,
|
|
734
|
+
className: "cteditor-h-8 cteditor-px-2 cteditor-text-xs cteditor-flex-1 cteditor-min-w-0 cteditor-border cteditor-border-border cteditor-rounded-md cteditor-outline-none cteditor-bg-muted cteditor-text-foreground"
|
|
735
|
+
}
|
|
736
|
+
),
|
|
737
|
+
n ? /* @__PURE__ */ t(
|
|
738
|
+
"button",
|
|
739
|
+
{
|
|
740
|
+
type: "button",
|
|
741
|
+
onClick: st,
|
|
742
|
+
className: "cteditor-h-8 cteditor-w-8 cteditor-bg-red-600 cteditor-text-white cteditor-rounded-md cteditor-border-none cteditor-flex cteditor-items-center cteditor-justify-center cteditor-shrink-0 cteditor-cursor-pointer cteditor-transition-colors cteditor-duration-200 hover:cteditor-bg-red-700",
|
|
743
|
+
title: "Stop generating",
|
|
744
|
+
children: /* @__PURE__ */ t(vt, { size: 14 })
|
|
745
|
+
}
|
|
746
|
+
) : /* @__PURE__ */ t(
|
|
747
|
+
"button",
|
|
748
|
+
{
|
|
749
|
+
type: "button",
|
|
750
|
+
onClick: rt,
|
|
751
|
+
disabled: !i.trim() || G,
|
|
752
|
+
className: `cteditor-h-8 cteditor-w-8 cteditor-bg-primary cteditor-text-primary-foreground cteditor-rounded-md cteditor-border-none cteditor-flex cteditor-items-center cteditor-justify-center cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 ${!i.trim() || G ? "cteditor-cursor-not-allowed cteditor-opacity-50" : "cteditor-cursor-pointer cteditor-opacity-100"}`,
|
|
753
|
+
children: /* @__PURE__ */ t(ce, { size: 16 })
|
|
754
|
+
}
|
|
755
|
+
),
|
|
756
|
+
A && /* @__PURE__ */ t(
|
|
757
|
+
"button",
|
|
758
|
+
{
|
|
759
|
+
type: "button",
|
|
760
|
+
onClick: A,
|
|
761
|
+
className: "cteditor-h-8 cteditor-w-8 cteditor-bg-muted cteditor-text-muted-foreground cteditor-flex cteditor-items-center cteditor-justify-center cteditor-cursor-pointer cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 hover:cteditor-text-foreground cteditor-rounded-md cteditor-border cteditor-border-border",
|
|
762
|
+
title: "Open AI Chat",
|
|
763
|
+
children: /* @__PURE__ */ t(Pt, { size: 14 })
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
/* @__PURE__ */ t(
|
|
767
|
+
"button",
|
|
768
|
+
{
|
|
769
|
+
type: "button",
|
|
770
|
+
onClick: L,
|
|
771
|
+
className: "cteditor-h-8 cteditor-w-8 cteditor-bg-muted cteditor-text-muted-foreground cteditor-flex cteditor-items-center cteditor-justify-center cteditor-cursor-pointer cteditor-shrink-0 cteditor-transition-colors cteditor-duration-200 hover:cteditor-text-foreground cteditor-rounded-md cteditor-border cteditor-border-border",
|
|
772
|
+
title: "Close (Esc)",
|
|
773
|
+
children: /* @__PURE__ */ t(gt, { size: 16 })
|
|
774
|
+
}
|
|
775
|
+
)
|
|
776
|
+
] })
|
|
777
|
+
] });
|
|
778
|
+
}
|
|
779
|
+
function se(d, C, dt) {
|
|
780
|
+
const [w, L] = c(!1), [j, B] = c(
|
|
781
|
+
void 0
|
|
782
|
+
), z = V(null), [et, A] = c(!1), [a, p] = c("chatgpt"), [i, f] = c(""), n = V(null), [P, y] = c(!1), [T, S] = c(!1), k = H(
|
|
783
|
+
(x) => {
|
|
784
|
+
d.getEditorState().read(() => {
|
|
785
|
+
const m = ct();
|
|
786
|
+
m && (z.current = m.clone());
|
|
787
|
+
}), B(x), L((m) => !m);
|
|
788
|
+
},
|
|
789
|
+
[d]
|
|
790
|
+
), W = H(
|
|
791
|
+
(x, m) => {
|
|
792
|
+
p(x), f(m || j || ""), A(!0);
|
|
793
|
+
},
|
|
794
|
+
[j]
|
|
795
|
+
), Y = H(
|
|
796
|
+
(x, m, l) => {
|
|
797
|
+
n.current = x, y(!0), S(l ?? !1), p(m), f(""), A(!0);
|
|
798
|
+
},
|
|
799
|
+
[]
|
|
800
|
+
), O = H(() => {
|
|
801
|
+
n.current = null, y(!1);
|
|
802
|
+
}, []), K = H(() => {
|
|
803
|
+
n.current && (n.current.abort(), n.current = null), y(!1);
|
|
804
|
+
}, []), _ = H(() => {
|
|
805
|
+
L(!0);
|
|
806
|
+
}, []), $ = H(() => {
|
|
807
|
+
n.current && (n.current.abort(), n.current = null), y(!1), A(!1), f("");
|
|
808
|
+
}, []);
|
|
809
|
+
R(() => {
|
|
810
|
+
const x = d.registerCommand(
|
|
811
|
+
Gt,
|
|
812
|
+
(l) => (k(l), !0),
|
|
813
|
+
bt
|
|
814
|
+
), m = d.registerCommand(
|
|
815
|
+
Dt,
|
|
816
|
+
(l) => {
|
|
817
|
+
let G = "";
|
|
818
|
+
return d.getEditorState().read(() => {
|
|
819
|
+
const E = ct();
|
|
820
|
+
E && (G = E.getTextContent());
|
|
821
|
+
}), p(l?.provider || "chatgpt"), f(l?.initialText || G), A(!0), !0;
|
|
822
|
+
},
|
|
823
|
+
bt
|
|
824
|
+
);
|
|
825
|
+
return () => {
|
|
826
|
+
x(), m();
|
|
827
|
+
};
|
|
828
|
+
}, [d, k]);
|
|
829
|
+
const F = d.getRootElement();
|
|
830
|
+
return /* @__PURE__ */ e(tt, { children: [
|
|
831
|
+
w && /* @__PURE__ */ t(
|
|
832
|
+
de,
|
|
833
|
+
{
|
|
834
|
+
open: w,
|
|
835
|
+
onOpenChange: L,
|
|
836
|
+
editor: d,
|
|
837
|
+
apiKey: C,
|
|
838
|
+
initialText: j,
|
|
839
|
+
savedSelection: z.current,
|
|
840
|
+
onShowInEditor: W,
|
|
841
|
+
onStreamStart: Y,
|
|
842
|
+
onStreamEnd: O,
|
|
843
|
+
selectedTextForInline: j
|
|
844
|
+
}
|
|
845
|
+
),
|
|
846
|
+
et && /* @__PURE__ */ t(
|
|
847
|
+
ne,
|
|
848
|
+
{
|
|
849
|
+
editor: d,
|
|
850
|
+
apiKey: C,
|
|
851
|
+
initialProvider: a,
|
|
852
|
+
selectedText: i,
|
|
853
|
+
onClose: $,
|
|
854
|
+
anchorElem: F,
|
|
855
|
+
isStreamingFromModal: P,
|
|
856
|
+
isImageStreaming: T,
|
|
857
|
+
onStopStreaming: K,
|
|
858
|
+
onReopenModal: _
|
|
859
|
+
}
|
|
860
|
+
)
|
|
861
|
+
] });
|
|
862
|
+
}
|
|
863
|
+
function fe({
|
|
864
|
+
apiKey: d
|
|
865
|
+
}) {
|
|
866
|
+
const [C] = ee();
|
|
867
|
+
return se(C, d);
|
|
868
|
+
}
|
|
869
|
+
export {
|
|
870
|
+
fe as default
|
|
871
|
+
};
|