@parathantl/react-email-editor 0.1.3 → 0.1.5

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)) {
@@ -2141,7 +2151,13 @@ var mjmlBrowser = null;
2141
2151
  async function loadMjmlBrowser() {
2142
2152
  if (mjmlBrowser) return mjmlBrowser;
2143
2153
  try {
2144
- mjmlBrowser = (await import("mjml-browser")).default;
2154
+ const mod = await import("mjml-browser");
2155
+ const fn = mod.default ?? mod;
2156
+ if (typeof fn === "function") {
2157
+ mjmlBrowser = fn;
2158
+ } else if (fn && typeof fn.default === "function") {
2159
+ mjmlBrowser = fn.default;
2160
+ }
2145
2161
  return mjmlBrowser;
2146
2162
  } catch {
2147
2163
  return null;
@@ -2415,7 +2431,8 @@ function parseHeadMetadata(doc3) {
2415
2431
  const styleEls = mjHead.querySelectorAll("mj-style");
2416
2432
  for (let i = 0; i < styleEls.length; i++) {
2417
2433
  const content = styleEls[i].textContent ?? "";
2418
- if (content.trim()) {
2434
+ const trimmed = content.trim();
2435
+ if (trimmed && !trimmed.startsWith("p, h1, h2, h3, h4") && trimmed !== "p { margin: 0; }") {
2419
2436
  metadata.headStyles.push(content);
2420
2437
  }
2421
2438
  }