diff --git a/apps/x/apps/renderer/src/components/email-view.tsx b/apps/x/apps/renderer/src/components/email-view.tsx index bd720692..173e22ee 100644 --- a/apps/x/apps/renderer/src/components/email-view.tsx +++ b/apps/x/apps/renderer/src/components/email-view.tsx @@ -312,6 +312,10 @@ function buildEmailDocument( overflow-y: hidden; word-wrap: break-word; padding-bottom: 4px; + /* Contain the first child's top margin. Without this it collapses through +
, shifting the box down while body.scrollHeight stays short — so + the height we hand the iframe cuts the last line off. */ + display: flow-root; } body > *:last-child { margin-bottom: 0; } img { max-width: 100%; height: auto; } diff --git a/apps/x/apps/renderer/src/lib/email-quotes.test.ts b/apps/x/apps/renderer/src/lib/email-quotes.test.ts index 0caf540b..6b29a668 100644 --- a/apps/x/apps/renderer/src/lib/email-quotes.test.ts +++ b/apps/x/apps/renderer/src/lib/email-quotes.test.ts @@ -79,6 +79,14 @@ describe('prepareEmailHtml — quote detection', () => { expect(html).toContain('.a{color:red}') }) + it('preserves attributes, which carry the email background', () => { + // Embedded in the host , the parser merges these onto it. Dropping + // the tag would strip the background off every styled newsletter. + const { html } = prepareEmailHtml('Hi
') + expect(html).toContain('bgcolor="#f4f4f4"') + expect(html).toContain('margin:0') + }) + it('ignores quoted content when deciding whether the email is styled', () => { // The table lives only in the quote, so the body should still adapt to theme. const { styled } = prepareEmailHtml( diff --git a/apps/x/apps/renderer/src/lib/email-quotes.ts b/apps/x/apps/renderer/src/lib/email-quotes.ts index 37fdd553..d69cd3f2 100644 --- a/apps/x/apps/renderer/src/lib/email-quotes.ts +++ b/apps/x/apps/renderer/src/lib/email-quotes.ts @@ -143,10 +143,12 @@ export function prepareEmailHtml(rawHtml: string): PreparedEmail { const doc = new DOMParser().parseFromString(rawHtml, 'text/html') const hasQuote = markQuotedNodes(doc) && unmarkIfNothingRemains(doc) const styled = isStyledDocument(doc) - // Emails ship