Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(email): preserve button styling in sanitized HTML emails (#2294)
Evan Hutnikc68f0e3326da
diff --git a/js/app/packages/block-email/component/EmailMessageBody.tsx b/js/app/packages/block-email/component/EmailMessageBody.tsxindex e082ced19f..b85934e505 100644--- a/js/app/packages/block-email/component/EmailMessageBody.tsx+++ b/js/app/packages/block-email/component/EmailMessageBody.tsx@@ -123,12 +123,23 @@ export function EmailMessageBody(props: EmailMessageBodyProps) {const styleEl = document.createElement('style');// Normalize font in emailconst fontOverride = isPersonal()- ? `*:not(code):not(pre):not(code *):not(pre *){font-family: system-ui, sans-serif !important; font-size: inherit !important; line-height: 1.5 !important;}`+ ? `*:not(code):not(pre):not(code *):not(pre *):not([data-macro-btn]){font-family: system-ui, sans-serif !important; font-size: inherit !important; line-height: 1.5 !important;}`: '';styleEl.textContent = `img{display: var(--macro-email-img-display, initial); max-width: 100% !important; height: auto !important;}${fontOverride}`;shadow.appendChild(styleEl);const messageDiv = document.createElement('div');messageDiv.innerHTML = source()?.mainContent ?? '';+ // Mark button-like anchors so the font override doesn't break their sizing+ for (const a of messageDiv.querySelectorAll<HTMLAnchorElement>(+ 'a[style]'+ )) {+ if (a.style.backgroundColor) {+ a.dataset.macroBtn = '';+ for (const child of a.querySelectorAll('*')) {+ (child as HTMLElement).dataset.macroBtn = '';+ }+ }+ }// Open links in a new tab instead of navigating the current onefor (const a of messageDiv.querySelectorAll('a[href]')) {a.setAttribute('target', '_blank');diff --git a/rust/cloud-storage/email_service/src/convert/sanitizer.rs b/rust/cloud-storage/email_service/src/convert/sanitizer.rsindex bdd4debbdc..213a3c83cf 100644--- a/rust/cloud-storage/email_service/src/convert/sanitizer.rs+++ b/rust/cloud-storage/email_service/src/convert/sanitizer.rs@@ -180,6 +180,7 @@ fn get_safe_css_properties() -> HashSet<&'static str> {"font-size","font-weight","font-style",+ "font","font-variant","text-decoration","text-transform",