/** CSS injecté dans les iframes d’aperçu mail (sujet + corps). */ import { stripHiddenEmailHtml } from "@/lib/strip-hidden-email-html" const DARK_TEXT = "#e8eaed" const DARK_LINK = "#8ab4f8" const LIGHT_TEXT = "#202124" const LIGHT_LINK = "#1a73e8" export function emailPreviewBaseCss(isDark: boolean): string { return ` * { margin: 0; padding: 0; box-sizing: border-box; } html { color-scheme: ${isDark ? "dark" : "light"}; background: transparent !important; } html, body { background: transparent !important; overflow: visible; word-wrap: break-word; overflow-wrap: break-word; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; line-height: 1.6; color: ${isDark ? DARK_TEXT : LIGHT_TEXT} !important; padding: 0; } a, a * { color: ${isDark ? DARK_LINK : LIGHT_LINK} !important; } img { max-width: 100%; height: auto; } blockquote { border-left: 3px solid ${isDark ? "#5f6368" : "#dadce0"}; padding-left: 12px; margin: 8px 0; color: ${isDark ? "#9aa0a6" : "#5f6368"} !important; } pre, code { background: ${isDark ? "#3c4043" : "#f6f8fa"} !important; color: ${isDark ? DARK_TEXT : LIGHT_TEXT} !important; border-radius: 3px; font-size: 13px; } pre { padding: 12px; overflow-x: auto; } code { padding: 2px 6px; } ` } export function emailPreviewSubjectCss(isDark: boolean): string { return ` * { margin: 0; padding: 0; box-sizing: border-box; } html { color-scheme: ${isDark ? "dark" : "light"}; background: transparent !important; } html, body { background: transparent !important; overflow: hidden; white-space: normal; word-wrap: break-word; } body { font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 22px; line-height: 1.3; color: ${isDark ? DARK_TEXT : LIGHT_TEXT} !important; padding: 0; } ` } /** CSS minimal quand le mail conserve sa mise en forme d'origine (contenu distant autorisé). */ export function emailPreviewWrapperCss(isDark = false): string { return ` html { color-scheme: ${isDark ? "dark" : "light"}; background: transparent !important; } html, body { margin: 0; padding: 0; background: transparent !important; } body { overflow: visible; word-wrap: break-word; overflow-wrap: break-word; } img { max-width: 100%; height: auto; } ` } /** Force le texte clair et fonds transparents sur le HTML d'e-mail en mode sombre. */ export function emailPreviewDarkOverrideCss(): string { return ` :root { color-scheme: dark; } body, body div, body p, body span, body td, body th, body li, body font, body h1, body h2, body h3, body h4, body h5, body h6, body label, body strong, body b, body em, body i, body u, body center, body table, body tbody, body thead, body tfoot, body tr { color: ${DARK_TEXT} !important; } body a, body a * { color: ${DARK_LINK} !important; } [bgcolor="#ffffff"], [bgcolor="#FFFFFF"], [bgcolor="white"], [bgcolor="#f8f9fa"], [bgcolor="#F8F9FA"], [bgcolor="#f1f3f4"], [bgcolor="#F1F3F4"], [bgcolor="#e8eaed"], [bgcolor="#E8EAED"], [bgcolor="#f6f8fc"], [bgcolor="#F6F8FC"], [bgcolor="#fafafa"], [bgcolor="#FAFAFA"], [bgcolor="#eeeeee"], [bgcolor="#EEEEEE"], [bgcolor="#fcfcfc"], [bgcolor="#FCFCFC"], [bgcolor="#fff"], [bgcolor="#FFF"] { background-color: transparent !important; background: transparent !important; } [color="#000000"], [color="#000"], [color="#111111"], [color="#202124"], [color="#3c4043"], [color="#5f6368"], [color="#444746"], [color="#1f1f1f"], [color="#333333"], [color="#333"], [color="#666666"], [color="#666"], [color="#757575"], [color="#80868b"], [color="#9aa0a6"] { color: ${DARK_TEXT} !important; } font[color] { color: ${DARK_TEXT} !important; } [bgcolor="#000000"], [bgcolor="#000"], [bgcolor="#202124"], [bgcolor="#3c4043"], [bgcolor="#1a1a1a"], [bgcolor="#2d2d2d"] { background-color: #3c4043 !important; } div, td, th, p, span, li, h1, h2, h3, h4, h5, h6, table { border-color: color-mix(in srgb, ${DARK_TEXT} 25%, transparent) !important; } ` } /** * En fin de
(après les