@emailmaker/emailmaker 1.0.9 → 1.0.10
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/README_eng.md +1 -1
- package/asset-manifest.json +10 -10
- package/emailmaker-esm.js +1 -1
- package/emailmaker.js +1 -1
- package/iframe/{iframe-eblock.608bba40534256f2936e.html → iframe-eblock.0647a1d3ec50c052e1ba.html} +1 -1
- package/iframe/{iframe.608bba40534256f2936e.html → iframe.0647a1d3ec50c052e1ba.html} +1 -1
- package/iframe/js/cssbeautify.js +1 -1
- package/iframe/sandbox-eblock.js +1 -1
- package/iframe/sandbox.js +1 -1
- package/package.json +1 -1
- package/plugin.html +1 -1
- package/plugin_default.html +1 -1
- package/plugin_s.html +1 -1
- package/static/js/{1399.2fad9d93.js → 1399.cb4cfaa3.js} +1 -1
- package/static/js/{5571.703bbc87.js → 5571.74b1c7f8.js} +1 -1
- package/static/js/5632.50b5ade7.js +1 -0
- package/static/js/{8353.556e79ed.js → 8353.be165e77.js} +1 -1
- package/static/js/{9141.063ee048.js → 9141.32c0af4c.js} +1 -1
- package/translations.pot +12 -12
- package/static/js/5632.0476b4be.js +0 -1
package/package.json
CHANGED
package/plugin.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?
|
|
1
|
+
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?41e67e21b8740cac1355"></script></head><body><button id="change_theme" style="width: 150px; height: 30px">Click Me</button><div style="background: white; width: 100%; height: 50px; display: flex; justify-content: center; align-items: center"></div><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?41e67e21b8740cac1355";
|
|
2
2
|
const auth_jwt = {
|
|
3
3
|
username: "****",
|
|
4
4
|
password: "****"
|
package/plugin_default.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?
|
|
1
|
+
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?41e67e21b8740cac1355"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">// import { init } from "./emailmaker-esm.js?41e67e21b8740cac1355";
|
|
2
2
|
const auth_jwt = {
|
|
3
3
|
username: "****",
|
|
4
4
|
password: "****"
|
package/plugin_s.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?
|
|
1
|
+
<!doctype html><html lang="en"><head><script id="plugin-script" src="emailmaker.js?41e67e21b8740cac1355"></script></head><body><div id="test" style="padding: 0px; background: #fff; height: 100vh;"></div><script async defer="defer">const getAuthToken = async () => {
|
|
2
2
|
|
|
3
3
|
var requestOptions = {
|
|
4
4
|
method: 'POST',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[1399],{83953:(e,t,a)=>{a.d(t,{A:()=>k});var o=a(92810),i=a(66170),r=a(66726),s=a(43005),l=a(71157),n=a(64617),d=a(45934),c=a(23287),u=a(48409),m=a.n(u),_=a(87701),v=a(84568),p=a(93563),h=a(64037),E=a(7760),g=a(32269),f=a(47381),R=a(32411),y=a(85163),b=a(70082);const C=({block:e,isEditableRights:t,rightCol:a,autoSaveBlockResult:u})=>{const{__:C}=(0,c.s9)(),{projectId:k,blockId:A}=(0,n.g)();let T=(0,d.d4)(E.Fv),O=(0,d.d4)(E.Fv),N=(0,d.wA)();const I=(0,l.hN)(),S=(0,R.fn)(),j=(0,d.Pj)(),[L,w]=(0,o.useState)(!1),[G,$]=(0,o.useState)(null),[x,B]=(0,o.useState)(!1),[K,D]=(0,o.useState)(!1);(0,o.useEffect)((()=>{var e,t;null!==(e=window)&&void 0!==e&&null!==(t=e.navigator)&&void 0!==t&&t.userAgent.includes("Macintosh")&&$(!0)}),[]);const{data:V,refetch:M}=(0,v.fo)(+k,{skip:!+k}),[P]=(0,_.Gr)(),[U,Y]=(0,_.OZ)(),[F,z]=(0,_.pP)(),[q]=(0,v.OD)(),X=`project_${k}`,H=V&&(0,g._q)(V,y.YY).find((e=>e.name===X)),Z=V&&(0,g.HT)(V,y.YY),J=(0,o.useCallback)((a=>{var o,i;if(B(!0),!t&&e.lock&&K)return I.error({id:"BLOCK_ACCESS_TO_LOCKED_ERROR",message:C("No access to edit the letter."),placement:"bottomRight",data:(0,l.x_)(e)}),void B(!1);if(((null===(o=e.tags)||void 0===o?void 0:o.length)||(null===(i=e.blocktags)||void 0===i?void 0:i.length))>10&&K)return I.error({id:"BLOCK_TOO_MANY_TAGS_ERROR",message:C("Maximum 10 tags available."),placement:"bottomRight",data:(0,l.x_)(e)}),void B(!1);if(""===e.type)return I.error({message:C("Set the type"),description:C("Please set the 'Type' field in the Settings section."),placement:"bottomRight"}),void B(!1);const r=t=>{var o;const i=null===(o=e.tags)||void 0===o?void 0:o.map((e=>{const a=null===Z||void 0===Z?void 0:Z.find((t=>t.name===e));return a?a.id:P({name:e,parent:t}).then((({error:t,data:a})=>{var o,i;return 400===(null===t||void 0===t?void 0:t.status)?null===t||void 0===t||null===(o=t.data)||void 0===o||null===(i=o.data)||void 0===i?void 0:i.term_id:a?a.id:void(t&&(I.fromError("TAG_CREATING_ERROR",e,t),B(!1)))}))})),r=(o=null)=>{const i=a=>{j.dispatch(p.kE.endpoints.getTags.initiate({parent:t})),M(),K&&(I.success({id:"BLOCK_EDITING_SUCCESS",message:C("The block was successfully saved.","block"),data:(0,l.x_)(e)}),B(!1)),fetch(((e,t,a,o)=>{let i="dev-backend-1.emailmaker.ru";const r=o?`&cacheControl=true&cache-hash=${m()(o)}`:"";return console.log("projectURL",i),`https://scr.emcdn.ru/screenshot?delay=1000&width=800&fullPage=true&deviceScaleFactor=0.8&format=jpg&clearCache=true${r}&url=${encodeURIComponent(`https://${i}/get${e}/${a}?secret_hash=${m()(`${t}${a}${y.KI}`)}&raw=true`)}`})(y.IE,k,a.id,a.modified),{mode:"no-cors"}).then((()=>{}))},r=(0,g._q)(e,y.zh).filter((t=>(o||e.blocktags).includes(t.id))).map((e=>e.name));e.isNew?z.status!==y.eG&&F({source:a,title:null===e.title?C("New block title"):e.title,project:e.project,type:e.type?e.type:"Other",description:e.description,html:(null===S||void 0===S?void 0:S.getValue())||"",blocktags:o?o.join(","):e.blocktags,tags:r}).then((({data:t,error:a})=>{a?(I.fromError("BLOCK_CREATING_ERROR",{title:e.title,html:(null===S||void 0===S?void 0:S.getValue())||""},a),B(!1)):i(t)})):Y.status!==y.eG&&U({blockId:e.id,source:a,title:e.title,project:e.project,type:e.type?e.type:"Other",description:e.description,html:(null===S||void 0===S?void 0:S.getValue())||"",blocktags:o||e.blocktags,tags:r}).then((({data:t,error:a})=>{a&&K?(I.fromError("BLOCK_EDITING_ERROR",(0,l.x_)(e),a),B(!1)):i(t)}))};i?Promise.all(i).then((e=>r(e))):r(null)};B(!0),H?r(H.id):P({name:X}).then((async({data:t,error:a})=>{if(a)I.fromError("FOLDER_CREATING_ERROR",X,a),B(!1);else{const{data:a,error:o}=await q({projectId:k,blocktags:t.id});o?(I.fromError("BLOCK_CLONING_ERROR",(0,l.x_)(e),o),B(!1)):a&&r(a.blocktags&&a.blocktags[0])}})).catch((e=>console.error(e)))}),[z.status,F,Y.status,U,e,t,P,q,k,C,K,S,I,Z,M,j,H,X]);(0,o.useEffect)((()=>{K&&(J(),D(!1))}),[K,J]);const Q=(0,o.useCallback)((e=>{(e.ctrlKey||e.metaKey)&&83===e.keyCode&&(e.preventDefault(),D(!0))}),[]);(0,o.useEffect)((()=>(document.addEventListener("keydown",Q),()=>{document.removeEventListener("keydown",Q)})),[Q]);const W=(0,o.useCallback)((e=>{const t=e.data.operation,a=e.data.action;t===y.Ru.APPLICATION_ACTION&&"save_email"===a&&D(!0)}),[]);return(0,h.A)(W),(0,o.useEffect)((()=>{z.isError&&(B(!1),(0,g.p6)(z,I))}),[N,z,I]),(0,o.useEffect)((()=>{const e=setTimeout((()=>{w(!0)}),1e4);return()=>{clearTimeout(e)}}),[]),(0,o.useEffect)((()=>{e.isNew&&!A&&L&&(J(),w(!1))}),[L,e,J,A]),(0,b.jsx)(r.A,{title:C(G?"Save by \u2318S":"Save by Ctrl+S"),placement:a?"right":"bottomRight",children:(0,b.jsx)(s.Ay,{type:"primary",block:a,className:"em-analytics__block-save",icon:(0,b.jsx)(i.A,{}),onClick:()=>{(0,f.d)({event:"click",action:"save_block"}),D(!0)},loading:Y.isLoading||q.isLoading||z.isLoading||x||u,children:a||T||O?"":C("Save")})})};C.defaultProps={block:null};const k=C},59287:(e,t,a)=>{a.d(t,{A:()=>w,W:()=>j});var o=a(92810),i=a(66726),r=a(43005),s=a(81e3),l=a(71157),n=a(66170),d=a(64617),c=a(45934),u=a(48409),m=a.n(u),_=a(23287),v=a(17581),p=a(84568),h=a(93563),E=a(64037),g=a(8493),f=a(32269),R=a(56991),y=a(47381),b=a(32411),C=a(13329),k=a(93982),A=a(85163),T=a(90070),O=a(13522),N=a(28316),I=a(70082);const S="KEYBOARD",j=(e,t,a,o,i=!0,r=.8,s)=>`${window.location.host.indexOf("localhost")>=0?`${window.location.protocol}//${window.location.host}`:"https://scr.emcdn.ru"}/screenshot?delay=1000&width=800${s?"":"&fullPage=true"}&deviceScaleFactor=${r}&format=jpg&clearCache=${i}${o?`&cacheControl=true&cache-hash=${m()(o)}`:""}&url=${encodeURIComponent(`https://app.emailmaker.ru/get${e}/${a}?secret_hash=${m()(`${t}${a}${A.KI}`)}&raw=true`)}${s?`&selector=${s}`:""}`,L=({email:e,isEditableRights:t,autoSaveEmailResult:a})=>{var u,m;let L=(0,c.wA)(),w=(0,d.Zp)();const{__:G,_x:$}=(0,_.s9)(),{projectId:x,emailId:B}=(0,d.g)(),K=(0,T.p6)(),D=(0,l.hN)(),V=(0,R.rD)(),M=(0,b.fn)(),P=(0,c.Pj)(),[U,Y]=(0,o.useState)(!1),[F,z]=(0,o.useState)(null);(0,o.useEffect)((()=>{var e,t;null!==(e=window)&&void 0!==e&&null!==(t=e.navigator)&&void 0!==t&&t.userAgent.includes("Macintosh")&&z(!0)}),[]);const{data:q,refetch:X}=(0,p.fo)(+x,{skip:!+x}),{data:H,refetch:Z}=(0,h.Jz)({parent:null===(u=q.folder)||void 0===u?void 0:u[0]},{skip:!(null!==(m=q.folder)&&void 0!==m&&m[0])}),[J]=(0,v.Gr)(),[Q,W]=(0,v.dN)(),[ee,te]=(0,v.Kh)(),[ae]=(0,p.OD)(),[oe,ie]=(0,o.useState)(!1),[re,se]=(0,o.useState)(""),le=`project_${x}`,ne=q&&(0,f._q)(q,A.zh).find((e=>e.name===le)),de=q&&(0,f.HT)(q,A.zh),ce=(0,k.ml)(O.A.BEFORE_SAVE_EMAIL),ue=(0,o.useCallback)((a=>{var o,i;if(!t&&e.lock&&re)return void D.error({id:"EMAIL_ACCESS_TO_LOCKED_ERROR",data:(0,l.Gy)(e),message:G("No access to edit the letter."),placement:"bottomRight"});if(((null===e||void 0===e||null===(o=e.tags)||void 0===o?void 0:o.length)||(null===(i=e.emailtags)||void 0===i?void 0:i.length))>10&&re)return void D.error({id:"EMAIL_TOO_MANY_TAGS_ERROR",data:(0,l.Gy)(e),message:G("Maximum 10 tags available."),placement:"bottomRight"});const r=t=>{var o;const i=null===(o=e.tags)||void 0===o?void 0:o.map((e=>{const a=null===de||void 0===de?void 0:de.find((t=>t.name===e));return a?a.id:J({name:e,parent:t}).then((({error:t,data:a})=>{var o,i;return 400===(null===t||void 0===t?void 0:t.status)?null===t||void 0===t||null===(o=t.data)||void 0===o||null===(i=o.data)||void 0===i?void 0:i.term_id:a?a.id:void(t&&(D.fromError("TAG_CREATING_ERROR",e,t),ie(!1)))}))})),r=(e,o=null,i=[])=>{var r,s;const n=(null===(r=e.title)||void 0===r?void 0:r.trim())||(null===(s=e.subject)||void 0===s?void 0:s.trim())||G("Untitled email."),d=a=>{P.dispatch(h.kE.endpoints.getTags.initiate({parent:t})),X(),re&&(D.success({id:"EMAIL_SAVING_SUCCESS",message:G("The email was successfully saved."),data:(0,l.Gy)(e)}),ie(!1),H&&Z()),fetch(j(A.Tm,x,a.id,a.modified),{mode:"no-cors"}).then((()=>{}))},c=(0,f._q)(e,A.zh).filter((t=>(o||e.emailtags).includes(t.id))).map((e=>e.name));var u,m,_,v,p;if(e.isNew){if(te.status!==A.eG){const t=K.get(A.A9.em_folder);ee({title:n,source:a,project:e.project,subject:e.subject,preheader:e.preheader,description:e.description,utm_parameters:{utm_source:e.utm_parameters.utm_source,utm_medium:e.utm_parameters.utm_medium,utm_campaign:e.utm_parameters.utm_campaign,utm_term:e.utm_parameters.utm_term,utm_content:e.utm_parameters.utm_content},html:(null===M||void 0===M?void 0:M.getValue())||"",parent_email:e.parent_email||A.iU,common_styles:e.common_styles||"",emailtags:o?o.join(","):e.emailtags,tags:c,is_template:e.is_template||!1,is_inited:e.is_inited,renderGuid:e.renderGuid,folder:t!==A.y2&&t}).then((({data:t,error:a})=>{a&&re?(D.fromError("EMAIL_CREATING_ERROR",{title:e.title,code:(null===M||void 0===M?void 0:M.getValue())||""},a),ie(!1)):(L((0,g.aY)(null)),d(t),K.remove(A.A9.em_folder))}))}}else W.status!==A.eG&&Q({emailId:e.id,source:a,title:n,project:e.project,preheader:e.preheader,subject:e.subject,utm_parameters:{utm_source:null===(u=e.utm_parameters)||void 0===u?void 0:u.utm_source,utm_medium:null===(m=e.utm_parameters)||void 0===m?void 0:m.utm_medium,utm_campaign:null===(_=e.utm_parameters)||void 0===_?void 0:_.utm_campaign,utm_term:null===(v=e.utm_parameters)||void 0===v?void 0:v.utm_term,utm_content:null===(p=e.utm_parameters)||void 0===p?void 0:p.utm_content},description:e.description,html:(null===M||void 0===M?void 0:M.getValue())||"",common_styles:e.common_styles||"",emailtags:o||e.emailtags,tags:c,is_template:e.is_template||!1}).then((({error:t})=>{t&&re?(D.fromError("EMAIL_EDITING_ERROR",(0,l.Gy)(e),t),ie(!1)):d(e)}));(0,y.d)({event:"save",action:a?"save_email":"auto_save_email",email_id:e.id,project_id:x})},s={...e};ce.fire(s).finally((()=>{i?Promise.all(i).then((e=>{r(s,e,[])})):r(s,null,[])}))};ie(!0),ne?r(ne.id):J({name:le}).then((async({data:t,error:a})=>{if(a)D.fromError("FOLDER_CREATING_ERROR",le,a),ie(!1);else{const{data:a,error:o}=await ae({projectId:x,emailtags:t.id});o?(D.fromError("EMAIL_CLONING_ERROR",(0,l.Gy)(e),o),ie(!1)):a&&r(a.emailtags&&a.emailtags[0])}})).catch((e=>console.error(e)))}),[te.status,ee,W.status,Q,e,t,J,L,ae,x,q,G,$,re,M,de,ce]);(0,C.D3)(N.Kp,(0,o.useCallback)((e=>ue(e||"EXTERNAL")),[ue]));const me=(0,k.ml)(O.A.ON_NEXTBUTTON_CLICK_ID),_e=(0,k.ml)(O.A.ON_SAVEBUTTON_CLICK_ID);(0,o.useEffect)((()=>{re&&(setTimeout((()=>ue(re))),se(""))}),[re]);const ve=(0,o.useCallback)((e=>{(e.ctrlKey||e.metaKey)&&83===e.keyCode&&(e.preventDefault(),se(S))}),[ue]);(0,o.useEffect)((()=>(document.addEventListener("keydown",ve),()=>{document.removeEventListener("keydown",ve)})),[ve]);const pe=(0,o.useCallback)((e=>{const t=e.data.operation,a=e.data.action;t===A.Ru.APPLICATION_ACTION&&"save_email"===a&&se(S)}),[ue]);(0,E.A)(pe),(0,o.useEffect)((()=>{e.isNew&&te.isSuccess&&(ie(!0),L(v.GY.util.upsertQueryData("getEmail",te.data.id,{...te.data,lock:e.lock,subject:e.subject,preheader:e.preheader,description:e.description,html:(null===M||void 0===M?void 0:M.getValue())||"",project:e.project,tags:e.tags,utm_parameters:e.utm_parameters,parent_email:e.parent_email,common_styles:e.common_styles,renderGuid:e.renderGuid,is_inited:e.is_inited,isNew:!1})).then((()=>{w(`/projects/${te.data.project}/emails/${te.data.id}`),ie(!1),re&&D.success({id:"EMAIL_SAVING_SUCCESS",message:G("The email was successfully saved."),data:(0,l.Gy)(e)})})))}),[w,L,te,e.isNew,G,$,re,M]),(0,o.useEffect)((()=>{const e=setTimeout((()=>Y(!0)),1e4);return()=>clearTimeout(e)}),[Y]),(0,o.useEffect)((()=>{e.isNew&&!B&&U&&(ue(),Y(!1))}),[U,e,ue,B]);const he=W.isLoading||(null===ae||void 0===ae?void 0:ae.isLoading)||te.isLoading||oe||a&&a.isLoading,Ee=V.saveButtonEnabled&&(0,I.jsx)(i.A,{title:G(F?"Save by \u2318S":"Save by Ctrl+S"),placement:"bottom",children:(0,I.jsx)(r.Ay,{type:V.nextButtonEnabled?"default":"primary",block:"false",className:"em-analytics__email-save",loading:he,icon:(0,I.jsx)(n.A,{}),onClick:async()=>{const t={...e,html:M.getValue()};try{!1!==await _e.fire(t)&&se("SAVE_BUTTON")}catch(a){D.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",(0,l.Gy)(t),a,!0)}},children:V.saveButtonText||G("Save")})},"save-button"),ge=V.nextButtonEnabled&&(0,I.jsx)(r.Ay,{type:"primary",block:"false",className:"em-analytics__email-save",icon:V.primaryCommandButtonIcon,loading:he,onClick:async()=>{const t={...e,html:M.getValue()};try{!1!==await me.fire(t)&&se("NEXT_BUTTON")}catch(a){D.fromError("NEXT_BUTTON_CLICK_EVENT_ERROR",(0,l.Gy)(t),a,!0)}},children:V.nextButtonText||G("Continue")},"next-button");return(0,I.jsx)(I.Fragment,{children:V.saveButtonEnabled&&V.nextButtonEnabled?(0,I.jsx)(s.A,{children:[Ee,ge]}):[Ee,ge]})};L.defaultProps={email:null,isEditableRights:null};const w=L}}]);
|
|
1
|
+
"use strict";(globalThis.webpackChunkemail_maker=globalThis.webpackChunkemail_maker||[]).push([[1399],{83953:(e,t,a)=>{a.d(t,{A:()=>k});var o=a(92810),i=a(66170),r=a(66726),s=a(43005),l=a(71157),n=a(64617),d=a(45934),c=a(23287),u=a(48409),m=a.n(u),_=a(87701),v=a(84568),p=a(93563),h=a(64037),E=a(7760),g=a(32269),f=a(47381),R=a(32411),y=a(85163),b=a(70082);const C=({block:e,isEditableRights:t,rightCol:a,autoSaveBlockResult:u})=>{const{__:C}=(0,c.s9)(),{projectId:k,blockId:A}=(0,n.g)();let T=(0,d.d4)(E.Fv),O=(0,d.d4)(E.Fv),N=(0,d.wA)();const I=(0,l.hN)(),S=(0,R.fn)(),j=(0,d.Pj)(),[L,w]=(0,o.useState)(!1),[G,$]=(0,o.useState)(null),[x,B]=(0,o.useState)(!1),[K,D]=(0,o.useState)(!1);(0,o.useEffect)((()=>{var e,t;null!==(e=window)&&void 0!==e&&null!==(t=e.navigator)&&void 0!==t&&t.userAgent.includes("Macintosh")&&$(!0)}),[]);const{data:V,refetch:P}=(0,v.fo)(+k,{skip:!+k}),[M]=(0,_.Gr)(),[U,Y]=(0,_.OZ)(),[F,z]=(0,_.pP)(),[q]=(0,v.OD)(),X=`project_${k}`,H=V&&(0,g._q)(V,y.YY).find((e=>e.name===X)),W=V&&(0,g.HT)(V,y.YY),Z=(0,o.useCallback)((a=>{var o,i;if(B(!0),!t&&e.lock&&K)return I.error({id:"BLOCK_ACCESS_TO_LOCKED_ERROR",message:C("No access to edit the letter."),placement:"bottomRight",data:(0,l.x_)(e)}),void B(!1);if(((null===(o=e.tags)||void 0===o?void 0:o.length)||(null===(i=e.blocktags)||void 0===i?void 0:i.length))>10&&K)return I.error({id:"BLOCK_TOO_MANY_TAGS_ERROR",message:C("Maximum 10 tags available."),placement:"bottomRight",data:(0,l.x_)(e)}),void B(!1);if(""===e.type)return I.error({message:C("Set the type"),description:C("Please set the 'Type' field in the Settings section."),placement:"bottomRight"}),void B(!1);const r=t=>{var o;const i=null===(o=e.tags)||void 0===o?void 0:o.map((e=>{const a=null===W||void 0===W?void 0:W.find((t=>t.name===e));return a?a.id:M({name:e,parent:t}).then((({error:t,data:a})=>{var o,i;return 400===(null===t||void 0===t?void 0:t.status)?null===t||void 0===t||null===(o=t.data)||void 0===o||null===(i=o.data)||void 0===i?void 0:i.term_id:a?a.id:void(t&&(I.fromError("TAG_CREATING_ERROR",e,t),B(!1)))}))})),r=(o=null)=>{const i=a=>{j.dispatch(p.kE.endpoints.getTags.initiate({parent:t})),P(),K&&(I.success({id:"BLOCK_EDITING_SUCCESS",message:C("The block was successfully saved.","block"),data:(0,l.x_)(e)}),B(!1)),fetch(((e,t,a,o)=>{let i="dev-backend-1.emailmaker.ru";const r=o?`&cacheControl=true&cache-hash=${m()(o)}`:"";return console.log("projectURL",i),`https://scr.emcdn.ru/screenshot?delay=1000&width=800&fullPage=true&deviceScaleFactor=0.8&format=jpg&clearCache=true${r}&url=${encodeURIComponent(`https://${i}/get${e}/${a}?secret_hash=${m()(`${t}${a}${y.KI}`)}&raw=true`)}`})(y.IE,k,a.id,a.modified),{mode:"no-cors"}).then((()=>{}))},r=(0,g._q)(e,y.zh).filter((t=>(o||e.blocktags).includes(t.id))).map((e=>e.name));e.isNew?z.status!==y.eG&&F({source:a,title:null===e.title?C("New block title"):e.title,project:e.project,type:e.type?e.type:"Other",description:e.description,html:(null===S||void 0===S?void 0:S.getValue())||"",blocktags:o?o.join(","):e.blocktags,tags:r}).then((({data:t,error:a})=>{a?(I.fromError("BLOCK_CREATING_ERROR",{title:e.title,html:(null===S||void 0===S?void 0:S.getValue())||""},a),B(!1)):i(t)})):Y.status!==y.eG&&U({blockId:e.id,source:a,title:e.title,project:e.project,type:e.type?e.type:"Other",description:e.description,html:(null===S||void 0===S?void 0:S.getValue())||"",blocktags:o||e.blocktags,tags:r}).then((({data:t,error:a})=>{a&&K?(I.fromError("BLOCK_EDITING_ERROR",(0,l.x_)(e),a),B(!1)):i(t)}))};i?Promise.all(i).then((e=>r(e))):r(null)};B(!0),H?r(H.id):M({name:X}).then((async({data:t,error:a})=>{if(a)I.fromError("FOLDER_CREATING_ERROR",X,a),B(!1);else{const{data:a,error:o}=await q({projectId:k,blocktags:t.id});o?(I.fromError("BLOCK_CLONING_ERROR",(0,l.x_)(e),o),B(!1)):a&&r(a.blocktags&&a.blocktags[0])}})).catch((e=>console.error(e)))}),[z.status,F,Y.status,U,e,t,M,q,k,C,K,S,I,W,P,j,H,X]);(0,o.useEffect)((()=>{K&&(Z(),D(!1))}),[K,Z]);const J=(0,o.useCallback)((e=>{(e.ctrlKey||e.metaKey)&&83===e.keyCode&&(e.preventDefault(),D(!0))}),[]);(0,o.useEffect)((()=>(document.addEventListener("keydown",J),()=>{document.removeEventListener("keydown",J)})),[J]);const Q=(0,o.useCallback)((e=>{const t=e.data.operation,a=e.data.action;t===y.Ru.APPLICATION_ACTION&&"save_email"===a&&D(!0)}),[]);return(0,h.A)(Q),(0,o.useEffect)((()=>{z.isError&&(B(!1),(0,g.p6)(z,I))}),[N,z,I]),(0,o.useEffect)((()=>{const e=setTimeout((()=>{w(!0)}),1e4);return()=>{clearTimeout(e)}}),[]),(0,o.useEffect)((()=>{e.isNew&&!A&&L&&(Z(),w(!1))}),[L,e,Z,A]),(0,b.jsx)(r.A,{title:C(G?"Save by \u2318S":"Save by Ctrl+S"),placement:a?"right":"bottomRight",children:(0,b.jsx)(s.Ay,{type:"primary",block:a,className:"em-analytics__block-save",icon:(0,b.jsx)(i.A,{}),onClick:()=>{(0,f.d)({event:"click",action:"save_block"}),D(!0)},loading:Y.isLoading||q.isLoading||z.isLoading||x||u,children:a||T||O?"":C("Save")})})};C.defaultProps={block:null};const k=C},59287:(e,t,a)=>{a.d(t,{A:()=>w,W:()=>j});var o=a(92810),i=a(66726),r=a(43005),s=a(81e3),l=a(71157),n=a(66170),d=a(64617),c=a(45934),u=a(48409),m=a.n(u),_=a(23287),v=a(17581),p=a(84568),h=a(93563),E=a(64037),g=a(8493),f=a(32269),R=a(56991),y=a(47381),b=a(32411),C=a(13329),k=a(93982),A=a(85163),T=a(90070),O=a(13522),N=a(28316),I=a(70082);const S="KEYBOARD",j=(e,t,a,o,i=!0,r=.8,s)=>`${window.location.host.indexOf("localhost")>=0?`${window.location.protocol}//${window.location.host}`:"https://scr.emcdn.ru"}/screenshot?delay=1000&width=800${s?"":"&fullPage=true"}&deviceScaleFactor=${r}&format=jpg&clearCache=${i}${o?`&cacheControl=true&cache-hash=${m()(o)}`:""}&url=${encodeURIComponent(`https://app.emailmaker.ru/get${e}/${a}?secret_hash=${m()(`${t}${a}${A.KI}`)}&raw=true`)}${s?`&selector=${s}`:""}`,L=({email:e,isEditableRights:t,autoSaveEmailResult:a})=>{var u,m;let L=(0,c.wA)(),w=(0,d.Zp)();const{__:G,_x:$}=(0,_.s9)(),{projectId:x,emailId:B}=(0,d.g)(),K=(0,T.p6)(),D=(0,l.hN)(),V=(0,R.rD)(),P=(0,b.fn)(),M=(0,c.Pj)(),[U,Y]=(0,o.useState)(!1),[F,z]=(0,o.useState)(null);(0,o.useEffect)((()=>{var e,t;null!==(e=window)&&void 0!==e&&null!==(t=e.navigator)&&void 0!==t&&t.userAgent.includes("Macintosh")&&z(!0)}),[]);const{data:q,refetch:X}=(0,p.fo)(+x,{skip:!+x}),{data:H,refetch:W}=(0,h.Jz)({parent:null===(u=q.folder)||void 0===u?void 0:u[0]},{skip:!(null!==(m=q.folder)&&void 0!==m&&m[0])}),[Z]=(0,v.Gr)(),[J,Q]=(0,v.dN)(),[ee,te]=(0,v.Kh)(),[ae]=(0,p.OD)(),[oe,ie]=(0,o.useState)(!1),[re,se]=(0,o.useState)(""),le=`project_${x}`,ne=q&&(0,f._q)(q,A.zh).find((e=>e.name===le)),de=q&&(0,f.HT)(q,A.zh),ce=(0,k.ml)(O.A.BEFORE_SAVE_EMAIL),ue=(0,o.useCallback)((a=>{var o,i;if(!t&&e.lock&&re)return void D.error({id:"EMAIL_ACCESS_TO_LOCKED_ERROR",data:(0,l.Gy)(e),message:G("No access to edit the letter."),placement:"bottomRight"});if(((null===e||void 0===e||null===(o=e.tags)||void 0===o?void 0:o.length)||(null===(i=e.emailtags)||void 0===i?void 0:i.length))>10&&re)return void D.error({id:"EMAIL_TOO_MANY_TAGS_ERROR",data:(0,l.Gy)(e),message:G("Maximum 10 tags available."),placement:"bottomRight"});const r=t=>{var o;const i=null===(o=e.tags)||void 0===o?void 0:o.map((e=>{const a=null===de||void 0===de?void 0:de.find((t=>t.name===e));return a?a.id:Z({name:e,parent:t}).then((({error:t,data:a})=>{var o,i;return 400===(null===t||void 0===t?void 0:t.status)?null===t||void 0===t||null===(o=t.data)||void 0===o||null===(i=o.data)||void 0===i?void 0:i.term_id:a?a.id:void(t&&(D.fromError("TAG_CREATING_ERROR",e,t),ie(!1)))}))})),r=(e,o=null,i=[])=>{var r,s;const n=(null===(r=e.title)||void 0===r?void 0:r.trim())||(null===(s=e.subject)||void 0===s?void 0:s.trim())||G("Untitled email."),d=a=>{M.dispatch(h.kE.endpoints.getTags.initiate({parent:t})),X(),re&&(D.success({id:"EMAIL_SAVING_SUCCESS",message:G("The email was successfully saved."),data:(0,l.Gy)(e)}),ie(!1),H&&W()),A.EW.isPlugin||fetch(j(A.Tm,x,a.id,a.modified),{mode:"no-cors"}).then((()=>{}))},c=(0,f._q)(e,A.zh).filter((t=>(o||e.emailtags).includes(t.id))).map((e=>e.name));var u,m,_,v,p;if(e.isNew){if(te.status!==A.eG){const t=K.get(A.A9.em_folder);ee({title:n,source:a,project:e.project,subject:e.subject,preheader:e.preheader,description:e.description,utm_parameters:{utm_source:e.utm_parameters.utm_source,utm_medium:e.utm_parameters.utm_medium,utm_campaign:e.utm_parameters.utm_campaign,utm_term:e.utm_parameters.utm_term,utm_content:e.utm_parameters.utm_content},html:(null===P||void 0===P?void 0:P.getValue())||"",parent_email:e.parent_email||A.iU,common_styles:e.common_styles||"",emailtags:o?o.join(","):e.emailtags,tags:c,is_template:e.is_template||!1,is_inited:e.is_inited,renderGuid:e.renderGuid,folder:t!==A.y2&&t}).then((({data:t,error:a})=>{a&&re?(D.fromError("EMAIL_CREATING_ERROR",{title:e.title,code:(null===P||void 0===P?void 0:P.getValue())||""},a),ie(!1)):(L((0,g.aY)(null)),d(t),K.remove(A.A9.em_folder))}))}}else Q.status!==A.eG&&J({emailId:e.id,source:a,title:n,project:e.project,preheader:e.preheader,subject:e.subject,utm_parameters:{utm_source:null===(u=e.utm_parameters)||void 0===u?void 0:u.utm_source,utm_medium:null===(m=e.utm_parameters)||void 0===m?void 0:m.utm_medium,utm_campaign:null===(_=e.utm_parameters)||void 0===_?void 0:_.utm_campaign,utm_term:null===(v=e.utm_parameters)||void 0===v?void 0:v.utm_term,utm_content:null===(p=e.utm_parameters)||void 0===p?void 0:p.utm_content},description:e.description,html:(null===P||void 0===P?void 0:P.getValue())||"",common_styles:e.common_styles||"",emailtags:o||e.emailtags,tags:c,is_template:e.is_template||!1}).then((({error:t})=>{t&&re?(D.fromError("EMAIL_EDITING_ERROR",(0,l.Gy)(e),t),ie(!1)):d(e)}));(0,y.d)({event:"save",action:a?"save_email":"auto_save_email",email_id:e.id,project_id:x})},s={...e};ce.fire(s).finally((()=>{i?Promise.all(i).then((e=>{r(s,e,[])})):r(s,null,[])}))};ie(!0),ne?r(ne.id):Z({name:le}).then((async({data:t,error:a})=>{if(a)D.fromError("FOLDER_CREATING_ERROR",le,a),ie(!1);else{const{data:a,error:o}=await ae({projectId:x,emailtags:t.id});o?(D.fromError("EMAIL_CLONING_ERROR",(0,l.Gy)(e),o),ie(!1)):a&&r(a.emailtags&&a.emailtags[0])}})).catch((e=>console.error(e)))}),[te.status,ee,Q.status,J,e,t,Z,L,ae,x,q,G,$,re,P,de,ce]);(0,C.D3)(N.Kp,(0,o.useCallback)((e=>ue(e||"EXTERNAL")),[ue]));const me=(0,k.ml)(O.A.ON_NEXTBUTTON_CLICK_ID),_e=(0,k.ml)(O.A.ON_SAVEBUTTON_CLICK_ID);(0,o.useEffect)((()=>{re&&(setTimeout((()=>ue(re))),se(""))}),[re]);const ve=(0,o.useCallback)((e=>{(e.ctrlKey||e.metaKey)&&83===e.keyCode&&(e.preventDefault(),se(S))}),[ue]);(0,o.useEffect)((()=>(document.addEventListener("keydown",ve),()=>{document.removeEventListener("keydown",ve)})),[ve]);const pe=(0,o.useCallback)((e=>{const t=e.data.operation,a=e.data.action;t===A.Ru.APPLICATION_ACTION&&"save_email"===a&&se(S)}),[ue]);(0,E.A)(pe),(0,o.useEffect)((()=>{e.isNew&&te.isSuccess&&(ie(!0),L(v.GY.util.upsertQueryData("getEmail",te.data.id,{...te.data,lock:e.lock,subject:e.subject,preheader:e.preheader,description:e.description,html:(null===P||void 0===P?void 0:P.getValue())||"",project:e.project,tags:e.tags,utm_parameters:e.utm_parameters,parent_email:e.parent_email,common_styles:e.common_styles,renderGuid:e.renderGuid,is_inited:e.is_inited,isNew:!1})).then((()=>{w(`/projects/${te.data.project}/emails/${te.data.id}`),ie(!1),re&&D.success({id:"EMAIL_SAVING_SUCCESS",message:G("The email was successfully saved."),data:(0,l.Gy)(e)})})))}),[w,L,te,e.isNew,G,$,re,P]),(0,o.useEffect)((()=>{const e=setTimeout((()=>Y(!0)),1e4);return()=>clearTimeout(e)}),[Y]),(0,o.useEffect)((()=>{e.isNew&&!B&&U&&(ue(),Y(!1))}),[U,e,ue,B]);const he=Q.isLoading||(null===ae||void 0===ae?void 0:ae.isLoading)||te.isLoading||oe||a&&a.isLoading,Ee=V.saveButtonEnabled&&(0,I.jsx)(i.A,{title:G(F?"Save by \u2318S":"Save by Ctrl+S"),placement:"bottom",children:(0,I.jsx)(r.Ay,{type:V.nextButtonEnabled?"default":"primary",block:"false",className:"em-analytics__email-save",loading:he,icon:(0,I.jsx)(n.A,{}),onClick:async()=>{const t={...e,html:P.getValue()};try{!1!==await _e.fire(t)&&se("SAVE_BUTTON")}catch(a){D.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",(0,l.Gy)(t),a,!0)}},children:V.saveButtonText||G("Save")})},"save-button"),ge=V.nextButtonEnabled&&(0,I.jsx)(r.Ay,{type:"primary",block:"false",className:"em-analytics__email-save",icon:V.primaryCommandButtonIcon,loading:he,onClick:async()=>{const t={...e,html:P.getValue()};try{!1!==await me.fire(t)&&se("NEXT_BUTTON")}catch(a){D.fromError("NEXT_BUTTON_CLICK_EVENT_ERROR",(0,l.Gy)(t),a,!0)}},children:V.nextButtonText||G("Continue")},"next-button");return(0,I.jsx)(I.Fragment,{children:V.saveButtonEnabled&&V.nextButtonEnabled?(0,I.jsx)(s.A,{children:[Ee,ge]}):[Ee,ge]})};L.defaultProps={email:null,isEditableRights:null};const w=L}}]);
|