best-email-builder 0.18.0 → 0.20.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/ai-server.js +3 -3
  3. package/dist/ai.js +11 -11
  4. package/dist/ai.js.map +1 -1
  5. package/dist/builder.js +8 -8
  6. package/dist/{chunk-2M44NIFG.js → chunk-2N6YC6JN.js} +2 -2
  7. package/dist/{chunk-W4UKDEB4.js → chunk-ACJQTHMG.js} +658 -390
  8. package/dist/chunk-ACJQTHMG.js.map +1 -0
  9. package/dist/{chunk-2B3N6CH4.js → chunk-DLQYMFN7.js} +25 -1
  10. package/dist/chunk-DLQYMFN7.js.map +1 -0
  11. package/dist/{chunk-LKD6QZMD.js → chunk-EAE6R7EQ.js} +3 -3
  12. package/dist/{chunk-D46HKFV5.js → chunk-FJ6IJO3K.js} +14 -13
  13. package/dist/chunk-FJ6IJO3K.js.map +1 -0
  14. package/dist/{chunk-JLQDVA4B.js → chunk-LYGVIQGG.js} +4 -4
  15. package/dist/{chunk-37PEEEBB.js → chunk-Q2J547BE.js} +2 -2
  16. package/dist/{chunk-F3566ZQB.js → chunk-RCN6FCCK.js} +3 -3
  17. package/dist/{chunk-L7NSAYYX.js → chunk-RZPCNCWF.js} +9 -5
  18. package/dist/chunk-RZPCNCWF.js.map +1 -0
  19. package/dist/{chunk-BER25JS7.js → chunk-THOQ3RVD.js} +20 -3
  20. package/dist/{chunk-BER25JS7.js.map → chunk-THOQ3RVD.js.map} +1 -1
  21. package/dist/{chunk-POUAC5TN.js → chunk-VLBVJJ4X.js} +2 -2
  22. package/dist/index.js +10 -10
  23. package/dist/library.js +5 -5
  24. package/dist/server.js +5 -5
  25. package/dist/styles.css +1 -1
  26. package/dist/types/blocks/shared.d.ts +1 -1
  27. package/dist/types/core/EmailEditor.d.ts +12 -4
  28. package/dist/types/core/constants.d.ts +1 -1
  29. package/dist/types/engine/NativeAdapter.d.ts +1 -1
  30. package/dist/types/engine/canvas/CanvasView.d.ts +4 -0
  31. package/dist/types/engine/canvas/canvasStyles.d.ts +1 -1
  32. package/dist/types/engine/canvasMjml.d.ts +7 -0
  33. package/dist/types/features/variables/VariableInsertButton.d.ts +7 -3
  34. package/dist/types/features/variables/VariablesPanel.d.ts +1 -2
  35. package/dist/types/ui/TextRibbon.d.ts +26 -1
  36. package/dist/types/ui/fields.d.ts +13 -0
  37. package/dist/types/ui/primitives/color-picker.d.ts +4 -2
  38. package/dist/types/ui/primitives/fields.d.ts +4 -3
  39. package/dist/types/ui/primitives/overlays.d.ts +3 -3
  40. package/package.json +1 -1
  41. package/dist/chunk-2B3N6CH4.js.map +0 -1
  42. package/dist/chunk-D46HKFV5.js.map +0 -1
  43. package/dist/chunk-L7NSAYYX.js.map +0 -1
  44. package/dist/chunk-W4UKDEB4.js.map +0 -1
  45. /package/dist/{chunk-2M44NIFG.js.map → chunk-2N6YC6JN.js.map} +0 -0
  46. /package/dist/{chunk-LKD6QZMD.js.map → chunk-EAE6R7EQ.js.map} +0 -0
  47. /package/dist/{chunk-JLQDVA4B.js.map → chunk-LYGVIQGG.js.map} +0 -0
  48. /package/dist/{chunk-37PEEEBB.js.map → chunk-Q2J547BE.js.map} +0 -0
  49. /package/dist/{chunk-F3566ZQB.js.map → chunk-RCN6FCCK.js.map} +0 -0
  50. /package/dist/{chunk-POUAC5TN.js.map → chunk-VLBVJJ4X.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  useLayoutWidth,
7
7
  useSearchShortcut,
8
8
  withThumbnailImages
9
- } from "./chunk-F3566ZQB.js";
9
+ } from "./chunk-RCN6FCCK.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-BER25JS7.js";
25
+ } from "./chunk-THOQ3RVD.js";
26
26
  import {
27
27
  cleanRichText,
28
28
  escapeText,
29
29
  textOfHtml
30
- } from "./chunk-37PEEEBB.js";
30
+ } from "./chunk-Q2J547BE.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-D46HKFV5.js";
71
+ } from "./chunk-FJ6IJO3K.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-L7NSAYYX.js";
116
+ } from "./chunk-RZPCNCWF.js";
117
117
  import {
118
118
  IMAGE_ATTRIBUTES,
119
119
  isSafeUrl
120
- } from "./chunk-POUAC5TN.js";
120
+ } from "./chunk-VLBVJJ4X.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-2B3N6CH4.js";
136
+ } from "./chunk-DLQYMFN7.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",
@@ -965,6 +967,7 @@ var navbarLinkBlock = {
965
967
  prop.color("Text"),
966
968
  prop.fontFamily(),
967
969
  prop.fontSize(10, 24),
970
+ prop.lineHeight(),
968
971
  {
969
972
  // MJML writes menu links in capitals unless told otherwise.
970
973
  key: "text-transform",
@@ -1424,7 +1427,7 @@ import { Braces as Braces2 } from "lucide-react";
1424
1427
 
1425
1428
  // src/features/variables/VariablesPanel.jsx
1426
1429
  import { Fragment, useEffect as useEffect2, useRef, useState as useState3 } from "react";
1427
- import { FolderPlus, Link2, Loader2 as Loader22, Pencil, Plus, Trash2 as Trash22 } from "lucide-react";
1430
+ import { FolderPlus, Loader2 as Loader22, Pencil, Plus, Trash2 as Trash22 } from "lucide-react";
1428
1431
 
1429
1432
  // src/features/variables/VariableDialog.jsx
1430
1433
  import { useEffect, useMemo, useState as useState2 } from "react";
@@ -1778,7 +1781,7 @@ function VariablesPanel({ context }) {
1778
1781
  const from = groupOf(variable);
1779
1782
  const over = groupAt(event.currentTarget, event.clientX, event.clientY);
1780
1783
  start.over = over !== from ? over : null;
1781
- setDrag({ key: variable.key, label, link: variable.kind === "link", from, over: start.over, x: event.clientX, y: event.clientY });
1784
+ setDrag({ key: variable.key, label, from, over: start.over, x: event.clientX, y: event.clientY });
1782
1785
  },
1783
1786
  onPointerUp: () => {
1784
1787
  const start = press.current;
@@ -1798,31 +1801,27 @@ function VariablesPanel({ context }) {
1798
1801
  }
1799
1802
  });
1800
1803
  const insert = (variable) => {
1801
- const done = variable.kind === "link" ? editor.insertLink(tokenOf(variable), t("Unsubscribe")) : editor.insertText(tokenOf(variable));
1804
+ const done = editor.insertText(tokenOf(variable));
1802
1805
  if (!done) notify("info", t("Select a text or a button first."));
1803
1806
  };
1804
1807
  const badge = (variable) => {
1805
- const link2 = variable.kind === "link";
1806
1808
  const label = labelOf(variable, t);
1807
- const button2 = /* @__PURE__ */ jsxs3(
1809
+ const button2 = /* @__PURE__ */ jsx3(
1808
1810
  "button",
1809
1811
  {
1810
1812
  type: "button",
1811
1813
  disabled: !ready,
1812
1814
  "data-variable": variable.key,
1813
- onMouseEnter: link2 ? void 0 : () => !drag && editor.previewText(tokenOf(variable)),
1814
- onMouseLeave: link2 ? void 0 : () => editor.clearPreview(),
1815
- onFocus: link2 ? void 0 : () => editor.previewText(tokenOf(variable)),
1816
- onBlur: link2 ? void 0 : () => editor.clearPreview(),
1815
+ onMouseEnter: () => !drag && editor.previewText(tokenOf(variable)),
1816
+ onMouseLeave: () => editor.clearPreview(),
1817
+ onFocus: () => editor.previewText(tokenOf(variable)),
1818
+ onBlur: () => editor.clearPreview(),
1817
1819
  onClick: () => {
1818
1820
  if (!press.current?.dragged) insert(variable);
1819
1821
  },
1820
1822
  ...canManageVariables ? dragHandlers(variable, label) : {},
1821
1823
  className: cn(BADGE, canManageVariables && "eb:cursor-grab eb:rounded-r-none eb:border-r-0 eb:pr-1.5 eb:active:cursor-grabbing"),
1822
- children: [
1823
- link2 && /* @__PURE__ */ jsx3(Link2, { className: "eb:size-3", "aria-hidden": "true" }),
1824
- label
1825
- ]
1824
+ children: label
1826
1825
  }
1827
1826
  );
1828
1827
  const tip = /* @__PURE__ */ jsx3(TooltipWrap, { label: /* @__PURE__ */ jsx3("code", { className: "eb:font-mono", children: tokenOf(variable) }), delayDuration: 100, hoverable: false, hidden: Boolean(drag), children: button2 });
@@ -1929,16 +1928,13 @@ function VariablesPanel({ context }) {
1929
1928
  ]
1930
1929
  }
1931
1930
  ),
1932
- drag && /* @__PURE__ */ jsxs3(
1931
+ drag && /* @__PURE__ */ jsx3(
1933
1932
  "span",
1934
1933
  {
1935
1934
  "aria-hidden": "true",
1936
1935
  className: cn(BADGE, "eb:pointer-events-none eb:fixed eb:z-50 eb:border-primary/50 eb:text-primary eb:shadow-md"),
1937
1936
  style: { left: drag.x + 10, top: drag.y + 10 },
1938
- children: [
1939
- drag.link && /* @__PURE__ */ jsx3(Link2, { className: "eb:size-3", "aria-hidden": "true" }),
1940
- drag.label
1941
- ]
1937
+ children: drag.label
1942
1938
  }
1943
1939
  ),
1944
1940
  canManageVariables && /* @__PURE__ */ jsx3(
@@ -2729,7 +2725,7 @@ function colorToHex(value) {
2729
2725
  const byte = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
2730
2726
  return `#${byte(Number(m[1]))}${byte(Number(m[2]))}${byte(Number(m[3]))}${alpha < 1 ? byte(alpha * 255) : ""}`.toUpperCase();
2731
2727
  }
2732
- function ColorPicker({ value, onChange, id, className, placeholder = "", alpha = true, dense = false }) {
2728
+ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha = true, dense = false, trigger = null }) {
2733
2729
  const t = useT();
2734
2730
  const [open, setOpen] = useState7(false);
2735
2731
  const hex = colorToHex(value);
@@ -2738,15 +2734,15 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
2738
2734
  const Picker = alpha ? HexAlphaColorPicker : HexColorPicker;
2739
2735
  return /* @__PURE__ */ jsxs7("div", { className: cn("eb:flex eb:gap-2", className), children: [
2740
2736
  /* @__PURE__ */ jsxs7(Popover, { open, onOpenChange: setOpen, children: [
2741
- /* @__PURE__ */ jsx7(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx7(
2737
+ /* @__PURE__ */ jsx7(PopoverTrigger, { asChild: true, children: trigger || /* @__PURE__ */ jsx7(
2742
2738
  "button",
2743
2739
  {
2744
2740
  type: "button",
2745
2741
  "aria-label": t("Pick a colour"),
2746
2742
  title: t("Pick a colour"),
2747
2743
  className: cn(
2748
- "eb-checker eb:relative eb:h-8 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]",
2749
- dense && "eb:h-6.5 eb:w-9"
2744
+ "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]",
2745
+ dense && "eb:w-9"
2750
2746
  ),
2751
2747
  children: /* @__PURE__ */ jsx7(
2752
2748
  "span",
@@ -2777,7 +2773,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
2777
2773
  placeholder: "#RRGGBB",
2778
2774
  maxLength: 9,
2779
2775
  "aria-label": t("Hex code"),
2780
- className: "eb:h-8 eb:flex-1 eb:font-mono eb:text-[12px] eb:uppercase"
2776
+ className: "eb:flex-1 eb:font-mono eb:uppercase"
2781
2777
  }
2782
2778
  )
2783
2779
  ] }),
@@ -2796,7 +2792,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
2796
2792
  )) })
2797
2793
  ] })
2798
2794
  ] }),
2799
- /* @__PURE__ */ jsx7(
2795
+ !trigger && /* @__PURE__ */ jsx7(
2800
2796
  Input,
2801
2797
  {
2802
2798
  id,
@@ -2805,7 +2801,7 @@ function ColorPicker({ value, onChange, id, className, placeholder = "", alpha =
2805
2801
  maxLength: 9,
2806
2802
  placeholder: colorToHex(placeholder) || "#RRGGBB",
2807
2803
  dense,
2808
- className: cn("eb:flex-1 eb:font-mono", dense ? "eb:text-[12px]" : "eb:text-[13px]")
2804
+ className: "eb:flex-1 eb:font-mono"
2809
2805
  }
2810
2806
  )
2811
2807
  ] });
@@ -3016,7 +3012,7 @@ function BrandButton({ context }) {
3016
3012
  }
3017
3013
  )
3018
3014
  ] }),
3019
- /* @__PURE__ */ jsxs8(Button, { type: "submit", size: "sm", className: "eb:h-6.5", disabled: reading || !form.website.trim(), children: [
3015
+ /* @__PURE__ */ jsxs8(Button, { type: "submit", size: "sm", className: "eb:h-7", disabled: reading || !form.website.trim(), children: [
3020
3016
  reading ? /* @__PURE__ */ jsx8(Loader25, { className: "eb:animate-spin" }) : /* @__PURE__ */ jsx8(WandSparkles, {}),
3021
3017
  t("Get my brand")
3022
3018
  ] })
@@ -3627,6 +3623,14 @@ td.eb-placeholder { outline: 1.5px dashed #c3cad6; outline-offset: -8px; }
3627
3623
  box-shadow: 0 0 0 2px #fff, 0 3px 10px -3px color-mix(in oklab, ${PRIMARY} 70%, transparent); transition: transform 0.12s ease; }
3628
3624
  .eb-ui-add:hover, .eb-ui-add:focus-visible { transform: scale(1.15); }
3629
3625
  .eb-ui-add svg { width: 14px; height: 14px; stroke-width: 2.75; }
3626
+ .eb-ui-column-border { position: absolute; width: 11px; margin-left: -5.5px; cursor: col-resize; pointer-events: auto;
3627
+ touch-action: none; outline: none; }
3628
+ .eb-ui-column-border::before { content: ''; position: absolute; top: 0; bottom: 0; left: 4.5px; width: 2px; border-radius: 1px;
3629
+ background: color-mix(in oklab, ${PRIMARY} 45%, transparent); transition: background 0.12s ease; }
3630
+ .eb-ui-column-border::after { content: ''; position: absolute; top: 50%; left: 2.5px; width: 6px; height: 24px; margin-top: -12px;
3631
+ border-radius: 3px; background: ${PRIMARY}; box-shadow: 0 0 0 1.5px #fff; }
3632
+ .eb-ui-column-border:hover::before, .eb-ui-column-border:focus-visible::before, .eb-ui-column-border[data-active]::before {
3633
+ background: ${PRIMARY}; }
3630
3634
  .eb-ui-drop { position: absolute; height: 4px; margin-top: -2px; border-radius: 2px; background: ${PRIMARY};
3631
3635
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); pointer-events: none; }
3632
3636
  .eb-ui-drop::before, .eb-ui-drop::after { content: ''; position: absolute; top: -3px; width: 10px; height: 10px;
@@ -3769,6 +3773,8 @@ function createCanvasView(options) {
3769
3773
  tagClear.hidden = true;
3770
3774
  tagClear.innerHTML = ICONS.x;
3771
3775
  ui.appendChild(tagClear);
3776
+ const columnBorders = doc.createElement("div");
3777
+ ui.appendChild(columnBorders);
3772
3778
  const workBox = make("eb-ui-box eb-ui-working");
3773
3779
  workBox.setAttribute("data-testid", "eb-canvas-working");
3774
3780
  let selectedId = null;
@@ -3875,6 +3881,70 @@ function createCanvasView(options) {
3875
3881
  tools.style.left = `${Math.max(afterChip, box.left + box.width - toolsWidth)}px`;
3876
3882
  drawAdd(box, details);
3877
3883
  }
3884
+ const COLUMN_MIN = 10;
3885
+ function rowAround(id) {
3886
+ const path = pathTo(getRoot(), id) || [];
3887
+ for (let i = path.length - 1; i >= 0; i -= 1) {
3888
+ if (path[i].children.filter((child) => child.tag === "mj-column").length > 1) return path[i];
3889
+ }
3890
+ return null;
3891
+ }
3892
+ function shownColumns(row) {
3893
+ const columns = row.children.filter((child) => child.tag === "mj-column");
3894
+ const found = columns.map((column2) => docBoxOf(column2.id));
3895
+ if (!found.every(Boolean)) return null;
3896
+ const boxes = (
3897
+ /** @type {{top: number, left: number, width: number, height: number}[]} */
3898
+ found
3899
+ );
3900
+ if (boxes.some((box, i) => i > 0 && Math.abs(box.top - boxes[0].top) > 2)) return null;
3901
+ const total = boxes.reduce((sum, box) => sum + box.width, 0);
3902
+ return { ids: columns.map((column2) => column2.id), boxes, total, shares: boxes.map((box) => box.width / total * 100) };
3903
+ }
3904
+ function sharesAfter(shares, index, delta) {
3905
+ const pair = shares[index] + shares[index + 1];
3906
+ const left = Math.round(Math.min(pair - COLUMN_MIN, Math.max(COLUMN_MIN, Math.round(shares[index] + delta))) * 100) / 100;
3907
+ const next = shares.map((share) => Math.round(share * 100) / 100);
3908
+ next[index] = left;
3909
+ next[index + 1] = Math.round((pair - left) * 100) / 100;
3910
+ return next;
3911
+ }
3912
+ const resizeColumns = (ids, shares) => options.onResizeColumns?.(Object.fromEntries(ids.map((id, i) => [id, `${shares[i]}%`])));
3913
+ function drawColumnBorders() {
3914
+ const row = selectedId && !editingId && !drag && options.onResizeColumns ? rowAround(selectedId) : null;
3915
+ const shown = row ? shownColumns(row) : null;
3916
+ const count = shown ? shown.ids.length - 1 : 0;
3917
+ while (columnBorders.children.length > count) columnBorders.lastElementChild?.remove();
3918
+ while (columnBorders.children.length < count) {
3919
+ const border = doc.createElement("div");
3920
+ border.className = "eb-ui-column-border";
3921
+ border.tabIndex = 0;
3922
+ border.setAttribute("role", "separator");
3923
+ border.setAttribute("aria-orientation", "vertical");
3924
+ border.setAttribute("data-testid", "eb-canvas-column-border");
3925
+ columnBorders.appendChild(border);
3926
+ }
3927
+ if (!shown || !row) return;
3928
+ const top = Math.min(...shown.boxes.map((box) => box.top));
3929
+ const bottom = Math.max(...shown.boxes.map((box) => box.top + box.height));
3930
+ [...columnBorders.children].forEach((element, i) => {
3931
+ const border = (
3932
+ /** @type {HTMLElement} */
3933
+ element
3934
+ );
3935
+ const box = shown.boxes[i];
3936
+ border.style.top = `${top}px`;
3937
+ border.style.left = `${box.left + box.width}px`;
3938
+ border.style.height = `${bottom - top}px`;
3939
+ border.dataset.row = row.id;
3940
+ border.dataset.index = String(i);
3941
+ border.title = t("Drag to change the widths of the columns");
3942
+ border.setAttribute("aria-label", t("Column width"));
3943
+ border.setAttribute("aria-valuenow", String(Math.round(shown.shares[i])));
3944
+ border.setAttribute("aria-valuemin", String(COLUMN_MIN));
3945
+ border.setAttribute("aria-valuemax", String(Math.round(shown.shares[i] + shown.shares[i + 1] - COLUMN_MIN)));
3946
+ });
3947
+ }
3878
3948
  function drawAdd(box, details) {
3879
3949
  const SIZE = 22;
3880
3950
  const busy = Boolean(editingId || drag);
@@ -3917,6 +3987,7 @@ function createCanvasView(options) {
3917
3987
  if (destroyed) return;
3918
3988
  drawMulti();
3919
3989
  drawSelection();
3990
+ drawColumnBorders();
3920
3991
  drawHover();
3921
3992
  drawTag();
3922
3993
  drawWorking();
@@ -4209,6 +4280,46 @@ function createCanvasView(options) {
4209
4280
  savedRange = selection.rangeCount ? selection.getRangeAt(0).cloneRange() : null;
4210
4281
  } else options.onRemoveTag(at.id, at.index);
4211
4282
  });
4283
+ const borderOf = (event) => {
4284
+ const border = (
4285
+ /** @type {HTMLElement|null} */
4286
+ /** @type {Element} */
4287
+ event.target.closest?.(".eb-ui-column-border")
4288
+ );
4289
+ const row = border?.dataset.row ? findNodeIn(border.dataset.row) : null;
4290
+ const shown = row ? shownColumns(row) : null;
4291
+ return border && shown ? { border, shown, index: Number(border.dataset.index) } : null;
4292
+ };
4293
+ const findNodeIn = (id) => (pathTo(getRoot(), id) || []).at(-1) || null;
4294
+ columnBorders.addEventListener("pointerdown", (event) => {
4295
+ const at = event.button === 0 ? borderOf(event) : null;
4296
+ if (!at) return;
4297
+ event.preventDefault();
4298
+ event.stopPropagation();
4299
+ const { border, shown, index } = at;
4300
+ const startX = event.clientX;
4301
+ border.setPointerCapture(event.pointerId);
4302
+ border.dataset.active = "";
4303
+ const move = (e) => resizeColumns(shown.ids, sharesAfter(shown.shares, index, (e.clientX - startX) / shown.total * 100));
4304
+ const end = () => {
4305
+ delete border.dataset.active;
4306
+ border.removeEventListener("pointermove", move);
4307
+ border.removeEventListener("pointerup", end);
4308
+ border.removeEventListener("pointercancel", end);
4309
+ };
4310
+ border.addEventListener("pointermove", move);
4311
+ border.addEventListener("pointerup", end);
4312
+ border.addEventListener("pointercancel", end);
4313
+ });
4314
+ columnBorders.addEventListener("keydown", (event) => {
4315
+ const step = { ArrowLeft: -1, ArrowRight: 1 }[event.key];
4316
+ const at = step ? borderOf(event) : null;
4317
+ if (!at || !step) return;
4318
+ event.preventDefault();
4319
+ event.stopPropagation();
4320
+ resizeColumns(at.shown.ids, sharesAfter(at.shown.shares, at.index, step * (event.shiftKey ? 5 : 1)));
4321
+ });
4322
+ columnBorders.addEventListener("click", (event) => event.stopPropagation());
4212
4323
  tools.addEventListener("click", (event) => {
4213
4324
  const button2 = (
4214
4325
  /** @type {Element} */
@@ -4947,6 +5058,8 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
4947
5058
  } : {} },
4948
5059
  content: LABEL_TAGS.has(node.tag) ? textOfHtml(node.content || "") : null,
4949
5060
  html: node.tag === "mj-text" ? node.content || "" : null,
5061
+ children: node.children.map((child) => child.id),
5062
+ parentId: parentOf(root, id)?.id || null,
4950
5063
  canRemove: !locked,
4951
5064
  canDuplicate: !locked,
4952
5065
  canMoveUp: !locked && index > 0,
@@ -5060,6 +5173,38 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
5060
5173
  emitSelection();
5061
5174
  if (render) void view?.render();
5062
5175
  }
5176
+ function rowImages(current, id) {
5177
+ for (let node = parentOf(current, id); node; node = parentOf(current, node.id)) {
5178
+ const columns = node.children.filter((child) => child.tag === "mj-column");
5179
+ if (columns.length > 1) {
5180
+ return (
5181
+ /** @type {EmailNode[]} */
5182
+ columns.map((column2) => findFirst(column2, "mj-image")).filter((image) => image?.attributes.src)
5183
+ );
5184
+ }
5185
+ }
5186
+ return [];
5187
+ }
5188
+ async function fitRowImages(id, merge) {
5189
+ const [first, ...others] = rowImages(requireRoot(), id);
5190
+ if (!first || !others.length || !view) return;
5191
+ await view.render();
5192
+ const img = (
5193
+ /** @type {HTMLImageElement|null} */
5194
+ view?.document.querySelector(`.${ID_CLASS_PREFIX}${first.id} img`) || null
5195
+ );
5196
+ if (!img) return;
5197
+ if (!img.complete) await new Promise((done) => {
5198
+ img.addEventListener("load", done, { once: true });
5199
+ img.addEventListener("error", done, { once: true });
5200
+ });
5201
+ const width = root ? imageWidths(root).get(first.id) : 0;
5202
+ if (!img.naturalWidth || !width) return;
5203
+ const height = `${Math.round(width * img.naturalHeight / img.naturalWidth)}px`;
5204
+ let next = requireRoot();
5205
+ for (const image of rowImages(next, id)) if (image.attributes.height !== height) next = setAttributes(next, image.id, { height });
5206
+ commit(next, { merge });
5207
+ }
5063
5208
  function replace(next) {
5064
5209
  view?.finishEditing();
5065
5210
  clearAll();
@@ -5334,6 +5479,12 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
5334
5479
  if (payload.nodeId) moveTo(payload.nodeId, target);
5335
5480
  else if (payload.block) insertBlock(payload.block, target);
5336
5481
  },
5482
+ // A border between columns dragged: one step of history for the whole drag.
5483
+ onResizeColumns: (widths) => {
5484
+ let next = requireRoot();
5485
+ for (const [id, width] of Object.entries(widths)) next = setAttributes(next, id, { width });
5486
+ commit(next, { merge: `columns:${Object.keys(widths).join("+")}` });
5487
+ },
5337
5488
  onEditStart: () => {
5338
5489
  history.key = null;
5339
5490
  },
@@ -5421,19 +5572,27 @@ function createNativeAdapter({ loadCompiler = defaultLoadCompiler, imageUrl = nu
5421
5572
  getSelection: () => currentSelection(),
5422
5573
  describe: (id) => describe(id),
5423
5574
  getRootId: () => root ? findFirst(root, "mj-body")?.id || null : null,
5575
+ /** Several ids (the ribbon on a menu's links): one step of the history. */
5424
5576
  updateProperties(id, attributes) {
5577
+ const ids = Array.isArray(id) ? id : [id];
5425
5578
  const current = requireRoot();
5426
- const node = findNode(current, id);
5427
- if (!node) return;
5428
- if (view?.editingId() === id) view.finishEditing();
5429
5579
  const keys = Object.keys(attributes).sort().join(",");
5430
5580
  const { "vertical-align": alignment, ...own } = attributes;
5431
- let next = setAttributes(current, id, own);
5432
- if ("vertical-align" in attributes) {
5433
- for (const target of alignmentTargets(current, node)) next = setAttributes(next, target.id, { "vertical-align": alignment });
5581
+ let next = current;
5582
+ for (const one of ids) {
5583
+ const node = findNode(current, one);
5584
+ if (!node) continue;
5585
+ if (view?.editingId() === one) view.finishEditing();
5586
+ next = setAttributes(next, one, own);
5587
+ if ("vertical-align" in attributes) {
5588
+ for (const target of alignmentTargets(current, node)) next = setAttributes(next, target.id, { "vertical-align": alignment });
5589
+ }
5590
+ if (node.tag === "mj-column" && "width" in attributes) next = balanceColumns(next, one, attributes.width);
5434
5591
  }
5435
- if (node.tag === "mj-column" && "width" in attributes) next = balanceColumns(next, id, attributes.width);
5436
- commit(next, { merge: `attributes:${id}:${keys}` });
5592
+ const merge = `attributes:${ids.join("+")}:${keys}`;
5593
+ commit(next, { merge });
5594
+ const image = ids.find((one) => attributes.src && findNode(current, one)?.tag === "mj-image");
5595
+ if (image) void fitRowImages(image, merge);
5437
5596
  },
5438
5597
  setContent(id, content, { reveal = false } = {}) {
5439
5598
  const current = requireRoot();
@@ -5594,7 +5753,7 @@ function EmailCanvas({ editor, document: document2 = null, onReady, onError, cla
5594
5753
  }
5595
5754
 
5596
5755
  // src/ui/EmailBuilder.jsx
5597
- import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as useRef13, useState as useState19 } from "react";
5756
+ import { useCallback as useCallback4, useEffect as useEffect16, useMemo as useMemo6, useRef as useRef14, useState as useState19 } from "react";
5598
5757
  import { AlertTriangle, Loader2 as Loader27, Plus as Plus3, Save, SlidersHorizontal } from "lucide-react";
5599
5758
 
5600
5759
  // src/features/brand/useBrand.js
@@ -5957,7 +6116,7 @@ function ItemChoices({ label, choices, onPick }) {
5957
6116
  }
5958
6117
 
5959
6118
  // src/ui/PropertiesPanel.jsx
5960
- import { useMemo as useMemo5, useRef as useRef9 } from "react";
6119
+ import { useMemo as useMemo5, useRef as useRef10 } from "react";
5961
6120
  import { Trash2 as Trash24, X as X2 } from "lucide-react";
5962
6121
 
5963
6122
  // src/ui/fields.jsx
@@ -6081,7 +6240,7 @@ function ImageField({ id, property, value, onCommit, services }) {
6081
6240
  type: "button",
6082
6241
  variant: "outline",
6083
6242
  size: "xs",
6084
- className: "eb:h-6.5",
6243
+ className: "eb:h-7",
6085
6244
  disabled: busy,
6086
6245
  onClick: () => inputRef.current?.click(),
6087
6246
  children: [
@@ -6154,7 +6313,7 @@ function SizeField({ id, property, value, fallback = "", onCommit }) {
6154
6313
  ] })
6155
6314
  ] });
6156
6315
  }
6157
- function ColorField({ id, property, value, fallback = "", onCommit }) {
6316
+ function ColorField({ id, property, value, fallback = "", onCommit, trigger = null }) {
6158
6317
  const t = useT();
6159
6318
  const [draft, setDraft, ref] = useDraft(value, colorToHex);
6160
6319
  const timer = useRef7(null);
@@ -6178,9 +6337,9 @@ function ColorField({ id, property, value, fallback = "", onCommit }) {
6178
6337
  if (wait <= 0) commit(next);
6179
6338
  else timer.current = setTimeout(() => commit(next), wait);
6180
6339
  };
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 })
6340
+ return /* @__PURE__ */ jsxs11("div", { ref, className: trigger ? "eb:contents" : "eb:space-y-1", children: [
6341
+ !trigger && /* @__PURE__ */ jsx12(FieldLabel, { id, children: t(property.label) }),
6342
+ /* @__PURE__ */ jsx12(ColorPicker, { id, value: draft, placeholder: emailColor(fallback) || "", onChange: change, dense: true, trigger })
6184
6343
  ] });
6185
6344
  }
6186
6345
  var DEFAULT_OPTION = "__default__";
@@ -6650,7 +6809,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
6650
6809
  placeholder: t("Search variables\u2026"),
6651
6810
  "aria-label": t("Search variables\u2026"),
6652
6811
  "aria-keyshortcuts": SEARCH_KEYS,
6653
- className: "eb:h-8 eb:w-full eb:rounded-lg2 eb:bg-surface-75 eb:pr-14 eb:pl-7 eb:text-[13px] eb:text-foreground eb:outline-none eb:placeholder:text-foreground-muted eb:focus-visible:ring-2 eb:focus-visible:ring-ring/40"
6812
+ 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
6813
  }
6655
6814
  ),
6656
6815
  /* @__PURE__ */ jsx14(SearchKeyHint, { className: "eb:absolute eb:top-1/2 eb:right-4 eb:-translate-y-1/2" })
@@ -6736,7 +6895,7 @@ function VariablePicker({ variables, onPick, onCreate = null, onEdit = null, fil
6736
6895
 
6737
6896
  // src/features/variables/VariableInsertButton.jsx
6738
6897
  import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
6739
- function VariableInsertButton({ variables, inputRef, value, onChange, label }) {
6898
+ function VariableInsertButton({ variables, inputRef, value, onChange, label, links = false }) {
6740
6899
  const [open, setOpen] = useState14(false);
6741
6900
  const insert = (variable) => {
6742
6901
  const input = inputRef.current;
@@ -6755,12 +6914,361 @@ function VariableInsertButton({ variables, inputRef, value, onChange, label }) {
6755
6914
  };
6756
6915
  return /* @__PURE__ */ jsxs14(Popover, { open, onOpenChange: setOpen, children: [
6757
6916
  /* @__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" }) })
6917
+ /* @__PURE__ */ jsx15(PopoverAnchor, { virtualRef: inputRef }),
6918
+ /* @__PURE__ */ jsx15(PopoverContent, { align: "start", className: "eb:w-(--radix-popover-trigger-width) eb:min-w-64 eb:p-0", onCloseAutoFocus: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx15(VariablePicker, { variables, onPick: insert, filter: links ? void 0 : (v) => v.kind !== "link" }) })
6919
+ ] });
6920
+ }
6921
+
6922
+ // src/ui/TextRibbon.jsx
6923
+ import { useEffect as useEffect11, useRef as useRef9, useState as useState15 } from "react";
6924
+ import {
6925
+ AlignCenter as AlignCenter2,
6926
+ AlignJustify as AlignJustify2,
6927
+ AlignLeft as AlignLeft2,
6928
+ AlignRight as AlignRight2,
6929
+ Baseline,
6930
+ Bold,
6931
+ CaseSensitive,
6932
+ Check as Check2,
6933
+ ChevronDown,
6934
+ Italic,
6935
+ Link,
6936
+ RemoveFormatting,
6937
+ Strikethrough,
6938
+ Underline,
6939
+ Unlink
6940
+ } from "lucide-react";
6941
+ import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
6942
+ var RIBBON_KEYS = /* @__PURE__ */ new Set(["font-family", "font-size", "line-height", "font-weight", "color", "text-transform", "align"]);
6943
+ var FORMATS = [
6944
+ { command: "bold", icon: Bold, label: "Bold (Ctrl+B)" },
6945
+ { command: "italic", icon: Italic, label: "Italic (Ctrl+I)" },
6946
+ { command: "underline", icon: Underline, label: "Underline (Ctrl+U)" },
6947
+ { command: "strike", icon: Strikethrough, label: "Strikethrough" }
6948
+ ];
6949
+ var SIZES = [10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 44, 48];
6950
+ var LINE_HEIGHTS = [1, 1.15, 1.3, 1.5, 2, 2.5];
6951
+ var ALIGNMENTS = [
6952
+ { value: "left", icon: AlignLeft2, label: "Align left" },
6953
+ { value: "center", icon: AlignCenter2, label: "Align center" },
6954
+ { value: "right", icon: AlignRight2, label: "Align right" },
6955
+ { value: "justify", icon: AlignJustify2, label: "Justify" }
6956
+ ];
6957
+ function LineSpacingIcon(props) {
6958
+ 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" }) });
6959
+ }
6960
+ function pixels(value, fontSize) {
6961
+ const text = String(value || "").trim();
6962
+ const n = Number.parseFloat(text);
6963
+ if (!Number.isFinite(n)) return null;
6964
+ if (text.endsWith("%")) return fontSize ? n / 100 * fontSize : null;
6965
+ if (/^[\d.]+$/.test(text)) return fontSize ? n * fontSize : null;
6966
+ return n;
6967
+ }
6968
+ var fontKey = (value) => String(value || "").toLowerCase().replace(/["'\s]/g, "");
6969
+ var STYLES = {
6970
+ italic: ["font-style", "italic", "normal"],
6971
+ underline: ["text-decoration", "underline", "none"],
6972
+ strike: ["text-decoration", "line-through", "none"]
6973
+ };
6974
+ var STYLED_TAGS = /* @__PURE__ */ new Set(["mj-text", "mj-button", "mj-navbar-link"]);
6975
+ var heavy = (weight) => weight === "bold" || Number(weight) >= 600;
6976
+ var clamp = (n, property) => Math.min(property.max ?? n, Math.max(property.min ?? n, n));
6977
+ 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";
6978
+ function Tip({ label, children }) {
6979
+ return /* @__PURE__ */ jsx16(TooltipWrap, { label, side: "bottom", delayDuration: 250, hoverable: false, children: /* @__PURE__ */ jsx16("span", { className: "eb:inline-flex", children }) });
6980
+ }
6981
+ 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" });
6982
+ function TextRibbon({ editor, ready, selection, format, variables = [], drawers, openDrawer, onToggleDrawer }) {
6983
+ const { t, locale } = useUi();
6984
+ const element = ready && selection && !selection.multiple ? selection : null;
6985
+ const own = (target, key) => (target.blockId ? editor.getBlock(target.blockId) : null)?.properties?.find((property) => property.key === key) || null;
6986
+ const inside = [];
6987
+ const walk = (ids = []) => {
6988
+ for (const id of ids) {
6989
+ const child = editor.getElement(id);
6990
+ if (!child) continue;
6991
+ inside.push(child);
6992
+ walk(child.children);
6993
+ }
6994
+ };
6995
+ if (element) walk(element.children);
6996
+ const parent = element?.parentId ? editor.getElement(element.parentId) : null;
6997
+ const targetsOf = (key) => {
6998
+ if (element && own(element, key)) return [element];
6999
+ const found = inside.filter((target) => own(target, key));
7000
+ return found.length || !parent || !own(parent, key) ? found : [parent];
7001
+ };
7002
+ const propertyOf = (key) => {
7003
+ const [first] = targetsOf(key);
7004
+ return first ? own(first, key) : null;
7005
+ };
7006
+ const valueOf = (key) => {
7007
+ const values = [...new Set(targetsOf(key).map((target) => target.values?.[key] || target.defaults?.[key] || ""))];
7008
+ return values.length === 1 ? values[0] : "";
7009
+ };
7010
+ const set = (key, value) => {
7011
+ const ids = targetsOf(key).map((target) => target.id);
7012
+ if (ids.length) editor.updateProperties({ [key]: value }, ids);
7013
+ };
7014
+ const words = ready && (format.editing || element?.tagName === "mj-text");
7015
+ const run = (command, value) => editor.formatText(command, value);
7016
+ const styledTargets = element && STYLED_TAGS.has(element.tagName) ? [element] : inside.filter((target) => STYLED_TAGS.has(target.tagName));
7017
+ const styled = !words && styledTargets.length > 0;
7018
+ const styleOn = (command) => styledTargets.length > 0 && styledTargets.every((target) => target.attributes?.[STYLES[command][0]] === STYLES[command][1]);
7019
+ const toggleStyle = (command) => {
7020
+ const [attribute, on, off] = STYLES[command];
7021
+ editor.updateProperties({ [attribute]: styleOn(command) ? off : on }, styledTargets.map((target) => target.id));
7022
+ };
7023
+ const weightOf = (target) => target.attributes?.["font-weight"] || target.values?.["font-weight"] || target.defaults?.["font-weight"] || "";
7024
+ const weightOn = styledTargets.length > 0 && styledTargets.every((target) => heavy(weightOf(target)));
7025
+ const textWeight = words && !format.editing && element ? heavy(weightOf(element)) : false;
7026
+ const bold = styled ? weightOn : format.bold || textWeight;
7027
+ const toggleBold = () => {
7028
+ if (styled) editor.updateProperties({ "font-weight": weightOn ? "normal" : "bold" }, styledTargets.map((target) => target.id));
7029
+ else if (textWeight && element) editor.updateProperties({ "font-weight": "normal" }, element.id);
7030
+ else run("bold");
7031
+ };
7032
+ const hrefTargets = words ? [] : targetsOf("href");
7033
+ const linked = hrefTargets.length === 1;
7034
+ const href = words ? format.link || "" : linked ? valueOf("href") : "";
7035
+ const clearStyles = () => editor.updateProperties({ "font-weight": null, "font-style": null, "text-decoration": null }, styledTargets.map((target) => target.id));
7036
+ const font = propertyOf("font-family");
7037
+ const fontValue = font?.options?.find((option) => fontKey(option.value) === fontKey(valueOf("font-family")))?.value;
7038
+ const color = propertyOf("color");
7039
+ const capitals = propertyOf("text-transform");
7040
+ const size = propertyOf("font-size");
7041
+ const lineHeight = propertyOf("line-height");
7042
+ const align = propertyOf("align");
7043
+ const currentSize = pixels(valueOf("font-size"), null);
7044
+ const currentLine = pixels(valueOf("line-height"), currentSize);
7045
+ const number = new Intl.NumberFormat(locale || void 0, { maximumFractionDigits: 2 });
7046
+ return /* @__PURE__ */ jsxs15(
7047
+ "div",
7048
+ {
7049
+ role: "toolbar",
7050
+ "aria-label": t("Text formatting"),
7051
+ "data-testid": "eb-ribbon",
7052
+ className: "eb:@container eb:flex eb:h-10 eb:shrink-0 eb:items-center eb:border-b eb:border-border eb:bg-background",
7053
+ onMouseDown: (event) => event.target instanceof HTMLInputElement || event.preventDefault(),
7054
+ children: [
7055
+ /* @__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: [
7056
+ /* @__PURE__ */ jsxs15(Select, { value: fontValue ?? "", onValueChange: (next) => set("font-family", next), disabled: !font, children: [
7057
+ /* @__PURE__ */ jsx16(Tip, { label: t("Font"), children: /* @__PURE__ */ jsx16(
7058
+ SelectTrigger,
7059
+ {
7060
+ "aria-label": t("Font"),
7061
+ "data-control": "font-family",
7062
+ className: "eb:w-28 eb:shrink-0 eb:gap-1 eb:px-2 eb:shadow-none eb:disabled:opacity-40",
7063
+ children: /* @__PURE__ */ jsx16(SelectValue, { placeholder: t("Font") })
7064
+ }
7065
+ ) }),
7066
+ /* @__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)) })
7067
+ ] }),
7068
+ /* @__PURE__ */ jsx16(Separator2, {}),
7069
+ FORMATS.map(({ command, icon: Icon, label }) => /* @__PURE__ */ jsx16(Tip, { label: t(label), children: /* @__PURE__ */ jsx16(
7070
+ "button",
7071
+ {
7072
+ type: "button",
7073
+ className: ICON_BUTTON,
7074
+ disabled: !words && !styled,
7075
+ "aria-label": t(label),
7076
+ "aria-pressed": Boolean(command === "bold" ? bold : styled ? styleOn(command) : format[command]),
7077
+ "data-command": command,
7078
+ onClick: () => {
7079
+ if (command === "bold") toggleBold();
7080
+ else if (styled) toggleStyle(command);
7081
+ else run(command);
7082
+ },
7083
+ children: /* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" })
7084
+ }
7085
+ ) }, command)),
7086
+ /* @__PURE__ */ jsx16(
7087
+ ColorField,
7088
+ {
7089
+ id: "eb-ribbon-color",
7090
+ property: color || { key: "color", label: "Text color", type: "color" },
7091
+ value: valueOf("color"),
7092
+ fallback: "",
7093
+ onCommit: (value) => set("color", value),
7094
+ 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: [
7095
+ /* @__PURE__ */ jsx16(Baseline, { "aria-hidden": "true" }),
7096
+ /* @__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" })
7097
+ ] }) })
7098
+ },
7099
+ element?.id ?? "none"
7100
+ ),
7101
+ /* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
7102
+ /* @__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: [
7103
+ /* @__PURE__ */ jsx16(CaseSensitive, { "aria-hidden": "true" }),
7104
+ /* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
7105
+ ] }) }) }),
7106
+ /* @__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: [
7107
+ /* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", valueOf("text-transform") !== option.value && "eb:invisible"), "aria-hidden": "true" }),
7108
+ t(option.label)
7109
+ ] }, option.value)) })
7110
+ ] }),
7111
+ /* @__PURE__ */ jsx16(Separator2, {}),
7112
+ /* @__PURE__ */ jsx16(LinkButton, { disabled: !words && !linked, href, variables, onApply: (next) => words ? run("link", next) : set("href", next) }),
7113
+ /* @__PURE__ */ jsx16(Tip, { label: t("Remove the link"), children: /* @__PURE__ */ jsx16("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__ */ jsx16(Unlink, { "aria-hidden": "true" }) }) }),
7114
+ /* @__PURE__ */ jsx16(Separator2, {}),
7115
+ /* @__PURE__ */ jsx16(Tip, { label: t("Clear formatting"), children: /* @__PURE__ */ jsx16("button", { type: "button", className: ICON_BUTTON, disabled: !words && !styled, "aria-label": t("Clear formatting"), "data-command": "clear", onClick: () => words ? run("clear") : clearStyles(), children: /* @__PURE__ */ jsx16(RemoveFormatting, { "aria-hidden": "true" }) }) }),
7116
+ /* @__PURE__ */ jsx16(Separator2, {}),
7117
+ /* @__PURE__ */ jsx16(SizeField2, { property: size, value: currentSize, onCommit: (n) => set("font-size", `${clamp(n, size)}px`) }),
7118
+ /* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
7119
+ /* @__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: [
7120
+ /* @__PURE__ */ jsx16(LineSpacingIcon, { "aria-hidden": "true" }),
7121
+ /* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3! eb:text-foreground-muted", "aria-hidden": "true" })
7122
+ ] }) }) }),
7123
+ /* @__PURE__ */ jsx16(DropdownMenuContent, { align: "start", "aria-label": t("Line height"), onCloseAutoFocus: (event) => event.preventDefault(), children: lineHeight && LINE_HEIGHTS.map((ratio) => {
7124
+ const px = clamp(Math.round((currentSize || 15) * ratio), lineHeight);
7125
+ const current = currentLine !== null && Math.round(currentLine) === px;
7126
+ return /* @__PURE__ */ jsxs15(DropdownMenuItem, { onSelect: () => set("line-height", `${px}px`), className: "eb:min-w-36", children: [
7127
+ /* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", !current && "eb:invisible"), "aria-hidden": "true" }),
7128
+ /* @__PURE__ */ jsx16("span", { className: "eb:tabular-nums", children: number.format(ratio) }),
7129
+ /* @__PURE__ */ jsxs15("span", { className: "eb:ml-auto eb:text-[12px] eb:tabular-nums eb:text-foreground-muted", children: [
7130
+ px,
7131
+ " px"
7132
+ ] })
7133
+ ] }, ratio);
7134
+ }) })
7135
+ ] }),
7136
+ /* @__PURE__ */ jsx16(Separator2, {}),
7137
+ /* @__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 }) => {
7138
+ const offered = Boolean(align?.options?.some((option) => option.value === value));
7139
+ return /* @__PURE__ */ jsx16(Tip, { label: t(label), children: /* @__PURE__ */ jsx16(
7140
+ "button",
7141
+ {
7142
+ type: "button",
7143
+ role: "radio",
7144
+ className: ICON_BUTTON,
7145
+ disabled: !offered,
7146
+ "aria-label": t(label),
7147
+ "aria-checked": offered && valueOf("align") === value,
7148
+ onClick: () => valueOf("align") !== value && set("align", value),
7149
+ children: /* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" })
7150
+ }
7151
+ ) }, value);
7152
+ }) })
7153
+ ] }),
7154
+ 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(
7155
+ "button",
7156
+ {
7157
+ type: "button",
7158
+ className: cn(ICON_BUTTON, "eb:text-[12px] eb:font-medium eb:@min-[50rem]:px-2"),
7159
+ "aria-label": t(label),
7160
+ "aria-pressed": openDrawer === id,
7161
+ "aria-controls": openDrawer === id ? `eb-drawer-${id}` : void 0,
7162
+ "data-drawer": id,
7163
+ onClick: () => onToggleDrawer(id),
7164
+ children: [
7165
+ /* @__PURE__ */ jsx16(Icon, { "aria-hidden": "true" }),
7166
+ /* @__PURE__ */ jsx16("span", { className: "eb:hidden eb:@min-[50rem]:inline", children: t(label) })
7167
+ ]
7168
+ }
7169
+ ) }, id)) })
7170
+ ]
7171
+ }
7172
+ );
7173
+ }
7174
+ function SizeField2({ property, value, onCommit }) {
7175
+ const { t } = useUi();
7176
+ const shown = value === null ? "" : String(Math.round(value * 100) / 100);
7177
+ const [draft, setDraft] = useState15(shown);
7178
+ useEffect11(() => setDraft(shown), [shown]);
7179
+ const commit = () => {
7180
+ const n = Number.parseFloat(draft);
7181
+ if (Number.isFinite(n) && n !== value) onCommit(n);
7182
+ else setDraft(shown);
7183
+ };
7184
+ const disabled = !property;
7185
+ const sizes = property ? SIZES.filter((n) => n >= (property.min ?? 0) && n <= (property.max ?? Infinity)) : [];
7186
+ return /* @__PURE__ */ jsxs15(DropdownMenu, { modal: false, children: [
7187
+ /* @__PURE__ */ jsx16(Tip, { label: t("Font size"), children: /* @__PURE__ */ jsxs15(
7188
+ "div",
7189
+ {
7190
+ className: cn(
7191
+ "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",
7192
+ disabled && "eb:opacity-40"
7193
+ ),
7194
+ children: [
7195
+ /* @__PURE__ */ jsx16(
7196
+ "input",
7197
+ {
7198
+ type: "text",
7199
+ inputMode: "numeric",
7200
+ 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",
7201
+ "aria-label": t("Font size"),
7202
+ "data-control": "font-size",
7203
+ disabled,
7204
+ value: disabled ? "" : draft,
7205
+ onChange: (event) => setDraft(event.target.value.replace(/[^\d.]/g, "")),
7206
+ onBlur: commit,
7207
+ onKeyDown: (event) => {
7208
+ if (event.key === "Enter") commit();
7209
+ if (event.key === "Escape") setDraft(shown);
7210
+ }
7211
+ }
7212
+ ),
7213
+ /* @__PURE__ */ jsx16(DropdownMenuTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsx16(
7214
+ "button",
7215
+ {
7216
+ type: "button",
7217
+ "aria-label": t("Font sizes"),
7218
+ 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",
7219
+ children: /* @__PURE__ */ jsx16(ChevronDown, { className: "eb:size-3", "aria-hidden": "true" })
7220
+ }
7221
+ ) })
7222
+ ]
7223
+ }
7224
+ ) }),
7225
+ /* @__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: [
7226
+ /* @__PURE__ */ jsx16(Check2, { className: cn("eb:size-3.5", n !== value && "eb:invisible"), "aria-hidden": "true" }),
7227
+ n
7228
+ ] }, n)) })
6759
7229
  ] });
6760
7230
  }
7231
+ function LinkButton({ disabled, href, variables, onApply }) {
7232
+ const { t } = useUi();
7233
+ const [open, setOpen] = useState15(false);
7234
+ const [draft, setDraft] = useState15("");
7235
+ const inputRef = useRef9(null);
7236
+ return /* @__PURE__ */ jsxs15(
7237
+ Popover,
7238
+ {
7239
+ open,
7240
+ onOpenChange: (next) => {
7241
+ if (next) setDraft(href);
7242
+ setOpen(next);
7243
+ },
7244
+ children: [
7245
+ /* @__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" }) }) }) }),
7246
+ /* @__PURE__ */ jsx16(PopoverContent, { align: "start", className: "eb:w-80 eb:p-2", onCloseAutoFocus: (event) => event.preventDefault(), children: /* @__PURE__ */ jsxs15(
7247
+ "form",
7248
+ {
7249
+ className: "eb:flex eb:items-center eb:gap-1.5",
7250
+ noValidate: true,
7251
+ onSubmit: (event) => {
7252
+ event.preventDefault();
7253
+ setOpen(false);
7254
+ if (draft.trim()) onApply(draft.trim());
7255
+ },
7256
+ children: [
7257
+ /* @__PURE__ */ jsxs15("div", { className: "eb:relative eb:min-w-0 eb:flex-1", children: [
7258
+ /* @__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" : "" }),
7259
+ 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 }) })
7260
+ ] }),
7261
+ /* @__PURE__ */ jsx16(Button, { type: "submit", size: "icon-dense", variant: "outline", "aria-label": t("Apply the link"), disabled: !draft.trim(), children: /* @__PURE__ */ jsx16(Check2, {}) })
7262
+ ]
7263
+ }
7264
+ ) })
7265
+ ]
7266
+ }
7267
+ );
7268
+ }
6761
7269
 
6762
7270
  // src/ui/PropertiesPanel.jsx
6763
- import { Fragment as Fragment7, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
7271
+ import { Fragment as Fragment7, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
6764
7272
  var GROUP_ORDER = Object.values(GROUPS);
6765
7273
  function grouped(properties) {
6766
7274
  const map = /* @__PURE__ */ new Map();
@@ -6772,13 +7280,13 @@ function grouped(properties) {
6772
7280
  ([a], [b]) => (GROUP_ORDER.indexOf(a) + 1 || 99) - (GROUP_ORDER.indexOf(b) + 1 || 99)
6773
7281
  );
6774
7282
  }
6775
- function PropertyGroups({ editor, element, block, idPrefix, services = null }) {
7283
+ function PropertyGroups({ editor, element, block, idPrefix, services = null, hidden = null }) {
6776
7284
  const t = useT();
6777
- return grouped(block?.properties || []).map(([group, properties]) => {
7285
+ return grouped((block?.properties || []).filter((property) => !hidden?.has(property.key))).map(([group, properties]) => {
6778
7286
  const box = properties.filter(boxRole);
6779
- return /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
6780
- /* @__PURE__ */ jsx16(SectionLabel, { children: t(group) }),
6781
- box.length > 0 && /* @__PURE__ */ jsx16(
7287
+ return /* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
7288
+ /* @__PURE__ */ jsx17(SectionLabel, { children: t(group) }),
7289
+ box.length > 0 && /* @__PURE__ */ jsx17(
6782
7290
  BoxModel,
6783
7291
  {
6784
7292
  idPrefix,
@@ -6788,7 +7296,7 @@ function PropertyGroups({ editor, element, block, idPrefix, services = null }) {
6788
7296
  },
6789
7297
  `${element.id}:box`
6790
7298
  ),
6791
- properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */ jsx16(
7299
+ properties.filter((property) => !boxRole(property)).map((property) => /* @__PURE__ */ jsx17(
6792
7300
  PropertyField,
6793
7301
  {
6794
7302
  idPrefix,
@@ -6807,31 +7315,31 @@ var LABEL_PROPERTY = { key: "content", label: "Label", type: "text", group: GROU
6807
7315
  var REWRITABLE_TAGS = /* @__PURE__ */ new Set(["mj-text", "mj-button"]);
6808
7316
  function PanelHeader({ title, onClose, closeLabel = "Deselect" }) {
6809
7317
  const t = useT();
6810
- 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: [
6811
- /* @__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 }) }),
6812
- onClose && /* @__PURE__ */ jsx16(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t(closeLabel), children: /* @__PURE__ */ jsx16(X2, {}) })
7318
+ 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: [
7319
+ /* @__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 }) }),
7320
+ onClose && /* @__PURE__ */ jsx17(Button, { variant: "ghost", size: "icon-sm-compact", onClick: onClose, "aria-label": t(closeLabel), children: /* @__PURE__ */ jsx17(X2, {}) })
6813
7321
  ] });
6814
7322
  }
6815
7323
  function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, variables = null, ai = null, onDismiss = null }) {
6816
7324
  const t = useT();
6817
- const subjectRef = useRef9(null);
6818
- const preheaderRef = useRef9(null);
7325
+ const subjectRef = useRef10(null);
7326
+ const preheaderRef = useRef10(null);
6819
7327
  const rootId = editor.getRootId();
6820
7328
  const root = useMemo5(() => rootId ? editor.getElement(rootId) : null, [editor, rootId, changes]);
6821
7329
  const bodyBlock2 = root?.blockId ? editor.getBlock(root.blockId) : null;
6822
7330
  const field = (key) => (e) => onMetaChange({ ...meta, [key]: e.target.value });
6823
- return /* @__PURE__ */ jsxs15(Fragment7, { children: [
6824
- /* @__PURE__ */ jsx16(PanelHeader, { title: t("Email"), onClose: onDismiss, closeLabel: "Close" }),
6825
- /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-4 eb:p-4", children: [
6826
- /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
6827
- /* @__PURE__ */ jsx16(SectionLabel, { children: t("Template") }),
6828
- /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
6829
- /* @__PURE__ */ jsxs15(Label, { htmlFor: "eb-meta-name", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: [
7331
+ return /* @__PURE__ */ jsxs16(Fragment7, { children: [
7332
+ /* @__PURE__ */ jsx17(PanelHeader, { title: t("Email"), onClose: onDismiss, closeLabel: "Close" }),
7333
+ /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-4 eb:p-4", children: [
7334
+ /* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
7335
+ /* @__PURE__ */ jsx17(SectionLabel, { children: t("Template") }),
7336
+ /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
7337
+ /* @__PURE__ */ jsxs16(Label, { htmlFor: "eb-meta-name", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: [
6830
7338
  t("Name"),
6831
7339
  " ",
6832
- /* @__PURE__ */ jsx16("span", { className: "eb:text-destructive", children: "*" })
7340
+ /* @__PURE__ */ jsx17("span", { className: "eb:text-destructive", children: "*" })
6833
7341
  ] }),
6834
- /* @__PURE__ */ jsx16(
7342
+ /* @__PURE__ */ jsx17(
6835
7343
  Input,
6836
7344
  {
6837
7345
  id: "eb-meta-name",
@@ -6842,12 +7350,12 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
6842
7350
  "aria-invalid": showErrors && !meta.name.trim() || void 0
6843
7351
  }
6844
7352
  ),
6845
- showErrors && !meta.name.trim() && /* @__PURE__ */ jsx16("p", { className: "eb:text-[12px] eb:text-destructive", children: t("Name is required") })
7353
+ showErrors && !meta.name.trim() && /* @__PURE__ */ jsx17("p", { className: "eb:text-[12px] eb:text-destructive", children: t("Name is required") })
6846
7354
  ] }),
6847
- /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
6848
- /* @__PURE__ */ jsxs15("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
6849
- /* @__PURE__ */ jsx16(Label, { htmlFor: "eb-meta-subject", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Subject") }),
6850
- variables && /* @__PURE__ */ jsx16(
7355
+ /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
7356
+ /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
7357
+ /* @__PURE__ */ jsx17(Label, { htmlFor: "eb-meta-subject", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Subject") }),
7358
+ variables && /* @__PURE__ */ jsx17(
6851
7359
  VariableInsertButton,
6852
7360
  {
6853
7361
  variables,
@@ -6858,8 +7366,8 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
6858
7366
  }
6859
7367
  )
6860
7368
  ] }),
6861
- /* @__PURE__ */ jsx16(Input, { ref: subjectRef, id: "eb-meta-subject", dense: true, maxLength: 250, value: meta.subject, onChange: field("subject") }),
6862
- ai?.suggestSubjects && /* @__PURE__ */ jsx16(
7369
+ /* @__PURE__ */ jsx17(Input, { ref: subjectRef, id: "eb-meta-subject", dense: true, maxLength: 250, value: meta.subject, onChange: field("subject") }),
7370
+ ai?.suggestSubjects && /* @__PURE__ */ jsx17(
6863
7371
  ai.components.Subjects,
6864
7372
  {
6865
7373
  editor,
@@ -6870,10 +7378,10 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
6870
7378
  }
6871
7379
  )
6872
7380
  ] }),
6873
- /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-1", children: [
6874
- /* @__PURE__ */ jsxs15("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
6875
- /* @__PURE__ */ jsx16(Label, { htmlFor: "eb-meta-preheader", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Preview text") }),
6876
- variables && /* @__PURE__ */ jsx16(
7381
+ /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-1", children: [
7382
+ /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-6 eb:items-center eb:justify-between", children: [
7383
+ /* @__PURE__ */ jsx17(Label, { htmlFor: "eb-meta-preheader", className: "eb:text-[12px] eb:font-normal eb:text-foreground-lighter", children: t("Preview text") }),
7384
+ variables && /* @__PURE__ */ jsx17(
6877
7385
  VariableInsertButton,
6878
7386
  {
6879
7387
  variables,
@@ -6884,7 +7392,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
6884
7392
  }
6885
7393
  )
6886
7394
  ] }),
6887
- /* @__PURE__ */ jsx16(
7395
+ /* @__PURE__ */ jsx17(
6888
7396
  Textarea,
6889
7397
  {
6890
7398
  ref: preheaderRef,
@@ -6899,7 +7407,7 @@ function TemplateSettings({ editor, meta, onMetaChange, changes, showErrors, var
6899
7407
  )
6900
7408
  ] })
6901
7409
  ] }),
6902
- root && bodyBlock2 && /* @__PURE__ */ jsx16(PropertyGroups, { editor, element: root, block: bodyBlock2, idPrefix: "eb-page" })
7410
+ root && bodyBlock2 && /* @__PURE__ */ jsx17(PropertyGroups, { editor, element: root, block: bodyBlock2, idPrefix: "eb-page" })
6903
7411
  ] })
6904
7412
  ] });
6905
7413
  }
@@ -6917,7 +7425,7 @@ function PropertiesPanel({
6917
7425
  }) {
6918
7426
  const t = useT();
6919
7427
  const block = selection?.blockId ? editor.getBlock(selection.blockId) : null;
6920
- 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(
7428
+ 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
7429
  TemplateSettings,
6922
7430
  {
6923
7431
  editor,
@@ -6929,8 +7437,8 @@ function PropertiesPanel({
6929
7437
  ai,
6930
7438
  onDismiss
6931
7439
  }
6932
- ) : /* @__PURE__ */ jsxs15(Fragment7, { children: [
6933
- /* @__PURE__ */ jsx16(
7440
+ ) : /* @__PURE__ */ jsxs16(Fragment7, { children: [
7441
+ /* @__PURE__ */ jsx17(
6934
7442
  PanelHeader,
6935
7443
  {
6936
7444
  title: t(selection.label),
@@ -6938,11 +7446,11 @@ function PropertiesPanel({
6938
7446
  closeLabel: onDismiss ? "Close" : "Deselect"
6939
7447
  }
6940
7448
  ),
6941
- selection.multiple ? /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-3 eb:p-4", children: [
6942
- /* @__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).", {
7449
+ selection.multiple ? /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-3 eb:p-4", children: [
7450
+ /* @__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
7451
  count: selection.multiple
6944
7452
  }) }),
6945
- /* @__PURE__ */ jsxs15(
7453
+ /* @__PURE__ */ jsxs16(
6946
7454
  Button,
6947
7455
  {
6948
7456
  variant: "outline",
@@ -6950,15 +7458,15 @@ function PropertiesPanel({
6950
7458
  onClick: () => editor.remove(selection.id),
6951
7459
  className: "eb:hover:border-destructive/40 eb:hover:bg-destructive/10 eb:hover:text-destructive",
6952
7460
  children: [
6953
- /* @__PURE__ */ jsx16(Trash24, { "aria-hidden": "true" }),
7461
+ /* @__PURE__ */ jsx17(Trash24, { "aria-hidden": "true" }),
6954
7462
  t("Delete")
6955
7463
  ]
6956
7464
  }
6957
7465
  )
6958
- ] }) : /* @__PURE__ */ jsxs15("div", { className: "eb:space-y-4 eb:p-4", children: [
6959
- selection.content !== null && selection.content !== void 0 && /* @__PURE__ */ jsxs15("section", { className: "eb:space-y-3", children: [
6960
- /* @__PURE__ */ jsx16(SectionLabel, { children: t(GROUPS.content) }),
6961
- /* @__PURE__ */ jsx16(
7466
+ ] }) : /* @__PURE__ */ jsxs16("div", { className: "eb:space-y-4 eb:p-4", children: [
7467
+ selection.content !== null && selection.content !== void 0 && /* @__PURE__ */ jsxs16("section", { className: "eb:space-y-3", children: [
7468
+ /* @__PURE__ */ jsx17(SectionLabel, { children: t(GROUPS.content) }),
7469
+ /* @__PURE__ */ jsx17(
6962
7470
  PropertyField,
6963
7471
  {
6964
7472
  idPrefix: "eb-prop",
@@ -6969,16 +7477,16 @@ function PropertiesPanel({
6969
7477
  `${selection.id}:content`
6970
7478
  )
6971
7479
  ] }),
6972
- selection.tagName === "mj-text" && /* @__PURE__ */ jsx16("p", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("Double-click the text to edit it.") }),
6973
- ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */ jsx16(ai.components.Rewrite, { editor, selection, rewrite: ai.rewrite }, selection.id),
6974
- /* @__PURE__ */ jsx16(PropertyGroups, { editor, element: selection, block, idPrefix: "eb-prop", services })
7480
+ selection.tagName === "mj-text" && /* @__PURE__ */ jsx17("p", { className: "eb:text-[12px] eb:text-foreground-muted", children: t("Double-click the text to edit it.") }),
7481
+ ai?.rewrite && REWRITABLE_TAGS.has(selection.tagName) && /* @__PURE__ */ jsx17(ai.components.Rewrite, { editor, selection, rewrite: ai.rewrite }, selection.id),
7482
+ /* @__PURE__ */ jsx17(PropertyGroups, { editor, element: selection, block, idPrefix: "eb-prop", services, hidden: RIBBON_KEYS })
6975
7483
  ] })
6976
7484
  ] }) });
6977
7485
  }
6978
7486
 
6979
7487
  // src/ui/Toolbar.jsx
6980
7488
  import { ArrowLeft, Monitor, Redo2, Smartphone, Undo2 } from "lucide-react";
6981
- import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
7489
+ import { Fragment as Fragment8, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
6982
7490
  function Toolbar({
6983
7491
  title,
6984
7492
  status,
@@ -6995,8 +7503,8 @@ function Toolbar({
6995
7503
  compact = false
6996
7504
  }) {
6997
7505
  const t = useT();
6998
- const identity2 = /* @__PURE__ */ jsxs16(Fragment8, { children: [
6999
- /* @__PURE__ */ jsxs16(
7506
+ const identity2 = /* @__PURE__ */ jsxs17(Fragment8, { children: [
7507
+ /* @__PURE__ */ jsxs17(
7000
7508
  Button,
7001
7509
  {
7002
7510
  variant: "ghost",
@@ -7004,300 +7512,58 @@ function Toolbar({
7004
7512
  onClick: onBack,
7005
7513
  "aria-label": compact ? t("Back") : void 0,
7006
7514
  children: [
7007
- /* @__PURE__ */ jsx17(ArrowLeft, {}),
7515
+ /* @__PURE__ */ jsx18(ArrowLeft, {}),
7008
7516
  !compact && t("Back")
7009
7517
  ]
7010
7518
  }
7011
7519
  ),
7012
- /* @__PURE__ */ jsx17(Separator, { orientation: "vertical", className: "eb:h-5" }),
7013
- /* @__PURE__ */ jsxs16("div", { className: cn("eb:min-w-0 eb:flex-1", !compact && "eb:max-w-[320px]"), children: [
7014
- /* @__PURE__ */ jsx17("p", { className: "eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx17(TruncatedText, { children: title || t("New template") }) }),
7015
- /* @__PURE__ */ jsx17("p", { className: "eb:text-[11px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: status })
7520
+ /* @__PURE__ */ jsx18(Separator, { orientation: "vertical", className: "eb:h-5" }),
7521
+ /* @__PURE__ */ jsxs17("div", { className: cn("eb:min-w-0 eb:flex-1", !compact && "eb:max-w-[320px]"), children: [
7522
+ /* @__PURE__ */ jsx18("p", { className: "eb:text-[13px] eb:font-medium eb:text-foreground", children: /* @__PURE__ */ jsx18(TruncatedText, { children: title || t("New template") }) }),
7523
+ /* @__PURE__ */ jsx18("p", { className: "eb:text-[11px] eb:text-foreground-muted", role: "status", "aria-live": "polite", children: status })
7016
7524
  ] })
7017
7525
  ] });
7018
- const editing = /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: [
7019
- /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:items-center eb:gap-0.5", children: [
7020
- /* @__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, {}) }) }),
7021
- /* @__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, {}) }) })
7526
+ const editing = /* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: [
7527
+ /* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:items-center eb:gap-0.5", children: [
7528
+ /* @__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, {}) }) }),
7529
+ /* @__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
7530
  ] }),
7023
- /* @__PURE__ */ jsx17(Tabs, { value: device, onValueChange: onDeviceChange, children: /* @__PURE__ */ jsxs16(TabsList, { "aria-label": t("Device"), children: [
7024
- /* @__PURE__ */ jsxs16(TabsTrigger, { value: "desktop", disabled: !ready, "aria-label": compact ? t("Desktop") : void 0, children: [
7025
- /* @__PURE__ */ jsx17(Monitor, {}),
7531
+ /* @__PURE__ */ jsx18(Tabs, { value: device, onValueChange: onDeviceChange, children: /* @__PURE__ */ jsxs17(TabsList, { "aria-label": t("Device"), children: [
7532
+ /* @__PURE__ */ jsxs17(TabsTrigger, { value: "desktop", disabled: !ready, "aria-label": compact ? t("Desktop") : void 0, children: [
7533
+ /* @__PURE__ */ jsx18(Monitor, {}),
7026
7534
  !compact && t("Desktop")
7027
7535
  ] }),
7028
- /* @__PURE__ */ jsxs16(TabsTrigger, { value: "mobile", disabled: !ready, "aria-label": compact ? t("Mobile") : void 0, children: [
7029
- /* @__PURE__ */ jsx17(Smartphone, {}),
7536
+ /* @__PURE__ */ jsxs17(TabsTrigger, { value: "mobile", disabled: !ready, "aria-label": compact ? t("Mobile") : void 0, children: [
7537
+ /* @__PURE__ */ jsx18(Smartphone, {}),
7030
7538
  !compact && t("Mobile")
7031
7539
  ] })
7032
7540
  ] }) })
7033
7541
  ] });
7034
7542
  if (compact) {
7035
- return /* @__PURE__ */ jsxs16("div", { className: "eb:shrink-0 eb:border-b eb:border-border", "data-layout": "compact", children: [
7036
- /* @__PURE__ */ jsxs16("div", { className: "eb:flex eb:h-12 eb:items-center eb:gap-2 eb:px-2", children: [
7543
+ return /* @__PURE__ */ jsxs17("div", { className: "eb:shrink-0 eb:border-b eb:border-border", "data-layout": "compact", children: [
7544
+ /* @__PURE__ */ jsxs17("div", { className: "eb:flex eb:h-12 eb:items-center eb:gap-2 eb:px-2", children: [
7037
7545
  identity2,
7038
7546
  primary
7039
7547
  ] }),
7040
- /* @__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: [
7548
+ /* @__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
7549
  editing,
7042
- /* @__PURE__ */ jsx17(Separator, { orientation: "vertical", className: "eb:h-5 eb:shrink-0" }),
7043
- /* @__PURE__ */ jsx17("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: actions })
7550
+ /* @__PURE__ */ jsx18(Separator, { orientation: "vertical", className: "eb:h-5 eb:shrink-0" }),
7551
+ /* @__PURE__ */ jsx18("div", { className: "eb:flex eb:shrink-0 eb:items-center eb:gap-2", children: actions })
7044
7552
  ] })
7045
7553
  ] });
7046
7554
  }
7047
- 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: [
7555
+ 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
7556
  identity2,
7049
7557
  editing,
7050
- /* @__PURE__ */ jsxs16("div", { className: "eb:ml-auto eb:flex eb:items-center eb:gap-2", "data-testid": "eb-toolbar-actions", children: [
7558
+ /* @__PURE__ */ jsxs17("div", { className: "eb:ml-auto eb:flex eb:items-center eb:gap-2", "data-testid": "eb-toolbar-actions", children: [
7051
7559
  actions,
7052
7560
  primary
7053
7561
  ] })
7054
7562
  ] });
7055
7563
  }
7056
7564
 
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
7565
  // src/ui/CanvasPanel.jsx
7300
- import { useEffect as useEffect12, useRef as useRef10, useState as useState16 } from "react";
7566
+ import { useEffect as useEffect12, useRef as useRef11, useState as useState16 } from "react";
7301
7567
  import { X as X3 } from "lucide-react";
7302
7568
  import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
7303
7569
  function CanvasPanel({ feature, context, compact, onClose }) {
@@ -7314,7 +7580,7 @@ function CanvasPanel({ feature, context, compact, onClose }) {
7314
7580
  const frame = requestAnimationFrame(() => setWide(true));
7315
7581
  return () => cancelAnimationFrame(frame);
7316
7582
  }, [open]);
7317
- const ref = useRef10(
7583
+ const ref = useRef11(
7318
7584
  /** @type {HTMLDivElement|null} */
7319
7585
  null
7320
7586
  );
@@ -7390,7 +7656,7 @@ function Drawer({ open, side = "left", title, onClose, children, testId, header:
7390
7656
  }
7391
7657
 
7392
7658
  // src/ui/useEmailEditorState.js
7393
- import { useCallback as useCallback2, useEffect as useEffect14, useRef as useRef11, useState as useState17 } from "react";
7659
+ import { useCallback as useCallback2, useEffect as useEffect14, useRef as useRef12, useState as useState17 } from "react";
7394
7660
  var DIRTY_CHECK_MS = 150;
7395
7661
  function useEmailEditorState(editor) {
7396
7662
  const [state, setState] = useState17(() => ({
@@ -7403,9 +7669,9 @@ function useEmailEditorState(editor) {
7403
7669
  changes: 0,
7404
7670
  dirty: false
7405
7671
  }));
7406
- const clean = useRef11(null);
7407
- const forced = useRef11(false);
7408
- const timer = useRef11(null);
7672
+ const clean = useRef12(null);
7673
+ const forced = useRef12(false);
7674
+ const timer = useRef12(null);
7409
7675
  const snapshot = useCallback2(() => {
7410
7676
  try {
7411
7677
  return editor.status === "ready" ? editor.exportMjml() : null;
@@ -7476,18 +7742,19 @@ function useEmailEditorState(editor) {
7476
7742
  }
7477
7743
 
7478
7744
  // src/ui/SidePanel.jsx
7479
- import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef12, useState as useState18 } from "react";
7745
+ import { useCallback as useCallback3, useEffect as useEffect15, useRef as useRef13, useState as useState18 } from "react";
7480
7746
  import { ChevronLeft, ChevronRight } from "lucide-react";
7481
7747
  import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
7482
7748
  var SIDE_PANELS = {
7483
- // Three blocks in a row.
7484
- blocks: { width: 328, min: 200, max: 480 },
7749
+ // Two blocks in a row: wider, the row takes three.
7750
+ blocks: { width: 272, min: 200, max: 480 },
7485
7751
  properties: { width: 416, min: 296, max: 640 }
7486
7752
  };
7487
7753
  var RAIL_WIDTH = 40;
7488
7754
  var FOLD_MS = 350;
7489
7755
  var CANVAS_MIN = { wide: 640, medium: 480 };
7490
7756
  var STORAGE_KEY = "best-email-builder:side-panels";
7757
+ var FORMER_BLOCKS_WIDTH = 328;
7491
7758
  var EDGE2 = { left: "eb:right-0 eb:translate-x-1/2", right: "eb:left-0 eb:-translate-x-1/2" };
7492
7759
  var KEY_STEP = 16;
7493
7760
  var clamp2 = (value, min, max) => Math.min(max, Math.max(min, value));
@@ -7507,7 +7774,7 @@ function initialPanels() {
7507
7774
  const entry = saved?.[name];
7508
7775
  if (!entry) continue;
7509
7776
  const { min, max } = SIDE_PANELS[name];
7510
- if (Number.isFinite(entry.width)) panels[name].width = clamp2(entry.width, min, max);
7777
+ if (Number.isFinite(entry.width) && !(name === "blocks" && entry.width === FORMER_BLOCKS_WIDTH)) panels[name].width = clamp2(entry.width, min, max);
7511
7778
  panels[name].collapsed = entry.collapsed === true;
7512
7779
  }
7513
7780
  } catch {
@@ -7520,7 +7787,7 @@ function useSidePanels() {
7520
7787
  /** @type {Partial<Record<keyof typeof SIDE_PANELS, true>>} */
7521
7788
  {}
7522
7789
  );
7523
- const timers = useRef12(
7790
+ const timers = useRef13(
7524
7791
  /** @type {Partial<Record<keyof typeof SIDE_PANELS, ReturnType<typeof setTimeout>>>} */
7525
7792
  {}
7526
7793
  );
@@ -7546,11 +7813,11 @@ function panelTrack(state, name) {
7546
7813
  }
7547
7814
  var FOLD_TRANSITION = "eb:transition-[grid-template-columns] eb:duration-[350ms] eb:ease-in-out";
7548
7815
  function SidePanel({ name, side, state, moving = false, onChange, room, labels, children }) {
7549
- const ref = useRef12(
7816
+ const ref = useRef13(
7550
7817
  /** @type {HTMLDivElement|null} */
7551
7818
  null
7552
7819
  );
7553
- const drag = useRef12(
7820
+ const drag = useRef13(
7554
7821
  /** @type {{x: number, width: number, max: number}|null} */
7555
7822
  null
7556
7823
  );
@@ -7694,10 +7961,10 @@ function Builder({
7694
7961
  className
7695
7962
  }) {
7696
7963
  const { t, locale, notify, confirm } = useUi();
7697
- const tRef = useRef13(t);
7964
+ const tRef = useRef14(t);
7698
7965
  tRef.current = t;
7699
7966
  const storage = useMemo6(() => injectedStorage || createHttpStorage(), [injectedStorage]);
7700
- const storageRef = useRef13(storage);
7967
+ const storageRef = useRef14(storage);
7701
7968
  storageRef.current = storage;
7702
7969
  const editor = useMemo6(
7703
7970
  () => injected || createDefaultEmailEditor({
@@ -7751,12 +8018,12 @@ function Builder({
7751
8018
  const [autosaveBlocked, setAutosaveBlocked] = useState19(null);
7752
8019
  const [engineError, setEngineError] = useState19(null);
7753
8020
  const [attempt, setAttempt] = useState19(0);
7754
- const rootRef = useRef13(null);
8021
+ const rootRef = useRef14(null);
7755
8022
  const layout2 = useLayoutWidth(rootRef);
7756
8023
  const compact = layout2 !== "wide";
7757
8024
  const blocksInDrawer = layout2 === "narrow";
7758
8025
  const { panels, update: updatePanel, moving: movingPanels } = useSidePanels();
7759
- const gridRef = useRef13(null);
8026
+ const gridRef = useRef14(null);
7760
8027
  const [drawer, setDrawer] = useState19(null);
7761
8028
  const closeDrawer = useCallback4(() => setDrawer(null), []);
7762
8029
  const [canvasPanel, setCanvasPanel] = useState19(null);
@@ -7771,7 +8038,7 @@ function Builder({
7771
8038
  (date) => date ? new Date(date).toLocaleTimeString(locale, { hour: "2-digit", minute: "2-digit" }) : "",
7772
8039
  [locale]
7773
8040
  );
7774
- const booted = useRef13(false);
8041
+ const booted = useRef14(false);
7775
8042
  useEffect16(() => {
7776
8043
  if (booted.current) return;
7777
8044
  booted.current = true;
@@ -7839,7 +8106,7 @@ function Builder({
7839
8106
  () => editor.status === "ready" && checkDirty() || metaDirty,
7840
8107
  [editor, checkDirty, metaDirty]
7841
8108
  );
7842
- const reportDirty = useRef13(onDirtyChange);
8109
+ const reportDirty = useRef14(onDirtyChange);
7843
8110
  reportDirty.current = onDirtyChange;
7844
8111
  useEffect16(() => {
7845
8112
  reportDirty.current?.(dirty);
@@ -7860,8 +8127,8 @@ function Builder({
7860
8127
  window.addEventListener("beforeunload", warn);
7861
8128
  return () => window.removeEventListener("beforeunload", warn);
7862
8129
  }, [dirty]);
7863
- const savingRef = useRef13(false);
7864
- const latest = useRef13({});
8130
+ const savingRef = useRef14(false);
8131
+ const latest = useRef14({});
7865
8132
  latest.current = { template, meta, onSaved, compact };
7866
8133
  const save = useCallback4(
7867
8134
  async ({ auto = false } = {}) => {
@@ -8134,6 +8401,7 @@ function Builder({
8134
8401
  ready,
8135
8402
  selection: state.selection,
8136
8403
  format: state.format,
8404
+ variables,
8137
8405
  drawers: panelFeatures.map((feature) => ({ id: feature.id, ...feature.drawer })),
8138
8406
  openDrawer: openPanel?.id ?? null,
8139
8407
  onToggleDrawer: (id) => setCanvasPanel((current) => current === id ? null : id)
@@ -8313,4 +8581,4 @@ export {
8313
8581
  EmailBuilder,
8314
8582
  EmailBuilderBoundary
8315
8583
  };
8316
- //# sourceMappingURL=chunk-W4UKDEB4.js.map
8584
+ //# sourceMappingURL=chunk-ACJQTHMG.js.map