@edmissioncrm/editor 0.1.0 → 0.1.1
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 +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ your own backend for uploads, AI and file storage.
|
|
|
7
7
|
menu, form, timer, table, carousel)
|
|
8
8
|
- **Email** and **PDF / document** modes; export clean email-safe HTML and the design JSON
|
|
9
9
|
- Merge tags that stay intact, desktop and mobile preview, and **inbox previews** (Gmail, Apple Mail,
|
|
10
|
-
Outlook, Yahoo)
|
|
10
|
+
Outlook, Yahoo)
|
|
11
11
|
- Undo / redo, saved versions with compare and restore, custom themes
|
|
12
12
|
- AI helper in every text field: improve writing, fix grammar, shorter / longer, change tone
|
|
13
13
|
- Image library: upload, **Amazon S3** and **Google Drive**
|
package/dist/index.cjs
CHANGED
|
@@ -283,5 +283,5 @@ ${x}
|
|
|
283
283
|
}`:""},[le.body.custom_css]),fg=((w=O.appearance)==null?void 0:w.direction)??"ltr",gg=v.useMemo(()=>{var x;const $=(x=O.appearance)==null?void 0:x.customCss,ne=(Array.isArray($)?$.join(`
|
|
284
284
|
`):$??"").trim();return ne?ne.replace(/<\/?\s*(?:style|script)[^>]*>/gi,""):""},[(C=O.appearance)==null?void 0:C.customCss]),Dn=(E=O.ui)==null?void 0:E.toolbar,Nu=((Dn==null?void 0:Dn.customActions)??[]).filter(x=>ds(M,x.id)),OC=Nu.filter(x=>(x.placement??"right")==="left"),RC=Nu.filter(x=>x.placement==="center"),LC=Nu.filter(x=>(x.placement??"right")==="right"),jC=(Dn==null?void 0:Dn.undoRedo)!==!1&&ds(M,"undo_redo")&&Ei(M,"editor.undo_redo"),BC=(Dn==null?void 0:Dn.saveVersion)!==!1&&ds(M,"save_version")&&Ei(M,"editor.save_version"),PC=(Dn==null?void 0:Dn.deviceToggle)!==!1&&ds(M,"device_toggle"),FC=(Dn==null?void 0:Dn.preview)!==!1&&ds(M,"preview"),Iu=(Dn==null?void 0:Dn.exportJson)!==!1&&ds(M,"export_json")&&Ei(M,"editor.export_json"),Rl=(Dn==null?void 0:Dn.exportHtml)!==!1&&ds(M,"export_html")&&Ei(M,"editor.export_html"),$C=je==="preview"?{gridTemplateColumns:"1fr"}:as?void 0:{gridTemplateColumns:`minmax(0, 1fr) ${as?$n:_?i8:qn}px`},Du=v.useMemo(()=>w1(le),[le]),Mr=Du.body,Mu=it==="desktop"?{maxWidth:`${Mr.content_width}px`,marginLeft:Mr.content_align==="left"?"0":"auto",marginRight:Mr.content_align==="right"?"0":"auto",background:Mr.background_color,fontFamily:Mr.font_family,fontWeight:Mr.font_weight}:{maxWidth:`${Math.min(Mr.content_width,420)}px`,marginLeft:"auto",marginRight:"auto",background:Mr.background_color,fontFamily:Mr.font_family,fontWeight:Mr.font_weight},Ag=v.useMemo(()=>Jn?Dp.find(x=>x.type===Jn.type)??null:null,[Jn]),HC=v.useMemo(()=>tL(le),[le]),UC=v.useMemo(()=>[...Dp.filter(x=>Ip(M,x.type)).map(x=>({key:x.type,label:x.title,icon:x.icon,draggableId:`palette:${x.type}`,onClick:()=>wu(x.type,Ar)})),...Y.map(x=>({key:`custom:${x.id}`,label:x.label,icon:x.icon??"content",draggableId:`palette:custom:${x.id}`,onClick:()=>wu("custom",Ar,H(x))}))],[wu,M,Ar,Y]),bg=x=>{const $=x.replace("palette:","");if($.startsWith("custom:")){const ae=Y.find(Fe=>Fe.id===$.replace("custom:",""));return ae?{type:"custom",initialValues:H(ae),allowed:!0}:null}const ne=$;return{type:ne,allowed:Ip(M,ne)}};v.useEffect(()=>{const x=()=>{const $=window.innerWidth;fr($),ns(ne=>Yh(ne,$))};return x(),window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const Yo=x=>{x==="content"&&!xe.content||x==="blocks"&&!xe.blocks||x==="body"&&!xe.body||(ee(x),_&&!as&&(j(!1),ns(Zs.current)))},GC=()=>{gr(null),fe("library"),xe.blocks&&Yo("blocks")},eo=()=>{fe("selection"),xe.blocks&&Yo("blocks")},yg=()=>{gr(null),Wo(null,null),Go(null),fe("library"),Yo(xe.content?"content":xe.blocks?"blocks":"body")},WC=x=>{var $,ne,ae,Fe;if(x.kind==="block"){const{blockId:Qe,columnId:Zn}=x,on=le.body.rows.flatMap(yr=>yr.columns).find(yr=>yr.blocks.some(Un=>Un.id===Qe)),Mn=on?on.blocks.findIndex(yr=>yr.id===Qe):-1,to=(on==null?void 0:on.blocks.length)??0,Jr=Mn>=0?on==null?void 0:on.blocks[Mn]:void 0,zo=!!(Jr!=null&&Jr.locked),Eg=!!(Jr!=null&&Jr.locked||Jr!=null&&Jr.delete_locked),Lu=[];if((Jr==null?void 0:Jr.type)==="table"){const yr=tu(Jr.values.rows),Un=Su&&Su.blockId===Qe?Su:null,On=Un?nu(yr,Un.anchor.r,Un.anchor.c,Un.focus.r,Un.focus.c):null,fT=On?On.r1!==On.r2||On.c1!==On.c2:!1,no=Un&&Un.anchor.r===Un.focus.r&&Un.anchor.c===Un.focus.c?Un.anchor:null,jl=no&&(((ne=($=yr[no.r])==null?void 0:$[no.c])==null?void 0:ne.colspan)??1)*(((Fe=(ae=yr[no.r])==null?void 0:ae[no.c])==null?void 0:Fe.rowspan)??1)>1?no:null;Lu.push({label:"Merge cells",disabled:!fT,onClick:()=>{On&&(Il(Qe,{rows:Wc(Tp(C1(yr,On.r1,On.c1,On.r2,On.c2)))}),CC({blockId:Qe,anchor:{r:On.r1,c:On.c1},focus:{r:On.r1,c:On.c1}}))}},{label:"Split cell",disabled:!jl,onClick:()=>{jl&&Il(Qe,{rows:Wc(Tp(T1(yr,jl.r,jl.c)))})}})}return[{label:"Edit settings",onClick:()=>{Wo(Qe,Zn),gr(null),eo()}},...Lu.length?["divider",...Lu]:[],"divider",{label:"Cut",shortcut:"⌘X",disabled:Eg,onClick:()=>EC(Qe)},{label:"Copy",shortcut:"⌘C",onClick:()=>kC(Qe)},{label:"Paste",shortcut:"⌘V",disabled:!lg,onClick:()=>og(Zn,Qe)},{label:"Duplicate",shortcut:"⌘D",disabled:zo,onClick:()=>Dl(Qe)},"divider",{label:"Move up",disabled:zo||Mn<=0,onClick:()=>ag(Qe,"up")},{label:"Move down",disabled:zo||Mn<0||Mn>=to-1,onClick:()=>ag(Qe,"down")},"divider",{label:zo?"Unlock":"Lock",onClick:()=>ig(Qe,{locked:!zo})},"divider",{label:"Delete",danger:!0,shortcut:"Del",disabled:Eg,onClick:()=>qr("block",Qe)}]}if(x.kind==="row"){const{rowId:Qe}=x,Zn=le.body.rows.findIndex(to=>to.id===Qe),on=le.body.rows[Zn],Mn=!!(on!=null&&on.settings.layout_locked);return[{label:"Edit settings",onClick:()=>{var to;Go(((to=on==null?void 0:on.columns[0])==null?void 0:to.id)??null),gr(null),eo()}},"divider",{label:"Duplicate row",disabled:Mn,onClick:()=>eg(Qe)},{label:"Add column",disabled:Mn||((on==null?void 0:on.columns.length)??0)>=4,onClick:()=>Nl(Qe)},"divider",{label:"Move up",disabled:Mn||Zn<=0,onClick:()=>vu(Qe,"up")},{label:"Move down",disabled:Mn||Zn>=le.body.rows.length-1,onClick:()=>vu(Qe,"down")},"divider",{label:"Delete row",danger:!0,disabled:Mn,onClick:()=>qr("row",Qe)}]}const{columnId:Ue}=x,Ze=le.body.rows.find(Qe=>Qe.columns.some(Zn=>Zn.id===Ue)),Gt=!!(Ze!=null&&Ze.settings.layout_locked);return[{label:"Edit settings",onClick:()=>{Go(Ue),gr(null),eo()}},"divider",{label:"Paste here",shortcut:"⌘V",disabled:!lg,onClick:()=>og(Ue)},{label:"Add column",disabled:Gt||((Ze==null?void 0:Ze.columns.length)??0)>=4,onClick:()=>Ze&&Nl(Ze.id)},"divider",{label:"Delete column",danger:!0,disabled:Gt,onClick:()=>qr("column",Ue)}]},YC=()=>{if(!as){if(_){j(!1),ns(Zs.current);return}Zs.current=qn,j(!0)}},zC=x=>{if(as)return;x.preventDefault(),_&&(j(!1),ns(Zs.current));const $=x.clientX,ne=_?Zs.current:qn,ae=Ue=>{const Ze=Yh(ne-(Ue.clientX-$),window.innerWidth);ns(Ze),Zs.current=Ze},Fe=()=>{window.removeEventListener("pointermove",ae),window.removeEventListener("pointerup",Fe)};window.addEventListener("pointermove",ae),window.addEventListener("pointerup",Fe)},KC=x=>{const $=String(x.active.id);if($.startsWith("row:")){bt($.replace("row:","")),kt(null),oe(null),St(null),xt(null);return}if($.startsWith("palette:")){const ne=bg($);if(!ne||!ne.allowed)return;oe(ne.type),St(null),xt(null),bt(null),kt(null);return}if($.startsWith("palette-row:")){St($.replace("palette-row:","")),oe(null),xt(null),bt(null),kt(null);return}bt(null),kt(null),xt($)},QC=x=>{var $;if(!dt)return;const ne=($=x.over)!=null&&$.id?String(x.over.id):null;if(ne!=null&&ne.startsWith("row:")){kt(ne.replace("row:",""));return}kt(null)},VC=x=>{var $;if(!x.active.id||!(($=x.over)!=null&&$.id)){oe(null),St(null),xt(null),bt(null),kt(null);return}const ne=String(x.active.id),ae=String(x.over.id);if(ne.startsWith("row:")){ae.startsWith("row:")&&hC(ne.replace("row:",""),ae.replace("row:","")),oe(null),St(null),xt(null),bt(null),kt(null);return}if(ne.startsWith("palette:")){const Ze=bg(ne);if(!Ze||!Ze.allowed){oe(null),St(null),xt(null),bt(null),kt(null);return}const Gt=Ze.type,Qe=Ze.initialValues,Zn=pm(ae),on=Kh(le,ae)?nx(le,x,ae):null;if(ae==="canvas-root"){AC(Gt,Qe),oe(null),xt(null),bt(null),kt(null);return}if(Zn)ku(Gt,Zn.columnId,Zn.index,Qe);else if(on)ku(Gt,on.columnId,on.index,Qe);else if(ae.startsWith("column:")){const Mn=ae.replace("column:","");ku(Gt,Mn,rx(le,x,Mn),Qe)}oe(null),St(null),xt(null),bt(null),kt(null);return}if(ne.startsWith("palette-row:")){const Ze=ne.replace("palette-row:",""),Gt=c8(le,x,ae);uC(Ze,Gt),oe(null),St(null),xt(null),bt(null),kt(null);return}const Fe=pm(ae),Ue=Kh(le,ae)?nx(le,x,ae):null;if(Fe){Cu(ne,Fe.columnId,Fe.index),oe(null),St(null),xt(null),bt(null),kt(null);return}if(Ue){Cu(ne,Ue.columnId,Ue.index),oe(null),St(null),xt(null),bt(null),kt(null);return}if(ae.startsWith("column:")){const Ze=ae.replace("column:","");Cu(ne,Ze,rx(le,x,Ze)),oe(null),St(null),xt(null),bt(null),kt(null);return}xC(ne,ae),oe(null),St(null),xt(null),bt(null),kt(null)},qC=()=>{oe(null),St(null),xt(null),bt(null),kt(null)},JC=async()=>{const x=Qn(le,{fullDocument:!0,mergeTags:Hn,tools:W,fontImports:J});xn(x),typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(x)},ZC=async()=>{const x=ru(le,{mergeTags:Hn,tools:W,fontImports:J});return typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(x),x},XC=async()=>{const x=JSON.stringify(le,null,2);typeof navigator<"u"&&navigator.clipboard&&await navigator.clipboard.writeText(x)},eT=()=>{if(typeof document>"u")return;const x=new Blob([JSON.stringify(le,null,2)],{type:"application/json"}),$=document.createElement("a");$.href=URL.createObjectURL(x),$.download=`${(le.title||"edm-design").toLowerCase().replace(/\s+/g,"-")}.json`,$.click(),URL.revokeObjectURL($.href)},tT=async x=>{if(lt(!1),!(typeof document>"u"))try{const $=await x.run(le,{mergeTags:Hn,tools:W,fontImports:J}),ne=String(le.title||"email").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"email",ae=$ instanceof Uint8Array?$.slice().buffer:$,Fe=new Blob([ae],{type:x.mimeType}),Ue=document.createElement("a");Ue.href=URL.createObjectURL(Fe),Ue.download=`${ne}.${x.extension}`,Ue.click(),URL.revokeObjectURL(Ue.href)}catch($){window.alert($ instanceof Error?$.message:"Export failed.")}},xg=async()=>{const x=hr.trim();if(!x||pr||!(pt!=null&&pt.editDesign))return;const $={id:`msg-${Math.random().toString(36).slice(2,10)}`,role:"user",content:x},ne=ct.map(({role:ae,content:Fe})=>({role:ae,content:Fe}));Ft(ae=>[...ae,$]),Qs(""),Vs(!0);try{const ae=await pt.editDesign({message:x,design:le,history:ne,mergeTags:Hn});ae.design&&(yi("Before AI assistant edit","autosave"),bi(ae.design)),Ft(Fe=>[...Fe,{id:`msg-${Math.random().toString(36).slice(2,10)}`,role:"assistant",content:ae.summary||"Done."}])}catch(ae){Ft(Fe=>[...Fe,{id:`msg-${Math.random().toString(36).slice(2,10)}`,role:"assistant",content:ae instanceof Error?`Sorry, ${ae.message}`:"Sorry, something went wrong."}])}finally{Vs(!1)}},nT=async x=>{if(x)try{const $=await x.text(),ne=ej(JSON.parse($)),ae=tx(ne,M);if(ae.length>0){window.alert(`This design contains restricted blocks for the current plan: ${ae.join(", ")}.`);return}bi(ne)}catch($){window.alert($ instanceof Error?$.message:"Unable to import that design.")}},rT=()=>{const x=window.prompt("Template name",le.title||"My template");if(!x)return;const $=[{id:`template-${Math.random().toString(36).slice(2,10)}`,name:x,savedAt:new Date().toISOString(),design:structuredClone(le)},...Nt];vt($),Xy($),yi(`Template saved: ${x}`,"manual")},iT=async()=>{const x=window.prompt("Shared template name",le.title||"Team template");if(!x)return;const $={id:`shared-template-${Math.random().toString(36).slice(2,10)}`,name:x,savedAt:new Date().toISOString(),design:structuredClone(le),scope:"team",owner:"Team"},ne=[$,...rs];xu(ne),await(a==null?void 0:a($)),yi(`Shared template saved: ${x}`,"manual")},Ou=x=>{const $=tx(x,M);if($.length>0){window.alert(`This template contains restricted blocks for the current plan: ${$.join(", ")}.`);return}bi(x),qe(!1)},sT=x=>{const $=Nt.filter(ne=>ne.id!==x);vt($),Xy($)},oT=async x=>{xu($=>$.filter(ne=>ne.id!==x)),await(l==null?void 0:l(x))},aT=()=>{var x,$;const ne=(x=window.prompt("Merge tag key","customer_name"))==null?void 0:x.trim();if(!ne)return;const ae=ne.replace(/\s+/g,"_"),Fe=(($=window.prompt("Merge tag label",ae.replace(/_/g," ")))==null?void 0:$.trim())||ae;Tl(Ue=>{if(Ue[ae])return Ue;const Ze={...Ue,[ae]:{label:Fe,value:Cs(ae),sample:""}};return ss(Gt=>Gt.map(Qe=>({...Qe,values:{...Qe.values,[ae]:Qe.values[ae]??""}}))),Ze})},lT=(x,$)=>{Tl(ne=>{const ae=ne[x];return ae?{...ne,[x]:{...ae,...$.label!==void 0?{label:$.label}:{},...$.sample!==void 0?{sample:$.sample}:{}}}:ne}),$.sample!==void 0&&ss(ne=>ne.map((ae,Fe)=>Fe===0?{...ae,values:{...ae.values,[x]:$.sample??""}}:ae))},cT=x=>{Tl($=>{if(!$[x])return $;const ne={...$};return delete ne[x],ne}),ss($=>$.map(ne=>{const ae={...ne.values};return delete ae[x],{...ne,values:ae}}))},dT=()=>{var x;const $=(x=window.prompt("Preview context name",`Context ${is.length+1}`))==null?void 0:x.trim();if(!$)return;const ne={id:`preview-context-${Math.random().toString(36).slice(2,10)}`,name:$,values:{...Hn}};ss(ae=>[ne,...ae]),_l(ne.id)},uT=x=>{var $;if(is.length<=1)return;const ne=is.filter(ae=>ae.id!==x);ss(ne),_l((($=ne[0])==null?void 0:$.id)??"preview-context-default")},hT=(x,$)=>{ss(ne=>ne.map(ae=>ae.id===Sl?{...ae,values:{...ae.values,[x]:$}}:ae))},vg=()=>{const x=window.prompt("Version name",`Version ${Vr.length+1}`);x!==null&&yi(x.trim()||"Manual save","manual")},Ru=v.useMemo(()=>({design:le,selectedBlockId:pn,selectedColumnId:Ar}),[le,pn,Ar]),Or=Pe!=="default"?Np.find(x=>x.id===Pe):void 0,pT=Or?oj(Tt,Or.id):Tt,Ll=v.useMemo(()=>{var x;return ve?hj(le,{validators:(x=O.qa)==null?void 0:x.validators}):[]},[ve,le,(S=O.qa)==null?void 0:S.validators]),wn=Ll.reduce((x,$)=>({...x,[$.severity]:(x[$.severity]??0)+1}),{}),wg=wn.error?wn.error:wn.warning?wn.warning:null,mT=wn.error?"error":"warning",kg=c.jsxs("div",{className:`edm-shell${((k=O.appearance)==null?void 0:k.mode)==="dark"?" edm-shell--dark":""}${je==="preview"?" edm-shell--preview":""}`,style:{...$C,...DC,...MC},dir:fg,"data-edm-dir":fg,children:[gg?c.jsx("style",{children:gg}):null,mg?c.jsx("style",{children:mg}):null,c.jsxs("main",{className:"edm-workspace",children:[c.jsxs("header",{className:"edm-toolbar",role:"toolbar","aria-label":"Editor toolbar",children:[ht&&c.jsx("span",{className:"edm-readonly-badge",role:"status",children:"Read-only"}),c.jsxs("div",{className:"edm-toolbar-main",children:[c.jsxs("div",{className:"edm-toolbar-group",children:[jC&&c.jsxs(c.Fragment,{children:[c.jsx(Wn,{icon:"undo",label:te.undo,disabled:!cC,onClick:Tu}),c.jsx(Wn,{icon:"redo",label:te.redo,disabled:!dC,onClick:Ml})]}),BC&&c.jsx(Wn,{icon:"save",label:te.saveVersion,onClick:vg}),OC.map(x=>c.jsx(ch,{label:x.label,icon:x.icon,onClick:()=>x.onClick(Ru)},x.id))]}),c.jsxs("div",{className:"edm-toolbar-group edm-toolbar-group-center",children:[PC&&c.jsxs(c.Fragment,{children:[c.jsx(Wn,{icon:"desktop",label:te.desktopView,active:it==="desktop",onClick:()=>He("desktop")}),c.jsx(Wn,{icon:"mobile",label:te.mobileView,active:it==="mobile",onClick:()=>He("mobile")})]}),je==="preview"&&ce&&c.jsxs("select",{className:"edm-preview-client-select",value:Pe,onChange:x=>Nn(x.target.value),title:"Preview in an email client","aria-label":"Preview in an email client",children:[c.jsx("option",{value:"default",children:"Default render"}),Np.map(x=>c.jsx("option",{value:x.id,children:x.label},x.id))]}),RC.map(x=>c.jsx(ch,{label:x.label,icon:x.icon,onClick:()=>x.onClick(Ru)},x.id))]}),c.jsxs("div",{className:"edm-toolbar-group",children:[ve&&c.jsx(Wn,{icon:"check",label:wg?`Audit, ${wn.error??0} error${(wn.error??0)===1?"":"s"}, ${wn.warning??0} warning${(wn.warning??0)===1?"":"s"}`:"Audit, no issues",active:Xi,badge:wg,badgeTone:mT,onClick:()=>In(x=>!x)}),mt&&c.jsx(Wn,{icon:"sparkles",label:"AI assistant, describe a change",active:we,onClick:()=>ue(x=>!x)}),Ne&&c.jsx(Wn,{icon:"palette",label:"Theme & custom CSS",active:Dr,onClick:()=>es(x=>!x)}),FC&&c.jsx(Wn,{icon:je==="preview"?"edit":"preview",label:je==="preview"?te.backToEdit:te.previewDesign,active:je==="preview",onClick:()=>{if(je==="preview"){rt("edit");return}xn(Qn(le,{fullDocument:!0,mergeTags:Hn,tools:W,fontImports:J})),rt("preview")}}),Iu&&c.jsx(Wn,{icon:"json",label:te.copyDesignJson,onClick:()=>void XC()}),Rl&&c.jsx(Wn,{icon:"html",label:te.copyExportedHtml,onClick:()=>void JC()}),Rl&&c.jsx(Wn,{icon:"amp",label:"Copy AMP (interactive email)",onClick:()=>void ZC()}),Ee&&(Rl||Iu)&&c.jsxs("div",{className:"edm-export-menu",children:[c.jsx(Wn,{icon:"download",label:"Export / download",active:ts,onClick:()=>lt(x=>!x)}),ts&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"edm-export-backdrop","aria-label":"Close export menu",onClick:()=>lt(!1)}),c.jsx("ul",{className:"edm-export-list",role:"menu","aria-label":"Export formats",children:Jt.filter(x=>x.id==="json"?Iu:Rl).map(x=>c.jsx("li",{role:"none",children:c.jsxs("button",{type:"button",role:"menuitem",className:"edm-export-item",onClick:()=>void tT(x),children:[c.jsx("span",{children:x.label}),c.jsxs("span",{className:"edm-export-ext",children:[".",x.extension]})]})},x.id))})]})]}),LC.map(x=>c.jsx(ch,{label:x.label,icon:x.icon,onClick:()=>x.onClick(Ru)},x.id))]})]})]}),c.jsx("section",{className:"edm-canvas","aria-label":"Email canvas",children:je==="edit"?c.jsx("div",{className:`edm-stage edm-stage--${it}`,style:Mu,children:c.jsx(X6,{empty:le.body.rows.length===0,children:c.jsx("div",{className:"edm-canvas-stack",children:le.body.rows.length===0?c.jsxs("div",{className:"edm-empty-canvas",children:[c.jsxs("div",{className:"edm-empty-canvas-illustration","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]}),c.jsx("strong",{children:te.startBlankCanvas}),c.jsx("p",{children:te.startBlankCanvasHelp})]}):c.jsx(Hx,{items:Sp(Du.body.rows).map(x=>`row:${x.id}`),strategy:Px,children:Sp(Du.body.rows).map((x,$)=>{const ne=mr===x.id&&dt!==x.id,ae=ne&&pg!==-1?pg<$?"bottom":"top":null,Fe=Js!==null||et!=="content";return c.jsx(n8,{row:x,rowIndex:$,rowCount:le.body.rows.length,isSelected:(br==null?void 0:br.id)===x.id,isRowOver:ne,rowDropSide:ae,hasOpenConfig:Fe,selectedBlockId:pn,inlineEditingBlockId:Js,selectedColumnId:Ar,mergeTags:qs,previewMergeTags:Hn,onClearSelection:yg,onMoveRow:vu,onAddColumn:Nl,onDuplicateRow:eg,onRemoveRow:Ue=>qr("row",Ue),onSelectRow:Ue=>{var Ze;gr(null);const Gt=le.body.rows.find(Qe=>Qe.id===Ue);Go(((Ze=Gt==null?void 0:Gt.columns[0])==null?void 0:Ze.id)??null)},onSelectColumn:Ue=>{gr(null),Go(Ue)},onSelectBlock:(Ue,Ze)=>{gr(null),Wo(Ue,Ze),eo()},onRemoveColumn:Ue=>qr("column",Ue),onDuplicateBlock:Dl,onRemoveBlock:Ue=>qr("block",Ue),onUpdateBlock:Il,onEnterInlineEdit:(Ue,Ze)=>{Wo(Ue,Ze),gr(Ue),eo()},onResizeColumns:mC,onBlockContextMenu:(Ue,Ze,Gt,Qe)=>Oe({x:Gt,y:Qe,target:{kind:"block",blockId:Ue,columnId:Ze}}),onColumnContextMenu:(Ue,Ze,Gt)=>Oe({x:Ze,y:Gt,target:{kind:"column",columnId:Ue}}),onRowContextMenu:(Ue,Ze,Gt)=>Oe({x:Ze,y:Gt,target:{kind:"row",rowId:Ue}})},x.id)})})})})}):c.jsxs("div",{className:"edm-preview-shell",children:[c.jsx("div",{className:`edm-preview-stage edm-stage edm-stage--${Or!=null&&Or.mobile?"mobile":it}`,style:Or?{...Mu,maxWidth:Or.width,width:Or.width}:Mu,children:c.jsx("iframe",{className:"edm-preview-frame",title:"Edm preview",sandbox:"",srcDoc:pT})}),Or?c.jsxs("div",{className:"edm-preview-client-notes",children:[c.jsxs("span",{className:"edm-preview-client-notes-title",children:[Or.label,", how it renders"]}),c.jsx("ul",{children:Or.notes.map(x=>c.jsx("li",{children:x},x))})]}):null]})})]}),c.jsxs("aside",{className:`edm-inspector edm-sidebar-right${_&&!as?" is-collapsed":""}`,children:[c.jsx(d8,{open:pe,starterTemplates:aN,savedTemplates:Nt,sharedTemplates:rs,onClose:()=>qe(!1),onSelectStarter:x=>Ou(structuredClone(x.design)),onSelectSaved:x=>Ou(structuredClone(x.design)),onSelectShared:x=>Ou(structuredClone(x.design)),onDeleteSaved:sT,onDeleteShared:x=>void oT(x)}),!as&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"edm-sidebar-resizer",onPointerDown:zC,role:"separator","aria-label":te.expandRightPanel,"aria-orientation":"vertical"}),c.jsx("button",{type:"button",className:"edm-sidebar-collapse","aria-label":_?te.expandRightPanel:te.collapseRightPanel,title:_?te.expandRightPanel:te.collapseRightPanel,onClick:YC,children:Yi(_?"expand":"collapse")})]}),c.jsxs("div",{className:"edm-builder-panel",role:"complementary","aria-label":"Design settings panel",children:[c.jsxs("div",{className:"edm-builder-content",children:[c.jsxs("div",{className:"edm-builder-scroll",children:[c.jsxs("div",{className:"edm-panel-title",children:[c.jsx("span",{children:et==="blocks"&&z==="selection"&&Jn?(Ag==null?void 0:Ag.title)??Jn.type:et==="blocks"&&z==="selection"&&br?"Row":et==="content"?te.content:et==="blocks"?te.blocks:te.body}),c.jsx("small",{children:et==="blocks"&&z==="selection"&&Jn?"Edit the selected block":et==="blocks"&&z==="selection"&&br?"Edit row and column properties":et==="content"?Ar?te.contentPrompt:te.selectColumnFirst:et==="blocks"?te.layoutLibraryPrompt:te.bodyCanvasWidth.replace("{width}",String(le.body.content_width))})]}),et==="content"&&c.jsx("div",{className:"edm-content-panel",children:ht?c.jsx("p",{className:"edm-readonly-note",role:"note",children:"Editing is disabled for this project."}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"edm-tool-grid edm-tool-grid--content",children:UC.map(x=>c.jsx(sB,{label:x.label,icon:x.icon,onClick:x.onClick,draggableId:x.draggableId},x.key))}),(Ye||he)&&c.jsx("div",{className:"edm-content-footer",children:c.jsx("small",{children:te.draggingComponent})})]})}),et==="blocks"&&c.jsx(c.Fragment,{children:z==="selection"&&Jn?c.jsx(gB,{block:Jn,design:le,mergeTags:qs,previewMergeTags:Hn,aiAdapter:pt,aiAllowed:de,assetSources:_C,assetConnectors:NC,onImageUpload:(I=O.assets)==null?void 0:I.onImageUpload,onChange:x=>Jn&&Il(Jn.id,x),onMetaChange:x=>Jn&&ig(Jn.id,x),freeformEnabled:Ot==="page"&&((L=br==null?void 0:br.settings)==null?void 0:L.layout_mode)==="free"}):z==="selection"&&br?c.jsx(oB,{row:br,selectedColumnId:Ar,onApplyLayout:x=>pC(br.id,x),onAddColumn:()=>Nl(br.id),onRemoveColumn:x=>qr("column",x),onUpdateColumnSettings:gC,onUpdateRowSettings:x=>fC(br.id,x),builderMode:Ot}):c.jsxs("div",{className:"edm-blocks-panel",children:[c.jsxs("div",{className:"edm-layout-section",children:[c.jsx("label",{children:"Blank"}),c.jsx(Op,{preset:ms[0],onClick:()=>Xf(ms[0].id)})]}),c.jsxs("div",{className:"edm-layout-section",children:[c.jsx("label",{children:"Layouts"}),c.jsx("div",{className:"edm-layout-grid",children:ms.slice(1).map(x=>c.jsx(Op,{preset:x,onClick:()=>Xf(x.id)},x.id))})]})]})}),et==="body"&&c.jsxs("div",{className:"edm-body-panel",children:[c.jsx(nB,{design:le,mergeTags:Hn,mergeTagDefinitions:qs,aiAdapter:pt,aiAllowed:de,design_tokens:le.design_tokens,background_color:le.body.background_color,content_width:le.body.content_width,font_family:le.body.font_family,customFonts:ie,text_color:le.body.text_color,content_align:le.body.content_align,font_weight:le.body.font_weight,subject_line:le.body.subject_line,preheader_text:le.body.preheader_text,link_color:le.body.link_color,link_underline:le.body.link_underline,html_title:le.body.html_title,onChange:Eu,onChangeTokens:rg,onApplyGeneratedDesign:bi}),(R=O.ui)!=null&&R.previewData?c.jsx(Dj,{mergeTags:qs,previewContexts:is,activePreviewContextId:(Ol==null?void 0:Ol.id)??Sl,availableMergeTagKeys:HC,onSelectPreviewContext:_l,onCreatePreviewContext:dT,onDeletePreviewContext:uT,onUpdatePreviewValue:hT,onAddMergeTag:aT,onUpdateMergeTag:lT,onRemoveMergeTag:cT}):null,c.jsxs("div",{className:"edm-panel-title edm-section-title",children:[c.jsx("span",{children:"Templates"}),c.jsxs("small",{children:[Nt.length," saved locally"]})]}),c.jsx("input",{ref:Zf,type:"file",accept:"application/json",hidden:!0,onChange:x=>{var $;nT((($=x.target.files)==null?void 0:$[0])??null),x.target.value=""}}),c.jsxs("div",{className:"edm-template-actions",children:[c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>qe(!0),children:"Open Library"}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:rT,children:"Save Current"}),Ee?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>void iT(),children:"Save to Team"}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>{var x;return(x=Zf.current)==null?void 0:x.click()},children:"Import JSON"}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:eT,children:"Export JSON"})]}):null]}),c.jsxs("div",{className:"edm-panel-title edm-section-title",children:[c.jsx("span",{children:"Versions"}),c.jsxs("small",{children:[Vr.length," snapshots"]})]}),c.jsxs("div",{className:"edm-history-panel",children:[c.jsxs("div",{className:"edm-history-toolbar",children:[c.jsx("input",{className:"edm-history-search",placeholder:"Filter versions",value:_u,onChange:x=>TC(x.target.value)}),c.jsxs("div",{className:"edm-inline-actions",children:[c.jsx(Dt,{icon:"save",label:"Save snapshot now",onClick:vg}),c.jsx(Dt,{icon:"delete",label:"Clear snapshot history",onClick:wC})]})]}),c.jsxs("div",{className:"edm-history-list",children:[ug.map(x=>{var $,ne;return c.jsxs("div",{className:`edm-history-card${(($=Vr[0])==null?void 0:$.id)===x.id?" is-latest":""}`,children:[c.jsxs("div",{className:"edm-history-card-top",children:[c.jsx("strong",{children:x.label}),c.jsxs("div",{className:"edm-inline-actions",children:[c.jsx(Dt,{icon:"compare",label:`Compare ${x.label}`,onClick:()=>qf(x.id)}),c.jsx(Dt,{icon:"preview",label:`Restore ${x.label}`,onClick:()=>vC(x.id)})]})]}),c.jsxs("div",{className:"edm-history-card-meta",children:[c.jsx("span",{className:`edm-history-kind edm-history-kind--${x.kind}`,children:x.kind==="autosave"?"Auto-save":"Manual"}),((ne=Vr[0])==null?void 0:ne.id)===x.id?c.jsx("span",{className:"edm-history-kind edm-history-kind--latest",children:"Latest"}):null]}),c.jsx("small",{children:zh(x.createdAt)})]},x.id)}),ug.length===0?c.jsxs("div",{className:"edm-empty-state",children:[c.jsx("h3",{children:"No matching versions"}),c.jsx("p",{children:"Try a different filter or save a new checkpoint."})]}):null]})]})]})]}),c.jsx("div",{className:"edm-panel-footer",children:ye})]}),c.jsxs("div",{className:"edm-mode-rail",children:[xe.content&&c.jsxs("button",{type:"button",className:`edm-mode-button${et==="content"?" is-active":""}`,onClick:()=>Yo("content"),"aria-label":te.contentTools,children:[c.jsx("span",{children:Ss("content")}),c.jsx("small",{children:te.content})]}),xe.blocks&&c.jsxs("button",{type:"button",className:`edm-mode-button${et==="blocks"?" is-active":""}`,onClick:GC,"aria-label":te.blockInspector,children:[c.jsx("span",{children:Ss("blocks")}),c.jsx("small",{children:te.blocks})]}),xe.body&&c.jsxs("button",{type:"button",className:`edm-mode-button${et==="body"?" is-active":""}`,onClick:()=>Yo("body"),"aria-label":te.bodySettings,children:[c.jsx("span",{children:Ss("body")}),c.jsx("small",{children:te.body})]})]}),(B=O.branding)!=null&&B.badge?c.jsx("div",{className:"edm-branding-badge",children:O.branding.badge}):null]})]}),Z?c.jsx(AB,{x:Z.x,y:Z.y,items:WC(Z.target),onClose:()=>Oe(null)}):null,Xi&&ve?c.jsxs("aside",{className:"edm-qa-drawer",role:"complementary","aria-label":"Audit",children:[c.jsxs("div",{className:"edm-asset-header",children:[c.jsxs("div",{children:[c.jsx("h3",{children:"Audit"}),c.jsx("p",{children:Ll.length===0?"All checks passed, ready to send.":`${wn.error??0} error${(wn.error??0)===1?"":"s"}, ${wn.warning??0} warning${(wn.warning??0)===1?"":"s"}, ${wn.info??0} note${(wn.info??0)===1?"":"s"}.`})]}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>In(!1),children:"Close"})]}),Ll.length===0?c.jsx("div",{className:"edm-qa-empty",children:"✓ No issues found."}):c.jsx("ul",{className:"edm-qa-list",children:Ll.map(x=>c.jsxs("li",{className:`edm-qa-item edm-qa-item--${x.severity}${x.blockId?" is-clickable":""}`,onClick:x.blockId?()=>{Wo(x.blockId,null),gr(null),eo()}:void 0,children:[c.jsx("span",{className:`edm-qa-badge edm-qa-badge--${x.severity}`,children:x.severity==="error"?"!":x.severity==="warning"?"▲":"i"}),c.jsxs("span",{className:"edm-qa-body",children:[c.jsx("span",{className:"edm-qa-message",children:x.message}),x.hint?c.jsx("span",{className:"edm-qa-hint",children:x.hint}):null]}),x.blockId?c.jsx("span",{className:"edm-qa-jump",children:"Go →"}):null]},x.id))})]}):null,we&&mt?c.jsxs("aside",{className:"edm-assistant-drawer",role:"complementary","aria-label":"AI assistant",children:[c.jsxs("div",{className:"edm-asset-header",children:[c.jsxs("div",{children:[c.jsx("h3",{children:"AI assistant"}),c.jsx("p",{children:"Describe a change and I'll edit the design."})]}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>ue(!1),children:"Close"})]}),c.jsxs("div",{className:"edm-assistant-messages",children:[ct.length===0?c.jsxs("div",{className:"edm-assistant-empty",children:[c.jsx("p",{children:"Try:"}),c.jsxs("ul",{children:[c.jsx("li",{children:"“Add a footer with an unsubscribe link.”"}),c.jsx("li",{children:"“Change the headline to ‘Summer Sale’.”"}),c.jsx("li",{children:"“Make the button green and say ‘Shop now’.”"})]})]}):ct.map(x=>c.jsx("div",{className:`edm-assistant-msg edm-assistant-msg--${x.role}`,children:x.content},x.id)),pr?c.jsx("div",{className:"edm-assistant-msg edm-assistant-msg--assistant is-busy",children:"Working…"}):null]}),c.jsxs("form",{className:"edm-assistant-input",onSubmit:x=>{x.preventDefault(),xg()},children:[c.jsx("textarea",{value:hr,onChange:x=>Qs(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),xg())},placeholder:"Describe a change…",rows:2,"aria-label":"Message the assistant",disabled:pr}),c.jsx("button",{type:"submit",className:"edm-primary-button",disabled:pr||!hr.trim(),children:"Send"})]})]}):null,Dr&&Ne&&typeof document<"u"?Ts.createPortal(c.jsx("div",{className:"edm-asset-overlay",role:"dialog","aria-modal":"true",onClick:()=>es(!1),children:c.jsx(iB,{design:le,customFonts:ie,onUpdateBody:Eu,onUpdateTokens:rg,onApplyThemeToBlocks:bC,onClose:()=>es(!1)})}),document.body):null,ft&&typeof document<"u"?Ts.createPortal(c.jsx("div",{className:"edm-asset-overlay",role:"dialog","aria-modal":"true",onClick:()=>vn(null),children:c.jsxs("div",{className:"edm-confirm-dialog",onClick:x=>x.stopPropagation(),children:[c.jsxs("h3",{children:["Delete ",ft.kind,"?"]}),c.jsxs("p",{children:["This ",ft.kind," and everything inside it will be removed. You can undo it afterward with Ctrl/⌘+Z."]}),c.jsxs("div",{className:"edm-confirm-actions",children:[c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>vn(null),children:"Cancel"}),c.jsx("button",{type:"button",className:"edm-danger-button",onClick:yC,autoFocus:!0,children:"Delete"})]})]})}),document.body):null]});return je!=="edit"?kg:c.jsx(Xm.Provider,{value:Q,children:c.jsx(U1.Provider,{value:pt,children:c.jsxs(MS,{sensors:ht?[]:IC,collisionDetection:l8,onDragStart:KC,onDragOver:QC,onDragEnd:VC,onDragCancel:qC,children:[kg,(()=>{var x,$,ne;const ae=c.jsx(VS,{modifiers:[O8],children:Ye?c.jsx(lc,{block:Yt(Ye)}):he?c.jsx(lc,{label:((x=ms.find(Fe=>Fe.id===he))==null?void 0:x.label)??"Columns",icon:"layout",widths:($=ms.find(Fe=>Fe.id===he))==null?void 0:$.widths}):dt?c.jsx(lc,{label:"Row",icon:"layout",widths:(ne=le.body.rows.find(Fe=>Fe.id===dt))==null?void 0:ne.columns.map(Fe=>Fe.width)}):hg?c.jsx(lc,{block:hg}):null});return typeof document<"u"?Ts.createPortal(ae,document.body):ae})(),Xs?c.jsx("div",{className:"edm-asset-overlay",role:"dialog","aria-modal":"true",children:c.jsxs("div",{className:"edm-compare-dialog",children:[c.jsxs("div",{className:"edm-asset-header",children:[c.jsxs("div",{children:[c.jsx("h3",{children:"Compare Versions"}),c.jsx("p",{children:"Current design on the left, selected snapshot on the right."})]}),c.jsx("button",{type:"button",className:"edm-secondary-button",onClick:()=>qf(null),children:"Close"})]}),c.jsxs("div",{className:"edm-compare-grid",children:[c.jsxs("div",{className:"edm-compare-pane",children:[c.jsxs("div",{className:"edm-panel-title",children:[c.jsx("span",{children:"Current"}),c.jsx("small",{children:le.title||"Untitled design"})]}),c.jsx("iframe",{className:"edm-preview-frame",title:"Current design preview",sandbox:"",srcDoc:Tt})]}),c.jsxs("div",{className:"edm-compare-pane",children:[c.jsxs("div",{className:"edm-panel-title",children:[c.jsx("span",{children:Xs.label}),c.jsx("small",{children:zh(Xs.createdAt)})]}),c.jsx("iframe",{className:"edm-preview-frame",title:"Snapshot preview",sandbox:"",srcDoc:SC})]})]})]})}):null]})})})},Hf=v.forwardRef(({className:e,style:t,...n},r)=>{const i=be(u=>u.design),s=be(u=>u.exportHtml),o=be(u=>u.setDesign),a=be(u=>u.saveSnapshot),l=be(u=>u.snapshots),d=be(u=>u.restoreSnapshot);return v.useImperativeHandle(r,()=>({getDesign:()=>i,exportHtml:u=>u?Qn(i,{fullDocument:!0,mergeTags:u}):s(),exportAmp:u=>ru(i,u?{mergeTags:u}:{}),exportDocument:u=>FL(i,u?{mergeTags:u}:{}),exportZip:u=>L1(i,u?{mergeTags:u}:{}),loadDesign:u=>o(u),saveSnapshot:u=>a(u,"manual"),getSnapshots:()=>l,restoreSnapshot:d}),[i,s,d,a,o,l]),c.jsx("div",{className:e,style:{height:"100%",minHeight:0,...t},children:c.jsx(R8,{...n})})});Hf.displayName="EdmEditor";const L8=e=>(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),j8=(e,t)=>{const n=String(e).match(/\{\{\s*([^}]+?)\s*\}\}/);return(n?n[1].trim():"")||L8(t)};function ax(e){const t={},n=(r,i)=>{if(!r||typeof r!="object")return;const s=Array.isArray(r)?r:Object.values(r);for(const o of s)if(!(!o||typeof o!="object")){if(o.mergeTags){const a=o.name?i?`${i} · ${o.name}`:o.name:i;n(o.mergeTags,a);continue}if(typeof o.value=="string"&&o.value){const a=j8(o.value,o.name||"");if(!a||t[a])continue;t[a]={label:i&&o.name?`${i} · ${o.name}`:o.name||a,value:o.value,sample:typeof o.sample=="string"?o.sample:void 0}}}};return n(e,""),t}let lx=0;const Uf=e=>`${e}-${(lx++).toString(36)}-${Math.floor(lx*2654435761%1e6).toString(36)}`;let tC=600;const wr=e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=parseFloat(e);return Number.isFinite(t)?t:void 0}},nC=(e,t,n)=>Math.min(n,Math.max(t,e)),ps=e=>typeof e=="string"?e.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim():"",cx=e=>String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">"),dx=e=>String(e??"").replace(/\{\{\s*([^}]+?)\s*\}\}/g,(t,n)=>{const r=String(n).trim();return`<span data-merge-tag="${cx(r)}" data-merge-label="${cx(r)}">{{${r}}}</span>`}),go=e=>{var t;return e?typeof e=="string"?e:((t=e==null?void 0:e.values)==null?void 0:t.href)||(e==null?void 0:e.href)||"":""},B8=e=>{var n;const t=((n=e==null?void 0:e.icons)==null?void 0:n.icons)||(e==null?void 0:e.items)||[];return Array.isArray(t)?t.map(r=>({network:((r==null?void 0:r.name)||(r==null?void 0:r.network)||"link").toLowerCase(),label:(r==null?void 0:r.name)||(r==null?void 0:r.label)||"",href:go(r==null?void 0:r.url)||(r==null?void 0:r.href)||(r==null?void 0:r.url)||""})):[]},P8=e=>{var r;const t=((r=e==null?void 0:e.menu)==null?void 0:r.items)||(e==null?void 0:e.items)||[];return!Array.isArray(t)||!t.length?"<p></p>":`<p>${t.map(i=>`<a href="${go(i==null?void 0:i.link)||(i==null?void 0:i.href)||"#"}">${(i==null?void 0:i.text)||(i==null?void 0:i.label)||"Link"}</a>`).join(" ")}</p>`},ux=e=>e==null?"":typeof e=="string"?ps(e)||e:String(typeof e=="object"?e.text??e.value??e.content??e.html??"":e),F8=e=>{const t=(e==null?void 0:e.table)??e??{},n=[];let r=!1;const i=t==null?void 0:t.columns;Array.isArray(i)&&i.some(o=>(o==null?void 0:o.name)??(o==null?void 0:o.label)??(typeof o=="string"?o:null))&&(n.push(i.map(o=>ux((o==null?void 0:o.name)??(o==null?void 0:o.label)??o))),r=!0);const s=(t==null?void 0:t.rows)??(e==null?void 0:e.rows);if(Array.isArray(s))for(const o of s){const a=Array.isArray(o)?o:Array.isArray(o==null?void 0:o.cells)?o.cells:Array.isArray(o==null?void 0:o.values)?o.values:null;a&&n.push(a.map(ux))}return{rows:n,header:r}},$8=e=>{var s,o,a,l,d,u,h,p,m,g,b,A;const t=e==null?void 0:e.type,n=(e==null?void 0:e.values)||{},r=(y,w)=>({id:Uf("blk"),type:y,values:w}),i=()=>{const y=typeof n.html=="string"?n.html:typeof n.text=="string"?n.text:"";return y?r("raw-html",{html:y}):r("text",{html:`<p><em>[Unsupported block: ${t??"unknown"}]</em></p>`})};switch(t){case"text":case"paragraph":case"list":return r("text",{html:dx(typeof n.text=="string"?n.text:"<p></p>"),align:n.textAlign,color:n.color,font_size:wr(n.fontSize)});case"heading":{const y=typeof n.text=="string"?n.text:"";return/\{\{/.test(y)?r("text",{html:`<p>${dx(y)}</p>`,font_size:wr(n.fontSize)||22,font_weight:"700",align:n.textAlign,color:n.color}):r("heading",{text:ps(y)||"Heading",tag:/^h[1-6]$/.test(n.headingType)?n.headingType:"h2",align:n.textAlign,color:n.color,font_size:wr(n.fontSize)})}case"image":{const y=wr((s=n.src)==null?void 0:s.width)??wr(n.width),w=y?nC(Math.round(y/tC*100),5,100):100;return r("image",{src:((o=n.src)==null?void 0:o.url)||(typeof n.src=="string"?n.src:"")||"",alt:n.altText||((a=n.src)==null?void 0:a.altText)||"",href:go(n.action)||go(n.href),align:n.textAlign||n.align||"center",width:w})}case"button":return r("button",{label:ps(n.text)||"Button",href:go(n.href),background_color:(l=n.buttonColors)==null?void 0:l.backgroundColor,color:(d=n.buttonColors)==null?void 0:d.color,align:n.textAlign||n.align||"left",border_radius:wr(n.borderRadius)});case"divider":return r("divider",{color:((u=n.border)==null?void 0:u.borderTopColor)||n.color||"#d9dce5",thickness:wr((h=n.border)==null?void 0:h.borderTopWidth)||1,width:wr(n.width)||100});case"html":return r("raw-html",{html:typeof n.html=="string"?n.html:""});case"menu":return r("raw-html",{html:P8(n)});case"social":return r("social",{items:B8(n),align:n.align||"center"});case"divider2":case"spacer":return r("spacer",{height:wr(n.height)||24});case"table":{const{rows:y,header:w}=F8(n);return y.length?r("table",{rows:y,header_row:w,align:n.textAlign||n.align||"left"}):i()}case"timer":case"countdown":{const y=((p=n==null?void 0:n.timer)==null?void 0:p.endTime)||(n==null?void 0:n.endTime)||(n==null?void 0:n.endDate)||(n==null?void 0:n.deadline)||((m=n==null?void 0:n.settings)==null?void 0:m.endDate);return r("countdown",{label:ps(n==null?void 0:n.text)||"Offer ends in",...typeof y=="string"&&y?{end_date:y}:{},background_color:n==null?void 0:n.backgroundColor,color:n==null?void 0:n.color,align:(n==null?void 0:n.align)||"center"})}case"video":{const y=(n==null?void 0:n.videoUrl)||(n==null?void 0:n.url)||go(n==null?void 0:n.action)||(typeof(n==null?void 0:n.src)=="string"?n.src:(g=n==null?void 0:n.src)==null?void 0:g.url)||"";return r("video",{url:y,thumbnail:((b=n==null?void 0:n.thumbnail)==null?void 0:b.url)||(typeof(n==null?void 0:n.thumbnail)=="string"?n.thumbnail:"")||(n==null?void 0:n.poster)||"",title:ps(n==null?void 0:n.text)||"Video",align:(n==null?void 0:n.align)||"center"})}case"form":return r("form",{headline:ps((n==null?void 0:n.title)||(n==null?void 0:n.headline)||(n==null?void 0:n.text))||"Sign up",button_label:ps(((A=n==null?void 0:n.button)==null?void 0:A.text)||(n==null?void 0:n.submitLabel)||(n==null?void 0:n.buttonText))||"Submit"});default:return i()}},H8=(e,t)=>{const n=(e==null?void 0:e.values)||{};return{id:Uf("col"),width:Math.round(t*100)/100,blocks:((e==null?void 0:e.contents)||[]).map($8).filter(Boolean),settings:{background_color:n.backgroundColor||void 0,padding:wr(n.padding)}}},U8=e=>{const t=(e==null?void 0:e.values)||{},n=(e==null?void 0:e.columns)||[],r=Array.isArray(e==null?void 0:e.cells)&&e.cells.length?e.cells.map(s=>Number(s)||1):n.map(()=>1),i=r.reduce((s,o)=>s+o,0)||1;return{id:Uf("row"),columns:n.map((s,o)=>H8(s,(r[o]||1)/i*100)),settings:{background_color:t.backgroundColor||void 0,content_background_color:t.columnsBackgroundColor||t.contentBackgroundColor||void 0,padding:typeof t.padding=="string"?t.padding:void 0}}};function G8(e){var s,o;const t=hl();if(!e||typeof e!="object"||!e.body)return t;const n=e.body,r=n.values||{},i=nC(wr(r.contentWidth)??t.body.content_width,320,1200);return tC=i,{...t,body:{...t.body,background_color:r.backgroundColor||t.body.background_color,content_width:i,font_family:((s=r.fontFamily)==null?void 0:s.value)||(typeof r.fontFamily=="string"?r.fontFamily:void 0)||t.body.font_family,preheader_text:typeof r.preheaderText=="string"?r.preheaderText:t.body.preheader_text,link_color:((o=r.linkStyle)==null?void 0:o.linkColor)||t.body.link_color,rows:Array.isArray(n.rows)?n.rows.map(U8):[]}}}const Gf={plan:"free",features:{"editor.undo_redo":!0,"editor.save_version":!0,"appearance.custom_themes":!0,"branding.white_label":!0,"assets.private_connectors":!0,"ai.generate":!0,"ai.rewrite":!0,"ai.subjects":!0,"ai.alt_text":!0,"preview.inbox":!0}},Wf=`
|
|
285
285
|
.edm-canvas { background: #ece9e2 !important; }
|
|
286
|
-
.edm-stage { border: 1px solid #ddd8cd; border-radius: 16px; box-shadow: 0 2px 14px rgba(20, 33, 61, 0.07); overflow:
|
|
286
|
+
.edm-stage { border: 1px solid #ddd8cd; border-radius: 16px; box-shadow: 0 2px 14px rgba(20, 33, 61, 0.07); overflow: clip; }
|
|
287
287
|
`;function Yf(e){const t={onImageUpload:oC(e)};return e.googleClientId&&(t.googleDrive={clientId:e.googleClientId}),t.s3Connector=w8({listEndpoint:e.s3ListEndpoint??`${zf(e.apiBaseUrl)}${sC}`,headers:yu(e),label:"Amazon S3"}),t}const rC="/buzz-communication/upload/template-assets",iC="/mail-templates/ai-generate",sC="/buzz-communication/upload/template-assets",zf=e=>e.replace(/\/$/,"");function yu(e){const t={"organization-id":e.orgId};return e.authToken&&(t.Authorization=`Bearer ${e.authToken}`),t}function oC(e){const t=`${zf(e.apiBaseUrl)}${e.uploadPath??rC}`;return async(n,r)=>{const i=new FormData;i.append("file",n);const s=await fetch(t,{method:"POST",body:i,headers:yu(e),credentials:"include"});if(!s.ok)throw new Error(`Upload failed: ${s.status} ${s.statusText}`);const o=await s.json().catch(()=>({})),a=W8(o);if(!a)throw new Error("Upload failed: no URL in the response");return{url:a}}}function W8(e){if(!e||typeof e!="object")return;const t=e,n=t.file&&typeof t.file=="object"?t.file:void 0,r=(n==null?void 0:n.url)??t.url??t.Location??t.fileUrl;return typeof r=="string"&&/^https?:\/\//i.test(r)?r:void 0}function Y8(e="off",t){return e==="client-id"&&t?{clientId:t}:!1}const aC=e=>e.replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ").replace(/ /gi," ").replace(/\s+/g," ").trim(),z8=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),K8=e=>{const t=e.match(/<(h1|h2|h3|p)[^>]*>([\s\S]*?)<\/\1>/i);return aC(t?t[2]:e)},Q8=e=>{const t=e==null?void 0:e.values,n=(t==null?void 0:t.html)??(t==null?void 0:t.text)??"";return typeof n=="string"?aC(n):""};function Kf(e){const t=`${zf(e.apiBaseUrl)}${e.aiGeneratePath??iC}`,n=async r=>{const i=await fetch(t,{method:"POST",credentials:"include",headers:{"content-type":"application/json",...yu(e)},body:JSON.stringify(r)});if(!i.ok)throw new Error(`AI request failed: ${i.status} ${i.statusText}`);return await i.json().catch(()=>({}))};return{generateDesignFromPrompt:async r=>{const i=await n({prompt:r.prompt,allowedVariables:Object.keys(r.mergeTags??{})});if(!i.htmlContent)return{summary:i.subject};const{design:s}=zL(i.htmlContent,{title:i.subject});return{design:s,summary:i.subject}},rewriteText:async r=>{var o;const i=((o=r.selectedText)==null?void 0:o.trim())||Q8(r.block),s=await n({prompt:`${r.prompt} Keep it to a single short piece of body text based on: "${i}"`,currentHtmlContent:`<p>${z8(i)}</p>`});return{text:K8(s.htmlContent??"")||i}},generateSubjectLines:async r=>{const i=Math.min(r.count??5,5),s=await Promise.all(Array.from({length:i},()=>n({prompt:`Write one short, catchy email subject line for: ${r.prompt}`}).then(a=>(a.subject??"").trim()).catch(()=>"")));return{subjects:Array.from(new Set(s.filter(Boolean)))}},generateAltText:async r=>{var i,s;return{alt:((i=r.currentAlt)==null?void 0:i.trim())||((s=r.title)==null?void 0:s.trim())||""}}}}const hx=760,px=e=>{const t=e==null?void 0:e.body;return!t||(Number(t.content_width)||0)>=hx?e:{...e,body:{...t,content_width:hx}}},V8=e=>{var t;return!!(e&&typeof e=="object"&&((t=e.body)!=null&&t.rows)&&!("schema_version"in e))},q8=e=>e==="web"||e==="page"?"page":e==="document"?"document":e==="popup"?"popup":"email",J8=()=>{if(typeof window>"u")return"";const e=window.location.pathname.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i);return e?e[0]:""};function Z8(e){const t=(e==null?void 0:e.apiBaseUrl)??(typeof window<"u"?window.location.origin:""),n=(e==null?void 0:e.orgId)??J8(),r=(e==null?void 0:e.authToken)??(typeof window<"u"?localStorage.getItem("token")??void 0:void 0);return{...e,apiBaseUrl:t,orgId:n,authToken:r}}const Qf=v.forwardRef(({edmission:e,options:t,onReady:n,onLoad:r,logoUrl:i,logoAlt:s,style:o,minHeight:a,className:l},d)=>{const u=v.useRef(null),h=v.useMemo(()=>Z8(e),[e==null?void 0:e.apiBaseUrl,e==null?void 0:e.orgId,e==null?void 0:e.authToken,e==null?void 0:e.uploadPath,e==null?void 0:e.aiGeneratePath,e==null?void 0:e.googleClientId,e==null?void 0:e.s3ListEndpoint]),p=q8(t==null?void 0:t.displayMode),[m,g]=v.useState(()=>ax(t==null?void 0:t.mergeTags)),[b]=v.useState(()=>px(hl())),A=v.useRef(new Map),y=v.useMemo(()=>({builder:p,entitlements:Gf,appearance:{customCss:Wf},branding:i?{paletteLogoUrl:i,paletteLogoAlt:s}:void 0,assets:Yf(h),ai:{adapter:Kf(h)}}),[p,i,s,h]),w=v.useMemo(()=>({loadDesign:E=>{var S;try{const k=V8(E)?G8(E):yj(E);(S=u.current)==null||S.loadDesign(px(k))}catch(k){console.warn("[@edmissioncrm/editor] loadDesign skipped (unrecognized design).",k)}},saveDesign:E=>{var S;return E(((S=u.current)==null?void 0:S.getDesign())??{})},exportHtml:E=>{var S,k;return E({design:((S=u.current)==null?void 0:S.getDesign())??{},html:((k=u.current)==null?void 0:k.exportHtml())??""})},exportPlainText:E=>{var S;return E({design:((S=u.current)==null?void 0:S.getDesign())??{},text:""})},setMergeTags:E=>g(ax(E)),addEventListener:(E,S)=>{const k=A.current.get(E)??new Set;k.add(S),A.current.set(E,k)},removeEventListener:(E,S)=>{var k;(k=A.current.get(E))==null||k.delete(S)},registerCallback:()=>{}}),[]);v.useImperativeHandle(d,()=>({editor:w}),[w]),v.useEffect(()=>{r==null||r(),n==null||n(w)},[]);const C=v.useCallback(E=>{const S=A.current.get("design:updated");if(S)for(const k of S)k({design:E})},[]);return c.jsx(Hf,{ref:u,className:l,style:a!=null?{minHeight:a,...o}:o,config:y,mergeTags:m,initialDesign:b,onDesignChange:C})});Qf.displayName="EmailEditor";const lC=v.forwardRef(({edmission:e,builder:t="email",mergeTags:n,logoUrl:r,logoAlt:i,initialDesign:s,onDesignChange:o,className:a,style:l},d)=>{const u={builder:t,entitlements:Gf,appearance:{customCss:Wf},branding:r?{paletteLogoUrl:r,paletteLogoAlt:i}:void 0,assets:Yf(e),ai:{adapter:Kf(e)}};return c.jsx(Hf,{ref:d,className:a,style:l,config:u,mergeTags:n,initialDesign:s,onDesignChange:o})});lC.displayName="EdmissionEmailEditor";exports.DEFAULT_EDMISSION_AI_GENERATE_PATH=iC;exports.DEFAULT_EDMISSION_S3_LIST_PATH=sC;exports.DEFAULT_EDMISSION_UPLOAD_PATH=rC;exports.EDMISSION_ENTITLEMENTS=Gf;exports.EDMISSION_FRAME_CSS=Wf;exports.EdmissionEmailEditor=lC;exports.EmailEditor=Qf;exports.buildEdmissionGoogleDrive=Y8;exports.createEdmissionAiAdapter=Kf;exports.createEdmissionAssets=Yf;exports.createEdmissionUploadHandler=oC;exports.default=Qf;exports.edmissionConnectorHeaders=yu;
|
package/dist/index.js
CHANGED
|
@@ -47511,7 +47511,7 @@ const hT = {
|
|
|
47511
47511
|
}
|
|
47512
47512
|
}, pT = `
|
|
47513
47513
|
.edm-canvas { background: #ece9e2 !important; }
|
|
47514
|
-
.edm-stage { border: 1px solid #ddd8cd; border-radius: 16px; box-shadow: 0 2px 14px rgba(20, 33, 61, 0.07); overflow:
|
|
47514
|
+
.edm-stage { border: 1px solid #ddd8cd; border-radius: 16px; box-shadow: 0 2px 14px rgba(20, 33, 61, 0.07); overflow: clip; }
|
|
47515
47515
|
`;
|
|
47516
47516
|
function mT(e) {
|
|
47517
47517
|
const t = {
|