@pagenflow/email 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export default function injectParagraphReset(html: string): string;
@@ -0,0 +1 @@
1
+ export default function isGapZero(gap?: string): boolean;
package/dist/index.cjs.js CHANGED
@@ -1792,6 +1792,15 @@ function Button({ config, devMode, bindings }) {
1792
1792
  }
1793
1793
  var Button_default = React.memo(Button, arePropsEqual);
1794
1794
 
1795
+ function isGapZero(gap) {
1796
+ if (!gap)
1797
+ return true;
1798
+ // Remove whitespace and convert to lowercase
1799
+ const trimmedGap = gap.trim().toLowerCase();
1800
+ // Check for exact zero matches (0, 0px, 0%, 0em, 0rem, etc.)
1801
+ return /^0(px|%|em|rem|ex|ch|vw|vh|vmin|vmax)?$/.test(trimmedGap);
1802
+ }
1803
+
1795
1804
  // Helper for vertical alignment
1796
1805
  const vAlignMap = {
1797
1806
  start: "top",
@@ -1926,7 +1935,7 @@ function Column({ children, config, devNode, bindings }) {
1926
1935
  ? vAlignMap[config.justifyContent]
1927
1936
  : "top", align: config.alignItems
1928
1937
  ? alignMap$2[config.alignItems]
1929
- : "left", children: child }) }), index < numChildren - 1 && (jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { style: gapSpacerStyle, children: "\u00A0" }) }))] }, `col-child-${index}`))) }) })) : (children) }) }) }) }));
1938
+ : "left", children: child }) }), index < numChildren - 1 && !isGapZero(config.gap) && (jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { style: gapSpacerStyle, children: "\u00A0" }) }))] }, `col-child-${index}`))) }) })) : (children) }) }) }) }));
1930
1939
  return (jsxRuntime.jsxs("table", { "aria-label": "Column Wrapper", role: "presentation", cellPadding: 0, cellSpacing: 0, border: 0, ...rootBindingProps(bindings), style: {
1931
1940
  position: "relative",
1932
1941
  ...outerTableStyle,
@@ -2104,13 +2113,13 @@ function Container({ children, config, bindings, devMode, devNode, }) {
2104
2113
  textAlign: "left",
2105
2114
  };
2106
2115
  if (config.gap && index < numChildren - 1) {
2107
- return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsxs("td", { className: isStacking ? "stack-td" : undefined, width: getChildWidths[index], style: childTdStyle, children: [child, isStacking && (jsxRuntime.jsx("div", { className: "mobile-gap-spacer", style: {
2116
+ return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsxs("td", { className: isStacking ? "stack-td" : undefined, width: getChildWidths[index], style: childTdStyle, children: [child, isStacking && !isGapZero(config.gap) && (jsxRuntime.jsx("div", { className: "mobile-gap-spacer", style: {
2108
2117
  display: "none",
2109
2118
  fontSize: "0",
2110
2119
  lineHeight: "0",
2111
2120
  height: config.gap,
2112
2121
  background: "transparent",
2113
- }, children: "\u00A0" }))] }, `child-${index}`), jsxRuntime.jsx("td", { className: isStacking ? "desktop-gap-column" : undefined, width: config.gap, style: gapTdStyle, children: "\u00A0" }, `gap-${index}`)] }, `ctn:${index}`));
2122
+ }, children: "\u00A0" }))] }, `child-${index}`), !isGapZero(config.gap) && (jsxRuntime.jsx("td", { className: isStacking ? "desktop-gap-column" : undefined, width: config.gap, style: gapTdStyle, children: "\u00A0" }, `gap-${index}`))] }, `ctn:${index}`));
2114
2123
  }
2115
2124
  return (jsxRuntime.jsx("td", { className: isStacking ? "stack-td" : undefined, width: getChildWidths[index], style: childTdStyle, children: child }, `child-${index}`));
2116
2125
  });
@@ -2238,7 +2247,13 @@ function Head({ children, backgroundColor = "#ffffff", title = "Email Preview",
2238
2247
  line-height: inherit !important;
2239
2248
  }
2240
2249
  body { background-color: ${backgroundColor} !important; }
2241
- p { margin: 0; }
2250
+ p {
2251
+ margin: 0;
2252
+ margin-block-start: 0px;
2253
+ margin-block-end: 0px;
2254
+ margin-inline-start: 0px;
2255
+ margin-inline-end: 0px;
2256
+ }
2242
2257
  `;
2243
2258
  const globalStyles = `
2244
2259
  @media screen and (max-width: 768px) {
@@ -2460,6 +2475,30 @@ function injectLinkStyles(html, fallback) {
2460
2475
  return result;
2461
2476
  }
2462
2477
 
2478
+ // injectParagraphReset.ts
2479
+ const P_RESET_STYLE = [
2480
+ "margin:0",
2481
+ "margin-block-start:0px",
2482
+ "margin-block-end:0px",
2483
+ "margin-inline-start:0px",
2484
+ "margin-inline-end:0px",
2485
+ ].join(";");
2486
+ function injectParagraphReset(html) {
2487
+ if (!html || !html.includes("<p"))
2488
+ return html;
2489
+ return html.replace(/<p(\s[^>]*)?>/gi, (_, attrs = "") => {
2490
+ var _a, _b;
2491
+ const existingStyle = (_b = (_a = /style\s*=\s*"([^"]*)"/i.exec(attrs)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : "";
2492
+ const mergedStyle = existingStyle
2493
+ ? `${existingStyle};${P_RESET_STYLE}`
2494
+ : P_RESET_STYLE;
2495
+ const cleanAttrs = attrs.replace(/\s*style\s*=\s*"[^"]*"/i, "").trim();
2496
+ return cleanAttrs
2497
+ ? `<p ${cleanAttrs} style="${mergedStyle}">`
2498
+ : `<p style="${mergedStyle}">`;
2499
+ });
2500
+ }
2501
+
2463
2502
  // Helper to build link href based on innerLink type
2464
2503
  function buildLinkHref$3(innerLink) {
2465
2504
  if (!innerLink || innerLink.type === "none")
@@ -2518,7 +2557,7 @@ function Heading({ config, devMode, children, bindings }) {
2518
2557
  ["msoLineHeightRule"]: "exactly",
2519
2558
  };
2520
2559
  const processedHtml = isString
2521
- ? injectLinkStyles(content, headingStyle)
2560
+ ? injectParagraphReset(injectLinkStyles(content, headingStyle))
2522
2561
  : "";
2523
2562
  // Dynamically create the Heading element
2524
2563
  const HeadingTag = level;