best-email-builder 0.18.0 → 0.19.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 +28 -0
- package/dist/ai-server.js +3 -3
- package/dist/ai.js +11 -11
- package/dist/ai.js.map +1 -1
- package/dist/builder.js +8 -8
- package/dist/{chunk-LKD6QZMD.js → chunk-4662C22G.js} +3 -3
- package/dist/{chunk-2M44NIFG.js → chunk-BMCXSP4Q.js} +2 -2
- package/dist/{chunk-L7NSAYYX.js → chunk-CYTZO2MW.js} +9 -5
- package/dist/chunk-CYTZO2MW.js.map +1 -0
- package/dist/{chunk-37PEEEBB.js → chunk-GUF6MIXZ.js} +2 -2
- package/dist/{chunk-BER25JS7.js → chunk-HWNNYG45.js} +20 -3
- package/dist/{chunk-BER25JS7.js.map → chunk-HWNNYG45.js.map} +1 -1
- package/dist/{chunk-D46HKFV5.js → chunk-K43QP3TX.js} +14 -13
- package/dist/chunk-K43QP3TX.js.map +1 -0
- package/dist/{chunk-POUAC5TN.js → chunk-LJXCMXYI.js} +2 -2
- package/dist/{chunk-2B3N6CH4.js → chunk-MW3ZGK34.js} +13 -1
- package/dist/chunk-MW3ZGK34.js.map +1 -0
- package/dist/{chunk-F3566ZQB.js → chunk-NSNODUL6.js} +3 -3
- package/dist/{chunk-JLQDVA4B.js → chunk-UR3UTVC5.js} +4 -4
- package/dist/{chunk-W4UKDEB4.js → chunk-WYYATB37.js} +511 -372
- package/dist/chunk-WYYATB37.js.map +1 -0
- package/dist/index.js +10 -10
- package/dist/library.js +5 -5
- package/dist/server.js +5 -5
- package/dist/styles.css +1 -1
- package/dist/types/blocks/shared.d.ts +1 -1
- package/dist/types/core/EmailEditor.d.ts +8 -4
- package/dist/types/core/constants.d.ts +1 -1
- package/dist/types/engine/NativeAdapter.d.ts +1 -1
- package/dist/types/engine/canvasMjml.d.ts +7 -0
- package/dist/types/features/variables/VariableInsertButton.d.ts +7 -3
- package/dist/types/ui/TextRibbon.d.ts +26 -1
- package/dist/types/ui/fields.d.ts +13 -0
- package/dist/types/ui/primitives/color-picker.d.ts +4 -2
- package/dist/types/ui/primitives/fields.d.ts +4 -3
- package/dist/types/ui/primitives/overlays.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunk-2B3N6CH4.js.map +0 -1
- package/dist/chunk-D46HKFV5.js.map +0 -1
- package/dist/chunk-L7NSAYYX.js.map +0 -1
- package/dist/chunk-W4UKDEB4.js.map +0 -1
- /package/dist/{chunk-LKD6QZMD.js.map → chunk-4662C22G.js.map} +0 -0
- /package/dist/{chunk-2M44NIFG.js.map → chunk-BMCXSP4Q.js.map} +0 -0
- /package/dist/{chunk-37PEEEBB.js.map → chunk-GUF6MIXZ.js.map} +0 -0
- /package/dist/{chunk-POUAC5TN.js.map → chunk-LJXCMXYI.js.map} +0 -0
- /package/dist/{chunk-F3566ZQB.js.map → chunk-NSNODUL6.js.map} +0 -0
- /package/dist/{chunk-JLQDVA4B.js.map → chunk-UR3UTVC5.js.map} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useLayoutWidth,
|
|
7
7
|
useSearchShortcut,
|
|
8
8
|
withThumbnailImages
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NSNODUL6.js";
|
|
10
10
|
import {
|
|
11
11
|
BORDER_STYLES,
|
|
12
12
|
BRAND_NOTES,
|
|
@@ -22,12 +22,12 @@ import {
|
|
|
22
22
|
parseSpacing,
|
|
23
23
|
toAttributes,
|
|
24
24
|
toValues
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-HWNNYG45.js";
|
|
26
26
|
import {
|
|
27
27
|
cleanRichText,
|
|
28
28
|
escapeText,
|
|
29
29
|
textOfHtml
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GUF6MIXZ.js";
|
|
31
31
|
import {
|
|
32
32
|
Button,
|
|
33
33
|
Dialog,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
createHttpStorage,
|
|
69
69
|
useT,
|
|
70
70
|
useUi
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-K43QP3TX.js";
|
|
72
72
|
import {
|
|
73
73
|
BRAND_FONT_SIZES,
|
|
74
74
|
DEFAULT_BUTTON_URL,
|
|
@@ -113,11 +113,11 @@ import {
|
|
|
113
113
|
setAttributes,
|
|
114
114
|
setContent,
|
|
115
115
|
toProject
|
|
116
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-CYTZO2MW.js";
|
|
117
117
|
import {
|
|
118
118
|
IMAGE_ATTRIBUTES,
|
|
119
119
|
isSafeUrl
|
|
120
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-LJXCMXYI.js";
|
|
121
121
|
import {
|
|
122
122
|
CUSTOM_GROUP,
|
|
123
123
|
DEFAULT_VARIABLES,
|
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
translatorFor,
|
|
134
134
|
validateCustomVariable,
|
|
135
135
|
validateVariableEdit
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-MW3ZGK34.js";
|
|
137
137
|
|
|
138
138
|
// src/core/events.js
|
|
139
139
|
function createEmitter({ onError } = {}) {
|
|
@@ -345,7 +345,7 @@ function createEmailEditor({ adapter, blocks, features = null, t = identity }) {
|
|
|
345
345
|
getRootId: () => status === "ready" ? adapter.getRootId() : null,
|
|
346
346
|
updateProperties(values, id = null) {
|
|
347
347
|
requireReady("updateProperties");
|
|
348
|
-
adapter.updateProperties(targetOf(id, "updateProperties"), toAttributes(values));
|
|
348
|
+
adapter.updateProperties(Array.isArray(id) ? id : targetOf(id, "updateProperties"), toAttributes(values));
|
|
349
349
|
},
|
|
350
350
|
/** `reveal`: its words come in one after the other on the canvas (a text the AI wrote). */
|
|
351
351
|
setContent(content, id = null, options = {}) {
|
|
@@ -606,7 +606,7 @@ var sectionBlock = {
|
|
|
606
606
|
prop.padding("margin", "Margin", "margin"),
|
|
607
607
|
prop.border(),
|
|
608
608
|
prop.padding("padding", "Padding", "padding"),
|
|
609
|
-
prop.radius()
|
|
609
|
+
prop.radius(["px"])
|
|
610
610
|
]
|
|
611
611
|
};
|
|
612
612
|
var columnBlock = {
|
|
@@ -710,6 +710,8 @@ var imageBlock = {
|
|
|
710
710
|
},
|
|
711
711
|
prop.href("Link on click"),
|
|
712
712
|
{ key: "width", label: "Width", type: "size", group: GROUPS.layout, min: 20, max: 600, unit: "px" },
|
|
713
|
+
// Set by itself beside other images (the first one's): cropped to it.
|
|
714
|
+
{ key: "height", label: "Height", type: "size", group: GROUPS.layout, min: 20, max: 1200, unit: "px" },
|
|
713
715
|
{
|
|
714
716
|
// A photo given a width keeps it on a phone unless told otherwise.
|
|
715
717
|
key: "fluid-on-mobile",
|
|
@@ -757,7 +759,7 @@ var buttonBlock = {
|
|
|
757
759
|
{ value: "normal", label: "Normal" }
|
|
758
760
|
]
|
|
759
761
|
},
|
|
760
|
-
prop.radius(),
|
|
762
|
+
prop.radius(["px"]),
|
|
761
763
|
{
|
|
762
764
|
key: "width",
|
|
763
765
|
label: "Width",
|
|
@@ -2729,7 +2731,7 @@ function colorToHex(value) {
|
|
|
2729
2731
|
const byte = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
|
|
2730
2732
|
return `#${byte(Number(m[1]))}${byte(Number(m[2]))}${byte(Number(m[3]))}${alpha < 1 ? byte(alpha * 255) : ""}`.toUpperCase();
|
|
2731
2733
|
}
|
|
2732
|
-
function ColorPicker({ value, onChange, id, className, placeholder = "", alpha = true, dense = false }) {
|
|
2734
|
+
function ColorPicker({ value, onChange, id, className, placeholder = "", alpha = true, dense = false, trigger = null }) {
|
|
2733
2735
|
const t = useT();
|
|
2734
2736
|
const [open, setOpen] = useState7(false);
|
|
2735
2737
|
const hex = colorToHex(value);
|
|
@@ -2738,15 +2740,15 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2738
2740
|
const Picker = alpha ? HexAlphaColorPicker : HexColorPicker;
|
|
2739
2741
|
return /* @__PURE__ */ jsxs7("div", { className: cn("eb:flex eb:gap-2", className), children: [
|
|
2740
2742
|
/* @__PURE__ */ jsxs7(Popover, { open, onOpenChange: setOpen, children: [
|
|
2741
|
-
/* @__PURE__ */ jsx7(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx7(
|
|
2743
|
+
/* @__PURE__ */ jsx7(PopoverTrigger, { asChild: true, children: trigger || /* @__PURE__ */ jsx7(
|
|
2742
2744
|
"button",
|
|
2743
2745
|
{
|
|
2744
2746
|
type: "button",
|
|
2745
2747
|
"aria-label": t("Pick a colour"),
|
|
2746
2748
|
title: t("Pick a colour"),
|
|
2747
2749
|
className: cn(
|
|
2748
|
-
"eb-checker eb:relative eb:h-
|
|
2749
|
-
dense && "eb:
|
|
2750
|
+
"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]",
|
|
2751
|
+
dense && "eb:w-9"
|
|
2750
2752
|
),
|
|
2751
2753
|
children: /* @__PURE__ */ jsx7(
|
|
2752
2754
|
"span",
|
|
@@ -2777,7 +2779,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2777
2779
|
placeholder: "#RRGGBB",
|
|
2778
2780
|
maxLength: 9,
|
|
2779
2781
|
"aria-label": t("Hex code"),
|
|
2780
|
-
className: "eb:
|
|
2782
|
+
className: "eb:flex-1 eb:font-mono eb:uppercase"
|
|
2781
2783
|
}
|
|
2782
2784
|
)
|
|
2783
2785
|
] }),
|
|
@@ -2796,7 +2798,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2796
2798
|
)) })
|
|
2797
2799
|
] })
|
|
2798
2800
|
] }),
|
|
2799
|
-
/* @__PURE__ */ jsx7(
|
|
2801
|
+
!trigger && /* @__PURE__ */ jsx7(
|
|
2800
2802
|
Input,
|
|
2801
2803
|
{
|
|
2802
2804
|
id,
|
|
@@ -2805,7 +2807,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
|
|
|
2805
2807
|
maxLength: 9,
|
|
2806
2808
|
placeholder: colorToHex(placeholder) || "#RRGGBB",
|
|
2807
2809
|
dense,
|
|
2808
|
-
className:
|
|
2810
|
+
className: "eb:flex-1 eb:font-mono"
|
|
2809
2811
|
}
|
|
2810
2812
|
)
|
|
2811
2813
|
] });
|
|
@@ -3016,7 +3018,7 @@ function BrandButton({ context }) {
|
|
|
3016
3018
|
}
|
|
3017
3019
|
)
|
|
3018
3020
|
] }),
|
|
3019
|
-
/* @__PURE__ */ jsxs8(Button, { type: "submit", size: "sm", className: "eb:h-
|
|
3021
|
+
/* @__PURE__ */ jsxs8(Button, { type: "submit", size: "sm", className: "eb:h-7", disabled: reading || !form.website.trim(), children: [
|
|
3020
3022
|
reading ? /* @__PURE__ */ jsx8(Loader25, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx8(WandSparkles, {}),
|
|
3021
3023
|
t("Get my brand")
|
|
3022
3024
|
] })
|
|
@@ -4947,6 +4949,7 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
|
|
|
4947
4949
|
} : {} },
|
|
4948
4950
|
content: LABEL_TAGS.has(node.tag) ? textOfHtml(node.content || "") : null,
|
|
4949
4951
|
html: node.tag === "mj-text" ? node.content || "" : null,
|
|
4952
|
+
children: node.children.map((child) => child.id),
|
|
4950
4953
|
canRemove: !locked,
|
|
4951
4954
|
canDuplicate: !locked,
|
|
4952
4955
|
canMoveUp: !locked && index > 0,
|
|
@@ -5060,6 +5063,38 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
|
|
|
5060
5063
|
emitSelection();
|
|
5061
5064
|
if (render) void view?.render();
|
|
5062
5065
|
}
|
|
5066
|
+
function rowImages(current, id) {
|
|
5067
|
+
for (let node = parentOf(current, id); node; node = parentOf(current, node.id)) {
|
|
5068
|
+
const columns = node.children.filter((child) => child.tag === "mj-column");
|
|
5069
|
+
if (columns.length > 1) {
|
|
5070
|
+
return (
|
|
5071
|
+
/** @type {EmailNode[]} */
|
|
5072
|
+
columns.map((column2) => findFirst(column2, "mj-image")).filter((image) => image?.attributes.src)
|
|
5073
|
+
);
|
|
5074
|
+
}
|
|
5075
|
+
}
|
|
5076
|
+
return [];
|
|
5077
|
+
}
|
|
5078
|
+
async function fitRowImages(id, merge) {
|
|
5079
|
+
const [first, ...others] = rowImages(requireRoot(), id);
|
|
5080
|
+
if (!first || !others.length || !view) return;
|
|
5081
|
+
await view.render();
|
|
5082
|
+
const img = (
|
|
5083
|
+
/** @type {HTMLImageElement|null} */
|
|
5084
|
+
view?.document.querySelector(`.${ID_CLASS_PREFIX}${first.id} img`) || null
|
|
5085
|
+
);
|
|
5086
|
+
if (!img) return;
|
|
5087
|
+
if (!img.complete) await new Promise((done) => {
|
|
5088
|
+
img.addEventListener("load", done, { once: true });
|
|
5089
|
+
img.addEventListener("error", done, { once: true });
|
|
5090
|
+
});
|
|
5091
|
+
const width = root ? imageWidths(root).get(first.id) : 0;
|
|
5092
|
+
if (!img.naturalWidth || !width) return;
|
|
5093
|
+
const height = `${Math.round(width * img.naturalHeight / img.naturalWidth)}px`;
|
|
5094
|
+
let next = requireRoot();
|
|
5095
|
+
for (const image of rowImages(next, id)) if (image.attributes.height !== height) next = setAttributes(next, image.id, { height });
|
|
5096
|
+
commit(next, { merge });
|
|
5097
|
+
}
|
|
5063
5098
|
function replace(next) {
|
|
5064
5099
|
view?.finishEditing();
|
|
5065
5100
|
clearAll();
|
|
@@ -5421,19 +5456,27 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
|
|
|
5421
5456
|
getSelection: () => currentSelection(),
|
|
5422
5457
|
describe: (id) => describe(id),
|
|
5423
5458
|
getRootId: () => root ? findFirst(root, "mj-body")?.id || null : null,
|
|
5459
|
+
/** Several ids (the ribbon on a menu's links): one step of the history. */
|
|
5424
5460
|
updateProperties(id, attributes) {
|
|
5461
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
5425
5462
|
const current = requireRoot();
|
|
5426
|
-
const node = findNode(current, id);
|
|
5427
|
-
if (!node) return;
|
|
5428
|
-
if (view?.editingId() === id) view.finishEditing();
|
|
5429
5463
|
const keys = Object.keys(attributes).sort().join(",");
|
|
5430
5464
|
const { "vertical-align": alignment, ...own } = attributes;
|
|
5431
|
-
let next =
|
|
5432
|
-
|
|
5433
|
-
|
|
5465
|
+
let next = current;
|
|
5466
|
+
for (const one of ids) {
|
|
5467
|
+
const node = findNode(current, one);
|
|
5468
|
+
if (!node) continue;
|
|
5469
|
+
if (view?.editingId() === one) view.finishEditing();
|
|
5470
|
+
next = setAttributes(next, one, own);
|
|
5471
|
+
if ("vertical-align" in attributes) {
|
|
5472
|
+
for (const target of alignmentTargets(current, node)) next = setAttributes(next, target.id, { "vertical-align": alignment });
|
|
5473
|
+
}
|
|
5474
|
+
if (node.tag === "mj-column" && "width" in attributes) next = balanceColumns(next, one, attributes.width);
|
|
5434
5475
|
}
|
|
5435
|
-
|
|
5436
|
-
commit(next, { merge
|
|
5476
|
+
const merge = `attributes:${ids.join("+")}:${keys}`;
|
|
5477
|
+
commit(next, { merge });
|
|
5478
|
+
const image = ids.find((one) => attributes.src && findNode(current, one)?.tag === "mj-image");
|
|
5479
|
+
if (image) void fitRowImages(image, merge);
|
|
5437
5480
|
},
|
|
5438
5481
|
setContent(id, content, { reveal = false } = {}) {
|
|
5439
5482
|
const current = requireRoot();
|
|
@@ -5594,7 +5637,7 @@ function EmailCanvas({ editor, document: document2 = null, onReady, onError, cla
|
|
|
5594
5637
|
}
|
|
5595
5638
|
|
|
5596
5639
|
// src/ui/EmailBuilder.jsx
|
|
5597
|
-
import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as
|
|
5640
|
+
import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as useRef14, useState as useState19 } from "react";
|
|
5598
5641
|
import { AlertTriangle, Loader2 as Loader27, Plus as Plus3, Save, SlidersHorizontal } from "lucide-react";
|
|
5599
5642
|
|
|
5600
5643
|
// src/features/brand/useBrand.js
|
|
@@ -5957,7 +6000,7 @@ function ItemChoices({ label, choices, onPick }) {
|
|
|
5957
6000
|
}
|
|
5958
6001
|
|
|
5959
6002
|
// src/ui/PropertiesPanel.jsx
|
|
5960
|
-
import { useMemo as useMemo5, useRef as
|
|
6003
|
+
import { useMemo as useMemo5, useRef as useRef10 } from "react";
|
|
5961
6004
|
import { Trash2 as Trash24, X as X2 } from "lucide-react";
|
|
5962
6005
|
|
|
5963
6006
|
// src/ui/fields.jsx
|
|
@@ -6081,7 +6124,7 @@ function ImageField({ id, property, value, onCommit, services }) {
|
|
|
6081
6124
|
type: "button",
|
|
6082
6125
|
variant: "outline",
|
|
6083
6126
|
size: "xs",
|
|
6084
|
-
className: "eb:h-
|
|
6127
|
+
className: "eb:h-7",
|
|
6085
6128
|
disabled: busy,
|
|
6086
6129
|
onClick: () => inputRef.current?.click(),
|
|
6087
6130
|
children: [
|
|
@@ -6154,7 +6197,7 @@ function SizeField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6154
6197
|
] })
|
|
6155
6198
|
] });
|
|
6156
6199
|
}
|
|
6157
|
-
function ColorField({ id, property, value, fallback = "", onCommit }) {
|
|
6200
|
+
function ColorField({ id, property, value, fallback = "", onCommit, trigger = null }) {
|
|
6158
6201
|
const t = useT();
|
|
6159
6202
|
const [draft, setDraft, ref] = useDraft(value, colorToHex);
|
|
6160
6203
|
const timer = useRef7(null);
|
|
@@ -6178,9 +6221,9 @@ function ColorField({ id, property, value, fallback = "", onCommit }) {
|
|
|
6178
6221
|
if (wait <= 0) commit(next);
|
|
6179
6222
|
else timer.current = setTimeout(() => commit(next), wait);
|
|
6180
6223
|
};
|
|
6181
|
-
return /* @__PURE__ */ jsxs11("div", { ref, className: "eb:space-y-1", children: [
|
|
6182
|
-
/* @__PURE__ */ jsx12(FieldLabel, { id, children: t(property.label) }),
|
|
6183
|
-
/* @__PURE__ */ jsx12(ColorPicker, { id, value: draft, placeholder: emailColor(fallback) || "", onChange: change, dense: true })
|
|
6224
|
+
return /* @__PURE__ */ jsxs11("div", { ref, className: trigger ? "eb:contents" : "eb:space-y-1", children: [
|
|
6225
|
+
!trigger && /* @__PURE__ */ jsx12(FieldLabel, { id, children: t(property.label) }),
|
|
6226
|
+
/* @__PURE__ */ jsx12(ColorPicker, { id, value: draft, placeholder: emailColor(fallback) || "", onChange: change, dense: true, trigger })
|
|
6184
6227
|
] });
|
|
6185
6228
|
}
|
|
6186
6229
|
var DEFAULT_OPTION = "__default__";
|
|
@@ -6650,7 +6693,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6650
6693
|
placeholder: t("Search variables\u2026"),
|
|
6651
6694
|
"aria-label": t("Search variables\u2026"),
|
|
6652
6695
|
"aria-keyshortcuts": SEARCH_KEYS,
|
|
6653
|
-
className: "eb:h-
|
|
6696
|
+
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"
|
|
6654
6697
|
}
|
|
6655
6698
|
),
|
|
6656
6699
|
/* @__PURE__ */ jsx14(SearchKeyHint, { className: "eb:absolute eb:top-1/2 eb:right-4 eb:-translate-y-1/2" })
|
|
@@ -6736,7 +6779,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
|
|
|
6736
6779
|
|
|
6737
6780
|
// src/features/variables/VariableInsertButton.jsx
|
|
6738
6781
|
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6739
|
-
function VariableInsertButton({ variables, inputRef, value, onChange, label }) {
|
|
6782
|
+
function VariableInsertButton({ variables, inputRef, value, onChange, label, links = false }) {
|
|
6740
6783
|
const [open, setOpen] = useState14(false);
|
|
6741
6784
|
const insert = (variable) => {
|
|
6742
6785
|
const input = inputRef.current;
|
|
@@ -6755,12 +6798,348 @@ function VariableInsertButton({ variables, inputRef, value, onChange, label }) {
|
|
|
6755
6798
|
};
|
|
6756
6799
|
return /* @__PURE__ */ jsxs14(Popover, { open, onOpenChange: setOpen, children: [
|
|
6757
6800
|
/* @__PURE__ */ jsx15(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx15(Button, { variant: "ghost", size: "icon-xs", "aria-label": label, title: label, children: /* @__PURE__ */ jsx15(Braces3, {}) }) }),
|
|
6758
|
-
/* @__PURE__ */ jsx15(PopoverContent, { align: "end", className: "eb:w-72 eb:p-0", onCloseAutoFocus: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx15(VariablePicker, { variables, onPick: insert, filter: (v) => v.kind !== "link" }) })
|
|
6801
|
+
/* @__PURE__ */ jsx15(PopoverContent, { align: "end", className: "eb:w-72 eb:p-0", onCloseAutoFocus: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx15(VariablePicker, { variables, onPick: insert, filter: links ? void 0 : (v) => v.kind !== "link" }) })
|
|
6759
6802
|
] });
|
|
6760
6803
|
}
|
|
6761
6804
|
|
|
6805
|
+
// src/ui/TextRibbon.jsx
|
|
6806
|
+
import { useEffect as useEffect11, useRef as useRef9, useState as useState15 } from "react";
|
|
6807
|
+
import {
|
|
6808
|
+
AlignCenter as AlignCenter2,
|
|
6809
|
+
AlignJustify as AlignJustify2,
|
|
6810
|
+
AlignLeft as AlignLeft2,
|
|
6811
|
+
AlignRight as AlignRight2,
|
|
6812
|
+
Baseline,
|
|
6813
|
+
Bold,
|
|
6814
|
+
CaseSensitive,
|
|
6815
|
+
Check as Check2,
|
|
6816
|
+
ChevronDown,
|
|
6817
|
+
Italic,
|
|
6818
|
+
Link,
|
|
6819
|
+
RemoveFormatting,
|
|
6820
|
+
Strikethrough,
|
|
6821
|
+
Underline,
|
|
6822
|
+
Unlink
|
|
6823
|
+
} from "lucide-react";
|
|
6824
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
6825
|
+
var RIBBON_KEYS = /* @__PURE__ */ new Set(["font-family", "font-size", "line-height", "font-weight", "color", "text-transform", "align"]);
|
|
6826
|
+
var FORMATS = [
|
|
6827
|
+
{ command: "bold", icon: Bold, label: "Bold (Ctrl+B)" },
|
|
6828
|
+
{ command: "italic", icon: Italic, label: "Italic (Ctrl+I)" },
|
|
6829
|
+
{ command: "underline", icon: Underline, label: "Underline (Ctrl+U)" },
|
|
6830
|
+
{ command: "strike", icon: Strikethrough, label: "Strikethrough" }
|
|
6831
|
+
];
|
|
6832
|
+
var SIZES = [10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48];
|
|
6833
|
+
var LINE_HEIGHTS = [1, 1.15, 1.3, 1.5, 2, 2.5];
|
|
6834
|
+
var ALIGNMENTS = [
|
|
6835
|
+
{ value: "left", icon: AlignLeft2, label: "Align left" },
|
|
6836
|
+
{ value: "center", icon: AlignCenter2, label: "Align center" },
|
|
6837
|
+
{ value: "right", icon: AlignRight2, label: "Align right" },
|
|
6838
|
+
{ value: "justify", icon: AlignJustify2, label: "Justify" }
|
|
6839
|
+
];
|
|
6840
|
+
function LineSpacingIcon(props) {
|
|
6841
|
+
return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: /* @__PURE__ */ jsx16("path", { d: "M5 4v16M2 7l3-3 3 3M2 17l3 3 3-3M12 6h9M12 12h9M12 18h9" }) });
|
|
6842
|
+
}
|
|
6843
|
+
function pixels(value, fontSize) {
|
|
6844
|
+
const text = String(value || "").trim();
|
|
6845
|
+
const n = Number.parseFloat(text);
|
|
6846
|
+
if (!Number.isFinite(n)) return null;
|
|
6847
|
+
if (text.endsWith("%")) return fontSize ? n / 100 * fontSize : null;
|
|
6848
|
+
if (/^[\d.]+$/.test(text)) return fontSize ? n * fontSize : null;
|
|
6849
|
+
return n;
|
|
6850
|
+
}
|
|
6851
|
+
var fontKey = (value) => String(value || "").toLowerCase().replace(/["'\s]/g, "");
|
|
6852
|
+
var STYLES = {
|
|
6853
|
+
italic: ["font-style", "italic", "normal"],
|
|
6854
|
+
underline: ["text-decoration", "underline", "none"],
|
|
6855
|
+
strike: ["text-decoration", "line-through", "none"]
|
|
6856
|
+
};
|
|
6857
|
+
var STYLED_TAGS = /* @__PURE__ */ new Set(["mj-text", "mj-button", "mj-navbar-link"]);
|
|
6858
|
+
var heavy = (weight) => weight === "bold" || Number(weight) >= 600;
|
|
6859
|
+
var clamp = (n, property) => Math.min(property.max ?? n, Math.max(property.min ?? n, n));
|
|
6860
|
+
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";
|
|
6861
|
+
function Tip({ label, children }) {
|
|
6862
|
+
return /* @__PURE__ */ jsx16(TooltipWrap, { label, side: "bottom", delayDuration: 250, hoverable: false, children: /* @__PURE__ */ jsx16("span", { className: "eb:inline-flex", children }) });
|
|
6863
|
+
}
|
|
6864
|
+
var Separator2 = () => /* @__PURE__ */ jsx16("span", { className: "eb:mx-0.5 eb:h-4 eb:w-px eb:shrink-0 eb:bg-border", "aria-hidden": "true" });
|
|
6865
|
+
function TextRibbon({ editor, ready, selection, format, variables = [], drawers, openDrawer, onToggleDrawer }) {
|
|
6866
|
+
const { t, locale } = useUi();
|
|
6867
|
+
const element = ready && selection && !selection.multiple ? selection : null;
|
|
6868
|
+
const own = (target, key) => (target.blockId ? editor.getBlock(target.blockId) : null)?.properties?.find((property) => property.key === key) || null;
|
|
6869
|
+
const inside = [];
|
|
6870
|
+
const walk = (ids = []) => {
|
|
6871
|
+
for (const id of ids) {
|
|
6872
|
+
const child = editor.getElement(id);
|
|
6873
|
+
if (!child) continue;
|
|
6874
|
+
inside.push(child);
|
|
6875
|
+
walk(child.children);
|
|
6876
|
+
}
|
|
6877
|
+
};
|
|
6878
|
+
if (element) walk(element.children);
|
|
6879
|
+
const targetsOf = (key) => element && own(element, key) ? [element] : inside.filter((target) => own(target, key));
|
|
6880
|
+
const propertyOf = (key) => {
|
|
6881
|
+
const [first] = targetsOf(key);
|
|
6882
|
+
return first ? own(first, key) : null;
|
|
6883
|
+
};
|
|
6884
|
+
const valueOf = (key) => {
|
|
6885
|
+
const values = [...new Set(targetsOf(key).map((target) => target.values?.[key] || target.defaults?.[key] || ""))];
|
|
6886
|
+
return values.length === 1 ? values[0] : "";
|
|
6887
|
+
};
|
|
6888
|
+
const set = (key, value) => {
|
|
6889
|
+
const ids = targetsOf(key).map((target) => target.id);
|
|
6890
|
+
if (ids.length) editor.updateProperties({ [key]: value }, ids);
|
|
6891
|
+
};
|
|
6892
|
+
const words = ready && (format.editing || element?.tagName === "mj-text");
|
|
6893
|
+
const run = (command, value) => editor.formatText(command, value);
|
|
6894
|
+
const styledTargets = element && STYLED_TAGS.has(element.tagName) ? [element] : inside.filter((target) => STYLED_TAGS.has(target.tagName));
|
|
6895
|
+
const styled = !words && styledTargets.length > 0;
|
|
6896
|
+
const styleOn = (command) => styledTargets.length > 0 && styledTargets.every((target) => target.attributes?.[STYLES[command][0]] === STYLES[command][1]);
|
|
6897
|
+
const toggleStyle = (command) => {
|
|
6898
|
+
const [attribute, on, off] = STYLES[command];
|
|
6899
|
+
editor.updateProperties({ [attribute]: styleOn(command) ? off : on }, styledTargets.map((target) => target.id));
|
|
6900
|
+
};
|
|
6901
|
+
const weight = !format.editing ? propertyOf("font-weight") : null;
|
|
6902
|
+
const bold = weight ? heavy(valueOf("font-weight")) || format.bold : format.bold;
|
|
6903
|
+
const toggleBold = () => {
|
|
6904
|
+
if (weight && (heavy(valueOf("font-weight")) || !words && !format.bold)) set("font-weight", heavy(valueOf("font-weight")) ? "normal" : "bold");
|
|
6905
|
+
else run("bold");
|
|
6906
|
+
};
|
|
6907
|
+
const font = propertyOf("font-family");
|
|
6908
|
+
const fontValue = font?.options?.find((option) => fontKey(option.value) === fontKey(valueOf("font-family")))?.value;
|
|
6909
|
+
const color = propertyOf("color");
|
|
6910
|
+
const capitals = propertyOf("text-transform");
|
|
6911
|
+
const size = propertyOf("font-size");
|
|
6912
|
+
const lineHeight = propertyOf("line-height");
|
|
6913
|
+
const align = propertyOf("align");
|
|
6914
|
+
const currentSize = pixels(valueOf("font-size"), null);
|
|
6915
|
+
const currentLine = pixels(valueOf("line-height"), currentSize);
|
|
6916
|
+
const number = new Intl.NumberFormat(locale || void 0, { maximumFractionDigits: 2 });
|
|
6917
|
+
return /* @__PURE__ */ jsxs15(
|
|
6918
|
+
"div",
|
|
6919
|
+
{
|
|
6920
|
+
role: "toolbar",
|
|
6921
|
+
"aria-label": t("Text formatting"),
|
|
6922
|
+
"data-testid": "eb-ribbon",
|
|
6923
|
+
className: "eb:@container eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:border-b eb:border-border eb:bg-background",
|
|
6924
|
+
onMouseDown: (event) => event.target instanceof HTMLInputElement || event.preventDefault(),
|
|
6925
|
+
children: [
|
|
6926
|
+
/* @__PURE__ */ jsxs15("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: [
|
|
6927
|
+
/* @__PURE__ */ jsxs15(Select, { value: fontValue ?? "", onValueChange: (next) => set("font-family", next), disabled: !font, children: [
|
|
6928
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Font"), children: /* @__PURE__ */ jsx16(
|
|
6929
|
+
SelectTrigger,
|
|
6930
|
+
{
|
|
6931
|
+
"aria-label": t("Font"),
|
|
6932
|
+
"data-control": "font-family",
|
|
6933
|
+
className: "eb:w-28 eb:shrink-0 eb:gap-1 eb:px-2 eb:shadow-none eb:disabled:opacity-40",
|
|
6934
|
+
children: /* @__PURE__ */ jsx16(SelectValue, { placeholder: t("Font") })
|
|
6935
|
+
}
|
|
6936
|
+
) }),
|
|
6937
|
+
/* @__PURE__ */ jsx16(SelectContent, { position: "popper", align: "start", onCloseAutoFocus: (event) => event.preventDefault(), children: font?.options?.map((option) => /* @__PURE__ */ jsx16(SelectItem, { value: option.value, style: { fontFamily: option.value }, children: t(option.label) }, option.value)) })
|
|
6938
|
+
] }),
|
|
6939
|
+
/* @__PURE__ */ jsx16(Separator2, {}),
|
|
6940
|
+
FORMATS.map(({ command, icon: Icon, label }) => /* @__PURE__ */ jsx16(Tip, { label: t(label), children: /* @__PURE__ */ jsx16(
|
|
6941
|
+
"button",
|
|
6942
|
+
{
|
|
6943
|
+
type: "button",
|
|
6944
|
+
className: ICON_BUTTON,
|
|
6945
|
+
disabled: command === "bold" ? !words && !weight : !words && !styled,
|
|
6946
|
+
"aria-label": t(label),
|
|
6947
|
+
"aria-pressed": Boolean(command === "bold" ? bold : styled ? styleOn(command) : format[command]),
|
|
6948
|
+
"data-command": command,
|
|
6949
|
+
onClick: () => {
|
|
6950
|
+
if (command === "bold") toggleBold();
|
|
6951
|
+
else if (styled) toggleStyle(command);
|
|
6952
|
+
else run(command);
|
|
6953
|
+
},
|
|
6954
|
+
children: /* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" })
|
|
6955
|
+
}
|
|
6956
|
+
) }, command)),
|
|
6957
|
+
/* @__PURE__ */ jsx16(
|
|
6958
|
+
ColorField,
|
|
6959
|
+
{
|
|
6960
|
+
id: "eb-ribbon-color",
|
|
6961
|
+
property: color || { key: "color", label: "Text color", type: "color" },
|
|
6962
|
+
value: valueOf("color"),
|
|
6963
|
+
fallback: "",
|
|
6964
|
+
onCommit: (value) => set("color", value),
|
|
6965
|
+
trigger: /* @__PURE__ */ jsx16("button", { type: "button", className: ICON_BUTTON, disabled: !color, "aria-label": t("Text color"), title: t("Text color"), "data-control": "color", children: /* @__PURE__ */ jsxs15("span", { className: "eb:relative eb:inline-flex", children: [
|
|
6966
|
+
/* @__PURE__ */ jsx16(Baseline, { "aria-hidden": "true" }),
|
|
6967
|
+
/* @__PURE__ */ jsx16("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" })
|
|
6968
|
+
] }) })
|
|
6969
|
+
},
|
|
6970
|
+
element?.id ?? "none"
|
|
6971
|
+
),
|
|
6972
|
+
/* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
|
|
6973
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Capitals"), children: /* @__PURE__ */ jsx16(DropdownMenuTrigger, { asChild: true, disabled: !capitals, children: /* @__PURE__ */ jsxs15("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Capitals"), "data-control": "text-transform", children: [
|
|
6974
|
+
/* @__PURE__ */ jsx16(CaseSensitive, { "aria-hidden": "true" }),
|
|
6975
|
+
/* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
|
|
6976
|
+
] }) }) }),
|
|
6977
|
+
/* @__PURE__ */ jsx16(DropdownMenuContent, { align: "start", "aria-label": t("Capitals"), onCloseAutoFocus: (event) => event.preventDefault(), children: capitals?.options?.map((option) => /* @__PURE__ */ jsxs15(DropdownMenuItem, { onSelect: () => set("text-transform", option.value), className: "eb:min-w-36", children: [
|
|
6978
|
+
/* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", valueOf("text-transform") !== option.value && "eb:invisible"), "aria-hidden": "true" }),
|
|
6979
|
+
t(option.label)
|
|
6980
|
+
] }, option.value)) })
|
|
6981
|
+
] }),
|
|
6982
|
+
/* @__PURE__ */ jsx16(Separator2, {}),
|
|
6983
|
+
/* @__PURE__ */ jsx16(LinkButton, { disabled: !words, href: format.link || "", variables, onApply: (href) => run("link", href) }),
|
|
6984
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Remove the link"), children: /* @__PURE__ */ jsx16("button", { type: "button", className: ICON_BUTTON, disabled: !words || !format.link, "aria-label": t("Remove the link"), "data-command": "unlink", onClick: () => run("unlink"), children: /* @__PURE__ */ jsx16(Unlink, { "aria-hidden": "true" }) }) }),
|
|
6985
|
+
/* @__PURE__ */ jsx16(Separator2, {}),
|
|
6986
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Clear formatting"), children: /* @__PURE__ */ jsx16("button", { type: "button", className: ICON_BUTTON, disabled: !words, "aria-label": t("Clear formatting"), "data-command": "clear", onClick: () => run("clear"), children: /* @__PURE__ */ jsx16(RemoveFormatting, { "aria-hidden": "true" }) }) }),
|
|
6987
|
+
/* @__PURE__ */ jsx16(Separator2, {}),
|
|
6988
|
+
/* @__PURE__ */ jsx16(SizeField2, { property: size, value: currentSize, onCommit: (n) => set("font-size", `${clamp(n, size)}px`) }),
|
|
6989
|
+
/* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
|
|
6990
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Line height"), children: /* @__PURE__ */ jsx16(DropdownMenuTrigger, { asChild: true, disabled: !lineHeight, children: /* @__PURE__ */ jsxs15("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Line height"), "data-control": "line-height", children: [
|
|
6991
|
+
/* @__PURE__ */ jsx16(LineSpacingIcon, { "aria-hidden": "true" }),
|
|
6992
|
+
/* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
|
|
6993
|
+
] }) }) }),
|
|
6994
|
+
/* @__PURE__ */ jsx16(DropdownMenuContent, { align: "start", "aria-label": t("Line height"), onCloseAutoFocus: (event) => event.preventDefault(), children: lineHeight && LINE_HEIGHTS.map((ratio) => {
|
|
6995
|
+
const px = clamp(Math.round((currentSize || 15) * ratio), lineHeight);
|
|
6996
|
+
const current = currentLine !== null && Math.round(currentLine) === px;
|
|
6997
|
+
return /* @__PURE__ */ jsxs15(DropdownMenuItem, { onSelect: () => set("line-height", `${px}px`), className: "eb:min-w-36", children: [
|
|
6998
|
+
/* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", !current && "eb:invisible"), "aria-hidden": "true" }),
|
|
6999
|
+
/* @__PURE__ */ jsx16("span", { className: "eb:tabular-nums", children: number.format(ratio) }),
|
|
7000
|
+
/* @__PURE__ */ jsxs15("span", { className: "eb:ml-auto eb:text-[12px] eb:tabular-nums eb:text-foreground-muted", children: [
|
|
7001
|
+
px,
|
|
7002
|
+
" px"
|
|
7003
|
+
] })
|
|
7004
|
+
] }, ratio);
|
|
7005
|
+
}) })
|
|
7006
|
+
] }),
|
|
7007
|
+
/* @__PURE__ */ jsx16(Separator2, {}),
|
|
7008
|
+
/* @__PURE__ */ jsx16("div", { role: "radiogroup", "aria-label": t("Alignment"), className: "eb:flex eb:items-center eb:gap-0.5", children: ALIGNMENTS.map(({ value, icon: Icon, label }) => {
|
|
7009
|
+
const offered = Boolean(align?.options?.some((option) => option.value === value));
|
|
7010
|
+
return /* @__PURE__ */ jsx16(Tip, { label: t(label), children: /* @__PURE__ */ jsx16(
|
|
7011
|
+
"button",
|
|
7012
|
+
{
|
|
7013
|
+
type: "button",
|
|
7014
|
+
role: "radio",
|
|
7015
|
+
className: ICON_BUTTON,
|
|
7016
|
+
disabled: !offered,
|
|
7017
|
+
"aria-label": t(label),
|
|
7018
|
+
"aria-checked": offered && valueOf("align") === value,
|
|
7019
|
+
onClick: () => valueOf("align") !== value && set("align", value),
|
|
7020
|
+
children: /* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" })
|
|
7021
|
+
}
|
|
7022
|
+
) }, value);
|
|
7023
|
+
}) })
|
|
7024
|
+
] }),
|
|
7025
|
+
drawers.length > 0 && /* @__PURE__ */ jsx16("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__ */ jsx16(Tip, { label: t(title || label), children: /* @__PURE__ */ jsxs15(
|
|
7026
|
+
"button",
|
|
7027
|
+
{
|
|
7028
|
+
type: "button",
|
|
7029
|
+
className: cn(ICON_BUTTON, "eb:text-[12px] eb:font-medium eb:@min-[50rem]:px-2"),
|
|
7030
|
+
"aria-label": t(label),
|
|
7031
|
+
"aria-pressed": openDrawer === id,
|
|
7032
|
+
"aria-controls": openDrawer === id ? `eb-drawer-${id}` : void 0,
|
|
7033
|
+
"data-drawer": id,
|
|
7034
|
+
onClick: () => onToggleDrawer(id),
|
|
7035
|
+
children: [
|
|
7036
|
+
/* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" }),
|
|
7037
|
+
/* @__PURE__ */ jsx16("span", { className: "eb:hidden eb:@min-[50rem]:inline", children: t(label) })
|
|
7038
|
+
]
|
|
7039
|
+
}
|
|
7040
|
+
) }, id)) })
|
|
7041
|
+
]
|
|
7042
|
+
}
|
|
7043
|
+
);
|
|
7044
|
+
}
|
|
7045
|
+
function SizeField2({ property, value, onCommit }) {
|
|
7046
|
+
const { t } = useUi();
|
|
7047
|
+
const shown = value === null ? "" : String(Math.round(value * 100) / 100);
|
|
7048
|
+
const [draft, setDraft] = useState15(shown);
|
|
7049
|
+
useEffect11(() => setDraft(shown), [shown]);
|
|
7050
|
+
const commit = () => {
|
|
7051
|
+
const n = Number.parseFloat(draft);
|
|
7052
|
+
if (Number.isFinite(n) && n !== value) onCommit(n);
|
|
7053
|
+
else setDraft(shown);
|
|
7054
|
+
};
|
|
7055
|
+
const disabled = !property;
|
|
7056
|
+
const sizes = property ? SIZES.filter((n) => n >= (property.min ?? 0) && n <= (property.max ?? Infinity)) : [];
|
|
7057
|
+
return /* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
|
|
7058
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Font size"), children: /* @__PURE__ */ jsxs15(
|
|
7059
|
+
"div",
|
|
7060
|
+
{
|
|
7061
|
+
className: cn(
|
|
7062
|
+
"eb:flex eb:h-7 eb:items-center eb:rounded-lg2 eb:border eb:border-border eb:bg-background eb:transition-colors eb:focus-within:border-ring",
|
|
7063
|
+
disabled && "eb:opacity-40"
|
|
7064
|
+
),
|
|
7065
|
+
children: [
|
|
7066
|
+
/* @__PURE__ */ jsx16(
|
|
7067
|
+
"input",
|
|
7068
|
+
{
|
|
7069
|
+
type: "text",
|
|
7070
|
+
inputMode: "numeric",
|
|
7071
|
+
className: "eb:h-full eb:w-9 eb:bg-transparent eb:pl-2 eb:text-[12px] eb:tabular-nums eb:text-foreground eb:outline-none eb:disabled:cursor-default",
|
|
7072
|
+
"aria-label": t("Font size"),
|
|
7073
|
+
"data-control": "font-size",
|
|
7074
|
+
disabled,
|
|
7075
|
+
value: disabled ? "" : draft,
|
|
7076
|
+
onChange: (event) => setDraft(event.target.value.replace(/[^\d.]/g, "")),
|
|
7077
|
+
onBlur: commit,
|
|
7078
|
+
onKeyDown: (event) => {
|
|
7079
|
+
if (event.key === "Enter") commit();
|
|
7080
|
+
if (event.key === "Escape") setDraft(shown);
|
|
7081
|
+
}
|
|
7082
|
+
}
|
|
7083
|
+
),
|
|
7084
|
+
/* @__PURE__ */ jsx16(DropdownMenuTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx16(
|
|
7085
|
+
"button",
|
|
7086
|
+
{
|
|
7087
|
+
type: "button",
|
|
7088
|
+
"aria-label": t("Font sizes"),
|
|
7089
|
+
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",
|
|
7090
|
+
children: /* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3", "aria-hidden": "true" })
|
|
7091
|
+
}
|
|
7092
|
+
) })
|
|
7093
|
+
]
|
|
7094
|
+
}
|
|
7095
|
+
) }),
|
|
7096
|
+
/* @__PURE__ */ jsx16(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__ */ jsxs15(DropdownMenuItem, { onSelect: () => onCommit(n), className: "eb:tabular-nums", children: [
|
|
7097
|
+
/* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", n !== value && "eb:invisible"), "aria-hidden": "true" }),
|
|
7098
|
+
n
|
|
7099
|
+
] }, n)) })
|
|
7100
|
+
] });
|
|
7101
|
+
}
|
|
7102
|
+
function LinkButton({ disabled, href, variables, onApply }) {
|
|
7103
|
+
const { t } = useUi();
|
|
7104
|
+
const [open, setOpen] = useState15(false);
|
|
7105
|
+
const [draft, setDraft] = useState15("");
|
|
7106
|
+
const inputRef = useRef9(null);
|
|
7107
|
+
return /* @__PURE__ */ jsxs15(
|
|
7108
|
+
Popover,
|
|
7109
|
+
{
|
|
7110
|
+
open,
|
|
7111
|
+
onOpenChange: (next) => {
|
|
7112
|
+
if (next) setDraft(href);
|
|
7113
|
+
setOpen(next);
|
|
7114
|
+
},
|
|
7115
|
+
children: [
|
|
7116
|
+
/* @__PURE__ */ jsx16(Tip, { label: t("Link"), children: /* @__PURE__ */ jsx16(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx16("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Link"), "aria-pressed": Boolean(href), "data-command": "link", children: /* @__PURE__ */ jsx16(Link, { "aria-hidden": "true" }) }) }) }),
|
|
7117
|
+
/* @__PURE__ */ jsx16(PopoverContent, { align: "start", className: "eb:w-80 eb:p-2", onCloseAutoFocus: (event) => event.preventDefault(), children: /* @__PURE__ */ jsxs15(
|
|
7118
|
+
"form",
|
|
7119
|
+
{
|
|
7120
|
+
className: "eb:flex eb:items-center eb:gap-1.5",
|
|
7121
|
+
noValidate: true,
|
|
7122
|
+
onSubmit: (event) => {
|
|
7123
|
+
event.preventDefault();
|
|
7124
|
+
setOpen(false);
|
|
7125
|
+
if (draft.trim()) onApply(draft.trim());
|
|
7126
|
+
},
|
|
7127
|
+
children: [
|
|
7128
|
+
/* @__PURE__ */ jsxs15("div", { className: "eb:relative eb:min-w-0 eb:flex-1", children: [
|
|
7129
|
+
/* @__PURE__ */ jsx16(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" : "" }),
|
|
7130
|
+
variables.length > 0 && /* @__PURE__ */ jsx16("span", { className: "eb:absolute eb:top-1/2 eb:right-0.5 eb:-translate-y-1/2", children: /* @__PURE__ */ jsx16(VariableInsertButton, { variables, inputRef, value: draft, onChange: setDraft, label: t("Insert a variable in the link"), links: true }) })
|
|
7131
|
+
] }),
|
|
7132
|
+
/* @__PURE__ */ jsx16(Button, { type: "submit", size: "icon-dense", variant: "outline", "aria-label": t("Apply the link"), disabled: !draft.trim(), children: /* @__PURE__ */ jsx16(Check2, {}) })
|
|
7133
|
+
]
|
|
7134
|
+
}
|
|
7135
|
+
) })
|
|
7136
|
+
]
|
|
7137
|
+
}
|
|
7138
|
+
);
|
|
7139
|
+
}
|
|
7140
|
+
|
|
6762
7141
|
// src/ui/PropertiesPanel.jsx
|
|
6763
|
-
import { Fragment as Fragment7, jsx as
|
|
7142
|
+
import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
6764
7143
|
var GROUP_ORDER = Object.values(GROUPS);
|
|
6765
7144
|
function grouped(properties) {
|
|
6766
7145
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -6772,13 +7151,13 @@ function grouped(properties) {
|
|
|
6772
7151
|
([a], [b]) => (GROUP_ORDER.indexOf(a) + 1 || 99) - (GROUP_ORDER.indexOf(b) + 1 || 99)
|
|
6773
7152
|
);
|
|
6774
7153
|
}
|
|
6775
|
-
function PropertyGroups({ editor, element, block, idPrefix, services = null }) {
|
|
7154
|
+
function PropertyGroups({ editor, element, block, idPrefix, services = null, hidden = null }) {
|
|
6776
7155
|
const t = useT();
|
|
6777
|
-
return grouped(block?.properties || []).map(([group, properties]) => {
|
|
7156
|
+
return grouped((block?.properties || []).filter((property) => !hidden?.has(property.key))).map(([group, properties]) => {
|
|
6778
7157
|
const box = properties.filter(boxRole);
|
|
6779
|
-
return /* @__PURE__ */
|
|
6780
|
-
/* @__PURE__ */
|
|
6781
|
-
box.length > 0 && /* @__PURE__ */
|
|
7158
|
+
return /* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
|
|
7159
|
+
/* @__PURE__ */ jsx17(SectionLabel, { children: t(group) }),
|
|
7160
|
+
box.length > 0 && /* @__PURE__ */ jsx17(
|
|
6782
7161
|
BoxModel,
|
|
6783
7162
|
{
|
|
6784
7163
|
idPrefix,
|
|
@@ -6788,7 +7167,7 @@ function PropertyGroups({ editor, element, block, idPrefix, services = null }) {
|
|
|
6788
7167
|
},
|
|
6789
7168
|
`${element.id}:box`
|
|
6790
7169
|
),
|
|
6791
|
-
properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */
|
|
7170
|
+
properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */ jsx17(
|
|
6792
7171
|
PropertyField,
|
|
6793
7172
|
{
|
|
6794
7173
|
idPrefix,
|
|
@@ -6807,31 +7186,31 @@ var LABEL_PROPERTY = { key: "content", label: "Label", type: "text", group: GROU
|
|
|
6807
7186
|
var REWRITABLE_TAGS = /* @__PURE__ */ new Set(["mj-text", "mj-button"]);
|
|
6808
7187
|
function PanelHeader({ title, onClose, closeLabel = "Deselect" }) {
|
|
6809
7188
|
const t = useT();
|
|
6810
|
-
return /* @__PURE__ */
|
|
6811
|
-
/* @__PURE__ */
|
|
6812
|
-
onClose && /* @__PURE__ */
|
|
7189
|
+
return /* @__PURE__ */ jsxs16("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: [
|
|
7190
|
+
/* @__PURE__ */ jsx17("h3", { className: "eb:min-w-0 eb:flex-1 eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx17(TruncatedText, { children: title }) }),
|
|
7191
|
+
onClose && /* @__PURE__ */ jsx17(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t(closeLabel), children: /* @__PURE__ */ jsx17(X2, {}) })
|
|
6813
7192
|
] });
|
|
6814
7193
|
}
|
|
6815
7194
|
function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, variables = null, ai = null, onDismiss = null }) {
|
|
6816
7195
|
const t = useT();
|
|
6817
|
-
const subjectRef =
|
|
6818
|
-
const preheaderRef =
|
|
7196
|
+
const subjectRef = useRef10(null);
|
|
7197
|
+
const preheaderRef = useRef10(null);
|
|
6819
7198
|
const rootId = editor.getRootId();
|
|
6820
7199
|
const root = useMemo5(() => rootId ? editor.getElement(rootId) : null, [editor, rootId, changes]);
|
|
6821
7200
|
const bodyBlock2 = root?.blockId ? editor.getBlock(root.blockId) : null;
|
|
6822
7201
|
const field = (key) => (e) => onMetaChange({ ...meta, [key]: e.target.value });
|
|
6823
|
-
return /* @__PURE__ */
|
|
6824
|
-
/* @__PURE__ */
|
|
6825
|
-
/* @__PURE__ */
|
|
6826
|
-
/* @__PURE__ */
|
|
6827
|
-
/* @__PURE__ */
|
|
6828
|
-
/* @__PURE__ */
|
|
6829
|
-
/* @__PURE__ */
|
|
7202
|
+
return /* @__PURE__ */ jsxs16(Fragment7, { children: [
|
|
7203
|
+
/* @__PURE__ */ jsx17(PanelHeader, { title: t("Email"), onClose: onDismiss, closeLabel: "Close" }),
|
|
7204
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:space-y-4 eb:p-4", children: [
|
|
7205
|
+
/* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
|
|
7206
|
+
/* @__PURE__ */ jsx17(SectionLabel, { children: t("Template") }),
|
|
7207
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
|
|
7208
|
+
/* @__PURE__ */ jsxs16(Label, { htmlFor: "eb-meta-name", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: [
|
|
6830
7209
|
t("Name"),
|
|
6831
7210
|
" ",
|
|
6832
|
-
/* @__PURE__ */
|
|
7211
|
+
/* @__PURE__ */ jsx17("span", { className: "eb:text-destructive", children: "*" })
|
|
6833
7212
|
] }),
|
|
6834
|
-
/* @__PURE__ */
|
|
7213
|
+
/* @__PURE__ */ jsx17(
|
|
6835
7214
|
Input,
|
|
6836
7215
|
{
|
|
6837
7216
|
id: "eb-meta-name",
|
|
@@ -6842,12 +7221,12 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
6842
7221
|
"aria-invalid": showErrors && !meta.name.trim() || void 0
|
|
6843
7222
|
}
|
|
6844
7223
|
),
|
|
6845
|
-
showErrors && !meta.name.trim() && /* @__PURE__ */
|
|
7224
|
+
showErrors && !meta.name.trim() && /* @__PURE__ */ jsx17("p", { className: "eb:text-[12px] eb:text-destructive", children: t("Name is required") })
|
|
6846
7225
|
] }),
|
|
6847
|
-
/* @__PURE__ */
|
|
6848
|
-
/* @__PURE__ */
|
|
6849
|
-
/* @__PURE__ */
|
|
6850
|
-
variables && /* @__PURE__ */
|
|
7226
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
|
|
7227
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
|
|
7228
|
+
/* @__PURE__ */ jsx17(Label, { htmlFor: "eb-meta-subject", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Subject") }),
|
|
7229
|
+
variables && /* @__PURE__ */ jsx17(
|
|
6851
7230
|
VariableInsertButton,
|
|
6852
7231
|
{
|
|
6853
7232
|
variables,
|
|
@@ -6858,8 +7237,8 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
6858
7237
|
}
|
|
6859
7238
|
)
|
|
6860
7239
|
] }),
|
|
6861
|
-
/* @__PURE__ */
|
|
6862
|
-
ai?.suggestSubjects && /* @__PURE__ */
|
|
7240
|
+
/* @__PURE__ */ jsx17(Input, { ref: subjectRef, id: "eb-meta-subject", dense: true, maxLength: 250, value: meta.subject, onChange: field("subject") }),
|
|
7241
|
+
ai?.suggestSubjects && /* @__PURE__ */ jsx17(
|
|
6863
7242
|
ai.components.Subjects,
|
|
6864
7243
|
{
|
|
6865
7244
|
editor,
|
|
@@ -6870,10 +7249,10 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
6870
7249
|
}
|
|
6871
7250
|
)
|
|
6872
7251
|
] }),
|
|
6873
|
-
/* @__PURE__ */
|
|
6874
|
-
/* @__PURE__ */
|
|
6875
|
-
/* @__PURE__ */
|
|
6876
|
-
variables && /* @__PURE__ */
|
|
7252
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
|
|
7253
|
+
/* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
|
|
7254
|
+
/* @__PURE__ */ jsx17(Label, { htmlFor: "eb-meta-preheader", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Preview text") }),
|
|
7255
|
+
variables && /* @__PURE__ */ jsx17(
|
|
6877
7256
|
VariableInsertButton,
|
|
6878
7257
|
{
|
|
6879
7258
|
variables,
|
|
@@ -6884,7 +7263,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
6884
7263
|
}
|
|
6885
7264
|
)
|
|
6886
7265
|
] }),
|
|
6887
|
-
/* @__PURE__ */
|
|
7266
|
+
/* @__PURE__ */ jsx17(
|
|
6888
7267
|
Textarea,
|
|
6889
7268
|
{
|
|
6890
7269
|
ref: preheaderRef,
|
|
@@ -6899,7 +7278,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
|
|
|
6899
7278
|
)
|
|
6900
7279
|
] })
|
|
6901
7280
|
] }),
|
|
6902
|
-
root && bodyBlock2 && /* @__PURE__ */
|
|
7281
|
+
root && bodyBlock2 && /* @__PURE__ */ jsx17(PropertyGroups, { editor, element: root, block: bodyBlock2, idPrefix: "eb-page" })
|
|
6903
7282
|
] })
|
|
6904
7283
|
] });
|
|
6905
7284
|
}
|
|
@@ -6917,7 +7296,7 @@ function PropertiesPanel({
|
|
|
6917
7296
|
}) {
|
|
6918
7297
|
const t = useT();
|
|
6919
7298
|
const block = selection?.blockId ? editor.getBlock(selection.blockId) : null;
|
|
6920
|
-
return /* @__PURE__ */
|
|
7299
|
+
return /* @__PURE__ */ jsx17("aside", { "aria-label": t("Properties"), className: "eb:min-h-0 eb:overflow-y-auto", "data-testid": "eb-properties", children: !selection ? /* @__PURE__ */ jsx17(
|
|
6921
7300
|
TemplateSettings,
|
|
6922
7301
|
{
|
|
6923
7302
|
editor,
|
|
@@ -6929,8 +7308,8 @@ function PropertiesPanel({
|
|
|
6929
7308
|
ai,
|
|
6930
7309
|
onDismiss
|
|
6931
7310
|
}
|
|
6932
|
-
) : /* @__PURE__ */
|
|
6933
|
-
/* @__PURE__ */
|
|
7311
|
+
) : /* @__PURE__ */ jsxs16(Fragment7, { children: [
|
|
7312
|
+
/* @__PURE__ */ jsx17(
|
|
6934
7313
|
PanelHeader,
|
|
6935
7314
|
{
|
|
6936
7315
|
title: t(selection.label),
|
|
@@ -6938,11 +7317,11 @@ function PropertiesPanel({
|
|
|
6938
7317
|
closeLabel: onDismiss ? "Close" : "Deselect"
|
|
6939
7318
|
}
|
|
6940
7319
|
),
|
|
6941
|
-
selection.multiple ? /* @__PURE__ */
|
|
6942
|
-
/* @__PURE__ */
|
|
7320
|
+
selection.multiple ? /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-3 eb:p-4", children: [
|
|
7321
|
+
/* @__PURE__ */ jsx17("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).", {
|
|
6943
7322
|
count: selection.multiple
|
|
6944
7323
|
}) }),
|
|
6945
|
-
/* @__PURE__ */
|
|
7324
|
+
/* @__PURE__ */ jsxs16(
|
|
6946
7325
|
Button,
|
|
6947
7326
|
{
|
|
6948
7327
|
variant: "outline",
|
|
@@ -6950,15 +7329,15 @@ function PropertiesPanel({
|
|
|
6950
7329
|
onClick: () => editor.remove(selection.id),
|
|
6951
7330
|
className: "eb:hover:border-destructive/40 eb:hover:bg-destructive/10 eb:hover:text-destructive",
|
|
6952
7331
|
children: [
|
|
6953
|
-
/* @__PURE__ */
|
|
7332
|
+
/* @__PURE__ */ jsx17(Trash24, { "aria-hidden": "true" }),
|
|
6954
7333
|
t("Delete")
|
|
6955
7334
|
]
|
|
6956
7335
|
}
|
|
6957
7336
|
)
|
|
6958
|
-
] }) : /* @__PURE__ */
|
|
6959
|
-
selection.content !== null && selection.content !== void 0 && /* @__PURE__ */
|
|
6960
|
-
/* @__PURE__ */
|
|
6961
|
-
/* @__PURE__ */
|
|
7337
|
+
] }) : /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-4 eb:p-4", children: [
|
|
7338
|
+
selection.content !== null && selection.content !== void 0 && /* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
|
|
7339
|
+
/* @__PURE__ */ jsx17(SectionLabel, { children: t(GROUPS.content) }),
|
|
7340
|
+
/* @__PURE__ */ jsx17(
|
|
6962
7341
|
PropertyField,
|
|
6963
7342
|
{
|
|
6964
7343
|
idPrefix: "eb-prop",
|
|
@@ -6969,16 +7348,16 @@ function PropertiesPanel({
|
|
|
6969
7348
|
`${selection.id}:content`
|
|
6970
7349
|
)
|
|
6971
7350
|
] }),
|
|
6972
|
-
selection.tagName === "mj-text" && /* @__PURE__ */
|
|
6973
|
-
ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */
|
|
6974
|
-
/* @__PURE__ */
|
|
7351
|
+
selection.tagName === "mj-text" && /* @__PURE__ */ jsx17("p", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("Double-click the text to edit it.") }),
|
|
7352
|
+
ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */ jsx17(ai.components.Rewrite, { editor, selection, rewrite: ai.rewrite }, selection.id),
|
|
7353
|
+
/* @__PURE__ */ jsx17(PropertyGroups, { editor, element: selection, block, idPrefix: "eb-prop", services, hidden: RIBBON_KEYS })
|
|
6975
7354
|
] })
|
|
6976
7355
|
] }) });
|
|
6977
7356
|
}
|
|
6978
7357
|
|
|
6979
7358
|
// src/ui/Toolbar.jsx
|
|
6980
7359
|
import { ArrowLeft, Monitor, Redo2, Smartphone, Undo2 } from "lucide-react";
|
|
6981
|
-
import { Fragment as Fragment8, jsx as
|
|
7360
|
+
import { Fragment as Fragment8, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
6982
7361
|
function Toolbar({
|
|
6983
7362
|
title,
|
|
6984
7363
|
status,
|
|
@@ -6995,8 +7374,8 @@ function Toolbar({
|
|
|
6995
7374
|
compact = false
|
|
6996
7375
|
}) {
|
|
6997
7376
|
const t = useT();
|
|
6998
|
-
const identity2 = /* @__PURE__ */
|
|
6999
|
-
/* @__PURE__ */
|
|
7377
|
+
const identity2 = /* @__PURE__ */ jsxs17(Fragment8, { children: [
|
|
7378
|
+
/* @__PURE__ */ jsxs17(
|
|
7000
7379
|
Button,
|
|
7001
7380
|
{
|
|
7002
7381
|
variant: "ghost",
|
|
@@ -7004,300 +7383,58 @@ function Toolbar({
|
|
|
7004
7383
|
onClick: onBack,
|
|
7005
7384
|
"aria-label": compact ? t("Back") : void 0,
|
|
7006
7385
|
children: [
|
|
7007
|
-
/* @__PURE__ */
|
|
7386
|
+
/* @__PURE__ */ jsx18(ArrowLeft, {}),
|
|
7008
7387
|
!compact && t("Back")
|
|
7009
7388
|
]
|
|
7010
7389
|
}
|
|
7011
7390
|
),
|
|
7012
|
-
/* @__PURE__ */
|
|
7013
|
-
/* @__PURE__ */
|
|
7014
|
-
/* @__PURE__ */
|
|
7015
|
-
/* @__PURE__ */
|
|
7391
|
+
/* @__PURE__ */ jsx18(Separator, { orientation: "vertical", className: "eb:h-5" }),
|
|
7392
|
+
/* @__PURE__ */ jsxs17("div", { className: cn("eb:min-w-0 eb:flex-1", !compact && "eb:max-w-[320px]"), children: [
|
|
7393
|
+
/* @__PURE__ */ jsx18("p", { className: "eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx18(TruncatedText, { children: title || t("New template") }) }),
|
|
7394
|
+
/* @__PURE__ */ jsx18("p", { className: "eb:text-[11px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: status })
|
|
7016
7395
|
] })
|
|
7017
7396
|
] });
|
|
7018
|
-
const editing = /* @__PURE__ */
|
|
7019
|
-
/* @__PURE__ */
|
|
7020
|
-
/* @__PURE__ */
|
|
7021
|
-
/* @__PURE__ */
|
|
7397
|
+
const editing = /* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: [
|
|
7398
|
+
/* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:items-center eb:gap-0.5", children: [
|
|
7399
|
+
/* @__PURE__ */ jsx18(TooltipWrap, { label: t("Undo (Ctrl+Z)"), children: /* @__PURE__ */ jsx18(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onUndo, disabled: !ready || !canUndo, "aria-label": t("Undo"), children: /* @__PURE__ */ jsx18(Undo2, {}) }) }),
|
|
7400
|
+
/* @__PURE__ */ jsx18(TooltipWrap, { label: t("Redo (Ctrl+Y)"), children: /* @__PURE__ */ jsx18(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onRedo, disabled: !ready || !canRedo, "aria-label": t("Redo"), children: /* @__PURE__ */ jsx18(Redo2, {}) }) })
|
|
7022
7401
|
] }),
|
|
7023
|
-
/* @__PURE__ */
|
|
7024
|
-
/* @__PURE__ */
|
|
7025
|
-
/* @__PURE__ */
|
|
7402
|
+
/* @__PURE__ */ jsx18(Tabs, { value: device, onValueChange: onDeviceChange, children: /* @__PURE__ */ jsxs17(TabsList, { "aria-label": t("Device"), children: [
|
|
7403
|
+
/* @__PURE__ */ jsxs17(TabsTrigger, { value: "desktop", disabled: !ready, "aria-label": compact ? t("Desktop") : void 0, children: [
|
|
7404
|
+
/* @__PURE__ */ jsx18(Monitor, {}),
|
|
7026
7405
|
!compact && t("Desktop")
|
|
7027
7406
|
] }),
|
|
7028
|
-
/* @__PURE__ */
|
|
7029
|
-
/* @__PURE__ */
|
|
7407
|
+
/* @__PURE__ */ jsxs17(TabsTrigger, { value: "mobile", disabled: !ready, "aria-label": compact ? t("Mobile") : void 0, children: [
|
|
7408
|
+
/* @__PURE__ */ jsx18(Smartphone, {}),
|
|
7030
7409
|
!compact && t("Mobile")
|
|
7031
7410
|
] })
|
|
7032
7411
|
] }) })
|
|
7033
7412
|
] });
|
|
7034
7413
|
if (compact) {
|
|
7035
|
-
return /* @__PURE__ */
|
|
7036
|
-
/* @__PURE__ */
|
|
7414
|
+
return /* @__PURE__ */ jsxs17("div", { className: "eb:shrink-0 eb:border-b eb:border-border", "data-layout": "compact", children: [
|
|
7415
|
+
/* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:h-12 eb:items-center eb:gap-2 eb:px-2", children: [
|
|
7037
7416
|
identity2,
|
|
7038
7417
|
primary
|
|
7039
7418
|
] }),
|
|
7040
|
-
/* @__PURE__ */
|
|
7419
|
+
/* @__PURE__ */ jsxs17("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: [
|
|
7041
7420
|
editing,
|
|
7042
|
-
/* @__PURE__ */
|
|
7043
|
-
/* @__PURE__ */
|
|
7421
|
+
/* @__PURE__ */ jsx18(Separator, { orientation: "vertical", className: "eb:h-5 eb:shrink-0" }),
|
|
7422
|
+
/* @__PURE__ */ jsx18("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: actions })
|
|
7044
7423
|
] })
|
|
7045
7424
|
] });
|
|
7046
7425
|
}
|
|
7047
|
-
return /* @__PURE__ */
|
|
7426
|
+
return /* @__PURE__ */ jsxs17("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: [
|
|
7048
7427
|
identity2,
|
|
7049
7428
|
editing,
|
|
7050
|
-
/* @__PURE__ */
|
|
7429
|
+
/* @__PURE__ */ jsxs17("div", { className: "eb:ml-auto eb:flex eb:items-center eb:gap-2", "data-testid": "eb-toolbar-actions", children: [
|
|
7051
7430
|
actions,
|
|
7052
7431
|
primary
|
|
7053
7432
|
] })
|
|
7054
7433
|
] });
|
|
7055
7434
|
}
|
|
7056
7435
|
|
|
7057
|
-
// src/ui/TextRibbon.jsx
|
|
7058
|
-
import { useEffect as useEffect11, useState as useState15 } from "react";
|
|
7059
|
-
import {
|
|
7060
|
-
AlignCenter as AlignCenter2,
|
|
7061
|
-
AlignJustify as AlignJustify2,
|
|
7062
|
-
AlignLeft as AlignLeft2,
|
|
7063
|
-
AlignRight as AlignRight2,
|
|
7064
|
-
Bold,
|
|
7065
|
-
Check as Check2,
|
|
7066
|
-
ChevronDown,
|
|
7067
|
-
Italic,
|
|
7068
|
-
Link,
|
|
7069
|
-
RemoveFormatting,
|
|
7070
|
-
Strikethrough,
|
|
7071
|
-
Underline,
|
|
7072
|
-
Unlink
|
|
7073
|
-
} from "lucide-react";
|
|
7074
|
-
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7075
|
-
var FORMATS = [
|
|
7076
|
-
{ command: "bold", icon: Bold, label: "Bold (Ctrl+B)" },
|
|
7077
|
-
{ command: "italic", icon: Italic, label: "Italic (Ctrl+I)" },
|
|
7078
|
-
{ command: "underline", icon: Underline, label: "Underline (Ctrl+U)" },
|
|
7079
|
-
{ command: "strike", icon: Strikethrough, label: "Strikethrough" }
|
|
7080
|
-
];
|
|
7081
|
-
var SIZES = [10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48];
|
|
7082
|
-
var LINE_HEIGHTS = [1, 1.15, 1.3, 1.5, 2, 2.5];
|
|
7083
|
-
var ALIGNMENTS = [
|
|
7084
|
-
{ value: "left", icon: AlignLeft2, label: "Align left" },
|
|
7085
|
-
{ value: "center", icon: AlignCenter2, label: "Align center" },
|
|
7086
|
-
{ value: "right", icon: AlignRight2, label: "Align right" },
|
|
7087
|
-
{ value: "justify", icon: AlignJustify2, label: "Justify" }
|
|
7088
|
-
];
|
|
7089
|
-
function LineSpacingIcon(props) {
|
|
7090
|
-
return /* @__PURE__ */ jsx18("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: /* @__PURE__ */ jsx18("path", { d: "M5 4v16M2 7l3-3 3 3M2 17l3 3 3-3M12 6h9M12 12h9M12 18h9" }) });
|
|
7091
|
-
}
|
|
7092
|
-
function pixels(value, fontSize) {
|
|
7093
|
-
const text = String(value || "").trim();
|
|
7094
|
-
const n = Number.parseFloat(text);
|
|
7095
|
-
if (!Number.isFinite(n)) return null;
|
|
7096
|
-
if (text.endsWith("%")) return fontSize ? n / 100 * fontSize : null;
|
|
7097
|
-
if (/^[\d.]+$/.test(text)) return fontSize ? n * fontSize : null;
|
|
7098
|
-
return n;
|
|
7099
|
-
}
|
|
7100
|
-
var clamp = (n, property) => Math.min(property.max ?? n, Math.max(property.min ?? n, n));
|
|
7101
|
-
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";
|
|
7102
|
-
function Tip({ label, children }) {
|
|
7103
|
-
return /* @__PURE__ */ jsx18(TooltipWrap, { label, side: "bottom", delayDuration: 250, hoverable: false, children: /* @__PURE__ */ jsx18("span", { className: "eb:inline-flex", children }) });
|
|
7104
|
-
}
|
|
7105
|
-
var Separator2 = () => /* @__PURE__ */ jsx18("span", { className: "eb:mx-0.5 eb:h-4 eb:w-px eb:shrink-0 eb:bg-border", "aria-hidden": "true" });
|
|
7106
|
-
function TextRibbon({ editor, ready, selection, format, drawers, openDrawer, onToggleDrawer }) {
|
|
7107
|
-
const { t, locale } = useUi();
|
|
7108
|
-
const element = ready && selection && !selection.multiple ? selection : null;
|
|
7109
|
-
const block = element?.blockId ? editor.getBlock(element.blockId) : null;
|
|
7110
|
-
const propertyOf = (key) => block?.properties?.find((property) => property.key === key) || null;
|
|
7111
|
-
const valueOf = (key) => element?.values?.[key] || element?.defaults?.[key] || "";
|
|
7112
|
-
const set = (key, value) => element && editor.updateProperties({ [key]: value }, element.id);
|
|
7113
|
-
const words = ready && (format.editing || element?.tagName === "mj-text");
|
|
7114
|
-
const run = (command, value) => editor.formatText(command, value);
|
|
7115
|
-
const size = propertyOf("font-size");
|
|
7116
|
-
const lineHeight = propertyOf("line-height");
|
|
7117
|
-
const align = propertyOf("align");
|
|
7118
|
-
const currentSize = pixels(valueOf("font-size"), null);
|
|
7119
|
-
const currentLine = pixels(valueOf("line-height"), currentSize);
|
|
7120
|
-
const number = new Intl.NumberFormat(locale || void 0, { maximumFractionDigits: 2 });
|
|
7121
|
-
return /* @__PURE__ */ jsxs17(
|
|
7122
|
-
"div",
|
|
7123
|
-
{
|
|
7124
|
-
role: "toolbar",
|
|
7125
|
-
"aria-label": t("Text formatting"),
|
|
7126
|
-
"data-testid": "eb-ribbon",
|
|
7127
|
-
className: "eb:@container eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:border-b eb:border-border eb:bg-background",
|
|
7128
|
-
onMouseDown: (event) => event.target instanceof HTMLInputElement || event.preventDefault(),
|
|
7129
|
-
children: [
|
|
7130
|
-
/* @__PURE__ */ jsxs17("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: [
|
|
7131
|
-
FORMATS.map(({ command, icon: Icon, label }) => /* @__PURE__ */ jsx18(Tip, { label: t(label), children: /* @__PURE__ */ jsx18(
|
|
7132
|
-
"button",
|
|
7133
|
-
{
|
|
7134
|
-
type: "button",
|
|
7135
|
-
className: ICON_BUTTON,
|
|
7136
|
-
disabled: !words,
|
|
7137
|
-
"aria-label": t(label),
|
|
7138
|
-
"aria-pressed": Boolean(format[command]),
|
|
7139
|
-
"data-command": command,
|
|
7140
|
-
onClick: () => run(command),
|
|
7141
|
-
children: /* @__PURE__ */ jsx18(Icon, { "aria-hidden": "true" })
|
|
7142
|
-
}
|
|
7143
|
-
) }, command)),
|
|
7144
|
-
/* @__PURE__ */ jsx18(Separator2, {}),
|
|
7145
|
-
/* @__PURE__ */ jsx18(LinkButton, { disabled: !words, href: format.link || "", onApply: (href) => run("link", href) }),
|
|
7146
|
-
/* @__PURE__ */ jsx18(Tip, { label: t("Remove the link"), children: /* @__PURE__ */ jsx18("button", { type: "button", className: ICON_BUTTON, disabled: !words || !format.link, "aria-label": t("Remove the link"), "data-command": "unlink", onClick: () => run("unlink"), children: /* @__PURE__ */ jsx18(Unlink, { "aria-hidden": "true" }) }) }),
|
|
7147
|
-
/* @__PURE__ */ jsx18(Separator2, {}),
|
|
7148
|
-
/* @__PURE__ */ jsx18(Tip, { label: t("Clear formatting"), children: /* @__PURE__ */ jsx18("button", { type: "button", className: ICON_BUTTON, disabled: !words, "aria-label": t("Clear formatting"), "data-command": "clear", onClick: () => run("clear"), children: /* @__PURE__ */ jsx18(RemoveFormatting, { "aria-hidden": "true" }) }) }),
|
|
7149
|
-
/* @__PURE__ */ jsx18(Separator2, {}),
|
|
7150
|
-
/* @__PURE__ */ jsx18(SizeField2, { property: size, value: currentSize, onCommit: (n) => set("font-size", `${clamp(n, size)}px`) }),
|
|
7151
|
-
/* @__PURE__ */ jsxs17(DropdownMenu, { modal: false, children: [
|
|
7152
|
-
/* @__PURE__ */ jsx18(Tip, { label: t("Line height"), children: /* @__PURE__ */ jsx18(DropdownMenuTrigger, { asChild: true, disabled: !lineHeight, children: /* @__PURE__ */ jsxs17("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Line height"), "data-control": "line-height", children: [
|
|
7153
|
-
/* @__PURE__ */ jsx18(LineSpacingIcon, { "aria-hidden": "true" }),
|
|
7154
|
-
/* @__PURE__ */ jsx18(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
|
|
7155
|
-
] }) }) }),
|
|
7156
|
-
/* @__PURE__ */ jsx18(DropdownMenuContent, { align: "start", "aria-label": t("Line height"), onCloseAutoFocus: (event) => event.preventDefault(), children: lineHeight && LINE_HEIGHTS.map((ratio) => {
|
|
7157
|
-
const px = clamp(Math.round((currentSize || 15) * ratio), lineHeight);
|
|
7158
|
-
const current = currentLine !== null && Math.round(currentLine) === px;
|
|
7159
|
-
return /* @__PURE__ */ jsxs17(DropdownMenuItem, { onSelect: () => set("line-height", `${px}px`), className: "eb:min-w-36", children: [
|
|
7160
|
-
/* @__PURE__ */ jsx18(Check2, { className: cn("eb:size-3.5", !current && "eb:invisible"), "aria-hidden": "true" }),
|
|
7161
|
-
/* @__PURE__ */ jsx18("span", { className: "eb:tabular-nums", children: number.format(ratio) }),
|
|
7162
|
-
/* @__PURE__ */ jsxs17("span", { className: "eb:ml-auto eb:text-[12px] eb:tabular-nums eb:text-foreground-muted", children: [
|
|
7163
|
-
px,
|
|
7164
|
-
" px"
|
|
7165
|
-
] })
|
|
7166
|
-
] }, ratio);
|
|
7167
|
-
}) })
|
|
7168
|
-
] }),
|
|
7169
|
-
/* @__PURE__ */ jsx18(Separator2, {}),
|
|
7170
|
-
/* @__PURE__ */ jsx18("div", { role: "radiogroup", "aria-label": t("Alignment"), className: "eb:flex eb:items-center eb:gap-0.5", children: ALIGNMENTS.map(({ value, icon: Icon, label }) => {
|
|
7171
|
-
const offered = Boolean(align?.options?.some((option) => option.value === value));
|
|
7172
|
-
return /* @__PURE__ */ jsx18(Tip, { label: t(label), children: /* @__PURE__ */ jsx18(
|
|
7173
|
-
"button",
|
|
7174
|
-
{
|
|
7175
|
-
type: "button",
|
|
7176
|
-
role: "radio",
|
|
7177
|
-
className: ICON_BUTTON,
|
|
7178
|
-
disabled: !offered,
|
|
7179
|
-
"aria-label": t(label),
|
|
7180
|
-
"aria-checked": offered && valueOf("align") === value,
|
|
7181
|
-
onClick: () => valueOf("align") !== value && set("align", value),
|
|
7182
|
-
children: /* @__PURE__ */ jsx18(Icon, { "aria-hidden": "true" })
|
|
7183
|
-
}
|
|
7184
|
-
) }, value);
|
|
7185
|
-
}) })
|
|
7186
|
-
] }),
|
|
7187
|
-
drawers.length > 0 && /* @__PURE__ */ jsx18("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__ */ jsx18(Tip, { label: t(title || label), children: /* @__PURE__ */ jsxs17(
|
|
7188
|
-
"button",
|
|
7189
|
-
{
|
|
7190
|
-
type: "button",
|
|
7191
|
-
className: cn(ICON_BUTTON, "eb:text-[12px] eb:font-medium eb:@min-[50rem]:px-2"),
|
|
7192
|
-
"aria-label": t(label),
|
|
7193
|
-
"aria-pressed": openDrawer === id,
|
|
7194
|
-
"aria-controls": openDrawer === id ? `eb-drawer-${id}` : void 0,
|
|
7195
|
-
"data-drawer": id,
|
|
7196
|
-
onClick: () => onToggleDrawer(id),
|
|
7197
|
-
children: [
|
|
7198
|
-
/* @__PURE__ */ jsx18(Icon, { "aria-hidden": "true" }),
|
|
7199
|
-
/* @__PURE__ */ jsx18("span", { className: "eb:hidden eb:@min-[50rem]:inline", children: t(label) })
|
|
7200
|
-
]
|
|
7201
|
-
}
|
|
7202
|
-
) }, id)) })
|
|
7203
|
-
]
|
|
7204
|
-
}
|
|
7205
|
-
);
|
|
7206
|
-
}
|
|
7207
|
-
function SizeField2({ property, value, onCommit }) {
|
|
7208
|
-
const { t } = useUi();
|
|
7209
|
-
const shown = value === null ? "" : String(Math.round(value * 100) / 100);
|
|
7210
|
-
const [draft, setDraft] = useState15(shown);
|
|
7211
|
-
useEffect11(() => setDraft(shown), [shown]);
|
|
7212
|
-
const commit = () => {
|
|
7213
|
-
const n = Number.parseFloat(draft);
|
|
7214
|
-
if (Number.isFinite(n) && n !== value) onCommit(n);
|
|
7215
|
-
else setDraft(shown);
|
|
7216
|
-
};
|
|
7217
|
-
const disabled = !property;
|
|
7218
|
-
const sizes = property ? SIZES.filter((n) => n >= (property.min ?? 0) && n <= (property.max ?? Infinity)) : [];
|
|
7219
|
-
return /* @__PURE__ */ jsxs17(DropdownMenu, { modal: false, children: [
|
|
7220
|
-
/* @__PURE__ */ jsx18(Tip, { label: t("Font size"), children: /* @__PURE__ */ jsxs17(
|
|
7221
|
-
"div",
|
|
7222
|
-
{
|
|
7223
|
-
className: cn(
|
|
7224
|
-
"eb:flex eb:h-7 eb:items-center eb:rounded-lg2 eb:border eb:border-border eb:bg-background eb:transition-colors eb:focus-within:border-ring",
|
|
7225
|
-
disabled && "eb:opacity-40"
|
|
7226
|
-
),
|
|
7227
|
-
children: [
|
|
7228
|
-
/* @__PURE__ */ jsx18(
|
|
7229
|
-
"input",
|
|
7230
|
-
{
|
|
7231
|
-
type: "text",
|
|
7232
|
-
inputMode: "numeric",
|
|
7233
|
-
className: "eb:h-full eb:w-9 eb:bg-transparent eb:pl-2 eb:text-[12px] eb:tabular-nums eb:text-foreground eb:outline-none eb:disabled:cursor-default",
|
|
7234
|
-
"aria-label": t("Font size"),
|
|
7235
|
-
"data-control": "font-size",
|
|
7236
|
-
disabled,
|
|
7237
|
-
value: disabled ? "" : draft,
|
|
7238
|
-
onChange: (event) => setDraft(event.target.value.replace(/[^\d.]/g, "")),
|
|
7239
|
-
onBlur: commit,
|
|
7240
|
-
onKeyDown: (event) => {
|
|
7241
|
-
if (event.key === "Enter") commit();
|
|
7242
|
-
if (event.key === "Escape") setDraft(shown);
|
|
7243
|
-
}
|
|
7244
|
-
}
|
|
7245
|
-
),
|
|
7246
|
-
/* @__PURE__ */ jsx18(DropdownMenuTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx18(
|
|
7247
|
-
"button",
|
|
7248
|
-
{
|
|
7249
|
-
type: "button",
|
|
7250
|
-
"aria-label": t("Font sizes"),
|
|
7251
|
-
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",
|
|
7252
|
-
children: /* @__PURE__ */ jsx18(ChevronDown, { className: "eb:size-3", "aria-hidden": "true" })
|
|
7253
|
-
}
|
|
7254
|
-
) })
|
|
7255
|
-
]
|
|
7256
|
-
}
|
|
7257
|
-
) }),
|
|
7258
|
-
/* @__PURE__ */ jsx18(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__ */ jsxs17(DropdownMenuItem, { onSelect: () => onCommit(n), className: "eb:tabular-nums", children: [
|
|
7259
|
-
/* @__PURE__ */ jsx18(Check2, { className: cn("eb:size-3.5", n !== value && "eb:invisible"), "aria-hidden": "true" }),
|
|
7260
|
-
n
|
|
7261
|
-
] }, n)) })
|
|
7262
|
-
] });
|
|
7263
|
-
}
|
|
7264
|
-
function LinkButton({ disabled, href, onApply }) {
|
|
7265
|
-
const { t } = useUi();
|
|
7266
|
-
const [open, setOpen] = useState15(false);
|
|
7267
|
-
const [draft, setDraft] = useState15("");
|
|
7268
|
-
return /* @__PURE__ */ jsxs17(
|
|
7269
|
-
Popover,
|
|
7270
|
-
{
|
|
7271
|
-
open,
|
|
7272
|
-
onOpenChange: (next) => {
|
|
7273
|
-
if (next) setDraft(href);
|
|
7274
|
-
setOpen(next);
|
|
7275
|
-
},
|
|
7276
|
-
children: [
|
|
7277
|
-
/* @__PURE__ */ jsx18(Tip, { label: t("Link"), children: /* @__PURE__ */ jsx18(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx18("button", { type: "button", className: ICON_BUTTON, "aria-label": t("Link"), "aria-pressed": Boolean(href), "data-command": "link", children: /* @__PURE__ */ jsx18(Link, { "aria-hidden": "true" }) }) }) }),
|
|
7278
|
-
/* @__PURE__ */ jsx18(PopoverContent, { align: "start", className: "eb:w-80 eb:p-2", onCloseAutoFocus: (event) => event.preventDefault(), children: /* @__PURE__ */ jsxs17(
|
|
7279
|
-
"form",
|
|
7280
|
-
{
|
|
7281
|
-
className: "eb:flex eb:items-center eb:gap-1.5",
|
|
7282
|
-
noValidate: true,
|
|
7283
|
-
onSubmit: (event) => {
|
|
7284
|
-
event.preventDefault();
|
|
7285
|
-
setOpen(false);
|
|
7286
|
-
if (draft.trim()) onApply(draft.trim());
|
|
7287
|
-
},
|
|
7288
|
-
children: [
|
|
7289
|
-
/* @__PURE__ */ jsx18(Input, { type: "url", dense: true, autoFocus: true, value: draft, onChange: (event) => setDraft(event.target.value), placeholder: "https://", "aria-label": t("Link URL") }),
|
|
7290
|
-
/* @__PURE__ */ jsx18(Button, { type: "submit", size: "icon-dense", variant: "outline", "aria-label": t("Apply the link"), disabled: !draft.trim(), children: /* @__PURE__ */ jsx18(Check2, {}) })
|
|
7291
|
-
]
|
|
7292
|
-
}
|
|
7293
|
-
) })
|
|
7294
|
-
]
|
|
7295
|
-
}
|
|
7296
|
-
);
|
|
7297
|
-
}
|
|
7298
|
-
|
|
7299
7436
|
// src/ui/CanvasPanel.jsx
|
|
7300
|
-
import { useEffect as useEffect12, useRef as
|
|
7437
|
+
import { useEffect as useEffect12, useRef as useRef11, useState as useState16 } from "react";
|
|
7301
7438
|
import { X as X3 } from "lucide-react";
|
|
7302
7439
|
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7303
7440
|
function CanvasPanel({ feature, context, compact, onClose }) {
|
|
@@ -7314,7 +7451,7 @@ function CanvasPanel({ feature, context, compact, onClose }) {
|
|
|
7314
7451
|
const frame = requestAnimationFrame(() => setWide(true));
|
|
7315
7452
|
return () => cancelAnimationFrame(frame);
|
|
7316
7453
|
}, [open]);
|
|
7317
|
-
const ref =
|
|
7454
|
+
const ref = useRef11(
|
|
7318
7455
|
/** @type {HTMLDivElement|null} */
|
|
7319
7456
|
null
|
|
7320
7457
|
);
|
|
@@ -7390,7 +7527,7 @@ function Drawer({ open, side = "left", title, onClose, children, testId, header:
|
|
|
7390
7527
|
}
|
|
7391
7528
|
|
|
7392
7529
|
// src/ui/useEmailEditorState.js
|
|
7393
|
-
import { useCallback as useCallback2, useEffect as useEffect14, useRef as
|
|
7530
|
+
import { useCallback as useCallback2, useEffect as useEffect14, useRef as useRef12, useState as useState17 } from "react";
|
|
7394
7531
|
var DIRTY_CHECK_MS = 150;
|
|
7395
7532
|
function useEmailEditorState(editor) {
|
|
7396
7533
|
const [state, setState] = useState17(() => ({
|
|
@@ -7403,9 +7540,9 @@ function useEmailEditorState(editor) {
|
|
|
7403
7540
|
changes: 0,
|
|
7404
7541
|
dirty: false
|
|
7405
7542
|
}));
|
|
7406
|
-
const clean =
|
|
7407
|
-
const forced =
|
|
7408
|
-
const timer =
|
|
7543
|
+
const clean = useRef12(null);
|
|
7544
|
+
const forced = useRef12(false);
|
|
7545
|
+
const timer = useRef12(null);
|
|
7409
7546
|
const snapshot = useCallback2(() => {
|
|
7410
7547
|
try {
|
|
7411
7548
|
return editor.status === "ready" ? editor.exportMjml() : null;
|
|
@@ -7476,18 +7613,19 @@ function useEmailEditorState(editor) {
|
|
|
7476
7613
|
}
|
|
7477
7614
|
|
|
7478
7615
|
// src/ui/SidePanel.jsx
|
|
7479
|
-
import { useCallback as useCallback3, useEffect as useEffect15, useRef as
|
|
7616
|
+
import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef13, useState as useState18 } from "react";
|
|
7480
7617
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
7481
7618
|
import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
7482
7619
|
var SIDE_PANELS = {
|
|
7483
|
-
//
|
|
7484
|
-
blocks: { width:
|
|
7620
|
+
// Two blocks in a row: wider, the row takes three.
|
|
7621
|
+
blocks: { width: 272, min: 200, max: 480 },
|
|
7485
7622
|
properties: { width: 416, min: 296, max: 640 }
|
|
7486
7623
|
};
|
|
7487
7624
|
var RAIL_WIDTH = 40;
|
|
7488
7625
|
var FOLD_MS = 350;
|
|
7489
7626
|
var CANVAS_MIN = { wide: 640, medium: 480 };
|
|
7490
7627
|
var STORAGE_KEY = "best-email-builder:side-panels";
|
|
7628
|
+
var FORMER_BLOCKS_WIDTH = 328;
|
|
7491
7629
|
var EDGE2 = { left: "eb:right-0 eb:translate-x-1/2", right: "eb:left-0 eb:-translate-x-1/2" };
|
|
7492
7630
|
var KEY_STEP = 16;
|
|
7493
7631
|
var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
@@ -7507,7 +7645,7 @@ function initialPanels() {
|
|
|
7507
7645
|
const entry = saved?.[name];
|
|
7508
7646
|
if (!entry) continue;
|
|
7509
7647
|
const { min, max } = SIDE_PANELS[name];
|
|
7510
|
-
if (Number.isFinite(entry.width)) panels[name].width = clamp2(entry.width, min, max);
|
|
7648
|
+
if (Number.isFinite(entry.width) && !(name === "blocks" && entry.width === FORMER_BLOCKS_WIDTH)) panels[name].width = clamp2(entry.width, min, max);
|
|
7511
7649
|
panels[name].collapsed = entry.collapsed === true;
|
|
7512
7650
|
}
|
|
7513
7651
|
} catch {
|
|
@@ -7520,7 +7658,7 @@ function useSidePanels() {
|
|
|
7520
7658
|
/** @type {Partial<Record<keyof typeof SIDE_PANELS, true>>} */
|
|
7521
7659
|
{}
|
|
7522
7660
|
);
|
|
7523
|
-
const timers =
|
|
7661
|
+
const timers = useRef13(
|
|
7524
7662
|
/** @type {Partial<Record<keyof typeof SIDE_PANELS, ReturnType<typeof setTimeout>>>} */
|
|
7525
7663
|
{}
|
|
7526
7664
|
);
|
|
@@ -7546,11 +7684,11 @@ function panelTrack(state, name) {
|
|
|
7546
7684
|
}
|
|
7547
7685
|
var FOLD_TRANSITION = "eb:transition-[grid-template-columns] eb:duration-[350ms] eb:ease-in-out";
|
|
7548
7686
|
function SidePanel({ name, side, state, moving = false, onChange, room, labels, children }) {
|
|
7549
|
-
const ref =
|
|
7687
|
+
const ref = useRef13(
|
|
7550
7688
|
/** @type {HTMLDivElement|null} */
|
|
7551
7689
|
null
|
|
7552
7690
|
);
|
|
7553
|
-
const drag =
|
|
7691
|
+
const drag = useRef13(
|
|
7554
7692
|
/** @type {{x: number, width: number, max: number}|null} */
|
|
7555
7693
|
null
|
|
7556
7694
|
);
|
|
@@ -7694,10 +7832,10 @@ function Builder({
|
|
|
7694
7832
|
className
|
|
7695
7833
|
}) {
|
|
7696
7834
|
const { t, locale, notify, confirm } = useUi();
|
|
7697
|
-
const tRef =
|
|
7835
|
+
const tRef = useRef14(t);
|
|
7698
7836
|
tRef.current = t;
|
|
7699
7837
|
const storage = useMemo6(() => injectedStorage || createHttpStorage(), [injectedStorage]);
|
|
7700
|
-
const storageRef =
|
|
7838
|
+
const storageRef = useRef14(storage);
|
|
7701
7839
|
storageRef.current = storage;
|
|
7702
7840
|
const editor = useMemo6(
|
|
7703
7841
|
() => injected || createDefaultEmailEditor({
|
|
@@ -7751,12 +7889,12 @@ function Builder({
|
|
|
7751
7889
|
const [autosaveBlocked, setAutosaveBlocked] = useState19(null);
|
|
7752
7890
|
const [engineError, setEngineError] = useState19(null);
|
|
7753
7891
|
const [attempt, setAttempt] = useState19(0);
|
|
7754
|
-
const rootRef =
|
|
7892
|
+
const rootRef = useRef14(null);
|
|
7755
7893
|
const layout2 = useLayoutWidth(rootRef);
|
|
7756
7894
|
const compact = layout2 !== "wide";
|
|
7757
7895
|
const blocksInDrawer = layout2 === "narrow";
|
|
7758
7896
|
const { panels, update: updatePanel, moving: movingPanels } = useSidePanels();
|
|
7759
|
-
const gridRef =
|
|
7897
|
+
const gridRef = useRef14(null);
|
|
7760
7898
|
const [drawer, setDrawer] = useState19(null);
|
|
7761
7899
|
const closeDrawer = useCallback4(() => setDrawer(null), []);
|
|
7762
7900
|
const [canvasPanel, setCanvasPanel] = useState19(null);
|
|
@@ -7771,7 +7909,7 @@ function Builder({
|
|
|
7771
7909
|
(date) => date ? new Date(date).toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }) : "",
|
|
7772
7910
|
[locale]
|
|
7773
7911
|
);
|
|
7774
|
-
const booted =
|
|
7912
|
+
const booted = useRef14(false);
|
|
7775
7913
|
useEffect16(() => {
|
|
7776
7914
|
if (booted.current) return;
|
|
7777
7915
|
booted.current = true;
|
|
@@ -7839,7 +7977,7 @@ function Builder({
|
|
|
7839
7977
|
() => editor.status === "ready" && checkDirty() || metaDirty,
|
|
7840
7978
|
[editor, checkDirty, metaDirty]
|
|
7841
7979
|
);
|
|
7842
|
-
const reportDirty =
|
|
7980
|
+
const reportDirty = useRef14(onDirtyChange);
|
|
7843
7981
|
reportDirty.current = onDirtyChange;
|
|
7844
7982
|
useEffect16(() => {
|
|
7845
7983
|
reportDirty.current?.(dirty);
|
|
@@ -7860,8 +7998,8 @@ function Builder({
|
|
|
7860
7998
|
window.addEventListener("beforeunload", warn);
|
|
7861
7999
|
return () => window.removeEventListener("beforeunload", warn);
|
|
7862
8000
|
}, [dirty]);
|
|
7863
|
-
const savingRef =
|
|
7864
|
-
const latest =
|
|
8001
|
+
const savingRef = useRef14(false);
|
|
8002
|
+
const latest = useRef14({});
|
|
7865
8003
|
latest.current = { template, meta, onSaved, compact };
|
|
7866
8004
|
const save = useCallback4(
|
|
7867
8005
|
async ({ auto = false } = {}) => {
|
|
@@ -8134,6 +8272,7 @@ function Builder({
|
|
|
8134
8272
|
ready,
|
|
8135
8273
|
selection: state.selection,
|
|
8136
8274
|
format: state.format,
|
|
8275
|
+
variables,
|
|
8137
8276
|
drawers: panelFeatures.map((feature) => ({ id: feature.id, ...feature.drawer })),
|
|
8138
8277
|
openDrawer: openPanel?.id ?? null,
|
|
8139
8278
|
onToggleDrawer: (id) => setCanvasPanel((current) => current === id ? null : id)
|
|
@@ -8313,4 +8452,4 @@ export {
|
|
|
8313
8452
|
EmailBuilder,
|
|
8314
8453
|
EmailBuilderBoundary
|
|
8315
8454
|
};
|
|
8316
|
-
//# sourceMappingURL=chunk-
|
|
8455
|
+
//# sourceMappingURL=chunk-WYYATB37.js.map
|