@lit-pigeon/parser-mjml 0.2.0 → 0.3.0
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/README.md +10 -6
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +185 -159
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,17 +27,21 @@ const mjml = `
|
|
|
27
27
|
</mjml>
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
|
-
const { document, warnings } = mjmlToDocument(mjml);
|
|
30
|
+
const { document, warnings, fonts } = mjmlToDocument(mjml);
|
|
31
31
|
// `document` is a PigeonDocument you can load into the editor.
|
|
32
32
|
// `warnings` lists unsupported tags that were skipped or approximated.
|
|
33
|
+
// `fonts` lists the `mj-font` web fonts; pass them to `documentToMjml`.
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
`mjmlToDocument` never throws. Each warning is `{ message, tag? }`, for
|
|
36
|
-
example for
|
|
37
|
-
`css-class` on elements that cannot keep it
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
example for unknown elements such as `mj-carousel` and custom components,
|
|
38
|
+
`css-class` on elements that cannot keep it, and an `mj-wrapper` whose styling
|
|
39
|
+
could only be approximated. The padding and background of an `mj-wrapper` are
|
|
40
|
+
moved onto the rows it wraps; a wrapped section with its own background, or a
|
|
41
|
+
wrapper background image over several sections, is imported with a warning.
|
|
42
|
+
Some things are changed or dropped without a warning: `mj-column` widths are
|
|
43
|
+
rounded to twelfths of the row, and inline `mj-style` and attributes the
|
|
44
|
+
document model has no field for are dropped. The full list is in
|
|
41
45
|
[Load and save](../../docs/guide/load-and-save.md#what-the-parser-does-not-keep).
|
|
42
46
|
|
|
43
47
|
The exported `ParseOptions`, `ParseResult`, and `ParseWarning` types describe
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`)),e}function m(t,n=0){if(!t)return{top:n,right:n,bottom:n,left:n};const e=t.trim().split(/\s+/).map(H);switch(e.length){case 1:return{top:e[0],right:e[0],bottom:e[0],left:e[0]};case 2:return{top:e[0],right:e[1],bottom:e[0],left:e[1]};case 3:return{top:e[0],right:e[1],bottom:e[2],left:e[1]};case 4:return{top:e[0],right:e[1],bottom:e[2],left:e[3]};default:return{top:n,right:n,bottom:n,left:n}}}function H(t){const n=parseFloat(t);return isNaN(n)?0:n}function a(t,n,e=""){return t[n]??e}function b(t,n,e=0){const o=t[n];if(o===void 0||o==="")return e;const i=parseFloat(o);return isNaN(i)?e:i}function R(t){const n={},e=t["css-class"];if(!e)return n;const o=e.replace(/(^|\s)pigeon-hide-(mobile|desktop)(?=\s|$)/g,(i,r,s)=>(n[s==="mobile"?"hideOnMobile":"hideOnDesktop"]=!0,"")).trim();return o?t["css-class"]=o:delete t["css-class"],n}function q(t,n){return{id:h.generateId(),type:"text",values:{content:n,padding:m(a(t,"padding"),10),lineHeight:a(t,"line-height","1.5"),textAlign:a(t,"align","left"),cssClass:a(t,"css-class")||void 0}}}function Y(t){const n=a(t,"width"),e=n&&parseInt(n,10)||"auto";return{id:h.generateId(),type:"image",values:{src:a(t,"src"),alt:a(t,"alt"),width:e,href:a(t,"href")||void 0,padding:m(a(t,"padding"),10),alignment:a(t,"align","center"),borderRadius:b(t,"border-radius",0),cssClass:a(t,"css-class")||void 0}}}const G=/^(solid|dashed|dotted|double|groove|ridge|inset|outset)$/;function X(t){const n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return;let e,o;const i=[];for(const r of n){const s=r.toLowerCase();if(s==="none"||s==="hidden")return;e===void 0&&/^\d*\.?\d+(px)?$/.test(s)?e=parseFloat(s):o===void 0&&G.test(s)?o=s==="dashed"||s==="dotted"?s:"solid":i.push(r)}if(e!==0)return{width:e??1,style:o??"solid",color:i.join(" ")||"#000000"}}function K(t,n){const e=n.trim(),o=/^<p[\s>]/i.test(e)?e:`<p>${e}</p>`,i=X(a(t,"border"));return{id:h.generateId(),type:"button",values:{content:o,href:a(t,"href","#"),backgroundColor:a(t,"background-color","#3b82f6"),textColor:a(t,"color","#ffffff"),borderRadius:b(t,"border-radius",4),...i?{border:i}:{},padding:m(a(t,"padding"),10),innerPadding:m(a(t,"inner-padding"),12),fontSize:b(t,"font-size",16),fontWeight:a(t,"font-weight","600"),alignment:a(t,"align","center"),fullWidth:a(t,"width")==="100%",cssClass:a(t,"css-class")||void 0}}}function V(t){return{id:h.generateId(),type:"divider",values:{borderColor:a(t,"border-color","#e2e8f0"),borderWidth:b(t,"border-width",1),borderStyle:a(t,"border-style","solid"),padding:m(a(t,"padding"),10),width:a(t,"width","100%")}}}function J(t){return{id:h.generateId(),type:"spacer",values:{height:b(t,"height",20)}}}const Z=["facebook","twitter","instagram","linkedin","youtube","tiktok"];function Q(t){const n=t.toLowerCase();for(const e of Z)if(n.includes(e))return e;return"custom"}function tt(t,n){const e=n.map(o=>{const r={type:Q(a(o.attrs,"name","custom")),href:a(o.attrs,"href","#"),label:o.innerText.trim()||void 0},s=a(o.attrs,"src");return s&&(r.iconUrl=s),r});return{id:h.generateId(),type:"social",values:{icons:e,iconSize:b(t,"icon-size",32),spacing:b(t,"icon-padding",0),alignment:a(t,"align","center"),padding:m(a(t,"padding"),10)}}}function et(t){const n=t.match(/^<div(?:\s+class="lp-html((?:\s+pigeon-hide-(?:mobile|desktop))*)")?\s+style="padding:\s*([^"]*)">([\s\S]*)<\/div>$/);return n?{id:h.generateId(),type:"html",values:{content:n[3],padding:m(n[2],0),...R({"css-class":n[1]??""})}}:{id:h.generateId(),type:"html",values:{content:t,padding:m(void 0,0)}}}const nt={align:"left",border:"none",cellpadding:"0",cellspacing:"0",color:"#000000","font-family":"Ubuntu, Helvetica, Arial, sans-serif","font-size":"13px","line-height":"22px",padding:"10px 25px","table-layout":"auto",width:"100%"};function ot(t,n){const e={...nt,...t},o=e.width.endsWith("%")||e.width==="auto"?e.width:String(parseInt(e.width,10)),i=parseFloat(e.cellspacing.replace(/[^\d.]/g,"")),r=[`color:${e.color}`,`font-family:${e["font-family"]}`,`font-size:${e["font-size"]}`,`line-height:${e["line-height"]}`,`table-layout:${e["table-layout"]}`,`width:${e.width}`,`border:${e.border}`,...i>0?["border-collapse:separate"]:[]].map(c=>`${c};`).join(""),s=[];return e.align!=="left"&&s.push(`align="${y(e.align)}"`),s.push(`cellpadding="${y(e.cellpadding)}"`,`cellspacing="${y(e.cellspacing)}"`),t.role&&s.push(`role="${y(t.role)}"`),s.push(`width="${y(o)}"`,'border="0"',`style="${y(r)}"`),{id:h.generateId(),type:"html",values:{content:`<table ${s.join(" ")}>${n.trim()}</table>`,padding:m(a(e,"padding"),0)}}}function y(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function it(t,n){const e=a(t,"base-url"),o=n.map(i=>{const r={href:e+a(i.attrs,"href","#"),text:i.innerText.trim()||"Link"},s=a(i.attrs,"color");s&&(r.color=s);const c=a(i.attrs,"font-weight");c&&(r.fontWeight=c);const d=a(i.attrs,"text-decoration");d&&(r.textDecoration=d);const l=a(i.attrs,"padding");return l&&(r.padding=l),r});return{id:h.generateId(),type:"navbar",values:{links:o,hamburger:a(t,"hamburger","none"),alignment:a(t,"align","center"),padding:m(a(t,"padding"),0),linkColor:a(t,"ico-color","#000000"),linkFontSize:b(t,"font-size",14),linkPadding:a(t,"link-padding","10px 15px")}}}function I(t,n){const e=t.attrs,o=[],i=t.children;for(let r=0;r<i.length;r++){const s=rt(i[r]);if(s&&at(i[r+2])){const d=z(i[r+1],n);if(d){Object.assign(d.values,i[r+1].visibility),d.values.condition=s,o.push(d),r+=2;continue}}const c=z(i[r],n);c&&(Object.assign(c.values,i[r].visibility),o.push(c))}return{id:h.generateId(),type:"column",attributes:{backgroundColor:a(e,"background-color")||void 0,padding:m(a(e,"padding"),0),borderRadius:b(e,"border-radius",0)||void 0,verticalAlign:a(e,"vertical-align","top"),cssClass:a(e,"css-class")||void 0,...t.visibility},blocks:o}}function rt(t){var n;if(t.tag==="mj-raw")return(n=/^\s*\{\{#if\s+([^}]+?)\s*\}\}\s*$/.exec(t.text??""))==null?void 0:n[1]}function at(t){return(t==null?void 0:t.tag)==="mj-raw"&&/^\s*\{\{\/if\}\}\s*$/.test(t.text??"")}function z(t,n){switch(t.tag){case"mj-text":return q(t.attrs,t.text);case"mj-image":return Y(t.attrs);case"mj-button":return K(t.attrs,t.text);case"mj-divider":return V(t.attrs);case"mj-spacer":return J(t.attrs);case"mj-social":{const e=t.children.filter(o=>o.tag==="mj-social-element").map(o=>({attrs:o.attrs,innerText:o.text}));return tt(t.attrs,e)}case"mj-raw":return et(t.text);case"mj-table":return ot(t.attrs,t.text);case"mj-navbar":{const e=t.children.filter(o=>o.tag==="mj-navbar-link").map(o=>({attrs:o.attrs,innerText:o.text}));return it(t.attrs,e)}default:return n.push({message:`Unknown block element: ${t.tag}`,tag:t.tag}),null}}function E(t,n,e){const o=t.attrs,i=[],r=[];let s=0,c=0;for(const g of t.children)if(g.tag==="mj-column")i.push(I(g,n)),r.push(g),c++;else if(g.tag==="mj-group"){s++;for(const x of g.children)x.tag==="mj-column"&&(i.push(I(x,n)),r.push(x))}else n.push({message:`Unexpected section child: ${g.tag}`,tag:g.tag});i.length===0&&i.push({id:h.generateId(),type:"column",attributes:{padding:m(void 0,0),verticalAlign:"top"},blocks:[]});const d=r.length?ct(r,e,n):[12],l=s===1&&c===0;s>0&&!l&&n.push({message:"A section mixing mj-group with other columns was flattened: its columns will stack on mobile",tag:"mj-group"});const u=a(o,"full-width")==="full-width";return{id:h.generateId(),type:"row",attributes:{...t.visibility,backgroundColor:a(o,"background-color")||void 0,...st(o,n),padding:m(a(o,"padding"),0),fullWidth:u,cssClass:a(o,"css-class")||void 0,...l?{noStackOnMobile:!0}:{}},columns:i,columnRatios:d,locked:!1}}function st(t,n){const e=a(t,"background-url");if(!e)return{};const o=a(t,"background-repeat");return(o==="repeat-x"||o==="repeat-y")&&n.push({message:`background-repeat="${o}" became "repeat" — a row cannot repeat on one axis`,tag:"mj-section"}),{backgroundImage:e,backgroundRepeat:o==="no-repeat"?"no-repeat":"repeat",backgroundSize:a(t,"background-size")||void 0,backgroundPosition:a(t,"background-position")||void 0}}function lt(t,n){var i;const e=(i=t.attrs.width)==null?void 0:i.trim();if(!e)return;const o=parseFloat(e);if(!(isNaN(o)||o<=0))return e.endsWith("%")?o:o/n*100}function ct(t,n,e){const o=t.map(l=>lt(l,n));if(o.every(l=>l===void 0)){const l=Math.floor(12/o.length);return o.map(()=>l)}const i=o.reduce((l,p)=>l+(p??0),0);i>101&&e.push({message:`Column widths total ${Math.round(i)}% of the body width; they were scaled to fit`,tag:"mj-section"});const r=o.filter(l=>l===void 0).length,s=Math.max(0,100-i),c=o.map(l=>l??s/r),d=c.reduce((l,p)=>l+p,0);return c.map(l=>Math.max(1,Math.round(l*12/d)))}const v="Ubuntu, Helvetica, Arial, sans-serif",M={"mj-body":{width:"600px"},"mj-section":{"background-repeat":"repeat","background-size":"auto","background-position":"top center",direction:"ltr",padding:"20px 0","text-align":"center","text-padding":"4px 4px 4px 0"},"mj-wrapper":{"background-repeat":"repeat","background-size":"auto","background-position":"top center",direction:"ltr",padding:"20px 0","text-align":"center","text-padding":"4px 4px 4px 0"},"mj-column":{direction:"ltr","vertical-align":"top"},"mj-text":{align:"left",color:"#000000","font-family":v,"font-size":"13px","line-height":"1",padding:"10px 25px"},"mj-button":{align:"center","background-color":"#414141",border:"none","border-radius":"3px",color:"#ffffff","font-family":v,"font-size":"13px","font-weight":"normal","inner-padding":"10px 25px","line-height":"120%",padding:"10px 25px",target:"_blank","text-decoration":"none","text-transform":"none","vertical-align":"middle"},"mj-image":{alt:"",align:"center",border:"0",height:"auto",padding:"10px 25px",target:"_blank","font-size":"13px"},"mj-divider":{"border-color":"#000000","border-style":"solid","border-width":"4px",padding:"10px 25px",width:"100%",align:"center"},"mj-spacer":{height:"20px"},"mj-social":{align:"center","border-radius":"3px",color:"#333333","font-family":v,"font-size":"13px","icon-size":"20px","line-height":"22px",mode:"horizontal",padding:"10px 25px","text-decoration":"none"},"mj-social-element":{alt:"",align:"left","icon-position":"left",color:"#000","border-radius":"3px","font-family":v,"font-size":"13px","line-height":"1",padding:"4px","text-padding":"4px 4px 4px 0",target:"_blank","text-decoration":"none","vertical-align":"middle"},"mj-hero":{mode:"fixed-height",height:"0px","background-position":"center center",padding:"0px","background-color":"#ffffff","vertical-align":"top"},"mj-navbar":{align:"center","ico-align":"center","ico-open":"☰","ico-close":"⊗","ico-color":"#000000","ico-font-size":"30px","ico-font-family":v,"ico-text-transform":"uppercase","ico-padding":"10px","ico-text-decoration":"none","ico-line-height":"30px"},"mj-navbar-link":{color:"#000000","font-family":v,"font-size":"13px","font-weight":"normal","line-height":"22px",padding:"15px 10px",target:"_blank","text-decoration":"none","text-transform":"uppercase"},"mj-table":{align:"left",border:"none",cellpadding:"0",cellspacing:"0",color:"#000000","font-family":v,"font-size":"13px","line-height":"22px",padding:"10px 25px","table-layout":"auto",width:"100%"}},dt=v;function pt(t,n,e){return{id:h.generateId(),type:"hero",values:{backgroundUrl:a(t,"background-url"),backgroundPosition:a(t,"background-position","center center"),mode:a(t,"mode","fluid-height"),width:b(t,"width",600),height:b(t,"height",400),verticalAlign:a(t,"vertical-align","middle"),padding:m(a(t,"padding"),0),innerPadding:m(e,20),backgroundColor:a(t,"background-color","#ffffff"),content:n}}}const ut=[["font-style","font-style"],["font-weight","font-weight"],["letter-spacing","letter-spacing"],["line-height","line-height"],["text-align","align"],["text-decoration","text-decoration"],["text-transform","text-transform"],["height","height"]],gt={"line-height":"1.5",align:"left"};function _(t,n,e){const o=ut.filter(([,i])=>t[i]&&t[i]!==gt[i]).concat(!e&&t.padding?[["padding","padding"]]:[]).map(([i,r])=>`${i}:${t[r]};`).join("");return o?`<div style="${w(o)}">${n}</div>`:e?n:`<div>${n}</div>`}function ft(t,n){const e={...M["mj-button"],...t},o=e["background-color"],i=`border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${o};`,r=`display:inline-block;background:${o};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`,s=e.href?`<a href="${w(e.href)}" target="${w(e.target)}" style="${w(r)}">${n.trim()}</a>`:`<p style="${w(r)}">${n.trim()}</p>`;return`<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${w(e.align)}" style="padding:${w(e.padding)};"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;"><tr><td align="center"${o==="none"?"":` bgcolor="${w(o)}"`} role="presentation" valign="${w(e["vertical-align"])}" style="${w(i)}">${s}</td></tr></table></td></tr></table>`}function w(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function ht(t,n){const e=b(t.attrs,"width",600),o=a(t.attrs,"background-color"),i=[];let r=[],s;const c=d=>{var g;const[l,p]=r;l&&(d.attributes.condition=l);const[u]=((g=d.columns[0])==null?void 0:g.blocks)??[];return p&&(u==null?void 0:u.type)==="hero"&&(u.values.condition=p),r=[],s&&(d.attributes.repeat=s,s=void 0),d};for(const d of t.children)switch(d.tag){case"mj-raw":{const l=/\{\{#if\s+([^}]+?)\s*\}\}/.exec(d.text??"");l&&r.push(l[1].trim());const p=/^\s*\{\{#each\s+([^}]+?)\s*\}\}\s*$/.exec(d.text??"");p&&(s=p[1].trim(),r=[r[0]]);break}case"mj-section":i.push(c(E(d,n,e)));break;case"mj-hero":{const l=mt(d,n),p=pt(d.attrs,l.content,l.innerPadding);Object.assign(p.values,d.visibility);const u={id:h.generateId(),type:"column",attributes:{padding:m(void 0,0),verticalAlign:"top"},blocks:[p]},g={id:h.generateId(),type:"row",attributes:{padding:m(void 0,0),fullWidth:!1},columns:[u],columnRatios:[12],locked:!1};i.push(c(g));break}case"mj-wrapper":n.push({message:"mj-wrapper styling (padding, background-color) was dropped: the document model has no wrapper; its sections were imported unwrapped",tag:"mj-wrapper"});for(const l of d.children)l.tag==="mj-section"&&i.push(c(E(l,n,e)));break;default:n.push({message:`Unknown body child element: ${d.tag}`,tag:d.tag});break}return{width:e,backgroundColor:o,rows:i}}function mt(t,n){const[e]=t.children;if(t.children.length===1&&e.tag==="mj-text")return{content:_(e.attrs,e.text,!0),innerPadding:e.attrs.padding};const o=[];for(const i of t.children)i.tag==="mj-text"?o.push(_(i.attrs,i.text,!1)):i.tag==="mj-button"?o.push(ft(i.attrs,i.text)):n.push({message:`Unsupported mj-hero child element: ${i.tag}`,tag:i.tag});return{content:o.join("")||"<p>Hero Content</p>"}}const bt=new Set(["mj-section","mj-column","mj-text","mj-button","mj-image"]);function N(t,n,e){const{"mj-class":o="",...i}=t.attrs,r=o.split(/\s+/).filter(Boolean).reduce((c,d)=>{const l=n.classes[d]??{},p=c["css-class"]&&l["css-class"]?{"css-class":`${c["css-class"]} ${l["css-class"]}`}:{};return{...c,...l,...p}},{});t.attrs={...M[t.tag],...n.all,...n.tags[t.tag],...r,...i},t.visibility=R(t.attrs);const s=t.attrs["css-class"];s&&!bt.has(t.tag)&&e.push({message:`css-class "${s}" on <${t.tag}> was dropped`,tag:t.tag});for(const c of t.children)N(c,n,e)}const D=new Set(["address","article","aside","blockquote","center","dd","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]),B=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),xt="14px",kt="#000000";function F(t,n){if(t.tag==="mj-text"){const{color:e,"font-size":o,"font-family":i}=t.attrs,r=[];e&&e.toLowerCase()!==kt&&r.push(`color: ${e}`),o&&o!==xt&&r.push(`font-size: ${o}`),i&&i!==n&&r.push(`font-family: ${i}`),r.length>0&&(t.text=wt(t.text,`<span style="${vt(r.join("; "))}">`));return}for(const e of t.children)F(e,n)}function wt(t,n){const e=[];let o=-1,i=-1,r=!1,s=0;const c=()=>{o>=0&&r&&e.push([o,n],[i,"</span>"]),o=-1,r=!1},d=(u,g)=>{o<0&&(o=u),i=g},l=new O.Parser({onopentag(u){if(s===0&&D.has(u)){c();return}d(l.startIndex,l.endIndex+1),B.has(u)?r=!0:s++},onclosetag(u,g){if(!B.has(u)){if(s===0){D.has(u)&&c();return}s--,g||(i=l.endIndex+1)}},ontext(u){o<0&&!u.trim()||(d(l.startIndex,l.endIndex+1),u.trim()&&(r=!0))},oncomment(){o>=0&&(i=l.endIndex+1)}},{recognizeSelfClosing:!0,lowerCaseTags:!0});l.write(t),l.end(),c();let p=t;for(const[u,g]of e.reverse())p=p.slice(0,u)+g+p.slice(u);return p}function vt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function jt(t){const n={tag:"root",attrs:{},children:[],text:""},e=[n],o=new Set(["mj-text","mj-button","mj-raw","mj-preview","mj-title","mj-social-element","mj-navbar-link","mj-table"]),i=new Set(["mj-image","mj-divider","mj-spacer","mj-all","mj-class","mj-font","mj-breakpoint"]),r=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),s=new Set(["mj-text","mj-button","mj-raw"]),c=new Set(["style","script"]),d=f=>f.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),l=f=>f.replace(/&/g,"&").replace(/"/g,""");let p=null,u="",g=0,x=!1;const $=new O.Parser({onopentag(f,j){if(p){const P=s.has(p.node.tag),T=Object.entries(j).map(([W,A])=>`${W}="${P?l(A):A}"`).join(" ");u+=T?`<${f} ${T}>`:`<${f}>`,r.has(f)||g++,c.has(f)&&(x=!0);return}const k={tag:f,attrs:j,children:[],text:""};e[e.length-1].children.push(k),!i.has(f)&&(e.push(k),o.has(f)&&(p={node:k,depth:0},u="",g=0))},ontext(f){if(p){const k=s.has(p.node.tag)&&!x;u+=k?d(f):f;return}const j=e[e.length-1];j.text+=f},onclosetag(f){if(p){if(r.has(f))return;if(g>0){u+=`</${f}>`,g--,c.has(f)&&(x=!1);return}p.node.text=u,p=null,u="",g=0,e.length>1&&e[e.length-1].tag===f&&e.pop();return}i.has(f)||e.length>1&&e[e.length-1].tag===f&&e.pop()},oncomment(f){p&&(u+=`<!--${f}-->`)}},{recognizeSelfClosing:!0,lowerCaseTags:!0,lowerCaseAttributeNames:!0});return $.write(t),$.end(),n}function C(t,n){if(t.tag===n)return t;for(const e of t.children){const o=C(e,n);if(o)return o}}function yt(t,n){var j;const e=[],o=jt(t),i=C(o,"mjml");if(!i)return e.push({message:"No <mjml> root element found"}),{document:L(),warnings:e};const r=C(i,"mj-head"),s=C(i,"mj-body");let c={attributeDefaults:{all:{},tags:{},classes:{}}};if(r&&(c=U(r.children.map(k=>({tag:k.tag,attrs:k.attrs,children:k.children.map(S=>({tag:S.tag,attrs:S.attrs,children:[],text:S.text})),text:k.text})))),!s)return e.push({message:"No <mj-body> element found"}),{document:L(),warnings:e};const d=c.fontFamily??dt;N(s,c.attributeDefaults,e),F(s,d);const l=ht(s,e),p=i.attrs.lang,u=p&&p!=="und"?p:void 0,g=i.attrs.dir,x=g==="ltr"||g==="rtl"?g:void 0,$=new Date().toISOString();return{document:{version:"1.0",metadata:{name:((j=c.title)==null?void 0:j.trim())||"Imported Template",previewText:c.previewText,createdAt:$,updatedAt:$},body:{attributes:{width:l.width,backgroundColor:l.backgroundColor,fontFamily:d,contentAlignment:"center",...c.linkStyle?{linkStyle:c.linkStyle}:{},...u?{language:u}:{},...x?{direction:x}:{},css:c.css},rows:l.rows}},warnings:e}}function L(){const t=new Date().toISOString();return{version:"1.0",metadata:{name:"Imported Template",createdAt:t,updatedAt:t},body:{attributes:{width:600,backgroundColor:"#f4f4f5",fontFamily:"Arial, Helvetica, sans-serif",contentAlignment:"center"},rows:[]}}}exports.mjmlToDocument=yt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("htmlparser2"),m=require("@lit-pigeon/core");function U(t,n){const e={fonts:[],attributeDefaults:{all:{},tags:{},classes:{}}},o=[];for(const i of t)switch(i.tag){case"mj-preview":e.previewText=i.text;break;case"mj-title":e.title=i.text;break;case"mj-font":i.attrs.name&&i.attrs.href&&e.fonts.push({name:i.attrs.name,family:i.attrs.name,url:i.attrs.href});break;case"mj-attributes":for(const r of i.children){const s=e.attributeDefaults;if(r.tag==="mj-all")Object.assign(s.all,r.attrs);else if(r.tag==="mj-class"){const{name:c,...d}=r.attrs;c&&(s.classes[c]={...s.classes[c],...d})}else s.tags[r.tag]={...s.tags[r.tag],...r.attrs}}e.attributeDefaults.all["font-family"]&&(e.fontFamily=e.attributeDefaults.all["font-family"]);break;case"mj-style":{if(i.attrs.inline==="inline"||!i.text.trim())break;const r=m.generatedStyleName(i.text);r===m.LINK_STYLE_NAME?e.linkStyle=m.cssToLinkStyle(i.text):r||o.push(i.text.trim());break}}return o.length>0&&(e.css=o.join(`
|
|
2
|
+
`)),e}function b(t,n=0){if(!t)return{top:n,right:n,bottom:n,left:n};const e=t.trim().split(/\s+/).map(H);switch(e.length){case 1:return{top:e[0],right:e[0],bottom:e[0],left:e[0]};case 2:return{top:e[0],right:e[1],bottom:e[0],left:e[1]};case 3:return{top:e[0],right:e[1],bottom:e[2],left:e[1]};case 4:return{top:e[0],right:e[1],bottom:e[2],left:e[3]};default:return{top:n,right:n,bottom:n,left:n}}}function H(t){const n=parseFloat(t);return isNaN(n)?0:n}function a(t,n,e=""){return t[n]??e}function w(t,n,e=0){const o=t[n];if(o===void 0||o==="")return e;const i=parseFloat(o);return isNaN(i)?e:i}function R(t){const n={},e=t["css-class"];if(!e)return n;const o=e.replace(/(^|\s)pigeon-hide-(mobile|desktop)(?=\s|$)/g,(i,r,s)=>(n[s==="mobile"?"hideOnMobile":"hideOnDesktop"]=!0,"")).trim();return o?t["css-class"]=o:delete t["css-class"],n}function q(t,n){return{id:m.generateId(),type:"text",values:{content:n,padding:b(a(t,"padding"),10),lineHeight:a(t,"line-height","1.5"),textAlign:a(t,"align","left"),cssClass:a(t,"css-class")||void 0}}}function Y(t){const n=a(t,"width"),e=n&&parseInt(n,10)||"auto";return{id:m.generateId(),type:"image",values:{src:a(t,"src"),alt:a(t,"alt"),width:e,href:a(t,"href")||void 0,padding:b(a(t,"padding"),10),alignment:a(t,"align","center"),borderRadius:w(t,"border-radius",0),cssClass:a(t,"css-class")||void 0}}}const G=/^(solid|dashed|dotted|double|groove|ridge|inset|outset)$/;function X(t){const n=t.trim().split(/\s+/).filter(Boolean);if(!n.length)return;let e,o;const i=[];for(const r of n){const s=r.toLowerCase();if(s==="none"||s==="hidden")return;e===void 0&&/^\d*\.?\d+(px)?$/.test(s)?e=parseFloat(s):o===void 0&&G.test(s)?o=s==="dashed"||s==="dotted"?s:"solid":i.push(r)}if(e!==0)return{width:e??1,style:o??"solid",color:i.join(" ")||"#000000"}}function K(t,n){const e=n.trim(),o=/^<p[\s>]/i.test(e)?e:`<p>${e}</p>`,i=X(a(t,"border"));return{id:m.generateId(),type:"button",values:{content:o,href:a(t,"href","#"),backgroundColor:a(t,"background-color","#3b82f6"),textColor:a(t,"color","#ffffff"),borderRadius:w(t,"border-radius",4),...i?{border:i}:{},padding:b(a(t,"padding"),10),innerPadding:b(a(t,"inner-padding"),12),fontSize:w(t,"font-size",16),fontWeight:a(t,"font-weight","600"),alignment:a(t,"align","center"),fullWidth:a(t,"width")==="100%",cssClass:a(t,"css-class")||void 0}}}function V(t){return{id:m.generateId(),type:"divider",values:{borderColor:a(t,"border-color","#e2e8f0"),borderWidth:w(t,"border-width",1),borderStyle:a(t,"border-style","solid"),padding:b(a(t,"padding"),10),width:a(t,"width","100%")}}}function J(t){return{id:m.generateId(),type:"spacer",values:{height:w(t,"height",20)}}}const Z=["facebook","twitter","instagram","linkedin","youtube","tiktok"];function Q(t){const n=t.toLowerCase();if(n==="x"||n==="x-noshare")return"twitter";for(const e of Z)if(n.includes(e))return e;return"custom"}function tt(t,n){const e=n.map(o=>{const r={type:Q(a(o.attrs,"name","custom")),href:a(o.attrs,"href","#"),label:o.innerText.trim()||void 0},s=a(o.attrs,"src");return s&&(r.iconUrl=s),r});return{id:m.generateId(),type:"social",values:{icons:e,iconSize:w(t,"icon-size",32),spacing:w(t,"icon-padding",0),alignment:a(t,"align","center"),padding:b(a(t,"padding"),10)}}}function et(t){const n=t.match(/^<div(?:\s+class="lp-html((?:\s+pigeon-hide-(?:mobile|desktop))*)")?\s+style="padding:\s*([^"]*)">([\s\S]*)<\/div>$/);return n?{id:m.generateId(),type:"html",values:{content:n[3],padding:b(n[2],0),...R({"css-class":n[1]??""})}}:{id:m.generateId(),type:"html",values:{content:t,padding:b(void 0,0)}}}const nt={align:"left",border:"none",cellpadding:"0",cellspacing:"0",color:"#000000","font-family":"Ubuntu, Helvetica, Arial, sans-serif","font-size":"13px","line-height":"22px",padding:"10px 25px","table-layout":"auto",width:"100%"};function ot(t,n){const e={...nt,...t},o=e.width.endsWith("%")||e.width==="auto"?e.width:String(parseInt(e.width,10)),i=parseFloat(e.cellspacing.replace(/[^\d.]/g,"")),r=[`color:${e.color}`,`font-family:${e["font-family"]}`,`font-size:${e["font-size"]}`,`line-height:${e["line-height"]}`,`table-layout:${e["table-layout"]}`,`width:${e.width}`,`border:${e.border}`,...i>0?["border-collapse:separate"]:[]].map(c=>`${c};`).join(""),s=[];return e.align!=="left"&&s.push(`align="${$(e.align)}"`),s.push(`cellpadding="${$(e.cellpadding)}"`,`cellspacing="${$(e.cellspacing)}"`),t.role&&s.push(`role="${$(t.role)}"`),s.push(`width="${$(o)}"`,'border="0"',`style="${$(r)}"`),{id:m.generateId(),type:"html",values:{content:`<table ${s.join(" ")}>${n.trim()}</table>`,padding:b(a(e,"padding"),0)}}}function $(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function it(t,n){const e=a(t,"base-url"),o=n.map(i=>{const r={href:e+a(i.attrs,"href","#"),text:i.innerText.trim()||"Link"},s=a(i.attrs,"color");s&&(r.color=s);const c=a(i.attrs,"font-weight");c&&(r.fontWeight=c);const d=a(i.attrs,"text-decoration");d&&(r.textDecoration=d);const l=a(i.attrs,"padding");return l&&(r.padding=l),r});return{id:m.generateId(),type:"navbar",values:{links:o,hamburger:a(t,"hamburger","none"),alignment:a(t,"align","center"),padding:b(a(t,"padding"),0),linkColor:a(t,"ico-color","#000000"),linkFontSize:w(t,"font-size",14),linkPadding:a(t,"link-padding","10px 15px")}}}function I(t,n){const e=t.attrs,o=[],i=t.children;for(let r=0;r<i.length;r++){const s=rt(i[r]);if(s&&at(i[r+2])){const d=z(i[r+1],n);if(d){Object.assign(d.values,i[r+1].visibility),d.values.condition=s,o.push(d),r+=2;continue}}const c=z(i[r],n);c&&(Object.assign(c.values,i[r].visibility),o.push(c))}return{id:m.generateId(),type:"column",attributes:{backgroundColor:a(e,"background-color")||void 0,padding:b(a(e,"padding"),0),borderRadius:w(e,"border-radius",0)||void 0,verticalAlign:a(e,"vertical-align","top"),cssClass:a(e,"css-class")||void 0,...t.visibility},blocks:o}}function rt(t){var n;if(t.tag==="mj-raw")return(n=/^\s*\{\{#if\s+([^}]+?)\s*\}\}\s*$/.exec(t.text??""))==null?void 0:n[1]}function at(t){return(t==null?void 0:t.tag)==="mj-raw"&&/^\s*\{\{\/if\}\}\s*$/.test(t.text??"")}function z(t,n){switch(t.tag){case"mj-text":return q(t.attrs,t.text);case"mj-image":return Y(t.attrs);case"mj-button":return K(t.attrs,t.text);case"mj-divider":return V(t.attrs);case"mj-spacer":return J(t.attrs);case"mj-social":{const e=t.children.filter(o=>o.tag==="mj-social-element").map(o=>({attrs:o.attrs,innerText:o.text}));return tt(t.attrs,e)}case"mj-raw":return et(t.text);case"mj-table":return ot(t.attrs,t.text);case"mj-navbar":{const e=t.children.filter(o=>o.tag==="mj-navbar-link").map(o=>({attrs:o.attrs,innerText:o.text}));return it(t.attrs,e)}default:return n.push({message:`Unknown block element: ${t.tag}`,tag:t.tag}),null}}function E(t,n,e){const o=t.attrs,i=[],r=[];let s=0,c=0;for(const f of t.children)if(f.tag==="mj-column")i.push(I(f,n)),r.push(f),c++;else if(f.tag==="mj-group"){s++;for(const x of f.children)x.tag==="mj-column"&&(i.push(I(x,n)),r.push(x))}else n.push({message:`Unexpected section child: ${f.tag}`,tag:f.tag});i.length===0&&i.push({id:m.generateId(),type:"column",attributes:{padding:b(void 0,0),verticalAlign:"top"},blocks:[]});const d=r.length?ct(r,e,n):[12],l=s===1&&c===0;s>0&&!l&&n.push({message:"A section mixing mj-group with other columns was flattened: its columns will stack on mobile",tag:"mj-group"});const g=a(o,"full-width")==="full-width";return{id:m.generateId(),type:"row",attributes:{...t.visibility,backgroundColor:a(o,"background-color")||void 0,...st(o,n),padding:b(a(o,"padding"),0),fullWidth:g,cssClass:a(o,"css-class")||void 0,...l?{noStackOnMobile:!0}:{}},columns:i,columnRatios:d,locked:!1}}function st(t,n){const e=a(t,"background-url");if(!e)return{};const o=a(t,"background-repeat");return(o==="repeat-x"||o==="repeat-y")&&n.push({message:`background-repeat="${o}" became "repeat" — a row cannot repeat on one axis`,tag:"mj-section"}),{backgroundImage:e,backgroundRepeat:o==="no-repeat"?"no-repeat":"repeat",backgroundSize:a(t,"background-size")||void 0,backgroundPosition:a(t,"background-position")||void 0}}function lt(t,n){var i;const e=(i=t.attrs.width)==null?void 0:i.trim();if(!e)return;const o=parseFloat(e);if(!(isNaN(o)||o<=0))return e.endsWith("%")?o:o/n*100}function ct(t,n,e){const o=t.map(l=>lt(l,n));if(o.every(l=>l===void 0)){const l=Math.floor(12/o.length);return o.map(()=>l)}const i=o.reduce((l,u)=>l+(u??0),0);i>101&&e.push({message:`Column widths total ${Math.round(i)}% of the body width; they were scaled to fit`,tag:"mj-section"});const r=o.filter(l=>l===void 0).length,s=Math.max(0,100-i),c=o.map(l=>l??s/r),d=c.reduce((l,u)=>l+u,0);return c.map(l=>Math.max(1,Math.round(l*12/d)))}const y="Ubuntu, Helvetica, Arial, sans-serif",M={"mj-body":{width:"600px"},"mj-section":{"background-repeat":"repeat","background-size":"auto","background-position":"top center",direction:"ltr",padding:"20px 0","text-align":"center","text-padding":"4px 4px 4px 0"},"mj-wrapper":{"background-repeat":"repeat","background-size":"auto","background-position":"top center",direction:"ltr",padding:"20px 0","text-align":"center","text-padding":"4px 4px 4px 0"},"mj-column":{direction:"ltr","vertical-align":"top"},"mj-text":{align:"left",color:"#000000","font-family":y,"font-size":"13px","line-height":"1",padding:"10px 25px"},"mj-button":{align:"center","background-color":"#414141",border:"none","border-radius":"3px",color:"#ffffff","font-family":y,"font-size":"13px","font-weight":"normal","inner-padding":"10px 25px","line-height":"120%",padding:"10px 25px",target:"_blank","text-decoration":"none","text-transform":"none","vertical-align":"middle"},"mj-image":{alt:"",align:"center",border:"0",height:"auto",padding:"10px 25px",target:"_blank","font-size":"13px"},"mj-divider":{"border-color":"#000000","border-style":"solid","border-width":"4px",padding:"10px 25px",width:"100%",align:"center"},"mj-spacer":{height:"20px"},"mj-social":{align:"center","border-radius":"3px",color:"#333333","font-family":y,"font-size":"13px","icon-size":"20px","line-height":"22px",mode:"horizontal",padding:"10px 25px","text-decoration":"none"},"mj-social-element":{alt:"",align:"left","icon-position":"left",color:"#000","border-radius":"3px","font-family":y,"font-size":"13px","line-height":"1",padding:"4px","text-padding":"4px 4px 4px 0",target:"_blank","text-decoration":"none","vertical-align":"middle"},"mj-hero":{mode:"fixed-height",height:"0px","background-position":"center center",padding:"0px","background-color":"#ffffff","vertical-align":"top"},"mj-navbar":{align:"center","ico-align":"center","ico-open":"☰","ico-close":"⊗","ico-color":"#000000","ico-font-size":"30px","ico-font-family":y,"ico-text-transform":"uppercase","ico-padding":"10px","ico-text-decoration":"none","ico-line-height":"30px"},"mj-navbar-link":{color:"#000000","font-family":y,"font-size":"13px","font-weight":"normal","line-height":"22px",padding:"15px 10px",target:"_blank","text-decoration":"none","text-transform":"uppercase"},"mj-table":{align:"left",border:"none",cellpadding:"0",cellspacing:"0",color:"#000000","font-family":y,"font-size":"13px","line-height":"22px",padding:"10px 25px","table-layout":"auto",width:"100%"}},dt=y;function ut(t,n,e){return{id:m.generateId(),type:"hero",values:{backgroundUrl:a(t,"background-url"),backgroundPosition:a(t,"background-position","center center"),mode:a(t,"mode","fluid-height"),width:w(t,"width",600),height:w(t,"height",400),verticalAlign:a(t,"vertical-align","middle"),padding:b(a(t,"padding"),0),innerPadding:b(e,20),backgroundColor:a(t,"background-color","#ffffff"),content:n}}}const gt=[["font-style","font-style"],["font-weight","font-weight"],["letter-spacing","letter-spacing"],["line-height","line-height"],["text-align","align"],["text-decoration","text-decoration"],["text-transform","text-transform"],["height","height"]],pt={"line-height":"1.5",align:"left"};function _(t,n,e){const o=gt.filter(([,i])=>t[i]&&t[i]!==pt[i]).concat(!e&&t.padding?[["padding","padding"]]:[]).map(([i,r])=>`${i}:${t[r]};`).join("");return o?`<div style="${v(o)}">${n}</div>`:e?n:`<div>${n}</div>`}function ft(t,n){const e={...M["mj-button"],...t},o=e["background-color"],i=`border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${o};`,r=`display:inline-block;background:${o};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`,s=e.href?`<a href="${v(e.href)}" target="${v(e.target)}" style="${v(r)}">${n.trim()}</a>`:`<p style="${v(r)}">${n.trim()}</p>`;return`<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${v(e.align)}" style="padding:${v(e.padding)};"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;"><tr><td align="center"${o==="none"?"":` bgcolor="${v(o)}"`} role="presentation" valign="${v(e["vertical-align"])}" style="${v(i)}">${s}</td></tr></table></td></tr></table>`}function v(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function ht(t,n){const e=w(t.attrs,"width",600),o=a(t.attrs,"background-color"),i=[];let r=[],s;const c=d=>{var f;const[l,u]=r;l&&(d.attributes.condition=l);const[g]=((f=d.columns[0])==null?void 0:f.blocks)??[];return u&&(g==null?void 0:g.type)==="hero"&&(g.values.condition=u),r=[],s&&(d.attributes.repeat=s,s=void 0),d};for(const d of t.children)switch(d.tag){case"mj-raw":{const l=/\{\{#if\s+([^}]+?)\s*\}\}/.exec(d.text??"");l&&r.push(l[1].trim());const u=/^\s*\{\{#each\s+([^}]+?)\s*\}\}\s*$/.exec(d.text??"");u&&(s=u[1].trim(),r=[r[0]]);break}case"mj-section":i.push(c(E(d,n,e)));break;case"mj-hero":{const l=mt(d,n),u=ut(d.attrs,l.content,l.innerPadding);Object.assign(u.values,d.visibility);const g={id:m.generateId(),type:"column",attributes:{padding:b(void 0,0),verticalAlign:"top"},blocks:[u]},f={id:m.generateId(),type:"row",attributes:{padding:b(void 0,0),fullWidth:!1},columns:[g],columnRatios:[12],locked:!1};i.push(c(f));break}case"mj-wrapper":{const l=d.children.filter(h=>h.tag==="mj-section"),u=b(d.attrs.padding),g={};for(const h of["background-color","background-url","background-repeat","background-size","background-position","full-width"])d.attrs[h]&&(g[h]=d.attrs[h]);const f=g["background-color"]||g["background-url"]||Object.values(u).some(h=>h>0);let x=!1;for(let h=0;h<l.length;h++){const p=l[h];p.attrs["background-color"]||p.attrs["background-url"]?f&&(x=!0):p.attrs={...p.attrs,...g};const k=c(E(p,n,e));k.attributes.padding.left+=u.left,k.attributes.padding.right+=u.right,h===0&&(k.attributes.padding.top+=u.top),h===l.length-1&&(k.attributes.padding.bottom+=u.bottom),i.push(k)}x&&n.push({message:"A section with its own background covers the padding of its mj-wrapper",tag:"mj-wrapper"}),g["background-url"]&&l.length>1&&n.push({message:"An mj-wrapper background image was repeated on each of its sections",tag:"mj-wrapper"});break}default:n.push({message:`Unknown body child element: ${d.tag}`,tag:d.tag});break}return{width:e,backgroundColor:o,rows:i}}function mt(t,n){const[e]=t.children;if(t.children.length===1&&e.tag==="mj-text")return{content:_(e.attrs,e.text,!0),innerPadding:e.attrs.padding};const o=[];for(const i of t.children)i.tag==="mj-text"?o.push(_(i.attrs,i.text,!1)):i.tag==="mj-button"?o.push(ft(i.attrs,i.text)):n.push({message:`Unsupported mj-hero child element: ${i.tag}`,tag:i.tag});return{content:o.join("")||"<p>Hero Content</p>"}}const bt=new Set(["mj-section","mj-column","mj-text","mj-button","mj-image"]);function N(t,n,e){const{"mj-class":o="",...i}=t.attrs,r=o.split(/\s+/).filter(Boolean).reduce((c,d)=>{const l=n.classes[d]??{},u=c["css-class"]&&l["css-class"]?{"css-class":`${c["css-class"]} ${l["css-class"]}`}:{};return{...c,...l,...u}},{});t.attrs={...M[t.tag],...n.all,...n.tags[t.tag],...r,...i},t.visibility=R(t.attrs);const s=t.attrs["css-class"];s&&!bt.has(t.tag)&&e.push({message:`css-class "${s}" on <${t.tag}> was dropped`,tag:t.tag});for(const c of t.children)N(c,n,e)}const D=new Set(["address","article","aside","blockquote","center","dd","div","dl","dt","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]),B=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),xt="14px",kt="#000000";function F(t,n){if(t.tag==="mj-text"){const{color:e,"font-size":o,"font-family":i}=t.attrs,r=[];e&&e.toLowerCase()!==kt&&r.push(`color: ${e}`),o&&o!==xt&&r.push(`font-size: ${o}`),i&&i!==n&&r.push(`font-family: ${i}`),r.length>0&&(t.text=wt(t.text,`<span style="${jt(r.join("; "))}">`));return}for(const e of t.children)F(e,n)}function wt(t,n){const e=[];let o=-1,i=-1,r=!1,s=0;const c=()=>{o>=0&&r&&e.push([o,n],[i,"</span>"]),o=-1,r=!1},d=(g,f)=>{o<0&&(o=g),i=f},l=new L.Parser({onopentag(g){if(s===0&&D.has(g)){c();return}d(l.startIndex,l.endIndex+1),B.has(g)?r=!0:s++},onclosetag(g,f){if(!B.has(g)){if(s===0){D.has(g)&&c();return}s--,f||(i=l.endIndex+1)}},ontext(g){o<0&&!g.trim()||(d(l.startIndex,l.endIndex+1),g.trim()&&(r=!0))},oncomment(){o>=0&&(i=l.endIndex+1)}},{recognizeSelfClosing:!0,lowerCaseTags:!0});l.write(t),l.end(),c();let u=t;for(const[g,f]of e.reverse())u=u.slice(0,g)+f+u.slice(g);return u}function jt(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function vt(t){const n={tag:"root",attrs:{},children:[],text:""},e=[n],o=new Set(["mj-text","mj-button","mj-raw","mj-preview","mj-title","mj-social-element","mj-navbar-link","mj-table"]),i=new Set(["mj-image","mj-divider","mj-spacer","mj-all","mj-class","mj-font","mj-breakpoint"]),r=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),s=new Set(["mj-text","mj-button","mj-raw"]),c=new Set(["style","script"]),d=p=>p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),l=p=>p.replace(/&/g,"&").replace(/"/g,""");let u=null,g="",f=0,x=!1;const h=new L.Parser({onopentag(p,k){if(u){const P=s.has(u.node.tag),T=Object.entries(k).map(([W,A])=>`${W}="${P?l(A):A}"`).join(" ");g+=T?`<${p} ${T}>`:`<${p}>`,r.has(p)||f++,c.has(p)&&(x=!0);return}const j={tag:p,attrs:k,children:[],text:""};e[e.length-1].children.push(j),!i.has(p)&&(e.push(j),o.has(p)&&(u={node:j,depth:0},g="",f=0))},ontext(p){if(u){const j=s.has(u.node.tag)&&!x;g+=j?d(p):p;return}const k=e[e.length-1];k.text+=p},onclosetag(p){if(u){if(r.has(p))return;if(f>0){g+=`</${p}>`,f--,c.has(p)&&(x=!1);return}u.node.text=g,u=null,g="",f=0,e.length>1&&e[e.length-1].tag===p&&e.pop();return}i.has(p)||e.length>1&&e[e.length-1].tag===p&&e.pop()},oncomment(p){u&&(g+=`<!--${p}-->`)}},{recognizeSelfClosing:!0,lowerCaseTags:!0,lowerCaseAttributeNames:!0});return h.write(t),h.end(),n}function C(t,n){if(t.tag===n)return t;for(const e of t.children){const o=C(e,n);if(o)return o}}function yt(t,n){var k;const e=[],o=vt(t),i=C(o,"mjml");if(!i)return e.push({message:"No <mjml> root element found"}),{document:O(),warnings:e,fonts:[]};const r=C(i,"mj-head"),s=C(i,"mj-body");let c={fonts:[],attributeDefaults:{all:{},tags:{},classes:{}}};if(r&&(c=U(r.children.map(j=>({tag:j.tag,attrs:j.attrs,children:j.children.map(S=>({tag:S.tag,attrs:S.attrs,children:[],text:S.text})),text:j.text})))),!s)return e.push({message:"No <mj-body> element found"}),{document:O(),warnings:e,fonts:c.fonts};const d=c.fontFamily??dt;N(s,c.attributeDefaults,e),F(s,d);const l=ht(s,e),u=i.attrs.lang,g=u&&u!=="und"?u:void 0,f=i.attrs.dir,x=f==="ltr"||f==="rtl"?f:void 0,h=new Date().toISOString();return{document:{version:"1.0",metadata:{name:((k=c.title)==null?void 0:k.trim())||"Imported Template",previewText:c.previewText,createdAt:h,updatedAt:h},body:{attributes:{width:l.width,backgroundColor:l.backgroundColor,fontFamily:d,contentAlignment:"center",...c.linkStyle?{linkStyle:c.linkStyle}:{},...g?{language:g}:{},...x?{direction:x}:{},css:c.css},rows:l.rows}},warnings:e,fonts:c.fonts}}function O(){const t=new Date().toISOString();return{version:"1.0",metadata:{name:"Imported Template",createdAt:t,updatedAt:t},body:{attributes:{width:600,backgroundColor:"#f4f4f5",fontFamily:"Arial, Helvetica, sans-serif",contentAlignment:"center"},rows:[]}}}exports.mjmlToDocument=yt;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontDefinition } from '@lit-pigeon/core';
|
|
1
2
|
import { PigeonDocument } from '@lit-pigeon/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -17,6 +18,8 @@ export declare interface ParseOptions {
|
|
|
17
18
|
export declare interface ParseResult {
|
|
18
19
|
document: PigeonDocument;
|
|
19
20
|
warnings: ParseWarning[];
|
|
21
|
+
/** Web fonts read from `<mj-font>`; pass them to `documentToMjml` to write them back out. */
|
|
22
|
+
fonts: FontDefinition[];
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export declare interface ParseWarning {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Parser as
|
|
2
|
-
import { generatedStyleName as U, LINK_STYLE_NAME as H, cssToLinkStyle as Y, generateId as
|
|
1
|
+
import { Parser as O } from "htmlparser2";
|
|
2
|
+
import { generatedStyleName as U, LINK_STYLE_NAME as H, cssToLinkStyle as Y, generateId as b } from "@lit-pigeon/core";
|
|
3
3
|
function q(t, n) {
|
|
4
|
-
const e = { attributeDefaults: { all: {}, tags: {}, classes: {} } }, o = [];
|
|
4
|
+
const e = { fonts: [], attributeDefaults: { all: {}, tags: {}, classes: {} } }, o = [];
|
|
5
5
|
for (const i of t)
|
|
6
6
|
switch (i.tag) {
|
|
7
7
|
case "mj-preview":
|
|
@@ -10,6 +10,9 @@ function q(t, n) {
|
|
|
10
10
|
case "mj-title":
|
|
11
11
|
e.title = i.text;
|
|
12
12
|
break;
|
|
13
|
+
case "mj-font":
|
|
14
|
+
i.attrs.name && i.attrs.href && e.fonts.push({ name: i.attrs.name, family: i.attrs.name, url: i.attrs.href });
|
|
15
|
+
break;
|
|
13
16
|
case "mj-attributes":
|
|
14
17
|
for (const r of i.children) {
|
|
15
18
|
const s = e.attributeDefaults;
|
|
@@ -33,7 +36,7 @@ function q(t, n) {
|
|
|
33
36
|
return o.length > 0 && (e.css = o.join(`
|
|
34
37
|
`)), e;
|
|
35
38
|
}
|
|
36
|
-
function
|
|
39
|
+
function m(t, n = 0) {
|
|
37
40
|
if (!t)
|
|
38
41
|
return { top: n, right: n, bottom: n, left: n };
|
|
39
42
|
const e = t.trim().split(/\s+/).map(G);
|
|
@@ -57,13 +60,13 @@ function G(t) {
|
|
|
57
60
|
function a(t, n, e = "") {
|
|
58
61
|
return t[n] ?? e;
|
|
59
62
|
}
|
|
60
|
-
function
|
|
63
|
+
function w(t, n, e = 0) {
|
|
61
64
|
const o = t[n];
|
|
62
65
|
if (o === void 0 || o === "") return e;
|
|
63
66
|
const i = parseFloat(o);
|
|
64
67
|
return isNaN(i) ? e : i;
|
|
65
68
|
}
|
|
66
|
-
function
|
|
69
|
+
function R(t) {
|
|
67
70
|
const n = {}, e = t["css-class"];
|
|
68
71
|
if (!e) return n;
|
|
69
72
|
const o = e.replace(/(^|\s)pigeon-hide-(mobile|desktop)(?=\s|$)/g, (i, r, s) => (n[s === "mobile" ? "hideOnMobile" : "hideOnDesktop"] = !0, "")).trim();
|
|
@@ -71,11 +74,11 @@ function O(t) {
|
|
|
71
74
|
}
|
|
72
75
|
function X(t, n) {
|
|
73
76
|
return {
|
|
74
|
-
id:
|
|
77
|
+
id: b(),
|
|
75
78
|
type: "text",
|
|
76
79
|
values: {
|
|
77
80
|
content: n,
|
|
78
|
-
padding:
|
|
81
|
+
padding: m(a(t, "padding"), 10),
|
|
79
82
|
lineHeight: a(t, "line-height", "1.5"),
|
|
80
83
|
textAlign: a(t, "align", "left"),
|
|
81
84
|
cssClass: a(t, "css-class") || void 0
|
|
@@ -85,16 +88,16 @@ function X(t, n) {
|
|
|
85
88
|
function K(t) {
|
|
86
89
|
const n = a(t, "width"), e = n && parseInt(n, 10) || "auto";
|
|
87
90
|
return {
|
|
88
|
-
id:
|
|
91
|
+
id: b(),
|
|
89
92
|
type: "image",
|
|
90
93
|
values: {
|
|
91
94
|
src: a(t, "src"),
|
|
92
95
|
alt: a(t, "alt"),
|
|
93
96
|
width: e,
|
|
94
97
|
href: a(t, "href") || void 0,
|
|
95
|
-
padding:
|
|
98
|
+
padding: m(a(t, "padding"), 10),
|
|
96
99
|
alignment: a(t, "align", "center"),
|
|
97
|
-
borderRadius:
|
|
100
|
+
borderRadius: w(t, "border-radius", 0),
|
|
98
101
|
cssClass: a(t, "css-class") || void 0
|
|
99
102
|
}
|
|
100
103
|
};
|
|
@@ -120,18 +123,18 @@ function J(t) {
|
|
|
120
123
|
function Z(t, n) {
|
|
121
124
|
const e = n.trim(), o = /^<p[\s>]/i.test(e) ? e : `<p>${e}</p>`, i = J(a(t, "border"));
|
|
122
125
|
return {
|
|
123
|
-
id:
|
|
126
|
+
id: b(),
|
|
124
127
|
type: "button",
|
|
125
128
|
values: {
|
|
126
129
|
content: o,
|
|
127
130
|
href: a(t, "href", "#"),
|
|
128
131
|
backgroundColor: a(t, "background-color", "#3b82f6"),
|
|
129
132
|
textColor: a(t, "color", "#ffffff"),
|
|
130
|
-
borderRadius:
|
|
133
|
+
borderRadius: w(t, "border-radius", 4),
|
|
131
134
|
...i ? { border: i } : {},
|
|
132
|
-
padding:
|
|
133
|
-
innerPadding:
|
|
134
|
-
fontSize:
|
|
135
|
+
padding: m(a(t, "padding"), 10),
|
|
136
|
+
innerPadding: m(a(t, "inner-padding"), 12),
|
|
137
|
+
fontSize: w(t, "font-size", 16),
|
|
135
138
|
fontWeight: a(t, "font-weight", "600"),
|
|
136
139
|
alignment: a(t, "align", "center"),
|
|
137
140
|
fullWidth: a(t, "width") === "100%",
|
|
@@ -141,29 +144,30 @@ function Z(t, n) {
|
|
|
141
144
|
}
|
|
142
145
|
function Q(t) {
|
|
143
146
|
return {
|
|
144
|
-
id:
|
|
147
|
+
id: b(),
|
|
145
148
|
type: "divider",
|
|
146
149
|
values: {
|
|
147
150
|
borderColor: a(t, "border-color", "#e2e8f0"),
|
|
148
|
-
borderWidth:
|
|
151
|
+
borderWidth: w(t, "border-width", 1),
|
|
149
152
|
borderStyle: a(t, "border-style", "solid"),
|
|
150
|
-
padding:
|
|
153
|
+
padding: m(a(t, "padding"), 10),
|
|
151
154
|
width: a(t, "width", "100%")
|
|
152
155
|
}
|
|
153
156
|
};
|
|
154
157
|
}
|
|
155
158
|
function tt(t) {
|
|
156
159
|
return {
|
|
157
|
-
id:
|
|
160
|
+
id: b(),
|
|
158
161
|
type: "spacer",
|
|
159
162
|
values: {
|
|
160
|
-
height:
|
|
163
|
+
height: w(t, "height", 20)
|
|
161
164
|
}
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
167
|
const et = ["facebook", "twitter", "instagram", "linkedin", "youtube", "tiktok"];
|
|
165
168
|
function nt(t) {
|
|
166
169
|
const n = t.toLowerCase();
|
|
170
|
+
if (n === "x" || n === "x-noshare") return "twitter";
|
|
167
171
|
for (const e of et)
|
|
168
172
|
if (n.includes(e)) return e;
|
|
169
173
|
return "custom";
|
|
@@ -178,14 +182,14 @@ function ot(t, n) {
|
|
|
178
182
|
return s && (r.iconUrl = s), r;
|
|
179
183
|
});
|
|
180
184
|
return {
|
|
181
|
-
id:
|
|
185
|
+
id: b(),
|
|
182
186
|
type: "social",
|
|
183
187
|
values: {
|
|
184
188
|
icons: e,
|
|
185
|
-
iconSize:
|
|
186
|
-
spacing:
|
|
189
|
+
iconSize: w(t, "icon-size", 32),
|
|
190
|
+
spacing: w(t, "icon-padding", 0),
|
|
187
191
|
alignment: a(t, "align", "center"),
|
|
188
|
-
padding:
|
|
192
|
+
padding: m(a(t, "padding"), 10)
|
|
189
193
|
}
|
|
190
194
|
};
|
|
191
195
|
}
|
|
@@ -194,19 +198,19 @@ function it(t) {
|
|
|
194
198
|
/^<div(?:\s+class="lp-html((?:\s+pigeon-hide-(?:mobile|desktop))*)")?\s+style="padding:\s*([^"]*)">([\s\S]*)<\/div>$/
|
|
195
199
|
);
|
|
196
200
|
return n ? {
|
|
197
|
-
id:
|
|
201
|
+
id: b(),
|
|
198
202
|
type: "html",
|
|
199
203
|
values: {
|
|
200
204
|
content: n[3],
|
|
201
|
-
padding:
|
|
202
|
-
...
|
|
205
|
+
padding: m(n[2], 0),
|
|
206
|
+
...R({ "css-class": n[1] ?? "" })
|
|
203
207
|
}
|
|
204
208
|
} : {
|
|
205
|
-
id:
|
|
209
|
+
id: b(),
|
|
206
210
|
type: "html",
|
|
207
211
|
values: {
|
|
208
212
|
content: t,
|
|
209
|
-
padding:
|
|
213
|
+
padding: m(void 0, 0)
|
|
210
214
|
}
|
|
211
215
|
};
|
|
212
216
|
}
|
|
@@ -234,16 +238,16 @@ function at(t, n) {
|
|
|
234
238
|
`border:${e.border}`,
|
|
235
239
|
...i > 0 ? ["border-collapse:separate"] : []
|
|
236
240
|
].map((c) => `${c};`).join(""), s = [];
|
|
237
|
-
return e.align !== "left" && s.push(`align="${
|
|
238
|
-
id:
|
|
241
|
+
return e.align !== "left" && s.push(`align="${$(e.align)}"`), s.push(`cellpadding="${$(e.cellpadding)}"`, `cellspacing="${$(e.cellspacing)}"`), t.role && s.push(`role="${$(t.role)}"`), s.push(`width="${$(o)}"`, 'border="0"', `style="${$(r)}"`), {
|
|
242
|
+
id: b(),
|
|
239
243
|
type: "html",
|
|
240
244
|
values: {
|
|
241
245
|
content: `<table ${s.join(" ")}>${n.trim()}</table>`,
|
|
242
|
-
padding:
|
|
246
|
+
padding: m(a(e, "padding"), 0)
|
|
243
247
|
}
|
|
244
248
|
};
|
|
245
249
|
}
|
|
246
|
-
function
|
|
250
|
+
function $(t) {
|
|
247
251
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
248
252
|
}
|
|
249
253
|
function st(t, n) {
|
|
@@ -261,15 +265,15 @@ function st(t, n) {
|
|
|
261
265
|
return l && (r.padding = l), r;
|
|
262
266
|
});
|
|
263
267
|
return {
|
|
264
|
-
id:
|
|
268
|
+
id: b(),
|
|
265
269
|
type: "navbar",
|
|
266
270
|
values: {
|
|
267
271
|
links: o,
|
|
268
272
|
hamburger: a(t, "hamburger", "none"),
|
|
269
273
|
alignment: a(t, "align", "center"),
|
|
270
|
-
padding:
|
|
274
|
+
padding: m(a(t, "padding"), 0),
|
|
271
275
|
linkColor: a(t, "ico-color", "#000000"),
|
|
272
|
-
linkFontSize:
|
|
276
|
+
linkFontSize: w(t, "font-size", 14),
|
|
273
277
|
linkPadding: a(t, "link-padding", "10px 15px")
|
|
274
278
|
}
|
|
275
279
|
};
|
|
@@ -289,12 +293,12 @@ function z(t, n) {
|
|
|
289
293
|
c && (Object.assign(c.values, i[r].visibility), o.push(c));
|
|
290
294
|
}
|
|
291
295
|
return {
|
|
292
|
-
id:
|
|
296
|
+
id: b(),
|
|
293
297
|
type: "column",
|
|
294
298
|
attributes: {
|
|
295
299
|
backgroundColor: a(e, "background-color") || void 0,
|
|
296
|
-
padding:
|
|
297
|
-
borderRadius:
|
|
300
|
+
padding: m(a(e, "padding"), 0),
|
|
301
|
+
borderRadius: w(e, "border-radius", 0) || void 0,
|
|
298
302
|
verticalAlign: a(e, "vertical-align", "top"),
|
|
299
303
|
cssClass: a(e, "css-class") || void 0,
|
|
300
304
|
...t.visibility
|
|
@@ -344,42 +348,42 @@ function E(t, n) {
|
|
|
344
348
|
function _(t, n, e) {
|
|
345
349
|
const o = t.attrs, i = [], r = [];
|
|
346
350
|
let s = 0, c = 0;
|
|
347
|
-
for (const
|
|
348
|
-
if (
|
|
349
|
-
i.push(z(
|
|
350
|
-
else if (
|
|
351
|
+
for (const f of t.children)
|
|
352
|
+
if (f.tag === "mj-column")
|
|
353
|
+
i.push(z(f, n)), r.push(f), c++;
|
|
354
|
+
else if (f.tag === "mj-group") {
|
|
351
355
|
s++;
|
|
352
|
-
for (const x of
|
|
356
|
+
for (const x of f.children)
|
|
353
357
|
x.tag === "mj-column" && (i.push(z(x, n)), r.push(x));
|
|
354
358
|
} else
|
|
355
359
|
n.push({
|
|
356
|
-
message: `Unexpected section child: ${
|
|
357
|
-
tag:
|
|
360
|
+
message: `Unexpected section child: ${f.tag}`,
|
|
361
|
+
tag: f.tag
|
|
358
362
|
});
|
|
359
363
|
i.length === 0 && i.push({
|
|
360
|
-
id:
|
|
364
|
+
id: b(),
|
|
361
365
|
type: "column",
|
|
362
366
|
attributes: {
|
|
363
|
-
padding:
|
|
367
|
+
padding: m(void 0, 0),
|
|
364
368
|
verticalAlign: "top"
|
|
365
369
|
},
|
|
366
370
|
blocks: []
|
|
367
371
|
});
|
|
368
|
-
const d = r.length ?
|
|
372
|
+
const d = r.length ? pt(r, e, n) : [12], l = s === 1 && c === 0;
|
|
369
373
|
s > 0 && !l && n.push({
|
|
370
374
|
message: "A section mixing mj-group with other columns was flattened: its columns will stack on mobile",
|
|
371
375
|
tag: "mj-group"
|
|
372
376
|
});
|
|
373
|
-
const
|
|
377
|
+
const p = a(o, "full-width") === "full-width";
|
|
374
378
|
return {
|
|
375
|
-
id:
|
|
379
|
+
id: b(),
|
|
376
380
|
type: "row",
|
|
377
381
|
attributes: {
|
|
378
382
|
...t.visibility,
|
|
379
383
|
backgroundColor: a(o, "background-color") || void 0,
|
|
380
384
|
...dt(o, n),
|
|
381
|
-
padding:
|
|
382
|
-
fullWidth:
|
|
385
|
+
padding: m(a(o, "padding"), 0),
|
|
386
|
+
fullWidth: p,
|
|
383
387
|
cssClass: a(o, "css-class") || void 0,
|
|
384
388
|
...l ? { noStackOnMobile: !0 } : {}
|
|
385
389
|
},
|
|
@@ -402,7 +406,7 @@ function dt(t, n) {
|
|
|
402
406
|
backgroundPosition: a(t, "background-position") || void 0
|
|
403
407
|
};
|
|
404
408
|
}
|
|
405
|
-
function
|
|
409
|
+
function ut(t, n) {
|
|
406
410
|
var i;
|
|
407
411
|
const e = (i = t.attrs.width) == null ? void 0 : i.trim();
|
|
408
412
|
if (!e) return;
|
|
@@ -410,21 +414,21 @@ function pt(t, n) {
|
|
|
410
414
|
if (!(isNaN(o) || o <= 0))
|
|
411
415
|
return e.endsWith("%") ? o : o / n * 100;
|
|
412
416
|
}
|
|
413
|
-
function
|
|
414
|
-
const o = t.map((l) =>
|
|
417
|
+
function pt(t, n, e) {
|
|
418
|
+
const o = t.map((l) => ut(l, n));
|
|
415
419
|
if (o.every((l) => l === void 0)) {
|
|
416
420
|
const l = Math.floor(12 / o.length);
|
|
417
421
|
return o.map(() => l);
|
|
418
422
|
}
|
|
419
|
-
const i = o.reduce((l,
|
|
423
|
+
const i = o.reduce((l, u) => l + (u ?? 0), 0);
|
|
420
424
|
i > 101 && e.push({
|
|
421
425
|
message: `Column widths total ${Math.round(i)}% of the body width; they were scaled to fit`,
|
|
422
426
|
tag: "mj-section"
|
|
423
427
|
});
|
|
424
|
-
const r = o.filter((l) => l === void 0).length, s = Math.max(0, 100 - i), c = o.map((l) => l ?? s / r), d = c.reduce((l,
|
|
428
|
+
const r = o.filter((l) => l === void 0).length, s = Math.max(0, 100 - i), c = o.map((l) => l ?? s / r), d = c.reduce((l, u) => l + u, 0);
|
|
425
429
|
return c.map((l) => Math.max(1, Math.round(l * 12 / d)));
|
|
426
430
|
}
|
|
427
|
-
const
|
|
431
|
+
const y = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
428
432
|
"mj-body": { width: "600px" },
|
|
429
433
|
"mj-section": {
|
|
430
434
|
"background-repeat": "repeat",
|
|
@@ -448,7 +452,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
448
452
|
"mj-text": {
|
|
449
453
|
align: "left",
|
|
450
454
|
color: "#000000",
|
|
451
|
-
"font-family":
|
|
455
|
+
"font-family": y,
|
|
452
456
|
"font-size": "13px",
|
|
453
457
|
"line-height": "1",
|
|
454
458
|
padding: "10px 25px"
|
|
@@ -459,7 +463,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
459
463
|
border: "none",
|
|
460
464
|
"border-radius": "3px",
|
|
461
465
|
color: "#ffffff",
|
|
462
|
-
"font-family":
|
|
466
|
+
"font-family": y,
|
|
463
467
|
"font-size": "13px",
|
|
464
468
|
"font-weight": "normal",
|
|
465
469
|
"inner-padding": "10px 25px",
|
|
@@ -492,7 +496,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
492
496
|
align: "center",
|
|
493
497
|
"border-radius": "3px",
|
|
494
498
|
color: "#333333",
|
|
495
|
-
"font-family":
|
|
499
|
+
"font-family": y,
|
|
496
500
|
"font-size": "13px",
|
|
497
501
|
"icon-size": "20px",
|
|
498
502
|
"line-height": "22px",
|
|
@@ -506,7 +510,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
506
510
|
"icon-position": "left",
|
|
507
511
|
color: "#000",
|
|
508
512
|
"border-radius": "3px",
|
|
509
|
-
"font-family":
|
|
513
|
+
"font-family": y,
|
|
510
514
|
"font-size": "13px",
|
|
511
515
|
"line-height": "1",
|
|
512
516
|
padding: "4px",
|
|
@@ -530,7 +534,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
530
534
|
"ico-close": "⊗",
|
|
531
535
|
"ico-color": "#000000",
|
|
532
536
|
"ico-font-size": "30px",
|
|
533
|
-
"ico-font-family":
|
|
537
|
+
"ico-font-family": y,
|
|
534
538
|
"ico-text-transform": "uppercase",
|
|
535
539
|
"ico-padding": "10px",
|
|
536
540
|
"ico-text-decoration": "none",
|
|
@@ -538,7 +542,7 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
538
542
|
},
|
|
539
543
|
"mj-navbar-link": {
|
|
540
544
|
color: "#000000",
|
|
541
|
-
"font-family":
|
|
545
|
+
"font-family": y,
|
|
542
546
|
"font-size": "13px",
|
|
543
547
|
"font-weight": "normal",
|
|
544
548
|
"line-height": "22px",
|
|
@@ -553,27 +557,27 @@ const v = "Ubuntu, Helvetica, Arial, sans-serif", N = {
|
|
|
553
557
|
cellpadding: "0",
|
|
554
558
|
cellspacing: "0",
|
|
555
559
|
color: "#000000",
|
|
556
|
-
"font-family":
|
|
560
|
+
"font-family": y,
|
|
557
561
|
"font-size": "13px",
|
|
558
562
|
"line-height": "22px",
|
|
559
563
|
padding: "10px 25px",
|
|
560
564
|
"table-layout": "auto",
|
|
561
565
|
width: "100%"
|
|
562
566
|
}
|
|
563
|
-
}, gt =
|
|
567
|
+
}, gt = y;
|
|
564
568
|
function ft(t, n, e) {
|
|
565
569
|
return {
|
|
566
|
-
id:
|
|
570
|
+
id: b(),
|
|
567
571
|
type: "hero",
|
|
568
572
|
values: {
|
|
569
573
|
backgroundUrl: a(t, "background-url"),
|
|
570
574
|
backgroundPosition: a(t, "background-position", "center center"),
|
|
571
575
|
mode: a(t, "mode", "fluid-height"),
|
|
572
|
-
width:
|
|
573
|
-
height:
|
|
576
|
+
width: w(t, "width", 600),
|
|
577
|
+
height: w(t, "height", 400),
|
|
574
578
|
verticalAlign: a(t, "vertical-align", "middle"),
|
|
575
|
-
padding:
|
|
576
|
-
innerPadding:
|
|
579
|
+
padding: m(a(t, "padding"), 0),
|
|
580
|
+
innerPadding: m(e, 20),
|
|
577
581
|
backgroundColor: a(t, "background-color", "#ffffff"),
|
|
578
582
|
content: n
|
|
579
583
|
}
|
|
@@ -591,70 +595,90 @@ const ht = [
|
|
|
591
595
|
], mt = { "line-height": "1.5", align: "left" };
|
|
592
596
|
function D(t, n, e) {
|
|
593
597
|
const o = ht.filter(([, i]) => t[i] && t[i] !== mt[i]).concat(!e && t.padding ? [["padding", "padding"]] : []).map(([i, r]) => `${i}:${t[r]};`).join("");
|
|
594
|
-
return o ? `<div style="${
|
|
598
|
+
return o ? `<div style="${j(o)}">${n}</div>` : e ? n : `<div>${n}</div>`;
|
|
595
599
|
}
|
|
596
600
|
function bt(t, n) {
|
|
597
|
-
const e = { ...N["mj-button"], ...t }, o = e["background-color"], i = `border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${o};`, r = `display:inline-block;background:${o};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`, s = e.href ? `<a href="${
|
|
598
|
-
return `<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${
|
|
601
|
+
const e = { ...N["mj-button"], ...t }, o = e["background-color"], i = `border:${e.border};border-radius:${e["border-radius"]};cursor:auto;mso-padding-alt:${e["inner-padding"]};background:${o};`, r = `display:inline-block;background:${o};color:${e.color};font-family:${e["font-family"]};font-size:${e["font-size"]};font-weight:${e["font-weight"]};line-height:${e["line-height"]};margin:0;text-decoration:${e["text-decoration"]};text-transform:${e["text-transform"]};padding:${e["inner-padding"]};mso-padding-alt:0px;border-radius:${e["border-radius"]};`, s = e.href ? `<a href="${j(e.href)}" target="${j(e.target)}" style="${j(r)}">${n.trim()}</a>` : `<p style="${j(r)}">${n.trim()}</p>`;
|
|
602
|
+
return `<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%"><tr><td align="${j(e.align)}" style="padding:${j(e.padding)};"><table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:separate;line-height:100%;"><tr><td align="center"${o === "none" ? "" : ` bgcolor="${j(o)}"`} role="presentation" valign="${j(e["vertical-align"])}" style="${j(i)}">${s}</td></tr></table></td></tr></table>`;
|
|
599
603
|
}
|
|
600
|
-
function
|
|
604
|
+
function j(t) {
|
|
601
605
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
602
606
|
}
|
|
603
607
|
function xt(t, n) {
|
|
604
|
-
const e =
|
|
608
|
+
const e = w(t.attrs, "width", 600), o = a(t.attrs, "background-color"), i = [];
|
|
605
609
|
let r = [], s;
|
|
606
610
|
const c = (d) => {
|
|
607
|
-
var
|
|
608
|
-
const [l,
|
|
611
|
+
var f;
|
|
612
|
+
const [l, u] = r;
|
|
609
613
|
l && (d.attributes.condition = l);
|
|
610
|
-
const [
|
|
611
|
-
return
|
|
614
|
+
const [p] = ((f = d.columns[0]) == null ? void 0 : f.blocks) ?? [];
|
|
615
|
+
return u && (p == null ? void 0 : p.type) === "hero" && (p.values.condition = u), r = [], s && (d.attributes.repeat = s, s = void 0), d;
|
|
612
616
|
};
|
|
613
617
|
for (const d of t.children)
|
|
614
618
|
switch (d.tag) {
|
|
615
619
|
case "mj-raw": {
|
|
616
620
|
const l = /\{\{#if\s+([^}]+?)\s*\}\}/.exec(d.text ?? "");
|
|
617
621
|
l && r.push(l[1].trim());
|
|
618
|
-
const
|
|
619
|
-
|
|
622
|
+
const u = /^\s*\{\{#each\s+([^}]+?)\s*\}\}\s*$/.exec(d.text ?? "");
|
|
623
|
+
u && (s = u[1].trim(), r = [r[0]]);
|
|
620
624
|
break;
|
|
621
625
|
}
|
|
622
626
|
case "mj-section":
|
|
623
627
|
i.push(c(_(d, n, e)));
|
|
624
628
|
break;
|
|
625
629
|
case "mj-hero": {
|
|
626
|
-
const l = kt(d, n),
|
|
627
|
-
Object.assign(
|
|
628
|
-
const
|
|
629
|
-
id:
|
|
630
|
+
const l = kt(d, n), u = ft(d.attrs, l.content, l.innerPadding);
|
|
631
|
+
Object.assign(u.values, d.visibility);
|
|
632
|
+
const p = {
|
|
633
|
+
id: b(),
|
|
630
634
|
type: "column",
|
|
631
635
|
attributes: {
|
|
632
|
-
padding:
|
|
636
|
+
padding: m(void 0, 0),
|
|
633
637
|
verticalAlign: "top"
|
|
634
638
|
},
|
|
635
|
-
blocks: [
|
|
636
|
-
},
|
|
637
|
-
id:
|
|
639
|
+
blocks: [u]
|
|
640
|
+
}, f = {
|
|
641
|
+
id: b(),
|
|
638
642
|
type: "row",
|
|
639
643
|
attributes: {
|
|
640
|
-
padding:
|
|
644
|
+
padding: m(void 0, 0),
|
|
641
645
|
fullWidth: !1
|
|
642
646
|
},
|
|
643
|
-
columns: [
|
|
647
|
+
columns: [p],
|
|
644
648
|
columnRatios: [12],
|
|
645
649
|
locked: !1
|
|
646
650
|
};
|
|
647
|
-
i.push(c(
|
|
651
|
+
i.push(c(f));
|
|
648
652
|
break;
|
|
649
653
|
}
|
|
650
|
-
case "mj-wrapper":
|
|
651
|
-
|
|
652
|
-
|
|
654
|
+
case "mj-wrapper": {
|
|
655
|
+
const l = d.children.filter((h) => h.tag === "mj-section"), u = m(d.attrs.padding), p = {};
|
|
656
|
+
for (const h of [
|
|
657
|
+
"background-color",
|
|
658
|
+
"background-url",
|
|
659
|
+
"background-repeat",
|
|
660
|
+
"background-size",
|
|
661
|
+
"background-position",
|
|
662
|
+
"full-width"
|
|
663
|
+
])
|
|
664
|
+
d.attrs[h] && (p[h] = d.attrs[h]);
|
|
665
|
+
const f = p["background-color"] || p["background-url"] || Object.values(u).some((h) => h > 0);
|
|
666
|
+
let x = !1;
|
|
667
|
+
for (let h = 0; h < l.length; h++) {
|
|
668
|
+
const g = l[h];
|
|
669
|
+
g.attrs["background-color"] || g.attrs["background-url"] ? f && (x = !0) : g.attrs = { ...g.attrs, ...p };
|
|
670
|
+
const k = c(_(g, n, e));
|
|
671
|
+
k.attributes.padding.left += u.left, k.attributes.padding.right += u.right, h === 0 && (k.attributes.padding.top += u.top), h === l.length - 1 && (k.attributes.padding.bottom += u.bottom), i.push(k);
|
|
672
|
+
}
|
|
673
|
+
x && n.push({
|
|
674
|
+
message: "A section with its own background covers the padding of its mj-wrapper",
|
|
675
|
+
tag: "mj-wrapper"
|
|
676
|
+
}), p["background-url"] && l.length > 1 && n.push({
|
|
677
|
+
message: "An mj-wrapper background image was repeated on each of its sections",
|
|
653
678
|
tag: "mj-wrapper"
|
|
654
679
|
});
|
|
655
|
-
for (const l of d.children)
|
|
656
|
-
l.tag === "mj-section" && i.push(c(_(l, n, e)));
|
|
657
680
|
break;
|
|
681
|
+
}
|
|
658
682
|
default:
|
|
659
683
|
n.push({
|
|
660
684
|
message: `Unknown body child element: ${d.tag}`,
|
|
@@ -676,10 +700,10 @@ function kt(t, n) {
|
|
|
676
700
|
const wt = /* @__PURE__ */ new Set(["mj-section", "mj-column", "mj-text", "mj-button", "mj-image"]);
|
|
677
701
|
function F(t, n, e) {
|
|
678
702
|
const { "mj-class": o = "", ...i } = t.attrs, r = o.split(/\s+/).filter(Boolean).reduce((c, d) => {
|
|
679
|
-
const l = n.classes[d] ?? {},
|
|
680
|
-
return { ...c, ...l, ...
|
|
703
|
+
const l = n.classes[d] ?? {}, u = c["css-class"] && l["css-class"] ? { "css-class": `${c["css-class"]} ${l["css-class"]}` } : {};
|
|
704
|
+
return { ...c, ...l, ...u };
|
|
681
705
|
}, {});
|
|
682
|
-
t.attrs = { ...N[t.tag], ...n.all, ...n.tags[t.tag], ...r, ...i }, t.visibility =
|
|
706
|
+
t.attrs = { ...N[t.tag], ...n.all, ...n.tags[t.tag], ...r, ...i }, t.visibility = R(t.attrs);
|
|
683
707
|
const s = t.attrs["css-class"];
|
|
684
708
|
s && !wt.has(t.tag) && e.push({ message: `css-class "${s}" on <${t.tag}> was dropped`, tag: t.tag });
|
|
685
709
|
for (const c of t.children)
|
|
@@ -751,37 +775,37 @@ function yt(t, n) {
|
|
|
751
775
|
let o = -1, i = -1, r = !1, s = 0;
|
|
752
776
|
const c = () => {
|
|
753
777
|
o >= 0 && r && e.push([o, n], [i, "</span>"]), o = -1, r = !1;
|
|
754
|
-
}, d = (
|
|
755
|
-
o < 0 && (o =
|
|
756
|
-
}, l = new
|
|
757
|
-
onopentag(
|
|
758
|
-
if (s === 0 && I.has(
|
|
778
|
+
}, d = (p, f) => {
|
|
779
|
+
o < 0 && (o = p), i = f;
|
|
780
|
+
}, l = new O({
|
|
781
|
+
onopentag(p) {
|
|
782
|
+
if (s === 0 && I.has(p)) {
|
|
759
783
|
c();
|
|
760
784
|
return;
|
|
761
785
|
}
|
|
762
|
-
d(l.startIndex, l.endIndex + 1), B.has(
|
|
786
|
+
d(l.startIndex, l.endIndex + 1), B.has(p) ? r = !0 : s++;
|
|
763
787
|
},
|
|
764
|
-
onclosetag(
|
|
765
|
-
if (!B.has(
|
|
788
|
+
onclosetag(p, f) {
|
|
789
|
+
if (!B.has(p)) {
|
|
766
790
|
if (s === 0) {
|
|
767
|
-
I.has(
|
|
791
|
+
I.has(p) && c();
|
|
768
792
|
return;
|
|
769
793
|
}
|
|
770
|
-
s--,
|
|
794
|
+
s--, f || (i = l.endIndex + 1);
|
|
771
795
|
}
|
|
772
796
|
},
|
|
773
|
-
ontext(
|
|
774
|
-
o < 0 && !
|
|
797
|
+
ontext(p) {
|
|
798
|
+
o < 0 && !p.trim() || (d(l.startIndex, l.endIndex + 1), p.trim() && (r = !0));
|
|
775
799
|
},
|
|
776
800
|
oncomment() {
|
|
777
801
|
o >= 0 && (i = l.endIndex + 1);
|
|
778
802
|
}
|
|
779
803
|
}, { recognizeSelfClosing: !0, lowerCaseTags: !0 });
|
|
780
804
|
l.write(t), l.end(), c();
|
|
781
|
-
let
|
|
782
|
-
for (const [
|
|
783
|
-
|
|
784
|
-
return
|
|
805
|
+
let u = t;
|
|
806
|
+
for (const [p, f] of e.reverse())
|
|
807
|
+
u = u.slice(0, p) + f + u.slice(p);
|
|
808
|
+
return u;
|
|
785
809
|
}
|
|
786
810
|
function $t(t) {
|
|
787
811
|
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -818,48 +842,48 @@ function St(t) {
|
|
|
818
842
|
"source",
|
|
819
843
|
"track",
|
|
820
844
|
"wbr"
|
|
821
|
-
]), s = /* @__PURE__ */ new Set(["mj-text", "mj-button", "mj-raw"]), c = /* @__PURE__ */ new Set(["style", "script"]), d = (
|
|
822
|
-
let
|
|
823
|
-
const
|
|
824
|
-
onopentag(
|
|
825
|
-
if (
|
|
826
|
-
const W = s.has(
|
|
827
|
-
|
|
845
|
+
]), s = /* @__PURE__ */ new Set(["mj-text", "mj-button", "mj-raw"]), c = /* @__PURE__ */ new Set(["style", "script"]), d = (g) => g.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), l = (g) => g.replace(/&/g, "&").replace(/"/g, """);
|
|
846
|
+
let u = null, p = "", f = 0, x = !1;
|
|
847
|
+
const h = new O({
|
|
848
|
+
onopentag(g, k) {
|
|
849
|
+
if (u) {
|
|
850
|
+
const W = s.has(u.node.tag), T = Object.entries(k).map(([P, A]) => `${P}="${W ? l(A) : A}"`).join(" ");
|
|
851
|
+
p += T ? `<${g} ${T}>` : `<${g}>`, r.has(g) || f++, c.has(g) && (x = !0);
|
|
828
852
|
return;
|
|
829
853
|
}
|
|
830
|
-
const
|
|
831
|
-
e[e.length - 1].children.push(
|
|
854
|
+
const v = { tag: g, attrs: k, children: [], text: "" };
|
|
855
|
+
e[e.length - 1].children.push(v), !i.has(g) && (e.push(v), o.has(g) && (u = { node: v, depth: 0 }, p = "", f = 0));
|
|
832
856
|
},
|
|
833
|
-
ontext(
|
|
834
|
-
if (
|
|
835
|
-
const
|
|
836
|
-
|
|
857
|
+
ontext(g) {
|
|
858
|
+
if (u) {
|
|
859
|
+
const v = s.has(u.node.tag) && !x;
|
|
860
|
+
p += v ? d(g) : g;
|
|
837
861
|
return;
|
|
838
862
|
}
|
|
839
|
-
const
|
|
840
|
-
|
|
863
|
+
const k = e[e.length - 1];
|
|
864
|
+
k.text += g;
|
|
841
865
|
},
|
|
842
|
-
onclosetag(
|
|
843
|
-
if (
|
|
844
|
-
if (r.has(
|
|
845
|
-
if (
|
|
846
|
-
|
|
866
|
+
onclosetag(g) {
|
|
867
|
+
if (u) {
|
|
868
|
+
if (r.has(g)) return;
|
|
869
|
+
if (f > 0) {
|
|
870
|
+
p += `</${g}>`, f--, c.has(g) && (x = !1);
|
|
847
871
|
return;
|
|
848
872
|
}
|
|
849
|
-
|
|
873
|
+
u.node.text = p, u = null, p = "", f = 0, e.length > 1 && e[e.length - 1].tag === g && e.pop();
|
|
850
874
|
return;
|
|
851
875
|
}
|
|
852
|
-
i.has(
|
|
876
|
+
i.has(g) || e.length > 1 && e[e.length - 1].tag === g && e.pop();
|
|
853
877
|
},
|
|
854
|
-
oncomment(
|
|
855
|
-
|
|
878
|
+
oncomment(g) {
|
|
879
|
+
u && (p += `<!--${g}-->`);
|
|
856
880
|
}
|
|
857
881
|
}, {
|
|
858
882
|
recognizeSelfClosing: !0,
|
|
859
883
|
lowerCaseTags: !0,
|
|
860
884
|
lowerCaseAttributeNames: !0
|
|
861
885
|
});
|
|
862
|
-
return
|
|
886
|
+
return h.write(t), h.end(), n;
|
|
863
887
|
}
|
|
864
888
|
function C(t, n) {
|
|
865
889
|
if (t.tag === n) return t;
|
|
@@ -869,42 +893,44 @@ function C(t, n) {
|
|
|
869
893
|
}
|
|
870
894
|
}
|
|
871
895
|
function At(t, n) {
|
|
872
|
-
var
|
|
896
|
+
var k;
|
|
873
897
|
const e = [], o = St(t), i = C(o, "mjml");
|
|
874
898
|
if (!i)
|
|
875
899
|
return e.push({ message: "No <mjml> root element found" }), {
|
|
876
900
|
document: L(),
|
|
877
|
-
warnings: e
|
|
901
|
+
warnings: e,
|
|
902
|
+
fonts: []
|
|
878
903
|
};
|
|
879
904
|
const r = C(i, "mj-head"), s = C(i, "mj-body");
|
|
880
|
-
let c = { attributeDefaults: { all: {}, tags: {}, classes: {} } };
|
|
905
|
+
let c = { fonts: [], attributeDefaults: { all: {}, tags: {}, classes: {} } };
|
|
881
906
|
if (r && (c = q(
|
|
882
|
-
r.children.map((
|
|
883
|
-
tag:
|
|
884
|
-
attrs:
|
|
885
|
-
children:
|
|
907
|
+
r.children.map((v) => ({
|
|
908
|
+
tag: v.tag,
|
|
909
|
+
attrs: v.attrs,
|
|
910
|
+
children: v.children.map((S) => ({
|
|
886
911
|
tag: S.tag,
|
|
887
912
|
attrs: S.attrs,
|
|
888
913
|
children: [],
|
|
889
914
|
text: S.text
|
|
890
915
|
})),
|
|
891
|
-
text:
|
|
916
|
+
text: v.text
|
|
892
917
|
}))
|
|
893
918
|
)), !s)
|
|
894
919
|
return e.push({ message: "No <mj-body> element found" }), {
|
|
895
920
|
document: L(),
|
|
896
|
-
warnings: e
|
|
921
|
+
warnings: e,
|
|
922
|
+
fonts: c.fonts
|
|
897
923
|
};
|
|
898
924
|
const d = c.fontFamily ?? gt;
|
|
899
925
|
F(s, c.attributeDefaults, e), M(s, d);
|
|
900
|
-
const l = xt(s, e),
|
|
926
|
+
const l = xt(s, e), u = i.attrs.lang, p = u && u !== "und" ? u : void 0, f = i.attrs.dir, x = f === "ltr" || f === "rtl" ? f : void 0, h = (/* @__PURE__ */ new Date()).toISOString();
|
|
901
927
|
return { document: {
|
|
902
928
|
version: "1.0",
|
|
903
929
|
metadata: {
|
|
904
|
-
name: ((
|
|
930
|
+
name: ((k = c.title) == null ? void 0 : k.trim()) || "Imported Template",
|
|
905
931
|
previewText: c.previewText,
|
|
906
|
-
createdAt:
|
|
907
|
-
updatedAt:
|
|
932
|
+
createdAt: h,
|
|
933
|
+
updatedAt: h
|
|
908
934
|
},
|
|
909
935
|
body: {
|
|
910
936
|
attributes: {
|
|
@@ -913,13 +939,13 @@ function At(t, n) {
|
|
|
913
939
|
fontFamily: d,
|
|
914
940
|
contentAlignment: "center",
|
|
915
941
|
...c.linkStyle ? { linkStyle: c.linkStyle } : {},
|
|
916
|
-
...
|
|
942
|
+
...p ? { language: p } : {},
|
|
917
943
|
...x ? { direction: x } : {},
|
|
918
944
|
css: c.css
|
|
919
945
|
},
|
|
920
946
|
rows: l.rows
|
|
921
947
|
}
|
|
922
|
-
}, warnings: e };
|
|
948
|
+
}, warnings: e, fonts: c.fonts };
|
|
923
949
|
}
|
|
924
950
|
function L() {
|
|
925
951
|
const t = (/* @__PURE__ */ new Date()).toISOString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-pigeon/parser-mjml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MJML-to-PigeonDocument parser for Pigeon email editor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"vite": "^6.0.0",
|
|
29
29
|
"vite-plugin-dts": "^4.0.0",
|
|
30
30
|
"vitest": "^4.1.12",
|
|
31
|
-
"@lit-pigeon/renderer-mjml": "^0.3.
|
|
31
|
+
"@lit-pigeon/renderer-mjml": "^0.3.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|