@parathantl/react-email-editor 0.1.3 → 0.1.4

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.
package/dist/index.cjs CHANGED
@@ -1792,6 +1792,7 @@ function generateMJML(template) {
1792
1792
  lines.push(" <mj-attributes>");
1793
1793
  lines.push(` <mj-all font-family="${escapeAttr(globalStyles.fontFamily)}" />`);
1794
1794
  lines.push(" </mj-attributes>");
1795
+ lines.push(" <mj-style>p, h1, h2, h3, h4, ul, ol, blockquote { margin: 0; } ul, ol { padding-left: 1.5em; }</mj-style>");
1795
1796
  if (headMetadata?.headStyles) {
1796
1797
  for (const style2 of headMetadata.headStyles) {
1797
1798
  const safe = style2.replace(/<\/?mj-/gi, "");
@@ -1912,7 +1913,7 @@ function generateTextBlock(block, indent) {
1912
1913
  "text-transform": p.textTransform && p.textTransform !== "none" ? p.textTransform : void 0,
1913
1914
  "letter-spacing": p.letterSpacing && p.letterSpacing !== "normal" ? p.letterSpacing : void 0
1914
1915
  });
1915
- const content = stripVariableChips(p.content || "");
1916
+ const content = resetBlockMargins(stripVariableChips(p.content || ""));
1916
1917
  return `${indent}<mj-text${attrs}>${content}</mj-text>`;
1917
1918
  }
1918
1919
  function generateButtonBlock(block, indent) {
@@ -2032,7 +2033,7 @@ function generateHeadingBlock(block, indent) {
2032
2033
  "letter-spacing": p.letterSpacing && p.letterSpacing !== "normal" ? p.letterSpacing : void 0,
2033
2034
  "css-class": `ee-block-heading ee-heading-${level}`
2034
2035
  });
2035
- const content = stripVariableChips(p.content || "");
2036
+ const content = resetBlockMargins(stripVariableChips(p.content || ""));
2036
2037
  return `${indent}<mj-text${attrs}><${level}>${content}</${level}></mj-text>`;
2037
2038
  }
2038
2039
  function generateCountdownBlock(block, indent) {
@@ -2119,6 +2120,15 @@ function stripVariableChips(html2) {
2119
2120
  (_match, key) => `{{ ${key} }}`
2120
2121
  );
2121
2122
  }
2123
+ function resetBlockMargins(html2) {
2124
+ return html2.replace(
2125
+ /<(p|h[1-4]|ul|ol|blockquote)(\s+style=")/gi,
2126
+ "<$1$2margin:0;"
2127
+ ).replace(
2128
+ /<(p|h[1-4]|ul|ol|blockquote)(\s*>)/gi,
2129
+ '<$1 style="margin:0"$2'
2130
+ );
2131
+ }
2122
2132
  function buildAttrs(obj) {
2123
2133
  const parts = [];
2124
2134
  for (const [key, value] of Object.entries(obj)) {
@@ -2415,7 +2425,8 @@ function parseHeadMetadata(doc3) {
2415
2425
  const styleEls = mjHead.querySelectorAll("mj-style");
2416
2426
  for (let i = 0; i < styleEls.length; i++) {
2417
2427
  const content = styleEls[i].textContent ?? "";
2418
- if (content.trim()) {
2428
+ const trimmed = content.trim();
2429
+ if (trimmed && !trimmed.startsWith("p, h1, h2, h3, h4") && trimmed !== "p { margin: 0; }") {
2419
2430
  metadata.headStyles.push(content);
2420
2431
  }
2421
2432
  }