best-email-builder 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +189 -0
- package/README.md +13 -6
- package/THIRD-PARTY-NOTICES.md +34 -0
- package/dist/ai-server.js +7 -3
- package/dist/ai-server.js.map +1 -1
- package/dist/ai.js +114 -108
- package/dist/ai.js.map +1 -1
- package/dist/builder.js +8 -8
- package/dist/{chunk-XXUYQ5BX.js → chunk-6OR6W4KJ.js} +268 -55
- package/dist/chunk-6OR6W4KJ.js.map +1 -0
- package/dist/{chunk-O2A2DPFJ.js → chunk-7H7TLQBL.js} +159 -122
- package/dist/chunk-7H7TLQBL.js.map +1 -0
- package/dist/{chunk-R3DWMSSR.js → chunk-AGA3BLRI.js} +2 -2
- package/dist/{chunk-SYEUC7I2.js → chunk-EFE245KW.js} +399 -19
- package/dist/chunk-EFE245KW.js.map +1 -0
- package/dist/{chunk-NEEOZR5C.js → chunk-F5H7ITED.js} +9 -9
- package/dist/chunk-F5H7ITED.js.map +1 -0
- package/dist/{chunk-2ZRGQFX6.js → chunk-HAHHRMQG.js} +2576 -885
- package/dist/chunk-HAHHRMQG.js.map +1 -0
- package/dist/{chunk-OTE7BRKU.js → chunk-MC7JUFHI.js} +4 -4
- package/dist/{chunk-PCSKVVSZ.js → chunk-MSHGCLCA.js} +2 -2
- package/dist/{chunk-VHTV32EW.js → chunk-QLUCTFJ2.js} +311 -3
- package/dist/chunk-QLUCTFJ2.js.map +1 -0
- package/dist/{chunk-7JJ4EZAZ.js → chunk-RPDQABWZ.js} +2 -2
- package/dist/{chunk-SAYIBNH5.js → chunk-W5AJWWHH.js} +159 -20
- package/dist/chunk-W5AJWWHH.js.map +1 -0
- package/dist/de-BNFO6VLR.js +1875 -0
- package/dist/de-BNFO6VLR.js.map +1 -0
- package/dist/en-PBUZLCBA.js +1875 -0
- package/dist/en-PBUZLCBA.js.map +1 -0
- package/dist/es-M7A73ED7.js +1875 -0
- package/dist/es-M7A73ED7.js.map +1 -0
- package/dist/fr-SUFB35ZZ.js +1875 -0
- package/dist/fr-SUFB35ZZ.js.map +1 -0
- package/dist/index.js +10 -10
- package/dist/library.js +5 -5
- package/dist/pt-OEAULFDA.js +1875 -0
- package/dist/pt-OEAULFDA.js.map +1 -0
- package/dist/ru-ZCORYHGA.js +1875 -0
- package/dist/ru-ZCORYHGA.js.map +1 -0
- package/dist/server.js +80 -19
- package/dist/server.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/ai/errors.d.ts +19 -7
- package/dist/types/ai/index.d.ts +1 -0
- package/dist/types/ai/languagetool.d.ts +46 -0
- package/dist/types/ai/rewrite.d.ts +9 -7
- package/dist/types/ai/server.d.ts +1 -0
- package/dist/types/ai/subjects.d.ts +1 -0
- package/dist/types/blocks/shared.d.ts +12 -9
- package/dist/types/core/EmailEditor.d.ts +85 -12
- package/dist/types/core/blockBox.d.ts +12 -0
- package/dist/types/core/constants.d.ts +1 -1
- package/dist/types/core/mjmlAttributes.d.ts +37 -0
- package/dist/types/core/textFormat.d.ts +4 -0
- package/dist/types/defaultEditor.d.ts +3 -1
- package/dist/types/engine/NativeAdapter.d.ts +5 -2
- package/dist/types/engine/canvas/CanvasView.d.ts +30 -3
- package/dist/types/engine/canvas/canvasStyles.d.ts +1 -1
- package/dist/types/engine/canvas/icons.d.ts +5 -0
- package/dist/types/engine/canvasMjml.d.ts +4 -2
- package/dist/types/engine/mergeTags.d.ts +47 -0
- package/dist/types/engine/mjml.d.ts +7 -0
- package/dist/types/features/brand/brand.d.ts +4 -0
- package/dist/types/features/emoji/EmojiPanel.d.ts +3 -0
- package/dist/types/features/emoji/data/de.d.ts +2 -0
- package/dist/types/features/emoji/data/en.d.ts +2 -0
- package/dist/types/features/emoji/data/es.d.ts +2 -0
- package/dist/types/features/emoji/data/fr.d.ts +2 -0
- package/dist/types/features/emoji/data/pt.d.ts +2 -0
- package/dist/types/features/emoji/data/ru.d.ts +2 -0
- package/dist/types/features/emoji/data/zh.d.ts +2 -0
- package/dist/types/features/emoji/emojis.d.ts +33 -0
- package/dist/types/features/emoji/index.d.ts +2 -0
- package/dist/types/features/variables/VariableDialog.d.ts +16 -4
- package/dist/types/features/variables/VariablesPanel.d.ts +23 -0
- package/dist/types/features/variables/catalog.d.ts +45 -3
- package/dist/types/renderer/columnAlignment.d.ts +10 -0
- package/dist/types/renderer/compileEditorMjml.d.ts +2 -0
- package/dist/types/server/compileMjml.d.ts +5 -0
- package/dist/types/server/handler.d.ts +1 -1
- package/dist/types/server/render.d.ts +15 -4
- package/dist/types/server/sendTest.d.ts +2 -2
- package/dist/types/server/variables.d.ts +7 -2
- package/dist/types/storage/client.d.ts +8 -1
- package/dist/types/ui/BoxModel.d.ts +39 -0
- package/dist/types/ui/CanvasPanel.d.ts +19 -0
- package/dist/types/ui/PropertiesPanel.d.ts +1 -2
- package/dist/types/ui/SidePanel.d.ts +72 -0
- package/dist/types/ui/TextRibbon.d.ts +25 -0
- package/dist/types/ui/fields.d.ts +16 -1
- package/dist/types/ui/primitives/button.d.ts +1 -1
- package/dist/types/ui/primitives/color-picker.d.ts +19 -3
- package/dist/types/ui/primitives/fields.d.ts +5 -0
- package/dist/types/ui/primitives/overlays.d.ts +3 -1
- package/dist/types/ui/useEmailEditorState.d.ts +1 -0
- package/dist/zh-KPGU7EQG.js +1875 -0
- package/dist/zh-KPGU7EQG.js.map +1 -0
- package/package.json +2 -1
- package/dist/chunk-2ZRGQFX6.js.map +0 -1
- package/dist/chunk-NEEOZR5C.js.map +0 -1
- package/dist/chunk-O2A2DPFJ.js.map +0 -1
- package/dist/chunk-SAYIBNH5.js.map +0 -1
- package/dist/chunk-SYEUC7I2.js.map +0 -1
- package/dist/chunk-VHTV32EW.js.map +0 -1
- package/dist/chunk-XXUYQ5BX.js.map +0 -1
- package/dist/types/features/variables/VariablesBar.d.ts +0 -21
- package/dist/types/ui/ElementActions.d.ts +0 -13
- /package/dist/{chunk-R3DWMSSR.js.map → chunk-AGA3BLRI.js.map} +0 -0
- /package/dist/{chunk-OTE7BRKU.js.map → chunk-MC7JUFHI.js.map} +0 -0
- /package/dist/{chunk-PCSKVVSZ.js.map → chunk-MSHGCLCA.js.map} +0 -0
- /package/dist/{chunk-7JJ4EZAZ.js.map → chunk-RPDQABWZ.js.map} +0 -0
package/dist/ai.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cleanRichText
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RPDQABWZ.js";
|
|
4
4
|
import {
|
|
5
5
|
Button,
|
|
6
6
|
Dialog,
|
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
Input,
|
|
17
17
|
Label,
|
|
18
18
|
SectionLabel,
|
|
19
|
+
Textarea,
|
|
19
20
|
cn,
|
|
20
21
|
createHttpCaller,
|
|
21
22
|
useUi
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-7H7TLQBL.js";
|
|
24
|
+
import "./chunk-W5AJWWHH.js";
|
|
24
25
|
import {
|
|
25
26
|
AGENT_ERROR_CODES,
|
|
26
27
|
AGENT_PROTOCOL,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
DEFAULT_CLAUDE_MODEL,
|
|
30
31
|
EmailGenerationError,
|
|
31
32
|
GENERATION_ERRORS,
|
|
33
|
+
LANGUAGETOOL_PUBLIC_API,
|
|
32
34
|
MAX_REWRITE_INSTRUCTION,
|
|
33
35
|
REWRITE_ACTIONS,
|
|
34
36
|
REWRITE_LANGUAGES,
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
claudeEmailModel,
|
|
37
39
|
claudeProvider,
|
|
38
40
|
createEmailGenerator,
|
|
41
|
+
createLanguageToolProofreader,
|
|
39
42
|
diffWords,
|
|
40
43
|
emailWords,
|
|
41
44
|
failureCode,
|
|
@@ -43,9 +46,9 @@ import {
|
|
|
43
46
|
providerEmailModel,
|
|
44
47
|
resolveProvider,
|
|
45
48
|
visibleText
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
+
} from "./chunk-6OR6W4KJ.js";
|
|
50
|
+
import "./chunk-AGA3BLRI.js";
|
|
51
|
+
import "./chunk-EFE245KW.js";
|
|
49
52
|
|
|
50
53
|
// src/ai/keys.js
|
|
51
54
|
var STORAGE_PREFIX = "best-email-builder:ai-key:";
|
|
@@ -863,7 +866,7 @@ function ProofreadButton({ context, proofread }) {
|
|
|
863
866
|
/* @__PURE__ */ jsx3(Dialog, { open, onOpenChange: close, children: /* @__PURE__ */ jsxs3(DialogContent, { className: "eb:flex eb:max-h-[calc(100dvh-2rem)] eb:flex-col eb:gap-0 eb:p-0 eb:sm:max-w-xl", "data-testid": "eb-proofread", children: [
|
|
864
867
|
/* @__PURE__ */ jsxs3(DialogHeader, { className: "eb:gap-1.5 eb:px-6 eb:pt-6 eb:pb-4", children: [
|
|
865
868
|
/* @__PURE__ */ jsx3(DialogTitle, { children: t("Proofread the email") }),
|
|
866
|
-
/* @__PURE__ */ jsx3(DialogDescription, { children: t("
|
|
869
|
+
/* @__PURE__ */ jsx3(DialogDescription, { children: t("Every text is checked for spelling, grammar and punctuation mistakes. Nothing changes until you apply it.") })
|
|
867
870
|
] }),
|
|
868
871
|
/* @__PURE__ */ jsxs3("div", { className: "eb:min-h-0 eb:flex-1 eb:overflow-y-auto eb:border-t eb:border-border eb:px-6 eb:py-4", children: [
|
|
869
872
|
busy && /* @__PURE__ */ jsxs3("p", { className: "eb:flex eb:items-center eb:gap-2 eb:py-6 eb:text-[13px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: [
|
|
@@ -930,17 +933,17 @@ function around(text, first, last) {
|
|
|
930
933
|
}
|
|
931
934
|
|
|
932
935
|
// src/ai/RewriteText.jsx
|
|
933
|
-
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
934
|
-
import { ChevronDown as ChevronDown2, Languages, Loader2 as Loader22,
|
|
936
|
+
import { useCallback, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
937
|
+
import { ChevronDown as ChevronDown2, Languages, Loader2 as Loader22, Sparkles, TriangleAlert as TriangleAlert3 } from "lucide-react";
|
|
935
938
|
|
|
936
939
|
// src/ai/chip.js
|
|
937
940
|
var chipClassName = (selected = false) => cn(
|
|
938
|
-
"eb:inline-flex eb:h-
|
|
941
|
+
"eb:inline-flex eb:h-[22px] eb:items-center eb:gap-1 eb:rounded-full eb:border eb:px-2.5 eb:text-[12px] eb:font-medium eb:transition-colors eb:outline-none eb:focus-visible:ring-[3px] eb:focus-visible:ring-ring/50 eb:disabled:opacity-50",
|
|
939
942
|
selected ? "eb:border-primary eb:bg-primary eb:text-primary-foreground" : "eb:border-border eb:bg-background eb:text-foreground eb:hover:border-primary/50 eb:hover:bg-primary/5"
|
|
940
943
|
);
|
|
941
944
|
|
|
942
945
|
// src/ai/RewriteText.jsx
|
|
943
|
-
import {
|
|
946
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
944
947
|
function nativeName(code) {
|
|
945
948
|
try {
|
|
946
949
|
const name = new Intl.DisplayNames([code], { type: "language" }).of(code) || code;
|
|
@@ -956,14 +959,19 @@ function RewriteText({ editor, selection, rewrite }) {
|
|
|
956
959
|
null
|
|
957
960
|
);
|
|
958
961
|
const [error, setError] = useState4("");
|
|
959
|
-
const [
|
|
960
|
-
const [topic, setTopic] = useState4("");
|
|
962
|
+
const [request, setRequest] = useState4("");
|
|
961
963
|
const abortRef = useRef4(
|
|
962
964
|
/** @type {AbortController|null} */
|
|
963
965
|
null
|
|
964
966
|
);
|
|
965
967
|
const label = selection.tagName === "mj-button";
|
|
966
|
-
|
|
968
|
+
const stop = useCallback(() => {
|
|
969
|
+
if (!abortRef.current) return;
|
|
970
|
+
abortRef.current.abort();
|
|
971
|
+
abortRef.current = null;
|
|
972
|
+
editor.showWorking(null);
|
|
973
|
+
}, [editor]);
|
|
974
|
+
useEffect4(() => stop, [stop]);
|
|
967
975
|
const currentText2 = () => {
|
|
968
976
|
const element = editor.getElement(selection.id);
|
|
969
977
|
return (label ? element?.content : element?.html) ?? "";
|
|
@@ -971,10 +979,12 @@ function RewriteText({ editor, selection, rewrite }) {
|
|
|
971
979
|
const run = async (action, extra = {}) => {
|
|
972
980
|
if (running) return;
|
|
973
981
|
const text = currentText2();
|
|
982
|
+
const writing = action === "custom";
|
|
974
983
|
setError("");
|
|
975
984
|
setRunning(action);
|
|
976
985
|
const controller = new AbortController();
|
|
977
986
|
abortRef.current = controller;
|
|
987
|
+
editor.showWorking(selection.id);
|
|
978
988
|
try {
|
|
979
989
|
const result = await rewrite({ action, text, format: label ? "plain" : "html", ...extra }, { signal: controller.signal });
|
|
980
990
|
if (controller.signal.aborted) return;
|
|
@@ -982,123 +992,117 @@ function RewriteText({ editor, selection, rewrite }) {
|
|
|
982
992
|
setError(t("The text changed in the meantime, so it was left as it is."));
|
|
983
993
|
return;
|
|
984
994
|
}
|
|
985
|
-
editor.setContent(label ? result.text : cleanRichText(result.text, document), selection.id);
|
|
986
|
-
if (action === "custom")
|
|
987
|
-
|
|
988
|
-
notify("success", action === "write" ? t("Text written. Ctrl+Z brings back the previous one.") : t("Text rewritten. Ctrl+Z brings back the previous one."));
|
|
995
|
+
editor.setContent(label ? result.text : cleanRichText(result.text, document), selection.id, { reveal: true });
|
|
996
|
+
if (action === "custom") setRequest("");
|
|
997
|
+
notify("success", writing ? t("Text written. Ctrl+Z brings back the previous one.") : t("Text rewritten. Ctrl+Z brings back the previous one."));
|
|
989
998
|
} catch (err) {
|
|
990
999
|
if (!controller.signal.aborted) {
|
|
991
|
-
setError(err?.message ? t(err.message) :
|
|
1000
|
+
setError(err?.message ? t(err.message) : writing ? t("The text could not be written.") : t("The text could not be rewritten."));
|
|
992
1001
|
}
|
|
993
1002
|
} finally {
|
|
994
|
-
if (abortRef.current === controller)
|
|
1003
|
+
if (abortRef.current === controller) {
|
|
1004
|
+
abortRef.current = null;
|
|
1005
|
+
editor.showWorking(null);
|
|
1006
|
+
}
|
|
995
1007
|
setRunning(null);
|
|
996
1008
|
}
|
|
997
1009
|
};
|
|
998
1010
|
const cancel = () => {
|
|
999
|
-
|
|
1011
|
+
stop();
|
|
1000
1012
|
setRunning(null);
|
|
1001
1013
|
};
|
|
1002
|
-
const
|
|
1003
|
-
const
|
|
1004
|
-
if (!
|
|
1014
|
+
const ask = () => {
|
|
1015
|
+
const words = request.trim();
|
|
1016
|
+
if (!words) return;
|
|
1005
1017
|
const size = Number.parseFloat(String(editor.getElement(selection.id)?.attributes?.["font-size"] || ""));
|
|
1006
1018
|
const own = visibleText(currentText2());
|
|
1007
|
-
const
|
|
1008
|
-
run("
|
|
1009
|
-
instruction:
|
|
1010
|
-
context: own ?
|
|
1019
|
+
const email = emailWords(editor.exportMjml());
|
|
1020
|
+
run("custom", {
|
|
1021
|
+
instruction: words,
|
|
1022
|
+
context: own ? email.replace(own, "").trim() : email,
|
|
1011
1023
|
role: size >= 20 ? "heading" : "text",
|
|
1012
1024
|
language: String(locale || "en").slice(0, 2)
|
|
1013
1025
|
});
|
|
1014
1026
|
};
|
|
1015
1027
|
const busy = Boolean(running);
|
|
1016
1028
|
const spinner = /* @__PURE__ */ jsx4(Loader22, { className: "eb:size-3 eb:animate-spin", "aria-hidden": "true" });
|
|
1017
|
-
return /* @__PURE__ */ jsxs4(
|
|
1018
|
-
|
|
1019
|
-
/* @__PURE__ */
|
|
1020
|
-
|
|
1021
|
-
t("Write with AI")
|
|
1022
|
-
] }),
|
|
1023
|
-
/* @__PURE__ */ jsxs4(
|
|
1024
|
-
"form",
|
|
1025
|
-
{
|
|
1026
|
-
className: "eb:flex eb:gap-1.5",
|
|
1027
|
-
onSubmit: (event) => {
|
|
1028
|
-
event.preventDefault();
|
|
1029
|
-
write();
|
|
1030
|
-
},
|
|
1031
|
-
children: [
|
|
1032
|
-
/* @__PURE__ */ jsx4(
|
|
1033
|
-
Input,
|
|
1034
|
-
{
|
|
1035
|
-
value: topic,
|
|
1036
|
-
onChange: (event) => setTopic(event.target.value),
|
|
1037
|
-
maxLength: MAX_REWRITE_INSTRUCTION,
|
|
1038
|
-
placeholder: t("What should it say? e.g. the sale ends Sunday"),
|
|
1039
|
-
"aria-label": t("What the text is about"),
|
|
1040
|
-
disabled: busy
|
|
1041
|
-
}
|
|
1042
|
-
),
|
|
1043
|
-
/* @__PURE__ */ jsx4(Button, { type: "submit", variant: "outline", size: "icon-sm", "aria-label": t("Write"), disabled: busy || !topic.trim(), children: running === "write" ? /* @__PURE__ */ jsx4(Loader22, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx4(PenLine, {}) })
|
|
1044
|
-
]
|
|
1045
|
-
}
|
|
1046
|
-
)
|
|
1029
|
+
return /* @__PURE__ */ jsxs4("section", { className: "eb:space-y-2.5", "aria-label": t("Write with AI"), "data-testid": "eb-rewrite", children: [
|
|
1030
|
+
/* @__PURE__ */ jsxs4(SectionLabel, { className: "eb:flex eb:items-center eb:gap-1.5", children: [
|
|
1031
|
+
/* @__PURE__ */ jsx4(Sparkles, { className: "eb:size-3", "aria-hidden": "true" }),
|
|
1032
|
+
t("Write with AI")
|
|
1047
1033
|
] }),
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
className: "eb:
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (instruction.trim()) run("custom", { instruction: instruction.trim() });
|
|
1074
|
-
},
|
|
1075
|
-
children: [
|
|
1076
|
-
/* @__PURE__ */ jsx4(
|
|
1077
|
-
Input,
|
|
1078
|
-
{
|
|
1079
|
-
value: instruction,
|
|
1080
|
-
onChange: (event) => setInstruction(event.target.value),
|
|
1081
|
-
maxLength: MAX_REWRITE_INSTRUCTION,
|
|
1082
|
-
placeholder: t("Or say what to change\u2026"),
|
|
1083
|
-
"aria-label": t("What to change"),
|
|
1084
|
-
disabled: busy
|
|
1085
|
-
}
|
|
1086
|
-
),
|
|
1087
|
-
/* @__PURE__ */ jsx4(Button, { type: "submit", variant: "outline", size: "icon-sm", "aria-label": t("Rewrite"), disabled: busy || !instruction.trim(), children: running === "custom" ? /* @__PURE__ */ jsx4(Loader22, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx4(Sparkles, {}) })
|
|
1088
|
-
]
|
|
1089
|
-
}
|
|
1090
|
-
),
|
|
1091
|
-
running && /* @__PURE__ */ jsxs4("p", { className: "eb:flex eb:items-center eb:gap-2 eb:text-[12px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: [
|
|
1092
|
-
running === "write" ? t("Writing\u2026") : t("Rewriting\u2026"),
|
|
1093
|
-
/* @__PURE__ */ jsx4(Button, { type: "button", variant: "link", size: "xs", className: "eb:h-auto eb:px-0", onClick: cancel, children: t("Cancel") })
|
|
1094
|
-
] }),
|
|
1095
|
-
error && /* @__PURE__ */ jsxs4("p", { role: "alert", className: "eb:flex eb:items-start eb:gap-1.5 eb:text-[12px] eb:text-destructive", children: [
|
|
1096
|
-
/* @__PURE__ */ jsx4(TriangleAlert3, { className: "eb:mt-px eb:size-3.5 eb:shrink-0", "aria-hidden": "true" }),
|
|
1097
|
-
error
|
|
1034
|
+
/* @__PURE__ */ jsx4(
|
|
1035
|
+
PromptForm,
|
|
1036
|
+
{
|
|
1037
|
+
value: request,
|
|
1038
|
+
onChange: setRequest,
|
|
1039
|
+
onSubmit: ask,
|
|
1040
|
+
placeholder: t("What should it say, or what should change? e.g. the sale ends Sunday"),
|
|
1041
|
+
label: t("Ask the AI"),
|
|
1042
|
+
busy,
|
|
1043
|
+
submitLabel: t("Write"),
|
|
1044
|
+
children: running === "custom" ? /* @__PURE__ */ jsx4(Loader22, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx4(Sparkles, {})
|
|
1045
|
+
}
|
|
1046
|
+
),
|
|
1047
|
+
/* @__PURE__ */ jsxs4("div", { className: "eb:flex eb:flex-wrap eb:gap-1.5", children: [
|
|
1048
|
+
REWRITE_ACTIONS.map((action) => /* @__PURE__ */ jsxs4("button", { type: "button", className: chipClassName(), disabled: busy, onClick: () => run(action.id), children: [
|
|
1049
|
+
running === action.id && spinner,
|
|
1050
|
+
t(action.label)
|
|
1051
|
+
] }, action.id)),
|
|
1052
|
+
/* @__PURE__ */ jsxs4(DropdownMenu, { children: [
|
|
1053
|
+
/* @__PURE__ */ jsx4(DropdownMenuTrigger, { asChild: true, disabled: busy, children: /* @__PURE__ */ jsxs4("button", { type: "button", className: chipClassName(), children: [
|
|
1054
|
+
running === "translate" ? spinner : /* @__PURE__ */ jsx4(Languages, { className: "eb:size-3", "aria-hidden": "true" }),
|
|
1055
|
+
t("Translate"),
|
|
1056
|
+
/* @__PURE__ */ jsx4(ChevronDown2, { className: "eb:size-3", "aria-hidden": "true" })
|
|
1057
|
+
] }) }),
|
|
1058
|
+
/* @__PURE__ */ jsx4(DropdownMenuContent, { align: "start", "aria-label": t("Translate into"), children: REWRITE_LANGUAGES.map((code) => /* @__PURE__ */ jsx4(DropdownMenuItem, { lang: code, onSelect: () => run("translate", { targetLanguage: code }), children: nativeName(code) }, code)) })
|
|
1098
1059
|
] })
|
|
1060
|
+
] }),
|
|
1061
|
+
running && /* @__PURE__ */ jsxs4("p", { className: "eb:flex eb:items-center eb:gap-2 eb:text-[12px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: [
|
|
1062
|
+
running === "custom" ? t("Writing\u2026") : t("Rewriting\u2026"),
|
|
1063
|
+
/* @__PURE__ */ jsx4(Button, { type: "button", variant: "link", size: "xs", className: "eb:h-auto eb:px-0", onClick: cancel, children: t("Cancel") })
|
|
1064
|
+
] }),
|
|
1065
|
+
error && /* @__PURE__ */ jsxs4("p", { role: "alert", className: "eb:flex eb:items-start eb:gap-1.5 eb:text-[12px] eb:text-destructive", children: [
|
|
1066
|
+
/* @__PURE__ */ jsx4(TriangleAlert3, { className: "eb:mt-px eb:size-3.5 eb:shrink-0", "aria-hidden": "true" }),
|
|
1067
|
+
error
|
|
1099
1068
|
] })
|
|
1100
1069
|
] });
|
|
1101
1070
|
}
|
|
1071
|
+
function PromptForm({ value, onChange, onSubmit, placeholder, label, busy, submitLabel, children }) {
|
|
1072
|
+
const ready = !busy && Boolean(value.trim());
|
|
1073
|
+
return /* @__PURE__ */ jsxs4(
|
|
1074
|
+
"form",
|
|
1075
|
+
{
|
|
1076
|
+
className: "eb:flex eb:items-end eb:gap-1.5",
|
|
1077
|
+
onSubmit: (event) => {
|
|
1078
|
+
event.preventDefault();
|
|
1079
|
+
if (ready) onSubmit();
|
|
1080
|
+
},
|
|
1081
|
+
children: [
|
|
1082
|
+
/* @__PURE__ */ jsx4(
|
|
1083
|
+
Textarea,
|
|
1084
|
+
{
|
|
1085
|
+
dense: true,
|
|
1086
|
+
rows: 3,
|
|
1087
|
+
value,
|
|
1088
|
+
onChange: (event) => onChange(event.target.value),
|
|
1089
|
+
onKeyDown: (event) => {
|
|
1090
|
+
if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing) return;
|
|
1091
|
+
event.preventDefault();
|
|
1092
|
+
if (ready) onSubmit();
|
|
1093
|
+
},
|
|
1094
|
+
maxLength: MAX_REWRITE_INSTRUCTION,
|
|
1095
|
+
placeholder,
|
|
1096
|
+
"aria-label": label,
|
|
1097
|
+
disabled: busy,
|
|
1098
|
+
className: "eb:min-h-16 eb:max-h-40 eb:resize-none"
|
|
1099
|
+
}
|
|
1100
|
+
),
|
|
1101
|
+
/* @__PURE__ */ jsx4(Button, { type: "submit", variant: "outline", size: "icon-dense", "aria-label": submitLabel, disabled: !ready, children })
|
|
1102
|
+
]
|
|
1103
|
+
}
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1102
1106
|
|
|
1103
1107
|
// src/ai/SubjectIdeas.jsx
|
|
1104
1108
|
import { useEffect as useEffect5, useLayoutEffect, useRef as useRef5, useState as useState5 } from "react";
|
|
@@ -1423,6 +1427,7 @@ export {
|
|
|
1423
1427
|
DEFAULT_CLAUDE_MODEL,
|
|
1424
1428
|
EmailGenerationError,
|
|
1425
1429
|
GENERATION_ERRORS,
|
|
1430
|
+
LANGUAGETOOL_PUBLIC_API,
|
|
1426
1431
|
REWRITE_ACTIONS,
|
|
1427
1432
|
REWRITE_LANGUAGES,
|
|
1428
1433
|
agentEmailModel,
|
|
@@ -1430,6 +1435,7 @@ export {
|
|
|
1430
1435
|
claudeProvider,
|
|
1431
1436
|
createAi,
|
|
1432
1437
|
createEmailGenerator,
|
|
1438
|
+
createLanguageToolProofreader,
|
|
1433
1439
|
diffWords,
|
|
1434
1440
|
emailWords,
|
|
1435
1441
|
failureCode,
|