@forgeroute/ui 0.5.38 โ†’ 0.5.40

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.
@@ -10,7 +10,6 @@ import { DividerComponent } from "@forgeroute/ui/divider";
10
10
  import { DateInputComponent } from "@forgeroute/ui/date-input";
11
11
  import { EmptyStateComponent } from "@forgeroute/ui/empty-state";
12
12
  import { ErrorComponent } from "@forgeroute/ui/error";
13
- import { PillTabsComponent } from "@forgeroute/ui/pill-tabs";
14
13
  import { RadioGroupComponent } from "@forgeroute/ui/radio";
15
14
  import { SearchInputComponent } from "@forgeroute/ui/search-input";
16
15
  import { SelectComponent } from "@forgeroute/ui/select";
@@ -1801,9 +1800,10 @@ const DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS = [{
1801
1800
  }
1802
1801
  ]
1803
1802
  }];
1803
+ const EMAIL_DEFAULT_FONT = "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif";
1804
1804
  function buildPreviewDocument(bodyHtml, brand) {
1805
1805
  const b = safePreviewBrand(brand);
1806
- const font = b.fontFamily ?? "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif";
1806
+ const font = b.fontFamily ?? "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif";
1807
1807
  const head = b.logoUrl || b.companyName ? "<div class=\"brand-head\">" + (b.logoUrl ? `<img src="${escapeHtml(b.logoUrl)}" alt="">` : "") + (b.companyName ? `<span>${escapeHtml(b.companyName)}</span>` : "") + "</div>" : "";
1808
1808
  const foot = b.footerText ? `<div class="brand-foot">${escapeHtml(b.footerText).replace(/\r?\n/g, "<br>")}</div>` : "";
1809
1809
  return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src * data:; style-src 'unsafe-inline'; font-src data:"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0}body{padding:24px 28px;font:15px/1.6 ${font};color:${b.textColor ?? "#1e293b"};${b.backgroundColor ? `background:${b.backgroundColor};` : ""}overflow-wrap:anywhere}p{margin:0 0 8px}img{max-width:100%}table{max-width:100%}a{color:${b.linkColor ?? "#3b82f6"}}.brand-head{display:flex;align-items:center;gap:12px;margin:0 0 16px;font-weight:600}.brand-head img{max-height:48px;width:auto}.brand-foot{margin:24px 0 0;padding-top:12px;border-top:1px solid rgba(100,116,139,.35);font-size:12px;line-height:1.5;color:#64748b}</style></head><body>${head}${bodyHtml}${foot}</body></html>`;
@@ -1869,6 +1869,232 @@ function localizedEmailVariableGroups() {
1869
1869
  }))
1870
1870
  }));
1871
1871
  }
1872
+ const EMAIL_EMOJI_GROUP_KEYS = [
1873
+ {
1874
+ key: "smileys",
1875
+ icon: "๐Ÿ˜€"
1876
+ },
1877
+ {
1878
+ key: "gestures",
1879
+ icon: "๐Ÿ‘‹"
1880
+ },
1881
+ {
1882
+ key: "hearts",
1883
+ icon: "โค๏ธ"
1884
+ },
1885
+ {
1886
+ key: "remembrance",
1887
+ icon: "๐Ÿ•Š๏ธ"
1888
+ },
1889
+ {
1890
+ key: "pets",
1891
+ icon: "๐Ÿถ"
1892
+ },
1893
+ {
1894
+ key: "nature",
1895
+ icon: "๐ŸŒณ"
1896
+ },
1897
+ {
1898
+ key: "food",
1899
+ icon: "๐ŸŽ"
1900
+ },
1901
+ {
1902
+ key: "places",
1903
+ icon: "๐Ÿš—"
1904
+ },
1905
+ {
1906
+ key: "objects",
1907
+ icon: "๐Ÿ’ก"
1908
+ },
1909
+ {
1910
+ key: "symbols",
1911
+ icon: "โœ…"
1912
+ }
1913
+ ];
1914
+ const EMAIL_SKIN_TONES = [
1915
+ {
1916
+ key: "default",
1917
+ modifier: "",
1918
+ swatch: "๐Ÿ‘‹"
1919
+ },
1920
+ {
1921
+ key: "light",
1922
+ modifier: "๐Ÿป",
1923
+ swatch: "๐Ÿ‘‹๐Ÿป"
1924
+ },
1925
+ {
1926
+ key: "mediumLight",
1927
+ modifier: "๐Ÿผ",
1928
+ swatch: "๐Ÿ‘‹๐Ÿผ"
1929
+ },
1930
+ {
1931
+ key: "medium",
1932
+ modifier: "๐Ÿฝ",
1933
+ swatch: "๐Ÿ‘‹๐Ÿฝ"
1934
+ },
1935
+ {
1936
+ key: "mediumDark",
1937
+ modifier: "๐Ÿพ",
1938
+ swatch: "๐Ÿ‘‹๐Ÿพ"
1939
+ },
1940
+ {
1941
+ key: "dark",
1942
+ modifier: "๐Ÿฟ",
1943
+ swatch: "๐Ÿ‘‹๐Ÿฟ"
1944
+ }
1945
+ ];
1946
+ const EMAIL_EMOJIS = Object.entries({
1947
+ smileys: "๐Ÿ˜€ grinning happy;๐Ÿ˜ƒ smile happy open;๐Ÿ˜„ smile happy eyes;๐Ÿ˜ grin beaming;๐Ÿ˜† laugh squint;๐Ÿ˜… sweat smile relief;๐Ÿคฃ rofl laughing floor;๐Ÿ˜‚ joy tears laughing;๐Ÿ™‚ slight smile;๐Ÿ™ƒ upside down;๐Ÿ˜‰ wink;๐Ÿ˜Š blush smile;๐Ÿ˜‡ angel halo innocent;๐Ÿฅฐ love hearts adore;๐Ÿ˜ heart eyes love;๐Ÿคฉ star struck wow;๐Ÿ˜˜ kiss blow;๐Ÿ˜— kiss;๐Ÿ˜š kiss closed eyes;๐Ÿ˜‹ yum tasty;๐Ÿ˜› tongue;๐Ÿ˜œ wink tongue;๐Ÿคช zany crazy;๐Ÿค— hug;๐Ÿคญ giggle oops;๐Ÿค” thinking hmm;๐Ÿค zipper quiet;๐Ÿ˜ neutral;๐Ÿ˜‘ expressionless;๐Ÿ˜ถ no mouth silent;๐Ÿ˜ smirk;๐Ÿ˜’ unamused;๐Ÿ™„ eye roll;๐Ÿ˜ฌ grimace;๐Ÿ˜Œ relieved calm;๐Ÿ˜” pensive sad;๐Ÿ˜ช sleepy;๐Ÿ˜ด sleeping zzz;๐Ÿ˜ท mask sick;๐Ÿค’ thermometer sick fever;๐Ÿค• bandage hurt;๐Ÿคข nauseated;๐Ÿฅต hot;๐Ÿฅถ cold freezing;๐Ÿฅด woozy;๐Ÿ˜ต dizzy;๐Ÿคฏ mind blown;๐Ÿค  cowboy;๐Ÿฅณ party celebrate;๐Ÿ˜Ž cool sunglasses;๐Ÿค“ nerd;๐Ÿง monocle;๐Ÿ˜• confused;๐Ÿ˜Ÿ worried;๐Ÿ™ frown;โ˜น๏ธ frowning;๐Ÿ˜ฎ surprised open mouth;๐Ÿ˜ฏ hushed;๐Ÿ˜ฒ astonished;๐Ÿ˜ณ flushed embarrassed;๐Ÿฅบ pleading puppy eyes;๐Ÿ˜ฆ frown open;๐Ÿ˜ง anguished;๐Ÿ˜จ fearful;๐Ÿ˜ฐ anxious sweat;๐Ÿ˜ฅ sad relieved;๐Ÿ˜ข cry tear;๐Ÿ˜ญ sob crying;๐Ÿ˜ฑ scream fear;๐Ÿ˜– confounded;๐Ÿ˜ฃ persevere;๐Ÿ˜ž disappointed;๐Ÿ˜“ downcast sweat;๐Ÿ˜ฉ weary;๐Ÿ˜ซ tired;๐Ÿฅฑ yawn;๐Ÿ˜ค triumph huff;๐Ÿ˜ก angry pouting;๐Ÿ˜  angry;๐Ÿคฌ cursing swearing;๐Ÿ˜ˆ devil smile;๐Ÿ‘ฟ imp angry;๐Ÿ’€ skull;โ˜ ๏ธ skull crossbones;๐Ÿ’ฉ poop;๐Ÿคก clown;๐Ÿ‘ป ghost;๐Ÿ‘ฝ alien;๐Ÿค– robot",
1948
+ gestures: "๐Ÿ‘‹+ wave hello hi goodbye;๐Ÿคš+ raised back hand;๐Ÿ–๏ธ+ hand fingers splayed;โœ‹+ raised hand stop high five;๐Ÿ‘Œ+ ok hand perfect;๐ŸคŒ+ pinched fingers;โœŒ๏ธ+ victory peace;๐Ÿคž+ crossed fingers luck;๐ŸคŸ+ love you gesture;๐Ÿค˜+ rock horns;๐Ÿ‘ˆ+ point left;๐Ÿ‘‰+ point right;๐Ÿ‘†+ point up;๐Ÿ‘‡+ point down;โ˜๏ธ+ index up;๐Ÿ‘+ thumbs up yes like approve;๐Ÿ‘Ž+ thumbs down no dislike;โœŠ+ raised fist;๐Ÿ‘Š+ fist bump;๐Ÿ‘+ clap applause;๐Ÿ™Œ+ raising hands celebrate praise;๐Ÿ‘+ open hands;๐Ÿคฒ+ palms up together;๐Ÿค handshake agreement deal;๐Ÿ™+ pray thanks please folded hands;โœ๏ธ+ writing hand;๐Ÿ’…+ nail polish;๐Ÿคณ+ selfie;๐Ÿ’ช+ muscle strong flex;๐Ÿซถ+ heart hands love;๐Ÿซ‚ people hugging comfort;๐Ÿ‘‚+ ear listen;๐Ÿ‘€ eyes look;๐Ÿง  brain;๐Ÿซ€ heart organ",
1949
+ hearts: "โค๏ธ red heart love;๐Ÿงก orange heart;๐Ÿ’› yellow heart;๐Ÿ’š green heart;๐Ÿ’™ blue heart;๐Ÿ’œ purple heart;๐ŸคŽ brown heart;๐Ÿ–ค black heart;๐Ÿค white heart;๐Ÿ’” broken heart;โฃ๏ธ heart exclamation;๐Ÿ’• two hearts;๐Ÿ’ž revolving hearts;๐Ÿ’“ beating heart;๐Ÿ’— growing heart;๐Ÿ’– sparkling heart;๐Ÿ’˜ heart arrow cupid;๐Ÿ’ heart ribbon gift;โค๏ธโ€๐Ÿฉน mending heart healing;โœจ sparkles shine;โญ star;๐ŸŒŸ glowing star;๐Ÿ’ซ dizzy star;๐Ÿ”ฅ fire hot;๐Ÿ’ฅ collision boom;๐ŸŽ‰ party popper celebrate;๐ŸŽŠ confetti",
1950
+ remembrance: "๐Ÿ•Š๏ธ dove peace;๐Ÿ•ฏ๏ธ candle remember;๐ŸŒน rose flower;๐Ÿฅ€ wilted flower;๐ŸŒท tulip;๐ŸŒธ cherry blossom;๐ŸŒบ hibiscus;๐Ÿ’ bouquet flowers;๐ŸŒป sunflower;๐ŸŒผ blossom;๐Ÿชท lotus;๐Ÿต๏ธ rosette;๐ŸŒฟ herb leaf;๐Ÿƒ leaves wind;๐Ÿ‚ fallen leaf autumn;๐ŸŒˆ rainbow;โ˜€๏ธ sun;๐ŸŒ… sunrise;๐ŸŒ„ sunrise mountains;๐ŸŒ™ moon crescent;โญ star night;๐ŸŒ  shooting star wish;โ˜๏ธ cloud;๐ŸŒค๏ธ sun behind cloud;โšฑ๏ธ urn funeral;๐Ÿชฆ headstone grave;โ›ช church;โœ๏ธ cross;โ˜ช๏ธ star crescent;๐Ÿ•‰๏ธ om;โœก๏ธ star of david;โ˜ฎ๏ธ peace symbol;๐Ÿ™ praying thanks;๐Ÿซถ heart hands;๐Ÿค white heart;๐Ÿ‘ผ baby angel;๐Ÿ˜‡ angel;๐Ÿงฟ nazar;๐Ÿชฝ wing",
1951
+ pets: "๐Ÿถ dog face;๐Ÿ• dog;๐Ÿฆฎ guide dog;๐Ÿ•โ€๐Ÿฆบ service dog;๐Ÿฉ poodle;๐Ÿบ wolf;๐Ÿฑ cat face;๐Ÿˆ cat;๐Ÿˆโ€โฌ› black cat;๐Ÿฆ lion;๐Ÿฏ tiger;๐Ÿด horse face;๐ŸŽ horse;๐Ÿฆ„ unicorn;๐Ÿฐ rabbit face;๐Ÿ‡ rabbit;๐Ÿน hamster;๐Ÿญ mouse;๐Ÿ€ rat;๐Ÿฟ๏ธ chipmunk squirrel;๐Ÿฆ” hedgehog;๐Ÿฆ bird;๐Ÿฆœ parrot;๐Ÿฆ† duck;๐Ÿฆข swan;๐Ÿ•Š๏ธ dove;๐Ÿข turtle;๐Ÿ snake;๐ŸฆŽ lizard;๐Ÿ  tropical fish;๐ŸŸ fish;๐Ÿก blowfish;๐Ÿพ paw prints;๐Ÿฆด bone;๐Ÿฎ cow;๐Ÿท pig;๐Ÿ‘ sheep;๐Ÿ goat;๐Ÿ“ rooster;๐Ÿฃ chick;๐Ÿป bear;๐Ÿผ panda;๐ŸฆŠ fox;๐Ÿฆ raccoon;๐Ÿจ koala;๐Ÿฆ‹ butterfly;๐Ÿ bee;๐Ÿž ladybug",
1952
+ nature: "๐ŸŒณ tree;๐ŸŒฒ evergreen;๐ŸŒด palm;๐ŸŒต cactus;๐ŸŒพ grain;๐Ÿ€ clover luck;๐Ÿ maple leaf;๐ŸŒฑ seedling grow;๐Ÿชด plant;๐ŸŒ earth;๐ŸŒŠ wave ocean;โ›ฐ๏ธ mountain;๐Ÿ”๏ธ snow mountain;๐ŸŒ‹ volcano;๐Ÿž๏ธ park;๐Ÿ–๏ธ beach;๐ŸŒง๏ธ rain;โ›ˆ๏ธ storm;โ„๏ธ snowflake;โ›„ snowman;๐ŸŒฌ๏ธ wind;๐Ÿ’ง drop water;๐Ÿ”† bright;๐ŸŒŒ milky way night;๐Ÿช planet",
1953
+ food: "๐ŸŽ apple;๐Ÿ pear;๐ŸŠ orange;๐Ÿ‹ lemon;๐ŸŒ banana;๐Ÿ‰ watermelon;๐Ÿ‡ grapes;๐Ÿ“ strawberry;๐Ÿ’ cherries;๐Ÿ‘ peach;๐Ÿฅญ mango;๐Ÿ pineapple;๐Ÿฅ kiwi;๐Ÿ… tomato;๐Ÿฅ‘ avocado;๐Ÿฅ• carrot;๐ŸŒฝ corn;๐Ÿฅ croissant;๐Ÿž bread;๐Ÿง€ cheese;๐Ÿณ egg cooking;๐Ÿฅž pancakes;๐Ÿ” burger;๐Ÿ• pizza;๐ŸŒฎ taco;๐Ÿฅ— salad;๐Ÿ pasta;๐Ÿฐ cake;๐ŸŽ‚ birthday cake;๐Ÿช cookie;๐Ÿซ chocolate;๐Ÿฉ donut;โ˜• coffee;๐Ÿต tea;๐Ÿท wine;๐Ÿฅ‚ cheers toast;๐Ÿฝ๏ธ plate dinner",
1954
+ places: "๐Ÿ  house home;๐Ÿก house garden;๐Ÿข office building;๐Ÿฅ hospital;๐Ÿ›๏ธ classical building;โ›ช church;๐Ÿ•Œ mosque;๐Ÿ• synagogue;๐Ÿซ school;๐Ÿจ hotel;๐Ÿช store;๐Ÿš— car;๐Ÿš™ suv;๐Ÿš van;๐Ÿšš truck delivery;๐Ÿš‘ ambulance;๐Ÿš“ police;๐Ÿšฒ bicycle;โœˆ๏ธ airplane;๐Ÿš† train;๐Ÿšข ship;๐Ÿ“ pin location;๐Ÿ—บ๏ธ map;๐Ÿงญ compass;๐Ÿ›ฃ๏ธ road;๐ŸŒ‰ bridge;๐ŸŒ† city;๐ŸŒ‡ sunset city;โ›บ camping;๐Ÿ“ž phone call;๐Ÿ“ฑ mobile phone;โ˜Ž๏ธ telephone;๐Ÿ“ง email;โœ‰๏ธ envelope mail;๐Ÿ“ฎ mailbox;๐Ÿ“ฌ mail",
1955
+ objects: "๐Ÿ’ก idea light bulb;๐Ÿ”” bell notification;๐Ÿ”• bell off;๐Ÿ“… calendar date;๐Ÿ—“๏ธ calendar spiral;โฐ alarm clock;โฑ๏ธ stopwatch;๐Ÿ• clock;โŒ› hourglass;๐Ÿ“„ document page;๐Ÿ“‹ clipboard;๐Ÿ“ memo note write;๐Ÿ“ folder;๐Ÿ“Ž paperclip attach;๐Ÿ“Œ pushpin;โœ‚๏ธ scissors;๐Ÿ”’ lock secure;๐Ÿ”“ unlock;๐Ÿ”‘ key;๐Ÿ’ณ credit card payment;๐Ÿ’ต dollar money;๐Ÿ’ฐ money bag;๐Ÿงพ receipt;๐Ÿ“ฆ package box;๐ŸŽ gift present;๐ŸŽ—๏ธ ribbon remembrance;๐Ÿ† trophy;๐ŸŽ–๏ธ medal;๐Ÿ“ท camera photo;๐ŸŽฅ movie camera;๐ŸŽต music note;๐Ÿ“ฃ megaphone announce;๐Ÿ” magnifying glass search;๐Ÿ› ๏ธ tools;โš™๏ธ gear settings;๐Ÿงฐ toolbox;๐Ÿ“Š chart;๐Ÿ“ˆ chart up;๐Ÿ–Š๏ธ pen;๐Ÿ–‹๏ธ fountain pen;๐Ÿ“– book;๐Ÿ“š books;๐ŸŽ“ graduation;๐Ÿชช id card;๐Ÿ›ก๏ธ shield",
1956
+ symbols: "โœ… check yes done;โ˜‘๏ธ checked box;โœ”๏ธ check mark;โŒ cross no;โŽ cross button;โš ๏ธ warning;โ„น๏ธ information;โ“ question;โ— exclamation;โ€ผ๏ธ double exclamation;โž• plus;โž– minus;โžก๏ธ arrow right;โฌ…๏ธ arrow left;โฌ†๏ธ arrow up;โฌ‡๏ธ arrow down;โ†ฉ๏ธ return;๐Ÿ”„ refresh;๐Ÿ”— link;โ™ป๏ธ recycle;๐Ÿ’ฏ hundred;๐Ÿ†— ok;๐Ÿ†• new;๐Ÿ”ด red circle;๐ŸŸ  orange circle;๐ŸŸก yellow circle;๐ŸŸข green circle;๐Ÿ”ต blue circle;๐ŸŸฃ purple circle;โšซ black circle;โšช white circle;โ–ถ๏ธ play;โธ๏ธ pause;๐Ÿ”Š sound;๐Ÿ”‡ mute;๐Ÿ finish flag;๐Ÿšฉ flag;ยฉ๏ธ copyright;ยฎ๏ธ registered;โ„ข๏ธ trademark"
1957
+ }).flatMap(([group, table]) => table.split(";").map((entry) => {
1958
+ const space = entry.indexOf(" ");
1959
+ const head = entry.slice(0, space);
1960
+ const tone = head.endsWith("+");
1961
+ return {
1962
+ char: tone ? head.slice(0, -1) : head,
1963
+ words: entry.slice(space + 1),
1964
+ group,
1965
+ tone
1966
+ };
1967
+ }));
1968
+ function findEmojis(search, group) {
1969
+ const fold = (t) => t.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
1970
+ const terms = fold(search).split(/\s+/).filter(Boolean);
1971
+ if (terms.length === 0) return EMAIL_EMOJIS.filter((e) => e.group === group);
1972
+ return EMAIL_EMOJIS.filter((e) => terms.every((t) => fold(e.words).includes(t)));
1973
+ }
1974
+ function withSkinTone(emoji, modifier) {
1975
+ if (!emoji.tone || !modifier) return emoji.char;
1976
+ return Array.from(emoji.char)[0] + modifier;
1977
+ }
1978
+ const EMAIL_SPECIAL_CHARACTERS = [
1979
+ "ยฉ",
1980
+ "ยฎ",
1981
+ "โ„ข",
1982
+ "ยฐ",
1983
+ "ยฑ",
1984
+ "ร—",
1985
+ "รท",
1986
+ "โ€ข",
1987
+ "ยท",
1988
+ "โ€“",
1989
+ "โ€”",
1990
+ "โ€ฆ",
1991
+ "โ€˜",
1992
+ "โ€™",
1993
+ "โ€œ",
1994
+ "โ€",
1995
+ "ยซ",
1996
+ "ยป",
1997
+ "โ€น",
1998
+ "โ€บ",
1999
+ "โ‚ฌ",
2000
+ "ยฃ",
2001
+ "ยฅ",
2002
+ "ยข",
2003
+ "$",
2004
+ "ยง",
2005
+ "ยถ",
2006
+ "โ€ ",
2007
+ "โ€ก",
2008
+ "โ€ฐ",
2009
+ "โ„–",
2010
+ "โ†",
2011
+ "โ†’",
2012
+ "โ†‘",
2013
+ "โ†“",
2014
+ "โ†”",
2015
+ "โ‡’",
2016
+ "โ‡",
2017
+ "โœ“",
2018
+ "โœ”",
2019
+ "โœ—",
2020
+ "โœ˜",
2021
+ "โ˜…",
2022
+ "โ˜†",
2023
+ "โ™ฅ",
2024
+ "โ™ฆ",
2025
+ "โ™ฃ",
2026
+ "โ™ ",
2027
+ "โ™ช",
2028
+ "โ˜Ž",
2029
+ "โœ‰",
2030
+ "โœ†",
2031
+ "ยฝ",
2032
+ "โ…“",
2033
+ "ยผ",
2034
+ "ยพ",
2035
+ "ยฒ",
2036
+ "ยณ",
2037
+ "ยน",
2038
+ "ยต",
2039
+ "ฮฑ",
2040
+ "ฮฒ",
2041
+ "ฯ€",
2042
+ "ฮฉ",
2043
+ "โˆž",
2044
+ "โ‰ˆ",
2045
+ "โ‰ ",
2046
+ "โ‰ค",
2047
+ "โ‰ฅ",
2048
+ "โˆš",
2049
+ "โˆ‘",
2050
+ "รก",
2051
+ "รฉ",
2052
+ "รญ",
2053
+ "รณ",
2054
+ "รบ",
2055
+ "รฑ",
2056
+ "รผ",
2057
+ "ร",
2058
+ "ร‰",
2059
+ "ร",
2060
+ "ร“",
2061
+ "รš",
2062
+ "ร‘",
2063
+ "รœ",
2064
+ "ยฟ",
2065
+ "ยก",
2066
+ "รง",
2067
+ "รฃ",
2068
+ "รต",
2069
+ "รช",
2070
+ "รจ",
2071
+ "ร ",
2072
+ "รข",
2073
+ "รด"
2074
+ ];
2075
+ const DOCUMENT_STYLES = `
2076
+ .tpl-doc p { margin: 0 0 8px; }
2077
+ .tpl-doc h1 { font-size: 2em; font-weight: bold; margin: 0.67em 0; color: #1e293b; }
2078
+ .tpl-doc h2 { font-size: 1.5em; font-weight: bold; margin: 0.83em 0; color: #1e293b; }
2079
+ .tpl-doc h3 { font-size: 1.17em; font-weight: bold; margin: 1em 0; color: #1e293b; }
2080
+ .tpl-doc h4 { font-size: 1em; font-weight: bold; margin: 1.33em 0; }
2081
+ .tpl-doc blockquote { margin: 1em 0; padding: 4px 16px; border-left: 4px solid #cbd5e1; color: #475569; }
2082
+ .tpl-doc table { border-collapse: collapse; width: 100%; margin: 8px 0; }
2083
+ .tpl-doc td, .tpl-doc th { border: 1px solid #cbd5e1; padding: 8px; vertical-align: top; min-width: 24px; }
2084
+ .tpl-doc hr { border: 0; border-top: 1px solid #cbd5e1; margin: 16px 0; }
2085
+ .tpl-doc a { color: #3b82f6; }
2086
+ .tpl-doc img { max-width: 100%; border-radius: 6px; }
2087
+ .tpl-doc ul, .tpl-doc ol { padding-left: 40px; margin: 1em 0; }
2088
+ .tpl-doc ul { list-style-type: disc; }
2089
+ .tpl-doc ol { list-style-type: decimal; }
2090
+ `;
2091
+ function ensureDocumentStyles() {
2092
+ if (typeof document === "undefined" || document.head.querySelector("style[data-tpl-doc-styles]")) return;
2093
+ const style = document.createElement("style");
2094
+ style.setAttribute("data-tpl-doc-styles", "");
2095
+ style.textContent = DOCUMENT_STYLES;
2096
+ document.head.appendChild(style);
2097
+ }
1872
2098
  const FONT_SIZE_OPTIONS = [
1873
2099
  "10",
1874
2100
  "12",
@@ -1884,10 +2110,51 @@ const FONT_SIZE_OPTIONS = [
1884
2110
  value: `${n}px`,
1885
2111
  label: `${n}px`
1886
2112
  }));
1887
- const BLOCK_BASE_PADDING_PX = 12;
2113
+ const COLOR_SWATCHES = [
2114
+ "#000000",
2115
+ "#1e293b",
2116
+ "#475569",
2117
+ "#64748b",
2118
+ "#94a3b8",
2119
+ "#cbd5e1",
2120
+ "#e2e8f0",
2121
+ "#f1f5f9",
2122
+ "#f8fafc",
2123
+ "#ffffff",
2124
+ "#dc2626",
2125
+ "#ea580c",
2126
+ "#d97706",
2127
+ "#ca8a04",
2128
+ "#16a34a",
2129
+ "#0d9488",
2130
+ "#0284c7",
2131
+ "#2563eb",
2132
+ "#7c3aed",
2133
+ "#c026d3",
2134
+ "#fecaca",
2135
+ "#fed7aa",
2136
+ "#fde68a",
2137
+ "#fef08a",
2138
+ "#bbf7d0",
2139
+ "#99f6e4",
2140
+ "#bae6fd",
2141
+ "#bfdbfe",
2142
+ "#ddd6fe",
2143
+ "#f5d0fe",
2144
+ "#991b1b",
2145
+ "#9a3412",
2146
+ "#92400e",
2147
+ "#854d0e",
2148
+ "#166534",
2149
+ "#115e59",
2150
+ "#075985",
2151
+ "#1e40af",
2152
+ "#5b21b6",
2153
+ "#86198f"
2154
+ ];
1888
2155
  function setEditorSpacing(el, spacing) {
1889
- el.style.paddingTop = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : "";
1890
- el.style.paddingBottom = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : "";
2156
+ el.style.paddingTop = spacing ?? "";
2157
+ el.style.paddingBottom = spacing ?? "";
1891
2158
  }
1892
2159
  const DEFAULT_VIDEO_LINK = (video) => video.shareLink;
1893
2160
  const EMPTY_VIDEO_DEFAULTS = {
@@ -1899,11 +2166,15 @@ const EMPTY_VIDEO_DEFAULTS = {
1899
2166
  hideReactions: false
1900
2167
  };
1901
2168
  var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2169
+ onActiveFromChange(value) {
2170
+ this.activeFrom.set(value ?? "");
2171
+ if (value && this.activeTo() && this.activeTo() < value) this.activeTo.set("");
2172
+ }
1902
2173
  get headingOptions() {
1903
2174
  return this._headingOptions();
1904
2175
  }
1905
- get spacingTabs() {
1906
- return this._spacingTabs();
2176
+ get spacingOptions() {
2177
+ return this._spacingOptions();
1907
2178
  }
1908
2179
  get ctaTypeOptions() {
1909
2180
  return this._ctaTypeOptions();
@@ -1919,7 +2190,9 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
1919
2190
  this.categories = input([], ...ngDevMode ? [{ debugName: "categories" }] : /* istanbul ignore next */ []);
1920
2191
  this.showCategory = input(true, ...ngDevMode ? [{ debugName: "showCategory" }] : /* istanbul ignore next */ []);
1921
2192
  this.showActiveRange = input(true, ...ngDevMode ? [{ debugName: "showActiveRange" }] : /* istanbul ignore next */ []);
2193
+ this.showSaveHint = input(true, ...ngDevMode ? [{ debugName: "showSaveHint" }] : /* istanbul ignore next */ []);
1922
2194
  this.previewBrand = input(null, ...ngDevMode ? [{ debugName: "previewBrand" }] : /* istanbul ignore next */ []);
2195
+ this.canvasFont = computed(() => safePreviewBrand(this.previewBrand()).fontFamily ?? "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif", ...ngDevMode ? [{ debugName: "canvasFont" }] : /* istanbul ignore next */ []);
1923
2196
  this.previewSampleData = input(false, ...ngDevMode ? [{ debugName: "previewSampleData" }] : /* istanbul ignore next */ []);
1924
2197
  this.imageUpload = input(null, ...ngDevMode ? [{ debugName: "imageUpload" }] : /* istanbul ignore next */ []);
1925
2198
  this.categoryPlaceholderInput = input(null, {
@@ -1939,6 +2212,16 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
1939
2212
  alias: "variableGroups"
1940
2213
  });
1941
2214
  this.variableGroups = computed(() => this.variableGroupsInput() ?? localizedEmailVariableGroups(), ...ngDevMode ? [{ debugName: "variableGroups" }] : /* istanbul ignore next */ []);
2215
+ this.variablesNeedAssignment = computed(() => this.assignmentOptions().length > 0 && this.assignedKeys().length === 0, ...ngDevMode ? [{ debugName: "variablesNeedAssignment" }] : /* istanbul ignore next */ []);
2216
+ this.availableVariableGroups = computed(() => {
2217
+ if (this.assignmentOptions().length === 0) return this.variableGroups();
2218
+ const assigned = this.assignedKeys();
2219
+ if (assigned.length === 0) return [];
2220
+ return this.variableGroups().map((g) => ({
2221
+ ...g,
2222
+ variables: g.variables.filter((v) => !v.appliesTo || v.appliesTo.some((k) => assigned.includes(k)))
2223
+ })).filter((g) => g.variables.length > 0);
2224
+ }, ...ngDevMode ? [{ debugName: "availableVariableGroups" }] : /* istanbul ignore next */ []);
1942
2225
  this.blockGroupsInput = input(null, {
1943
2226
  ...ngDevMode ? { debugName: "blockGroupsInput" } : /* istanbul ignore next */ {},
1944
2227
  alias: "blockGroups"
@@ -1995,8 +2278,13 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
1995
2278
  this.subject = signal("", ...ngDevMode ? [{ debugName: "subject" }] : /* istanbul ignore next */ []);
1996
2279
  this.category = signal("", ...ngDevMode ? [{ debugName: "category" }] : /* istanbul ignore next */ []);
1997
2280
  this.useAllYear = signal(true, ...ngDevMode ? [{ debugName: "useAllYear" }] : /* istanbul ignore next */ []);
2281
+ this.today = (() => {
2282
+ const d = /* @__PURE__ */ new Date();
2283
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
2284
+ })();
1998
2285
  this.activeFrom = signal("", ...ngDevMode ? [{ debugName: "activeFrom" }] : /* istanbul ignore next */ []);
1999
2286
  this.activeTo = signal("", ...ngDevMode ? [{ debugName: "activeTo" }] : /* istanbul ignore next */ []);
2287
+ this.activeToMin = computed(() => this.activeFrom() > this.today ? this.activeFrom() : this.today, ...ngDevMode ? [{ debugName: "activeToMin" }] : /* istanbul ignore next */ []);
2000
2288
  this.videoId = signal(null, ...ngDevMode ? [{ debugName: "videoId" }] : /* istanbul ignore next */ []);
2001
2289
  this.videoTitle = signal(null, ...ngDevMode ? [{ debugName: "videoTitle" }] : /* istanbul ignore next */ []);
2002
2290
  this.assignedKeys = signal([], ...ngDevMode ? [{ debugName: "assignedKeys" }] : /* istanbul ignore next */ []);
@@ -2010,15 +2298,13 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2010
2298
  this.savedRange = null;
2011
2299
  this.blockEditors = viewChildren("blockEditor", ...ngDevMode ? [{ debugName: "blockEditors" }] : /* istanbul ignore next */ []);
2012
2300
  this.colorInputRef = viewChild("colorInput", ...ngDevMode ? [{ debugName: "colorInputRef" }] : /* istanbul ignore next */ []);
2301
+ this.highlightInputRef = viewChild("highlightInput", ...ngDevMode ? [{ debugName: "highlightInputRef" }] : /* istanbul ignore next */ []);
2013
2302
  this.loadedBody = signal(null, ...ngDevMode ? [{ debugName: "loadedBody" }] : /* istanbul ignore next */ []);
2014
2303
  this.bodyEdited = signal(false, ...ngDevMode ? [{ debugName: "bodyEdited" }] : /* istanbul ignore next */ []);
2015
2304
  this.savedSnapshot = signal(null, ...ngDevMode ? [{ debugName: "savedSnapshot" }] : /* istanbul ignore next */ []);
2016
2305
  this.dragFromPalette = null;
2017
- this.dragFromCanvas = signal(null, ...ngDevMode ? [{ debugName: "dragFromCanvas" }] : /* istanbul ignore next */ []);
2018
- this.dragOverIndex = signal(null, ...ngDevMode ? [{ debugName: "dragOverIndex" }] : /* istanbul ignore next */ []);
2019
2306
  this.currentColor = signal("#1e293b", ...ngDevMode ? [{ debugName: "currentColor" }] : /* istanbul ignore next */ []);
2020
2307
  this.blockSpacing = signal("", ...ngDevMode ? [{ debugName: "blockSpacing" }] : /* istanbul ignore next */ []);
2021
- this.headingKey = signal(0, ...ngDevMode ? [{ debugName: "headingKey" }] : /* istanbul ignore next */ []);
2022
2308
  this.sizeKey = signal(0, ...ngDevMode ? [{ debugName: "sizeKey" }] : /* istanbul ignore next */ []);
2023
2309
  this._headingOptions = computed(() => [
2024
2310
  {
@@ -2039,24 +2325,27 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2039
2325
  }
2040
2326
  ], ...ngDevMode ? [{ debugName: "_headingOptions" }] : /* istanbul ignore next */ []);
2041
2327
  this.fontSizeOptions = FONT_SIZE_OPTIONS;
2042
- this._spacingTabs = computed(() => [
2043
- {
2044
- key: "none",
2045
- label: this.labels.t("emailTemplateEditor.spacing.none")
2046
- },
2047
- {
2048
- key: "8px",
2049
- label: this.labels.t("emailTemplateEditor.spacing.small")
2050
- },
2051
- {
2052
- key: "16px",
2053
- label: this.labels.t("emailTemplateEditor.spacing.medium")
2054
- },
2055
- {
2056
- key: "32px",
2057
- label: this.labels.t("emailTemplateEditor.spacing.large")
2058
- }
2059
- ], ...ngDevMode ? [{ debugName: "_spacingTabs" }] : /* istanbul ignore next */ []);
2328
+ this._spacingOptions = computed(() => {
2329
+ const lead = this.labels.t("emailTemplateEditor.spacingShort");
2330
+ return [
2331
+ {
2332
+ value: "none",
2333
+ label: `${lead}: ${this.labels.t("emailTemplateEditor.spacing.none")}`
2334
+ },
2335
+ {
2336
+ value: "8px",
2337
+ label: `${lead}: ${this.labels.t("emailTemplateEditor.spacing.small")}`
2338
+ },
2339
+ {
2340
+ value: "16px",
2341
+ label: `${lead}: ${this.labels.t("emailTemplateEditor.spacing.medium")}`
2342
+ },
2343
+ {
2344
+ value: "32px",
2345
+ label: `${lead}: ${this.labels.t("emailTemplateEditor.spacing.large")}`
2346
+ }
2347
+ ];
2348
+ }, ...ngDevMode ? [{ debugName: "_spacingOptions" }] : /* istanbul ignore next */ []);
2060
2349
  this.startPlaceholder = computed(() => this.labels.t("emailTemplateEditor.startWriting"), ...ngDevMode ? [{ debugName: "startPlaceholder" }] : /* istanbul ignore next */ []);
2061
2350
  this._ctaTypeOptions = computed(() => [
2062
2351
  {
@@ -2084,6 +2373,24 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2084
2373
  label: this.labels.t("emailTemplateEditor.playback.autoplay")
2085
2374
  }], ...ngDevMode ? [{ debugName: "_playbackOptions" }] : /* istanbul ignore next */ []);
2086
2375
  this.showLinkDialog = signal(false, ...ngDevMode ? [{ debugName: "showLinkDialog" }] : /* istanbul ignore next */ []);
2376
+ this.showEmojiPanel = signal(false, ...ngDevMode ? [{ debugName: "showEmojiPanel" }] : /* istanbul ignore next */ []);
2377
+ this.colorPanel = signal(null, ...ngDevMode ? [{ debugName: "colorPanel" }] : /* istanbul ignore next */ []);
2378
+ this.colorSwatches = COLOR_SWATCHES;
2379
+ this.brandTextColor = computed(() => this.previewBrand()?.textColor ?? "#1e293b", ...ngDevMode ? [{ debugName: "brandTextColor" }] : /* istanbul ignore next */ []);
2380
+ this.showSpecialPanel = signal(false, ...ngDevMode ? [{ debugName: "showSpecialPanel" }] : /* istanbul ignore next */ []);
2381
+ this.emojiGroupKeys = EMAIL_EMOJI_GROUP_KEYS;
2382
+ this.specialCharacters = EMAIL_SPECIAL_CHARACTERS;
2383
+ this.emojiSearch = signal("", ...ngDevMode ? [{ debugName: "emojiSearch" }] : /* istanbul ignore next */ []);
2384
+ this.emojiTone = signal("", ...ngDevMode ? [{ debugName: "emojiTone" }] : /* istanbul ignore next */ []);
2385
+ this.emojiGroup = signal("smileys", ...ngDevMode ? [{ debugName: "emojiGroup" }] : /* istanbul ignore next */ []);
2386
+ this.skinToneOptions = computed(() => EMAIL_SKIN_TONES.map((t) => ({
2387
+ value: t.modifier,
2388
+ label: this.toneLabel(t.key)
2389
+ })), ...ngDevMode ? [{ debugName: "skinToneOptions" }] : /* istanbul ignore next */ []);
2390
+ this.shownEmojis = computed(() => findEmojis(this.emojiSearch(), this.emojiGroup()), ...ngDevMode ? [{ debugName: "shownEmojis" }] : /* istanbul ignore next */ []);
2391
+ this.headingValue = signal("p", ...ngDevMode ? [{ debugName: "headingValue" }] : /* istanbul ignore next */ []);
2392
+ this.currentHighlight = signal("#fde68a", ...ngDevMode ? [{ debugName: "currentHighlight" }] : /* istanbul ignore next */ []);
2393
+ this.inTable = signal(false, ...ngDevMode ? [{ debugName: "inTable" }] : /* istanbul ignore next */ []);
2087
2394
  this.linkUrl = signal("", ...ngDevMode ? [{ debugName: "linkUrl" }] : /* istanbul ignore next */ []);
2088
2395
  this.linkText = signal("", ...ngDevMode ? [{ debugName: "linkText" }] : /* istanbul ignore next */ []);
2089
2396
  this.linkTextFromSelection = signal(false, ...ngDevMode ? [{ debugName: "linkTextFromSelection" }] : /* istanbul ignore next */ []);
@@ -2110,9 +2417,14 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2110
2417
  this.filteredAssignments = computed(() => {
2111
2418
  const featured = this.featuredAssignmentKey();
2112
2419
  const all = this.assignmentState();
2113
- const ordered = featured ? [...all.filter((a) => a.key === featured), ...all.filter((a) => a.key !== featured)] : all;
2420
+ const grouped = all.some((a) => a.group);
2421
+ const ordered = featured && !grouped ? [...all.filter((a) => a.key === featured), ...all.filter((a) => a.key !== featured)] : all;
2114
2422
  const q = this.assignmentSearch().trim().toLowerCase();
2115
- return q ? ordered.filter((a) => a.name.toLowerCase().includes(q) || a.description.toLowerCase().includes(q)) : ordered;
2423
+ const shown = q ? ordered.filter((a) => a.name.toLowerCase().includes(q) || a.description.toLowerCase().includes(q)) : ordered;
2424
+ return shown.map((a, i) => ({
2425
+ ...a,
2426
+ groupStart: !!a.group && a.group !== shown[i - 1]?.group
2427
+ }));
2116
2428
  }, ...ngDevMode ? [{ debugName: "filteredAssignments" }] : /* istanbul ignore next */ []);
2117
2429
  this.filteredBlockGroups = computed(() => {
2118
2430
  const q = this.blockSearch().trim().toLowerCase();
@@ -2197,7 +2509,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2197
2509
  return !url || isWebUrl(url) ? "" : this.labels.t("emailTemplateEditor.validImageAddress");
2198
2510
  }, ...ngDevMode ? [{ debugName: "imageUrlError" }] : /* istanbul ignore next */ []);
2199
2511
  this.canInsertImage = computed(() => !!this.imageUrl().trim() && !this.imageUrlError() && !this.imageUploading(), ...ngDevMode ? [{ debugName: "canInsertImage" }] : /* istanbul ignore next */ []);
2200
- this.emailChecks = computed(() => findEmailChecks(this.subject(), this.serialized(), this.variableGroups().flatMap((g) => g.variables.map((v) => v.key))), ...ngDevMode ? [{ debugName: "emailChecks" }] : /* istanbul ignore next */ []);
2512
+ this.emailChecks = computed(() => findEmailChecks(this.subject(), this.serialized(), (this.variablesNeedAssignment() ? this.variableGroups() : this.availableVariableGroups()).flatMap((g) => g.variables.map((v) => v.key))), ...ngDevMode ? [{ debugName: "emailChecks" }] : /* istanbul ignore next */ []);
2201
2513
  this.checkMessages = computed(() => {
2202
2514
  const c = this.emailChecks();
2203
2515
  return [
@@ -2212,6 +2524,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2212
2524
  }, ...ngDevMode ? [{ debugName: "testEmailError" }] : /* istanbul ignore next */ []);
2213
2525
  this.canSendTest = computed(() => this.canWrite() && !!this.editingId() && !!this.testSendEmail().trim() && !this.testEmailError() && !this.testSending(), ...ngDevMode ? [{ debugName: "canSendTest" }] : /* istanbul ignore next */ []);
2214
2526
  this.hasUnsavedChanges = computed(() => !!this.editingId() && this.savedSnapshot() !== null && this.savedSnapshot() !== this.snapshot(), ...ngDevMode ? [{ debugName: "hasUnsavedChanges" }] : /* istanbul ignore next */ []);
2527
+ ensureDocumentStyles();
2215
2528
  effect(() => {
2216
2529
  const t = this.template();
2217
2530
  untracked(() => this.applyTemplate(t));
@@ -2268,12 +2581,14 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2268
2581
  this.activeTo.set(t?.activeTo ?? "");
2269
2582
  this.videoId.set(t?.videoId ?? null);
2270
2583
  this.videoTitle.set(t?.videoTitle ?? null);
2271
- this.blocks.set(!t || !t.id && !(t.body ?? "").trim() ? [{
2584
+ this.blocks.set([{
2272
2585
  id: this.genId(),
2273
- html: ""
2274
- }] : this.htmlToBlocks(t.body ?? ""));
2275
- this.selectedBlockId.set(this.blocks()[0]?.id ?? null);
2276
- this.blockSpacing.set(this.blocks()[0]?.spacing ?? "");
2586
+ html: !t || !t.id && !(t.body ?? "").trim() ? "" : this.htmlToDocument(t.body ?? "")
2587
+ }]);
2588
+ this.selectedBlockId.set(this.blocks()[0].id);
2589
+ this.blockSpacing.set("");
2590
+ this.headingValue.set("p");
2591
+ this.inTable.set(false);
2277
2592
  this.loadedBody.set(t?.id ? t.body ?? "" : null);
2278
2593
  this.bodyEdited.set(false);
2279
2594
  this.bodyBlurred.set(false);
@@ -2327,36 +2642,13 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2327
2642
  ]);
2328
2643
  }
2329
2644
  serialize(blocks) {
2330
- return blocks.map((b) => {
2331
- return `<div data-block="true">${b.spacing ? `<div data-spacing="true" style="padding:${b.spacing} 0">${b.html}</div>` : b.html}</div>`;
2332
- }).join("");
2645
+ return `<div data-block="true">${blocks.map((b) => b.html).join("")}</div>`;
2333
2646
  }
2334
- htmlToBlocks(html) {
2335
- if (!html || !html.trim()) return [{
2336
- id: this.genId(),
2337
- html: "<p></p>"
2338
- }];
2339
- const div = new DOMParser().parseFromString(html, "text/html").body;
2340
- const blockDivs = Array.from(div.querySelectorAll(":scope > [data-block]"));
2341
- if (blockDivs.length > 0) return blockDivs.map((el) => {
2342
- const spacingEl = el.querySelector(":scope > [data-spacing]");
2343
- if (spacingEl) {
2344
- const spacing = spacingEl.style.padding?.split(" ")[0] || void 0;
2345
- return {
2346
- id: this.genId(),
2347
- html: spacingEl.innerHTML,
2348
- spacing
2349
- };
2350
- }
2351
- return {
2352
- id: this.genId(),
2353
- html: el.innerHTML
2354
- };
2355
- });
2356
- return [{
2357
- id: this.genId(),
2358
- html
2359
- }];
2647
+ htmlToDocument(html) {
2648
+ if (!html || !html.trim()) return "<p></p>";
2649
+ const body = new DOMParser().parseFromString(html, "text/html").body;
2650
+ const blockDivs = Array.from(body.querySelectorAll(":scope > [data-block]"));
2651
+ return blockDivs.length > 0 ? blockDivs.map((el) => el.innerHTML).join("") : html;
2360
2652
  }
2361
2653
  genId() {
2362
2654
  return Math.random().toString(36).slice(2, 10);
@@ -2392,67 +2684,26 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2392
2684
  if (tab === "edit" && previous !== "edit") this.initializedBlockIds = /* @__PURE__ */ new Set();
2393
2685
  this.activeEditorTab.set(tab);
2394
2686
  }
2395
- addBlock(blockKey = "text-block") {
2396
- if (!this.canWrite()) return;
2397
- this.addBlockHtml(this.blockHtml(blockKey));
2398
- }
2399
- addBlockHtml(html, at) {
2400
- this.bodyEdited.set(true);
2401
- const block = {
2402
- id: this.genId(),
2403
- html
2404
- };
2405
- this.blocks.update((list) => at === void 0 ? [...list, block] : [
2406
- ...list.slice(0, at),
2407
- block,
2408
- ...list.slice(at)
2409
- ]);
2410
- this.selectedBlockId.set(block.id);
2411
- return block;
2412
- }
2413
- deleteBlock(index) {
2414
- if (!this.canWrite()) return;
2415
- const list = this.blocks();
2416
- if (index < 0 || index >= list.length) return;
2417
- if (list.length === 1) return;
2418
- this.bodyEdited.set(true);
2419
- this.initializedBlockIds.delete(list[index].id);
2420
- const next = list.filter((_, i) => i !== index);
2421
- this.blocks.set(next);
2422
- this.selectedBlockId.set(next[Math.min(index, next.length - 1)].id);
2423
- }
2424
- duplicateBlock(index) {
2425
- if (!this.canWrite()) return;
2426
- const list = this.blocks();
2427
- if (index < 0 || index >= list.length) return;
2687
+ addBlockHtml(html) {
2428
2688
  this.bodyEdited.set(true);
2429
- const src = list[index];
2430
- const html = this.editorFor(src.id)?.nativeElement.innerHTML ?? src.html;
2431
- const copy = {
2432
- id: this.genId(),
2433
- html,
2434
- spacing: src.spacing
2435
- };
2436
- this.blocks.set([
2437
- ...list.slice(0, index + 1),
2438
- copy,
2439
- ...list.slice(index + 1)
2440
- ]);
2441
- this.selectedBlockId.set(copy.id);
2442
- }
2443
- moveBlock(index, direction) {
2444
- if (!this.canWrite()) return;
2445
- const list = this.blocks();
2446
- const target = index + direction;
2447
- if (index < 0 || index >= list.length || target < 0 || target >= list.length) return;
2448
- this.bodyEdited.set(true);
2449
- const next = [...list];
2450
- [next[index], next[target]] = [next[target], next[index]];
2451
- this.blocks.set(next);
2689
+ const editor = this.editorFor(this.selectedBlockId())?.nativeElement;
2690
+ if (editor) {
2691
+ this.restoreSelection();
2692
+ const sel = window.getSelection();
2693
+ if (!!sel && sel.rangeCount > 0 && insideEditorBlock(sel.getRangeAt(0).commonAncestorContainer)) document.execCommand("insertHTML", false, html);
2694
+ else editor.insertAdjacentHTML("beforeend", html);
2695
+ this.syncBlock();
2696
+ return;
2697
+ }
2698
+ this.blocks.update((list) => list.map((b, i) => i === 0 ? {
2699
+ ...b,
2700
+ html: b.html + html
2701
+ } : b));
2452
2702
  }
2453
2703
  onBlockInput(event, block) {
2454
2704
  if (!this.canWrite()) return;
2455
2705
  this.bodyEdited.set(true);
2706
+ this.wrapBareText(event.target);
2456
2707
  const html = event.target.innerHTML;
2457
2708
  this.blocks.update((list) => list.map((b) => b.id === block.id ? {
2458
2709
  ...b,
@@ -2477,7 +2728,81 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2477
2728
  }
2478
2729
  onBlockFocus(block) {
2479
2730
  this.selectedBlockId.set(block.id);
2480
- this.blockSpacing.set(block.spacing ?? "");
2731
+ document.execCommand("defaultParagraphSeparator", false, "p");
2732
+ this.refreshContext();
2733
+ }
2734
+ wrapBareText(editor) {
2735
+ const INLINE = /* @__PURE__ */ new Set([
2736
+ "B",
2737
+ "STRONG",
2738
+ "I",
2739
+ "EM",
2740
+ "U",
2741
+ "S",
2742
+ "STRIKE",
2743
+ "SPAN",
2744
+ "A",
2745
+ "FONT",
2746
+ "SUB",
2747
+ "SUP",
2748
+ "BR",
2749
+ "IMG",
2750
+ "MARK"
2751
+ ]);
2752
+ const isLoose = (n) => n.nodeType === 3 || n instanceof HTMLElement && INLINE.has(n.tagName);
2753
+ const nodes = Array.from(editor.childNodes);
2754
+ if (!nodes.some((n) => isLoose(n) && (n.nodeType !== 3 || (n.textContent ?? "").trim() !== ""))) return;
2755
+ const sel = window.getSelection();
2756
+ const anchor = sel && sel.rangeCount > 0 ? {
2757
+ node: sel.anchorNode,
2758
+ offset: sel.anchorOffset
2759
+ } : null;
2760
+ let run = [];
2761
+ const flush = () => {
2762
+ if (run.length === 0) return;
2763
+ const p = document.createElement("p");
2764
+ editor.insertBefore(p, run[0]);
2765
+ run.forEach((n) => p.appendChild(n));
2766
+ run = [];
2767
+ };
2768
+ for (const n of nodes) if (isLoose(n)) run.push(n);
2769
+ else flush();
2770
+ flush();
2771
+ if (anchor?.node && anchor.node.isConnected && sel) {
2772
+ const range = document.createRange();
2773
+ range.setStart(anchor.node, anchor.offset);
2774
+ range.collapse(true);
2775
+ sel.removeAllRanges();
2776
+ sel.addRange(range);
2777
+ }
2778
+ }
2779
+ refreshContext() {
2780
+ const top = this.topLevelAtCaret();
2781
+ const tag = top?.tagName.toLowerCase() ?? "p";
2782
+ this.headingValue.set([
2783
+ "h1",
2784
+ "h2",
2785
+ "h3"
2786
+ ].includes(tag) ? tag : "p");
2787
+ const pad = (top?.hasAttribute("data-spacing") ? top : null)?.style.paddingTop ?? "";
2788
+ this.blockSpacing.set([
2789
+ "8px",
2790
+ "16px",
2791
+ "32px"
2792
+ ].includes(pad) ? pad : "");
2793
+ const sel = window.getSelection();
2794
+ const node = sel && sel.rangeCount > 0 ? sel.getRangeAt(0).commonAncestorContainer : null;
2795
+ const el = node instanceof Element ? node : node?.parentElement;
2796
+ this.inTable.set(!!el && insideEditorBlock(el) && !!el.closest("td, th"));
2797
+ }
2798
+ topLevelAtCaret() {
2799
+ const editor = this.editorFor(this.selectedBlockId())?.nativeElement;
2800
+ const sel = window.getSelection();
2801
+ if (!editor || !sel || sel.rangeCount === 0) return null;
2802
+ let node = sel.getRangeAt(0).startContainer;
2803
+ if (!editor.contains(node)) return null;
2804
+ while (node && node.parentNode !== editor) node = node.parentNode;
2805
+ return node instanceof HTMLElement ? node : null;
2481
2806
  }
2482
2807
  onPaletteDragStart(event, block) {
2483
2808
  if (!this.canWrite()) {
@@ -2485,64 +2810,39 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2485
2810
  return;
2486
2811
  }
2487
2812
  this.dragFromPalette = block;
2488
- this.dragFromCanvas.set(null);
2489
2813
  event.dataTransfer.effectAllowed = "copy";
2490
2814
  event.dataTransfer.setData(EMAIL_BLOCK_DRAG_TYPE, block.key);
2491
2815
  }
2492
- onBlockDragStart(event, index, wrapper) {
2493
- if (!this.canWrite()) {
2494
- event.preventDefault();
2495
- return;
2496
- }
2497
- if (event.target !== event.currentTarget) return;
2498
- this.dragFromCanvas.set(index);
2499
- this.dragFromPalette = null;
2500
- event.dataTransfer.effectAllowed = "move";
2501
- event.dataTransfer.setData(EMAIL_BLOCK_DRAG_TYPE, String(index));
2502
- if (wrapper) event.dataTransfer.setDragImage?.(wrapper, 0, 0);
2503
- event.stopPropagation();
2504
- }
2505
2816
  onBlockDragEnd() {
2506
- this.dragFromCanvas.set(null);
2507
2817
  this.dragFromPalette = null;
2508
- this.dragOverIndex.set(null);
2509
2818
  }
2510
- onCanvasDragOver(event) {
2511
- if (this.canWrite() && isBlockDrag(event)) event.preventDefault();
2512
- }
2513
- onDropZoneDragOver(event, index) {
2514
- if (!this.canWrite() || !isBlockDrag(event)) return;
2515
- event.preventDefault();
2516
- event.dataTransfer.dropEffect = this.dragFromPalette ? "copy" : "move";
2517
- if (this.dragOverIndex() !== index) this.dragOverIndex.set(index);
2518
- }
2519
- onDropZoneLeave() {
2520
- this.dragOverIndex.set(null);
2521
- }
2522
- onDropZoneDrop(event, insertBefore) {
2523
- if (!this.canWrite()) {
2819
+ onDocDragOver(event) {
2820
+ if (this.canWrite() && isBlockDrag(event)) {
2524
2821
  event.preventDefault();
2525
- return;
2822
+ event.dataTransfer.dropEffect = "copy";
2526
2823
  }
2527
- const fromCanvas = this.dragFromCanvas();
2528
- if (this.dragFromPalette === null && fromCanvas === null) return;
2824
+ }
2825
+ onDocDrop(event) {
2826
+ if (!this.canWrite() || this.dragFromPalette === null) return;
2529
2827
  event.preventDefault();
2530
- this.dragOverIndex.set(null);
2531
- if (this.dragFromPalette) {
2532
- const html = this.dragFromPalette.html;
2533
- this.dragFromPalette = null;
2534
- this.addBlockHtml(html, insertBefore);
2535
- } else if (fromCanvas !== null) {
2536
- const to = fromCanvas < insertBefore ? insertBefore - 1 : insertBefore;
2537
- if (fromCanvas !== to) {
2538
- const next = [...this.blocks()];
2539
- const [moved] = next.splice(fromCanvas, 1);
2540
- next.splice(to, 0, moved);
2541
- this.blocks.set(next);
2542
- this.bodyEdited.set(true);
2543
- }
2544
- this.dragFromCanvas.set(null);
2828
+ const html = this.dragFromPalette.html;
2829
+ this.dragFromPalette = null;
2830
+ const doc = document;
2831
+ const range = document.caretRangeFromPoint?.(event.clientX, event.clientY) ?? (() => {
2832
+ const pos = doc.caretPositionFromPoint?.(event.clientX, event.clientY);
2833
+ if (!pos) return null;
2834
+ const r = document.createRange();
2835
+ r.setStart(pos.offsetNode, pos.offset);
2836
+ return r;
2837
+ })();
2838
+ if (range && insideEditorBlock(range.commonAncestorContainer)) {
2839
+ range.collapse(true);
2840
+ const sel = window.getSelection();
2841
+ sel?.removeAllRanges();
2842
+ sel?.addRange(range);
2843
+ this.savedRange = range.cloneRange();
2545
2844
  }
2845
+ this.addBlockHtml(html);
2546
2846
  }
2547
2847
  preventFocusLoss(event) {
2548
2848
  if (event.target?.closest?.("select, input")) return;
@@ -2561,6 +2861,10 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2561
2861
  sel?.removeAllRanges();
2562
2862
  sel?.addRange(saved);
2563
2863
  }
2864
+ focusEditor() {
2865
+ const editor = this.editorFor(this.selectedBlockId())?.nativeElement;
2866
+ if (editor && document.activeElement !== editor) editor.focus({ preventScroll: true });
2867
+ }
2564
2868
  activeBlockHtml() {
2565
2869
  return this.editorFor(this.selectedBlockId())?.nativeElement.innerHTML ?? null;
2566
2870
  }
@@ -2578,16 +2882,55 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2578
2882
  document.execCommand(cmd, false, value ?? void 0);
2579
2883
  });
2580
2884
  if (cmd === "insertUnorderedList" || cmd === "insertOrderedList") this.styleNewLists();
2885
+ if (cmd === "insertHorizontalRule" || cmd === "formatBlock" && value === "blockquote") this.styleNewBlocks();
2581
2886
  this.syncBlock();
2887
+ this.refreshContext();
2888
+ }
2889
+ styleNewBlocks() {
2890
+ const doc = this.editorFor(this.selectedBlockId())?.nativeElement;
2891
+ doc?.querySelectorAll("hr:not([style])").forEach((hr) => hr.setAttribute("style", "border:0;border-top:1px solid #cbd5e1;margin:16px 0"));
2892
+ doc?.querySelectorAll("table:not([style])").forEach((t) => t.setAttribute("style", "border-collapse:collapse;width:100%;margin:8px 0"));
2893
+ doc?.querySelectorAll("td:not([style]), th:not([style])").forEach((c) => c.setAttribute("style", "border:1px solid #cbd5e1;padding:8px;vertical-align:top"));
2894
+ doc?.querySelectorAll("blockquote:not([style])").forEach((q) => q.setAttribute("style", "margin:1em 0;padding:4px 16px;border-left:4px solid #cbd5e1;color:#475569"));
2582
2895
  }
2583
2896
  styleNewLists() {
2584
2897
  (this.editorFor(this.selectedBlockId())?.nativeElement)?.querySelectorAll("ul:not([style]), ol:not([style])").forEach((list) => {
2585
2898
  list.setAttribute("style", `list-style-type:${list.tagName === "OL" ? "decimal" : "disc"};padding-left:40px;margin:1em 0`);
2586
2899
  });
2587
2900
  }
2901
+ onDocEnter(event) {
2902
+ const node = window.getSelection()?.anchorNode ?? null;
2903
+ const el = node instanceof Element ? node : node?.parentElement ?? null;
2904
+ const quote = el?.closest("blockquote");
2905
+ if (!quote || !this.canWrite()) return;
2906
+ const line = el.closest("blockquote > *") ?? el;
2907
+ if ((line?.textContent ?? "").trim() !== "" && line !== quote) return;
2908
+ if (line === quote && quote.textContent?.trim()) return;
2909
+ event.preventDefault();
2910
+ this.execCommand("formatBlock", "p");
2911
+ this.stripQuoteLook();
2912
+ }
2913
+ stripQuoteLook() {
2914
+ (this.editorFor(this.selectedBlockId())?.nativeElement)?.querySelectorAll("[style*=\"border-left\"]").forEach((el) => {
2915
+ if (el.tagName === "BLOCKQUOTE" || el.closest("blockquote")) return;
2916
+ [
2917
+ "border-left",
2918
+ "padding",
2919
+ "margin",
2920
+ "color"
2921
+ ].forEach((p) => el.style.removeProperty(p));
2922
+ if (!el.getAttribute("style")) el.removeAttribute("style");
2923
+ });
2924
+ this.syncBlock();
2925
+ }
2926
+ toggleQuote() {
2927
+ const node = window.getSelection()?.anchorNode ?? null;
2928
+ const leaving = !!(node instanceof Element ? node : node?.parentElement ?? null)?.closest("blockquote");
2929
+ this.execCommand("formatBlock", leaving ? "p" : "blockquote");
2930
+ if (leaving) this.stripQuoteLook();
2931
+ }
2588
2932
  onHeading(value) {
2589
2933
  this.execCommand("formatBlock", value);
2590
- this.headingKey.update((k) => k + 1);
2591
2934
  }
2592
2935
  onFontSize(value) {
2593
2936
  this.applyFontSize(value);
@@ -2622,25 +2965,174 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2622
2965
  });
2623
2966
  this.syncBlock();
2624
2967
  }
2625
- openColorPicker() {
2968
+ toggleColorPanel(which) {
2969
+ if (!this.canWrite()) return;
2970
+ this.showLinkDialog.set(false);
2971
+ this.showImageDialog.set(false);
2972
+ this.showEmojiPanel.set(false);
2973
+ this.showSpecialPanel.set(false);
2974
+ this.colorPanel.update((v) => v === which ? null : which);
2975
+ }
2976
+ pickColor(which, color) {
2977
+ this.colorPanel.set(null);
2978
+ if (which === "text") this.applyTextColor(color);
2979
+ else this.applyHighlight(color);
2980
+ }
2981
+ removeColor(which) {
2982
+ this.colorPanel.set(null);
2983
+ if (which === "text") this.applyTextColor(this.brandTextColor());
2984
+ else {
2985
+ this.runEditCommand(() => {
2986
+ document.execCommand("styleWithCSS", false, "true");
2987
+ document.execCommand("hiliteColor", false, "transparent");
2988
+ });
2989
+ this.syncBlock();
2990
+ }
2991
+ }
2992
+ openCustomColor(which) {
2626
2993
  this.saveSelection();
2627
- this.colorInputRef()?.nativeElement.click();
2994
+ const input = (which === "text" ? this.colorInputRef() : this.highlightInputRef())?.nativeElement;
2995
+ if (!input) return;
2996
+ try {
2997
+ if (typeof input.showPicker === "function") input.showPicker();
2998
+ else input.click();
2999
+ } catch {
3000
+ input.click();
3001
+ }
2628
3002
  }
2629
3003
  applySpacing(value) {
2630
3004
  if (!this.canWrite()) return;
3005
+ this.restoreSelection();
3006
+ const editor = this.editorFor(this.selectedBlockId())?.nativeElement;
3007
+ let top = this.topLevelAtCaret();
3008
+ if (editor && !top) {
3009
+ top = editor.querySelector(":scope > *") ?? null;
3010
+ if (!top && editor.textContent) {
3011
+ editor.innerHTML = `<p>${editor.innerHTML}</p>`;
3012
+ top = editor.firstElementChild;
3013
+ }
3014
+ }
3015
+ if (!editor || !top) {
3016
+ this.blockSpacing.set(value);
3017
+ return;
3018
+ }
3019
+ if ((top.hasAttribute("data-spacing") ? top.style.paddingTop : "") === value) {
3020
+ this.blockSpacing.set(value);
3021
+ return;
3022
+ }
3023
+ if (top.hasAttribute("data-spacing")) {
3024
+ if (value) top.style.padding = `${value} 0`;
3025
+ else {
3026
+ while (top.firstChild) top.parentNode.insertBefore(top.firstChild, top);
3027
+ top.remove();
3028
+ }
3029
+ } else if (value) {
3030
+ const wrapper = document.createElement("div");
3031
+ wrapper.setAttribute("data-spacing", "true");
3032
+ wrapper.setAttribute("style", `padding:${value} 0`);
3033
+ top.parentNode.insertBefore(wrapper, top);
3034
+ wrapper.appendChild(top);
3035
+ }
3036
+ this.bodyEdited.set(true);
2631
3037
  this.blockSpacing.set(value);
2632
- const id = this.selectedBlockId();
2633
- if (!id) return;
2634
- const ref = this.editorFor(id);
2635
- if (ref) setEditorSpacing(ref.nativeElement, value);
2636
- const block = this.blocks().find((b) => b.id === id);
2637
- if (!block) return;
2638
- const changed = (block.spacing ?? "") !== (value ?? "");
2639
- this.blocks.update((list) => list.map((b) => b.id === id ? {
2640
- ...b,
2641
- spacing: value || void 0
2642
- } : b));
2643
- if (changed) this.bodyEdited.set(true);
3038
+ this.syncBlock();
3039
+ }
3040
+ applyHighlight(color) {
3041
+ if (!this.canWrite()) return;
3042
+ this.currentHighlight.set(color);
3043
+ this.runEditCommand(() => {
3044
+ document.execCommand("styleWithCSS", false, "true");
3045
+ document.execCommand("hiliteColor", false, color);
3046
+ });
3047
+ this.syncBlock();
3048
+ }
3049
+ insertTable() {
3050
+ if (!this.canWrite()) return;
3051
+ const row = `<tr>${`<td style="border:1px solid #cbd5e1;padding:8px;vertical-align:top"><br></td>`.repeat(3)}</tr>`;
3052
+ this.runEditCommand(() => {
3053
+ document.execCommand("insertHTML", false, `<table style="border-collapse:collapse;width:100%;margin:8px 0"><tbody>${row.repeat(3)}</tbody></table><p><br></p>`);
3054
+ });
3055
+ this.styleNewBlocks();
3056
+ this.bodyEdited.set(true);
3057
+ this.syncBlock();
3058
+ this.refreshContext();
3059
+ }
3060
+ currentCell() {
3061
+ const sel = window.getSelection();
3062
+ const node = sel && sel.rangeCount > 0 ? sel.getRangeAt(0).startContainer : null;
3063
+ const cell = (node instanceof Element ? node : node?.parentElement)?.closest("td, th") ?? null;
3064
+ return cell && insideEditorBlock(cell) ? cell : null;
3065
+ }
3066
+ editTable(change) {
3067
+ if (!this.canWrite()) return;
3068
+ this.restoreSelection();
3069
+ const cell = this.currentCell();
3070
+ const row = cell?.parentElement;
3071
+ const table = cell?.closest("table") ?? null;
3072
+ if (!cell || !row || !table) return;
3073
+ change(cell, row, table);
3074
+ this.bodyEdited.set(true);
3075
+ this.syncBlock();
3076
+ this.refreshContext();
3077
+ }
3078
+ newCell(like) {
3079
+ const c = document.createElement("td");
3080
+ c.setAttribute("style", like.getAttribute("style") ?? "border:1px solid #cbd5e1;padding:8px;vertical-align:top");
3081
+ c.innerHTML = "<br>";
3082
+ return c;
3083
+ }
3084
+ tableAddRow() {
3085
+ this.editTable((_cell, row) => {
3086
+ const copy = document.createElement("tr");
3087
+ Array.from(row.cells).forEach((c) => copy.appendChild(this.newCell(c)));
3088
+ row.after(copy);
3089
+ });
3090
+ }
3091
+ tableAddColumn() {
3092
+ this.editTable((cell, _row, table) => {
3093
+ const index = cell.cellIndex;
3094
+ Array.from(table.rows).forEach((r) => {
3095
+ const ref = r.cells[index];
3096
+ if (ref) ref.after(this.newCell(ref));
3097
+ });
3098
+ });
3099
+ }
3100
+ placeCaretInCell(cell) {
3101
+ if (!cell) return;
3102
+ const range = document.createRange();
3103
+ range.selectNodeContents(cell);
3104
+ range.collapse(true);
3105
+ const sel = window.getSelection();
3106
+ sel?.removeAllRanges();
3107
+ sel?.addRange(range);
3108
+ }
3109
+ tableDeleteRow() {
3110
+ this.editTable((cell, row, table) => {
3111
+ if (table.rows.length <= 1) {
3112
+ table.remove();
3113
+ return;
3114
+ }
3115
+ const neighbour = row.nextElementSibling ?? row.previousElementSibling;
3116
+ const index = cell.cellIndex;
3117
+ row.remove();
3118
+ this.placeCaretInCell(neighbour?.cells[index] ?? neighbour?.cells[0]);
3119
+ });
3120
+ }
3121
+ tableDeleteColumn() {
3122
+ this.editTable((cell, _row, table) => {
3123
+ const index = cell.cellIndex;
3124
+ if (table.rows[0]?.cells.length <= 1) {
3125
+ table.remove();
3126
+ return;
3127
+ }
3128
+ const row = cell.parentElement;
3129
+ const neighbour = cell.nextElementSibling ?? cell.previousElementSibling;
3130
+ Array.from(table.rows).forEach((r) => r.cells[index]?.remove());
3131
+ this.placeCaretInCell(neighbour ?? row.cells[0]);
3132
+ });
3133
+ }
3134
+ tableDelete() {
3135
+ this.editTable((_cell, _row, table) => table.remove());
2644
3136
  }
2645
3137
  anchorAtSelection() {
2646
3138
  const sel = window.getSelection();
@@ -2652,6 +3144,8 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2652
3144
  }
2653
3145
  openLinkDialog() {
2654
3146
  if (!this.canWrite()) return;
3147
+ this.showEmojiPanel.set(false);
3148
+ this.showSpecialPanel.set(false);
2655
3149
  this.saveSelection();
2656
3150
  const selected = window.getSelection()?.toString() || "";
2657
3151
  this.linkText.set(selected);
@@ -2664,6 +3158,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2664
3158
  this.bodyEdited.set(true);
2665
3159
  const url = this.normalizedLink();
2666
3160
  this.restoreSelection();
3161
+ this.focusEditor();
2667
3162
  const existing = this.anchorAtSelection();
2668
3163
  if (existing) {
2669
3164
  existing.setAttribute("href", url);
@@ -2695,6 +3190,8 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2695
3190
  }
2696
3191
  openImageDialog() {
2697
3192
  if (!this.canWrite()) return;
3193
+ this.showEmojiPanel.set(false);
3194
+ this.showSpecialPanel.set(false);
2698
3195
  this.saveSelection();
2699
3196
  this.imageUrl.set("");
2700
3197
  this.imageAlt.set("");
@@ -2705,6 +3202,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2705
3202
  if (!this.canWrite() || !this.canInsertImage()) return;
2706
3203
  this.bodyEdited.set(true);
2707
3204
  this.restoreSelection();
3205
+ this.focusEditor();
2708
3206
  const img = document.createElement("img");
2709
3207
  img.setAttribute("src", this.imageUrl().trim());
2710
3208
  img.setAttribute("alt", this.imageAlt() || this.labels.t("emailTemplateEditor.imageAltDefault"));
@@ -2774,7 +3272,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2774
3272
  this.assignmentsTouched.set(true);
2775
3273
  }
2776
3274
  isOpen(id) {
2777
- return id === "v:" + (this.variableGroups()[0]?.name ?? "") !== this.toggledGroups().has(id);
3275
+ return id === "v:" + (this.availableVariableGroups()[0]?.name ?? "") !== this.toggledGroups().has(id);
2778
3276
  }
2779
3277
  toggleGroup(id) {
2780
3278
  this.toggledGroups.update((s) => {
@@ -2788,6 +3286,59 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2788
3286
  if (!this.canWrite()) return;
2789
3287
  this.addBlockHtml(block.html);
2790
3288
  }
3289
+ emojiGroupLabel(key) {
3290
+ switch (key) {
3291
+ case "smileys": return this.labels.t("emailTemplateEditor.emojiGroup.smileys");
3292
+ case "gestures": return this.labels.t("emailTemplateEditor.emojiGroup.gestures");
3293
+ case "hearts": return this.labels.t("emailTemplateEditor.emojiGroup.hearts");
3294
+ case "remembrance": return this.labels.t("emailTemplateEditor.emojiGroup.remembrance");
3295
+ case "pets": return this.labels.t("emailTemplateEditor.emojiGroup.pets");
3296
+ case "nature": return this.labels.t("emailTemplateEditor.emojiGroup.nature");
3297
+ case "food": return this.labels.t("emailTemplateEditor.emojiGroup.food");
3298
+ case "places": return this.labels.t("emailTemplateEditor.emojiGroup.places");
3299
+ case "symbols": return this.labels.t("emailTemplateEditor.emojiGroup.symbols");
3300
+ default: return this.labels.t("emailTemplateEditor.emojiGroup.objects");
3301
+ }
3302
+ }
3303
+ toneLabel(key) {
3304
+ switch (key) {
3305
+ case "light": return this.labels.t("emailTemplateEditor.tone.light");
3306
+ case "mediumLight": return this.labels.t("emailTemplateEditor.tone.mediumLight");
3307
+ case "medium": return this.labels.t("emailTemplateEditor.tone.medium");
3308
+ case "mediumDark": return this.labels.t("emailTemplateEditor.tone.mediumDark");
3309
+ case "dark": return this.labels.t("emailTemplateEditor.tone.dark");
3310
+ default: return this.labels.t("emailTemplateEditor.tone.default");
3311
+ }
3312
+ }
3313
+ emojiWithTone(e) {
3314
+ return withSkinTone(e, this.emojiTone());
3315
+ }
3316
+ emojiName(e) {
3317
+ return `${this.emojiWithTone(e)} ${e.words.split(" ").slice(0, 3).join(" ")}`;
3318
+ }
3319
+ toggleEmojiPanel() {
3320
+ if (!this.canWrite()) return;
3321
+ this.showLinkDialog.set(false);
3322
+ this.showImageDialog.set(false);
3323
+ this.showSpecialPanel.set(false);
3324
+ this.colorPanel.set(null);
3325
+ this.showEmojiPanel.update((v) => !v);
3326
+ }
3327
+ toggleSpecialPanel() {
3328
+ if (!this.canWrite()) return;
3329
+ this.showLinkDialog.set(false);
3330
+ this.showImageDialog.set(false);
3331
+ this.showEmojiPanel.set(false);
3332
+ this.colorPanel.set(null);
3333
+ this.showSpecialPanel.update((v) => !v);
3334
+ }
3335
+ insertEmoji(emoji) {
3336
+ if (!this.canWrite()) return;
3337
+ this.runEditCommand(() => {
3338
+ document.execCommand("insertText", false, emoji);
3339
+ });
3340
+ this.syncBlock();
3341
+ }
2791
3342
  insertVariable(variable) {
2792
3343
  if (!this.canWrite()) return;
2793
3344
  this.runEditCommand(() => {
@@ -2795,13 +3346,6 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2795
3346
  });
2796
3347
  this.syncBlock();
2797
3348
  }
2798
- blockHtml(key) {
2799
- for (const g of this.blockGroups()) {
2800
- const found = g.blocks.find((b) => b.key === key);
2801
- if (found) return found.html;
2802
- }
2803
- return `<p>${this.labels.t("emailTemplateEditor.blockFallback")}</p>`;
2804
- }
2805
3349
  static {
2806
3350
  this.ษตfac = i0.ษตษตngDeclareFactory({
2807
3351
  minVersion: "12.0.0",
@@ -2848,6 +3392,13 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
2848
3392
  isRequired: false,
2849
3393
  transformFunction: null
2850
3394
  },
3395
+ showSaveHint: {
3396
+ classPropertyName: "showSaveHint",
3397
+ publicName: "showSaveHint",
3398
+ isSignal: true,
3399
+ isRequired: false,
3400
+ transformFunction: null
3401
+ },
2851
3402
  previewBrand: {
2852
3403
  classPropertyName: "previewBrand",
2853
3404
  publicName: "previewBrand",
@@ -3051,26 +3602,40 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3051
3602
  videosRequested: "videosRequested",
3052
3603
  useAsMine: "useAsMine"
3053
3604
  },
3054
- viewQueries: [{
3055
- propertyName: "blockEditors",
3056
- predicate: ["blockEditor"],
3057
- descendants: true,
3058
- isSignal: true
3059
- }, {
3060
- propertyName: "colorInputRef",
3061
- first: true,
3062
- predicate: ["colorInput"],
3063
- descendants: true,
3064
- isSignal: true
3065
- }],
3605
+ viewQueries: [
3606
+ {
3607
+ propertyName: "blockEditors",
3608
+ predicate: ["blockEditor"],
3609
+ descendants: true,
3610
+ isSignal: true
3611
+ },
3612
+ {
3613
+ propertyName: "colorInputRef",
3614
+ first: true,
3615
+ predicate: ["colorInput"],
3616
+ descendants: true,
3617
+ isSignal: true
3618
+ },
3619
+ {
3620
+ propertyName: "highlightInputRef",
3621
+ first: true,
3622
+ predicate: ["highlightInput"],
3623
+ descendants: true,
3624
+ isSignal: true
3625
+ }
3626
+ ],
3066
3627
  ngImport: i0,
3067
3628
  template: `
3068
3629
  <div class="editor-page">
3069
3630
  <!-- Actions (outside the white panels) -->
3070
3631
  <div class="editor-actions">
3071
- @if (heading()) {
3072
- <h2 class="editor-heading" data-testid="editor-heading">{{ heading() }}</h2>
3073
- }
3632
+ <div class="editor-heading-group">
3633
+ <!-- e.g. a back arrow button: content with the editor-heading-start attribute is shown before the heading, on the same row as Save -->
3634
+ <ng-content select="[editor-heading-start]" />
3635
+ @if (heading()) {
3636
+ <h2 class="editor-heading" data-testid="editor-heading">{{ heading() }}</h2>
3637
+ }
3638
+ </div>
3074
3639
  <div class="editor-actions-buttons">
3075
3640
  @if (canWrite() && testSendEnabled()) {
3076
3641
  <ui-button variant="secondary" size="sm" (click)="openTestSendDialog()">
@@ -3081,7 +3646,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3081
3646
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>{{ labels.t('emailTemplateEditor.saveTemplate') }}</ui-button>
3082
3647
  </span>
3083
3648
  </div>
3084
- @if (saveHintVisible(); as hint) {
3649
+ @if (showSaveHint() && saveHintVisible(); as hint) {
3085
3650
  <!-- A blocked Save explains itself in visible text, not only in the tooltip. -->
3086
3651
  <p class="save-hint" role="status" data-testid="save-hint">{{ hint }}</p>
3087
3652
  }
@@ -3102,34 +3667,34 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3102
3667
  <!-- 3-Column Layout -->
3103
3668
  <div class="editor-body">
3104
3669
  <!-- LEFT PANEL: Details -->
3105
- <aside class="panel-left" [attr.aria-label]="labels.t('emailTemplateEditor.templateDetails')">
3670
+ <aside class="panel-left" data-testid="editor-details" [attr.aria-label]="labels.t('emailTemplateEditor.templateDetails')">
3106
3671
  <h3 class="panel-title">{{ labels.t('common.details') }}</h3>
3107
3672
 
3108
3673
  <div class="form-field">
3109
- <ui-text-input [label]="labels.t('common.name')" [required]="true" [(ngModel)]="name" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3674
+ <ui-text-input data-testid="template-name" [label]="labels.t('common.name')" [required]="true" [(ngModel)]="name" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3110
3675
  [placeholder]="namePlaceholder()" [error]="nameErrorShown()" [showErrors]="nameTouched()" (blurred)="nameTouched.set(true)" />
3111
3676
  </div>
3112
3677
 
3113
3678
  <div class="form-field">
3114
- <ui-text-input [label]="labels.t('common.subject')" [required]="true" [(ngModel)]="subject" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3679
+ <ui-text-input data-testid="template-subject" [label]="labels.t('common.subject')" [required]="true" [(ngModel)]="subject" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3115
3680
  [placeholder]="subjectPlaceholder()" [error]="subjectErrorShown()" [showErrors]="subjectTouched()" (blurred)="subjectTouched.set(true)">
3116
3681
  </ui-text-input>
3117
3682
  </div>
3118
3683
 
3119
3684
  @if (showCategory()) {
3120
3685
  <div class="form-field">
3121
- <ui-select [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
3686
+ <ui-select data-testid="template-category" [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
3122
3687
  </div>
3123
3688
  }
3124
3689
 
3125
3690
  @if (showActiveRange()) {
3126
- <ui-checkbox [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
3691
+ <ui-checkbox data-testid="template-all-year" [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
3127
3692
  }
3128
3693
 
3129
3694
  @if (showActiveRange() && !useAllYear()) {
3130
3695
  <div class="form-row-dates" (focusout)="datesTouched.set(true)">
3131
- <ui-date-input [label]="labels.t('emailTemplateEditor.activeFrom')" [(ngModel)]="activeFrom" [disabled]="!canWrite()" />
3132
- <ui-date-input [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeFrom()" [error]="datesError()" />
3696
+ <ui-date-input data-testid="template-active-from" [label]="labels.t('emailTemplateEditor.activeFrom')" [ngModel]="activeFrom()" (ngModelChange)="onActiveFromChange($event)" [disabled]="!canWrite()" [min]="today" />
3697
+ <ui-date-input data-testid="template-active-to" [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeToMin()" [error]="datesError()" />
3133
3698
  </div>
3134
3699
  }
3135
3700
 
@@ -3139,17 +3704,20 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3139
3704
  <h4 class="section-title">{{ labels.t('emailTemplateEditor.assignments') }}<span class="required" aria-hidden="true">*</span></h4>
3140
3705
  <p class="section-desc">{{ assignmentsDescription() }}</p>
3141
3706
  <ui-error [errorId]="idPrefix() + '-assignments-error'" [message]="assignmentErrorShown()" />
3142
- <ui-search-input [placeholder]="labels.t('common.searchellipsis')" [ariaLabel]="labels.t('emailTemplateEditor.searchAssignments')" [(value)]="assignmentSearch" />
3707
+ <ui-search-input data-testid="assignment-search" [placeholder]="labels.t('common.searchellipsis')" [ariaLabel]="labels.t('emailTemplateEditor.searchAssignments')" [(value)]="assignmentSearch" />
3143
3708
  @if (filteredAssignments().length === 0) {
3144
3709
  <ui-empty-state iconType="search" [title]="labels.t('emailTemplateEditor.noAssignmentsFound')" [message]="labels.t('emailTemplateEditor.noAssignmentsMatchYourSearch')" />
3145
3710
  }
3146
- <div class="assignment-list" [hidden]="filteredAssignments().length === 0" (focusout)="onAssignmentsFocusOut($event)">
3711
+ <div class="assignment-list" data-testid="assignment-list" [hidden]="filteredAssignments().length === 0" (focusout)="onAssignmentsFocusOut($event)">
3147
3712
  @for (item of filteredAssignments(); track item.key) {
3148
- <div class="assignment-item" [class.assignment-readonly]="!canWrite()" [attr.role]="canWrite() ? 'switch' : null" [attr.tabindex]="canWrite() ? 0 : null"
3713
+ @if (item.groupStart) {
3714
+ <div class="assignment-group" role="heading" aria-level="5" data-testid="assignment-group">{{ item.group }}</div>
3715
+ }
3716
+ <div class="assignment-item" data-testid="assignment-item" [attr.data-assignment]="item.key" [class.assignment-readonly]="!canWrite()" [attr.role]="canWrite() ? 'switch' : null" [attr.tabindex]="canWrite() ? 0 : null"
3149
3717
  [attr.aria-checked]="canWrite() ? item.assigned : null" [attr.aria-label]="canWrite() ? item.name : null"
3150
3718
  (click)="toggleAssignment(item)" (keydown.enter)="toggleAssignment(item); $event.preventDefault()" (keydown.space)="toggleAssignment(item); $event.preventDefault()">
3151
3719
  <div class="assignment-text">
3152
- <strong>{{ item.name }}</strong>
3720
+ <strong data-testid="assignment-name">{{ item.name }}</strong>
3153
3721
  <span>{{ item.description }}</span>
3154
3722
  </div>
3155
3723
  <div class="assignment-channels">
@@ -3167,88 +3735,134 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3167
3735
  <!-- CENTER: Editor -->
3168
3736
  <section class="panel-center" [attr.aria-label]="labels.t('emailTemplateEditor.emailDesign')">
3169
3737
  <div class="editor-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.editorView')">
3170
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'edit'" [attr.aria-selected]="activeEditorTab() === 'edit'" (click)="setEditorTab('edit')">
3738
+ <button type="button" class="editor-tab" data-testid="editor-tab-edit" role="tab" [class.active]="activeEditorTab() === 'edit'" [attr.aria-selected]="activeEditorTab() === 'edit'" (click)="setEditorTab('edit')">
3171
3739
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>{{ labels.t('common.edit') }}</button>
3172
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'preview'" [attr.aria-selected]="activeEditorTab() === 'preview'" (click)="setEditorTab('preview')">
3740
+ <button type="button" class="editor-tab" data-testid="editor-tab-preview" role="tab" [class.active]="activeEditorTab() === 'preview'" [attr.aria-selected]="activeEditorTab() === 'preview'" (click)="setEditorTab('preview')">
3173
3741
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>{{ labels.t('common.preview') }}</button>
3174
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'mobile'" [attr.aria-selected]="activeEditorTab() === 'mobile'" (click)="setEditorTab('mobile')">
3742
+ <button type="button" class="editor-tab" data-testid="editor-tab-mobile" role="tab" [class.active]="activeEditorTab() === 'mobile'" [attr.aria-selected]="activeEditorTab() === 'mobile'" (click)="setEditorTab('mobile')">
3175
3743
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="5" y="2" width="14" height="20" rx="2" ry="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>{{ labels.t('common.mobile') }}</button>
3176
3744
  </div>
3177
3745
 
3178
3746
  @if (activeEditorTab() === 'edit') {
3179
3747
  @if (canWrite()) {
3180
- <!-- Toolbar row 1: mousedown preventDefault keeps focus (and the selection) in the editor -->
3181
- <div class="editor-toolbar" role="toolbar" [attr.aria-label]="labels.t('emailTemplateEditor.textFormatting')" (mousedown)="preventFocusLoss($event)">
3748
+ <!-- Toolbar (the last group is the block spacing): mousedown preventDefault keeps focus (and the selection) in the editor -->
3749
+ <div class="editor-toolbar" data-testid="editor-toolbar" role="toolbar" [attr.aria-label]="labels.t('emailTemplateEditor.textFormatting')" (mousedown)="preventFocusLoss($event)">
3182
3750
  <div class="toolbar-group">
3183
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bold')" [uiTooltip]="labels.t('emailTemplateEditor.tipBold')" (click)="execCommand('bold')"><strong>B</strong></ui-button>
3184
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.italic')" [uiTooltip]="labels.t('emailTemplateEditor.tipItalic')" (click)="execCommand('italic')"><em>I</em></ui-button>
3185
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.underline')" [uiTooltip]="labels.t('emailTemplateEditor.tipUnderline')" (click)="execCommand('underline')"><u>U</u></ui-button>
3186
- </div>
3187
- <div class="toolbar-group">
3188
- @for (k of [headingKey()]; track k) {
3189
- <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.headingLevel')" [options]="headingOptions" ngModel="p"
3190
- (mousedown)="saveSelection()" (ngModelChange)="onHeading($event)" />
3191
- }
3751
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.undo')" [uiTooltip]="labels.t('emailTemplateEditor.undo')" (click)="execCommand('undo')">
3752
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13"/></svg>
3753
+ </ui-button>
3754
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.redo')" [uiTooltip]="labels.t('emailTemplateEditor.redo')" (click)="execCommand('redo')">
3755
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13"/></svg>
3756
+ </ui-button>
3192
3757
  </div>
3193
3758
  <div class="toolbar-group">
3759
+ <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.headingLevel')" [options]="headingOptions" [ngModel]="headingValue()"
3760
+ (mousedown)="saveSelection()" (ngModelChange)="onHeading($event)" />
3194
3761
  @for (k of [sizeKey()]; track k) {
3195
3762
  <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.fontSize')" [placeholder]="labels.t('emailTemplateEditor.size')" [options]="fontSizeOptions" ngModel=""
3196
3763
  (mousedown)="saveSelection()" (ngModelChange)="onFontSize($event)" />
3197
3764
  }
3198
3765
  </div>
3199
3766
  <div class="toolbar-group">
3200
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignLeft')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignLeft')" (click)="execCommand('justifyLeft')">
3201
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>
3202
- </ui-button>
3203
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignCenter')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignCenter')" (click)="execCommand('justifyCenter')">
3204
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>
3205
- </ui-button>
3206
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignRight')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignRight')" (click)="execCommand('justifyRight')">
3207
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>
3767
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bold')" [uiTooltip]="labels.t('emailTemplateEditor.tipBold')" (click)="execCommand('bold')"><strong>B</strong></ui-button>
3768
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.italic')" [uiTooltip]="labels.t('emailTemplateEditor.tipItalic')" (click)="execCommand('italic')"><em>I</em></ui-button>
3769
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.underline')" [uiTooltip]="labels.t('emailTemplateEditor.tipUnderline')" (click)="execCommand('underline')"><u>U</u></ui-button>
3770
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.strikethrough')" [uiTooltip]="labels.t('emailTemplateEditor.strikethrough')" (click)="execCommand('strikeThrough')">
3771
+ <s>S</s>
3208
3772
  </ui-button>
3209
- </div>
3210
- <div class="toolbar-group">
3211
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bulletedList')" [uiTooltip]="labels.t('emailTemplateEditor.tipBulletedList')" (click)="execCommand('insertUnorderedList')">
3212
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
3773
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.subscript')" [uiTooltip]="labels.t('emailTemplateEditor.subscript')" (click)="execCommand('subscript')">
3774
+ <span class="tb-sub">x<sub>2</sub></span>
3213
3775
  </ui-button>
3214
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.numberedList')" [uiTooltip]="labels.t('emailTemplateEditor.tipNumberedList')" (click)="execCommand('insertOrderedList')">
3215
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>
3776
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.superscript')" [uiTooltip]="labels.t('emailTemplateEditor.superscript')" (click)="execCommand('superscript')">
3777
+ <span class="tb-sub">x<sup>2</sup></span>
3216
3778
  </ui-button>
3217
3779
  </div>
3218
3780
  <div class="toolbar-group">
3219
- <!-- The browser's own colour dialog is the picker; a button opens it so the toolbar keeps one look. -->
3781
+ <!-- The browser's own colour dialogs are the pickers; a button opens each so the toolbar keeps one look. -->
3220
3782
  <input #colorInput type="color" class="hidden-color-input" [attr.aria-label]="labels.t('emailTemplateEditor.textColor')" tabindex="-1" [value]="currentColor()" (change)="applyTextColor($any($event.target).value)" (mousedown)="$event.stopPropagation()" />
3221
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.textColor')" [uiTooltip]="labels.t('emailTemplateEditor.tipTextColor')" (mousedown)="openColorPicker()">
3783
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.textColor')" [uiTooltip]="labels.t('emailTemplateEditor.tipTextColor')" data-testid="text-color-button" (mousedown)="saveSelection()" (click)="toggleColorPanel('text')">
3222
3784
  <span class="color-indicator">
3223
3785
  <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><text y="20" font-size="20" font-weight="700">A</text></svg>
3224
3786
  <span class="color-bar" [style.background]="currentColor()"></span>
3225
3787
  </span>
3226
3788
  </ui-button>
3789
+ <input #highlightInput type="color" class="hidden-color-input" [attr.aria-label]="labels.t('emailTemplateEditor.highlightColor')" tabindex="-1" [value]="currentHighlight()" (change)="applyHighlight($any($event.target).value)" (mousedown)="$event.stopPropagation()" />
3790
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.highlightColor')" [uiTooltip]="labels.t('emailTemplateEditor.highlightColor')" data-testid="highlight-color-button" (mousedown)="saveSelection()" (click)="toggleColorPanel('highlight')">
3791
+ <span class="color-indicator">
3792
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 11l-6 6v3h9l3-3"/><path d="M22 12l-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>
3793
+ <span class="color-bar" [style.background]="currentHighlight()"></span>
3794
+ </span>
3795
+ </ui-button>
3796
+ </div>
3797
+ <div class="toolbar-group">
3798
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignLeft')" [uiTooltip]="labels.t('emailTemplateEditor.alignLeft')" (click)="execCommand('justifyLeft')">
3799
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>
3800
+ </ui-button>
3801
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignCenter')" [uiTooltip]="labels.t('emailTemplateEditor.alignCenter')" (click)="execCommand('justifyCenter')">
3802
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>
3803
+ </ui-button>
3804
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignRight')" [uiTooltip]="labels.t('emailTemplateEditor.alignRight')" (click)="execCommand('justifyRight')">
3805
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>
3806
+ </ui-button>
3807
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignJustify')" [uiTooltip]="labels.t('emailTemplateEditor.alignJustify')" (click)="execCommand('justifyFull')">
3808
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="21" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="3" y2="18"/></svg>
3809
+ </ui-button>
3227
3810
  </div>
3228
3811
  <div class="toolbar-group">
3229
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertLink')" [uiTooltip]="labels.t('emailTemplateEditor.tipInsertLink')" (mousedown)="saveSelection()" (click)="openLinkDialog()">
3230
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
3812
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bulletedList')" [uiTooltip]="labels.t('emailTemplateEditor.bulletedList')" (click)="execCommand('insertUnorderedList')">
3813
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
3814
+ </ui-button>
3815
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.numberedList')" [uiTooltip]="labels.t('emailTemplateEditor.numberedList')" (click)="execCommand('insertOrderedList')">
3816
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>
3817
+ </ui-button>
3818
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.outdent')" [uiTooltip]="labels.t('emailTemplateEditor.outdent')" (click)="execCommand('outdent')">
3819
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>
3231
3820
  </ui-button>
3232
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertImage')" [uiTooltip]="labels.t('emailTemplateEditor.tipInsertImage')" (mousedown)="saveSelection()" (click)="openImageDialog()">
3233
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
3821
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.indent')" [uiTooltip]="labels.t('emailTemplateEditor.indent')" (click)="execCommand('indent')">
3822
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 8 7 12 3 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>
3234
3823
  </ui-button>
3235
3824
  </div>
3236
3825
  <div class="toolbar-group">
3237
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.undo')" [uiTooltip]="labels.t('emailTemplateEditor.tipUndo')" (click)="execCommand('undo')">
3238
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13"/></svg>
3826
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertLink')" [uiTooltip]="labels.t('emailTemplateEditor.insertLink')" (mousedown)="saveSelection()" (click)="openLinkDialog()">
3827
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
3828
+ </ui-button>
3829
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertImage')" [uiTooltip]="labels.t('emailTemplateEditor.insertImage')" (mousedown)="saveSelection()" (click)="openImageDialog()">
3830
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
3831
+ </ui-button>
3832
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertTable')" [uiTooltip]="labels.t('emailTemplateEditor.insertTable')" (mousedown)="saveSelection()" (click)="insertTable()">
3833
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
3834
+ </ui-button>
3835
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.blockQuote')" [uiTooltip]="labels.t('emailTemplateEditor.blockQuote')" data-testid="quote-button" (click)="toggleQuote()">
3836
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3 21c3 0 7-1 7-8V5H3v8h4c0 3-2 4-4 4zm11 0c3 0 7-1 7-8V5h-7v8h4c0 3-2 4-4 4z"/></svg>
3239
3837
  </ui-button>
3240
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.redo')" [uiTooltip]="labels.t('emailTemplateEditor.tipRedo')" (click)="execCommand('redo')">
3241
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13"/></svg>
3838
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.horizontalLine')" [uiTooltip]="labels.t('emailTemplateEditor.horizontalLine')" (click)="execCommand('insertHorizontalRule')">
3839
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="3" y1="12" x2="21" y2="12"/></svg>
3242
3840
  </ui-button>
3243
3841
  </div>
3244
- </div>
3245
-
3246
- <!-- Toolbar row 2: block spacing -->
3247
- <div class="toolbar-row-2">
3248
- <div class="toolbar-group" (mousedown)="preventFocusLoss($event)">
3249
- <span class="toolbar-label" id="tpl-spacing-label">{{ labels.t('emailTemplateEditor.blockSpacing') }}</span>
3250
- <ui-pill-tabs [tabs]="spacingTabs" [activeKey]="blockSpacing() || 'none'" [ariaLabel]="labels.t('emailTemplateEditor.blockSpacing')" (tabChange)="applySpacing($event === 'none' ? '' : $event)" />
3842
+ <div class="toolbar-group">
3843
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.emoji')" [uiTooltip]="labels.t('emailTemplateEditor.tipEmoji')" data-testid="emoji-button" (mousedown)="saveSelection()" (click)="toggleEmojiPanel()">
3844
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>
3845
+ </ui-button>
3846
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.specialCharacters')" [uiTooltip]="labels.t('emailTemplateEditor.specialCharacters')" data-testid="special-button" (mousedown)="saveSelection()" (click)="toggleSpecialPanel()">
3847
+ <span class="tb-sub">ฮฉ</span>
3848
+ </ui-button>
3849
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.clearFormatting')" [uiTooltip]="labels.t('emailTemplateEditor.clearFormatting')" (click)="execCommand('removeFormat')">
3850
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/><line x1="3" y1="3" x2="21" y2="21"/></svg>
3851
+ </ui-button>
3251
3852
  </div>
3853
+ <div class="toolbar-group">
3854
+ <ui-select class="toolbar-select" size="sm" data-testid="spacing-select" [ariaLabel]="labels.t('emailTemplateEditor.blockSpacing')" [uiTooltip]="labels.t('emailTemplateEditor.blockSpacing')" [options]="spacingOptions" [ngModel]="blockSpacing() || 'none'"
3855
+ (mousedown)="saveSelection()" (ngModelChange)="applySpacing($event === 'none' ? '' : $event)" />
3856
+ </div>
3857
+ @if (inTable()) {
3858
+ <div class="toolbar-group" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.tableTools')" data-testid="table-tools">
3859
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableAddRow')" [uiTooltip]="labels.t('emailTemplateEditor.tableAddRow')" (click)="tableAddRow()"><span class="tb-sub">+ โ†“</span></ui-button>
3860
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableAddColumn')" [uiTooltip]="labels.t('emailTemplateEditor.tableAddColumn')" (click)="tableAddColumn()"><span class="tb-sub">+ โ†’</span></ui-button>
3861
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDeleteRow')" [uiTooltip]="labels.t('emailTemplateEditor.tableDeleteRow')" (click)="tableDeleteRow()"><span class="tb-sub">โˆ’ โ†“</span></ui-button>
3862
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDeleteColumn')" [uiTooltip]="labels.t('emailTemplateEditor.tableDeleteColumn')" (click)="tableDeleteColumn()"><span class="tb-sub">โˆ’ โ†’</span></ui-button>
3863
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDelete')" [uiTooltip]="labels.t('emailTemplateEditor.tableDelete')" (click)="tableDelete()"><span class="tb-sub">โœ•</span></ui-button>
3864
+ </div>
3865
+ }
3252
3866
  </div>
3253
3867
  }
3254
3868
 
@@ -3257,9 +3871,9 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3257
3871
  <div class="link-dialog" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.insertLink')">
3258
3872
  <div class="link-dialog-inner">
3259
3873
  <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.insertLink2') }}</span>
3260
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkAddress')" placeholder="https://example.com" [(ngModel)]="linkUrl" [error]="linkUrlError()" (keydown.enter)="insertLink()" />
3874
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkAddress')" placeholder="https://example.com" [(ngModel)]="linkUrl" [error]="linkUrlError()" (keydown.enter)="insertLink(); $event.preventDefault()" />
3261
3875
  @if (!linkTextFromSelection()) {
3262
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkText')" [placeholder]="labels.t('emailTemplateEditor.linkTextOptional')" [(ngModel)]="linkText" (keydown.enter)="insertLink()" />
3876
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkText')" [placeholder]="labels.t('emailTemplateEditor.linkTextOptional')" [(ngModel)]="linkText" (keydown.enter)="insertLink(); $event.preventDefault()" />
3263
3877
  }
3264
3878
  <div class="link-dialog-actions">
3265
3879
  <ui-button variant="secondary" size="sm" (click)="showLinkDialog.set(false)">{{ labels.t('common.cancel') }}</ui-button>
@@ -3269,18 +3883,75 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3269
3883
  </div>
3270
3884
  }
3271
3885
 
3886
+ <!-- Colour picker (inline panel, for the text colour and the highlight): a grid of ready colours, a custom colour (the browser's own dialog) and Remove -->
3887
+ @if (canWrite() && colorPanel(); as which) {
3888
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t(which === 'text' ? 'emailTemplateEditor.textColor' : 'emailTemplateEditor.highlightColor')" data-testid="color-panel" (mousedown)="preventFocusLoss($event)" (keydown.escape)="colorPanel.set(null)">
3889
+ <div class="emoji-panel-head">
3890
+ <span class="link-dialog-title">{{ labels.t(which === 'text' ? 'emailTemplateEditor.textColor' : 'emailTemplateEditor.highlightColor') }}</span>
3891
+ <ui-button variant="secondary" size="sm" data-testid="color-remove" (click)="removeColor(which)">{{ labels.t('emailTemplateEditor.removeColor') }}</ui-button>
3892
+ <ui-button variant="secondary" size="sm" data-testid="color-custom" (click)="openCustomColor(which)">{{ labels.t('emailTemplateEditor.customColor') }}</ui-button>
3893
+ <ui-button variant="secondary" size="sm" (click)="colorPanel.set(null)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
3894
+ </div>
3895
+ <div class="color-grid" data-testid="color-grid">
3896
+ @for (c of colorSwatches; track c) {
3897
+ <button type="button" class="color-swatch" data-testid="color-swatch" [style.background]="c" [attr.aria-label]="c" [attr.title]="c" [class.selected]="(which === 'text' ? currentColor() : currentHighlight()).toLowerCase() === c" [attr.aria-pressed]="(which === 'text' ? currentColor() : currentHighlight()).toLowerCase() === c" (click)="pickColor(which, c)"></button>
3898
+ }
3899
+ </div>
3900
+ </div>
3901
+ }
3902
+
3903
+ <!-- Emoji picker (inline popover): a search box, category tabs and a skin tone; a click inserts the emoji at the caret and the panel stays open for more -->
3904
+ @if (canWrite() && showEmojiPanel()) {
3905
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.emoji')" data-testid="emoji-panel" (mousedown)="preventFocusLoss($event)">
3906
+ <div class="emoji-panel-head">
3907
+ <ui-text-input class="emoji-search" data-testid="emoji-search" [ariaLabel]="labels.t('emailTemplateEditor.emojiSearch')" [placeholder]="labels.t('emailTemplateEditor.emojiSearch')" [(ngModel)]="emojiSearch" (mousedown)="saveSelection()" />
3908
+ <ui-select class="emoji-tone" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.emojiSkinTone')" [options]="skinToneOptions()" [(ngModel)]="emojiTone" (mousedown)="saveSelection()" />
3909
+ <ui-button variant="secondary" size="sm" (click)="showEmojiPanel.set(false)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
3910
+ </div>
3911
+ @if (!emojiSearch().trim()) {
3912
+ <div class="emoji-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.emoji')">
3913
+ @for (g of emojiGroupKeys; track g.key) {
3914
+ <button type="button" role="tab" class="emoji-tab" [class.active]="emojiGroup() === g.key" [attr.aria-selected]="emojiGroup() === g.key" [attr.aria-label]="emojiGroupLabel(g.key)" [attr.title]="emojiGroupLabel(g.key)" (click)="emojiGroup.set(g.key)">{{ g.icon }}</button>
3915
+ }
3916
+ </div>
3917
+ }
3918
+ <div class="emoji-grid" data-testid="emoji-grid">
3919
+ @for (e of shownEmojis(); track e.char) {
3920
+ <button type="button" class="emoji-btn" data-testid="emoji-option" [attr.aria-label]="emojiName(e)" [attr.title]="e.words.split(' ').slice(0, 3).join(' ')" (click)="insertEmoji(emojiWithTone(e))">{{ emojiWithTone(e) }}</button>
3921
+ } @empty {
3922
+ <span class="emoji-empty">{{ labels.t('emailTemplateEditor.emojiNoResults') }}</span>
3923
+ }
3924
+ </div>
3925
+ </div>
3926
+ }
3927
+
3928
+ <!-- Special characters (inline popover) -->
3929
+ @if (canWrite() && showSpecialPanel()) {
3930
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.specialCharacters')" data-testid="special-panel" (mousedown)="preventFocusLoss($event)">
3931
+ <div class="emoji-panel-head">
3932
+ <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.specialCharactersTitle') }}</span>
3933
+ <ui-button variant="secondary" size="sm" (click)="showSpecialPanel.set(false)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
3934
+ </div>
3935
+ <div class="emoji-grid">
3936
+ @for (c of specialCharacters; track c) {
3937
+ <button type="button" class="emoji-btn special-btn" data-testid="special-option" [attr.aria-label]="c" (click)="insertEmoji(c)">{{ c }}</button>
3938
+ }
3939
+ </div>
3940
+ </div>
3941
+ }
3942
+
3272
3943
  <!-- Image URL dialog -->
3273
3944
  @if (canWrite() && showImageDialog()) {
3274
3945
  <div class="link-dialog" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.insertImage')">
3275
3946
  <div class="link-dialog-inner">
3276
3947
  <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.insertImage2') }}</span>
3277
3948
  @if (imageUpload()) {
3278
- <input #imageFile type="file" class="hidden-file-input" accept="image/png,image/jpeg,image/webp,image/gif" tabindex="-1" [attr.aria-label]="labels.t('emailTemplateEditor.uploadImage')" (change)="onImageFile($event)" />
3949
+ <input #imageFile type="file" class="hidden-file-input" data-testid="image-file-input" accept="image/png,image/jpeg,image/webp,image/gif" tabindex="-1" [attr.aria-label]="labels.t('emailTemplateEditor.uploadImage')" (change)="onImageFile($event)" />
3279
3950
  <ui-button variant="secondary" size="sm" [loading]="imageUploading()" (click)="imageFile.click()">{{ imageUploading() ? labels.t('emailTemplateEditor.uploadingImage') : labels.t('emailTemplateEditor.uploadImage') }}</ui-button>
3280
3951
  <ui-error [errorId]="idPrefix() + '-image-upload-error'" [message]="imageUploadError()" />
3281
3952
  }
3282
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAddress')" placeholder="https://example.com/image.jpg" [(ngModel)]="imageUrl" [error]="imageUrlError()" (keydown.enter)="insertImageFromUrl()" />
3283
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAltText')" [placeholder]="labels.t('emailTemplateEditor.altTextOptional')" [(ngModel)]="imageAlt" (keydown.enter)="insertImageFromUrl()" />
3953
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAddress')" placeholder="https://example.com/image.jpg" [(ngModel)]="imageUrl" [error]="imageUrlError()" (keydown.enter)="insertImageFromUrl(); $event.preventDefault()" />
3954
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAltText')" [placeholder]="labels.t('emailTemplateEditor.altTextOptional')" [(ngModel)]="imageAlt" (keydown.enter)="insertImageFromUrl(); $event.preventDefault()" />
3284
3955
  <div class="link-dialog-actions">
3285
3956
  <ui-button variant="secondary" size="sm" (click)="showImageDialog.set(false)">{{ labels.t('common.cancel') }}</ui-button>
3286
3957
  <ui-button variant="primary" size="sm" [disabled]="!canInsertImage()" (click)="insertImageFromUrl()">{{ labels.t('common.insert') }}</ui-button>
@@ -3301,70 +3972,30 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3301
3972
  </ui-alert>
3302
3973
  }
3303
3974
 
3304
- <!-- Block Canvas with DnD -->
3305
- <div class="blocks-canvas" (dragover)="onCanvasDragOver($event)" (drop)="onDropZoneDrop($event, blocks().length)" (focusout)="onBodyFocusOut($event)">
3306
- <!-- Initial drop zone (before first block) -->
3307
- <div class="drop-zone" [class.active]="dragOverIndex() === 0" (dragover)="onDropZoneDragOver($event, 0)" (dragleave)="onDropZoneLeave()" (drop)="onDropZoneDrop($event, 0)">
3308
- <span class="drop-zone-label">{{ labels.t('emailTemplateEditor.dropHere') }}</span>
3309
- </div>
3310
-
3311
- @for (block of blocks(); track block.id; let i = $index) {
3312
- <div class="block-wrapper" #blockWrapper [class.selected]="selectedBlockId() === block.id" [class.dragging]="dragFromCanvas() === i" (dragend)="onBlockDragEnd()">
3313
- @if (canWrite()) {
3314
- <!-- Only the handle is draggable: a draggable ancestor of the contenteditable breaks text selection in Firefox / Safari. Move up / down below are the keyboard and touch alternative. -->
3315
- <div class="block-drag-handle" [attr.title]="labels.t('emailTemplateEditor.dragToReorder')" draggable="true" (dragstart)="onBlockDragStart($event, i, blockWrapper)">
3316
- <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="9" cy="6" r="1.5"/><circle cx="15" cy="6" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="9" cy="18" r="1.5"/><circle cx="15" cy="18" r="1.5"/></svg>
3317
- </div>
3318
- }
3319
-
3320
- <!-- Block content (contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps) -->
3321
- <div #blockEditor class="block-content" role="textbox" aria-multiline="true" [attr.aria-label]="labels.t('emailTemplateEditor.emailBlockN', { n: i + 1 })"
3322
- [attr.data-block-id]="block.id" [attr.data-placeholder]="i === 0 ? startPlaceholder() : labels.t('emailTemplateEditor.clickToEdit')" [attr.contenteditable]="canWrite() ? 'true' : 'false'"
3323
- (input)="onBlockInput($event, block)" (beforeinput)="onBlockBeforeInput($any($event))" (focus)="onBlockFocus(block)" (click)="selectedBlockId.set(block.id)"></div>
3324
-
3325
- @if (canWrite()) {
3326
- <div class="block-controls">
3327
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.moveBlockUp')" [uiTooltip]="labels.t('emailTemplateEditor.tipMoveUp')" [disabled]="i === 0" (mousedown)="preventFocusLoss($event)" (click)="moveBlock(i, -1)">
3328
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M18 15l-6-6-6 6"/></svg>
3329
- </ui-button>
3330
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.moveBlockDown')" [uiTooltip]="labels.t('emailTemplateEditor.tipMoveDown')" [disabled]="i === blocks().length - 1" (mousedown)="preventFocusLoss($event)" (click)="moveBlock(i, 1)">
3331
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>
3332
- </ui-button>
3333
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.duplicateBlock')" [uiTooltip]="labels.t('emailTemplateEditor.tipDuplicate')" (mousedown)="preventFocusLoss($event)" (click)="duplicateBlock(i)">
3334
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
3335
- </ui-button>
3336
- @if (blocks().length > 1) {
3337
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.deleteBlock')" [uiTooltip]="labels.t('emailTemplateEditor.tipDeleteBlock')" (mousedown)="preventFocusLoss($event)" (click)="deleteBlock(i)">
3338
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/></svg>
3339
- </ui-button>
3340
- }
3341
- </div>
3342
- }
3975
+ <!-- The document: ONE editing surface, like a word processor. The page is as wide as a sent email's card (600px) with the same 28px side padding, so the text wraps as it does in an inbox. -->
3976
+ <div class="blocks-canvas" [style.font-family]="canvasFont()" (focusout)="onBodyFocusOut($event)">
3977
+ @for (block of blocks(); track block.id) {
3978
+ <div class="block-wrapper">
3979
+ <!-- contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps -->
3980
+ <div #blockEditor class="block-content tpl-doc" data-testid="email-document" role="textbox" aria-multiline="true" [attr.aria-label]="labels.t('emailTemplateEditor.documentLabel')"
3981
+ [attr.data-block-id]="block.id" [attr.data-placeholder]="startPlaceholder()" [attr.contenteditable]="canWrite() ? 'true' : 'false'"
3982
+ (input)="onBlockInput($event, block)" (beforeinput)="onBlockBeforeInput($any($event))" (focus)="onBlockFocus(block)" (keyup)="refreshContext()" (mouseup)="refreshContext()" (keydown.enter)="onDocEnter($event)"
3983
+ (dragover)="onDocDragOver($event)" (drop)="onDocDrop($event)"></div>
3343
3984
  </div>
3344
-
3345
- <!-- Drop zone after each block -->
3346
- <div class="drop-zone" [class.active]="dragOverIndex() === i + 1" (dragover)="onDropZoneDragOver($event, i + 1)" (dragleave)="onDropZoneLeave()" (drop)="onDropZoneDrop($event, i + 1)">
3347
- <span class="drop-zone-label">{{ labels.t('emailTemplateEditor.dropHere') }}</span>
3348
- </div>
3349
- }
3350
-
3351
- @if (canWrite()) {
3352
- <button type="button" class="add-block-btn" (click)="addBlock('text-block')">
3353
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>{{ labels.t('emailTemplateEditor.addBlock') }}</button>
3354
3985
  }
3355
3986
  </div>
3356
3987
  }
3357
3988
 
3358
3989
  @if (activeEditorTab() === 'preview') {
3359
- <div class="preview-frame">
3360
- <iframe class="preview-content" [attr.title]="labels.t('emailTemplateEditor.emailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
3990
+ <div class="preview-frame" data-testid="preview-frame">
3991
+ <iframe class="preview-content" data-testid="preview-iframe" [attr.title]="labels.t('emailTemplateEditor.emailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
3361
3992
  </div>
3362
3993
  }
3363
3994
 
3364
3995
  @if (activeEditorTab() === 'mobile') {
3365
- <div class="preview-frame mobile">
3366
- <div class="mobile-shell">
3367
- <iframe class="preview-content" [attr.title]="labels.t('emailTemplateEditor.mobileEmailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
3996
+ <div class="preview-frame mobile" data-testid="mobile-preview-frame">
3997
+ <div class="mobile-shell" data-testid="mobile-shell">
3998
+ <iframe class="preview-content" data-testid="mobile-preview-iframe" [attr.title]="labels.t('emailTemplateEditor.mobileEmailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
3368
3999
  </div>
3369
4000
  </div>
3370
4001
  }
@@ -3379,18 +4010,18 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3379
4010
  </div>
3380
4011
  } @else {
3381
4012
  <div class="right-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.rightPanelSections')">
3382
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'blocks'" [attr.aria-selected]="activeRightTab() === 'blocks'" (click)="activeRightTab.set('blocks')">
4013
+ <button type="button" class="right-tab" data-testid="right-tab-blocks" role="tab" [class.active]="activeRightTab() === 'blocks'" [attr.aria-selected]="activeRightTab() === 'blocks'" (click)="activeRightTab.set('blocks')">
3383
4014
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>{{ labels.t('emailTemplateEditor.blocks') }}</button>
3384
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'variables'" [attr.aria-selected]="activeRightTab() === 'variables'" (click)="activeRightTab.set('variables')">
4015
+ <button type="button" class="right-tab" data-testid="right-tab-variables" role="tab" [class.active]="activeRightTab() === 'variables'" [attr.aria-selected]="activeRightTab() === 'variables'" (click)="activeRightTab.set('variables')">
3385
4016
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 3v18M3 12h18"/></svg>{{ labels.t('emailTemplateEditor.variables') }}</button>
3386
4017
  @if (videosEnabled()) {
3387
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'video'" [attr.aria-selected]="activeRightTab() === 'video'" (click)="openVideoTab()">
4018
+ <button type="button" class="right-tab" data-testid="right-tab-video" role="tab" [class.active]="activeRightTab() === 'video'" [attr.aria-selected]="activeRightTab() === 'video'" (click)="openVideoTab()">
3388
4019
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>{{ labels.t('common.video') }}</button>
3389
4020
  }
3390
4021
  </div>
3391
4022
 
3392
4023
  @if (activeRightTab() === 'blocks') {
3393
- <div class="right-panel-body">
4024
+ <div class="right-panel-body" data-testid="blocks-panel">
3394
4025
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.contentBlocks') }}</h4>
3395
4026
  <p class="right-section-desc">{{ labels.t('emailTemplateEditor.clickToInsertOrDrag') }}</p>
3396
4027
  <ui-search-input [placeholder]="labels.t('emailTemplateEditor.searchBlocks')" [ariaLabel]="labels.t('emailTemplateEditor.searchBlocks2')" [(value)]="blockSearch" />
@@ -3400,7 +4031,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3400
4031
  }
3401
4032
  @for (group of filteredBlockGroups(); track group.name) {
3402
4033
  <div class="block-group">
3403
- <button type="button" class="block-group-header" [attr.aria-expanded]="isOpen('b:' + group.name)" (click)="toggleGroup('b:' + group.name)">
4034
+ <button type="button" class="block-group-header" data-testid="block-group" [attr.aria-expanded]="isOpen('b:' + group.name)" (click)="toggleGroup('b:' + group.name)">
3404
4035
  <svg class="chevron" [class.expanded]="isOpen('b:' + group.name)" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg>
3405
4036
  <span>{{ group.name }}</span>
3406
4037
  <span class="block-count">{{ group.blocks.length }}</span>
@@ -3409,7 +4040,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3409
4040
  <div class="block-list">
3410
4041
  @for (block of group.blocks; track block.key) {
3411
4042
  <!-- A div, not a button: Firefox does not start a drag from a <button>. Role, tabindex and Enter / Space keep it a keyboard control; a click inserts the block. -->
3412
- <div role="button" tabindex="0" class="block-item" draggable="true" [attr.aria-label]="labels.t('emailTemplateEditor.insertNamed', { name: block.label })"
4043
+ <div role="button" tabindex="0" class="block-item" data-testid="block-item" [attr.data-block-key]="block.key" draggable="true" [attr.aria-label]="labels.t('emailTemplateEditor.insertNamed', { name: block.label })"
3413
4044
  (dragstart)="onPaletteDragStart($event, block)" (dragend)="onBlockDragEnd()" (click)="insertBlock(block)"
3414
4045
  (keydown.enter)="insertBlock(block); $event.preventDefault()" (keydown.space)="insertBlock(block); $event.preventDefault()">
3415
4046
  <svg class="block-item-drag" width="10" height="10" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="9" cy="6" r="1.5"/><circle cx="15" cy="6" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="9" cy="18" r="1.5"/><circle cx="15" cy="18" r="1.5"/></svg>
@@ -3424,13 +4055,16 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3424
4055
  }
3425
4056
 
3426
4057
  @if (activeRightTab() === 'variables') {
3427
- <div class="right-panel-body">
4058
+ <div class="right-panel-body" data-testid="variables-panel">
3428
4059
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.templateVariables') }}</h4>
3429
- <p class="right-section-desc">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>
3430
-
3431
- @for (group of variableGroups(); track group.name) {
4060
+ @if (variablesNeedAssignment()) {
4061
+ <p class="right-section-desc" role="status" data-testid="variables-need-assignment">{{ labels.t('emailTemplateEditor.assignToSeeVariables') }}</p>
4062
+ } @else {
4063
+ <p class="right-section-desc" data-testid="variables-click-hint">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>
4064
+ }
4065
+ @for (group of availableVariableGroups(); track group.name) {
3432
4066
  <div class="block-group">
3433
- <button type="button" class="block-group-header" [attr.aria-expanded]="isOpen('v:' + group.name)" (click)="toggleGroup('v:' + group.name)">
4067
+ <button type="button" class="block-group-header" data-testid="variable-group" [attr.aria-expanded]="isOpen('v:' + group.name)" (click)="toggleGroup('v:' + group.name)">
3434
4068
  <svg class="chevron" [class.expanded]="isOpen('v:' + group.name)" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg>
3435
4069
  <span>{{ group.name }}</span>
3436
4070
  <span class="block-count">{{ group.variables.length }}</span>
@@ -3438,8 +4072,8 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3438
4072
  @if (isOpen('v:' + group.name)) {
3439
4073
  <div class="variable-list">
3440
4074
  @for (v of group.variables; track v.key) {
3441
- <button type="button" class="variable-item" (mousedown)="saveSelection()" (click)="insertVariable(v)">
3442
- <span class="var-tag">{{ '{{' + v.key + '}}' }}</span>
4075
+ <button type="button" class="variable-item" data-testid="variable-item" [attr.data-variable]="v.key" (mousedown)="saveSelection()" (click)="insertVariable(v)">
4076
+ <span class="var-tag" data-testid="variable-tag">{{ '{{' + v.key + '}}' }}</span>
3443
4077
  <span class="var-example">{{ labels.t('emailTemplateEditor.example', { example: v.example }) }}</span>
3444
4078
  <!-- A very short explanation of what the variable is: the host's description, else its label. -->
3445
4079
  <span class="var-description">{{ v.description || v.label }}</span>
@@ -3453,7 +4087,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3453
4087
  }
3454
4088
 
3455
4089
  @if (activeRightTab() === 'video' && videosEnabled()) {
3456
- <div class="right-panel-body video-library-panel">
4090
+ <div class="right-panel-body video-library-panel" data-testid="video-panel">
3457
4091
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.videoLibrary') }}</h4>
3458
4092
  <p class="right-section-hint">{{ labels.t('emailTemplateEditor.clickAVideoToAdd') }}</p>
3459
4093
 
@@ -3532,7 +4166,7 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3532
4166
 
3533
4167
  `,
3534
4168
  isInline: true,
3535
- styles: [":host{display:flex;flex-direction:column;flex:1;min-height:0}.required{color:#ef4444;font-weight:400}.editor-page{display:flex;flex-direction:column;flex:1;min-height:0;background:#f8fafc;overflow:hidden}.editor-actions{display:flex;justify-content:space-between;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:0 0 12px;flex-shrink:0}.editor-heading{margin:0;font-size:1.25rem;font-weight:700;color:#1e293b;line-height:1.3;min-width:0}.save-wrap{display:inline-flex}.save-hint{margin:0;font-size:12px;color:#475569;flex-basis:100%;text-align:right}.editor-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-left:auto}.readonly-note{margin:0;padding:8px 16px;font-size:.8125rem;color:#92400e;background:#fffbeb;border-bottom:1px solid #fde68a}.readonly-note.system-note{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.editor-body{display:grid;grid-template-columns:340px minmax(0,1fr) 300px;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden}.panel-left{background:#fff;border-right:1px solid #e2e8f0;padding:24px;overflow-y:auto}.panel-title{font-size:1.0625rem;font-weight:700;color:#1e293b;margin:0 0 20px}.form-field{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}.form-row-dates{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:16px}.email-checks{margin:8px 12px 0}.email-checks-list{margin:0;padding-left:18px}.hidden-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.assignments-section{border-top:1px solid #e2e8f0;padding-top:20px;margin-top:16px}.section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 6px}.section-desc{font-size:.8125rem;color:#64748b;line-height:1.5;margin:0 0 12px}.assignment-list{max-height:340px;overflow-y:auto;margin-top:12px;border:1px solid #e2e8f0;border-radius:8px}.assignment-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;cursor:pointer;border-bottom:1px solid #f1f5f9;transition:background .1s}.assignment-item:last-child{border-bottom:none}.assignment-item:hover{background:#f8fafc}.assignment-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.assignment-item.assignment-readonly{cursor:default}.assignment-item.assignment-readonly:hover{background:transparent}.assignment-text{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.assignment-text strong{font-size:.8125rem;color:#1e293b}.assignment-text span{font-size:.75rem;color:#64748b}.assignment-channels{display:flex;gap:4px;flex-shrink:0}.channel-badge{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;background:#f1f5f9;color:#64748b;transition:all .15s}.channel-badge.active{background:#3b82f6;color:#fff}.channel-badge.disabled{opacity:.4;cursor:not-allowed}.config-desc{font-size:.875rem;color:#64748b;line-height:1.5;margin:0}.config-divider{border:none;border-top:1px solid #e2e8f0;margin:20px 0}.config-section{display:flex;flex-direction:column;gap:12px}.config-section-label{font-size:.6875rem;font-weight:700;color:#3b82f6;text-transform:uppercase;letter-spacing:.04em}.config-field{display:flex;flex-direction:column;gap:6px}.config-field-mt{margin-top:16px}.config-label{font-size:.8125rem;font-weight:600;color:#1e293b}.config-readonly{padding:9px 12px;border:1px solid #e2e8f0;border-radius:8px;background:#f8fafc;font-size:.875rem;color:#1e293b}.config-hint{font-size:.75rem;color:#64748b}.test-save-note{display:flex;align-items:center;gap:8px;padding:10px 14px;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;font-size:.8125rem;color:#92400e;margin-top:12px}.test-save-note svg{flex-shrink:0}.panel-center{display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden}.editor-tabs{display:flex;gap:2px;padding:12px 20px 0;background:#fff;border-bottom:1px solid #e2e8f0;overflow-x:auto;-webkit-overflow-scrolling:touch}.editor-tab{display:flex;align-items:center;gap:6px;padding:10px 16px;border:1px solid #e2e8f0;border-bottom:none;border-radius:8px 8px 0 0;background:#f8fafc;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;white-space:nowrap}.editor-tab:hover{background:#fff;color:#1e293b}.editor-tab.active{background:#eff6ff;color:#1d4ed8;border-color:#93c5fd}.editor-tab:focus-visible,.right-tab:focus-visible,.block-group-header:focus-visible,.variable-item:focus-visible,.add-block-btn:focus-visible,.block-item:focus-visible,.video-lib-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.editor-toolbar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:#fff;border-bottom:1px solid #e2e8f0;flex-wrap:wrap}.toolbar-row-2{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 20px;background:#fff;border-bottom:1px solid #e2e8f0}.toolbar-group{display:flex;align-items:center;gap:2px;padding-right:8px;border-right:1px solid #e2e8f0}.toolbar-group:last-child{border-right:none;padding-right:0}.toolbar-select{display:block;min-width:96px}.toolbar-label{font-size:.75rem;font-weight:600;color:#64748b;white-space:nowrap;margin-right:6px}.hidden-color-input{position:absolute;width:0;height:0;opacity:0;pointer-events:none;border:none;padding:0}.color-indicator{display:flex;flex-direction:column;align-items:center;gap:2px;color:#475569}.color-bar{display:block;width:16px;height:3px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.link-dialog{background:#fff;border-bottom:1px solid #e2e8f0;padding:12px 20px}.link-dialog-inner{display:flex;align-items:flex-start;gap:8px;flex-wrap:wrap}.link-dialog-title{font-size:.8125rem;font-weight:700;color:#1e293b;white-space:nowrap;padding-top:10px}.link-dialog-input{display:block;width:240px;max-width:100%}.link-dialog-actions{display:flex;gap:6px}.preview-frame{flex:1;display:flex;justify-content:center;align-items:stretch;padding:24px;overflow-y:auto;background:#f1f5f9}.preview-frame.mobile{align-items:flex-start}.preview-content{display:block;flex:1 1 auto;max-width:600px;width:100%;box-sizing:border-box;min-height:400px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.mobile-shell{width:375px;max-width:100%;box-sizing:border-box;min-height:600px;border:2px solid #1e293b;border-radius:24px;padding:40px 12px 24px;background:#fff;box-shadow:0 8px 32px #0000001f}.mobile-shell .preview-content{border:none;border-radius:0;max-width:100%;height:520px;min-height:0}.blocks-canvas{flex:1 1 0;min-height:0;padding:16px 20px 24px 56px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;background:#f1f5f9;display:flex;flex-direction:column}.block-wrapper{flex-shrink:0;position:relative;display:flex;align-items:flex-start;background:#fff;border:2px solid transparent;border-radius:8px;transition:border-color .15s,box-shadow .15s}.block-wrapper:hover,.block-wrapper.selected,.block-wrapper:focus-within{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.block-wrapper:hover .block-drag-handle,.block-wrapper.selected .block-drag-handle,.block-wrapper:focus-within .block-drag-handle{opacity:1}.block-wrapper:hover .block-controls,.block-wrapper.selected .block-controls,.block-wrapper:focus-within .block-controls{opacity:1;pointer-events:all}.block-wrapper.dragging{opacity:.4}.block-drag-handle{flex-shrink:0;width:28px;display:flex;align-items:flex-start;justify-content:center;padding-top:14px;opacity:0;transition:opacity .15s;cursor:grab;color:#94a3b8}.block-drag-handle:active{cursor:grabbing}.block-content{flex:1;min-width:0;padding:12px 16px;outline:none;font-size:.9375rem;color:#1e293b;line-height:1.6;min-height:48px;overflow-wrap:anywhere}.block-content:empty:before{content:attr(data-placeholder);color:#64748b;font-style:italic;pointer-events:none}.block-content p{margin:0 0 8px}.block-content p:last-child{margin:0}.block-content h1,.block-content h2,.block-content h3{margin:8px 0 6px;color:#1e293b}.block-content a{color:#3b82f6}.block-content img{max-width:100%;border-radius:6px}.block-content ul,.block-content ol{padding-left:20px;margin:0 0 8px}.block-controls{position:absolute;top:0;left:-48px;flex-direction:column;display:flex;gap:2px;opacity:0;pointer-events:none;transition:opacity .15s;background:#fff;border:1px solid #e2e8f0;border-radius:6px;padding:3px;box-shadow:0 2px 6px #00000014}@media(pointer:coarse){.editor-tab,.right-tab,.block-group-header{min-height:44px}}@media(hover:none){.block-wrapper.selected .block-controls{opacity:1;pointer-events:all}}.drop-zone{flex-shrink:0;height:8px;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:height .15s,background .15s;position:relative}.drop-zone-label{font-size:.75rem;font-weight:600;color:#1d4ed8;opacity:0;transition:opacity .1s}.drop-zone.active{height:40px;background:#3b82f614;border:2px dashed #3b82f6}.drop-zone.active .drop-zone-label{opacity:1}.add-block-btn{flex-shrink:0;display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:44px;padding:12px;margin-top:8px;border:2px dashed #e2e8f0;border-radius:8px;background:none;font-size:.875rem;font-weight:600;color:#475569;cursor:pointer;font-family:inherit;transition:border-color .15s,color .15s,background .15s}.add-block-btn:hover{border-color:#3b82f6;color:#3b82f6;background:#3b82f60a}.panel-right{background:#fff;border-left:1px solid #e2e8f0;display:flex;flex-direction:column;min-height:0;min-width:0}.right-tabs{display:flex;border-bottom:1px solid #e2e8f0}.right-tab{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:12px;min-height:44px;border:none;background:none;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;border-bottom:2px solid transparent}.right-tab:hover{color:#1e293b}.right-tab.active{color:#1d4ed8;background:#eff6ff;border-bottom-color:#3b82f6}.right-panel-body{flex:1;padding:20px;overflow-y:auto}.right-section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 12px}.right-section-desc{font-size:.8125rem;color:#64748b;margin:0 0 16px;line-height:1.5}.right-section-hint{font-size:.8125rem;color:#64748b;margin:0 0 12px;line-height:1.5}.block-group{border-bottom:1px solid #f1f5f9}.block-group-header{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:12px 0;border:none;background:none;font-size:.875rem;font-weight:600;color:#1e293b;cursor:pointer;font-family:inherit;text-align:left}.block-group-header .chevron{transition:transform .2s;color:#94a3b8}.block-group-header .chevron.expanded{transform:rotate(90deg)}.block-group-header span:nth-of-type(1){flex:1}.block-count{font-size:.75rem;font-weight:600;color:#475569;background:#f1f5f9;padding:2px 8px;border-radius:10px;margin-left:auto}.block-list{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.variable-list{display:flex;flex-direction:column;padding-bottom:8px}.variable-item+.variable-item{border-top:1px solid #f1f5f9;border-radius:0}.block-item{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-height:44px;padding:8px 0;font-size:.8125rem;color:#64748b;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit;-webkit-user-select:none;user-select:none}.block-item:hover{background:#f8fafc;color:#1e293b}.block-item-drag{color:#cbd5e1;flex-shrink:0;cursor:grab}.variable-item{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-height:44px;padding:8px 0;min-width:0;width:100%;box-sizing:border-box;border:none;background:none;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit}.variable-item:hover{background:#f8fafc}.var-tag{max-width:100%;overflow-wrap:anywhere;font-size:.75rem;font-weight:600;color:#1d4ed8;background:#3b82f614;padding:2px 6px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.var-example{font-size:.75rem;color:#64748b;overflow-wrap:anywhere}.var-description{font-size:.75rem;color:#64748b;line-height:1.4;overflow-wrap:anywhere}.video-library-panel{padding:0}.video-library-panel .right-section-title,.video-library-panel .right-section-hint{padding:0 16px}.video-library-panel .right-section-title{padding-top:16px}.video-config-section{display:flex;flex-direction:column;gap:8px;padding:12px 16px;border-bottom:1px solid #f1f5f9}.video-config-section:last-of-type{border-bottom:none}.video-lib-list{display:flex;flex-direction:column;gap:2px;padding:8px 8px 16px}.video-lib-item{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:8px;border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;text-align:left;font-family:inherit;transition:background .15s,border-color .15s}.video-lib-item:hover{background:#f8fafc;border-color:#e2e8f0}.video-lib-item.selected{background:#eff6ff;border-color:#93c5fd}.vli-thumb{position:relative;flex-shrink:0;width:56px;height:40px;border-radius:6px;background:linear-gradient(135deg,#f1f5f9,#e2e8f0);display:flex;align-items:center;justify-content:center}.vli-dur{position:absolute;bottom:2px;right:3px;font-size:.625rem;font-weight:600;color:#fff;background:#000000a6;padding:1px 4px;border-radius:3px}.vli-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.vli-title{font-size:.8125rem;font-weight:600;color:#1e293b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vli-cat{font-size:.75rem;color:#475569}.vli-check{flex-shrink:0}.video-lib-loading{padding:8px}.video-lib-skeleton{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:4px}.vls-info{flex:1;display:flex;flex-direction:column;gap:6px}@media(max-width:1200px){.editor-body{grid-template-columns:280px minmax(0,1fr) 260px}}@media(max-width:900px){:host{flex:none}.editor-page{flex:none;min-height:100vh;min-height:100dvh;overflow:visible}.editor-body{display:flex;flex-direction:column;flex:none;overflow:visible}.panel-left{border-right:none;border-bottom:1px solid #e2e8f0;overflow:visible;padding:16px}.panel-center{overflow:visible;min-height:480px}.blocks-canvas{overflow:visible;min-height:320px}.panel-right{border-left:none;border-top:1px solid #e2e8f0}.right-panel-body{overflow:visible}.editor-toolbar,.toolbar-row-2,.link-dialog,.editor-tabs{padding-left:12px;padding-right:12px}.preview-frame{padding:12px}.form-row-dates{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}\n"],
4169
+ styles: [":host{display:flex;flex-direction:column;flex:1;min-height:0}.required{color:#ef4444;font-weight:400}.editor-page{display:flex;flex-direction:column;flex:1;min-height:0;background:#f8fafc;overflow:hidden}.editor-actions{display:flex;justify-content:space-between;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:0 0 12px;flex-shrink:0}.editor-heading-group{display:flex;align-items:center;gap:4px;min-width:0}.editor-heading{margin:0;font-size:1.25rem;font-weight:700;color:#1e293b;line-height:1.3;min-width:0}.save-wrap{display:inline-flex}.save-hint{margin:0;font-size:12px;color:#475569;flex-basis:100%;text-align:right}.editor-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-left:auto}.readonly-note{margin:0;padding:8px 16px;font-size:.8125rem;color:#92400e;background:#fffbeb;border-bottom:1px solid #fde68a}.readonly-note.system-note{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.editor-body{display:grid;grid-template-columns:340px minmax(0,1fr) 300px;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden}.panel-left{background:#fff;border-right:1px solid #e2e8f0;padding:24px;overflow-y:auto;overflow-x:hidden}.panel-title{font-size:1.0625rem;font-weight:700;color:#1e293b;margin:0 0 20px}.form-field{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}.form-row-dates{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:16px}.form-row-dates>*{min-width:0}.email-checks{margin:8px 12px 0}.email-checks-list{margin:0;padding-left:18px}.hidden-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.assignments-section{border-top:1px solid #e2e8f0;padding-top:20px;margin-top:16px}.section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 6px}.section-desc{font-size:.8125rem;color:#64748b;line-height:1.5;margin:0 0 12px}.assignment-list{max-height:340px;overflow-y:auto;margin-top:12px;border:1px solid #e2e8f0;border-radius:8px}.assignment-group{position:sticky;top:0;z-index:1;padding:8px 14px;background:#f8fafc;border-bottom:1px solid #e2e8f0;font-size:.6875rem;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:.04em}.assignment-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;cursor:pointer;border-bottom:1px solid #f1f5f9;transition:background .1s}.assignment-item:last-child{border-bottom:none}.assignment-item:hover{background:#f8fafc}.assignment-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.assignment-item.assignment-readonly{cursor:default}.assignment-item.assignment-readonly:hover{background:transparent}.assignment-text{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.assignment-text strong{font-size:.8125rem;color:#1e293b}.assignment-text span{font-size:.75rem;color:#64748b}.assignment-channels{display:flex;gap:4px;flex-shrink:0}.channel-badge{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;background:#f1f5f9;color:#64748b;transition:all .15s}.channel-badge.active{background:#3b82f6;color:#fff}.channel-badge.disabled{opacity:.4;cursor:not-allowed}.config-desc{font-size:.875rem;color:#64748b;line-height:1.5;margin:0}.config-section{display:flex;flex-direction:column;gap:12px}.config-field{display:flex;flex-direction:column;gap:6px}.config-field-mt{margin-top:16px}.test-save-note{display:flex;align-items:center;gap:8px;padding:10px 14px;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;font-size:.8125rem;color:#92400e;margin-top:12px}.test-save-note svg{flex-shrink:0}.panel-center{display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden}.editor-tabs{display:flex;gap:2px;padding:12px 20px 0;background:#fff;border-bottom:1px solid #e2e8f0;overflow-x:auto;-webkit-overflow-scrolling:touch}.editor-tab{display:flex;align-items:center;gap:6px;padding:10px 16px;border:1px solid #e2e8f0;border-bottom:none;border-radius:8px 8px 0 0;background:#f8fafc;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;white-space:nowrap}.editor-tab:hover{background:#fff;color:#1e293b}.editor-tab.active{background:#eff6ff;color:#1d4ed8;border-color:#93c5fd}.editor-tab:focus-visible,.right-tab:focus-visible,.block-group-header:focus-visible,.variable-item:focus-visible,.block-item:focus-visible,.video-lib-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.editor-toolbar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:#fff;border-bottom:1px solid #e2e8f0;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:2px;padding-right:8px;border-right:1px solid #e2e8f0}.toolbar-group:last-child{border-right:none;padding-right:0}.toolbar-select{display:block;min-width:96px}.hidden-color-input{position:absolute;width:0;height:0;opacity:0;pointer-events:none;border:none;padding:0}.color-indicator{display:flex;flex-direction:column;align-items:center;gap:2px;color:#475569}.color-bar{display:block;width:16px;height:3px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.link-dialog{background:#fff;border-bottom:1px solid #e2e8f0;padding:12px 20px}.link-dialog-inner{display:flex;align-items:flex-start;gap:8px;flex-wrap:wrap}.link-dialog-title{font-size:.8125rem;font-weight:700;color:#1e293b;white-space:nowrap;padding-top:10px}.link-dialog-input{display:block;width:240px;max-width:100%}.link-dialog-actions{display:flex;gap:6px}.emoji-panel-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap}.emoji-search{display:block;flex:1 1 200px;min-width:160px}.emoji-tone{display:block;min-width:120px}.emoji-tabs{display:flex;gap:2px;border-bottom:1px solid #e2e8f0;margin-bottom:8px;overflow-x:auto}.emoji-tab{flex:0 0 auto;width:40px;height:36px;border:0;border-bottom:2px solid transparent;background:transparent;font-size:18px;cursor:pointer;font-family:\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Noto Color Emoji\",sans-serif}.emoji-tab.active{border-bottom-color:#3b82f6;background:#eff6ff}.color-grid{display:grid;grid-template-columns:repeat(10,28px);gap:4px}.color-swatch{width:28px;height:28px;border-radius:6px;border:1px solid rgba(0,0,0,.15);cursor:pointer;padding:0}.color-swatch:hover{transform:scale(1.1)}.color-swatch:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.color-swatch.selected{outline:2px solid #1e293b;outline-offset:1px}@media(pointer:coarse){.color-grid{grid-template-columns:repeat(auto-fill,44px);max-height:240px;overflow-y:auto}.color-swatch{width:44px;height:44px}}.emoji-grid{display:flex;flex-wrap:wrap;gap:2px;max-height:220px;overflow-y:auto}.emoji-empty{font-size:.8125rem;color:#64748b;padding:8px 4px}.emoji-btn{width:36px;height:36px;padding:0;border:0;border-radius:6px;background:transparent;font-size:20px;line-height:1;cursor:pointer;font-family:\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Noto Color Emoji\",sans-serif}.emoji-btn.special-btn{font-family:inherit;font-size:16px}.emoji-btn:hover,.emoji-btn:focus-visible{background:#f1f5f9}.tb-sub{font-size:12px;font-weight:700;line-height:1}@media(pointer:coarse){.emoji-btn{width:44px;height:44px}}.preview-frame{flex:1;display:flex;justify-content:center;align-items:stretch;padding:24px;overflow-y:auto;background:#f1f5f9}.preview-frame.mobile{align-items:flex-start}.preview-content{display:block;flex:1 1 auto;max-width:602px;width:100%;box-sizing:border-box;min-height:400px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.mobile-shell{width:375px;max-width:100%;box-sizing:border-box;min-height:600px;border:2px solid #1e293b;border-radius:24px;padding:40px 12px 24px;background:#fff;box-shadow:0 8px 32px #0000001f}.mobile-shell .preview-content{border:none;border-radius:0;max-width:100%;height:520px;min-height:0}.block-wrapper{flex-shrink:0;width:100%;max-width:602px;margin:0 auto;box-sizing:border-box;padding:24px 28px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.blocks-canvas{flex:1 1 0;min-height:0;padding:16px 20px 24px 56px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;background:#f1f5f9;display:flex;flex-direction:column}.block-content{min-width:0;padding:0;outline:none;font-size:15px;color:#1e293b;line-height:1.6;min-height:320px;overflow-wrap:anywhere}.block-content:empty:before{content:attr(data-placeholder);color:#64748b;font-style:italic;pointer-events:none}@media(pointer:coarse){.editor-tab,.right-tab,.block-group-header{min-height:44px}}.panel-right{background:#fff;border-left:1px solid #e2e8f0;display:flex;flex-direction:column;min-height:0;min-width:0}.right-tabs{display:flex;border-bottom:1px solid #e2e8f0}.right-tab{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:12px;min-height:44px;border:none;background:none;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;border-bottom:2px solid transparent}.right-tab:hover{color:#1e293b}.right-tab.active{color:#1d4ed8;background:#eff6ff;border-bottom-color:#3b82f6}.right-panel-body{flex:1;padding:20px;overflow-y:auto}.right-section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 12px}.right-section-desc{font-size:.8125rem;color:#64748b;margin:0 0 16px;line-height:1.5}.right-section-hint{font-size:.8125rem;color:#64748b;margin:0 0 12px;line-height:1.5}.block-group{border-bottom:1px solid #f1f5f9}.block-group-header{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:12px 0;border:none;background:none;font-size:.875rem;font-weight:600;color:#1e293b;cursor:pointer;font-family:inherit;text-align:left}.block-group-header .chevron{transition:transform .2s;color:#94a3b8}.block-group-header .chevron.expanded{transform:rotate(90deg)}.block-group-header span:nth-of-type(1){flex:1}.block-count{font-size:.75rem;font-weight:600;color:#475569;background:#f1f5f9;padding:2px 8px;border-radius:10px;margin-left:auto}.block-list{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.variable-list{display:flex;flex-direction:column;padding-bottom:8px}.variable-item+.variable-item{border-top:1px solid #f1f5f9;border-radius:0}.block-item{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-height:44px;padding:8px 0;font-size:.8125rem;color:#64748b;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit;-webkit-user-select:none;user-select:none}.block-item:hover{background:#f8fafc;color:#1e293b}.block-item-drag{color:#cbd5e1;flex-shrink:0;cursor:grab}.variable-item{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-height:44px;padding:8px 0;min-width:0;width:100%;box-sizing:border-box;border:none;background:none;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit}.variable-item:hover{background:#f8fafc}.var-tag{max-width:100%;overflow-wrap:anywhere;font-size:.75rem;font-weight:600;color:#1d4ed8;background:#3b82f614;padding:2px 6px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.var-example{font-size:.75rem;color:#64748b;overflow-wrap:anywhere}.var-description{font-size:.75rem;color:#64748b;line-height:1.4;overflow-wrap:anywhere}.video-library-panel{padding:0}.video-library-panel .right-section-title,.video-library-panel .right-section-hint{padding:0 16px}.video-library-panel .right-section-title{padding-top:16px}.video-config-section{display:flex;flex-direction:column;gap:8px;padding:12px 16px;border-bottom:1px solid #f1f5f9}.video-config-section:last-of-type{border-bottom:none}.video-lib-list{display:flex;flex-direction:column;gap:2px;padding:8px 8px 16px}.video-lib-item{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:8px;border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;text-align:left;font-family:inherit;transition:background .15s,border-color .15s}.video-lib-item:hover{background:#f8fafc;border-color:#e2e8f0}.video-lib-item.selected{background:#eff6ff;border-color:#93c5fd}.vli-thumb{position:relative;flex-shrink:0;width:56px;height:40px;border-radius:6px;background:linear-gradient(135deg,#f1f5f9,#e2e8f0);display:flex;align-items:center;justify-content:center}.vli-dur{position:absolute;bottom:2px;right:3px;font-size:.625rem;font-weight:600;color:#fff;background:#000000a6;padding:1px 4px;border-radius:3px}.vli-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.vli-title{font-size:.8125rem;font-weight:600;color:#1e293b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vli-cat{font-size:.75rem;color:#475569}.vli-check{flex-shrink:0}.video-lib-loading{padding:8px}.video-lib-skeleton{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:4px}.vls-info{flex:1;display:flex;flex-direction:column;gap:6px}@media(max-width:1200px){.editor-body{grid-template-columns:280px minmax(0,1fr) 260px}}@media(max-width:900px){:host{flex:none}.editor-page{flex:none;min-height:100vh;min-height:100dvh;overflow:visible}.editor-body{display:flex;flex-direction:column;flex:none;overflow:visible}.panel-left{border-right:none;border-bottom:1px solid #e2e8f0;overflow:visible;padding:16px}.panel-center{overflow:visible;min-height:480px}.blocks-canvas{overflow:visible;min-height:320px}.panel-right{border-left:none;border-top:1px solid #e2e8f0}.right-panel-body{overflow:visible}.editor-toolbar,.link-dialog,.editor-tabs{padding-left:12px;padding-right:12px}.preview-frame{padding:12px}.form-row-dates{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}\n"],
3536
4170
  dependencies: [
3537
4171
  {
3538
4172
  kind: "ngmodule",
@@ -3689,23 +4323,6 @@ var EmailTemplateEditorComponent = class EmailTemplateEditorComponent {
3689
4323
  selector: "ui-error",
3690
4324
  inputs: ["message", "errorId"]
3691
4325
  },
3692
- {
3693
- kind: "component",
3694
- type: PillTabsComponent,
3695
- selector: "ui-pill-tabs",
3696
- inputs: [
3697
- "tabs",
3698
- "activeKey",
3699
- "ariaLabel",
3700
- "name",
3701
- "noWrap",
3702
- "orientation",
3703
- "controlsPanels",
3704
- "showDescription",
3705
- "headingLevel"
3706
- ],
3707
- outputs: ["tabChange"]
3708
- },
3709
4326
  {
3710
4327
  kind: "component",
3711
4328
  type: RadioGroupComponent,
@@ -3875,7 +4492,6 @@ i0.ษตษตngDeclareClassMetadata({
3875
4492
  DividerComponent,
3876
4493
  EmptyStateComponent,
3877
4494
  ErrorComponent,
3878
- PillTabsComponent,
3879
4495
  RadioGroupComponent,
3880
4496
  SearchInputComponent,
3881
4497
  SelectComponent,
@@ -3888,9 +4504,13 @@ i0.ษตษตngDeclareClassMetadata({
3888
4504
  <div class="editor-page">
3889
4505
  <!-- Actions (outside the white panels) -->
3890
4506
  <div class="editor-actions">
3891
- @if (heading()) {
3892
- <h2 class="editor-heading" data-testid="editor-heading">{{ heading() }}</h2>
3893
- }
4507
+ <div class="editor-heading-group">
4508
+ <!-- e.g. a back arrow button: content with the editor-heading-start attribute is shown before the heading, on the same row as Save -->
4509
+ <ng-content select="[editor-heading-start]" />
4510
+ @if (heading()) {
4511
+ <h2 class="editor-heading" data-testid="editor-heading">{{ heading() }}</h2>
4512
+ }
4513
+ </div>
3894
4514
  <div class="editor-actions-buttons">
3895
4515
  @if (canWrite() && testSendEnabled()) {
3896
4516
  <ui-button variant="secondary" size="sm" (click)="openTestSendDialog()">
@@ -3901,7 +4521,7 @@ i0.ษตษตngDeclareClassMetadata({
3901
4521
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>{{ labels.t('emailTemplateEditor.saveTemplate') }}</ui-button>
3902
4522
  </span>
3903
4523
  </div>
3904
- @if (saveHintVisible(); as hint) {
4524
+ @if (showSaveHint() && saveHintVisible(); as hint) {
3905
4525
  <!-- A blocked Save explains itself in visible text, not only in the tooltip. -->
3906
4526
  <p class="save-hint" role="status" data-testid="save-hint">{{ hint }}</p>
3907
4527
  }
@@ -3922,34 +4542,34 @@ i0.ษตษตngDeclareClassMetadata({
3922
4542
  <!-- 3-Column Layout -->
3923
4543
  <div class="editor-body">
3924
4544
  <!-- LEFT PANEL: Details -->
3925
- <aside class="panel-left" [attr.aria-label]="labels.t('emailTemplateEditor.templateDetails')">
4545
+ <aside class="panel-left" data-testid="editor-details" [attr.aria-label]="labels.t('emailTemplateEditor.templateDetails')">
3926
4546
  <h3 class="panel-title">{{ labels.t('common.details') }}</h3>
3927
4547
 
3928
4548
  <div class="form-field">
3929
- <ui-text-input [label]="labels.t('common.name')" [required]="true" [(ngModel)]="name" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
4549
+ <ui-text-input data-testid="template-name" [label]="labels.t('common.name')" [required]="true" [(ngModel)]="name" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3930
4550
  [placeholder]="namePlaceholder()" [error]="nameErrorShown()" [showErrors]="nameTouched()" (blurred)="nameTouched.set(true)" />
3931
4551
  </div>
3932
4552
 
3933
4553
  <div class="form-field">
3934
- <ui-text-input [label]="labels.t('common.subject')" [required]="true" [(ngModel)]="subject" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
4554
+ <ui-text-input data-testid="template-subject" [label]="labels.t('common.subject')" [required]="true" [(ngModel)]="subject" [readonly]="!canWrite()" [maxlength]="maxTextLength()"
3935
4555
  [placeholder]="subjectPlaceholder()" [error]="subjectErrorShown()" [showErrors]="subjectTouched()" (blurred)="subjectTouched.set(true)">
3936
4556
  </ui-text-input>
3937
4557
  </div>
3938
4558
 
3939
4559
  @if (showCategory()) {
3940
4560
  <div class="form-field">
3941
- <ui-select [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
4561
+ <ui-select data-testid="template-category" [label]="labels.t('emailTemplateEditor.category')" [options]="categories()" [placeholder]="categoryPlaceholder()" [(ngModel)]="category" [disabled]="!canWrite()" />
3942
4562
  </div>
3943
4563
  }
3944
4564
 
3945
4565
  @if (showActiveRange()) {
3946
- <ui-checkbox [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
4566
+ <ui-checkbox data-testid="template-all-year" [label]="labels.t('emailTemplateEditor.useThisTemplateAllYear')" [(checked)]="useAllYear" [disabled]="!canWrite()" />
3947
4567
  }
3948
4568
 
3949
4569
  @if (showActiveRange() && !useAllYear()) {
3950
4570
  <div class="form-row-dates" (focusout)="datesTouched.set(true)">
3951
- <ui-date-input [label]="labels.t('emailTemplateEditor.activeFrom')" [(ngModel)]="activeFrom" [disabled]="!canWrite()" />
3952
- <ui-date-input [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeFrom()" [error]="datesError()" />
4571
+ <ui-date-input data-testid="template-active-from" [label]="labels.t('emailTemplateEditor.activeFrom')" [ngModel]="activeFrom()" (ngModelChange)="onActiveFromChange($event)" [disabled]="!canWrite()" [min]="today" />
4572
+ <ui-date-input data-testid="template-active-to" [label]="labels.t('emailTemplateEditor.activeTo')" [(ngModel)]="activeTo" [disabled]="!canWrite()" [min]="activeToMin()" [error]="datesError()" />
3953
4573
  </div>
3954
4574
  }
3955
4575
 
@@ -3959,17 +4579,20 @@ i0.ษตษตngDeclareClassMetadata({
3959
4579
  <h4 class="section-title">{{ labels.t('emailTemplateEditor.assignments') }}<span class="required" aria-hidden="true">*</span></h4>
3960
4580
  <p class="section-desc">{{ assignmentsDescription() }}</p>
3961
4581
  <ui-error [errorId]="idPrefix() + '-assignments-error'" [message]="assignmentErrorShown()" />
3962
- <ui-search-input [placeholder]="labels.t('common.searchellipsis')" [ariaLabel]="labels.t('emailTemplateEditor.searchAssignments')" [(value)]="assignmentSearch" />
4582
+ <ui-search-input data-testid="assignment-search" [placeholder]="labels.t('common.searchellipsis')" [ariaLabel]="labels.t('emailTemplateEditor.searchAssignments')" [(value)]="assignmentSearch" />
3963
4583
  @if (filteredAssignments().length === 0) {
3964
4584
  <ui-empty-state iconType="search" [title]="labels.t('emailTemplateEditor.noAssignmentsFound')" [message]="labels.t('emailTemplateEditor.noAssignmentsMatchYourSearch')" />
3965
4585
  }
3966
- <div class="assignment-list" [hidden]="filteredAssignments().length === 0" (focusout)="onAssignmentsFocusOut($event)">
4586
+ <div class="assignment-list" data-testid="assignment-list" [hidden]="filteredAssignments().length === 0" (focusout)="onAssignmentsFocusOut($event)">
3967
4587
  @for (item of filteredAssignments(); track item.key) {
3968
- <div class="assignment-item" [class.assignment-readonly]="!canWrite()" [attr.role]="canWrite() ? 'switch' : null" [attr.tabindex]="canWrite() ? 0 : null"
4588
+ @if (item.groupStart) {
4589
+ <div class="assignment-group" role="heading" aria-level="5" data-testid="assignment-group">{{ item.group }}</div>
4590
+ }
4591
+ <div class="assignment-item" data-testid="assignment-item" [attr.data-assignment]="item.key" [class.assignment-readonly]="!canWrite()" [attr.role]="canWrite() ? 'switch' : null" [attr.tabindex]="canWrite() ? 0 : null"
3969
4592
  [attr.aria-checked]="canWrite() ? item.assigned : null" [attr.aria-label]="canWrite() ? item.name : null"
3970
4593
  (click)="toggleAssignment(item)" (keydown.enter)="toggleAssignment(item); $event.preventDefault()" (keydown.space)="toggleAssignment(item); $event.preventDefault()">
3971
4594
  <div class="assignment-text">
3972
- <strong>{{ item.name }}</strong>
4595
+ <strong data-testid="assignment-name">{{ item.name }}</strong>
3973
4596
  <span>{{ item.description }}</span>
3974
4597
  </div>
3975
4598
  <div class="assignment-channels">
@@ -3987,88 +4610,134 @@ i0.ษตษตngDeclareClassMetadata({
3987
4610
  <!-- CENTER: Editor -->
3988
4611
  <section class="panel-center" [attr.aria-label]="labels.t('emailTemplateEditor.emailDesign')">
3989
4612
  <div class="editor-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.editorView')">
3990
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'edit'" [attr.aria-selected]="activeEditorTab() === 'edit'" (click)="setEditorTab('edit')">
4613
+ <button type="button" class="editor-tab" data-testid="editor-tab-edit" role="tab" [class.active]="activeEditorTab() === 'edit'" [attr.aria-selected]="activeEditorTab() === 'edit'" (click)="setEditorTab('edit')">
3991
4614
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/></svg>{{ labels.t('common.edit') }}</button>
3992
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'preview'" [attr.aria-selected]="activeEditorTab() === 'preview'" (click)="setEditorTab('preview')">
4615
+ <button type="button" class="editor-tab" data-testid="editor-tab-preview" role="tab" [class.active]="activeEditorTab() === 'preview'" [attr.aria-selected]="activeEditorTab() === 'preview'" (click)="setEditorTab('preview')">
3993
4616
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>{{ labels.t('common.preview') }}</button>
3994
- <button type="button" class="editor-tab" role="tab" [class.active]="activeEditorTab() === 'mobile'" [attr.aria-selected]="activeEditorTab() === 'mobile'" (click)="setEditorTab('mobile')">
4617
+ <button type="button" class="editor-tab" data-testid="editor-tab-mobile" role="tab" [class.active]="activeEditorTab() === 'mobile'" [attr.aria-selected]="activeEditorTab() === 'mobile'" (click)="setEditorTab('mobile')">
3995
4618
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="5" y="2" width="14" height="20" rx="2" ry="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>{{ labels.t('common.mobile') }}</button>
3996
4619
  </div>
3997
4620
 
3998
4621
  @if (activeEditorTab() === 'edit') {
3999
4622
  @if (canWrite()) {
4000
- <!-- Toolbar row 1: mousedown preventDefault keeps focus (and the selection) in the editor -->
4001
- <div class="editor-toolbar" role="toolbar" [attr.aria-label]="labels.t('emailTemplateEditor.textFormatting')" (mousedown)="preventFocusLoss($event)">
4002
- <div class="toolbar-group">
4003
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bold')" [uiTooltip]="labels.t('emailTemplateEditor.tipBold')" (click)="execCommand('bold')"><strong>B</strong></ui-button>
4004
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.italic')" [uiTooltip]="labels.t('emailTemplateEditor.tipItalic')" (click)="execCommand('italic')"><em>I</em></ui-button>
4005
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.underline')" [uiTooltip]="labels.t('emailTemplateEditor.tipUnderline')" (click)="execCommand('underline')"><u>U</u></ui-button>
4006
- </div>
4623
+ <!-- Toolbar (the last group is the block spacing): mousedown preventDefault keeps focus (and the selection) in the editor -->
4624
+ <div class="editor-toolbar" data-testid="editor-toolbar" role="toolbar" [attr.aria-label]="labels.t('emailTemplateEditor.textFormatting')" (mousedown)="preventFocusLoss($event)">
4007
4625
  <div class="toolbar-group">
4008
- @for (k of [headingKey()]; track k) {
4009
- <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.headingLevel')" [options]="headingOptions" ngModel="p"
4010
- (mousedown)="saveSelection()" (ngModelChange)="onHeading($event)" />
4011
- }
4626
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.undo')" [uiTooltip]="labels.t('emailTemplateEditor.undo')" (click)="execCommand('undo')">
4627
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13"/></svg>
4628
+ </ui-button>
4629
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.redo')" [uiTooltip]="labels.t('emailTemplateEditor.redo')" (click)="execCommand('redo')">
4630
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13"/></svg>
4631
+ </ui-button>
4012
4632
  </div>
4013
4633
  <div class="toolbar-group">
4634
+ <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.headingLevel')" [options]="headingOptions" [ngModel]="headingValue()"
4635
+ (mousedown)="saveSelection()" (ngModelChange)="onHeading($event)" />
4014
4636
  @for (k of [sizeKey()]; track k) {
4015
4637
  <ui-select class="toolbar-select" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.fontSize')" [placeholder]="labels.t('emailTemplateEditor.size')" [options]="fontSizeOptions" ngModel=""
4016
4638
  (mousedown)="saveSelection()" (ngModelChange)="onFontSize($event)" />
4017
4639
  }
4018
4640
  </div>
4019
4641
  <div class="toolbar-group">
4020
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignLeft')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignLeft')" (click)="execCommand('justifyLeft')">
4021
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>
4022
- </ui-button>
4023
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignCenter')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignCenter')" (click)="execCommand('justifyCenter')">
4024
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>
4642
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bold')" [uiTooltip]="labels.t('emailTemplateEditor.tipBold')" (click)="execCommand('bold')"><strong>B</strong></ui-button>
4643
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.italic')" [uiTooltip]="labels.t('emailTemplateEditor.tipItalic')" (click)="execCommand('italic')"><em>I</em></ui-button>
4644
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.underline')" [uiTooltip]="labels.t('emailTemplateEditor.tipUnderline')" (click)="execCommand('underline')"><u>U</u></ui-button>
4645
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.strikethrough')" [uiTooltip]="labels.t('emailTemplateEditor.strikethrough')" (click)="execCommand('strikeThrough')">
4646
+ <s>S</s>
4025
4647
  </ui-button>
4026
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignRight')" [uiTooltip]="labels.t('emailTemplateEditor.tipAlignRight')" (click)="execCommand('justifyRight')">
4027
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>
4648
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.subscript')" [uiTooltip]="labels.t('emailTemplateEditor.subscript')" (click)="execCommand('subscript')">
4649
+ <span class="tb-sub">x<sub>2</sub></span>
4028
4650
  </ui-button>
4029
- </div>
4030
- <div class="toolbar-group">
4031
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bulletedList')" [uiTooltip]="labels.t('emailTemplateEditor.tipBulletedList')" (click)="execCommand('insertUnorderedList')">
4032
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
4033
- </ui-button>
4034
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.numberedList')" [uiTooltip]="labels.t('emailTemplateEditor.tipNumberedList')" (click)="execCommand('insertOrderedList')">
4035
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>
4651
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.superscript')" [uiTooltip]="labels.t('emailTemplateEditor.superscript')" (click)="execCommand('superscript')">
4652
+ <span class="tb-sub">x<sup>2</sup></span>
4036
4653
  </ui-button>
4037
4654
  </div>
4038
4655
  <div class="toolbar-group">
4039
- <!-- The browser's own colour dialog is the picker; a button opens it so the toolbar keeps one look. -->
4656
+ <!-- The browser's own colour dialogs are the pickers; a button opens each so the toolbar keeps one look. -->
4040
4657
  <input #colorInput type="color" class="hidden-color-input" [attr.aria-label]="labels.t('emailTemplateEditor.textColor')" tabindex="-1" [value]="currentColor()" (change)="applyTextColor($any($event.target).value)" (mousedown)="$event.stopPropagation()" />
4041
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.textColor')" [uiTooltip]="labels.t('emailTemplateEditor.tipTextColor')" (mousedown)="openColorPicker()">
4658
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.textColor')" [uiTooltip]="labels.t('emailTemplateEditor.tipTextColor')" data-testid="text-color-button" (mousedown)="saveSelection()" (click)="toggleColorPanel('text')">
4042
4659
  <span class="color-indicator">
4043
4660
  <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><text y="20" font-size="20" font-weight="700">A</text></svg>
4044
4661
  <span class="color-bar" [style.background]="currentColor()"></span>
4045
4662
  </span>
4046
4663
  </ui-button>
4664
+ <input #highlightInput type="color" class="hidden-color-input" [attr.aria-label]="labels.t('emailTemplateEditor.highlightColor')" tabindex="-1" [value]="currentHighlight()" (change)="applyHighlight($any($event.target).value)" (mousedown)="$event.stopPropagation()" />
4665
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.highlightColor')" [uiTooltip]="labels.t('emailTemplateEditor.highlightColor')" data-testid="highlight-color-button" (mousedown)="saveSelection()" (click)="toggleColorPanel('highlight')">
4666
+ <span class="color-indicator">
4667
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 11l-6 6v3h9l3-3"/><path d="M22 12l-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>
4668
+ <span class="color-bar" [style.background]="currentHighlight()"></span>
4669
+ </span>
4670
+ </ui-button>
4047
4671
  </div>
4048
4672
  <div class="toolbar-group">
4049
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertLink')" [uiTooltip]="labels.t('emailTemplateEditor.tipInsertLink')" (mousedown)="saveSelection()" (click)="openLinkDialog()">
4050
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
4673
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignLeft')" [uiTooltip]="labels.t('emailTemplateEditor.alignLeft')" (click)="execCommand('justifyLeft')">
4674
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>
4675
+ </ui-button>
4676
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignCenter')" [uiTooltip]="labels.t('emailTemplateEditor.alignCenter')" (click)="execCommand('justifyCenter')">
4677
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>
4051
4678
  </ui-button>
4052
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertImage')" [uiTooltip]="labels.t('emailTemplateEditor.tipInsertImage')" (mousedown)="saveSelection()" (click)="openImageDialog()">
4053
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
4679
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignRight')" [uiTooltip]="labels.t('emailTemplateEditor.alignRight')" (click)="execCommand('justifyRight')">
4680
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>
4681
+ </ui-button>
4682
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.alignJustify')" [uiTooltip]="labels.t('emailTemplateEditor.alignJustify')" (click)="execCommand('justifyFull')">
4683
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="21" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="3" y2="18"/></svg>
4054
4684
  </ui-button>
4055
4685
  </div>
4056
4686
  <div class="toolbar-group">
4057
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.undo')" [uiTooltip]="labels.t('emailTemplateEditor.tipUndo')" (click)="execCommand('undo')">
4058
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13"/></svg>
4687
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.bulletedList')" [uiTooltip]="labels.t('emailTemplateEditor.bulletedList')" (click)="execCommand('insertUnorderedList')">
4688
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
4689
+ </ui-button>
4690
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.numberedList')" [uiTooltip]="labels.t('emailTemplateEditor.numberedList')" (click)="execCommand('insertOrderedList')">
4691
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>
4692
+ </ui-button>
4693
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.outdent')" [uiTooltip]="labels.t('emailTemplateEditor.outdent')" (click)="execCommand('outdent')">
4694
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>
4059
4695
  </ui-button>
4060
- <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.redo')" [uiTooltip]="labels.t('emailTemplateEditor.tipRedo')" (click)="execCommand('redo')">
4061
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M21 7v6h-6"/><path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13"/></svg>
4696
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.indent')" [uiTooltip]="labels.t('emailTemplateEditor.indent')" (click)="execCommand('indent')">
4697
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="3 8 7 12 3 16"/><line x1="21" y1="12" x2="11" y2="12"/><line x1="21" y1="6" x2="11" y2="6"/><line x1="21" y1="18" x2="11" y2="18"/></svg>
4062
4698
  </ui-button>
4063
4699
  </div>
4064
- </div>
4065
-
4066
- <!-- Toolbar row 2: block spacing -->
4067
- <div class="toolbar-row-2">
4068
- <div class="toolbar-group" (mousedown)="preventFocusLoss($event)">
4069
- <span class="toolbar-label" id="tpl-spacing-label">{{ labels.t('emailTemplateEditor.blockSpacing') }}</span>
4070
- <ui-pill-tabs [tabs]="spacingTabs" [activeKey]="blockSpacing() || 'none'" [ariaLabel]="labels.t('emailTemplateEditor.blockSpacing')" (tabChange)="applySpacing($event === 'none' ? '' : $event)" />
4700
+ <div class="toolbar-group">
4701
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertLink')" [uiTooltip]="labels.t('emailTemplateEditor.insertLink')" (mousedown)="saveSelection()" (click)="openLinkDialog()">
4702
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>
4703
+ </ui-button>
4704
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertImage')" [uiTooltip]="labels.t('emailTemplateEditor.insertImage')" (mousedown)="saveSelection()" (click)="openImageDialog()">
4705
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
4706
+ </ui-button>
4707
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.insertTable')" [uiTooltip]="labels.t('emailTemplateEditor.insertTable')" (mousedown)="saveSelection()" (click)="insertTable()">
4708
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>
4709
+ </ui-button>
4710
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.blockQuote')" [uiTooltip]="labels.t('emailTemplateEditor.blockQuote')" data-testid="quote-button" (click)="toggleQuote()">
4711
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M3 21c3 0 7-1 7-8V5H3v8h4c0 3-2 4-4 4zm11 0c3 0 7-1 7-8V5h-7v8h4c0 3-2 4-4 4z"/></svg>
4712
+ </ui-button>
4713
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.horizontalLine')" [uiTooltip]="labels.t('emailTemplateEditor.horizontalLine')" (click)="execCommand('insertHorizontalRule')">
4714
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="3" y1="12" x2="21" y2="12"/></svg>
4715
+ </ui-button>
4716
+ </div>
4717
+ <div class="toolbar-group">
4718
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.emoji')" [uiTooltip]="labels.t('emailTemplateEditor.tipEmoji')" data-testid="emoji-button" (mousedown)="saveSelection()" (click)="toggleEmojiPanel()">
4719
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>
4720
+ </ui-button>
4721
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.specialCharacters')" [uiTooltip]="labels.t('emailTemplateEditor.specialCharacters')" data-testid="special-button" (mousedown)="saveSelection()" (click)="toggleSpecialPanel()">
4722
+ <span class="tb-sub">ฮฉ</span>
4723
+ </ui-button>
4724
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.clearFormatting')" [uiTooltip]="labels.t('emailTemplateEditor.clearFormatting')" (click)="execCommand('removeFormat')">
4725
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/><line x1="3" y1="3" x2="21" y2="21"/></svg>
4726
+ </ui-button>
4727
+ </div>
4728
+ <div class="toolbar-group">
4729
+ <ui-select class="toolbar-select" size="sm" data-testid="spacing-select" [ariaLabel]="labels.t('emailTemplateEditor.blockSpacing')" [uiTooltip]="labels.t('emailTemplateEditor.blockSpacing')" [options]="spacingOptions" [ngModel]="blockSpacing() || 'none'"
4730
+ (mousedown)="saveSelection()" (ngModelChange)="applySpacing($event === 'none' ? '' : $event)" />
4071
4731
  </div>
4732
+ @if (inTable()) {
4733
+ <div class="toolbar-group" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.tableTools')" data-testid="table-tools">
4734
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableAddRow')" [uiTooltip]="labels.t('emailTemplateEditor.tableAddRow')" (click)="tableAddRow()"><span class="tb-sub">+ โ†“</span></ui-button>
4735
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableAddColumn')" [uiTooltip]="labels.t('emailTemplateEditor.tableAddColumn')" (click)="tableAddColumn()"><span class="tb-sub">+ โ†’</span></ui-button>
4736
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDeleteRow')" [uiTooltip]="labels.t('emailTemplateEditor.tableDeleteRow')" (click)="tableDeleteRow()"><span class="tb-sub">โˆ’ โ†“</span></ui-button>
4737
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDeleteColumn')" [uiTooltip]="labels.t('emailTemplateEditor.tableDeleteColumn')" (click)="tableDeleteColumn()"><span class="tb-sub">โˆ’ โ†’</span></ui-button>
4738
+ <ui-button variant="ghost" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.tableDelete')" [uiTooltip]="labels.t('emailTemplateEditor.tableDelete')" (click)="tableDelete()"><span class="tb-sub">โœ•</span></ui-button>
4739
+ </div>
4740
+ }
4072
4741
  </div>
4073
4742
  }
4074
4743
 
@@ -4077,9 +4746,9 @@ i0.ษตษตngDeclareClassMetadata({
4077
4746
  <div class="link-dialog" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.insertLink')">
4078
4747
  <div class="link-dialog-inner">
4079
4748
  <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.insertLink2') }}</span>
4080
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkAddress')" placeholder="https://example.com" [(ngModel)]="linkUrl" [error]="linkUrlError()" (keydown.enter)="insertLink()" />
4749
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkAddress')" placeholder="https://example.com" [(ngModel)]="linkUrl" [error]="linkUrlError()" (keydown.enter)="insertLink(); $event.preventDefault()" />
4081
4750
  @if (!linkTextFromSelection()) {
4082
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkText')" [placeholder]="labels.t('emailTemplateEditor.linkTextOptional')" [(ngModel)]="linkText" (keydown.enter)="insertLink()" />
4751
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.linkText')" [placeholder]="labels.t('emailTemplateEditor.linkTextOptional')" [(ngModel)]="linkText" (keydown.enter)="insertLink(); $event.preventDefault()" />
4083
4752
  }
4084
4753
  <div class="link-dialog-actions">
4085
4754
  <ui-button variant="secondary" size="sm" (click)="showLinkDialog.set(false)">{{ labels.t('common.cancel') }}</ui-button>
@@ -4089,18 +4758,75 @@ i0.ษตษตngDeclareClassMetadata({
4089
4758
  </div>
4090
4759
  }
4091
4760
 
4761
+ <!-- Colour picker (inline panel, for the text colour and the highlight): a grid of ready colours, a custom colour (the browser's own dialog) and Remove -->
4762
+ @if (canWrite() && colorPanel(); as which) {
4763
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t(which === 'text' ? 'emailTemplateEditor.textColor' : 'emailTemplateEditor.highlightColor')" data-testid="color-panel" (mousedown)="preventFocusLoss($event)" (keydown.escape)="colorPanel.set(null)">
4764
+ <div class="emoji-panel-head">
4765
+ <span class="link-dialog-title">{{ labels.t(which === 'text' ? 'emailTemplateEditor.textColor' : 'emailTemplateEditor.highlightColor') }}</span>
4766
+ <ui-button variant="secondary" size="sm" data-testid="color-remove" (click)="removeColor(which)">{{ labels.t('emailTemplateEditor.removeColor') }}</ui-button>
4767
+ <ui-button variant="secondary" size="sm" data-testid="color-custom" (click)="openCustomColor(which)">{{ labels.t('emailTemplateEditor.customColor') }}</ui-button>
4768
+ <ui-button variant="secondary" size="sm" (click)="colorPanel.set(null)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
4769
+ </div>
4770
+ <div class="color-grid" data-testid="color-grid">
4771
+ @for (c of colorSwatches; track c) {
4772
+ <button type="button" class="color-swatch" data-testid="color-swatch" [style.background]="c" [attr.aria-label]="c" [attr.title]="c" [class.selected]="(which === 'text' ? currentColor() : currentHighlight()).toLowerCase() === c" [attr.aria-pressed]="(which === 'text' ? currentColor() : currentHighlight()).toLowerCase() === c" (click)="pickColor(which, c)"></button>
4773
+ }
4774
+ </div>
4775
+ </div>
4776
+ }
4777
+
4778
+ <!-- Emoji picker (inline popover): a search box, category tabs and a skin tone; a click inserts the emoji at the caret and the panel stays open for more -->
4779
+ @if (canWrite() && showEmojiPanel()) {
4780
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.emoji')" data-testid="emoji-panel" (mousedown)="preventFocusLoss($event)">
4781
+ <div class="emoji-panel-head">
4782
+ <ui-text-input class="emoji-search" data-testid="emoji-search" [ariaLabel]="labels.t('emailTemplateEditor.emojiSearch')" [placeholder]="labels.t('emailTemplateEditor.emojiSearch')" [(ngModel)]="emojiSearch" (mousedown)="saveSelection()" />
4783
+ <ui-select class="emoji-tone" size="sm" [ariaLabel]="labels.t('emailTemplateEditor.emojiSkinTone')" [options]="skinToneOptions()" [(ngModel)]="emojiTone" (mousedown)="saveSelection()" />
4784
+ <ui-button variant="secondary" size="sm" (click)="showEmojiPanel.set(false)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
4785
+ </div>
4786
+ @if (!emojiSearch().trim()) {
4787
+ <div class="emoji-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.emoji')">
4788
+ @for (g of emojiGroupKeys; track g.key) {
4789
+ <button type="button" role="tab" class="emoji-tab" [class.active]="emojiGroup() === g.key" [attr.aria-selected]="emojiGroup() === g.key" [attr.aria-label]="emojiGroupLabel(g.key)" [attr.title]="emojiGroupLabel(g.key)" (click)="emojiGroup.set(g.key)">{{ g.icon }}</button>
4790
+ }
4791
+ </div>
4792
+ }
4793
+ <div class="emoji-grid" data-testid="emoji-grid">
4794
+ @for (e of shownEmojis(); track e.char) {
4795
+ <button type="button" class="emoji-btn" data-testid="emoji-option" [attr.aria-label]="emojiName(e)" [attr.title]="e.words.split(' ').slice(0, 3).join(' ')" (click)="insertEmoji(emojiWithTone(e))">{{ emojiWithTone(e) }}</button>
4796
+ } @empty {
4797
+ <span class="emoji-empty">{{ labels.t('emailTemplateEditor.emojiNoResults') }}</span>
4798
+ }
4799
+ </div>
4800
+ </div>
4801
+ }
4802
+
4803
+ <!-- Special characters (inline popover) -->
4804
+ @if (canWrite() && showSpecialPanel()) {
4805
+ <div class="link-dialog emoji-panel" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.specialCharacters')" data-testid="special-panel" (mousedown)="preventFocusLoss($event)">
4806
+ <div class="emoji-panel-head">
4807
+ <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.specialCharactersTitle') }}</span>
4808
+ <ui-button variant="secondary" size="sm" (click)="showSpecialPanel.set(false)">{{ labels.t('emailTemplateEditor.emojiClose') }}</ui-button>
4809
+ </div>
4810
+ <div class="emoji-grid">
4811
+ @for (c of specialCharacters; track c) {
4812
+ <button type="button" class="emoji-btn special-btn" data-testid="special-option" [attr.aria-label]="c" (click)="insertEmoji(c)">{{ c }}</button>
4813
+ }
4814
+ </div>
4815
+ </div>
4816
+ }
4817
+
4092
4818
  <!-- Image URL dialog -->
4093
4819
  @if (canWrite() && showImageDialog()) {
4094
4820
  <div class="link-dialog" role="group" [attr.aria-label]="labels.t('emailTemplateEditor.insertImage')">
4095
4821
  <div class="link-dialog-inner">
4096
4822
  <span class="link-dialog-title">{{ labels.t('emailTemplateEditor.insertImage2') }}</span>
4097
4823
  @if (imageUpload()) {
4098
- <input #imageFile type="file" class="hidden-file-input" accept="image/png,image/jpeg,image/webp,image/gif" tabindex="-1" [attr.aria-label]="labels.t('emailTemplateEditor.uploadImage')" (change)="onImageFile($event)" />
4824
+ <input #imageFile type="file" class="hidden-file-input" data-testid="image-file-input" accept="image/png,image/jpeg,image/webp,image/gif" tabindex="-1" [attr.aria-label]="labels.t('emailTemplateEditor.uploadImage')" (change)="onImageFile($event)" />
4099
4825
  <ui-button variant="secondary" size="sm" [loading]="imageUploading()" (click)="imageFile.click()">{{ imageUploading() ? labels.t('emailTemplateEditor.uploadingImage') : labels.t('emailTemplateEditor.uploadImage') }}</ui-button>
4100
4826
  <ui-error [errorId]="idPrefix() + '-image-upload-error'" [message]="imageUploadError()" />
4101
4827
  }
4102
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAddress')" placeholder="https://example.com/image.jpg" [(ngModel)]="imageUrl" [error]="imageUrlError()" (keydown.enter)="insertImageFromUrl()" />
4103
- <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAltText')" [placeholder]="labels.t('emailTemplateEditor.altTextOptional')" [(ngModel)]="imageAlt" (keydown.enter)="insertImageFromUrl()" />
4828
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAddress')" placeholder="https://example.com/image.jpg" [(ngModel)]="imageUrl" [error]="imageUrlError()" (keydown.enter)="insertImageFromUrl(); $event.preventDefault()" />
4829
+ <ui-text-input class="link-dialog-input" [ariaLabel]="labels.t('emailTemplateEditor.imageAltText')" [placeholder]="labels.t('emailTemplateEditor.altTextOptional')" [(ngModel)]="imageAlt" (keydown.enter)="insertImageFromUrl(); $event.preventDefault()" />
4104
4830
  <div class="link-dialog-actions">
4105
4831
  <ui-button variant="secondary" size="sm" (click)="showImageDialog.set(false)">{{ labels.t('common.cancel') }}</ui-button>
4106
4832
  <ui-button variant="primary" size="sm" [disabled]="!canInsertImage()" (click)="insertImageFromUrl()">{{ labels.t('common.insert') }}</ui-button>
@@ -4121,70 +4847,30 @@ i0.ษตษตngDeclareClassMetadata({
4121
4847
  </ui-alert>
4122
4848
  }
4123
4849
 
4124
- <!-- Block Canvas with DnD -->
4125
- <div class="blocks-canvas" (dragover)="onCanvasDragOver($event)" (drop)="onDropZoneDrop($event, blocks().length)" (focusout)="onBodyFocusOut($event)">
4126
- <!-- Initial drop zone (before first block) -->
4127
- <div class="drop-zone" [class.active]="dragOverIndex() === 0" (dragover)="onDropZoneDragOver($event, 0)" (dragleave)="onDropZoneLeave()" (drop)="onDropZoneDrop($event, 0)">
4128
- <span class="drop-zone-label">{{ labels.t('emailTemplateEditor.dropHere') }}</span>
4129
- </div>
4130
-
4131
- @for (block of blocks(); track block.id; let i = $index) {
4132
- <div class="block-wrapper" #blockWrapper [class.selected]="selectedBlockId() === block.id" [class.dragging]="dragFromCanvas() === i" (dragend)="onBlockDragEnd()">
4133
- @if (canWrite()) {
4134
- <!-- Only the handle is draggable: a draggable ancestor of the contenteditable breaks text selection in Firefox / Safari. Move up / down below are the keyboard and touch alternative. -->
4135
- <div class="block-drag-handle" [attr.title]="labels.t('emailTemplateEditor.dragToReorder')" draggable="true" (dragstart)="onBlockDragStart($event, i, blockWrapper)">
4136
- <svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="9" cy="6" r="1.5"/><circle cx="15" cy="6" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="9" cy="18" r="1.5"/><circle cx="15" cy="18" r="1.5"/></svg>
4137
- </div>
4138
- }
4139
-
4140
- <!-- Block content (contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps) -->
4141
- <div #blockEditor class="block-content" role="textbox" aria-multiline="true" [attr.aria-label]="labels.t('emailTemplateEditor.emailBlockN', { n: i + 1 })"
4142
- [attr.data-block-id]="block.id" [attr.data-placeholder]="i === 0 ? startPlaceholder() : labels.t('emailTemplateEditor.clickToEdit')" [attr.contenteditable]="canWrite() ? 'true' : 'false'"
4143
- (input)="onBlockInput($event, block)" (beforeinput)="onBlockBeforeInput($any($event))" (focus)="onBlockFocus(block)" (click)="selectedBlockId.set(block.id)"></div>
4144
-
4145
- @if (canWrite()) {
4146
- <div class="block-controls">
4147
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.moveBlockUp')" [uiTooltip]="labels.t('emailTemplateEditor.tipMoveUp')" [disabled]="i === 0" (mousedown)="preventFocusLoss($event)" (click)="moveBlock(i, -1)">
4148
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M18 15l-6-6-6 6"/></svg>
4149
- </ui-button>
4150
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.moveBlockDown')" [uiTooltip]="labels.t('emailTemplateEditor.tipMoveDown')" [disabled]="i === blocks().length - 1" (mousedown)="preventFocusLoss($event)" (click)="moveBlock(i, 1)">
4151
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>
4152
- </ui-button>
4153
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.duplicateBlock')" [uiTooltip]="labels.t('emailTemplateEditor.tipDuplicate')" (mousedown)="preventFocusLoss($event)" (click)="duplicateBlock(i)">
4154
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
4155
- </ui-button>
4156
- @if (blocks().length > 1) {
4157
- <ui-button variant="ghost" size="xs" [ariaLabel]="labels.t('emailTemplateEditor.deleteBlock')" [uiTooltip]="labels.t('emailTemplateEditor.tipDeleteBlock')" (mousedown)="preventFocusLoss($event)" (click)="deleteBlock(i)">
4158
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/></svg>
4159
- </ui-button>
4160
- }
4161
- </div>
4162
- }
4163
- </div>
4164
-
4165
- <!-- Drop zone after each block -->
4166
- <div class="drop-zone" [class.active]="dragOverIndex() === i + 1" (dragover)="onDropZoneDragOver($event, i + 1)" (dragleave)="onDropZoneLeave()" (drop)="onDropZoneDrop($event, i + 1)">
4167
- <span class="drop-zone-label">{{ labels.t('emailTemplateEditor.dropHere') }}</span>
4850
+ <!-- The document: ONE editing surface, like a word processor. The page is as wide as a sent email's card (600px) with the same 28px side padding, so the text wraps as it does in an inbox. -->
4851
+ <div class="blocks-canvas" [style.font-family]="canvasFont()" (focusout)="onBodyFocusOut($event)">
4852
+ @for (block of blocks(); track block.id) {
4853
+ <div class="block-wrapper">
4854
+ <!-- contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps -->
4855
+ <div #blockEditor class="block-content tpl-doc" data-testid="email-document" role="textbox" aria-multiline="true" [attr.aria-label]="labels.t('emailTemplateEditor.documentLabel')"
4856
+ [attr.data-block-id]="block.id" [attr.data-placeholder]="startPlaceholder()" [attr.contenteditable]="canWrite() ? 'true' : 'false'"
4857
+ (input)="onBlockInput($event, block)" (beforeinput)="onBlockBeforeInput($any($event))" (focus)="onBlockFocus(block)" (keyup)="refreshContext()" (mouseup)="refreshContext()" (keydown.enter)="onDocEnter($event)"
4858
+ (dragover)="onDocDragOver($event)" (drop)="onDocDrop($event)"></div>
4168
4859
  </div>
4169
4860
  }
4170
-
4171
- @if (canWrite()) {
4172
- <button type="button" class="add-block-btn" (click)="addBlock('text-block')">
4173
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>{{ labels.t('emailTemplateEditor.addBlock') }}</button>
4174
- }
4175
4861
  </div>
4176
4862
  }
4177
4863
 
4178
4864
  @if (activeEditorTab() === 'preview') {
4179
- <div class="preview-frame">
4180
- <iframe class="preview-content" [attr.title]="labels.t('emailTemplateEditor.emailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
4865
+ <div class="preview-frame" data-testid="preview-frame">
4866
+ <iframe class="preview-content" data-testid="preview-iframe" [attr.title]="labels.t('emailTemplateEditor.emailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
4181
4867
  </div>
4182
4868
  }
4183
4869
 
4184
4870
  @if (activeEditorTab() === 'mobile') {
4185
- <div class="preview-frame mobile">
4186
- <div class="mobile-shell">
4187
- <iframe class="preview-content" [attr.title]="labels.t('emailTemplateEditor.mobileEmailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
4871
+ <div class="preview-frame mobile" data-testid="mobile-preview-frame">
4872
+ <div class="mobile-shell" data-testid="mobile-shell">
4873
+ <iframe class="preview-content" data-testid="mobile-preview-iframe" [attr.title]="labels.t('emailTemplateEditor.mobileEmailPreview')" sandbox="" referrerpolicy="no-referrer" [srcdoc]="previewDoc()"></iframe>
4188
4874
  </div>
4189
4875
  </div>
4190
4876
  }
@@ -4199,18 +4885,18 @@ i0.ษตษตngDeclareClassMetadata({
4199
4885
  </div>
4200
4886
  } @else {
4201
4887
  <div class="right-tabs" role="tablist" [attr.aria-label]="labels.t('emailTemplateEditor.rightPanelSections')">
4202
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'blocks'" [attr.aria-selected]="activeRightTab() === 'blocks'" (click)="activeRightTab.set('blocks')">
4888
+ <button type="button" class="right-tab" data-testid="right-tab-blocks" role="tab" [class.active]="activeRightTab() === 'blocks'" [attr.aria-selected]="activeRightTab() === 'blocks'" (click)="activeRightTab.set('blocks')">
4203
4889
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>{{ labels.t('emailTemplateEditor.blocks') }}</button>
4204
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'variables'" [attr.aria-selected]="activeRightTab() === 'variables'" (click)="activeRightTab.set('variables')">
4890
+ <button type="button" class="right-tab" data-testid="right-tab-variables" role="tab" [class.active]="activeRightTab() === 'variables'" [attr.aria-selected]="activeRightTab() === 'variables'" (click)="activeRightTab.set('variables')">
4205
4891
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 3v18M3 12h18"/></svg>{{ labels.t('emailTemplateEditor.variables') }}</button>
4206
4892
  @if (videosEnabled()) {
4207
- <button type="button" class="right-tab" role="tab" [class.active]="activeRightTab() === 'video'" [attr.aria-selected]="activeRightTab() === 'video'" (click)="openVideoTab()">
4893
+ <button type="button" class="right-tab" data-testid="right-tab-video" role="tab" [class.active]="activeRightTab() === 'video'" [attr.aria-selected]="activeRightTab() === 'video'" (click)="openVideoTab()">
4208
4894
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2" ry="2"/></svg>{{ labels.t('common.video') }}</button>
4209
4895
  }
4210
4896
  </div>
4211
4897
 
4212
4898
  @if (activeRightTab() === 'blocks') {
4213
- <div class="right-panel-body">
4899
+ <div class="right-panel-body" data-testid="blocks-panel">
4214
4900
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.contentBlocks') }}</h4>
4215
4901
  <p class="right-section-desc">{{ labels.t('emailTemplateEditor.clickToInsertOrDrag') }}</p>
4216
4902
  <ui-search-input [placeholder]="labels.t('emailTemplateEditor.searchBlocks')" [ariaLabel]="labels.t('emailTemplateEditor.searchBlocks2')" [(value)]="blockSearch" />
@@ -4220,7 +4906,7 @@ i0.ษตษตngDeclareClassMetadata({
4220
4906
  }
4221
4907
  @for (group of filteredBlockGroups(); track group.name) {
4222
4908
  <div class="block-group">
4223
- <button type="button" class="block-group-header" [attr.aria-expanded]="isOpen('b:' + group.name)" (click)="toggleGroup('b:' + group.name)">
4909
+ <button type="button" class="block-group-header" data-testid="block-group" [attr.aria-expanded]="isOpen('b:' + group.name)" (click)="toggleGroup('b:' + group.name)">
4224
4910
  <svg class="chevron" [class.expanded]="isOpen('b:' + group.name)" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg>
4225
4911
  <span>{{ group.name }}</span>
4226
4912
  <span class="block-count">{{ group.blocks.length }}</span>
@@ -4229,7 +4915,7 @@ i0.ษตษตngDeclareClassMetadata({
4229
4915
  <div class="block-list">
4230
4916
  @for (block of group.blocks; track block.key) {
4231
4917
  <!-- A div, not a button: Firefox does not start a drag from a <button>. Role, tabindex and Enter / Space keep it a keyboard control; a click inserts the block. -->
4232
- <div role="button" tabindex="0" class="block-item" draggable="true" [attr.aria-label]="labels.t('emailTemplateEditor.insertNamed', { name: block.label })"
4918
+ <div role="button" tabindex="0" class="block-item" data-testid="block-item" [attr.data-block-key]="block.key" draggable="true" [attr.aria-label]="labels.t('emailTemplateEditor.insertNamed', { name: block.label })"
4233
4919
  (dragstart)="onPaletteDragStart($event, block)" (dragend)="onBlockDragEnd()" (click)="insertBlock(block)"
4234
4920
  (keydown.enter)="insertBlock(block); $event.preventDefault()" (keydown.space)="insertBlock(block); $event.preventDefault()">
4235
4921
  <svg class="block-item-drag" width="10" height="10" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="9" cy="6" r="1.5"/><circle cx="15" cy="6" r="1.5"/><circle cx="9" cy="12" r="1.5"/><circle cx="15" cy="12" r="1.5"/><circle cx="9" cy="18" r="1.5"/><circle cx="15" cy="18" r="1.5"/></svg>
@@ -4244,13 +4930,16 @@ i0.ษตษตngDeclareClassMetadata({
4244
4930
  }
4245
4931
 
4246
4932
  @if (activeRightTab() === 'variables') {
4247
- <div class="right-panel-body">
4933
+ <div class="right-panel-body" data-testid="variables-panel">
4248
4934
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.templateVariables') }}</h4>
4249
- <p class="right-section-desc">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>
4250
-
4251
- @for (group of variableGroups(); track group.name) {
4935
+ @if (variablesNeedAssignment()) {
4936
+ <p class="right-section-desc" role="status" data-testid="variables-need-assignment">{{ labels.t('emailTemplateEditor.assignToSeeVariables') }}</p>
4937
+ } @else {
4938
+ <p class="right-section-desc" data-testid="variables-click-hint">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>
4939
+ }
4940
+ @for (group of availableVariableGroups(); track group.name) {
4252
4941
  <div class="block-group">
4253
- <button type="button" class="block-group-header" [attr.aria-expanded]="isOpen('v:' + group.name)" (click)="toggleGroup('v:' + group.name)">
4942
+ <button type="button" class="block-group-header" data-testid="variable-group" [attr.aria-expanded]="isOpen('v:' + group.name)" (click)="toggleGroup('v:' + group.name)">
4254
4943
  <svg class="chevron" [class.expanded]="isOpen('v:' + group.name)" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M9 18l6-6-6-6"/></svg>
4255
4944
  <span>{{ group.name }}</span>
4256
4945
  <span class="block-count">{{ group.variables.length }}</span>
@@ -4258,8 +4947,8 @@ i0.ษตษตngDeclareClassMetadata({
4258
4947
  @if (isOpen('v:' + group.name)) {
4259
4948
  <div class="variable-list">
4260
4949
  @for (v of group.variables; track v.key) {
4261
- <button type="button" class="variable-item" (mousedown)="saveSelection()" (click)="insertVariable(v)">
4262
- <span class="var-tag">{{ '{{' + v.key + '}}' }}</span>
4950
+ <button type="button" class="variable-item" data-testid="variable-item" [attr.data-variable]="v.key" (mousedown)="saveSelection()" (click)="insertVariable(v)">
4951
+ <span class="var-tag" data-testid="variable-tag">{{ '{{' + v.key + '}}' }}</span>
4263
4952
  <span class="var-example">{{ labels.t('emailTemplateEditor.example', { example: v.example }) }}</span>
4264
4953
  <!-- A very short explanation of what the variable is: the host's description, else its label. -->
4265
4954
  <span class="var-description">{{ v.description || v.label }}</span>
@@ -4273,7 +4962,7 @@ i0.ษตษตngDeclareClassMetadata({
4273
4962
  }
4274
4963
 
4275
4964
  @if (activeRightTab() === 'video' && videosEnabled()) {
4276
- <div class="right-panel-body video-library-panel">
4965
+ <div class="right-panel-body video-library-panel" data-testid="video-panel">
4277
4966
  <h4 class="right-section-title">{{ labels.t('emailTemplateEditor.videoLibrary') }}</h4>
4278
4967
  <p class="right-section-hint">{{ labels.t('emailTemplateEditor.clickAVideoToAdd') }}</p>
4279
4968
 
@@ -4351,7 +5040,7 @@ i0.ษตษตngDeclareClassMetadata({
4351
5040
 
4352
5041
 
4353
5042
  `,
4354
- styles: [":host{display:flex;flex-direction:column;flex:1;min-height:0}.required{color:#ef4444;font-weight:400}.editor-page{display:flex;flex-direction:column;flex:1;min-height:0;background:#f8fafc;overflow:hidden}.editor-actions{display:flex;justify-content:space-between;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:0 0 12px;flex-shrink:0}.editor-heading{margin:0;font-size:1.25rem;font-weight:700;color:#1e293b;line-height:1.3;min-width:0}.save-wrap{display:inline-flex}.save-hint{margin:0;font-size:12px;color:#475569;flex-basis:100%;text-align:right}.editor-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-left:auto}.readonly-note{margin:0;padding:8px 16px;font-size:.8125rem;color:#92400e;background:#fffbeb;border-bottom:1px solid #fde68a}.readonly-note.system-note{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.editor-body{display:grid;grid-template-columns:340px minmax(0,1fr) 300px;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden}.panel-left{background:#fff;border-right:1px solid #e2e8f0;padding:24px;overflow-y:auto}.panel-title{font-size:1.0625rem;font-weight:700;color:#1e293b;margin:0 0 20px}.form-field{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}.form-row-dates{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:16px}.email-checks{margin:8px 12px 0}.email-checks-list{margin:0;padding-left:18px}.hidden-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.assignments-section{border-top:1px solid #e2e8f0;padding-top:20px;margin-top:16px}.section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 6px}.section-desc{font-size:.8125rem;color:#64748b;line-height:1.5;margin:0 0 12px}.assignment-list{max-height:340px;overflow-y:auto;margin-top:12px;border:1px solid #e2e8f0;border-radius:8px}.assignment-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;cursor:pointer;border-bottom:1px solid #f1f5f9;transition:background .1s}.assignment-item:last-child{border-bottom:none}.assignment-item:hover{background:#f8fafc}.assignment-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.assignment-item.assignment-readonly{cursor:default}.assignment-item.assignment-readonly:hover{background:transparent}.assignment-text{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.assignment-text strong{font-size:.8125rem;color:#1e293b}.assignment-text span{font-size:.75rem;color:#64748b}.assignment-channels{display:flex;gap:4px;flex-shrink:0}.channel-badge{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;background:#f1f5f9;color:#64748b;transition:all .15s}.channel-badge.active{background:#3b82f6;color:#fff}.channel-badge.disabled{opacity:.4;cursor:not-allowed}.config-desc{font-size:.875rem;color:#64748b;line-height:1.5;margin:0}.config-divider{border:none;border-top:1px solid #e2e8f0;margin:20px 0}.config-section{display:flex;flex-direction:column;gap:12px}.config-section-label{font-size:.6875rem;font-weight:700;color:#3b82f6;text-transform:uppercase;letter-spacing:.04em}.config-field{display:flex;flex-direction:column;gap:6px}.config-field-mt{margin-top:16px}.config-label{font-size:.8125rem;font-weight:600;color:#1e293b}.config-readonly{padding:9px 12px;border:1px solid #e2e8f0;border-radius:8px;background:#f8fafc;font-size:.875rem;color:#1e293b}.config-hint{font-size:.75rem;color:#64748b}.test-save-note{display:flex;align-items:center;gap:8px;padding:10px 14px;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;font-size:.8125rem;color:#92400e;margin-top:12px}.test-save-note svg{flex-shrink:0}.panel-center{display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden}.editor-tabs{display:flex;gap:2px;padding:12px 20px 0;background:#fff;border-bottom:1px solid #e2e8f0;overflow-x:auto;-webkit-overflow-scrolling:touch}.editor-tab{display:flex;align-items:center;gap:6px;padding:10px 16px;border:1px solid #e2e8f0;border-bottom:none;border-radius:8px 8px 0 0;background:#f8fafc;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;white-space:nowrap}.editor-tab:hover{background:#fff;color:#1e293b}.editor-tab.active{background:#eff6ff;color:#1d4ed8;border-color:#93c5fd}.editor-tab:focus-visible,.right-tab:focus-visible,.block-group-header:focus-visible,.variable-item:focus-visible,.add-block-btn:focus-visible,.block-item:focus-visible,.video-lib-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.editor-toolbar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:#fff;border-bottom:1px solid #e2e8f0;flex-wrap:wrap}.toolbar-row-2{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 20px;background:#fff;border-bottom:1px solid #e2e8f0}.toolbar-group{display:flex;align-items:center;gap:2px;padding-right:8px;border-right:1px solid #e2e8f0}.toolbar-group:last-child{border-right:none;padding-right:0}.toolbar-select{display:block;min-width:96px}.toolbar-label{font-size:.75rem;font-weight:600;color:#64748b;white-space:nowrap;margin-right:6px}.hidden-color-input{position:absolute;width:0;height:0;opacity:0;pointer-events:none;border:none;padding:0}.color-indicator{display:flex;flex-direction:column;align-items:center;gap:2px;color:#475569}.color-bar{display:block;width:16px;height:3px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.link-dialog{background:#fff;border-bottom:1px solid #e2e8f0;padding:12px 20px}.link-dialog-inner{display:flex;align-items:flex-start;gap:8px;flex-wrap:wrap}.link-dialog-title{font-size:.8125rem;font-weight:700;color:#1e293b;white-space:nowrap;padding-top:10px}.link-dialog-input{display:block;width:240px;max-width:100%}.link-dialog-actions{display:flex;gap:6px}.preview-frame{flex:1;display:flex;justify-content:center;align-items:stretch;padding:24px;overflow-y:auto;background:#f1f5f9}.preview-frame.mobile{align-items:flex-start}.preview-content{display:block;flex:1 1 auto;max-width:600px;width:100%;box-sizing:border-box;min-height:400px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.mobile-shell{width:375px;max-width:100%;box-sizing:border-box;min-height:600px;border:2px solid #1e293b;border-radius:24px;padding:40px 12px 24px;background:#fff;box-shadow:0 8px 32px #0000001f}.mobile-shell .preview-content{border:none;border-radius:0;max-width:100%;height:520px;min-height:0}.blocks-canvas{flex:1 1 0;min-height:0;padding:16px 20px 24px 56px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;background:#f1f5f9;display:flex;flex-direction:column}.block-wrapper{flex-shrink:0;position:relative;display:flex;align-items:flex-start;background:#fff;border:2px solid transparent;border-radius:8px;transition:border-color .15s,box-shadow .15s}.block-wrapper:hover,.block-wrapper.selected,.block-wrapper:focus-within{border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.block-wrapper:hover .block-drag-handle,.block-wrapper.selected .block-drag-handle,.block-wrapper:focus-within .block-drag-handle{opacity:1}.block-wrapper:hover .block-controls,.block-wrapper.selected .block-controls,.block-wrapper:focus-within .block-controls{opacity:1;pointer-events:all}.block-wrapper.dragging{opacity:.4}.block-drag-handle{flex-shrink:0;width:28px;display:flex;align-items:flex-start;justify-content:center;padding-top:14px;opacity:0;transition:opacity .15s;cursor:grab;color:#94a3b8}.block-drag-handle:active{cursor:grabbing}.block-content{flex:1;min-width:0;padding:12px 16px;outline:none;font-size:.9375rem;color:#1e293b;line-height:1.6;min-height:48px;overflow-wrap:anywhere}.block-content:empty:before{content:attr(data-placeholder);color:#64748b;font-style:italic;pointer-events:none}.block-content p{margin:0 0 8px}.block-content p:last-child{margin:0}.block-content h1,.block-content h2,.block-content h3{margin:8px 0 6px;color:#1e293b}.block-content a{color:#3b82f6}.block-content img{max-width:100%;border-radius:6px}.block-content ul,.block-content ol{padding-left:20px;margin:0 0 8px}.block-controls{position:absolute;top:0;left:-48px;flex-direction:column;display:flex;gap:2px;opacity:0;pointer-events:none;transition:opacity .15s;background:#fff;border:1px solid #e2e8f0;border-radius:6px;padding:3px;box-shadow:0 2px 6px #00000014}@media(pointer:coarse){.editor-tab,.right-tab,.block-group-header{min-height:44px}}@media(hover:none){.block-wrapper.selected .block-controls{opacity:1;pointer-events:all}}.drop-zone{flex-shrink:0;height:8px;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:height .15s,background .15s;position:relative}.drop-zone-label{font-size:.75rem;font-weight:600;color:#1d4ed8;opacity:0;transition:opacity .1s}.drop-zone.active{height:40px;background:#3b82f614;border:2px dashed #3b82f6}.drop-zone.active .drop-zone-label{opacity:1}.add-block-btn{flex-shrink:0;display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:44px;padding:12px;margin-top:8px;border:2px dashed #e2e8f0;border-radius:8px;background:none;font-size:.875rem;font-weight:600;color:#475569;cursor:pointer;font-family:inherit;transition:border-color .15s,color .15s,background .15s}.add-block-btn:hover{border-color:#3b82f6;color:#3b82f6;background:#3b82f60a}.panel-right{background:#fff;border-left:1px solid #e2e8f0;display:flex;flex-direction:column;min-height:0;min-width:0}.right-tabs{display:flex;border-bottom:1px solid #e2e8f0}.right-tab{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:12px;min-height:44px;border:none;background:none;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;border-bottom:2px solid transparent}.right-tab:hover{color:#1e293b}.right-tab.active{color:#1d4ed8;background:#eff6ff;border-bottom-color:#3b82f6}.right-panel-body{flex:1;padding:20px;overflow-y:auto}.right-section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 12px}.right-section-desc{font-size:.8125rem;color:#64748b;margin:0 0 16px;line-height:1.5}.right-section-hint{font-size:.8125rem;color:#64748b;margin:0 0 12px;line-height:1.5}.block-group{border-bottom:1px solid #f1f5f9}.block-group-header{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:12px 0;border:none;background:none;font-size:.875rem;font-weight:600;color:#1e293b;cursor:pointer;font-family:inherit;text-align:left}.block-group-header .chevron{transition:transform .2s;color:#94a3b8}.block-group-header .chevron.expanded{transform:rotate(90deg)}.block-group-header span:nth-of-type(1){flex:1}.block-count{font-size:.75rem;font-weight:600;color:#475569;background:#f1f5f9;padding:2px 8px;border-radius:10px;margin-left:auto}.block-list{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.variable-list{display:flex;flex-direction:column;padding-bottom:8px}.variable-item+.variable-item{border-top:1px solid #f1f5f9;border-radius:0}.block-item{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-height:44px;padding:8px 0;font-size:.8125rem;color:#64748b;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit;-webkit-user-select:none;user-select:none}.block-item:hover{background:#f8fafc;color:#1e293b}.block-item-drag{color:#cbd5e1;flex-shrink:0;cursor:grab}.variable-item{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-height:44px;padding:8px 0;min-width:0;width:100%;box-sizing:border-box;border:none;background:none;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit}.variable-item:hover{background:#f8fafc}.var-tag{max-width:100%;overflow-wrap:anywhere;font-size:.75rem;font-weight:600;color:#1d4ed8;background:#3b82f614;padding:2px 6px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.var-example{font-size:.75rem;color:#64748b;overflow-wrap:anywhere}.var-description{font-size:.75rem;color:#64748b;line-height:1.4;overflow-wrap:anywhere}.video-library-panel{padding:0}.video-library-panel .right-section-title,.video-library-panel .right-section-hint{padding:0 16px}.video-library-panel .right-section-title{padding-top:16px}.video-config-section{display:flex;flex-direction:column;gap:8px;padding:12px 16px;border-bottom:1px solid #f1f5f9}.video-config-section:last-of-type{border-bottom:none}.video-lib-list{display:flex;flex-direction:column;gap:2px;padding:8px 8px 16px}.video-lib-item{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:8px;border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;text-align:left;font-family:inherit;transition:background .15s,border-color .15s}.video-lib-item:hover{background:#f8fafc;border-color:#e2e8f0}.video-lib-item.selected{background:#eff6ff;border-color:#93c5fd}.vli-thumb{position:relative;flex-shrink:0;width:56px;height:40px;border-radius:6px;background:linear-gradient(135deg,#f1f5f9,#e2e8f0);display:flex;align-items:center;justify-content:center}.vli-dur{position:absolute;bottom:2px;right:3px;font-size:.625rem;font-weight:600;color:#fff;background:#000000a6;padding:1px 4px;border-radius:3px}.vli-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.vli-title{font-size:.8125rem;font-weight:600;color:#1e293b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vli-cat{font-size:.75rem;color:#475569}.vli-check{flex-shrink:0}.video-lib-loading{padding:8px}.video-lib-skeleton{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:4px}.vls-info{flex:1;display:flex;flex-direction:column;gap:6px}@media(max-width:1200px){.editor-body{grid-template-columns:280px minmax(0,1fr) 260px}}@media(max-width:900px){:host{flex:none}.editor-page{flex:none;min-height:100vh;min-height:100dvh;overflow:visible}.editor-body{display:flex;flex-direction:column;flex:none;overflow:visible}.panel-left{border-right:none;border-bottom:1px solid #e2e8f0;overflow:visible;padding:16px}.panel-center{overflow:visible;min-height:480px}.blocks-canvas{overflow:visible;min-height:320px}.panel-right{border-left:none;border-top:1px solid #e2e8f0}.right-panel-body{overflow:visible}.editor-toolbar,.toolbar-row-2,.link-dialog,.editor-tabs{padding-left:12px;padding-right:12px}.preview-frame{padding:12px}.form-row-dates{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}\n"]
5043
+ styles: [":host{display:flex;flex-direction:column;flex:1;min-height:0}.required{color:#ef4444;font-weight:400}.editor-page{display:flex;flex-direction:column;flex:1;min-height:0;background:#f8fafc;overflow:hidden}.editor-actions{display:flex;justify-content:space-between;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:0 0 12px;flex-shrink:0}.editor-heading-group{display:flex;align-items:center;gap:4px;min-width:0}.editor-heading{margin:0;font-size:1.25rem;font-weight:700;color:#1e293b;line-height:1.3;min-width:0}.save-wrap{display:inline-flex}.save-hint{margin:0;font-size:12px;color:#475569;flex-basis:100%;text-align:right}.editor-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-left:auto}.readonly-note{margin:0;padding:8px 16px;font-size:.8125rem;color:#92400e;background:#fffbeb;border-bottom:1px solid #fde68a}.readonly-note.system-note{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.editor-body{display:grid;grid-template-columns:340px minmax(0,1fr) 300px;grid-template-rows:minmax(0,1fr);flex:1;min-height:0;overflow:hidden}.panel-left{background:#fff;border-right:1px solid #e2e8f0;padding:24px;overflow-y:auto;overflow-x:hidden}.panel-title{font-size:1.0625rem;font-weight:700;color:#1e293b;margin:0 0 20px}.form-field{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}.form-row-dates{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:16px}.form-row-dates>*{min-width:0}.email-checks{margin:8px 12px 0}.email-checks-list{margin:0;padding-left:18px}.hidden-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.assignments-section{border-top:1px solid #e2e8f0;padding-top:20px;margin-top:16px}.section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 6px}.section-desc{font-size:.8125rem;color:#64748b;line-height:1.5;margin:0 0 12px}.assignment-list{max-height:340px;overflow-y:auto;margin-top:12px;border:1px solid #e2e8f0;border-radius:8px}.assignment-group{position:sticky;top:0;z-index:1;padding:8px 14px;background:#f8fafc;border-bottom:1px solid #e2e8f0;font-size:.6875rem;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:.04em}.assignment-item{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;cursor:pointer;border-bottom:1px solid #f1f5f9;transition:background .1s}.assignment-item:last-child{border-bottom:none}.assignment-item:hover{background:#f8fafc}.assignment-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.assignment-item.assignment-readonly{cursor:default}.assignment-item.assignment-readonly:hover{background:transparent}.assignment-text{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.assignment-text strong{font-size:.8125rem;color:#1e293b}.assignment-text span{font-size:.75rem;color:#64748b}.assignment-channels{display:flex;gap:4px;flex-shrink:0}.channel-badge{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:4px;background:#f1f5f9;color:#64748b;transition:all .15s}.channel-badge.active{background:#3b82f6;color:#fff}.channel-badge.disabled{opacity:.4;cursor:not-allowed}.config-desc{font-size:.875rem;color:#64748b;line-height:1.5;margin:0}.config-section{display:flex;flex-direction:column;gap:12px}.config-field{display:flex;flex-direction:column;gap:6px}.config-field-mt{margin-top:16px}.test-save-note{display:flex;align-items:center;gap:8px;padding:10px 14px;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;font-size:.8125rem;color:#92400e;margin-top:12px}.test-save-note svg{flex-shrink:0}.panel-center{display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden}.editor-tabs{display:flex;gap:2px;padding:12px 20px 0;background:#fff;border-bottom:1px solid #e2e8f0;overflow-x:auto;-webkit-overflow-scrolling:touch}.editor-tab{display:flex;align-items:center;gap:6px;padding:10px 16px;border:1px solid #e2e8f0;border-bottom:none;border-radius:8px 8px 0 0;background:#f8fafc;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;white-space:nowrap}.editor-tab:hover{background:#fff;color:#1e293b}.editor-tab.active{background:#eff6ff;color:#1d4ed8;border-color:#93c5fd}.editor-tab:focus-visible,.right-tab:focus-visible,.block-group-header:focus-visible,.variable-item:focus-visible,.block-item:focus-visible,.video-lib-item:focus-visible{outline:2px solid #3b82f6;outline-offset:-2px}.editor-toolbar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:#fff;border-bottom:1px solid #e2e8f0;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:2px;padding-right:8px;border-right:1px solid #e2e8f0}.toolbar-group:last-child{border-right:none;padding-right:0}.toolbar-select{display:block;min-width:96px}.hidden-color-input{position:absolute;width:0;height:0;opacity:0;pointer-events:none;border:none;padding:0}.color-indicator{display:flex;flex-direction:column;align-items:center;gap:2px;color:#475569}.color-bar{display:block;width:16px;height:3px;border-radius:2px;border:1px solid rgba(0,0,0,.1)}.link-dialog{background:#fff;border-bottom:1px solid #e2e8f0;padding:12px 20px}.link-dialog-inner{display:flex;align-items:flex-start;gap:8px;flex-wrap:wrap}.link-dialog-title{font-size:.8125rem;font-weight:700;color:#1e293b;white-space:nowrap;padding-top:10px}.link-dialog-input{display:block;width:240px;max-width:100%}.link-dialog-actions{display:flex;gap:6px}.emoji-panel-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;flex-wrap:wrap}.emoji-search{display:block;flex:1 1 200px;min-width:160px}.emoji-tone{display:block;min-width:120px}.emoji-tabs{display:flex;gap:2px;border-bottom:1px solid #e2e8f0;margin-bottom:8px;overflow-x:auto}.emoji-tab{flex:0 0 auto;width:40px;height:36px;border:0;border-bottom:2px solid transparent;background:transparent;font-size:18px;cursor:pointer;font-family:\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Noto Color Emoji\",sans-serif}.emoji-tab.active{border-bottom-color:#3b82f6;background:#eff6ff}.color-grid{display:grid;grid-template-columns:repeat(10,28px);gap:4px}.color-swatch{width:28px;height:28px;border-radius:6px;border:1px solid rgba(0,0,0,.15);cursor:pointer;padding:0}.color-swatch:hover{transform:scale(1.1)}.color-swatch:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.color-swatch.selected{outline:2px solid #1e293b;outline-offset:1px}@media(pointer:coarse){.color-grid{grid-template-columns:repeat(auto-fill,44px);max-height:240px;overflow-y:auto}.color-swatch{width:44px;height:44px}}.emoji-grid{display:flex;flex-wrap:wrap;gap:2px;max-height:220px;overflow-y:auto}.emoji-empty{font-size:.8125rem;color:#64748b;padding:8px 4px}.emoji-btn{width:36px;height:36px;padding:0;border:0;border-radius:6px;background:transparent;font-size:20px;line-height:1;cursor:pointer;font-family:\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Noto Color Emoji\",sans-serif}.emoji-btn.special-btn{font-family:inherit;font-size:16px}.emoji-btn:hover,.emoji-btn:focus-visible{background:#f1f5f9}.tb-sub{font-size:12px;font-weight:700;line-height:1}@media(pointer:coarse){.emoji-btn{width:44px;height:44px}}.preview-frame{flex:1;display:flex;justify-content:center;align-items:stretch;padding:24px;overflow-y:auto;background:#f1f5f9}.preview-frame.mobile{align-items:flex-start}.preview-content{display:block;flex:1 1 auto;max-width:602px;width:100%;box-sizing:border-box;min-height:400px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.mobile-shell{width:375px;max-width:100%;box-sizing:border-box;min-height:600px;border:2px solid #1e293b;border-radius:24px;padding:40px 12px 24px;background:#fff;box-shadow:0 8px 32px #0000001f}.mobile-shell .preview-content{border:none;border-radius:0;max-width:100%;height:520px;min-height:0}.block-wrapper{flex-shrink:0;width:100%;max-width:602px;margin:0 auto;box-sizing:border-box;padding:24px 28px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.blocks-canvas{flex:1 1 0;min-height:0;padding:16px 20px 24px 56px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;background:#f1f5f9;display:flex;flex-direction:column}.block-content{min-width:0;padding:0;outline:none;font-size:15px;color:#1e293b;line-height:1.6;min-height:320px;overflow-wrap:anywhere}.block-content:empty:before{content:attr(data-placeholder);color:#64748b;font-style:italic;pointer-events:none}@media(pointer:coarse){.editor-tab,.right-tab,.block-group-header{min-height:44px}}.panel-right{background:#fff;border-left:1px solid #e2e8f0;display:flex;flex-direction:column;min-height:0;min-width:0}.right-tabs{display:flex;border-bottom:1px solid #e2e8f0}.right-tab{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:12px;min-height:44px;border:none;background:none;font-size:.8125rem;font-weight:600;color:#64748b;cursor:pointer;font-family:inherit;border-bottom:2px solid transparent}.right-tab:hover{color:#1e293b}.right-tab.active{color:#1d4ed8;background:#eff6ff;border-bottom-color:#3b82f6}.right-panel-body{flex:1;padding:20px;overflow-y:auto}.right-section-title{font-size:.9375rem;font-weight:700;color:#1e293b;margin:0 0 12px}.right-section-desc{font-size:.8125rem;color:#64748b;margin:0 0 16px;line-height:1.5}.right-section-hint{font-size:.8125rem;color:#64748b;margin:0 0 12px;line-height:1.5}.block-group{border-bottom:1px solid #f1f5f9}.block-group-header{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:12px 0;border:none;background:none;font-size:.875rem;font-weight:600;color:#1e293b;cursor:pointer;font-family:inherit;text-align:left}.block-group-header .chevron{transition:transform .2s;color:#94a3b8}.block-group-header .chevron.expanded{transform:rotate(90deg)}.block-group-header span:nth-of-type(1){flex:1}.block-count{font-size:.75rem;font-weight:600;color:#475569;background:#f1f5f9;padding:2px 8px;border-radius:10px;margin-left:auto}.block-list{display:flex;flex-direction:column;gap:2px;padding-bottom:8px}.variable-list{display:flex;flex-direction:column;padding-bottom:8px}.variable-item+.variable-item{border-top:1px solid #f1f5f9;border-radius:0}.block-item{display:flex;align-items:center;gap:6px;box-sizing:border-box;width:100%;min-height:44px;padding:8px 0;font-size:.8125rem;color:#64748b;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit;-webkit-user-select:none;user-select:none}.block-item:hover{background:#f8fafc;color:#1e293b}.block-item-drag{color:#cbd5e1;flex-shrink:0;cursor:grab}.variable-item{display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-height:44px;padding:8px 0;min-width:0;width:100%;box-sizing:border-box;border:none;background:none;cursor:pointer;text-align:left;border-radius:4px;font-family:inherit}.variable-item:hover{background:#f8fafc}.var-tag{max-width:100%;overflow-wrap:anywhere;font-size:.75rem;font-weight:600;color:#1d4ed8;background:#3b82f614;padding:2px 6px;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.var-example{font-size:.75rem;color:#64748b;overflow-wrap:anywhere}.var-description{font-size:.75rem;color:#64748b;line-height:1.4;overflow-wrap:anywhere}.video-library-panel{padding:0}.video-library-panel .right-section-title,.video-library-panel .right-section-hint{padding:0 16px}.video-library-panel .right-section-title{padding-top:16px}.video-config-section{display:flex;flex-direction:column;gap:8px;padding:12px 16px;border-bottom:1px solid #f1f5f9}.video-config-section:last-of-type{border-bottom:none}.video-lib-list{display:flex;flex-direction:column;gap:2px;padding:8px 8px 16px}.video-lib-item{display:flex;align-items:center;gap:10px;width:100%;min-height:44px;padding:8px;border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;text-align:left;font-family:inherit;transition:background .15s,border-color .15s}.video-lib-item:hover{background:#f8fafc;border-color:#e2e8f0}.video-lib-item.selected{background:#eff6ff;border-color:#93c5fd}.vli-thumb{position:relative;flex-shrink:0;width:56px;height:40px;border-radius:6px;background:linear-gradient(135deg,#f1f5f9,#e2e8f0);display:flex;align-items:center;justify-content:center}.vli-dur{position:absolute;bottom:2px;right:3px;font-size:.625rem;font-weight:600;color:#fff;background:#000000a6;padding:1px 4px;border-radius:3px}.vli-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.vli-title{font-size:.8125rem;font-weight:600;color:#1e293b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vli-cat{font-size:.75rem;color:#475569}.vli-check{flex-shrink:0}.video-lib-loading{padding:8px}.video-lib-skeleton{display:flex;align-items:center;gap:10px;padding:8px;margin-bottom:4px}.vls-info{flex:1;display:flex;flex-direction:column;gap:6px}@media(max-width:1200px){.editor-body{grid-template-columns:280px minmax(0,1fr) 260px}}@media(max-width:900px){:host{flex:none}.editor-page{flex:none;min-height:100vh;min-height:100dvh;overflow:visible}.editor-body{display:flex;flex-direction:column;flex:none;overflow:visible}.panel-left{border-right:none;border-bottom:1px solid #e2e8f0;overflow:visible;padding:16px}.panel-center{overflow:visible;min-height:480px}.blocks-canvas{overflow:visible;min-height:320px}.panel-right{border-left:none;border-top:1px solid #e2e8f0}.right-panel-body{overflow:visible}.editor-toolbar,.link-dialog,.editor-tabs{padding-left:12px;padding-right:12px}.preview-frame{padding:12px}.form-row-dates{grid-template-columns:1fr}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}\n"]
4355
5044
  }]
4356
5045
  }],
4357
5046
  ctorParameters: () => [],
@@ -4388,6 +5077,14 @@ i0.ษตษตngDeclareClassMetadata({
4388
5077
  required: false
4389
5078
  }]
4390
5079
  }],
5080
+ showSaveHint: [{
5081
+ type: i0.Input,
5082
+ args: [{
5083
+ isSignal: true,
5084
+ alias: "showSaveHint",
5085
+ required: false
5086
+ }]
5087
+ }],
4391
5088
  previewBrand: [{
4392
5089
  type: i0.Input,
4393
5090
  args: [{
@@ -4635,6 +5332,10 @@ i0.ษตษตngDeclareClassMetadata({
4635
5332
  colorInputRef: [{
4636
5333
  type: i0.ViewChild,
4637
5334
  args: ["colorInput", { isSignal: true }]
5335
+ }],
5336
+ highlightInputRef: [{
5337
+ type: i0.ViewChild,
5338
+ args: ["highlightInput", { isSignal: true }]
4638
5339
  }]
4639
5340
  }
4640
5341
  });
@@ -4781,6 +5482,6 @@ i0.ษตษตngDeclareClassMetadata({
4781
5482
  args: [{ providedIn: "root" }]
4782
5483
  }]
4783
5484
  });
4784
- export { DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS, DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS, EMAIL_BLOCK_DRAG_TYPE, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT, EMAIL_TEMPLATE_START_TEXT, EmailTemplateEditorComponent, InspectionTemplatePrintService, MAX_EMAIL_ADDRESS_LENGTH, RICH_TEXT_OPTIONS, RichTextEditorComponent, blockHasContent, buildInspectionTemplateHtml, buildPreviewDocument, buildVideoBlockHtml, escapeHtml, fillSampleVariables, findEmailChecks, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isVariableAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, safePreviewBrand, sanitizeRichTextHtml, serializedTextLength, usedVariableKeys };
5485
+ export { DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS, DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS, EMAIL_BLOCK_DRAG_TYPE, EMAIL_DEFAULT_FONT, EMAIL_EMOJIS, EMAIL_EMOJI_GROUP_KEYS, EMAIL_SKIN_TONES, EMAIL_SPECIAL_CHARACTERS, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT, EMAIL_TEMPLATE_START_TEXT, EmailTemplateEditorComponent, InspectionTemplatePrintService, MAX_EMAIL_ADDRESS_LENGTH, RICH_TEXT_OPTIONS, RichTextEditorComponent, blockHasContent, buildInspectionTemplateHtml, buildPreviewDocument, buildVideoBlockHtml, escapeHtml, fillSampleVariables, findEmailChecks, findEmojis, formatCategoryLabel, formatVideoDuration, insideEditorBlock, inspectionTemplateStatusLabel, isBlockDrag, isValidEmailAddress, isVariableAddress, isWebUrl, localizedEmailBlockGroups, localizedEmailVariableGroups, plainTextToHtml, safePreviewBrand, sanitizeRichTextHtml, serializedTextLength, usedVariableKeys, withSkinTone };
4785
5486
 
4786
5487
  //# sourceMappingURL=forgeroute-ui-editor.mjs.map