best-email-builder 0.22.0 → 0.24.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 +40 -0
- package/dist/ai-server.js +3 -3
- package/dist/ai.js +6 -6
- package/dist/builder.js +11 -8
- package/dist/chunk-6MOFRBFL.js +768 -0
- package/dist/chunk-6MOFRBFL.js.map +1 -0
- package/dist/{chunk-3FKHX47M.js → chunk-7KOL5ON4.js} +565 -636
- package/dist/chunk-7KOL5ON4.js.map +1 -0
- package/dist/{chunk-HE2VAOLR.js → chunk-BNCV6YFL.js} +127 -7
- package/dist/chunk-BNCV6YFL.js.map +1 -0
- package/dist/{chunk-IGC3I4XL.js → chunk-DVC7C52B.js} +2 -2
- package/dist/{chunk-WWP3FQYO.js → chunk-FIPMQV6N.js} +4 -4
- package/dist/{chunk-2XSNS7EW.js → chunk-FSDQV6FU.js} +3 -3
- package/dist/{chunk-2XSNS7EW.js.map → chunk-FSDQV6FU.js.map} +1 -1
- package/dist/{chunk-XYXN3UBQ.js → chunk-HBFZQGE7.js} +2 -2
- package/dist/{chunk-LQ3JCPZ2.js → chunk-MDFZRNZW.js} +12 -5
- package/dist/chunk-MDFZRNZW.js.map +1 -0
- package/dist/{chunk-C22PQBW4.js → chunk-OX22IB5D.js} +15 -4
- package/dist/chunk-OX22IB5D.js.map +1 -0
- package/dist/{chunk-OSQ5YGHL.js → chunk-QY67KPCS.js} +2 -2
- package/dist/{chunk-4SRNGFAV.js → chunk-YKPRHFMR.js} +3 -3
- package/dist/index.js +10 -10
- package/dist/library.js +7 -5
- package/dist/server.js +99 -16
- package/dist/server.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/builder.d.ts +1 -0
- package/dist/types/core/constants.d.ts +1 -1
- package/dist/types/engine/NativeAdapter.d.ts +1 -1
- package/dist/types/features/preview/PreviewButton.d.ts +4 -3
- package/dist/types/features/test-email/TestEmailDialog.d.ts +29 -0
- package/dist/types/library.d.ts +1 -0
- package/dist/types/renderer/columnAlignment.d.ts +9 -0
- package/dist/types/server/handler.d.ts +45 -0
- package/dist/types/server/render.d.ts +6 -2
- package/dist/types/server/sendTest.d.ts +21 -3
- package/dist/types/storage/client.d.ts +39 -5
- package/package.json +1 -1
- package/dist/chunk-3FKHX47M.js.map +0 -1
- package/dist/chunk-7ZI7ZOYQ.js +0 -294
- package/dist/chunk-7ZI7ZOYQ.js.map +0 -1
- package/dist/chunk-C22PQBW4.js.map +0 -1
- package/dist/chunk-HE2VAOLR.js.map +0 -1
- package/dist/chunk-LQ3JCPZ2.js.map +0 -1
- package/dist/types/features/test-email/TestEmailButton.d.ts +0 -3
- /package/dist/{chunk-IGC3I4XL.js.map → chunk-DVC7C52B.js.map} +0 -0
- /package/dist/{chunk-WWP3FQYO.js.map → chunk-FIPMQV6N.js.map} +0 -0
- /package/dist/{chunk-XYXN3UBQ.js.map → chunk-HBFZQGE7.js.map} +0 -0
- /package/dist/{chunk-OSQ5YGHL.js.map → chunk-QY67KPCS.js.map} +0 -0
- /package/dist/{chunk-4SRNGFAV.js.map → chunk-YKPRHFMR.js.map} +0 -0
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
PreviewButton,
|
|
4
4
|
SEARCH_KEYS,
|
|
5
5
|
SearchKeyHint,
|
|
6
|
+
TestEmailButton,
|
|
6
7
|
useLayoutWidth,
|
|
7
8
|
useSearchShortcut,
|
|
8
9
|
withThumbnailImages
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6MOFRBFL.js";
|
|
10
11
|
import {
|
|
11
12
|
BORDER_STYLES,
|
|
12
13
|
BRAND_NOTES,
|
|
@@ -26,12 +27,12 @@ import {
|
|
|
26
27
|
toMobileAttributes,
|
|
27
28
|
toValues,
|
|
28
29
|
withMobile
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-MDFZRNZW.js";
|
|
30
31
|
import {
|
|
31
32
|
cleanRichText,
|
|
32
33
|
escapeText,
|
|
33
34
|
textOfHtml
|
|
34
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-DVC7C52B.js";
|
|
35
36
|
import {
|
|
36
37
|
Button,
|
|
37
38
|
Dialog,
|
|
@@ -72,7 +73,7 @@ import {
|
|
|
72
73
|
createHttpStorage,
|
|
73
74
|
useT,
|
|
74
75
|
useUi
|
|
75
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-OX22IB5D.js";
|
|
76
77
|
import {
|
|
77
78
|
BRAND_FONT_SIZES,
|
|
78
79
|
DEFAULT_BUTTON_URL,
|
|
@@ -117,11 +118,11 @@ import {
|
|
|
117
118
|
setAttributes,
|
|
118
119
|
setContent,
|
|
119
120
|
toProject
|
|
120
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-FSDQV6FU.js";
|
|
121
122
|
import {
|
|
122
123
|
IMAGE_ATTRIBUTES,
|
|
123
124
|
isSafeUrl
|
|
124
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-QY67KPCS.js";
|
|
125
126
|
import {
|
|
126
127
|
CUSTOM_GROUP,
|
|
127
128
|
DEFAULT_VARIABLES,
|
|
@@ -137,7 +138,7 @@ import {
|
|
|
137
138
|
translatorFor,
|
|
138
139
|
validateCustomVariable,
|
|
139
140
|
validateVariableEdit
|
|
140
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-BNCV6YFL.js";
|
|
141
142
|
|
|
142
143
|
// src/core/events.js
|
|
143
144
|
function createEmitter({ onError } = {}) {
|
|
@@ -1818,7 +1819,7 @@ function VariablesPanel({ context }) {
|
|
|
1818
1819
|
}
|
|
1819
1820
|
});
|
|
1820
1821
|
const insert = (variable) => {
|
|
1821
|
-
const done = editor.insertText(tokenOf(variable));
|
|
1822
|
+
const done = editor.insertText(`${tokenOf(variable)} `);
|
|
1822
1823
|
if (!done) notify("info", t("Select a text or a button first."));
|
|
1823
1824
|
};
|
|
1824
1825
|
const badge = (variable) => {
|
|
@@ -1967,7 +1968,7 @@ function VariablesPanel({ context }) {
|
|
|
1967
1968
|
onSaved: async (variable, created) => {
|
|
1968
1969
|
await reloadVariables();
|
|
1969
1970
|
if (created) {
|
|
1970
|
-
if (editor.insertText(tokenOf(variable))) {
|
|
1971
|
+
if (editor.insertText(`${tokenOf(variable)} `)) {
|
|
1971
1972
|
notify("success", t("Variable \u201C{name}\u201D created and inserted.", { name: variable.label }));
|
|
1972
1973
|
} else {
|
|
1973
1974
|
notify("success", t("Variable \u201C{name}\u201D created.", { name: variable.label }));
|
|
@@ -2378,113 +2379,6 @@ var previewFeature = {
|
|
|
2378
2379
|
isAvailable: (context) => typeof context.storage?.render === "function"
|
|
2379
2380
|
};
|
|
2380
2381
|
|
|
2381
|
-
// src/features/test-email/TestEmailButton.jsx
|
|
2382
|
-
import { useState as useState5 } from "react";
|
|
2383
|
-
import { CheckCircle2, Loader2 as Loader24, Send, XCircle } from "lucide-react";
|
|
2384
|
-
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2385
|
-
var KEY = "best-email-builder:test-addresses";
|
|
2386
|
-
function readAddresses(fallback) {
|
|
2387
|
-
try {
|
|
2388
|
-
return window.localStorage.getItem(KEY) ?? fallback;
|
|
2389
|
-
} catch {
|
|
2390
|
-
return fallback;
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
function rememberAddresses(value) {
|
|
2394
|
-
try {
|
|
2395
|
-
window.localStorage.setItem(KEY, value);
|
|
2396
|
-
} catch {
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
function TestEmailButton({ context }) {
|
|
2400
|
-
const { editor, ready, meta, storage, testRecipients = [] } = context;
|
|
2401
|
-
const { t, notify } = useUi();
|
|
2402
|
-
const [open, setOpen] = useState5(false);
|
|
2403
|
-
const [addresses, setAddresses] = useState5("");
|
|
2404
|
-
const [sending, setSending] = useState5(false);
|
|
2405
|
-
const [report, setReport] = useState5(null);
|
|
2406
|
-
const emails = addresses.split(/[,;\s]+/).map((a) => a.trim()).filter(Boolean);
|
|
2407
|
-
const send = async () => {
|
|
2408
|
-
if (!emails.length) return;
|
|
2409
|
-
rememberAddresses(addresses);
|
|
2410
|
-
setSending(true);
|
|
2411
|
-
setReport(null);
|
|
2412
|
-
try {
|
|
2413
|
-
const result = await storage.sendTest({
|
|
2414
|
-
mjml: editor.exportMjml(),
|
|
2415
|
-
subject: meta.subject,
|
|
2416
|
-
preheader: meta.preheader,
|
|
2417
|
-
emails
|
|
2418
|
-
});
|
|
2419
|
-
setReport(result);
|
|
2420
|
-
if (result.failed > 0) notify("warning", t("{sent} sent, {failed} failed.", { sent: result.sent, failed: result.failed }));
|
|
2421
|
-
else notify("success", t("{sent} test(s) sent \u2014 check your inbox.", { sent: result.sent }));
|
|
2422
|
-
} catch (error) {
|
|
2423
|
-
notify("error", error.message);
|
|
2424
|
-
} finally {
|
|
2425
|
-
setSending(false);
|
|
2426
|
-
}
|
|
2427
|
-
};
|
|
2428
|
-
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2429
|
-
/* @__PURE__ */ jsxs5(
|
|
2430
|
-
Button,
|
|
2431
|
-
{
|
|
2432
|
-
variant: "outline",
|
|
2433
|
-
size: "sm-compact",
|
|
2434
|
-
disabled: !ready,
|
|
2435
|
-
onClick: () => {
|
|
2436
|
-
setAddresses(readAddresses(testRecipients.join(", ")));
|
|
2437
|
-
setReport(null);
|
|
2438
|
-
setOpen(true);
|
|
2439
|
-
},
|
|
2440
|
-
children: [
|
|
2441
|
-
/* @__PURE__ */ jsx5(Send, {}),
|
|
2442
|
-
t("Test")
|
|
2443
|
-
]
|
|
2444
|
-
}
|
|
2445
|
-
),
|
|
2446
|
-
/* @__PURE__ */ jsx5(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs5(DialogContent, { className: "eb:sm:max-w-[460px]", children: [
|
|
2447
|
-
/* @__PURE__ */ jsx5(DialogHeader, { children: /* @__PURE__ */ jsxs5("div", { className: "eb:flex eb:items-center eb:gap-3", children: [
|
|
2448
|
-
/* @__PURE__ */ jsx5("span", { className: "eb:flex eb:size-10 eb:shrink-0 eb:items-center eb:justify-center eb:rounded-lg2 eb:bg-primary/10 eb:text-primary", children: /* @__PURE__ */ jsx5(Send, { className: "eb:size-5" }) }),
|
|
2449
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
2450
|
-
/* @__PURE__ */ jsx5(DialogTitle, { className: "eb:text-base eb:font-normal", children: t("Send a test") }),
|
|
2451
|
-
/* @__PURE__ */ jsx5(DialogDescription, { className: "eb:text-[13px]", children: t("The email on screen, to reviewers\u2019 addresses.") })
|
|
2452
|
-
] })
|
|
2453
|
-
] }) }),
|
|
2454
|
-
/* @__PURE__ */ jsxs5("div", { className: "eb:space-y-2", children: [
|
|
2455
|
-
/* @__PURE__ */ jsx5(Label, { htmlFor: "eb-test-addresses", children: t("Addresses") }),
|
|
2456
|
-
/* @__PURE__ */ jsx5(
|
|
2457
|
-
Textarea,
|
|
2458
|
-
{
|
|
2459
|
-
id: "eb-test-addresses",
|
|
2460
|
-
value: addresses,
|
|
2461
|
-
onChange: (e) => setAddresses(e.target.value),
|
|
2462
|
-
placeholder: "jane@example.com, john@example.com",
|
|
2463
|
-
rows: 3
|
|
2464
|
-
}
|
|
2465
|
-
)
|
|
2466
|
-
] }),
|
|
2467
|
-
report && /* @__PURE__ */ jsxs5("ul", { className: "eb:space-y-1", "aria-label": t("Results"), children: [
|
|
2468
|
-
report.results.map((r) => /* @__PURE__ */ jsxs5("li", { className: "eb:flex eb:items-start eb:gap-1.5 eb:text-[12px] eb:text-foreground", children: [
|
|
2469
|
-
r.ok ? /* @__PURE__ */ jsx5(CheckCircle2, { className: "eb:mt-0.5 eb:size-3.5 eb:shrink-0 eb:text-success", "aria-hidden": "true" }) : /* @__PURE__ */ jsx5(XCircle, { className: "eb:mt-0.5 eb:size-3.5 eb:shrink-0 eb:text-destructive", "aria-hidden": "true" }),
|
|
2470
|
-
/* @__PURE__ */ jsxs5("span", { className: "eb:min-w-0 eb:break-all", children: [
|
|
2471
|
-
r.email,
|
|
2472
|
-
r.error ? ` \u2014 ${r.error}` : ""
|
|
2473
|
-
] })
|
|
2474
|
-
] }, r.email)),
|
|
2475
|
-
report.invalid.map((email2) => /* @__PURE__ */ jsx5("li", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("Ignored (invalid): {email}", { email: email2 }) }, `invalid-${email2}`))
|
|
2476
|
-
] }),
|
|
2477
|
-
/* @__PURE__ */ jsxs5("div", { className: "eb:flex eb:justify-end eb:gap-2", children: [
|
|
2478
|
-
/* @__PURE__ */ jsx5(Button, { variant: "outline", onClick: () => setOpen(false), children: t("Close") }),
|
|
2479
|
-
/* @__PURE__ */ jsxs5(Button, { onClick: send, disabled: sending || !emails.length, children: [
|
|
2480
|
-
sending ? /* @__PURE__ */ jsx5(Loader24, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx5(Send, {}),
|
|
2481
|
-
t("Send")
|
|
2482
|
-
] })
|
|
2483
|
-
] })
|
|
2484
|
-
] }) })
|
|
2485
|
-
] });
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
2382
|
// src/features/test-email/index.js
|
|
2489
2383
|
var testEmailFeature = {
|
|
2490
2384
|
id: "test-email",
|
|
@@ -2495,9 +2389,9 @@ var testEmailFeature = {
|
|
|
2495
2389
|
};
|
|
2496
2390
|
|
|
2497
2391
|
// src/features/templates/TemplateGallery.jsx
|
|
2498
|
-
import { useEffect as useEffect4, useMemo as useMemo3, useState as
|
|
2392
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useState as useState5 } from "react";
|
|
2499
2393
|
import { LayoutTemplate, Search as Search2, X } from "lucide-react";
|
|
2500
|
-
import { Fragment as
|
|
2394
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2501
2395
|
var THUMBNAIL_SCALE = 0.38;
|
|
2502
2396
|
var EMAIL_WIDTH = 600;
|
|
2503
2397
|
var FADE_LINE = "eb:block eb:overflow-hidden eb:whitespace-nowrap eb:[mask-image:linear-gradient(to_right,#000_calc(100%-2.5rem),transparent)]";
|
|
@@ -2505,12 +2399,12 @@ var NO_SCROLLBAR = "<style>html,body{overflow:hidden!important;scrollbar-width:n
|
|
|
2505
2399
|
var withoutScrollbar = (html) => !html ? html : /<\/head>/i.test(html) ? html.replace(/<\/head>/i, `${NO_SCROLLBAR}</head>`) : NO_SCROLLBAR + html;
|
|
2506
2400
|
var fold = (text) => String(text || "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
2507
2401
|
function Thumbnail({ html, title }) {
|
|
2508
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ jsx5(
|
|
2509
2403
|
"div",
|
|
2510
2404
|
{
|
|
2511
2405
|
className: "eb:relative eb:h-[220px] eb:shrink-0 eb:overflow-hidden eb:rounded-lg2 eb:border eb:border-border eb:bg-surface-75",
|
|
2512
2406
|
"aria-hidden": "true",
|
|
2513
|
-
children: /* @__PURE__ */
|
|
2407
|
+
children: /* @__PURE__ */ jsx5(
|
|
2514
2408
|
"iframe",
|
|
2515
2409
|
{
|
|
2516
2410
|
title,
|
|
@@ -2532,10 +2426,10 @@ function Thumbnail({ html, title }) {
|
|
|
2532
2426
|
function TemplateGalleryButton({ context }) {
|
|
2533
2427
|
const { editor, ready, templates, isDirty, markDirty, template, setMeta } = context;
|
|
2534
2428
|
const { t, confirm, notify } = useUi();
|
|
2535
|
-
const [open, setOpen] =
|
|
2536
|
-
const [query, setQuery] =
|
|
2537
|
-
const [chosen, setChosen] =
|
|
2538
|
-
const [rendered, setRendered] =
|
|
2429
|
+
const [open, setOpen] = useState5(false);
|
|
2430
|
+
const [query, setQuery] = useState5("");
|
|
2431
|
+
const [chosen, setChosen] = useState5(() => /* @__PURE__ */ new Set());
|
|
2432
|
+
const [rendered, setRendered] = useState5({});
|
|
2539
2433
|
useEffect4(() => {
|
|
2540
2434
|
if (!open || !ready) return void 0;
|
|
2541
2435
|
let alive = true;
|
|
@@ -2592,8 +2486,8 @@ function TemplateGalleryButton({ context }) {
|
|
|
2592
2486
|
setOpen(false);
|
|
2593
2487
|
notify("success", t("\u201C{name}\u201D template applied.", { name: entry.name }));
|
|
2594
2488
|
};
|
|
2595
|
-
return /* @__PURE__ */
|
|
2596
|
-
/* @__PURE__ */
|
|
2489
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2490
|
+
/* @__PURE__ */ jsxs5(
|
|
2597
2491
|
Button,
|
|
2598
2492
|
{
|
|
2599
2493
|
variant: "outline",
|
|
@@ -2605,12 +2499,12 @@ function TemplateGalleryButton({ context }) {
|
|
|
2605
2499
|
setOpen(true);
|
|
2606
2500
|
},
|
|
2607
2501
|
children: [
|
|
2608
|
-
/* @__PURE__ */
|
|
2502
|
+
/* @__PURE__ */ jsx5(LayoutTemplate, {}),
|
|
2609
2503
|
t("Templates")
|
|
2610
2504
|
]
|
|
2611
2505
|
}
|
|
2612
2506
|
),
|
|
2613
|
-
/* @__PURE__ */
|
|
2507
|
+
/* @__PURE__ */ jsx5(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs5(
|
|
2614
2508
|
DialogContent,
|
|
2615
2509
|
{
|
|
2616
2510
|
className: "eb:flex eb:h-[min(48rem,calc(100dvh-2rem))] eb:flex-col eb:sm:max-w-4xl",
|
|
@@ -2622,14 +2516,14 @@ function TemplateGalleryButton({ context }) {
|
|
|
2622
2516
|
}
|
|
2623
2517
|
},
|
|
2624
2518
|
children: [
|
|
2625
|
-
/* @__PURE__ */
|
|
2626
|
-
/* @__PURE__ */
|
|
2627
|
-
/* @__PURE__ */
|
|
2519
|
+
/* @__PURE__ */ jsxs5(DialogHeader, { children: [
|
|
2520
|
+
/* @__PURE__ */ jsx5(DialogTitle, { children: t("Start from a template") }),
|
|
2521
|
+
/* @__PURE__ */ jsx5(DialogDescription, { children: t("Picking a template replaces the email being edited.") })
|
|
2628
2522
|
] }),
|
|
2629
|
-
/* @__PURE__ */
|
|
2630
|
-
/* @__PURE__ */
|
|
2631
|
-
/* @__PURE__ */
|
|
2632
|
-
/* @__PURE__ */
|
|
2523
|
+
/* @__PURE__ */ jsxs5("div", { className: "eb:flex eb:shrink-0 eb:flex-col eb:gap-3", children: [
|
|
2524
|
+
/* @__PURE__ */ jsxs5("div", { className: "eb:relative", children: [
|
|
2525
|
+
/* @__PURE__ */ jsx5(Search2, { className: "eb:pointer-events-none eb:absolute eb:top-1/2 eb:left-2.5 eb:size-3.5 eb:-translate-y-1/2 eb:text-foreground-muted" }),
|
|
2526
|
+
/* @__PURE__ */ jsx5(
|
|
2633
2527
|
Input,
|
|
2634
2528
|
{
|
|
2635
2529
|
type: "search",
|
|
@@ -2640,20 +2534,20 @@ function TemplateGalleryButton({ context }) {
|
|
|
2640
2534
|
className: "eb:pr-8 eb:pl-8 eb:[&::-webkit-search-cancel-button]:hidden"
|
|
2641
2535
|
}
|
|
2642
2536
|
),
|
|
2643
|
-
query && /* @__PURE__ */
|
|
2537
|
+
query && /* @__PURE__ */ jsx5(
|
|
2644
2538
|
"button",
|
|
2645
2539
|
{
|
|
2646
2540
|
type: "button",
|
|
2647
2541
|
onClick: () => setQuery(""),
|
|
2648
2542
|
"aria-label": t("Clear the search"),
|
|
2649
2543
|
className: "eb:absolute eb:top-1/2 eb:right-2.5 eb:-translate-y-1/2 eb:cursor-pointer",
|
|
2650
|
-
children: /* @__PURE__ */
|
|
2544
|
+
children: /* @__PURE__ */ jsx5(X, { className: "eb:size-3.5 eb:text-foreground-muted eb:hover:text-foreground" })
|
|
2651
2545
|
}
|
|
2652
2546
|
)
|
|
2653
2547
|
] }),
|
|
2654
|
-
tags.length > 0 && /* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */
|
|
2656
|
-
/* @__PURE__ */
|
|
2548
|
+
tags.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "eb:flex eb:items-start eb:gap-1.5", children: [
|
|
2549
|
+
/* @__PURE__ */ jsx5("div", { role: "group", "aria-label": t("Filter by tag"), className: "eb:flex eb:min-w-0 eb:flex-1 eb:flex-wrap eb:gap-1.5", "data-testid": "eb-gallery-tags", children: tags.map((tag) => /* @__PURE__ */ jsx5(FilterChip, { pressed: chosen.has(tag), onClick: () => toggle(tag), children: tag }, tag)) }),
|
|
2550
|
+
/* @__PURE__ */ jsx5(
|
|
2657
2551
|
FilterReset,
|
|
2658
2552
|
{
|
|
2659
2553
|
label: t("Clear the tag filters"),
|
|
@@ -2664,7 +2558,7 @@ function TemplateGalleryButton({ context }) {
|
|
|
2664
2558
|
)
|
|
2665
2559
|
] })
|
|
2666
2560
|
] }),
|
|
2667
|
-
/* @__PURE__ */
|
|
2561
|
+
/* @__PURE__ */ jsx5("div", { className: "eb:-m-1 eb:min-h-0 eb:flex-1 eb:overflow-y-auto eb:p-1", children: shown.length === 0 ? /* @__PURE__ */ jsx5("p", { className: "eb:m-0 eb:py-10 eb:text-center eb:text-[13px] eb:text-foreground-muted", children: t("Nothing matches \u201C{query}\u201D.", { query: query.trim() }) }) : /* @__PURE__ */ jsx5("ul", { className: "eb:m-0 eb:grid eb:list-none eb:grid-cols-1 eb:gap-3 eb:p-0 eb:sm:grid-cols-2 eb:md:grid-cols-3", children: shown.map((card) => /* @__PURE__ */ jsx5("li", { className: "eb:min-w-0", children: /* @__PURE__ */ jsxs5(
|
|
2668
2562
|
"button",
|
|
2669
2563
|
{
|
|
2670
2564
|
type: "button",
|
|
@@ -2673,10 +2567,10 @@ function TemplateGalleryButton({ context }) {
|
|
|
2673
2567
|
title: card.description,
|
|
2674
2568
|
className: "eb:group eb:flex eb:h-full eb:w-full eb:flex-col eb:gap-2 eb:rounded-lg2 eb:border eb:border-border eb:bg-background eb:p-2 eb:text-left eb:transition-colors eb:hover:border-primary/50 eb:hover:bg-primary/5 eb:focus-visible:outline-none eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50",
|
|
2675
2569
|
children: [
|
|
2676
|
-
/* @__PURE__ */
|
|
2677
|
-
/* @__PURE__ */
|
|
2678
|
-
/* @__PURE__ */
|
|
2679
|
-
/* @__PURE__ */
|
|
2570
|
+
/* @__PURE__ */ jsx5(Thumbnail, { html: card.html, title: card.name }),
|
|
2571
|
+
/* @__PURE__ */ jsxs5("span", { className: "eb:block eb:min-w-0 eb:px-1", children: [
|
|
2572
|
+
/* @__PURE__ */ jsx5("span", { className: cn(FADE_LINE, "eb:text-[13px] eb:font-medium eb:text-foreground"), children: card.name }),
|
|
2573
|
+
/* @__PURE__ */ jsx5("span", { className: cn(FADE_LINE, "eb:text-[12px] eb:text-foreground-muted"), children: card.description })
|
|
2680
2574
|
] })
|
|
2681
2575
|
]
|
|
2682
2576
|
}
|
|
@@ -2697,14 +2591,14 @@ var templatesFeature = {
|
|
|
2697
2591
|
};
|
|
2698
2592
|
|
|
2699
2593
|
// src/features/brand/BrandButton.jsx
|
|
2700
|
-
import { useEffect as useEffect5, useRef as useRef3, useState as
|
|
2701
|
-
import { Globe, ImageOff, Loader2 as
|
|
2594
|
+
import { useEffect as useEffect5, useRef as useRef3, useState as useState7 } from "react";
|
|
2595
|
+
import { Globe, ImageOff, Loader2 as Loader24, Palette, Trash2 as Trash23, TriangleAlert, WandSparkles } from "lucide-react";
|
|
2702
2596
|
|
|
2703
2597
|
// src/ui/primitives/color-picker.jsx
|
|
2704
|
-
import { useState as
|
|
2598
|
+
import { useState as useState6 } from "react";
|
|
2705
2599
|
import { HexAlphaColorPicker, HexColorPicker } from "react-colorful";
|
|
2706
2600
|
import { Check } from "lucide-react";
|
|
2707
|
-
import { jsx as
|
|
2601
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2708
2602
|
var PRESET_COLORS = [
|
|
2709
2603
|
"#8B5CF6",
|
|
2710
2604
|
"#A78BFA",
|
|
@@ -2744,14 +2638,14 @@ function colorToHex(value) {
|
|
|
2744
2638
|
}
|
|
2745
2639
|
function ColorPicker({ value, onChange, id, className, placeholder = "", alpha = true, dense = false, trigger = null }) {
|
|
2746
2640
|
const t = useT();
|
|
2747
|
-
const [open, setOpen] =
|
|
2641
|
+
const [open, setOpen] = useState6(false);
|
|
2748
2642
|
const hex = colorToHex(value);
|
|
2749
2643
|
const valid = isValidHex(hex);
|
|
2750
2644
|
const normalized = valid ? normalizeHex(hex) : "";
|
|
2751
2645
|
const Picker = alpha ? HexAlphaColorPicker : HexColorPicker;
|
|
2752
|
-
return /* @__PURE__ */
|
|
2753
|
-
/* @__PURE__ */
|
|
2754
|
-
/* @__PURE__ */
|
|
2646
|
+
return /* @__PURE__ */ jsxs6("div", { className: cn("eb:flex eb:gap-2", className), children: [
|
|
2647
|
+
/* @__PURE__ */ jsxs6(Popover, { open, onOpenChange: setOpen, children: [
|
|
2648
|
+
/* @__PURE__ */ jsx6(PopoverTrigger, { asChild: true, children: trigger || /* @__PURE__ */ jsx6(
|
|
2755
2649
|
"button",
|
|
2756
2650
|
{
|
|
2757
2651
|
type: "button",
|
|
@@ -2761,7 +2655,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2761
2655
|
"eb-checker eb:relative eb:h-7 eb:w-[44px] eb:shrink-0 eb:overflow-hidden eb:rounded-lg2 eb:shadow-sm eb:ring-1 eb:ring-black/10 eb:ring-inset eb:transition-transform eb:hover:scale-[1.04]",
|
|
2762
2656
|
dense && "eb:w-9"
|
|
2763
2657
|
),
|
|
2764
|
-
children: /* @__PURE__ */
|
|
2658
|
+
children: /* @__PURE__ */ jsx6(
|
|
2765
2659
|
"span",
|
|
2766
2660
|
{
|
|
2767
2661
|
className: "eb:absolute eb:inset-0",
|
|
@@ -2771,18 +2665,18 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2771
2665
|
)
|
|
2772
2666
|
}
|
|
2773
2667
|
) }),
|
|
2774
|
-
/* @__PURE__ */
|
|
2775
|
-
/* @__PURE__ */
|
|
2776
|
-
/* @__PURE__ */
|
|
2777
|
-
/* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ jsxs6(PopoverContent, { align: "start", className: "eb:w-64 eb:space-y-3 eb:p-3", children: [
|
|
2669
|
+
/* @__PURE__ */ jsx6("div", { className: "eb-picker", children: /* @__PURE__ */ jsx6(Picker, { color: valid ? hex : FALLBACK_COLOR, onChange: (next) => onChange(normalizeHex(next), { live: true }) }) }),
|
|
2670
|
+
/* @__PURE__ */ jsxs6("div", { className: "eb:flex eb:items-center eb:gap-2", children: [
|
|
2671
|
+
/* @__PURE__ */ jsx6(
|
|
2778
2672
|
"span",
|
|
2779
2673
|
{
|
|
2780
2674
|
className: "eb-checker eb:relative eb:size-8 eb:shrink-0 eb:overflow-hidden eb:rounded-lg2 eb:ring-1 eb:ring-black/10 eb:ring-inset",
|
|
2781
2675
|
"aria-hidden": true,
|
|
2782
|
-
children: /* @__PURE__ */
|
|
2676
|
+
children: /* @__PURE__ */ jsx6("span", { className: "eb:absolute eb:inset-0", style: { backgroundColor: valid ? hex : "transparent" } })
|
|
2783
2677
|
}
|
|
2784
2678
|
),
|
|
2785
|
-
/* @__PURE__ */
|
|
2679
|
+
/* @__PURE__ */ jsx6(
|
|
2786
2680
|
Input,
|
|
2787
2681
|
{
|
|
2788
2682
|
value: hex,
|
|
@@ -2794,7 +2688,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2794
2688
|
}
|
|
2795
2689
|
)
|
|
2796
2690
|
] }),
|
|
2797
|
-
/* @__PURE__ */
|
|
2691
|
+
/* @__PURE__ */ jsx6("div", { className: "eb:grid eb:grid-cols-6 eb:gap-1.5 eb:border-t eb:border-border eb:pt-2.5", children: PRESET_COLORS.map((c) => /* @__PURE__ */ jsx6(
|
|
2798
2692
|
"button",
|
|
2799
2693
|
{
|
|
2800
2694
|
type: "button",
|
|
@@ -2803,13 +2697,13 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2803
2697
|
"aria-label": c,
|
|
2804
2698
|
className: "eb:relative eb:size-6 eb:rounded-lg2 eb:ring-1 eb:ring-black/10 eb:ring-inset eb:transition-transform eb:hover:scale-110",
|
|
2805
2699
|
style: { backgroundColor: c },
|
|
2806
|
-
children: normalized === c && /* @__PURE__ */
|
|
2700
|
+
children: normalized === c && /* @__PURE__ */ jsx6(Check, { className: "eb:absolute eb:inset-0 eb:m-auto eb:size-3.5 eb:text-white eb:drop-shadow-[0_1px_1px_rgba(0,0,0,0.6)]" })
|
|
2807
2701
|
},
|
|
2808
2702
|
c
|
|
2809
2703
|
)) })
|
|
2810
2704
|
] })
|
|
2811
2705
|
] }),
|
|
2812
|
-
!trigger && /* @__PURE__ */
|
|
2706
|
+
!trigger && /* @__PURE__ */ jsx6(
|
|
2813
2707
|
Input,
|
|
2814
2708
|
{
|
|
2815
2709
|
id,
|
|
@@ -2825,7 +2719,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2825
2719
|
}
|
|
2826
2720
|
|
|
2827
2721
|
// src/features/brand/BrandButton.jsx
|
|
2828
|
-
import { Fragment as
|
|
2722
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2829
2723
|
var toForm = (brand) => ({
|
|
2830
2724
|
name: brand.name || "",
|
|
2831
2725
|
logoUrl: brand.logoUrl || "",
|
|
@@ -2842,18 +2736,18 @@ var isLogoUrl = (url) => !url || url.startsWith("/") || /^https:\/\//i.test(url)
|
|
|
2842
2736
|
function BrandButton({ context }) {
|
|
2843
2737
|
const { editor, ready, storage, brand, setBrand, hostSender } = context;
|
|
2844
2738
|
const { t, notify } = useUi();
|
|
2845
|
-
const [open, setOpen] =
|
|
2846
|
-
const [form, setForm] =
|
|
2847
|
-
const [applyNow, setApplyNow] =
|
|
2848
|
-
const [reading, setReading] =
|
|
2849
|
-
const [readError, setReadError] =
|
|
2850
|
-
const [notes, setNotes] =
|
|
2739
|
+
const [open, setOpen] = useState7(false);
|
|
2740
|
+
const [form, setForm] = useState7(() => toForm(brand || {}));
|
|
2741
|
+
const [applyNow, setApplyNow] = useState7(true);
|
|
2742
|
+
const [reading, setReading] = useState7(false);
|
|
2743
|
+
const [readError, setReadError] = useState7("");
|
|
2744
|
+
const [notes, setNotes] = useState7(
|
|
2851
2745
|
/** @type {string[]} */
|
|
2852
2746
|
[]
|
|
2853
2747
|
);
|
|
2854
|
-
const [uploading, setUploading] =
|
|
2855
|
-
const [saving, setSaving] =
|
|
2856
|
-
const [error, setError] =
|
|
2748
|
+
const [uploading, setUploading] = useState7(false);
|
|
2749
|
+
const [saving, setSaving] = useState7(false);
|
|
2750
|
+
const [error, setError] = useState7("");
|
|
2857
2751
|
const abortRef = useRef3(
|
|
2858
2752
|
/** @type {AbortController|null} */
|
|
2859
2753
|
null
|
|
@@ -2976,12 +2870,12 @@ function BrandButton({ context }) {
|
|
|
2976
2870
|
}
|
|
2977
2871
|
};
|
|
2978
2872
|
const swatch = brand?.primary;
|
|
2979
|
-
const logoShown = uploading ? /* @__PURE__ */
|
|
2980
|
-
return /* @__PURE__ */
|
|
2981
|
-
/* @__PURE__ */
|
|
2982
|
-
/* @__PURE__ */
|
|
2873
|
+
const logoShown = uploading ? /* @__PURE__ */ jsx7(Loader24, { className: "eb:size-4 eb:animate-spin eb:text-foreground-muted", "aria-hidden": "true" }) : form.logoUrl && !logoInvalid ? /* @__PURE__ */ jsx7("img", { src: logoSrc, alt: t("Logo"), className: "eb:max-h-16 eb:max-w-16 eb:object-contain" }) : /* @__PURE__ */ jsx7(ImageOff, { className: "eb:size-4 eb:text-foreground-muted", "aria-hidden": "true" });
|
|
2874
|
+
return /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
2875
|
+
/* @__PURE__ */ jsxs7(Button, { variant: "outline", size: "sm-compact", disabled: !ready, onClick: openDialog, "data-testid": "eb-brand-button", children: [
|
|
2876
|
+
/* @__PURE__ */ jsx7(Palette, {}),
|
|
2983
2877
|
t("Brand"),
|
|
2984
|
-
swatch && /* @__PURE__ */
|
|
2878
|
+
swatch && /* @__PURE__ */ jsx7(
|
|
2985
2879
|
"span",
|
|
2986
2880
|
{
|
|
2987
2881
|
"aria-hidden": "true",
|
|
@@ -2990,18 +2884,18 @@ function BrandButton({ context }) {
|
|
|
2990
2884
|
}
|
|
2991
2885
|
)
|
|
2992
2886
|
] }),
|
|
2993
|
-
/* @__PURE__ */
|
|
2887
|
+
/* @__PURE__ */ jsx7(Dialog, { open, onOpenChange: close, children: /* @__PURE__ */ jsxs7(
|
|
2994
2888
|
DialogContent,
|
|
2995
2889
|
{
|
|
2996
2890
|
className: "eb:flex eb:max-h-[calc(100dvh-2rem)] eb:flex-col eb:gap-0 eb:p-0 eb:sm:max-w-2xl",
|
|
2997
2891
|
"data-testid": "eb-brand",
|
|
2998
2892
|
children: [
|
|
2999
|
-
/* @__PURE__ */
|
|
3000
|
-
/* @__PURE__ */
|
|
3001
|
-
/* @__PURE__ */
|
|
2893
|
+
/* @__PURE__ */ jsxs7(DialogHeader, { className: "eb:gap-1.5 eb:px-6 eb:pt-6 eb:pb-4", children: [
|
|
2894
|
+
/* @__PURE__ */ jsx7(DialogTitle, { children: t("Your brand") }),
|
|
2895
|
+
/* @__PURE__ */ jsx7(DialogDescription, { children: t("Set it once: new emails, templates and blocks take your logo, colors and font.") })
|
|
3002
2896
|
] }),
|
|
3003
|
-
/* @__PURE__ */
|
|
3004
|
-
canRead && /* @__PURE__ */
|
|
2897
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:min-h-0 eb:flex-1 eb:overflow-y-auto eb:border-y eb:border-border eb:px-6 eb:py-5", children: [
|
|
2898
|
+
canRead && /* @__PURE__ */ jsxs7(
|
|
3005
2899
|
"form",
|
|
3006
2900
|
{
|
|
3007
2901
|
className: "eb:mb-5 eb:flex eb:flex-col eb:gap-1.5",
|
|
@@ -3010,11 +2904,11 @@ function BrandButton({ context }) {
|
|
|
3010
2904
|
readWebsite();
|
|
3011
2905
|
},
|
|
3012
2906
|
children: [
|
|
3013
|
-
/* @__PURE__ */
|
|
3014
|
-
/* @__PURE__ */
|
|
3015
|
-
/* @__PURE__ */
|
|
3016
|
-
/* @__PURE__ */
|
|
3017
|
-
/* @__PURE__ */
|
|
2907
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-website", children: t("Your website") }),
|
|
2908
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-2 eb:sm:flex-row", children: [
|
|
2909
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:relative eb:min-w-0 eb:flex-1", children: [
|
|
2910
|
+
/* @__PURE__ */ jsx7(Globe, { className: "eb:pointer-events-none eb:absolute eb:top-1/2 eb:left-2.5 eb:size-3.5 eb:-translate-y-1/2 eb:text-foreground-muted", "aria-hidden": "true" }),
|
|
2911
|
+
/* @__PURE__ */ jsx7(
|
|
3018
2912
|
Input,
|
|
3019
2913
|
{
|
|
3020
2914
|
id: "eb-brand-website",
|
|
@@ -3029,25 +2923,25 @@ function BrandButton({ context }) {
|
|
|
3029
2923
|
}
|
|
3030
2924
|
)
|
|
3031
2925
|
] }),
|
|
3032
|
-
/* @__PURE__ */
|
|
3033
|
-
reading ? /* @__PURE__ */
|
|
2926
|
+
/* @__PURE__ */ jsxs7(Button, { type: "submit", size: "sm", className: "eb:h-7", disabled: reading || !form.website.trim(), children: [
|
|
2927
|
+
reading ? /* @__PURE__ */ jsx7(Loader24, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx7(WandSparkles, {}),
|
|
3034
2928
|
t("Get my brand")
|
|
3035
2929
|
] })
|
|
3036
2930
|
] }),
|
|
3037
|
-
reading ? /* @__PURE__ */
|
|
3038
|
-
/* @__PURE__ */
|
|
2931
|
+
reading ? /* @__PURE__ */ jsx7("p", { role: "status", className: "eb:text-[12px] eb:text-foreground-muted", children: t("Reading the website\u2026") }) : readError ? /* @__PURE__ */ jsxs7("p", { role: "alert", className: "eb:flex eb:items-start eb:gap-1.5 eb:text-[12px] eb:text-destructive", children: [
|
|
2932
|
+
/* @__PURE__ */ jsx7(TriangleAlert, { className: "eb:mt-px eb:size-3.5 eb:shrink-0", "aria-hidden": "true" }),
|
|
3039
2933
|
readError
|
|
3040
|
-
] }) : notes.length ? /* @__PURE__ */
|
|
2934
|
+
] }) : notes.length ? /* @__PURE__ */ jsx7("ul", { className: "eb:flex eb:flex-col eb:gap-1 eb:text-[12px] eb:text-foreground-muted", "data-testid": "eb-brand-notes", children: notes.map((note) => /* @__PURE__ */ jsx7("li", { children: t(BRAND_NOTES[note]) }, note)) }) : /* @__PURE__ */ jsx7("p", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("The logo, colors and font are read from it. You can change them before saving.") })
|
|
3041
2935
|
]
|
|
3042
2936
|
}
|
|
3043
2937
|
),
|
|
3044
|
-
/* @__PURE__ */
|
|
3045
|
-
/* @__PURE__ */
|
|
3046
|
-
/* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3049
|
-
/* @__PURE__ */
|
|
3050
|
-
canUpload ? /* @__PURE__ */
|
|
2938
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:grid eb:gap-6 eb:sm:grid-cols-[minmax(0,1fr)_240px]", children: [
|
|
2939
|
+
/* @__PURE__ */ jsxs7("fieldset", { disabled: reading, className: "eb:m-0 eb:flex eb:min-w-0 eb:flex-col eb:gap-4 eb:border-0 eb:p-0", children: [
|
|
2940
|
+
/* @__PURE__ */ jsx7("legend", { className: "eb:sr-only", children: t("Your brand") }),
|
|
2941
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
2942
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-logo", children: t("Logo") }),
|
|
2943
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:items-start eb:gap-3", children: [
|
|
2944
|
+
canUpload ? /* @__PURE__ */ jsx7(
|
|
3051
2945
|
"button",
|
|
3052
2946
|
{
|
|
3053
2947
|
type: "button",
|
|
@@ -3059,8 +2953,8 @@ function BrandButton({ context }) {
|
|
|
3059
2953
|
className: cn(LOGO_SQUARE, "eb:cursor-pointer eb:outline-none eb:transition-shadow eb:hover:ring-primary/60 eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50 eb:disabled:cursor-wait"),
|
|
3060
2954
|
children: logoShown
|
|
3061
2955
|
}
|
|
3062
|
-
) : /* @__PURE__ */
|
|
3063
|
-
canUpload && /* @__PURE__ */
|
|
2956
|
+
) : /* @__PURE__ */ jsx7("div", { className: LOGO_SQUARE, children: logoShown }),
|
|
2957
|
+
canUpload && /* @__PURE__ */ jsx7(
|
|
3064
2958
|
"input",
|
|
3065
2959
|
{
|
|
3066
2960
|
ref: fileRef,
|
|
@@ -3073,8 +2967,8 @@ function BrandButton({ context }) {
|
|
|
3073
2967
|
onChange: pickLogo
|
|
3074
2968
|
}
|
|
3075
2969
|
),
|
|
3076
|
-
/* @__PURE__ */
|
|
3077
|
-
/* @__PURE__ */
|
|
2970
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:min-w-0 eb:flex-1 eb:flex-col eb:items-start eb:gap-1.5", children: [
|
|
2971
|
+
/* @__PURE__ */ jsx7(
|
|
3078
2972
|
Input,
|
|
3079
2973
|
{
|
|
3080
2974
|
id: "eb-brand-logo",
|
|
@@ -3086,17 +2980,17 @@ function BrandButton({ context }) {
|
|
|
3086
2980
|
className: "eb:text-[12px]"
|
|
3087
2981
|
}
|
|
3088
2982
|
),
|
|
3089
|
-
logoInvalid && /* @__PURE__ */
|
|
3090
|
-
form.logoUrl && /* @__PURE__ */
|
|
3091
|
-
/* @__PURE__ */
|
|
2983
|
+
logoInvalid && /* @__PURE__ */ jsx7("p", { className: "eb:text-[12px] eb:text-destructive", children: t("An https:// address is required") }),
|
|
2984
|
+
form.logoUrl && /* @__PURE__ */ jsxs7(Button, { type: "button", variant: "ghost", size: "xs", onClick: () => set({ logoUrl: "", logoWidth: 0 }), children: [
|
|
2985
|
+
/* @__PURE__ */ jsx7(Trash23, {}),
|
|
3092
2986
|
t("Remove")
|
|
3093
2987
|
] })
|
|
3094
2988
|
] })
|
|
3095
2989
|
] })
|
|
3096
2990
|
] }),
|
|
3097
|
-
/* @__PURE__ */
|
|
3098
|
-
/* @__PURE__ */
|
|
3099
|
-
/* @__PURE__ */
|
|
2991
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
2992
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-name", children: t("Company name") }),
|
|
2993
|
+
/* @__PURE__ */ jsx7(
|
|
3100
2994
|
Input,
|
|
3101
2995
|
{
|
|
3102
2996
|
id: "eb-brand-name",
|
|
@@ -3108,49 +3002,49 @@ function BrandButton({ context }) {
|
|
|
3108
3002
|
}
|
|
3109
3003
|
)
|
|
3110
3004
|
] }),
|
|
3111
|
-
/* @__PURE__ */
|
|
3112
|
-
/* @__PURE__ */
|
|
3113
|
-
/* @__PURE__ */
|
|
3114
|
-
/* @__PURE__ */
|
|
3115
|
-
/* @__PURE__ */
|
|
3005
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:grid eb:gap-4 eb:sm:grid-cols-2", children: [
|
|
3006
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
3007
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-primary", children: t("Main color") }),
|
|
3008
|
+
/* @__PURE__ */ jsx7(ColorPicker, { id: "eb-brand-primary", value: form.primary, onChange: (primary) => set({ primary }), placeholder: PALETTE.navy, alpha: false, dense: true }),
|
|
3009
|
+
/* @__PURE__ */ jsx7("p", { className: "eb:text-[11px] eb:text-foreground-muted", children: t("Buttons, banners, links") })
|
|
3116
3010
|
] }),
|
|
3117
|
-
/* @__PURE__ */
|
|
3118
|
-
/* @__PURE__ */
|
|
3119
|
-
/* @__PURE__ */
|
|
3011
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
3012
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-heading", children: t("Headings color") }),
|
|
3013
|
+
/* @__PURE__ */ jsx7(ColorPicker, { id: "eb-brand-heading", value: form.heading, onChange: (heading2) => set({ heading: heading2 }), placeholder: PALETTE.navy, alpha: false, dense: true })
|
|
3120
3014
|
] })
|
|
3121
3015
|
] }),
|
|
3122
|
-
/* @__PURE__ */
|
|
3123
|
-
/* @__PURE__ */
|
|
3124
|
-
/* @__PURE__ */
|
|
3125
|
-
/* @__PURE__ */
|
|
3126
|
-
/* @__PURE__ */
|
|
3127
|
-
/* @__PURE__ */
|
|
3016
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:grid eb:gap-4 eb:sm:grid-cols-2", children: [
|
|
3017
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
3018
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-font", children: t("Font") }),
|
|
3019
|
+
/* @__PURE__ */ jsxs7(Select, { value: form.font || FONT_STACK, onValueChange: (font) => set({ font }), children: [
|
|
3020
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { id: "eb-brand-font", dense: true, children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
3021
|
+
/* @__PURE__ */ jsx7(SelectContent, { children: FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx7(SelectItem, { value: option.value, children: /* @__PURE__ */ jsx7("span", { style: { fontFamily: option.value }, children: option.label }) }, option.value)) })
|
|
3128
3022
|
] })
|
|
3129
3023
|
] }),
|
|
3130
|
-
/* @__PURE__ */
|
|
3131
|
-
/* @__PURE__ */
|
|
3132
|
-
/* @__PURE__ */
|
|
3133
|
-
/* @__PURE__ */
|
|
3134
|
-
/* @__PURE__ */
|
|
3024
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
3025
|
+
/* @__PURE__ */ jsx7(Label, { htmlFor: "eb-brand-font-size", children: t("Font size") }),
|
|
3026
|
+
/* @__PURE__ */ jsxs7(Select, { value: String(form.fontSize || TEXT_SIZE), onValueChange: (size) => set({ fontSize: Number(size) }), children: [
|
|
3027
|
+
/* @__PURE__ */ jsx7(SelectTrigger, { id: "eb-brand-font-size", dense: true, "aria-describedby": "eb-brand-font-size-hint", children: /* @__PURE__ */ jsx7(SelectValue, {}) }),
|
|
3028
|
+
/* @__PURE__ */ jsx7(SelectContent, { children: BRAND_FONT_SIZES.map((size) => /* @__PURE__ */ jsxs7(SelectItem, { value: String(size), children: [
|
|
3135
3029
|
size,
|
|
3136
3030
|
" px"
|
|
3137
3031
|
] }, size)) })
|
|
3138
3032
|
] }),
|
|
3139
|
-
/* @__PURE__ */
|
|
3033
|
+
/* @__PURE__ */ jsx7("p", { id: "eb-brand-font-size-hint", className: "eb:text-[11px] eb:text-foreground-muted", children: t("Paragraphs; headings keep theirs") })
|
|
3140
3034
|
] })
|
|
3141
3035
|
] })
|
|
3142
3036
|
] }),
|
|
3143
|
-
/* @__PURE__ */
|
|
3037
|
+
/* @__PURE__ */ jsx7(BrandPreview, { brand: draft, logoSrc: logoInvalid ? "" : logoSrc, fallbackName: hostSender?.name || t("Your company") })
|
|
3144
3038
|
] })
|
|
3145
3039
|
] }),
|
|
3146
|
-
/* @__PURE__ */
|
|
3147
|
-
error && /* @__PURE__ */
|
|
3148
|
-
/* @__PURE__ */
|
|
3040
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-3 eb:px-6 eb:pt-3 eb:pb-6", children: [
|
|
3041
|
+
error && /* @__PURE__ */ jsxs7("p", { role: "alert", className: "eb:flex eb:items-start eb:gap-1.5 eb:text-[12px] eb:text-destructive", children: [
|
|
3042
|
+
/* @__PURE__ */ jsx7(TriangleAlert, { className: "eb:mt-px eb:size-3.5 eb:shrink-0", "aria-hidden": "true" }),
|
|
3149
3043
|
error
|
|
3150
3044
|
] }),
|
|
3151
|
-
/* @__PURE__ */
|
|
3152
|
-
/* @__PURE__ */
|
|
3153
|
-
/* @__PURE__ */
|
|
3045
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-3 eb:sm:flex-row eb:sm:items-center", children: [
|
|
3046
|
+
/* @__PURE__ */ jsxs7("label", { className: "eb:flex eb:cursor-pointer eb:items-center eb:gap-2 eb:text-[13px] eb:sm:mr-auto", children: [
|
|
3047
|
+
/* @__PURE__ */ jsx7(
|
|
3154
3048
|
"input",
|
|
3155
3049
|
{
|
|
3156
3050
|
type: "checkbox",
|
|
@@ -3162,10 +3056,10 @@ function BrandButton({ context }) {
|
|
|
3162
3056
|
),
|
|
3163
3057
|
t("Also apply to this email")
|
|
3164
3058
|
] }),
|
|
3165
|
-
/* @__PURE__ */
|
|
3166
|
-
/* @__PURE__ */
|
|
3167
|
-
/* @__PURE__ */
|
|
3168
|
-
saving && /* @__PURE__ */
|
|
3059
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:justify-end eb:gap-2", children: [
|
|
3060
|
+
/* @__PURE__ */ jsx7(Button, { variant: "outline", size: "sm", onClick: () => close(false), children: t("Cancel") }),
|
|
3061
|
+
/* @__PURE__ */ jsxs7(Button, { size: "sm", onClick: save, disabled: saving || reading || uploading || logoInvalid, "data-testid": "eb-brand-save", children: [
|
|
3062
|
+
saving && /* @__PURE__ */ jsx7(Loader24, { className: "eb:animate-spin" }),
|
|
3169
3063
|
t("Save")
|
|
3170
3064
|
] })
|
|
3171
3065
|
] })
|
|
@@ -3185,30 +3079,30 @@ function BrandPreview({ brand, logoSrc, fallbackName }) {
|
|
|
3185
3079
|
const font = brand.font || FONT_STACK;
|
|
3186
3080
|
const textSize = (brand.fontSize || TEXT_SIZE) * 3 / 5;
|
|
3187
3081
|
const name = brand.name || fallbackName;
|
|
3188
|
-
return /* @__PURE__ */
|
|
3189
|
-
/* @__PURE__ */
|
|
3190
|
-
/* @__PURE__ */
|
|
3082
|
+
return /* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-col eb:gap-1.5", children: [
|
|
3083
|
+
/* @__PURE__ */ jsx7("span", { className: "eb:text-[12px] eb:font-medium eb:text-foreground-muted", children: t("Preview") }),
|
|
3084
|
+
/* @__PURE__ */ jsx7(
|
|
3191
3085
|
"div",
|
|
3192
3086
|
{
|
|
3193
3087
|
className: "eb:flex eb:flex-1 eb:flex-col eb:overflow-hidden eb:rounded-lg2 eb:p-2.5 eb:ring-1 eb:ring-border",
|
|
3194
3088
|
style: { backgroundColor: PALETTE.canvas, fontFamily: font },
|
|
3195
3089
|
"data-testid": "eb-brand-preview",
|
|
3196
3090
|
"aria-hidden": "true",
|
|
3197
|
-
children: /* @__PURE__ */
|
|
3198
|
-
/* @__PURE__ */
|
|
3199
|
-
/* @__PURE__ */
|
|
3200
|
-
/* @__PURE__ */
|
|
3201
|
-
/* @__PURE__ */
|
|
3091
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-1 eb:flex-col eb:overflow-hidden eb:rounded-[3px]", style: { backgroundColor: PALETTE.white }, children: [
|
|
3092
|
+
/* @__PURE__ */ jsx7("div", { className: "eb:px-3 eb:pt-3 eb:pb-2", children: logoSrc ? /* @__PURE__ */ jsx7("img", { src: logoSrc, alt: "", style: { width: Math.round((brand.logoWidth || 140) * 0.45), maxWidth: "100%" } }) : /* @__PURE__ */ jsx7("span", { className: "eb:text-[11px] eb:font-bold", style: { color: PALETTE.ink }, children: name }) }),
|
|
3093
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:px-3 eb:py-4 eb:text-center", style: { backgroundColor: primary, color: onPrimary }, children: [
|
|
3094
|
+
/* @__PURE__ */ jsx7("div", { className: "eb:text-[13px] eb:leading-tight eb:font-bold", children: t("Big news") }),
|
|
3095
|
+
/* @__PURE__ */ jsx7("div", { className: "eb:mt-1 eb:text-[9px] eb:opacity-90", children: t("A short line under the title.") })
|
|
3202
3096
|
] }),
|
|
3203
|
-
/* @__PURE__ */
|
|
3204
|
-
/* @__PURE__ */
|
|
3205
|
-
/* @__PURE__ */
|
|
3097
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:flex eb:flex-1 eb:flex-col eb:gap-1.5 eb:px-3 eb:py-3", children: [
|
|
3098
|
+
/* @__PURE__ */ jsx7("div", { className: "eb:text-[11px] eb:leading-tight eb:font-bold", style: { color: heading2 }, children: t("A headline") }),
|
|
3099
|
+
/* @__PURE__ */ jsxs7("div", { className: "eb:leading-snug", style: { color: PALETTE.ink, fontSize: textSize }, children: [
|
|
3206
3100
|
t("Some text, with"),
|
|
3207
3101
|
" ",
|
|
3208
|
-
/* @__PURE__ */
|
|
3102
|
+
/* @__PURE__ */ jsx7("span", { className: "eb:underline", style: { color: link2 }, children: t("a link") }),
|
|
3209
3103
|
"."
|
|
3210
3104
|
] }),
|
|
3211
|
-
/* @__PURE__ */
|
|
3105
|
+
/* @__PURE__ */ jsx7(
|
|
3212
3106
|
"span",
|
|
3213
3107
|
{
|
|
3214
3108
|
className: cn("eb:mt-1 eb:self-start eb:rounded-[3px] eb:px-2.5 eb:py-1 eb:text-[9px] eb:font-bold"),
|
|
@@ -3217,7 +3111,7 @@ function BrandPreview({ brand, logoSrc, fallbackName }) {
|
|
|
3217
3111
|
}
|
|
3218
3112
|
)
|
|
3219
3113
|
] }),
|
|
3220
|
-
/* @__PURE__ */
|
|
3114
|
+
/* @__PURE__ */ jsx7("div", { className: "eb:px-3 eb:pb-2.5 eb:text-center eb:text-[7px]", style: { color: "#6d7484" }, children: name })
|
|
3221
3115
|
] })
|
|
3222
3116
|
}
|
|
3223
3117
|
)
|
|
@@ -4926,6 +4820,16 @@ function createCanvasView(options) {
|
|
|
4926
4820
|
insertText(text) {
|
|
4927
4821
|
dropPreview();
|
|
4928
4822
|
if (!restoreCaret()) return false;
|
|
4823
|
+
const selection = win.getSelection();
|
|
4824
|
+
const range = selection?.rangeCount ? selection.getRangeAt(0) : null;
|
|
4825
|
+
let after = "";
|
|
4826
|
+
if (range && editingEl) {
|
|
4827
|
+
const rest = doc.createRange();
|
|
4828
|
+
rest.setStart(range.endContainer, range.endOffset);
|
|
4829
|
+
rest.setEnd(editingEl, editingEl.childNodes.length);
|
|
4830
|
+
after = rest.toString().charAt(0);
|
|
4831
|
+
}
|
|
4832
|
+
if (after && /\s/.test(after)) text = text.replace(/\s+$/, "");
|
|
4929
4833
|
doc.execCommand("insertText", false, text);
|
|
4930
4834
|
options.onEditInput(
|
|
4931
4835
|
/** @type {string} */
|
|
@@ -5637,7 +5541,7 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
|
|
|
5637
5541
|
const node = selectedId ? findNode(root, selectedId) : null;
|
|
5638
5542
|
if (!node || !TEXT_TAGS.has(node.tag)) return false;
|
|
5639
5543
|
view.settlePreview();
|
|
5640
|
-
commit(setContent(root, node.id, `${node.content || ""} ${escapeText(text)}`));
|
|
5544
|
+
commit(setContent(root, node.id, `${node.content || ""} ${escapeText(text.trimEnd())}`));
|
|
5641
5545
|
return true;
|
|
5642
5546
|
},
|
|
5643
5547
|
previewText(text) {
|
|
@@ -5747,7 +5651,7 @@ function createDefaultEmailEditor(options = {}) {
|
|
|
5747
5651
|
|
|
5748
5652
|
// src/ui/EmailCanvas.jsx
|
|
5749
5653
|
import { useEffect as useEffect6, useRef as useRef4 } from "react";
|
|
5750
|
-
import { jsx as
|
|
5654
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
5751
5655
|
function EmailCanvas({ editor, document: document2 = null, onReady, onError, className }) {
|
|
5752
5656
|
const ref = useRef4(null);
|
|
5753
5657
|
const documentRef = useRef4(document2);
|
|
@@ -5766,15 +5670,15 @@ function EmailCanvas({ editor, document: document2 = null, onReady, onError, cla
|
|
|
5766
5670
|
editor.destroy();
|
|
5767
5671
|
};
|
|
5768
5672
|
}, [editor]);
|
|
5769
|
-
return /* @__PURE__ */
|
|
5673
|
+
return /* @__PURE__ */ jsx8("div", { ref, className: cn("eb-canvas eb:h-full eb:w-full", className), "data-testid": "eb-canvas" });
|
|
5770
5674
|
}
|
|
5771
5675
|
|
|
5772
5676
|
// src/ui/EmailBuilder.jsx
|
|
5773
|
-
import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as useRef14, useState as
|
|
5774
|
-
import { AlertTriangle, Loader2 as
|
|
5677
|
+
import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as useRef14, useState as useState18 } from "react";
|
|
5678
|
+
import { AlertTriangle, Loader2 as Loader26, Plus as Plus3, Save, SlidersHorizontal } from "lucide-react";
|
|
5775
5679
|
|
|
5776
5680
|
// src/features/brand/useBrand.js
|
|
5777
|
-
import { useCallback, useEffect as useEffect7, useState as
|
|
5681
|
+
import { useCallback, useEffect as useEffect7, useState as useState8 } from "react";
|
|
5778
5682
|
var entries = /* @__PURE__ */ new WeakMap();
|
|
5779
5683
|
function brandOf(storage) {
|
|
5780
5684
|
let entry = entries.get(storage);
|
|
@@ -5795,7 +5699,7 @@ function brandOf(storage) {
|
|
|
5795
5699
|
return created;
|
|
5796
5700
|
}
|
|
5797
5701
|
function useBrand(storage) {
|
|
5798
|
-
const [brand, setState] =
|
|
5702
|
+
const [brand, setState] = useState8(() => brandOf(storage).value);
|
|
5799
5703
|
useEffect7(() => {
|
|
5800
5704
|
const entry = brandOf(storage);
|
|
5801
5705
|
setState(entry.value);
|
|
@@ -5860,7 +5764,7 @@ function createAutosaveScheduler({
|
|
|
5860
5764
|
}
|
|
5861
5765
|
|
|
5862
5766
|
// src/features/autosave/localDraft.js
|
|
5863
|
-
var
|
|
5767
|
+
var KEY = "best-email-builder:new-template-draft";
|
|
5864
5768
|
var MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
5865
5769
|
function usable(store) {
|
|
5866
5770
|
return store && typeof store.getItem === "function" ? store : null;
|
|
@@ -5876,7 +5780,7 @@ function saveLocalDraft({ document: document2, meta }, store = defaultStore()) {
|
|
|
5876
5780
|
const target = usable(store);
|
|
5877
5781
|
if (!target) return false;
|
|
5878
5782
|
try {
|
|
5879
|
-
target.setItem(
|
|
5783
|
+
target.setItem(KEY, JSON.stringify({ savedAt: Date.now(), document: document2, meta }));
|
|
5880
5784
|
return true;
|
|
5881
5785
|
} catch {
|
|
5882
5786
|
return false;
|
|
@@ -5886,22 +5790,22 @@ function readLocalDraft(store = defaultStore(), { now = Date.now() } = {}) {
|
|
|
5886
5790
|
const target = usable(store);
|
|
5887
5791
|
if (!target) return null;
|
|
5888
5792
|
try {
|
|
5889
|
-
const raw = target.getItem(
|
|
5793
|
+
const raw = target.getItem(KEY);
|
|
5890
5794
|
if (!raw) return null;
|
|
5891
5795
|
const parsed = JSON.parse(raw);
|
|
5892
5796
|
if (!parsed || now - Number(parsed.savedAt) > MAX_AGE_MS) {
|
|
5893
|
-
target.removeItem(
|
|
5797
|
+
target.removeItem(KEY);
|
|
5894
5798
|
return null;
|
|
5895
5799
|
}
|
|
5896
5800
|
return { savedAt: Number(parsed.savedAt), document: readDocument(parsed.document), meta: parsed.meta || {} };
|
|
5897
5801
|
} catch {
|
|
5898
|
-
target.removeItem(
|
|
5802
|
+
target.removeItem(KEY);
|
|
5899
5803
|
return null;
|
|
5900
5804
|
}
|
|
5901
5805
|
}
|
|
5902
5806
|
function clearLocalDraft(store = defaultStore()) {
|
|
5903
5807
|
try {
|
|
5904
|
-
usable(store)?.removeItem(
|
|
5808
|
+
usable(store)?.removeItem(KEY);
|
|
5905
5809
|
} catch {
|
|
5906
5810
|
}
|
|
5907
5811
|
}
|
|
@@ -5924,7 +5828,7 @@ import {
|
|
|
5924
5828
|
Type
|
|
5925
5829
|
} from "lucide-react";
|
|
5926
5830
|
import { useRef as useRef5 } from "react";
|
|
5927
|
-
import { jsx as
|
|
5831
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
5928
5832
|
var DRAG_THRESHOLD2 = 5;
|
|
5929
5833
|
var BLOCK_ICONS = {
|
|
5930
5834
|
Heading,
|
|
@@ -5950,7 +5854,7 @@ function BlockTile({ block, disabled, onAdd, onDragStart }) {
|
|
|
5950
5854
|
const t = useT();
|
|
5951
5855
|
const Icon = BLOCK_ICONS[block.icon] || Square;
|
|
5952
5856
|
const press = useRef5(null);
|
|
5953
|
-
return /* @__PURE__ */
|
|
5857
|
+
return /* @__PURE__ */ jsx9(TooltipWrap, { label: block.description ? t(block.description) : block.description, children: /* @__PURE__ */ jsxs8(
|
|
5954
5858
|
"button",
|
|
5955
5859
|
{
|
|
5956
5860
|
type: "button",
|
|
@@ -5990,8 +5894,8 @@ function BlockTile({ block, disabled, onAdd, onDragStart }) {
|
|
|
5990
5894
|
disabled && "eb:cursor-not-allowed eb:opacity-50"
|
|
5991
5895
|
),
|
|
5992
5896
|
children: [
|
|
5993
|
-
/* @__PURE__ */
|
|
5994
|
-
/* @__PURE__ */
|
|
5897
|
+
/* @__PURE__ */ jsx9(Icon, { className: "eb:h-5 eb:w-5 eb:text-foreground-lighter", "aria-hidden": "true" }),
|
|
5898
|
+
/* @__PURE__ */ jsx9("span", { className: "eb:text-[12px] eb:text-foreground", children: t(block.label) })
|
|
5995
5899
|
]
|
|
5996
5900
|
}
|
|
5997
5901
|
) });
|
|
@@ -5999,12 +5903,12 @@ function BlockTile({ block, disabled, onAdd, onDragStart }) {
|
|
|
5999
5903
|
function BlockSidebar({ editor, disabled = false, onAdded }) {
|
|
6000
5904
|
const t = useT();
|
|
6001
5905
|
const blocks = editor.listBlocks();
|
|
6002
|
-
return /* @__PURE__ */
|
|
5906
|
+
return /* @__PURE__ */ jsx9("aside", { "aria-label": t("Blocks"), className: "eb:min-h-0 eb:space-y-5 eb:overflow-y-auto eb:p-3", children: BLOCK_GROUPS.map((group) => {
|
|
6003
5907
|
const items = blocks.filter((b) => b.kind === group.kind && b.mjml);
|
|
6004
5908
|
if (!items.length) return null;
|
|
6005
|
-
return /* @__PURE__ */
|
|
6006
|
-
/* @__PURE__ */
|
|
6007
|
-
/* @__PURE__ */
|
|
5909
|
+
return /* @__PURE__ */ jsxs8("section", { className: "eb:space-y-2", children: [
|
|
5910
|
+
/* @__PURE__ */ jsx9(SectionLabel, { children: t(group.title) }),
|
|
5911
|
+
/* @__PURE__ */ jsx9("div", { className: "eb:grid eb:grid-cols-[repeat(auto-fill,minmax(80px,1fr))] eb:gap-2", children: items.map((block) => /* @__PURE__ */ jsx9(
|
|
6008
5912
|
BlockTile,
|
|
6009
5913
|
{
|
|
6010
5914
|
block,
|
|
@@ -6022,8 +5926,8 @@ function BlockSidebar({ editor, disabled = false, onAdded }) {
|
|
|
6022
5926
|
|
|
6023
5927
|
// src/ui/CanvasAddMenu.jsx
|
|
6024
5928
|
import { Square as Square2 } from "lucide-react";
|
|
6025
|
-
import { useEffect as useEffect8, useRef as useRef6, useState as
|
|
6026
|
-
import { jsx as
|
|
5929
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState9 } from "react";
|
|
5930
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
6027
5931
|
var TILE = cn(
|
|
6028
5932
|
"eb:flex eb:h-16 eb:min-w-0 eb:flex-col eb:items-center eb:justify-center eb:gap-1 eb:rounded-lg2 eb:border eb:border-border eb:bg-background eb:px-1 eb:text-center eb:transition-colors",
|
|
6029
5933
|
"eb:hover:border-primary/50 eb:hover:bg-primary/5 eb:focus-visible:outline-none eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50"
|
|
@@ -6031,7 +5935,7 @@ var TILE = cn(
|
|
|
6031
5935
|
var LABEL = "eb:line-clamp-2 eb:w-full eb:text-[11px] eb:leading-tight eb:break-words eb:text-foreground";
|
|
6032
5936
|
function CanvasAddMenu({ editor, onAdded }) {
|
|
6033
5937
|
const t = useT();
|
|
6034
|
-
const [menu, setMenu] =
|
|
5938
|
+
const [menu, setMenu] = useState9(null);
|
|
6035
5939
|
const added = useRef6(onAdded);
|
|
6036
5940
|
added.current = onAdded;
|
|
6037
5941
|
useEffect8(() => {
|
|
@@ -6058,8 +5962,8 @@ function CanvasAddMenu({ editor, onAdded }) {
|
|
|
6058
5962
|
}, [editor]);
|
|
6059
5963
|
const close = () => setMenu(null);
|
|
6060
5964
|
const label = menu?.kind === "item" ? t(menu.items.label) : t("Add a block");
|
|
6061
|
-
return /* @__PURE__ */
|
|
6062
|
-
menu && /* @__PURE__ */
|
|
5965
|
+
return /* @__PURE__ */ jsxs9(Popover, { open: Boolean(menu), onOpenChange: (open) => !open && close(), children: [
|
|
5966
|
+
menu && /* @__PURE__ */ jsx10(PopoverAnchor, { asChild: true, children: /* @__PURE__ */ jsx10(
|
|
6063
5967
|
"span",
|
|
6064
5968
|
{
|
|
6065
5969
|
"aria-hidden": "true",
|
|
@@ -6067,7 +5971,7 @@ function CanvasAddMenu({ editor, onAdded }) {
|
|
|
6067
5971
|
style: { top: menu.anchor.top, left: menu.anchor.left, width: menu.anchor.width, height: menu.anchor.height }
|
|
6068
5972
|
}
|
|
6069
5973
|
) }),
|
|
6070
|
-
menu && /* @__PURE__ */
|
|
5974
|
+
menu && /* @__PURE__ */ jsx10(
|
|
6071
5975
|
PopoverContent,
|
|
6072
5976
|
{
|
|
6073
5977
|
side: "bottom",
|
|
@@ -6080,7 +5984,7 @@ function CanvasAddMenu({ editor, onAdded }) {
|
|
|
6080
5984
|
event.currentTarget.focus();
|
|
6081
5985
|
},
|
|
6082
5986
|
className: cn("eb:space-y-3 eb:p-3", menu.kind === "item" ? "eb:w-72" : "eb:w-[25rem]"),
|
|
6083
|
-
children: menu.kind === "item" ? /* @__PURE__ */
|
|
5987
|
+
children: menu.kind === "item" ? /* @__PURE__ */ jsx10(
|
|
6084
5988
|
ItemChoices,
|
|
6085
5989
|
{
|
|
6086
5990
|
label,
|
|
@@ -6090,7 +5994,7 @@ function CanvasAddMenu({ editor, onAdded }) {
|
|
|
6090
5994
|
if (editor.addItem(choice, menu.id)) added.current?.();
|
|
6091
5995
|
}
|
|
6092
5996
|
}
|
|
6093
|
-
) : /* @__PURE__ */
|
|
5997
|
+
) : /* @__PURE__ */ jsx10(
|
|
6094
5998
|
BlockChoices,
|
|
6095
5999
|
{
|
|
6096
6000
|
blocks: editor.listBlocks(),
|
|
@@ -6109,13 +6013,13 @@ function BlockChoices({ blocks, onPick }) {
|
|
|
6109
6013
|
return BLOCK_GROUPS.map((group) => {
|
|
6110
6014
|
const items = blocks.filter((b) => b.kind === group.kind && b.mjml);
|
|
6111
6015
|
if (!items.length) return null;
|
|
6112
|
-
return /* @__PURE__ */
|
|
6113
|
-
/* @__PURE__ */
|
|
6114
|
-
/* @__PURE__ */
|
|
6016
|
+
return /* @__PURE__ */ jsxs9("section", { className: "eb:space-y-1.5", children: [
|
|
6017
|
+
/* @__PURE__ */ jsx10(SectionLabel, { children: t(group.title) }),
|
|
6018
|
+
/* @__PURE__ */ jsx10("div", { className: "eb:grid eb:grid-cols-4 eb:gap-1.5", children: items.map((block) => {
|
|
6115
6019
|
const Icon = BLOCK_ICONS[block.icon] || Square2;
|
|
6116
|
-
return /* @__PURE__ */
|
|
6117
|
-
/* @__PURE__ */
|
|
6118
|
-
/* @__PURE__ */
|
|
6020
|
+
return /* @__PURE__ */ jsxs9("button", { type: "button", "data-block-id": block.id, className: TILE, onClick: () => onPick(block.id), children: [
|
|
6021
|
+
/* @__PURE__ */ jsx10(Icon, { className: "eb:size-4 eb:text-foreground-lighter", "aria-hidden": "true" }),
|
|
6022
|
+
/* @__PURE__ */ jsx10("span", { className: LABEL, children: t(block.label) })
|
|
6119
6023
|
] }, block.id);
|
|
6120
6024
|
}) })
|
|
6121
6025
|
] }, group.kind);
|
|
@@ -6123,11 +6027,11 @@ function BlockChoices({ blocks, onPick }) {
|
|
|
6123
6027
|
}
|
|
6124
6028
|
function ItemChoices({ label, choices, onPick }) {
|
|
6125
6029
|
const t = useT();
|
|
6126
|
-
return /* @__PURE__ */
|
|
6127
|
-
/* @__PURE__ */
|
|
6128
|
-
/* @__PURE__ */
|
|
6129
|
-
choice.image ? /* @__PURE__ */
|
|
6130
|
-
/* @__PURE__ */
|
|
6030
|
+
return /* @__PURE__ */ jsxs9("section", { className: "eb:space-y-1.5", children: [
|
|
6031
|
+
/* @__PURE__ */ jsx10(SectionLabel, { children: label }),
|
|
6032
|
+
/* @__PURE__ */ jsx10("div", { className: "eb:grid eb:grid-cols-3 eb:gap-1.5", children: choices.map((choice) => /* @__PURE__ */ jsxs9("button", { type: "button", "data-choice": choice.label, className: TILE, onClick: () => onPick(choice), children: [
|
|
6033
|
+
choice.image ? /* @__PURE__ */ jsx10("img", { src: choice.image, alt: "", width: 24, height: 24, className: "eb:size-6 eb:rounded-full", style: { background: choice.color } }) : /* @__PURE__ */ jsx10(Square2, { className: "eb:size-4 eb:text-foreground-lighter", "aria-hidden": "true" }),
|
|
6034
|
+
/* @__PURE__ */ jsx10("span", { className: LABEL, children: t(choice.label) })
|
|
6131
6035
|
] }, choice.label)) })
|
|
6132
6036
|
] });
|
|
6133
6037
|
}
|
|
@@ -6137,9 +6041,9 @@ import { useMemo as useMemo5, useRef as useRef10 } from "react";
|
|
|
6137
6041
|
import { Smartphone, Trash2 as Trash24, X as X2 } from "lucide-react";
|
|
6138
6042
|
|
|
6139
6043
|
// src/ui/fields.jsx
|
|
6140
|
-
import { useEffect as useEffect9, useRef as useRef7, useState as
|
|
6141
|
-
import { AlignCenter, AlignJustify, AlignLeft, AlignRight, Loader2 as
|
|
6142
|
-
import { Fragment as
|
|
6044
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState10 } from "react";
|
|
6045
|
+
import { AlignCenter, AlignJustify, AlignLeft, AlignRight, Loader2 as Loader25, Upload } from "lucide-react";
|
|
6046
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
6143
6047
|
var COLOR_DEBOUNCE_MS = 250;
|
|
6144
6048
|
var COLOR_LIVE_MS = 60;
|
|
6145
6049
|
function emailColor(value) {
|
|
@@ -6152,7 +6056,7 @@ function emailColor(value) {
|
|
|
6152
6056
|
return `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 100) / 100})`;
|
|
6153
6057
|
}
|
|
6154
6058
|
function useDraft(value, toDraft) {
|
|
6155
|
-
const [draft, setDraft] =
|
|
6059
|
+
const [draft, setDraft] = useState10(() => toDraft(value));
|
|
6156
6060
|
const ref = useRef7(null);
|
|
6157
6061
|
const convert = useRef7(toDraft);
|
|
6158
6062
|
convert.current = toDraft;
|
|
@@ -6165,10 +6069,10 @@ function useDraft(value, toDraft) {
|
|
|
6165
6069
|
}
|
|
6166
6070
|
var asText = (v) => v || "";
|
|
6167
6071
|
function FieldLabel({ id, children }) {
|
|
6168
|
-
return /* @__PURE__ */
|
|
6072
|
+
return /* @__PURE__ */ jsx11(Label, { htmlFor: id, className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children });
|
|
6169
6073
|
}
|
|
6170
6074
|
function FieldError({ children }) {
|
|
6171
|
-
return children ? /* @__PURE__ */
|
|
6075
|
+
return children ? /* @__PURE__ */ jsx11("p", { className: "eb:text-[12px] eb:text-destructive", children }) : null;
|
|
6172
6076
|
}
|
|
6173
6077
|
function TextField({ id, property, value, fallback = "", onCommit, addon = null, error = null }) {
|
|
6174
6078
|
const t = useT();
|
|
@@ -6199,13 +6103,13 @@ function TextField({ id, property, value, fallback = "", onCommit, addon = null,
|
|
|
6199
6103
|
onKeyDown: keyDown,
|
|
6200
6104
|
"aria-invalid": invalid || void 0
|
|
6201
6105
|
};
|
|
6202
|
-
return /* @__PURE__ */
|
|
6203
|
-
/* @__PURE__ */
|
|
6204
|
-
property.type === "textarea" ? /* @__PURE__ */
|
|
6205
|
-
/* @__PURE__ */
|
|
6106
|
+
return /* @__PURE__ */ jsxs10("div", { ref, className: "eb:space-y-1", children: [
|
|
6107
|
+
/* @__PURE__ */ jsx11(FieldLabel, { id, children: t(property.label) }),
|
|
6108
|
+
property.type === "textarea" ? /* @__PURE__ */ jsx11(Textarea, { rows: 3, dense: true, ...shared }) : addon ? /* @__PURE__ */ jsxs10("div", { className: "eb:flex eb:gap-2", children: [
|
|
6109
|
+
/* @__PURE__ */ jsx11(Input, { ...shared, dense: true, className: "eb:min-w-0 eb:flex-1" }),
|
|
6206
6110
|
addon
|
|
6207
|
-
] }) : /* @__PURE__ */
|
|
6208
|
-
/* @__PURE__ */
|
|
6111
|
+
] }) : /* @__PURE__ */ jsx11(Input, { ...shared, dense: true }),
|
|
6112
|
+
/* @__PURE__ */ jsx11(FieldError, { children: invalid ? kind === "image" ? t("An https:// address is required") : t("Address not allowed") : error })
|
|
6209
6113
|
] });
|
|
6210
6114
|
}
|
|
6211
6115
|
function ImageField({ id, property, value, onCommit, services }) {
|
|
@@ -6214,8 +6118,8 @@ function ImageField({ id, property, value, onCommit, services }) {
|
|
|
6214
6118
|
/** @type {HTMLInputElement|null} */
|
|
6215
6119
|
null
|
|
6216
6120
|
);
|
|
6217
|
-
const [busy, setBusy] =
|
|
6218
|
-
const [error, setError] =
|
|
6121
|
+
const [busy, setBusy] = useState10(false);
|
|
6122
|
+
const [error, setError] = useState10(
|
|
6219
6123
|
/** @type {string|null} */
|
|
6220
6124
|
null
|
|
6221
6125
|
);
|
|
@@ -6237,8 +6141,8 @@ function ImageField({ id, property, value, onCommit, services }) {
|
|
|
6237
6141
|
setBusy(false);
|
|
6238
6142
|
}
|
|
6239
6143
|
};
|
|
6240
|
-
const addon = upload ? /* @__PURE__ */
|
|
6241
|
-
/* @__PURE__ */
|
|
6144
|
+
const addon = upload ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
6145
|
+
/* @__PURE__ */ jsx11(
|
|
6242
6146
|
"input",
|
|
6243
6147
|
{
|
|
6244
6148
|
ref: inputRef,
|
|
@@ -6251,7 +6155,7 @@ function ImageField({ id, property, value, onCommit, services }) {
|
|
|
6251
6155
|
onChange: pick
|
|
6252
6156
|
}
|
|
6253
6157
|
),
|
|
6254
|
-
/* @__PURE__ */
|
|
6158
|
+
/* @__PURE__ */ jsxs10(
|
|
6255
6159
|
Button,
|
|
6256
6160
|
{
|
|
6257
6161
|
type: "button",
|
|
@@ -6261,13 +6165,13 @@ function ImageField({ id, property, value, onCommit, services }) {
|
|
|
6261
6165
|
disabled: busy,
|
|
6262
6166
|
onClick: () => inputRef.current?.click(),
|
|
6263
6167
|
children: [
|
|
6264
|
-
busy ? /* @__PURE__ */
|
|
6168
|
+
busy ? /* @__PURE__ */ jsx11(Loader25, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx11(Upload, {}),
|
|
6265
6169
|
t("Upload")
|
|
6266
6170
|
]
|
|
6267
6171
|
}
|
|
6268
6172
|
)
|
|
6269
6173
|
] }) : null;
|
|
6270
|
-
return /* @__PURE__ */
|
|
6174
|
+
return /* @__PURE__ */ jsx11(TextField, { id, property, value, onCommit, addon, error });
|
|
6271
6175
|
}
|
|
6272
6176
|
var asNumber = (v) => {
|
|
6273
6177
|
const n = Number.parseFloat(String(v || ""));
|
|
@@ -6290,10 +6194,10 @@ function SizeField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6290
6194
|
const next = `${n}${nextUnit}`;
|
|
6291
6195
|
if (next !== value) onCommit(next);
|
|
6292
6196
|
};
|
|
6293
|
-
return /* @__PURE__ */
|
|
6294
|
-
/* @__PURE__ */
|
|
6295
|
-
/* @__PURE__ */
|
|
6296
|
-
/* @__PURE__ */
|
|
6197
|
+
return /* @__PURE__ */ jsxs10("div", { ref, className: "eb:space-y-1", children: [
|
|
6198
|
+
/* @__PURE__ */ jsx11(FieldLabel, { id, children: t(property.label) }),
|
|
6199
|
+
/* @__PURE__ */ jsxs10("div", { className: "eb:relative", children: [
|
|
6200
|
+
/* @__PURE__ */ jsx11(
|
|
6297
6201
|
Input,
|
|
6298
6202
|
{
|
|
6299
6203
|
id,
|
|
@@ -6315,18 +6219,18 @@ function SizeField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6315
6219
|
),
|
|
6316
6220
|
property.units ? (
|
|
6317
6221
|
// The unit, picked in the builder's own list (as the font's), not the browser's.
|
|
6318
|
-
/* @__PURE__ */
|
|
6319
|
-
/* @__PURE__ */
|
|
6222
|
+
/* @__PURE__ */ jsxs10(Select, { value: unit, onValueChange: (next) => commit(draft || asNumber(fallback) || "0", next), children: [
|
|
6223
|
+
/* @__PURE__ */ jsx11(
|
|
6320
6224
|
SelectTrigger,
|
|
6321
6225
|
{
|
|
6322
6226
|
"aria-label": `${t(property.label)} \u2014 ${t("Unit")}`,
|
|
6323
6227
|
className: "eb:absolute eb:top-1/2 eb:right-1 eb:h-5.5 eb:w-auto eb:-translate-y-1/2 eb:gap-0.5 eb:rounded-md eb:border-0 eb:bg-transparent eb:px-1.5 eb:text-[12px] eb:shadow-none eb:hover:bg-accent eb:[&_svg:not([class*='size-'])]:size-3",
|
|
6324
|
-
children: /* @__PURE__ */
|
|
6228
|
+
children: /* @__PURE__ */ jsx11(SelectValue, {})
|
|
6325
6229
|
}
|
|
6326
6230
|
),
|
|
6327
|
-
/* @__PURE__ */
|
|
6231
|
+
/* @__PURE__ */ jsx11(SelectContent, { align: "end", className: "eb:min-w-[4.5rem]", children: property.units.map((option) => /* @__PURE__ */ jsx11(SelectItem, { value: option, children: option }, option)) })
|
|
6328
6232
|
] })
|
|
6329
|
-
) : /* @__PURE__ */
|
|
6233
|
+
) : /* @__PURE__ */ jsx11("span", { className: "eb:pointer-events-none eb:absolute eb:right-2.5 eb:top-1/2 eb:-translate-y-1/2 eb:text-[12px] eb:text-foreground-muted", children: property.unit || "px" })
|
|
6330
6234
|
] })
|
|
6331
6235
|
] });
|
|
6332
6236
|
}
|
|
@@ -6354,9 +6258,9 @@ function ColorField({ id, property, value, fallback = "", onCommit, trigger = nu
|
|
|
6354
6258
|
if (wait <= 0) commit(next);
|
|
6355
6259
|
else timer.current = setTimeout(() => commit(next), wait);
|
|
6356
6260
|
};
|
|
6357
|
-
return /* @__PURE__ */
|
|
6358
|
-
!trigger && /* @__PURE__ */
|
|
6359
|
-
/* @__PURE__ */
|
|
6261
|
+
return /* @__PURE__ */ jsxs10("div", { ref, className: trigger ? "eb:contents" : "eb:space-y-1", children: [
|
|
6262
|
+
!trigger && /* @__PURE__ */ jsx11(FieldLabel, { id, children: t(property.label) }),
|
|
6263
|
+
/* @__PURE__ */ jsx11(ColorPicker, { id, value: draft, placeholder: emailColor(fallback) || "", onChange: change, dense: true, trigger })
|
|
6360
6264
|
] });
|
|
6361
6265
|
}
|
|
6362
6266
|
var DEFAULT_OPTION = "__default__";
|
|
@@ -6366,9 +6270,9 @@ function SelectField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6366
6270
|
const words = (v) => String(v || "").trim().split(/\s+/).sort().join(" ");
|
|
6367
6271
|
const fallbackOption = (property.options || []).find((o) => o.value && words(o.value) === words(fallback));
|
|
6368
6272
|
const defaultLabel = fallbackOption ? t("Default ({value})", { value: t(fallbackOption.label) }) : t("Default");
|
|
6369
|
-
return /* @__PURE__ */
|
|
6370
|
-
/* @__PURE__ */
|
|
6371
|
-
/* @__PURE__ */
|
|
6273
|
+
return /* @__PURE__ */ jsxs10("div", { className: "eb:space-y-1", children: [
|
|
6274
|
+
/* @__PURE__ */ jsx11(FieldLabel, { id, children: t(property.label) }),
|
|
6275
|
+
/* @__PURE__ */ jsxs10(
|
|
6372
6276
|
Select,
|
|
6373
6277
|
{
|
|
6374
6278
|
value: current,
|
|
@@ -6377,10 +6281,10 @@ function SelectField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6377
6281
|
if (v !== (value || "")) onCommit(v || null);
|
|
6378
6282
|
},
|
|
6379
6283
|
children: [
|
|
6380
|
-
/* @__PURE__ */
|
|
6381
|
-
/* @__PURE__ */
|
|
6382
|
-
!(property.options || []).some((o) => !o.value) && /* @__PURE__ */
|
|
6383
|
-
(property.options || []).map((o) => /* @__PURE__ */
|
|
6284
|
+
/* @__PURE__ */ jsx11(SelectTrigger, { id, dense: true, className: "eb:w-full", children: /* @__PURE__ */ jsx11(SelectValue, { placeholder: defaultLabel }) }),
|
|
6285
|
+
/* @__PURE__ */ jsxs10(SelectContent, { children: [
|
|
6286
|
+
!(property.options || []).some((o) => !o.value) && /* @__PURE__ */ jsx11(SelectItem, { value: DEFAULT_OPTION, children: defaultLabel }),
|
|
6287
|
+
(property.options || []).map((o) => /* @__PURE__ */ jsx11(SelectItem, { value: o.value || DEFAULT_OPTION, children: t(o.label) }, o.value || DEFAULT_OPTION))
|
|
6384
6288
|
] })
|
|
6385
6289
|
]
|
|
6386
6290
|
}
|
|
@@ -6390,9 +6294,9 @@ function SelectField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6390
6294
|
var ALIGN_ICONS = { left: AlignLeft, center: AlignCenter, right: AlignRight, justify: AlignJustify };
|
|
6391
6295
|
function AlignField({ id, property, value, fallback = "", onCommit }) {
|
|
6392
6296
|
const t = useT();
|
|
6393
|
-
return /* @__PURE__ */
|
|
6394
|
-
/* @__PURE__ */
|
|
6395
|
-
/* @__PURE__ */
|
|
6297
|
+
return /* @__PURE__ */ jsxs10("div", { className: "eb:space-y-1", children: [
|
|
6298
|
+
/* @__PURE__ */ jsx11(FieldLabel, { id, children: t(property.label) }),
|
|
6299
|
+
/* @__PURE__ */ jsx11(
|
|
6396
6300
|
"div",
|
|
6397
6301
|
{
|
|
6398
6302
|
id,
|
|
@@ -6402,7 +6306,7 @@ function AlignField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6402
6306
|
children: (property.options || []).map((option) => {
|
|
6403
6307
|
const Icon = ALIGN_ICONS[option.value] || AlignLeft;
|
|
6404
6308
|
const active = (value || fallback) === option.value;
|
|
6405
|
-
return /* @__PURE__ */
|
|
6309
|
+
return /* @__PURE__ */ jsx11(TooltipWrap, { label: t(option.label), children: /* @__PURE__ */ jsx11(
|
|
6406
6310
|
"button",
|
|
6407
6311
|
{
|
|
6408
6312
|
type: "button",
|
|
@@ -6414,7 +6318,7 @@ function AlignField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6414
6318
|
"eb:inline-flex eb:h-5 eb:w-6 eb:items-center eb:justify-center eb:rounded-md eb:transition-colors",
|
|
6415
6319
|
active ? "eb:bg-primary eb:text-primary-foreground" : "eb:text-foreground-lighter eb:hover:bg-surface-200 eb:hover:text-foreground"
|
|
6416
6320
|
),
|
|
6417
|
-
children: /* @__PURE__ */
|
|
6321
|
+
children: /* @__PURE__ */ jsx11(Icon, { className: "eb:h-3.5 eb:w-3.5" })
|
|
6418
6322
|
}
|
|
6419
6323
|
) }, option.value);
|
|
6420
6324
|
})
|
|
@@ -6447,10 +6351,10 @@ function SpacingField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6447
6351
|
const next = spacingFromSides(sides, value, defaults);
|
|
6448
6352
|
if (next !== null) onCommit(next);
|
|
6449
6353
|
};
|
|
6450
|
-
return /* @__PURE__ */
|
|
6451
|
-
/* @__PURE__ */
|
|
6452
|
-
/* @__PURE__ */
|
|
6453
|
-
/* @__PURE__ */
|
|
6354
|
+
return /* @__PURE__ */ jsxs10("fieldset", { ref, className: "eb:space-y-1", children: [
|
|
6355
|
+
/* @__PURE__ */ jsx11("legend", { className: "eb:mb-1 eb:text-[12px] eb:text-foreground-lighter", children: t(property.label) }),
|
|
6356
|
+
/* @__PURE__ */ jsx11("div", { className: "eb:grid eb:grid-cols-4 eb:gap-1.5", children: SIDE_LABELS.map(([side, label], i) => /* @__PURE__ */ jsxs10("div", { className: "eb:space-y-1", children: [
|
|
6357
|
+
/* @__PURE__ */ jsx11(
|
|
6454
6358
|
Input,
|
|
6455
6359
|
{
|
|
6456
6360
|
id: `${id}-${side}`,
|
|
@@ -6470,7 +6374,7 @@ function SpacingField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6470
6374
|
className: "eb:px-2 eb:text-center eb:tabular-nums"
|
|
6471
6375
|
}
|
|
6472
6376
|
),
|
|
6473
|
-
/* @__PURE__ */
|
|
6377
|
+
/* @__PURE__ */ jsx11("span", { className: "eb:block eb:text-center eb:text-[10.5px] eb:text-foreground-muted", children: t(label) })
|
|
6474
6378
|
] }, side)) })
|
|
6475
6379
|
] });
|
|
6476
6380
|
}
|
|
@@ -6488,13 +6392,13 @@ var FIELDS = {
|
|
|
6488
6392
|
function PropertyField({ property, value, fallback = "", onCommit, idPrefix = "eb", services = null }) {
|
|
6489
6393
|
const Field = FIELDS[property.type] || TextField;
|
|
6490
6394
|
const id = `${idPrefix}-${property.key}`;
|
|
6491
|
-
return /* @__PURE__ */
|
|
6395
|
+
return /* @__PURE__ */ jsx11(Field, { id, property, value, fallback, onCommit, services });
|
|
6492
6396
|
}
|
|
6493
6397
|
|
|
6494
6398
|
// src/ui/BoxModel.jsx
|
|
6495
|
-
import { useState as
|
|
6399
|
+
import { useState as useState11 } from "react";
|
|
6496
6400
|
import { Ban } from "lucide-react";
|
|
6497
|
-
import { Fragment as
|
|
6401
|
+
import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
6498
6402
|
var BOX_ROLES = (
|
|
6499
6403
|
/** @type {const} */
|
|
6500
6404
|
["margin", "border", "padding"]
|
|
@@ -6522,7 +6426,7 @@ var asWidths = (v) => {
|
|
|
6522
6426
|
return border ? border.widths.map(String) : ["", "", "", ""];
|
|
6523
6427
|
};
|
|
6524
6428
|
function SideInput({ id, label, value, placeholder, max, className, onChange, onCommit }) {
|
|
6525
|
-
return /* @__PURE__ */
|
|
6429
|
+
return /* @__PURE__ */ jsx12(
|
|
6526
6430
|
"input",
|
|
6527
6431
|
{
|
|
6528
6432
|
id,
|
|
@@ -6552,7 +6456,7 @@ function Zone({ id, role, rootRef, active, onActive, draft, setDraft, placeholde
|
|
|
6552
6456
|
const t = useT();
|
|
6553
6457
|
const tone = TONES[role];
|
|
6554
6458
|
const name = { margin: t("Margin"), border: t("Border"), padding: t("Padding") }[role];
|
|
6555
|
-
const inputs = SIDES.map(([side, label, place], i) => /* @__PURE__ */
|
|
6459
|
+
const inputs = SIDES.map(([side, label, place], i) => /* @__PURE__ */ jsx12(
|
|
6556
6460
|
SideInput,
|
|
6557
6461
|
{
|
|
6558
6462
|
id: `${id}-${side}`,
|
|
@@ -6566,7 +6470,7 @@ function Zone({ id, role, rootRef, active, onActive, draft, setDraft, placeholde
|
|
|
6566
6470
|
},
|
|
6567
6471
|
side
|
|
6568
6472
|
));
|
|
6569
|
-
return /* @__PURE__ */
|
|
6473
|
+
return /* @__PURE__ */ jsxs11(
|
|
6570
6474
|
"div",
|
|
6571
6475
|
{
|
|
6572
6476
|
"data-box": role,
|
|
@@ -6585,14 +6489,14 @@ function Zone({ id, role, rootRef, active, onActive, draft, setDraft, placeholde
|
|
|
6585
6489
|
onActive(role);
|
|
6586
6490
|
},
|
|
6587
6491
|
children: [
|
|
6588
|
-
/* @__PURE__ */
|
|
6589
|
-
/* @__PURE__ */
|
|
6590
|
-
/* @__PURE__ */
|
|
6492
|
+
/* @__PURE__ */ jsxs11("div", { ref: rootRef, className: "eb:contents", children: [
|
|
6493
|
+
/* @__PURE__ */ jsxs11("div", { className: "eb:col-span-3 eb:row-start-1 eb:grid eb:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] eb:items-center", children: [
|
|
6494
|
+
/* @__PURE__ */ jsx12("span", { className: cn("eb:truncate eb:pl-1 eb:text-[10.5px] eb:font-medium eb:leading-5", tone.text), children: name }),
|
|
6591
6495
|
inputs[0]
|
|
6592
6496
|
] }),
|
|
6593
6497
|
inputs.slice(1)
|
|
6594
6498
|
] }),
|
|
6595
|
-
/* @__PURE__ */
|
|
6499
|
+
/* @__PURE__ */ jsx12("div", { className: "eb:col-start-2 eb:row-start-2 eb:min-w-0", children })
|
|
6596
6500
|
]
|
|
6597
6501
|
}
|
|
6598
6502
|
);
|
|
@@ -6604,7 +6508,7 @@ function SpacingZone({ id, role, property, value, fallback, onCommit, ...rest })
|
|
|
6604
6508
|
const next = spacingFromSides(draft, value, defaults);
|
|
6605
6509
|
if (next !== null) onCommit(property.key, next);
|
|
6606
6510
|
};
|
|
6607
|
-
return /* @__PURE__ */
|
|
6511
|
+
return /* @__PURE__ */ jsx12(Zone, { id, role, rootRef: ref, draft, setDraft, placeholders: defaults, max: 200, onCommit: commit, ...rest });
|
|
6608
6512
|
}
|
|
6609
6513
|
function BorderZone({ id, property, value, onCommit, ...rest }) {
|
|
6610
6514
|
const [draft, setDraft, ref] = useDraft(value, asWidths);
|
|
@@ -6617,7 +6521,7 @@ function BorderZone({ id, property, value, onCommit, ...rest }) {
|
|
|
6617
6521
|
const next = formatBorder({ widths, style: border?.style || "solid", color: border ? border.color : BORDER_COLOR });
|
|
6618
6522
|
if (next !== (value || "")) onCommit(property.key, next || null);
|
|
6619
6523
|
};
|
|
6620
|
-
return /* @__PURE__ */
|
|
6524
|
+
return /* @__PURE__ */ jsx12(
|
|
6621
6525
|
Zone,
|
|
6622
6526
|
{
|
|
6623
6527
|
id,
|
|
@@ -6646,9 +6550,9 @@ function BorderStyle({ id, value, onChange }) {
|
|
|
6646
6550
|
groove: t("Groove"),
|
|
6647
6551
|
ridge: t("Ridge")
|
|
6648
6552
|
};
|
|
6649
|
-
return /* @__PURE__ */
|
|
6650
|
-
/* @__PURE__ */
|
|
6651
|
-
/* @__PURE__ */
|
|
6553
|
+
return /* @__PURE__ */ jsxs11("div", { className: "eb:space-y-1", children: [
|
|
6554
|
+
/* @__PURE__ */ jsx12("span", { id: `${id}-label`, className: "eb:block eb:text-[12px] eb:text-foreground-lighter", children: t("Border style") }),
|
|
6555
|
+
/* @__PURE__ */ jsx12(
|
|
6652
6556
|
"div",
|
|
6653
6557
|
{
|
|
6654
6558
|
id,
|
|
@@ -6657,7 +6561,7 @@ function BorderStyle({ id, value, onChange }) {
|
|
|
6657
6561
|
className: "eb:flex eb:w-fit eb:flex-wrap eb:items-center eb:gap-0.5 eb:rounded-lg2 eb:border eb:border-border-strong eb:bg-surface-75 eb:p-0.5",
|
|
6658
6562
|
children: ["none", ...BORDER_STYLES].map((style) => {
|
|
6659
6563
|
const active = current === style;
|
|
6660
|
-
return /* @__PURE__ */
|
|
6564
|
+
return /* @__PURE__ */ jsx12(TooltipWrap, { label: labels[style], children: /* @__PURE__ */ jsx12(
|
|
6661
6565
|
"button",
|
|
6662
6566
|
{
|
|
6663
6567
|
type: "button",
|
|
@@ -6670,7 +6574,7 @@ function BorderStyle({ id, value, onChange }) {
|
|
|
6670
6574
|
"eb:inline-flex eb:h-6 eb:w-8 eb:items-center eb:justify-center eb:rounded-md eb:transition-colors",
|
|
6671
6575
|
active ? "eb:bg-primary eb:text-primary-foreground" : "eb:text-foreground-lighter eb:hover:bg-surface-200 eb:hover:text-foreground"
|
|
6672
6576
|
),
|
|
6673
|
-
children: style === "none" ? /* @__PURE__ */
|
|
6577
|
+
children: style === "none" ? /* @__PURE__ */ jsx12(Ban, { className: "eb:size-3.5", "aria-hidden": "true" }) : /* @__PURE__ */ jsx12("span", { "aria-hidden": "true", className: "eb:block eb:h-3.5 eb:w-5 eb:rounded-[3px]", style: { border: `${THICK_STYLES.has(style) ? 4 : 2}px ${style} currentColor` } })
|
|
6674
6578
|
}
|
|
6675
6579
|
) }, style);
|
|
6676
6580
|
})
|
|
@@ -6680,7 +6584,7 @@ function BorderStyle({ id, value, onChange }) {
|
|
|
6680
6584
|
}
|
|
6681
6585
|
function BoxModel({ idPrefix, element, properties, onCommit }) {
|
|
6682
6586
|
const t = useT();
|
|
6683
|
-
const [active, setActive] =
|
|
6587
|
+
const [active, setActive] = useState11(
|
|
6684
6588
|
/** @type {string|null} */
|
|
6685
6589
|
null
|
|
6686
6590
|
);
|
|
@@ -6717,9 +6621,9 @@ function BoxModel({ idPrefix, element, properties, onCommit }) {
|
|
|
6717
6621
|
(inner, role) => {
|
|
6718
6622
|
const property = byRole[role];
|
|
6719
6623
|
const common = { id: `${idPrefix}-box-${role}`, role, property, value: element.values[property.key] || "", onCommit, active, onActive: setActive };
|
|
6720
|
-
return role === "border" ? /* @__PURE__ */
|
|
6624
|
+
return role === "border" ? /* @__PURE__ */ jsx12(BorderZone, { ...common, children: inner }) : /* @__PURE__ */ jsx12(SpacingZone, { ...common, fallback: element.defaults?.[property.key] || "", children: inner });
|
|
6721
6625
|
},
|
|
6722
|
-
/* @__PURE__ */
|
|
6626
|
+
/* @__PURE__ */ jsx12(
|
|
6723
6627
|
"div",
|
|
6724
6628
|
{
|
|
6725
6629
|
"data-box": "content",
|
|
@@ -6732,8 +6636,8 @@ function BoxModel({ idPrefix, element, properties, onCommit }) {
|
|
|
6732
6636
|
}
|
|
6733
6637
|
)
|
|
6734
6638
|
);
|
|
6735
|
-
return /* @__PURE__ */
|
|
6736
|
-
/* @__PURE__ */
|
|
6639
|
+
return /* @__PURE__ */ jsxs11("div", { className: "eb:space-y-3", "data-testid": "eb-box-model", children: [
|
|
6640
|
+
/* @__PURE__ */ jsxs11(
|
|
6737
6641
|
"div",
|
|
6738
6642
|
{
|
|
6739
6643
|
className: "eb:space-y-1.5",
|
|
@@ -6746,16 +6650,16 @@ function BoxModel({ idPrefix, element, properties, onCommit }) {
|
|
|
6746
6650
|
},
|
|
6747
6651
|
children: [
|
|
6748
6652
|
zones,
|
|
6749
|
-
/* @__PURE__ */
|
|
6653
|
+
/* @__PURE__ */ jsx12("p", { className: "eb:min-h-8 eb:text-[11.5px] eb:leading-4 eb:text-foreground-muted", "data-testid": "eb-box-model-hint", children: active && hints[
|
|
6750
6654
|
/** @type {keyof typeof hints} */
|
|
6751
6655
|
active
|
|
6752
6656
|
] || t("In pixels. Point at a zone to see what it sets.") })
|
|
6753
6657
|
]
|
|
6754
6658
|
}
|
|
6755
6659
|
),
|
|
6756
|
-
border && /* @__PURE__ */
|
|
6757
|
-
/* @__PURE__ */
|
|
6758
|
-
/* @__PURE__ */
|
|
6660
|
+
border && /* @__PURE__ */ jsxs11(Fragment5, { children: [
|
|
6661
|
+
/* @__PURE__ */ jsx12(BorderStyle, { id: `${idPrefix}-box-border-style`, value: borderValue, onChange: (style) => setBorder({ style }) }),
|
|
6662
|
+
/* @__PURE__ */ jsx12(
|
|
6759
6663
|
PropertyField,
|
|
6760
6664
|
{
|
|
6761
6665
|
idPrefix: `${idPrefix}-box`,
|
|
@@ -6770,17 +6674,17 @@ function BoxModel({ idPrefix, element, properties, onCommit }) {
|
|
|
6770
6674
|
}
|
|
6771
6675
|
|
|
6772
6676
|
// src/features/variables/VariableInsertButton.jsx
|
|
6773
|
-
import { useState as
|
|
6677
|
+
import { useId, useState as useState13 } from "react";
|
|
6774
6678
|
import { Braces as Braces3 } from "lucide-react";
|
|
6775
6679
|
|
|
6776
6680
|
// src/features/variables/VariablePicker.jsx
|
|
6777
|
-
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef8, useState as
|
|
6681
|
+
import { useEffect as useEffect10, useMemo as useMemo4, useRef as useRef8, useState as useState12 } from "react";
|
|
6778
6682
|
import { Pencil as Pencil2, Plus as Plus2, Search as Search3 } from "lucide-react";
|
|
6779
|
-
import { jsx as
|
|
6683
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6780
6684
|
function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, filter }) {
|
|
6781
6685
|
const t = useT();
|
|
6782
|
-
const [query, setQuery] =
|
|
6783
|
-
const [active, setActive] =
|
|
6686
|
+
const [query, setQuery] = useState12("");
|
|
6687
|
+
const [active, setActive] = useState12(0);
|
|
6784
6688
|
const listRef = useRef8(null);
|
|
6785
6689
|
const searchRef = useRef8(
|
|
6786
6690
|
/** @type {HTMLInputElement|null} */
|
|
@@ -6812,10 +6716,10 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6812
6716
|
else if (onCreate && query.trim()) onCreate(query.trim());
|
|
6813
6717
|
}
|
|
6814
6718
|
};
|
|
6815
|
-
return /* @__PURE__ */
|
|
6816
|
-
/* @__PURE__ */
|
|
6817
|
-
/* @__PURE__ */
|
|
6818
|
-
/* @__PURE__ */
|
|
6719
|
+
return /* @__PURE__ */ jsxs12("div", { className: "eb:flex eb:max-h-[min(440px,70vh)] eb:flex-col", "data-testid": "variable-picker", children: [
|
|
6720
|
+
/* @__PURE__ */ jsxs12("div", { className: "eb:relative eb:border-b eb:border-border eb:p-2", children: [
|
|
6721
|
+
/* @__PURE__ */ jsx13(Search3, { className: "eb:pointer-events-none eb:absolute eb:top-1/2 eb:left-4 eb:size-3.5 eb:-translate-y-1/2 eb:text-foreground-muted" }),
|
|
6722
|
+
/* @__PURE__ */ jsx13(
|
|
6819
6723
|
"input",
|
|
6820
6724
|
{
|
|
6821
6725
|
ref: searchRef,
|
|
@@ -6829,29 +6733,29 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6829
6733
|
className: "eb:h-7 eb:w-full eb:rounded-lg2 eb:border eb:border-border eb:bg-background eb:pr-14 eb:pl-7 eb:text-[12px] eb:text-foreground eb:shadow-xs eb:outline-none eb:placeholder:text-foreground-muted eb:focus-visible:ring-2 eb:focus-visible:ring-ring/40"
|
|
6830
6734
|
}
|
|
6831
6735
|
),
|
|
6832
|
-
/* @__PURE__ */
|
|
6736
|
+
/* @__PURE__ */ jsx13(SearchKeyHint, { className: "eb:absolute eb:top-1/2 eb:right-4 eb:-translate-y-1/2" })
|
|
6833
6737
|
] }),
|
|
6834
|
-
/* @__PURE__ */
|
|
6835
|
-
ordered.length === 0 && /* @__PURE__ */
|
|
6836
|
-
/* @__PURE__ */
|
|
6837
|
-
onCreate && query.trim() && /* @__PURE__ */
|
|
6738
|
+
/* @__PURE__ */ jsxs12("div", { ref: listRef, role: "listbox", "aria-label": t("Variables"), className: "eb:min-h-0 eb:flex-1 eb:overflow-y-auto eb:p-1", children: [
|
|
6739
|
+
ordered.length === 0 && /* @__PURE__ */ jsxs12("div", { className: "eb:px-2 eb:py-3 eb:text-center eb:text-[12px] eb:text-foreground-muted", children: [
|
|
6740
|
+
/* @__PURE__ */ jsx13("p", { children: t("No variable found.") }),
|
|
6741
|
+
onCreate && query.trim() && /* @__PURE__ */ jsxs12(
|
|
6838
6742
|
"button",
|
|
6839
6743
|
{
|
|
6840
6744
|
type: "button",
|
|
6841
6745
|
onClick: () => onCreate(query.trim()),
|
|
6842
6746
|
className: "eb:mt-2 eb:inline-flex eb:items-center eb:gap-1 eb:rounded-md eb:px-2 eb:py-1 eb:text-[12px] eb:font-medium eb:text-primary eb:hover:bg-accent",
|
|
6843
6747
|
children: [
|
|
6844
|
-
/* @__PURE__ */
|
|
6748
|
+
/* @__PURE__ */ jsx13(Plus2, { className: "eb:size-3.5" }),
|
|
6845
6749
|
t("Create \u201C{name}\u201D", { name: query.trim() })
|
|
6846
6750
|
]
|
|
6847
6751
|
}
|
|
6848
6752
|
)
|
|
6849
6753
|
] }),
|
|
6850
|
-
groups.map((group) => /* @__PURE__ */
|
|
6851
|
-
/* @__PURE__ */
|
|
6754
|
+
groups.map((group) => /* @__PURE__ */ jsxs12("div", { role: "group", "aria-label": t(group), children: [
|
|
6755
|
+
/* @__PURE__ */ jsx13("p", { className: "eb:px-2 eb:pt-2 eb:pb-1 eb:text-[11px] eb:text-foreground-muted", children: t(group) }),
|
|
6852
6756
|
ordered.filter((v) => v.group === group).map((variable) => {
|
|
6853
6757
|
const index = ordered.indexOf(variable);
|
|
6854
|
-
return /* @__PURE__ */
|
|
6758
|
+
return /* @__PURE__ */ jsxs12(
|
|
6855
6759
|
"div",
|
|
6856
6760
|
{
|
|
6857
6761
|
"data-active": index === active,
|
|
@@ -6861,7 +6765,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6861
6765
|
),
|
|
6862
6766
|
onMouseEnter: () => setActive(index),
|
|
6863
6767
|
children: [
|
|
6864
|
-
/* @__PURE__ */
|
|
6768
|
+
/* @__PURE__ */ jsxs12(
|
|
6865
6769
|
"button",
|
|
6866
6770
|
{
|
|
6867
6771
|
type: "button",
|
|
@@ -6872,12 +6776,12 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6872
6776
|
className: "eb:flex eb:min-w-0 eb:flex-1 eb:items-center eb:gap-2 eb:px-2 eb:py-1.5 eb:text-left eb:text-[13px]",
|
|
6873
6777
|
title: variable.description || void 0,
|
|
6874
6778
|
children: [
|
|
6875
|
-
/* @__PURE__ */
|
|
6876
|
-
/* @__PURE__ */
|
|
6779
|
+
/* @__PURE__ */ jsx13("span", { className: "eb:min-w-0 eb:flex-1 eb:truncate", children: labelOf(variable, t) }),
|
|
6780
|
+
/* @__PURE__ */ jsx13("code", { className: "eb:shrink-0 eb:font-mono eb:text-[10.5px] eb:text-foreground-muted", children: tokenOf(variable) })
|
|
6877
6781
|
]
|
|
6878
6782
|
}
|
|
6879
6783
|
),
|
|
6880
|
-
onEdit && /* @__PURE__ */
|
|
6784
|
+
onEdit && /* @__PURE__ */ jsx13(
|
|
6881
6785
|
"button",
|
|
6882
6786
|
{
|
|
6883
6787
|
type: "button",
|
|
@@ -6885,7 +6789,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6885
6789
|
title: t("Edit"),
|
|
6886
6790
|
onClick: () => onEdit(variable),
|
|
6887
6791
|
className: "eb:mr-1 eb:flex eb:size-6 eb:shrink-0 eb:items-center eb:justify-center eb:rounded-md eb:text-foreground-muted eb:opacity-0 eb:group-hover/var:opacity-100 eb:hover:bg-background eb:hover:text-foreground eb:focus-visible:opacity-100",
|
|
6888
|
-
children: /* @__PURE__ */
|
|
6792
|
+
children: /* @__PURE__ */ jsx13(Pencil2, { className: "eb:size-3" })
|
|
6889
6793
|
}
|
|
6890
6794
|
)
|
|
6891
6795
|
]
|
|
@@ -6895,14 +6799,14 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6895
6799
|
})
|
|
6896
6800
|
] }, group))
|
|
6897
6801
|
] }),
|
|
6898
|
-
onCreate && /* @__PURE__ */
|
|
6802
|
+
onCreate && /* @__PURE__ */ jsx13("div", { className: "eb:border-t eb:border-border eb:p-1", children: /* @__PURE__ */ jsxs12(
|
|
6899
6803
|
"button",
|
|
6900
6804
|
{
|
|
6901
6805
|
type: "button",
|
|
6902
6806
|
onClick: () => onCreate(query.trim()),
|
|
6903
6807
|
className: "eb:flex eb:w-full eb:items-center eb:gap-2 eb:rounded-md eb:px-2 eb:py-1.5 eb:text-left eb:text-[13px] eb:font-medium eb:text-primary eb:hover:bg-accent",
|
|
6904
6808
|
children: [
|
|
6905
|
-
/* @__PURE__ */
|
|
6809
|
+
/* @__PURE__ */ jsx13(Plus2, { className: "eb:size-4" }),
|
|
6906
6810
|
t("New variable")
|
|
6907
6811
|
]
|
|
6908
6812
|
}
|
|
@@ -6911,15 +6815,16 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6911
6815
|
}
|
|
6912
6816
|
|
|
6913
6817
|
// src/features/variables/VariableInsertButton.jsx
|
|
6914
|
-
import { jsx as
|
|
6818
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6915
6819
|
function VariableInsertButton({ variables, inputRef, value, onChange, label, links = false }) {
|
|
6916
|
-
const [open, setOpen] =
|
|
6820
|
+
const [open, setOpen] = useState13(false);
|
|
6821
|
+
const id = useId();
|
|
6917
6822
|
const insert = (variable) => {
|
|
6918
6823
|
const input = inputRef.current;
|
|
6919
6824
|
const text = String(value || "");
|
|
6920
|
-
const token = tokenOf(variable);
|
|
6921
6825
|
const start = input?.selectionStart ?? text.length;
|
|
6922
6826
|
const end = input?.selectionEnd ?? text.length;
|
|
6827
|
+
const token = tokenOf(variable) + (links || /^\s/.test(text.slice(end)) ? "" : " ");
|
|
6923
6828
|
const next = `${text.slice(0, start)}${token}${text.slice(end)}`;
|
|
6924
6829
|
onChange(next);
|
|
6925
6830
|
setOpen(false);
|
|
@@ -6929,15 +6834,39 @@ function VariableInsertButton({ variables, inputRef, value, onChange, label, lin
|
|
|
6929
6834
|
input.setSelectionRange(start + token.length, start + token.length);
|
|
6930
6835
|
});
|
|
6931
6836
|
};
|
|
6932
|
-
return /* @__PURE__ */
|
|
6933
|
-
/* @__PURE__ */
|
|
6934
|
-
|
|
6935
|
-
|
|
6837
|
+
return /* @__PURE__ */ jsxs13(Popover, { open, onOpenChange: setOpen, children: [
|
|
6838
|
+
/* @__PURE__ */ jsx14(
|
|
6839
|
+
Button,
|
|
6840
|
+
{
|
|
6841
|
+
"data-eb-variable-insert": id,
|
|
6842
|
+
variant: "ghost",
|
|
6843
|
+
size: "icon-xs",
|
|
6844
|
+
"aria-label": label,
|
|
6845
|
+
title: label,
|
|
6846
|
+
"aria-haspopup": "dialog",
|
|
6847
|
+
"aria-expanded": open,
|
|
6848
|
+
onClick: () => setOpen((current) => !current),
|
|
6849
|
+
children: /* @__PURE__ */ jsx14(Braces3, {})
|
|
6850
|
+
}
|
|
6851
|
+
),
|
|
6852
|
+
/* @__PURE__ */ jsx14(PopoverAnchor, { virtualRef: inputRef }),
|
|
6853
|
+
/* @__PURE__ */ jsx14(
|
|
6854
|
+
PopoverContent,
|
|
6855
|
+
{
|
|
6856
|
+
align: "start",
|
|
6857
|
+
className: "eb:w-(--radix-popover-trigger-width) eb:min-w-64 eb:p-0",
|
|
6858
|
+
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
6859
|
+
onPointerDownOutside: (e) => {
|
|
6860
|
+
if (e.target instanceof Element && e.target.closest(`[data-eb-variable-insert="${id}"]`)) e.preventDefault();
|
|
6861
|
+
},
|
|
6862
|
+
children: /* @__PURE__ */ jsx14(VariablePicker, { variables, onPick: insert, filter: links ? void 0 : (v) => v.kind !== "link" })
|
|
6863
|
+
}
|
|
6864
|
+
)
|
|
6936
6865
|
] });
|
|
6937
6866
|
}
|
|
6938
6867
|
|
|
6939
6868
|
// src/ui/TextRibbon.jsx
|
|
6940
|
-
import { useEffect as useEffect11, useRef as useRef9, useState as
|
|
6869
|
+
import { useEffect as useEffect11, useRef as useRef9, useState as useState14 } from "react";
|
|
6941
6870
|
import {
|
|
6942
6871
|
AlignCenter as AlignCenter2,
|
|
6943
6872
|
AlignJustify as AlignJustify2,
|
|
@@ -6955,7 +6884,7 @@ import {
|
|
|
6955
6884
|
Underline,
|
|
6956
6885
|
Unlink
|
|
6957
6886
|
} from "lucide-react";
|
|
6958
|
-
import { jsx as
|
|
6887
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6959
6888
|
var RIBBON_KEYS = /* @__PURE__ */ new Set(["font-family", "font-size", "line-height", "font-weight", "color", "text-transform", "align"]);
|
|
6960
6889
|
var FORMATS = [
|
|
6961
6890
|
{ command: "bold", icon: Bold, label: "Bold (Ctrl+B)" },
|
|
@@ -6972,7 +6901,7 @@ var ALIGNMENTS = [
|
|
|
6972
6901
|
{ value: "justify", icon: AlignJustify2, label: "Justify" }
|
|
6973
6902
|
];
|
|
6974
6903
|
function LineSpacingIcon(props) {
|
|
6975
|
-
return /* @__PURE__ */
|
|
6904
|
+
return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: /* @__PURE__ */ jsx15("path", { d: "M5 4v16M2 7l3-3 3 3M2 17l3 3 3-3M12 6h9M12 12h9M12 18h9" }) });
|
|
6976
6905
|
}
|
|
6977
6906
|
function pixels(value, fontSize) {
|
|
6978
6907
|
const text = String(value || "").trim();
|
|
@@ -6993,9 +6922,9 @@ var heavy = (weight) => weight === "bold" || Number(weight) >= 600;
|
|
|
6993
6922
|
var clamp = (n, property) => Math.min(property.max ?? n, Math.max(property.min ?? n, n));
|
|
6994
6923
|
var ICON_BUTTON = "eb:inline-flex eb:h-7 eb:min-w-7 eb:items-center eb:justify-center eb:gap-1 eb:rounded-lg2 eb:px-1.5 eb:text-foreground-lighter eb:outline-none eb:transition-colors eb:hover:bg-surface-200 eb:hover:text-foreground eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50 eb:disabled:pointer-events-none eb:disabled:opacity-40 eb:aria-pressed:bg-primary/10 eb:aria-pressed:text-primary eb:aria-checked:bg-primary/10 eb:aria-checked:text-primary eb:data-[state=open]:bg-surface-200 eb:[&_svg]:size-4 eb:[&_svg]:shrink-0";
|
|
6995
6924
|
function Tip({ label, children }) {
|
|
6996
|
-
return /* @__PURE__ */
|
|
6925
|
+
return /* @__PURE__ */ jsx15(TooltipWrap, { label, side: "bottom", delayDuration: 250, hoverable: false, children: /* @__PURE__ */ jsx15("span", { className: "eb:inline-flex", children }) });
|
|
6997
6926
|
}
|
|
6998
|
-
var Separator2 = () => /* @__PURE__ */
|
|
6927
|
+
var Separator2 = () => /* @__PURE__ */ jsx15("span", { className: "eb:mx-0.5 eb:h-4 eb:w-px eb:shrink-0 eb:bg-border", "aria-hidden": "true" });
|
|
6999
6928
|
function TextRibbon({ editor, ready, selection, format, variables = [], drawers, openDrawer, onToggleDrawer }) {
|
|
7000
6929
|
const { t, locale } = useUi();
|
|
7001
6930
|
const element = ready && selection && !selection.multiple ? selection : null;
|
|
@@ -7060,7 +6989,7 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7060
6989
|
const currentSize = pixels(valueOf("font-size"), null);
|
|
7061
6990
|
const currentLine = pixels(valueOf("line-height"), currentSize);
|
|
7062
6991
|
const number = new Intl.NumberFormat(locale || void 0, { maximumFractionDigits: 2 });
|
|
7063
|
-
return /* @__PURE__ */
|
|
6992
|
+
return /* @__PURE__ */ jsxs14(
|
|
7064
6993
|
"div",
|
|
7065
6994
|
{
|
|
7066
6995
|
role: "toolbar",
|
|
@@ -7069,21 +6998,21 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7069
6998
|
className: "eb:@container eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:border-b eb:border-border eb:bg-background",
|
|
7070
6999
|
onMouseDown: (event) => event.target instanceof HTMLInputElement || event.preventDefault(),
|
|
7071
7000
|
children: [
|
|
7072
|
-
/* @__PURE__ */
|
|
7073
|
-
/* @__PURE__ */
|
|
7074
|
-
/* @__PURE__ */
|
|
7001
|
+
/* @__PURE__ */ jsxs14("div", { className: "eb:flex eb:h-full eb:min-w-0 eb:flex-1 eb:items-center eb:gap-0.5 eb:overflow-x-auto eb:px-2 eb:[scrollbar-width:thin]", children: [
|
|
7002
|
+
/* @__PURE__ */ jsxs14(Select, { value: fontValue ?? "", onValueChange: (next) => set("font-family", next), disabled: !font, children: [
|
|
7003
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Font"), children: /* @__PURE__ */ jsx15(
|
|
7075
7004
|
SelectTrigger,
|
|
7076
7005
|
{
|
|
7077
7006
|
"aria-label": t("Font"),
|
|
7078
7007
|
"data-control": "font-family",
|
|
7079
7008
|
className: "eb:w-28 eb:shrink-0 eb:gap-1 eb:px-2 eb:shadow-none eb:disabled:opacity-40",
|
|
7080
|
-
children: /* @__PURE__ */
|
|
7009
|
+
children: /* @__PURE__ */ jsx15(SelectValue, { placeholder: t("Font") })
|
|
7081
7010
|
}
|
|
7082
7011
|
) }),
|
|
7083
|
-
/* @__PURE__ */
|
|
7012
|
+
/* @__PURE__ */ jsx15(SelectContent, { position: "popper", align: "start", onCloseAutoFocus: (event) => event.preventDefault(), children: font?.options?.map((option) => /* @__PURE__ */ jsx15(SelectItem, { value: option.value, style: { fontFamily: option.value }, children: t(option.label) }, option.value)) })
|
|
7084
7013
|
] }),
|
|
7085
|
-
/* @__PURE__ */
|
|
7086
|
-
FORMATS.map(({ command, icon: Icon, label }) => /* @__PURE__ */
|
|
7014
|
+
/* @__PURE__ */ jsx15(Separator2, {}),
|
|
7015
|
+
FORMATS.map(({ command, icon: Icon, label }) => /* @__PURE__ */ jsx15(Tip, { label: t(label), children: /* @__PURE__ */ jsx15(
|
|
7087
7016
|
"button",
|
|
7088
7017
|
{
|
|
7089
7018
|
type: "button",
|
|
@@ -7097,10 +7026,10 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7097
7026
|
else if (styled) toggleStyle(command);
|
|
7098
7027
|
else run(command);
|
|
7099
7028
|
},
|
|
7100
|
-
children: /* @__PURE__ */
|
|
7029
|
+
children: /* @__PURE__ */ jsx15(Icon, { "aria-hidden": "true" })
|
|
7101
7030
|
}
|
|
7102
7031
|
) }, command)),
|
|
7103
|
-
/* @__PURE__ */
|
|
7032
|
+
/* @__PURE__ */ jsx15(
|
|
7104
7033
|
ColorField,
|
|
7105
7034
|
{
|
|
7106
7035
|
id: "eb-ribbon-color",
|
|
@@ -7108,52 +7037,52 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7108
7037
|
value: valueOf("color"),
|
|
7109
7038
|
fallback: "",
|
|
7110
7039
|
onCommit: (value) => set("color", value),
|
|
7111
|
-
trigger: /* @__PURE__ */
|
|
7112
|
-
/* @__PURE__ */
|
|
7113
|
-
/* @__PURE__ */
|
|
7040
|
+
trigger: /* @__PURE__ */ jsx15("button", { type: "button", className: ICON_BUTTON, disabled: !color, "aria-label": t("Text color"), title: t("Text color"), "data-control": "color", children: /* @__PURE__ */ jsxs14("span", { className: "eb:relative eb:inline-flex", children: [
|
|
7041
|
+
/* @__PURE__ */ jsx15(Baseline, { "aria-hidden": "true" }),
|
|
7042
|
+
/* @__PURE__ */ jsx15("span", { className: "eb:absolute eb:inset-x-0.5 eb:-bottom-0.5 eb:h-1 eb:rounded-sm", style: { backgroundColor: valueOf("color") || "currentColor" }, "aria-hidden": "true" })
|
|
7114
7043
|
] }) })
|
|
7115
7044
|
},
|
|
7116
7045
|
element?.id ?? "none"
|
|
7117
7046
|
),
|
|
7118
|
-
/* @__PURE__ */
|
|
7119
|
-
/* @__PURE__ */
|
|
7120
|
-
/* @__PURE__ */
|
|
7121
|
-
/* @__PURE__ */
|
|
7047
|
+
/* @__PURE__ */ jsxs14(DropdownMenu, { modal: false, children: [
|
|
7048
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Capitals"), children: /* @__PURE__ */ jsx15(DropdownMenuTrigger, { asChild: true, disabled: !capitals, children: /* @__PURE__ */ jsxs14("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Capitals"), "data-control": "text-transform", children: [
|
|
7049
|
+
/* @__PURE__ */ jsx15(CaseSensitive, { "aria-hidden": "true" }),
|
|
7050
|
+
/* @__PURE__ */ jsx15(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
|
|
7122
7051
|
] }) }) }),
|
|
7123
|
-
/* @__PURE__ */
|
|
7124
|
-
/* @__PURE__ */
|
|
7052
|
+
/* @__PURE__ */ jsx15(DropdownMenuContent, { align: "start", "aria-label": t("Capitals"), onCloseAutoFocus: (event) => event.preventDefault(), children: capitals?.options?.map((option) => /* @__PURE__ */ jsxs14(DropdownMenuItem, { onSelect: () => set("text-transform", option.value), className: "eb:min-w-36", children: [
|
|
7053
|
+
/* @__PURE__ */ jsx15(Check2, { className: cn("eb:size-3.5", valueOf("text-transform") !== option.value && "eb:invisible"), "aria-hidden": "true" }),
|
|
7125
7054
|
t(option.label)
|
|
7126
7055
|
] }, option.value)) })
|
|
7127
7056
|
] }),
|
|
7128
|
-
/* @__PURE__ */
|
|
7129
|
-
/* @__PURE__ */
|
|
7130
|
-
/* @__PURE__ */
|
|
7131
|
-
/* @__PURE__ */
|
|
7132
|
-
/* @__PURE__ */
|
|
7133
|
-
/* @__PURE__ */
|
|
7134
|
-
/* @__PURE__ */
|
|
7135
|
-
/* @__PURE__ */
|
|
7136
|
-
/* @__PURE__ */
|
|
7137
|
-
/* @__PURE__ */
|
|
7138
|
-
/* @__PURE__ */
|
|
7057
|
+
/* @__PURE__ */ jsx15(Separator2, {}),
|
|
7058
|
+
/* @__PURE__ */ jsx15(LinkButton, { disabled: !words && !linked, href, variables, onApply: (next) => words ? run("link", next) : set("href", next) }),
|
|
7059
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Remove the link"), children: /* @__PURE__ */ jsx15("button", { type: "button", className: ICON_BUTTON, disabled: !href, "aria-label": t("Remove the link"), "data-command": "unlink", onClick: () => words ? run("unlink") : set("href", null), children: /* @__PURE__ */ jsx15(Unlink, { "aria-hidden": "true" }) }) }),
|
|
7060
|
+
/* @__PURE__ */ jsx15(Separator2, {}),
|
|
7061
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Clear formatting"), children: /* @__PURE__ */ jsx15("button", { type: "button", className: ICON_BUTTON, disabled: !words && !styled, "aria-label": t("Clear formatting"), "data-command": "clear", onClick: () => words ? run("clear") : clearStyles(), children: /* @__PURE__ */ jsx15(RemoveFormatting, { "aria-hidden": "true" }) }) }),
|
|
7062
|
+
/* @__PURE__ */ jsx15(Separator2, {}),
|
|
7063
|
+
/* @__PURE__ */ jsx15(SizeField2, { property: size, value: currentSize, onCommit: (n) => set("font-size", `${clamp(n, size)}px`) }),
|
|
7064
|
+
/* @__PURE__ */ jsxs14(DropdownMenu, { modal: false, children: [
|
|
7065
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Line height"), children: /* @__PURE__ */ jsx15(DropdownMenuTrigger, { asChild: true, disabled: !lineHeight, children: /* @__PURE__ */ jsxs14("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Line height"), "data-control": "line-height", children: [
|
|
7066
|
+
/* @__PURE__ */ jsx15(LineSpacingIcon, { "aria-hidden": "true" }),
|
|
7067
|
+
/* @__PURE__ */ jsx15(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
|
|
7139
7068
|
] }) }) }),
|
|
7140
|
-
/* @__PURE__ */
|
|
7069
|
+
/* @__PURE__ */ jsx15(DropdownMenuContent, { align: "start", "aria-label": t("Line height"), onCloseAutoFocus: (event) => event.preventDefault(), children: lineHeight && LINE_HEIGHTS.map((ratio) => {
|
|
7141
7070
|
const px = clamp(Math.round((currentSize || 15) * ratio), lineHeight);
|
|
7142
7071
|
const current = currentLine !== null && Math.round(currentLine) === px;
|
|
7143
|
-
return /* @__PURE__ */
|
|
7144
|
-
/* @__PURE__ */
|
|
7145
|
-
/* @__PURE__ */
|
|
7146
|
-
/* @__PURE__ */
|
|
7072
|
+
return /* @__PURE__ */ jsxs14(DropdownMenuItem, { onSelect: () => set("line-height", `${px}px`), className: "eb:min-w-36", children: [
|
|
7073
|
+
/* @__PURE__ */ jsx15(Check2, { className: cn("eb:size-3.5", !current && "eb:invisible"), "aria-hidden": "true" }),
|
|
7074
|
+
/* @__PURE__ */ jsx15("span", { className: "eb:tabular-nums", children: number.format(ratio) }),
|
|
7075
|
+
/* @__PURE__ */ jsxs14("span", { className: "eb:ml-auto eb:text-[12px] eb:tabular-nums eb:text-foreground-muted", children: [
|
|
7147
7076
|
px,
|
|
7148
7077
|
" px"
|
|
7149
7078
|
] })
|
|
7150
7079
|
] }, ratio);
|
|
7151
7080
|
}) })
|
|
7152
7081
|
] }),
|
|
7153
|
-
/* @__PURE__ */
|
|
7154
|
-
/* @__PURE__ */
|
|
7082
|
+
/* @__PURE__ */ jsx15(Separator2, {}),
|
|
7083
|
+
/* @__PURE__ */ jsx15("div", { role: "radiogroup", "aria-label": t("Alignment"), className: "eb:flex eb:items-center eb:gap-0.5", children: ALIGNMENTS.map(({ value, icon: Icon, label }) => {
|
|
7155
7084
|
const offered = Boolean(align?.options?.some((option) => option.value === value));
|
|
7156
|
-
return /* @__PURE__ */
|
|
7085
|
+
return /* @__PURE__ */ jsx15(Tip, { label: t(label), children: /* @__PURE__ */ jsx15(
|
|
7157
7086
|
"button",
|
|
7158
7087
|
{
|
|
7159
7088
|
type: "button",
|
|
@@ -7163,12 +7092,12 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7163
7092
|
"aria-label": t(label),
|
|
7164
7093
|
"aria-checked": offered && valueOf("align") === value,
|
|
7165
7094
|
onClick: () => valueOf("align") !== value && set("align", value),
|
|
7166
|
-
children: /* @__PURE__ */
|
|
7095
|
+
children: /* @__PURE__ */ jsx15(Icon, { "aria-hidden": "true" })
|
|
7167
7096
|
}
|
|
7168
7097
|
) }, value);
|
|
7169
7098
|
}) })
|
|
7170
7099
|
] }),
|
|
7171
|
-
drawers.length > 0 && /* @__PURE__ */
|
|
7100
|
+
drawers.length > 0 && /* @__PURE__ */ jsx15("div", { className: "eb:flex eb:h-full eb:shrink-0 eb:items-center eb:gap-0.5 eb:px-1.5", children: drawers.map(({ id, icon: Icon, label, title }) => /* @__PURE__ */ jsx15(Tip, { label: t(title || label), children: /* @__PURE__ */ jsxs14(
|
|
7172
7101
|
"button",
|
|
7173
7102
|
{
|
|
7174
7103
|
type: "button",
|
|
@@ -7179,8 +7108,8 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7179
7108
|
"data-drawer": id,
|
|
7180
7109
|
onClick: () => onToggleDrawer(id),
|
|
7181
7110
|
children: [
|
|
7182
|
-
/* @__PURE__ */
|
|
7183
|
-
/* @__PURE__ */
|
|
7111
|
+
/* @__PURE__ */ jsx15(Icon, { "aria-hidden": "true" }),
|
|
7112
|
+
/* @__PURE__ */ jsx15("span", { className: "eb:hidden eb:@min-[50rem]:inline", children: t(label) })
|
|
7184
7113
|
]
|
|
7185
7114
|
}
|
|
7186
7115
|
) }, id)) })
|
|
@@ -7191,7 +7120,7 @@ function TextRibbon({ editor, ready, selection, format, variables = [], drawers,
|
|
|
7191
7120
|
function SizeField2({ property, value, onCommit }) {
|
|
7192
7121
|
const { t } = useUi();
|
|
7193
7122
|
const shown = value === null ? "" : String(Math.round(value * 100) / 100);
|
|
7194
|
-
const [draft, setDraft] =
|
|
7123
|
+
const [draft, setDraft] = useState14(shown);
|
|
7195
7124
|
useEffect11(() => setDraft(shown), [shown]);
|
|
7196
7125
|
const commit = () => {
|
|
7197
7126
|
const n = Number.parseFloat(draft);
|
|
@@ -7200,8 +7129,8 @@ function SizeField2({ property, value, onCommit }) {
|
|
|
7200
7129
|
};
|
|
7201
7130
|
const disabled = !property;
|
|
7202
7131
|
const sizes = property ? SIZES.filter((n) => n >= (property.min ?? 0) && n <= (property.max ?? Infinity)) : [];
|
|
7203
|
-
return /* @__PURE__ */
|
|
7204
|
-
/* @__PURE__ */
|
|
7132
|
+
return /* @__PURE__ */ jsxs14(DropdownMenu, { modal: false, children: [
|
|
7133
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Font size"), children: /* @__PURE__ */ jsxs14(
|
|
7205
7134
|
"div",
|
|
7206
7135
|
{
|
|
7207
7136
|
className: cn(
|
|
@@ -7209,7 +7138,7 @@ function SizeField2({ property, value, onCommit }) {
|
|
|
7209
7138
|
disabled && "eb:opacity-40"
|
|
7210
7139
|
),
|
|
7211
7140
|
children: [
|
|
7212
|
-
/* @__PURE__ */
|
|
7141
|
+
/* @__PURE__ */ jsx15(
|
|
7213
7142
|
"input",
|
|
7214
7143
|
{
|
|
7215
7144
|
type: "text",
|
|
@@ -7227,30 +7156,30 @@ function SizeField2({ property, value, onCommit }) {
|
|
|
7227
7156
|
}
|
|
7228
7157
|
}
|
|
7229
7158
|
),
|
|
7230
|
-
/* @__PURE__ */
|
|
7159
|
+
/* @__PURE__ */ jsx15(DropdownMenuTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx15(
|
|
7231
7160
|
"button",
|
|
7232
7161
|
{
|
|
7233
7162
|
type: "button",
|
|
7234
7163
|
"aria-label": t("Font sizes"),
|
|
7235
7164
|
className: "eb:grid eb:h-full eb:w-5 eb:place-items-center eb:rounded-r-lg2 eb:text-foreground-muted eb:outline-none eb:hover:bg-surface-200 eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50 eb:disabled:pointer-events-none",
|
|
7236
|
-
children: /* @__PURE__ */
|
|
7165
|
+
children: /* @__PURE__ */ jsx15(ChevronDown, { className: "eb:size-3", "aria-hidden": "true" })
|
|
7237
7166
|
}
|
|
7238
7167
|
) })
|
|
7239
7168
|
]
|
|
7240
7169
|
}
|
|
7241
7170
|
) }),
|
|
7242
|
-
/* @__PURE__ */
|
|
7243
|
-
/* @__PURE__ */
|
|
7171
|
+
/* @__PURE__ */ jsx15(DropdownMenuContent, { align: "start", "aria-label": t("Font size"), className: "eb:max-h-72 eb:min-w-20", onCloseAutoFocus: (event) => event.preventDefault(), children: sizes.map((n) => /* @__PURE__ */ jsxs14(DropdownMenuItem, { onSelect: () => onCommit(n), className: "eb:tabular-nums", children: [
|
|
7172
|
+
/* @__PURE__ */ jsx15(Check2, { className: cn("eb:size-3.5", n !== value && "eb:invisible"), "aria-hidden": "true" }),
|
|
7244
7173
|
n
|
|
7245
7174
|
] }, n)) })
|
|
7246
7175
|
] });
|
|
7247
7176
|
}
|
|
7248
7177
|
function LinkButton({ disabled, href, variables, onApply }) {
|
|
7249
7178
|
const { t } = useUi();
|
|
7250
|
-
const [open, setOpen] =
|
|
7251
|
-
const [draft, setDraft] =
|
|
7179
|
+
const [open, setOpen] = useState14(false);
|
|
7180
|
+
const [draft, setDraft] = useState14("");
|
|
7252
7181
|
const inputRef = useRef9(null);
|
|
7253
|
-
return /* @__PURE__ */
|
|
7182
|
+
return /* @__PURE__ */ jsxs14(
|
|
7254
7183
|
Popover,
|
|
7255
7184
|
{
|
|
7256
7185
|
open,
|
|
@@ -7259,8 +7188,8 @@ function LinkButton({ disabled, href, variables, onApply }) {
|
|
|
7259
7188
|
setOpen(next);
|
|
7260
7189
|
},
|
|
7261
7190
|
children: [
|
|
7262
|
-
/* @__PURE__ */
|
|
7263
|
-
/* @__PURE__ */
|
|
7191
|
+
/* @__PURE__ */ jsx15(Tip, { label: t("Link"), children: /* @__PURE__ */ jsx15(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx15("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Link"), "aria-pressed": Boolean(href), "data-command": "link", children: /* @__PURE__ */ jsx15(Link, { "aria-hidden": "true" }) }) }) }),
|
|
7192
|
+
/* @__PURE__ */ jsx15(PopoverContent, { align: "start", className: "eb:w-80 eb:p-2", onCloseAutoFocus: (event) => event.preventDefault(), children: /* @__PURE__ */ jsxs14(
|
|
7264
7193
|
"form",
|
|
7265
7194
|
{
|
|
7266
7195
|
className: "eb:flex eb:items-center eb:gap-1.5",
|
|
@@ -7271,11 +7200,11 @@ function LinkButton({ disabled, href, variables, onApply }) {
|
|
|
7271
7200
|
if (draft.trim()) onApply(draft.trim());
|
|
7272
7201
|
},
|
|
7273
7202
|
children: [
|
|
7274
|
-
/* @__PURE__ */
|
|
7275
|
-
/* @__PURE__ */
|
|
7276
|
-
variables.length > 0 && /* @__PURE__ */
|
|
7203
|
+
/* @__PURE__ */ jsxs14("div", { className: "eb:relative eb:min-w-0 eb:flex-1", children: [
|
|
7204
|
+
/* @__PURE__ */ jsx15(Input, { ref: inputRef, type: "url", autoFocus: true, value: draft, onChange: (event) => setDraft(event.target.value), placeholder: "https://", "aria-label": t("Link URL"), className: variables.length ? "eb:pr-8" : "" }),
|
|
7205
|
+
variables.length > 0 && /* @__PURE__ */ jsx15("span", { className: "eb:absolute eb:top-1/2 eb:right-0.5 eb:-translate-y-1/2", children: /* @__PURE__ */ jsx15(VariableInsertButton, { variables, inputRef, value: draft, onChange: setDraft, label: t("Insert a variable in the link"), links: true }) })
|
|
7277
7206
|
] }),
|
|
7278
|
-
/* @__PURE__ */
|
|
7207
|
+
/* @__PURE__ */ jsx15(Button, { type: "submit", size: "icon-dense", variant: "outline", "aria-label": t("Apply the link"), disabled: !draft.trim(), children: /* @__PURE__ */ jsx15(Check2, {}) })
|
|
7279
7208
|
]
|
|
7280
7209
|
}
|
|
7281
7210
|
) })
|
|
@@ -7285,7 +7214,7 @@ function LinkButton({ disabled, href, variables, onApply }) {
|
|
|
7285
7214
|
}
|
|
7286
7215
|
|
|
7287
7216
|
// src/ui/PropertiesPanel.jsx
|
|
7288
|
-
import { Fragment as
|
|
7217
|
+
import { Fragment as Fragment6, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7289
7218
|
var GROUP_ORDER = Object.values(GROUPS);
|
|
7290
7219
|
function grouped(properties) {
|
|
7291
7220
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -7301,9 +7230,9 @@ function PropertyGroups({ editor, element, block, idPrefix, services = null, hid
|
|
|
7301
7230
|
const t = useT();
|
|
7302
7231
|
return grouped((block?.properties || []).filter((property) => !hidden?.has(property.key))).map(([group, properties]) => {
|
|
7303
7232
|
const box = properties.filter(boxRole);
|
|
7304
|
-
return /* @__PURE__ */
|
|
7305
|
-
/* @__PURE__ */
|
|
7306
|
-
box.length > 0 && /* @__PURE__ */
|
|
7233
|
+
return /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
|
|
7234
|
+
/* @__PURE__ */ jsx16(SectionLabel, { children: t(group) }),
|
|
7235
|
+
box.length > 0 && /* @__PURE__ */ jsx16(
|
|
7307
7236
|
BoxModel,
|
|
7308
7237
|
{
|
|
7309
7238
|
idPrefix,
|
|
@@ -7313,7 +7242,7 @@ function PropertyGroups({ editor, element, block, idPrefix, services = null, hid
|
|
|
7313
7242
|
},
|
|
7314
7243
|
`${element.id}:box`
|
|
7315
7244
|
),
|
|
7316
|
-
properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */
|
|
7245
|
+
properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */ jsx16(
|
|
7317
7246
|
PropertyField,
|
|
7318
7247
|
{
|
|
7319
7248
|
idPrefix,
|
|
@@ -7332,26 +7261,26 @@ var STYLE_LABELS = { "font-weight": "Bold", "font-style": "Italic", "text-decora
|
|
|
7332
7261
|
function MobileStyles({ editor, element, block }) {
|
|
7333
7262
|
const t = useT();
|
|
7334
7263
|
const labelOf2 = (key) => block?.properties?.find((property) => property.key === key)?.label || STYLE_LABELS[key] || key;
|
|
7335
|
-
return /* @__PURE__ */
|
|
7336
|
-
/* @__PURE__ */
|
|
7337
|
-
/* @__PURE__ */
|
|
7264
|
+
return /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-2 eb:rounded-lg2 eb:border eb:border-primary/30 eb:bg-primary/5 eb:p-3", "data-testid": "eb-mobile-styles", children: [
|
|
7265
|
+
/* @__PURE__ */ jsxs15("p", { className: "eb:flex eb:items-start eb:gap-2 eb:text-[12px] eb:leading-relaxed eb:text-foreground-lighter", children: [
|
|
7266
|
+
/* @__PURE__ */ jsx16(Smartphone, { className: "eb:mt-0.5 eb:size-3.5 eb:shrink-0 eb:text-primary", "aria-hidden": "true" }),
|
|
7338
7267
|
t("Mobile view: the styles you change here apply to phones only. Links and pictures are the same on every screen.")
|
|
7339
7268
|
] }),
|
|
7340
|
-
element.mobileOverrides.length > 0 && /* @__PURE__ */
|
|
7341
|
-
/* @__PURE__ */
|
|
7269
|
+
element.mobileOverrides.length > 0 && /* @__PURE__ */ jsxs15(Fragment6, { children: [
|
|
7270
|
+
/* @__PURE__ */ jsx16("ul", { "aria-label": t("Different on phones"), className: "eb:flex eb:flex-wrap eb:gap-1", children: element.mobileOverrides.map((key) => /* @__PURE__ */ jsxs15("li", { className: "eb:inline-flex eb:h-6 eb:items-center eb:gap-0.5 eb:rounded-md eb:bg-background eb:pr-0.5 eb:pl-2 eb:text-[12px] eb:text-foreground eb:ring-1 eb:ring-border", children: [
|
|
7342
7271
|
t(labelOf2(key)),
|
|
7343
|
-
/* @__PURE__ */
|
|
7272
|
+
/* @__PURE__ */ jsx16(
|
|
7344
7273
|
Button,
|
|
7345
7274
|
{
|
|
7346
7275
|
variant: "ghost",
|
|
7347
7276
|
size: "icon-xs",
|
|
7348
7277
|
"aria-label": t("Back to the desktop value: {name}", { name: t(labelOf2(key)) }),
|
|
7349
7278
|
onClick: () => editor.updateProperties({ [key]: null }, element.id),
|
|
7350
|
-
children: /* @__PURE__ */
|
|
7279
|
+
children: /* @__PURE__ */ jsx16(X2, {})
|
|
7351
7280
|
}
|
|
7352
7281
|
)
|
|
7353
7282
|
] }, key)) }),
|
|
7354
|
-
/* @__PURE__ */
|
|
7283
|
+
/* @__PURE__ */ jsx16(Button, { variant: "outline", size: "sm-compact", onClick: () => editor.clearMobileStyles(element.id), children: t("Same as desktop") })
|
|
7355
7284
|
] })
|
|
7356
7285
|
] });
|
|
7357
7286
|
}
|
|
@@ -7359,9 +7288,9 @@ var LABEL_PROPERTY = { key: "content", label: "Label", type: "text", group: GROU
|
|
|
7359
7288
|
var REWRITABLE_TAGS = /* @__PURE__ */ new Set(["mj-text", "mj-button"]);
|
|
7360
7289
|
function PanelHeader({ title, onClose, closeLabel = "Deselect" }) {
|
|
7361
7290
|
const t = useT();
|
|
7362
|
-
return /* @__PURE__ */
|
|
7363
|
-
/* @__PURE__ */
|
|
7364
|
-
onClose && /* @__PURE__ */
|
|
7291
|
+
return /* @__PURE__ */ jsxs15("header", { className: "eb:sticky eb:top-0 eb:z-10 eb:flex eb:h-11 eb:shrink-0 eb:items-center eb:gap-2 eb:bg-background eb:px-4", children: [
|
|
7292
|
+
/* @__PURE__ */ jsx16("h3", { className: "eb:min-w-0 eb:flex-1 eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx16(TruncatedText, { children: title }) }),
|
|
7293
|
+
onClose && /* @__PURE__ */ jsx16(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t(closeLabel), children: /* @__PURE__ */ jsx16(X2, {}) })
|
|
7365
7294
|
] });
|
|
7366
7295
|
}
|
|
7367
7296
|
function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, variables = null, ai = null, onDismiss = null }) {
|
|
@@ -7372,18 +7301,18 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7372
7301
|
const root = useMemo5(() => rootId ? editor.getElement(rootId) : null, [editor, rootId, changes]);
|
|
7373
7302
|
const bodyBlock2 = root?.blockId ? editor.getBlock(root.blockId) : null;
|
|
7374
7303
|
const field = (key) => (e) => onMetaChange({ ...meta, [key]: e.target.value });
|
|
7375
|
-
return /* @__PURE__ */
|
|
7376
|
-
/* @__PURE__ */
|
|
7377
|
-
/* @__PURE__ */
|
|
7378
|
-
/* @__PURE__ */
|
|
7379
|
-
/* @__PURE__ */
|
|
7380
|
-
/* @__PURE__ */
|
|
7381
|
-
/* @__PURE__ */
|
|
7304
|
+
return /* @__PURE__ */ jsxs15(Fragment6, { children: [
|
|
7305
|
+
/* @__PURE__ */ jsx16(PanelHeader, { title: t("Email"), onClose: onDismiss, closeLabel: "Close" }),
|
|
7306
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:space-y-4 eb:p-4", children: [
|
|
7307
|
+
/* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
|
|
7308
|
+
/* @__PURE__ */ jsx16(SectionLabel, { children: t("Template") }),
|
|
7309
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
|
|
7310
|
+
/* @__PURE__ */ jsxs15(Label, { htmlFor: "eb-meta-name", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: [
|
|
7382
7311
|
t("Name"),
|
|
7383
7312
|
" ",
|
|
7384
|
-
/* @__PURE__ */
|
|
7313
|
+
/* @__PURE__ */ jsx16("span", { className: "eb:text-destructive", children: "*" })
|
|
7385
7314
|
] }),
|
|
7386
|
-
/* @__PURE__ */
|
|
7315
|
+
/* @__PURE__ */ jsx16(
|
|
7387
7316
|
Input,
|
|
7388
7317
|
{
|
|
7389
7318
|
id: "eb-meta-name",
|
|
@@ -7394,12 +7323,12 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7394
7323
|
"aria-invalid": showErrors && !meta.name.trim() || void 0
|
|
7395
7324
|
}
|
|
7396
7325
|
),
|
|
7397
|
-
showErrors && !meta.name.trim() && /* @__PURE__ */
|
|
7326
|
+
showErrors && !meta.name.trim() && /* @__PURE__ */ jsx16("p", { className: "eb:text-[12px] eb:text-destructive", children: t("Name is required") })
|
|
7398
7327
|
] }),
|
|
7399
|
-
/* @__PURE__ */
|
|
7400
|
-
/* @__PURE__ */
|
|
7401
|
-
/* @__PURE__ */
|
|
7402
|
-
variables && /* @__PURE__ */
|
|
7328
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
|
|
7329
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
|
|
7330
|
+
/* @__PURE__ */ jsx16(Label, { htmlFor: "eb-meta-subject", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Subject") }),
|
|
7331
|
+
variables && /* @__PURE__ */ jsx16(
|
|
7403
7332
|
VariableInsertButton,
|
|
7404
7333
|
{
|
|
7405
7334
|
variables,
|
|
@@ -7410,8 +7339,8 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7410
7339
|
}
|
|
7411
7340
|
)
|
|
7412
7341
|
] }),
|
|
7413
|
-
/* @__PURE__ */
|
|
7414
|
-
ai?.suggestSubjects && /* @__PURE__ */
|
|
7342
|
+
/* @__PURE__ */ jsx16(Input, { ref: subjectRef, id: "eb-meta-subject", dense: true, maxLength: 250, value: meta.subject, onChange: field("subject") }),
|
|
7343
|
+
ai?.suggestSubjects && /* @__PURE__ */ jsx16(
|
|
7415
7344
|
ai.components.Subjects,
|
|
7416
7345
|
{
|
|
7417
7346
|
editor,
|
|
@@ -7422,10 +7351,10 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7422
7351
|
}
|
|
7423
7352
|
)
|
|
7424
7353
|
] }),
|
|
7425
|
-
/* @__PURE__ */
|
|
7426
|
-
/* @__PURE__ */
|
|
7427
|
-
/* @__PURE__ */
|
|
7428
|
-
variables && /* @__PURE__ */
|
|
7354
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
|
|
7355
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
|
|
7356
|
+
/* @__PURE__ */ jsx16(Label, { htmlFor: "eb-meta-preheader", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Preview text") }),
|
|
7357
|
+
variables && /* @__PURE__ */ jsx16(
|
|
7429
7358
|
VariableInsertButton,
|
|
7430
7359
|
{
|
|
7431
7360
|
variables,
|
|
@@ -7436,7 +7365,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7436
7365
|
}
|
|
7437
7366
|
)
|
|
7438
7367
|
] }),
|
|
7439
|
-
/* @__PURE__ */
|
|
7368
|
+
/* @__PURE__ */ jsx16(
|
|
7440
7369
|
Textarea,
|
|
7441
7370
|
{
|
|
7442
7371
|
ref: preheaderRef,
|
|
@@ -7451,7 +7380,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
7451
7380
|
)
|
|
7452
7381
|
] })
|
|
7453
7382
|
] }),
|
|
7454
|
-
root && bodyBlock2 && /* @__PURE__ */
|
|
7383
|
+
root && bodyBlock2 && /* @__PURE__ */ jsx16(PropertyGroups, { editor, element: root, block: bodyBlock2, idPrefix: "eb-page" })
|
|
7455
7384
|
] })
|
|
7456
7385
|
] });
|
|
7457
7386
|
}
|
|
@@ -7469,7 +7398,7 @@ function PropertiesPanel({
|
|
|
7469
7398
|
}) {
|
|
7470
7399
|
const t = useT();
|
|
7471
7400
|
const block = selection?.blockId ? editor.getBlock(selection.blockId) : null;
|
|
7472
|
-
return /* @__PURE__ */
|
|
7401
|
+
return /* @__PURE__ */ jsx16("aside", { "aria-label": t("Properties"), className: "eb:min-h-0 eb:overflow-y-auto", "data-testid": "eb-properties", children: !selection ? /* @__PURE__ */ jsx16(
|
|
7473
7402
|
TemplateSettings,
|
|
7474
7403
|
{
|
|
7475
7404
|
editor,
|
|
@@ -7481,8 +7410,8 @@ function PropertiesPanel({
|
|
|
7481
7410
|
ai,
|
|
7482
7411
|
onDismiss
|
|
7483
7412
|
}
|
|
7484
|
-
) : /* @__PURE__ */
|
|
7485
|
-
/* @__PURE__ */
|
|
7413
|
+
) : /* @__PURE__ */ jsxs15(Fragment6, { children: [
|
|
7414
|
+
/* @__PURE__ */ jsx16(
|
|
7486
7415
|
PanelHeader,
|
|
7487
7416
|
{
|
|
7488
7417
|
title: t(selection.label),
|
|
@@ -7490,11 +7419,11 @@ function PropertiesPanel({
|
|
|
7490
7419
|
closeLabel: onDismiss ? "Close" : "Deselect"
|
|
7491
7420
|
}
|
|
7492
7421
|
),
|
|
7493
|
-
selection.multiple ? /* @__PURE__ */
|
|
7494
|
-
/* @__PURE__ */
|
|
7422
|
+
selection.multiple ? /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-3 eb:p-4", children: [
|
|
7423
|
+
/* @__PURE__ */ jsx16("p", { className: "eb:text-[13px] eb:leading-relaxed eb:text-foreground-lighter", "data-testid": "eb-select-all", children: t("{count} sections selected. Press Delete to remove them (Ctrl+Z brings them back).", {
|
|
7495
7424
|
count: selection.multiple
|
|
7496
7425
|
}) }),
|
|
7497
|
-
/* @__PURE__ */
|
|
7426
|
+
/* @__PURE__ */ jsxs15(
|
|
7498
7427
|
Button,
|
|
7499
7428
|
{
|
|
7500
7429
|
variant: "outline",
|
|
@@ -7502,16 +7431,16 @@ function PropertiesPanel({
|
|
|
7502
7431
|
onClick: () => editor.remove(selection.id),
|
|
7503
7432
|
className: "eb:hover:border-destructive/40 eb:hover:bg-destructive/10 eb:hover:text-destructive",
|
|
7504
7433
|
children: [
|
|
7505
|
-
/* @__PURE__ */
|
|
7434
|
+
/* @__PURE__ */ jsx16(Trash24, { "aria-hidden": "true" }),
|
|
7506
7435
|
t("Delete")
|
|
7507
7436
|
]
|
|
7508
7437
|
}
|
|
7509
7438
|
)
|
|
7510
|
-
] }) : /* @__PURE__ */
|
|
7511
|
-
editor.getDevice() === "mobile" && /* @__PURE__ */
|
|
7512
|
-
selection.content !== null && selection.content !== void 0 && /* @__PURE__ */
|
|
7513
|
-
/* @__PURE__ */
|
|
7514
|
-
/* @__PURE__ */
|
|
7439
|
+
] }) : /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-4 eb:p-4", children: [
|
|
7440
|
+
editor.getDevice() === "mobile" && /* @__PURE__ */ jsx16(MobileStyles, { editor, element: selection, block }),
|
|
7441
|
+
selection.content !== null && selection.content !== void 0 && /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
|
|
7442
|
+
/* @__PURE__ */ jsx16(SectionLabel, { children: t(GROUPS.content) }),
|
|
7443
|
+
/* @__PURE__ */ jsx16(
|
|
7515
7444
|
PropertyField,
|
|
7516
7445
|
{
|
|
7517
7446
|
idPrefix: "eb-prop",
|
|
@@ -7522,16 +7451,16 @@ function PropertiesPanel({
|
|
|
7522
7451
|
`${selection.id}:content`
|
|
7523
7452
|
)
|
|
7524
7453
|
] }),
|
|
7525
|
-
selection.tagName === "mj-text" && /* @__PURE__ */
|
|
7526
|
-
ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */
|
|
7527
|
-
/* @__PURE__ */
|
|
7454
|
+
selection.tagName === "mj-text" && /* @__PURE__ */ jsx16("p", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("Double-click the text to edit it.") }),
|
|
7455
|
+
ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */ jsx16(ai.components.Rewrite, { editor, selection, rewrite: ai.rewrite }, selection.id),
|
|
7456
|
+
/* @__PURE__ */ jsx16(PropertyGroups, { editor, element: selection, block, idPrefix: "eb-prop", services, hidden: RIBBON_KEYS })
|
|
7528
7457
|
] })
|
|
7529
7458
|
] }) });
|
|
7530
7459
|
}
|
|
7531
7460
|
|
|
7532
7461
|
// src/ui/Toolbar.jsx
|
|
7533
7462
|
import { ArrowLeft, Monitor, Redo2, Smartphone as Smartphone2, Undo2 } from "lucide-react";
|
|
7534
|
-
import { Fragment as
|
|
7463
|
+
import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7535
7464
|
function Toolbar({
|
|
7536
7465
|
title,
|
|
7537
7466
|
status,
|
|
@@ -7548,8 +7477,8 @@ function Toolbar({
|
|
|
7548
7477
|
compact = false
|
|
7549
7478
|
}) {
|
|
7550
7479
|
const t = useT();
|
|
7551
|
-
const identity2 = /* @__PURE__ */
|
|
7552
|
-
/* @__PURE__ */
|
|
7480
|
+
const identity2 = /* @__PURE__ */ jsxs16(Fragment7, { children: [
|
|
7481
|
+
/* @__PURE__ */ jsxs16(
|
|
7553
7482
|
Button,
|
|
7554
7483
|
{
|
|
7555
7484
|
variant: "ghost",
|
|
@@ -7557,50 +7486,50 @@ function Toolbar({
|
|
|
7557
7486
|
onClick: onBack,
|
|
7558
7487
|
"aria-label": compact ? t("Back") : void 0,
|
|
7559
7488
|
children: [
|
|
7560
|
-
/* @__PURE__ */
|
|
7489
|
+
/* @__PURE__ */ jsx17(ArrowLeft, {}),
|
|
7561
7490
|
!compact && t("Back")
|
|
7562
7491
|
]
|
|
7563
7492
|
}
|
|
7564
7493
|
),
|
|
7565
|
-
/* @__PURE__ */
|
|
7566
|
-
/* @__PURE__ */
|
|
7567
|
-
/* @__PURE__ */
|
|
7568
|
-
/* @__PURE__ */
|
|
7494
|
+
/* @__PURE__ */ jsx17(Separator, { orientation: "vertical", className: "eb:h-5" }),
|
|
7495
|
+
/* @__PURE__ */ jsxs16("div", { className: cn("eb:min-w-0 eb:flex-1", !compact && "eb:max-w-[320px]"), children: [
|
|
7496
|
+
/* @__PURE__ */ jsx17("p", { className: "eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx17(TruncatedText, { children: title || t("New template") }) }),
|
|
7497
|
+
/* @__PURE__ */ jsx17("p", { className: "eb:text-[11px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: status })
|
|
7569
7498
|
] })
|
|
7570
7499
|
] });
|
|
7571
|
-
const editing = /* @__PURE__ */
|
|
7572
|
-
/* @__PURE__ */
|
|
7573
|
-
/* @__PURE__ */
|
|
7574
|
-
/* @__PURE__ */
|
|
7500
|
+
const editing = /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: [
|
|
7501
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:items-center eb:gap-0.5", children: [
|
|
7502
|
+
/* @__PURE__ */ jsx17(TooltipWrap, { label: t("Undo (Ctrl+Z)"), children: /* @__PURE__ */ jsx17(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onUndo, disabled: !ready || !canUndo, "aria-label": t("Undo"), children: /* @__PURE__ */ jsx17(Undo2, {}) }) }),
|
|
7503
|
+
/* @__PURE__ */ jsx17(TooltipWrap, { label: t("Redo (Ctrl+Y)"), children: /* @__PURE__ */ jsx17(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onRedo, disabled: !ready || !canRedo, "aria-label": t("Redo"), children: /* @__PURE__ */ jsx17(Redo2, {}) }) })
|
|
7575
7504
|
] }),
|
|
7576
|
-
/* @__PURE__ */
|
|
7577
|
-
/* @__PURE__ */
|
|
7578
|
-
/* @__PURE__ */
|
|
7505
|
+
/* @__PURE__ */ jsx17(Tabs, { value: device, onValueChange: onDeviceChange, children: /* @__PURE__ */ jsxs16(TabsList, { "aria-label": t("Device"), children: [
|
|
7506
|
+
/* @__PURE__ */ jsxs16(TabsTrigger, { value: "desktop", disabled: !ready, "aria-label": compact ? t("Desktop") : void 0, children: [
|
|
7507
|
+
/* @__PURE__ */ jsx17(Monitor, {}),
|
|
7579
7508
|
!compact && t("Desktop")
|
|
7580
7509
|
] }),
|
|
7581
|
-
/* @__PURE__ */
|
|
7582
|
-
/* @__PURE__ */
|
|
7510
|
+
/* @__PURE__ */ jsxs16(TabsTrigger, { value: "mobile", disabled: !ready, "aria-label": compact ? t("Mobile") : void 0, children: [
|
|
7511
|
+
/* @__PURE__ */ jsx17(Smartphone2, {}),
|
|
7583
7512
|
!compact && t("Mobile")
|
|
7584
7513
|
] })
|
|
7585
7514
|
] }) })
|
|
7586
7515
|
] });
|
|
7587
7516
|
if (compact) {
|
|
7588
|
-
return /* @__PURE__ */
|
|
7589
|
-
/* @__PURE__ */
|
|
7517
|
+
return /* @__PURE__ */ jsxs16("div", { className: "eb:shrink-0 eb:border-b eb:border-border", "data-layout": "compact", children: [
|
|
7518
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-12 eb:items-center eb:gap-2 eb:px-2", children: [
|
|
7590
7519
|
identity2,
|
|
7591
7520
|
primary
|
|
7592
7521
|
] }),
|
|
7593
|
-
/* @__PURE__ */
|
|
7522
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:items-center eb:gap-2 eb:overflow-x-auto eb:px-2 eb:pb-2", "data-testid": "eb-toolbar-actions", children: [
|
|
7594
7523
|
editing,
|
|
7595
|
-
/* @__PURE__ */
|
|
7596
|
-
/* @__PURE__ */
|
|
7524
|
+
/* @__PURE__ */ jsx17(Separator, { orientation: "vertical", className: "eb:h-5 eb:shrink-0" }),
|
|
7525
|
+
/* @__PURE__ */ jsx17("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: actions })
|
|
7597
7526
|
] })
|
|
7598
7527
|
] });
|
|
7599
7528
|
}
|
|
7600
|
-
return /* @__PURE__ */
|
|
7529
|
+
return /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-12 eb:shrink-0 eb:items-center eb:gap-3 eb:border-b eb:border-border eb:px-3", children: [
|
|
7601
7530
|
identity2,
|
|
7602
7531
|
editing,
|
|
7603
|
-
/* @__PURE__ */
|
|
7532
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:ml-auto eb:flex eb:items-center eb:gap-2", "data-testid": "eb-toolbar-actions", children: [
|
|
7604
7533
|
actions,
|
|
7605
7534
|
primary
|
|
7606
7535
|
] })
|
|
@@ -7608,15 +7537,15 @@ function Toolbar({
|
|
|
7608
7537
|
}
|
|
7609
7538
|
|
|
7610
7539
|
// src/ui/CanvasPanel.jsx
|
|
7611
|
-
import { useEffect as useEffect12, useRef as useRef11, useState as
|
|
7540
|
+
import { useEffect as useEffect12, useRef as useRef11, useState as useState15 } from "react";
|
|
7612
7541
|
import { X as X3 } from "lucide-react";
|
|
7613
|
-
import { jsx as
|
|
7542
|
+
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7614
7543
|
function CanvasPanel({ feature, context, compact, onClose }) {
|
|
7615
7544
|
const { t } = useUi();
|
|
7616
7545
|
const open = Boolean(feature);
|
|
7617
|
-
const [last, setLast] =
|
|
7546
|
+
const [last, setLast] = useState15(feature);
|
|
7618
7547
|
if (feature && feature !== last) setLast(feature);
|
|
7619
|
-
const [wide, setWide] =
|
|
7548
|
+
const [wide, setWide] = useState15(false);
|
|
7620
7549
|
useEffect12(() => {
|
|
7621
7550
|
if (!open) {
|
|
7622
7551
|
setWide(false);
|
|
@@ -7636,7 +7565,7 @@ function CanvasPanel({ feature, context, compact, onClose }) {
|
|
|
7636
7565
|
if (!shown?.drawer) return null;
|
|
7637
7566
|
const { label, panel: Panel } = shown.drawer;
|
|
7638
7567
|
const name = t(label);
|
|
7639
|
-
return /* @__PURE__ */
|
|
7568
|
+
return /* @__PURE__ */ jsx18(
|
|
7640
7569
|
"div",
|
|
7641
7570
|
{
|
|
7642
7571
|
ref,
|
|
@@ -7646,7 +7575,7 @@ function CanvasPanel({ feature, context, compact, onClose }) {
|
|
|
7646
7575
|
compact && "eb:absolute eb:inset-y-0 eb:right-0 eb:z-20 eb:shadow-lg"
|
|
7647
7576
|
),
|
|
7648
7577
|
onTransitionEnd: (event) => event.target === event.currentTarget && !open && setLast(null),
|
|
7649
|
-
children: /* @__PURE__ */
|
|
7578
|
+
children: /* @__PURE__ */ jsxs17(
|
|
7650
7579
|
"aside",
|
|
7651
7580
|
{
|
|
7652
7581
|
id: `eb-drawer-${shown.id}`,
|
|
@@ -7654,8 +7583,8 @@ function CanvasPanel({ feature, context, compact, onClose }) {
|
|
|
7654
7583
|
"data-testid": `eb-panel-${shown.id}`,
|
|
7655
7584
|
className: "eb:flex eb:h-full eb:w-64 eb:flex-col eb:border-l eb:border-border eb:bg-background",
|
|
7656
7585
|
children: [
|
|
7657
|
-
/* @__PURE__ */
|
|
7658
|
-
/* @__PURE__ */
|
|
7586
|
+
/* @__PURE__ */ jsx18("header", { className: "eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:justify-end eb:pr-1.5", children: /* @__PURE__ */ jsx18(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t("Close the panel"), children: /* @__PURE__ */ jsx18(X3, {}) }) }),
|
|
7587
|
+
/* @__PURE__ */ jsx18(Panel, { context })
|
|
7659
7588
|
]
|
|
7660
7589
|
}
|
|
7661
7590
|
)
|
|
@@ -7666,7 +7595,7 @@ function CanvasPanel({ feature, context, compact, onClose }) {
|
|
|
7666
7595
|
// src/ui/Drawer.jsx
|
|
7667
7596
|
import { useEffect as useEffect13 } from "react";
|
|
7668
7597
|
import { X as X4 } from "lucide-react";
|
|
7669
|
-
import { jsx as
|
|
7598
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7670
7599
|
function Drawer({ open, side = "left", title, onClose, children, testId, header: header2 = true }) {
|
|
7671
7600
|
const t = useT();
|
|
7672
7601
|
useEffect13(() => {
|
|
@@ -7677,9 +7606,9 @@ function Drawer({ open, side = "left", title, onClose, children, testId, header:
|
|
|
7677
7606
|
window.addEventListener("keydown", onKey);
|
|
7678
7607
|
return () => window.removeEventListener("keydown", onKey);
|
|
7679
7608
|
}, [open, onClose]);
|
|
7680
|
-
return /* @__PURE__ */
|
|
7681
|
-
/* @__PURE__ */
|
|
7682
|
-
/* @__PURE__ */
|
|
7609
|
+
return /* @__PURE__ */ jsxs18("div", { className: cn("eb:absolute eb:inset-0 eb:z-20", !open && "eb:hidden"), "data-testid": testId, "data-open": open ? "true" : "false", children: [
|
|
7610
|
+
/* @__PURE__ */ jsx19("div", { className: "eb:absolute eb:inset-0 eb:bg-black/30", onClick: onClose, "aria-hidden": "true" }),
|
|
7611
|
+
/* @__PURE__ */ jsxs18(
|
|
7683
7612
|
"section",
|
|
7684
7613
|
{
|
|
7685
7614
|
role: "dialog",
|
|
@@ -7689,11 +7618,11 @@ function Drawer({ open, side = "left", title, onClose, children, testId, header:
|
|
|
7689
7618
|
side === "left" ? "eb:left-0 eb:border-r eb:border-border" : "eb:right-0 eb:border-l eb:border-border"
|
|
7690
7619
|
),
|
|
7691
7620
|
children: [
|
|
7692
|
-
header2 && /* @__PURE__ */
|
|
7693
|
-
/* @__PURE__ */
|
|
7694
|
-
/* @__PURE__ */
|
|
7621
|
+
header2 && /* @__PURE__ */ jsxs18("header", { className: "eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:justify-between eb:border-b eb:border-border eb:px-3", children: [
|
|
7622
|
+
/* @__PURE__ */ jsx19("h3", { className: "eb:text-[13px] eb:font-medium eb:text-foreground", children: title }),
|
|
7623
|
+
/* @__PURE__ */ jsx19(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t("Close"), children: /* @__PURE__ */ jsx19(X4, {}) })
|
|
7695
7624
|
] }),
|
|
7696
|
-
/* @__PURE__ */
|
|
7625
|
+
/* @__PURE__ */ jsx19("div", { className: "eb:grid eb:min-h-0 eb:flex-1", children })
|
|
7697
7626
|
]
|
|
7698
7627
|
}
|
|
7699
7628
|
)
|
|
@@ -7701,10 +7630,10 @@ function Drawer({ open, side = "left", title, onClose, children, testId, header:
|
|
|
7701
7630
|
}
|
|
7702
7631
|
|
|
7703
7632
|
// src/ui/useEmailEditorState.js
|
|
7704
|
-
import { useCallback as useCallback2, useEffect as useEffect14, useRef as useRef12, useState as
|
|
7633
|
+
import { useCallback as useCallback2, useEffect as useEffect14, useRef as useRef12, useState as useState16 } from "react";
|
|
7705
7634
|
var DIRTY_CHECK_MS = 150;
|
|
7706
7635
|
function useEmailEditorState(editor) {
|
|
7707
|
-
const [state, setState] =
|
|
7636
|
+
const [state, setState] = useState16(() => ({
|
|
7708
7637
|
status: editor?.status || "idle",
|
|
7709
7638
|
selection: null,
|
|
7710
7639
|
canUndo: false,
|
|
@@ -7788,9 +7717,9 @@ function useEmailEditorState(editor) {
|
|
|
7788
7717
|
}
|
|
7789
7718
|
|
|
7790
7719
|
// src/ui/SidePanel.jsx
|
|
7791
|
-
import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef13, useState as
|
|
7720
|
+
import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef13, useState as useState17 } from "react";
|
|
7792
7721
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
7793
|
-
import { jsx as
|
|
7722
|
+
import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
7794
7723
|
var SIDE_PANELS = {
|
|
7795
7724
|
// Two blocks in a row: wider, the row takes three.
|
|
7796
7725
|
blocks: { width: 272, min: 200, max: 480 },
|
|
@@ -7828,8 +7757,8 @@ function initialPanels() {
|
|
|
7828
7757
|
return panels;
|
|
7829
7758
|
}
|
|
7830
7759
|
function useSidePanels() {
|
|
7831
|
-
const [panels, setPanels] =
|
|
7832
|
-
const [moving, setMoving] =
|
|
7760
|
+
const [panels, setPanels] = useState17(initialPanels);
|
|
7761
|
+
const [moving, setMoving] = useState17(
|
|
7833
7762
|
/** @type {Partial<Record<keyof typeof SIDE_PANELS, true>>} */
|
|
7834
7763
|
{}
|
|
7835
7764
|
);
|
|
@@ -7867,8 +7796,8 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7867
7796
|
/** @type {{x: number, width: number, max: number}|null} */
|
|
7868
7797
|
null
|
|
7869
7798
|
);
|
|
7870
|
-
const [dragging, setDragging] =
|
|
7871
|
-
const [glide, setGlide] =
|
|
7799
|
+
const [dragging, setDragging] = useState17(false);
|
|
7800
|
+
const [glide, setGlide] = useState17(0);
|
|
7872
7801
|
const { min, max } = SIDE_PANELS[name];
|
|
7873
7802
|
const sign = side === "left" ? 1 : -1;
|
|
7874
7803
|
const widest = () => clamp2(room(), min, max);
|
|
@@ -7880,7 +7809,7 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7880
7809
|
setGlide(open ? panel?.clientWidth || 0 : Math.min(state.width, widest()) - border);
|
|
7881
7810
|
onChange({ collapsed: open });
|
|
7882
7811
|
};
|
|
7883
|
-
return /* @__PURE__ */
|
|
7812
|
+
return /* @__PURE__ */ jsxs19(
|
|
7884
7813
|
"div",
|
|
7885
7814
|
{
|
|
7886
7815
|
ref,
|
|
@@ -7889,7 +7818,7 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7889
7818
|
"data-collapsed": open ? "false" : "true",
|
|
7890
7819
|
children: [
|
|
7891
7820
|
(open || moving) && // Held on the border with the canvas, the content slides out at the far edge.
|
|
7892
|
-
/* @__PURE__ */
|
|
7821
|
+
/* @__PURE__ */ jsx20("div", { className: cn("eb:absolute eb:inset-0 eb:flex eb:overflow-hidden", side === "left" && "eb:justify-end"), children: /* @__PURE__ */ jsx20(
|
|
7893
7822
|
"div",
|
|
7894
7823
|
{
|
|
7895
7824
|
className: cn(
|
|
@@ -7901,7 +7830,7 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7901
7830
|
children
|
|
7902
7831
|
}
|
|
7903
7832
|
) }),
|
|
7904
|
-
open && /* @__PURE__ */
|
|
7833
|
+
open && /* @__PURE__ */ jsx20(
|
|
7905
7834
|
"div",
|
|
7906
7835
|
{
|
|
7907
7836
|
role: "separator",
|
|
@@ -7940,7 +7869,7 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7940
7869
|
event.preventDefault();
|
|
7941
7870
|
onChange({ width: clamp2(rendered() + sign * step, min, widest()) });
|
|
7942
7871
|
},
|
|
7943
|
-
children: /* @__PURE__ */
|
|
7872
|
+
children: /* @__PURE__ */ jsx20(
|
|
7944
7873
|
"span",
|
|
7945
7874
|
{
|
|
7946
7875
|
className: cn(
|
|
@@ -7952,14 +7881,14 @@ function SidePanel({ name, side, state, moving = false, onChange, room, labels,
|
|
|
7952
7881
|
)
|
|
7953
7882
|
}
|
|
7954
7883
|
),
|
|
7955
|
-
/* @__PURE__ */
|
|
7884
|
+
/* @__PURE__ */ jsx20(EdgeToggle, { side, collapsed: !open, label: open ? labels.hide : labels.show, onClick: toggle })
|
|
7956
7885
|
]
|
|
7957
7886
|
}
|
|
7958
7887
|
);
|
|
7959
7888
|
}
|
|
7960
7889
|
function EdgeToggle({ side, collapsed, label, onClick }) {
|
|
7961
7890
|
const Arrow = side === "left" === collapsed ? ChevronRight : ChevronLeft;
|
|
7962
|
-
return /* @__PURE__ */
|
|
7891
|
+
return /* @__PURE__ */ jsx20(TooltipWrap, { label, side: side === "left" ? "right" : "left", children: /* @__PURE__ */ jsx20(
|
|
7963
7892
|
"button",
|
|
7964
7893
|
{
|
|
7965
7894
|
type: "button",
|
|
@@ -7971,13 +7900,13 @@ function EdgeToggle({ side, collapsed, label, onClick }) {
|
|
|
7971
7900
|
"eb:hover:border-primary/50 eb:hover:text-foreground eb:focus-visible:ring-2 eb:focus-visible:ring-ring/50",
|
|
7972
7901
|
EDGE2[side]
|
|
7973
7902
|
),
|
|
7974
|
-
children: /* @__PURE__ */
|
|
7903
|
+
children: /* @__PURE__ */ jsx20(Arrow, { className: "eb:size-3.5", "aria-hidden": "true" })
|
|
7975
7904
|
}
|
|
7976
7905
|
) });
|
|
7977
7906
|
}
|
|
7978
7907
|
|
|
7979
7908
|
// src/ui/EmailBuilder.jsx
|
|
7980
|
-
import { Fragment as
|
|
7909
|
+
import { Fragment as Fragment8, jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7981
7910
|
var EMPTY_META = { name: "", subject: "", preheader: "", description: "" };
|
|
7982
7911
|
function metaOf(template) {
|
|
7983
7912
|
return {
|
|
@@ -8021,7 +7950,7 @@ function Builder({
|
|
|
8021
7950
|
[injected, locale]
|
|
8022
7951
|
);
|
|
8023
7952
|
const systemVariables = useMemo6(() => defineVariables(variablesProp || DEFAULT_VARIABLES), [variablesProp]);
|
|
8024
|
-
const [customVariables, setCustomVariables] =
|
|
7953
|
+
const [customVariables, setCustomVariables] = useState18([]);
|
|
8025
7954
|
const variables = useMemo6(() => mergeVariables(systemVariables, customVariables), [systemVariables, customVariables]);
|
|
8026
7955
|
const canManageVariables = typeof storage.saveVariable === "function" && typeof storage.listVariables === "function";
|
|
8027
7956
|
const reloadVariables = useCallback4(async () => {
|
|
@@ -8055,24 +7984,24 @@ function Builder({
|
|
|
8055
7984
|
const state = useEmailEditorState(editor);
|
|
8056
7985
|
const autosaveOn = isFeatureEnabled("autosave");
|
|
8057
7986
|
const autosaveOptions = emailBuilderFeatures.get("autosave")?.options || {};
|
|
8058
|
-
const [template, setTemplate] =
|
|
8059
|
-
const [boot, setBoot] =
|
|
8060
|
-
const [meta, setMeta] =
|
|
8061
|
-
const [savedMeta, setSavedMeta] =
|
|
8062
|
-
const [saving, setSaving] =
|
|
8063
|
-
const [showErrors, setShowErrors] =
|
|
8064
|
-
const [autosaveBlocked, setAutosaveBlocked] =
|
|
8065
|
-
const [engineError, setEngineError] =
|
|
8066
|
-
const [attempt, setAttempt] =
|
|
7987
|
+
const [template, setTemplate] = useState18({ id: initialTemplateId, revision: null, savedAt: null, auto: false });
|
|
7988
|
+
const [boot, setBoot] = useState18({ status: "loading", document: null, mjml: null, draft: false, message: null });
|
|
7989
|
+
const [meta, setMeta] = useState18(EMPTY_META);
|
|
7990
|
+
const [savedMeta, setSavedMeta] = useState18(EMPTY_META);
|
|
7991
|
+
const [saving, setSaving] = useState18(null);
|
|
7992
|
+
const [showErrors, setShowErrors] = useState18(false);
|
|
7993
|
+
const [autosaveBlocked, setAutosaveBlocked] = useState18(null);
|
|
7994
|
+
const [engineError, setEngineError] = useState18(null);
|
|
7995
|
+
const [attempt, setAttempt] = useState18(0);
|
|
8067
7996
|
const rootRef = useRef14(null);
|
|
8068
7997
|
const layout2 = useLayoutWidth(rootRef);
|
|
8069
7998
|
const compact = layout2 !== "wide";
|
|
8070
7999
|
const blocksInDrawer = layout2 === "narrow";
|
|
8071
8000
|
const { panels, update: updatePanel, moving: movingPanels } = useSidePanels();
|
|
8072
8001
|
const gridRef = useRef14(null);
|
|
8073
|
-
const [drawer, setDrawer] =
|
|
8002
|
+
const [drawer, setDrawer] = useState18(null);
|
|
8074
8003
|
const closeDrawer = useCallback4(() => setDrawer(null), []);
|
|
8075
|
-
const [canvasPanel, setCanvasPanel] =
|
|
8004
|
+
const [canvasPanel, setCanvasPanel] = useState18(null);
|
|
8076
8005
|
useEffect16(() => {
|
|
8077
8006
|
if (!compact) setDrawer(null);
|
|
8078
8007
|
else if (!blocksInDrawer) setDrawer((d) => d === "blocks" ? null : d);
|
|
@@ -8350,7 +8279,7 @@ function Builder({
|
|
|
8350
8279
|
const otherWidth = otherPanel ? otherPanel.getBoundingClientRect().width : 0;
|
|
8351
8280
|
return grid.getBoundingClientRect().width - otherWidth - (layout2 === "wide" ? CANVAS_MIN.wide : CANVAS_MIN.medium);
|
|
8352
8281
|
};
|
|
8353
|
-
const properties = /* @__PURE__ */
|
|
8282
|
+
const properties = /* @__PURE__ */ jsx21(
|
|
8354
8283
|
PropertiesPanel,
|
|
8355
8284
|
{
|
|
8356
8285
|
onDismiss: compact ? closeDrawer : null,
|
|
@@ -8365,7 +8294,7 @@ function Builder({
|
|
|
8365
8294
|
variables
|
|
8366
8295
|
}
|
|
8367
8296
|
);
|
|
8368
|
-
return /* @__PURE__ */
|
|
8297
|
+
return /* @__PURE__ */ jsxs20(
|
|
8369
8298
|
"div",
|
|
8370
8299
|
{
|
|
8371
8300
|
ref: rootRef,
|
|
@@ -8375,7 +8304,7 @@ function Builder({
|
|
|
8375
8304
|
"data-layout": layout2,
|
|
8376
8305
|
"data-template-id": template.id || "",
|
|
8377
8306
|
children: [
|
|
8378
|
-
/* @__PURE__ */
|
|
8307
|
+
/* @__PURE__ */ jsx21(
|
|
8379
8308
|
Toolbar,
|
|
8380
8309
|
{
|
|
8381
8310
|
title: meta.name,
|
|
@@ -8391,26 +8320,26 @@ function Builder({
|
|
|
8391
8320
|
compact,
|
|
8392
8321
|
actions: [
|
|
8393
8322
|
// The AI module's button first, when the host gave the module.
|
|
8394
|
-
ai?.proofread && /* @__PURE__ */
|
|
8323
|
+
ai?.proofread && /* @__PURE__ */ jsx21(ai.components.Proofread, { context: featureContext, proofread: ai.proofread }, "ai-proofread"),
|
|
8395
8324
|
...toolbarFeatures.map((feature) => {
|
|
8396
8325
|
const Action = feature.toolbar;
|
|
8397
|
-
return /* @__PURE__ */
|
|
8326
|
+
return /* @__PURE__ */ jsx21(Action, { context: featureContext }, feature.id);
|
|
8398
8327
|
})
|
|
8399
8328
|
].filter(Boolean),
|
|
8400
|
-
primary: /* @__PURE__ */
|
|
8401
|
-
saving === "manual" ? /* @__PURE__ */
|
|
8329
|
+
primary: /* @__PURE__ */ jsxs20(Button, { size: "sm-compact", onClick: () => save(), disabled: !ready || saving !== null, children: [
|
|
8330
|
+
saving === "manual" ? /* @__PURE__ */ jsx21(Loader26, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx21(Save, {}),
|
|
8402
8331
|
t("Save")
|
|
8403
8332
|
] })
|
|
8404
8333
|
}
|
|
8405
8334
|
),
|
|
8406
|
-
/* @__PURE__ */
|
|
8335
|
+
/* @__PURE__ */ jsxs20(
|
|
8407
8336
|
"div",
|
|
8408
8337
|
{
|
|
8409
8338
|
ref: gridRef,
|
|
8410
8339
|
className: cn("eb:relative eb:grid eb:min-h-0 eb:flex-1 eb:grid-rows-1", Object.keys(movingPanels).length > 0 && FOLD_TRANSITION),
|
|
8411
8340
|
style: { gridTemplateColumns: columns },
|
|
8412
8341
|
children: [
|
|
8413
|
-
!blocksInDrawer && /* @__PURE__ */
|
|
8342
|
+
!blocksInDrawer && /* @__PURE__ */ jsx21(
|
|
8414
8343
|
SidePanel,
|
|
8415
8344
|
{
|
|
8416
8345
|
name: "blocks",
|
|
@@ -8420,14 +8349,14 @@ function Builder({
|
|
|
8420
8349
|
onChange: (patch) => updatePanel("blocks", patch),
|
|
8421
8350
|
room: () => roomFor("properties"),
|
|
8422
8351
|
labels: { resize: t("Width of the blocks"), hide: t("Hide the blocks"), show: t("Show the blocks") },
|
|
8423
|
-
children: /* @__PURE__ */
|
|
8352
|
+
children: /* @__PURE__ */ jsx21(BlockSidebar, { editor, disabled: !ready, onAdded: compact ? () => setDrawer("properties") : void 0 })
|
|
8424
8353
|
}
|
|
8425
8354
|
),
|
|
8426
|
-
/* @__PURE__ */
|
|
8427
|
-
/* @__PURE__ */
|
|
8428
|
-
/* @__PURE__ */
|
|
8429
|
-
/* @__PURE__ */
|
|
8430
|
-
engineError && /* @__PURE__ */
|
|
8355
|
+
/* @__PURE__ */ jsx21("div", { className: "eb:relative eb:flex eb:min-w-0 eb:flex-col eb:bg-surface-75", "aria-busy": !ready, children: boot.status === "error" || engineError ? /* @__PURE__ */ jsxs20("div", { role: "alert", className: "eb:flex eb:h-full eb:flex-col eb:items-center eb:justify-center eb:gap-2 eb:p-6 eb:text-center", children: [
|
|
8356
|
+
/* @__PURE__ */ jsx21(AlertTriangle, { className: "eb:size-6 eb:text-destructive", "aria-hidden": "true" }),
|
|
8357
|
+
/* @__PURE__ */ jsx21("p", { className: "eb:text-[13px] eb:text-foreground", children: boot.status === "error" ? t("The template could not be loaded.") : t("The builder could not start.") }),
|
|
8358
|
+
/* @__PURE__ */ jsx21("p", { className: "eb:max-w-sm eb:text-[12px] eb:text-foreground-muted", children: boot.message || engineError }),
|
|
8359
|
+
engineError && /* @__PURE__ */ jsx21(
|
|
8431
8360
|
Button,
|
|
8432
8361
|
{
|
|
8433
8362
|
variant: "outline",
|
|
@@ -8439,8 +8368,8 @@ function Builder({
|
|
|
8439
8368
|
children: t("Retry")
|
|
8440
8369
|
}
|
|
8441
8370
|
)
|
|
8442
|
-
] }) : /* @__PURE__ */
|
|
8443
|
-
/* @__PURE__ */
|
|
8371
|
+
] }) : /* @__PURE__ */ jsxs20(Fragment8, { children: [
|
|
8372
|
+
/* @__PURE__ */ jsx21(
|
|
8444
8373
|
TextRibbon,
|
|
8445
8374
|
{
|
|
8446
8375
|
editor,
|
|
@@ -8455,11 +8384,11 @@ function Builder({
|
|
|
8455
8384
|
),
|
|
8456
8385
|
canvasBars.map((feature) => {
|
|
8457
8386
|
const Bar = feature.canvasBar;
|
|
8458
|
-
return /* @__PURE__ */
|
|
8387
|
+
return /* @__PURE__ */ jsx21(Bar, { context: featureContext }, feature.id);
|
|
8459
8388
|
}),
|
|
8460
|
-
/* @__PURE__ */
|
|
8461
|
-
/* @__PURE__ */
|
|
8462
|
-
boot.status === "ready" && /* @__PURE__ */
|
|
8389
|
+
/* @__PURE__ */ jsxs20("div", { className: "eb:relative eb:flex eb:min-h-0 eb:flex-1", children: [
|
|
8390
|
+
/* @__PURE__ */ jsxs20("div", { className: "eb:relative eb:min-h-0 eb:min-w-0 eb:flex-1", children: [
|
|
8391
|
+
boot.status === "ready" && /* @__PURE__ */ jsx21(
|
|
8463
8392
|
EmailCanvas,
|
|
8464
8393
|
{
|
|
8465
8394
|
editor,
|
|
@@ -8469,16 +8398,16 @@ function Builder({
|
|
|
8469
8398
|
},
|
|
8470
8399
|
attempt
|
|
8471
8400
|
),
|
|
8472
|
-
/* @__PURE__ */
|
|
8401
|
+
/* @__PURE__ */ jsx21(CanvasAddMenu, { editor, onAdded: compact ? () => setDrawer("properties") : void 0 })
|
|
8473
8402
|
] }),
|
|
8474
|
-
/* @__PURE__ */
|
|
8403
|
+
/* @__PURE__ */ jsx21(CanvasPanel, { feature: openPanel, context: featureContext, compact, onClose: () => setCanvasPanel(null) })
|
|
8475
8404
|
] }),
|
|
8476
|
-
!ready && /* @__PURE__ */
|
|
8477
|
-
/* @__PURE__ */
|
|
8478
|
-
/* @__PURE__ */
|
|
8405
|
+
!ready && /* @__PURE__ */ jsxs20("div", { className: "eb:absolute eb:inset-0 eb:flex eb:items-center eb:justify-center eb:bg-surface-75", role: "status", "aria-live": "polite", children: [
|
|
8406
|
+
/* @__PURE__ */ jsx21(Loader26, { className: "eb:size-6 eb:animate-spin eb:text-foreground-muted", "aria-hidden": "true" }),
|
|
8407
|
+
/* @__PURE__ */ jsx21("span", { className: "eb:sr-only", children: t("Loading the builder") })
|
|
8479
8408
|
] })
|
|
8480
8409
|
] }) }),
|
|
8481
|
-
!compact && /* @__PURE__ */
|
|
8410
|
+
!compact && /* @__PURE__ */ jsx21(
|
|
8482
8411
|
SidePanel,
|
|
8483
8412
|
{
|
|
8484
8413
|
name: "properties",
|
|
@@ -8491,8 +8420,8 @@ function Builder({
|
|
|
8491
8420
|
children: properties
|
|
8492
8421
|
}
|
|
8493
8422
|
),
|
|
8494
|
-
blocksInDrawer && /* @__PURE__ */
|
|
8495
|
-
compact && /* @__PURE__ */
|
|
8423
|
+
blocksInDrawer && /* @__PURE__ */ jsx21(Drawer, { open: drawer === "blocks", side: "left", title: t("Add a block"), onClose: closeDrawer, testId: "eb-blocks-drawer", children: /* @__PURE__ */ jsx21(BlockSidebar, { editor, disabled: !ready, onAdded: () => setDrawer("properties") }) }),
|
|
8424
|
+
compact && /* @__PURE__ */ jsx21(
|
|
8496
8425
|
Drawer,
|
|
8497
8426
|
{
|
|
8498
8427
|
open: drawer === "properties",
|
|
@@ -8507,12 +8436,12 @@ function Builder({
|
|
|
8507
8436
|
]
|
|
8508
8437
|
}
|
|
8509
8438
|
),
|
|
8510
|
-
compact && /* @__PURE__ */
|
|
8511
|
-
blocksInDrawer && /* @__PURE__ */
|
|
8512
|
-
/* @__PURE__ */
|
|
8439
|
+
compact && /* @__PURE__ */ jsxs20("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2 eb:border-t eb:border-border eb:px-2 eb:py-2", "data-testid": "eb-compact-bar", children: [
|
|
8440
|
+
blocksInDrawer && /* @__PURE__ */ jsxs20(Button, { variant: "outline", size: "sm-compact", disabled: !ready, onClick: () => setDrawer("blocks"), children: [
|
|
8441
|
+
/* @__PURE__ */ jsx21(Plus3, {}),
|
|
8513
8442
|
t("Add a block")
|
|
8514
8443
|
] }),
|
|
8515
|
-
/* @__PURE__ */
|
|
8444
|
+
/* @__PURE__ */ jsxs20(
|
|
8516
8445
|
Button,
|
|
8517
8446
|
{
|
|
8518
8447
|
variant: state.selection ? "default" : "outline",
|
|
@@ -8521,14 +8450,14 @@ function Builder({
|
|
|
8521
8450
|
disabled: !ready,
|
|
8522
8451
|
onClick: () => setDrawer("properties"),
|
|
8523
8452
|
children: [
|
|
8524
|
-
/* @__PURE__ */
|
|
8525
|
-
/* @__PURE__ */
|
|
8453
|
+
/* @__PURE__ */ jsx21(SlidersHorizontal, {}),
|
|
8454
|
+
/* @__PURE__ */ jsx21("span", { className: "eb:truncate", children: ready && state.selection ? t("Edit: {element}", { element: t(state.selection.label) }) : t("Email settings") })
|
|
8526
8455
|
]
|
|
8527
8456
|
}
|
|
8528
8457
|
)
|
|
8529
8458
|
] }),
|
|
8530
|
-
/* @__PURE__ */
|
|
8531
|
-
ai?.key && ai.components.Connect && /* @__PURE__ */
|
|
8459
|
+
/* @__PURE__ */ jsx21(NoticeArea, {}),
|
|
8460
|
+
ai?.key && ai.components.Connect && /* @__PURE__ */ jsx21(ai.components.Connect, { aiKey: ai.key })
|
|
8532
8461
|
]
|
|
8533
8462
|
}
|
|
8534
8463
|
);
|
|
@@ -8539,7 +8468,7 @@ function EmailBuilder({ locale = "en", messages, onNotify, ai: aiProp = null, ..
|
|
|
8539
8468
|
() => ai ? { ...messagesOf(ai.messages, locale), ...messages } : messages,
|
|
8540
8469
|
[ai, locale, messages]
|
|
8541
8470
|
);
|
|
8542
|
-
return /* @__PURE__ */
|
|
8471
|
+
return /* @__PURE__ */ jsx21(UiProvider, { locale, messages: allMessages, onNotify, children: /* @__PURE__ */ jsx21(Builder, { ...props, ai, templateId: props.templateId ?? null }) });
|
|
8543
8472
|
}
|
|
8544
8473
|
function useAiModule(value) {
|
|
8545
8474
|
const valid = Boolean(value && typeof value === "object" && /** @type {any} */
|
|
@@ -8558,7 +8487,7 @@ function useAiModule(value) {
|
|
|
8558
8487
|
// src/ui/EmailBuilderBoundary.jsx
|
|
8559
8488
|
import { Component } from "react";
|
|
8560
8489
|
import { AlertTriangle as AlertTriangle2, ArrowLeft as ArrowLeft2, RefreshCw } from "lucide-react";
|
|
8561
|
-
import { jsx as
|
|
8490
|
+
import { jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
8562
8491
|
var isChunkError = (error) => error?.name === "ChunkLoadError" || /Loading (CSS )?chunk .* failed/i.test(String(error?.message || ""));
|
|
8563
8492
|
var english = (text) => text;
|
|
8564
8493
|
var EmailBuilderBoundary = class extends Component {
|
|
@@ -8583,23 +8512,23 @@ var EmailBuilderBoundary = class extends Component {
|
|
|
8583
8512
|
const { error, attempt } = this.state;
|
|
8584
8513
|
const t = this.props.t || english;
|
|
8585
8514
|
if (!error) {
|
|
8586
|
-
return /* @__PURE__ */
|
|
8515
|
+
return /* @__PURE__ */ jsx22("div", { style: { height: "100%" }, children: this.props.children }, attempt);
|
|
8587
8516
|
}
|
|
8588
|
-
return /* @__PURE__ */
|
|
8517
|
+
return /* @__PURE__ */ jsxs21(
|
|
8589
8518
|
"div",
|
|
8590
8519
|
{
|
|
8591
8520
|
role: "alert",
|
|
8592
8521
|
className: "eb-root eb:flex eb:h-full eb:flex-col eb:items-center eb:justify-center eb:gap-3 eb:p-6 eb:text-center",
|
|
8593
8522
|
children: [
|
|
8594
|
-
/* @__PURE__ */
|
|
8595
|
-
/* @__PURE__ */
|
|
8596
|
-
/* @__PURE__ */
|
|
8597
|
-
this.props.onClose && /* @__PURE__ */
|
|
8598
|
-
/* @__PURE__ */
|
|
8523
|
+
/* @__PURE__ */ jsx22(AlertTriangle2, { className: "eb:size-6 eb:text-destructive", "aria-hidden": "true" }),
|
|
8524
|
+
/* @__PURE__ */ jsx22("p", { className: "eb:text-[13px] eb:text-foreground", children: t("The builder could not load.") }),
|
|
8525
|
+
/* @__PURE__ */ jsxs21("div", { className: "eb:flex eb:gap-2", children: [
|
|
8526
|
+
this.props.onClose && /* @__PURE__ */ jsxs21(Button, { variant: "outline", size: "sm", onClick: this.props.onClose, children: [
|
|
8527
|
+
/* @__PURE__ */ jsx22(ArrowLeft2, {}),
|
|
8599
8528
|
t("Back")
|
|
8600
8529
|
] }),
|
|
8601
|
-
/* @__PURE__ */
|
|
8602
|
-
/* @__PURE__ */
|
|
8530
|
+
/* @__PURE__ */ jsxs21(Button, { size: "sm", onClick: this.retry, children: [
|
|
8531
|
+
/* @__PURE__ */ jsx22(RefreshCw, {}),
|
|
8603
8532
|
t("Retry")
|
|
8604
8533
|
] })
|
|
8605
8534
|
] })
|
|
@@ -8627,4 +8556,4 @@ export {
|
|
|
8627
8556
|
EmailBuilder,
|
|
8628
8557
|
EmailBuilderBoundary
|
|
8629
8558
|
};
|
|
8630
|
-
//# sourceMappingURL=chunk-
|
|
8559
|
+
//# sourceMappingURL=chunk-7KOL5ON4.js.map
|