fix(email-renderer): preserve multiline text across email formats
Quality / quality (ubuntu-latest) (push) Failing after 0s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 13:09:06 +05:30
1 parent baee958c68
commit 612b3945ac
3 files changed
+20 -4

No files matched your search

+4 -3
View File
@@ -32,6 +32,7 @@ const html = (value: unknown) =>
.replaceAll('"', """)
.replaceAll("'", "'");
const attrs = (node: BlockNode) => node.props as Record<string, unknown>;
const multilineText = (value: unknown) => html(value).replace(/\r\n?|\n/g, "<br />");
const imageDimension = (fallback: string): ValueSchema<string> => ({
kind: "string",
defaultValue: fallback,
@@ -290,11 +291,11 @@ export const textBlock = leaf(
{
emailHtml: ({ node }) =>
emailCell(
`<p style="font-family:inherit;line-height:1.5;margin:0 0 16px;white-space:pre-line;">${html(attrs(node).text)}</p>`,
`<p style="font-family:inherit;line-height:1.5;margin:0 0 16px;">${multilineText(attrs(node).text)}</p>`,
node,
),
ampEmail: ({ node }) => emailCell(`<p>${html(attrs(node).text)}</p>`, node),
mjml: ({ node }) => `<mj-text>${html(attrs(node).text)}</mj-text>`,
ampEmail: ({ node }) => emailCell(`<p>${multilineText(attrs(node).text)}</p>`, node),
mjml: ({ node }) => `<mj-text>${multilineText(attrs(node).text)}</mj-text>`,
},
({ node }) => `${String(attrs(node).text)}\n\n`,
);