fix(email-renderer): honor explicit heading typography
This commit is contained in:
1 parent
0a17867ae7
commit
62d1dd8bf3
4 files changed
+16
-3
No files matched your search
@@ -439,7 +439,7 @@
|
||||
},
|
||||
"packages/email-renderer": {
|
||||
"name": "@wrnexus/email-renderer",
|
||||
"version": "0.1.50",
|
||||
"version": "0.1.51",
|
||||
"dependencies": {
|
||||
"@wrnexus/blocks": "workspace:*",
|
||||
"amphtml-validator": "1.0.38",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/email-renderer",
|
||||
"version": "0.1.50",
|
||||
"version": "0.1.51",
|
||||
"type": "module",
|
||||
"description": "WRNexus block email renderers with HTML, text, AMP Email, and MJML interoperability.",
|
||||
"exports": {
|
||||
|
||||
@@ -340,7 +340,7 @@ export const headingBlock = leaf(
|
||||
{
|
||||
emailHtml: ({ node }) =>
|
||||
emailCell(
|
||||
`<h${attrs(node).level} style="font-family:inherit;margin:0 0 16px;">${renderRichText(attrs(node))}</h${attrs(node).level}>`,
|
||||
`<h${attrs(node).level} style="font-family:inherit;margin:0 0 16px;${emailStyleValue("fontSize", styleBase(node, "fontSize")) ? "font-size:inherit;line-height:1.2;" : ""}${emailStyleValue("fontWeight", styleBase(node, "fontWeight")) ? "font-weight:inherit;" : ""}">${renderRichText(attrs(node))}</h${attrs(node).level}>`,
|
||||
node,
|
||||
),
|
||||
ampEmail: ({ node }) =>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { renderEmail } from "../src/index.ts";
|
||||
|
||||
test("explicit heading sizes are not multiplied by browser heading defaults", async () => {
|
||||
for (const size of [undefined, "36px", "expression(1)"]) {
|
||||
const result = await renderEmail({schemaVersion:1,kind:"email",meta:{subject:"Typography",lang:"en"},theme:{tokens:{}},root:{id:"root",type:"layout.email-document",version:1,props:{width:"600"},styles:{},slots:{content:[{id:"heading",type:"content.heading",version:1,props:{text:"Design that works",level:"1"},styles:size?{fontSize:{base:size}}:{},slots:{}}]}}}, {amp:false,mjml:false});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) continue;
|
||||
const html=result.value.parts.html.content;
|
||||
expect(html.includes("font-size:inherit;line-height:1.2;")).toBe(size === "36px");
|
||||
expect(html).not.toContain("expression(");
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user