UNPKG

@creaditor/newsletter-starterkit

Version:

Creaditor Newsletter Editor - Starterkit for creating beautiful email newsletters

12 lines 2.83 kB
"use strict";(("undefined"!=typeof self?self:this).webpackChunkCreaditor=("undefined"!=typeof self?self:this).webpackChunkCreaditor||[]).push([[9001],{59001:(t,e,i)=>{i.r(e),i.d(e,{DesignFactory:()=>l});var o=i(56666),r=i(40949),n=i(21293),s=(i(58860),i(45607)),d=i(59320),c=i(70235);i.e(8312).then(i.bind(i,8312));class l extends n.oi{constructor(){super(),this.lastEditor=null,c.h.set({injectEditor:t=>{this.injected=!0,this.lastEditor=this.editor,this.backToEditor=this.editor,this.editor=t}}),this.editor=n.dy`<cdtr-ilustration-preference width="200px" height="200px" ></cdtr-ilustration-preference>`,this.delayer=new d.Z,this.connect=this.connect.bind(this),this.editors={block:{selector:"block-editor",load:()=>i.e(9766).then(i.bind(i,29766)),component:null},no_editor:{selector:"cdtr-no-component",load:()=>i.e(6491).then(i.bind(i,36491)),component:null,attrs:{style:"margin:auto;display:block;max-width:150px;margin-top:30px;"}}},this.type=null,s.Z.on("select",this.connect)}connect(t){let{editor:e}=t;if(!e)return;let i=e.type;if("string"!=typeof i)return;if(this.editor?.type===i)return;if(!this.editors[i]){const t=c.h.get("config","editor","configure","plugins");if(Array.isArray(t)){const e=t.find((t=>t.name===i));if(e&&"function"==typeof e.createEditor){this.editor=document.createElement("cdtr-editor-builder"),this.editor.type=i;const t=e.createEditor();return void(t&&(this.editor.editors=t.layout,t!==this.backToEditor&&this.lastEditor&&(this.lastEditor=null)))}}i="no_editor"}this.type=i;const o=(0,r.Z)("div",null,(0,r.Z)("cdtr-block-loader",null),(0,r.Z)("cdtr-title",{style:"text-align:center;"},(0,r.Z)("lang-text",{text:"please_wait_downloading_new_version"})));this.editors[i]&&!this.editors[i].component&&(this.editors[i].load().then((()=>{if(o.remove(),this.editors[i].attrs)for(const t in this.editors[i].attrs)if(Object.hasOwnProperty.call(this.editors[i].attrs,t)){const e=this.editors[i].attrs[t];this.editors[i].component[t]=e}})),this.editors[i].component=document.createElement(this.editors[i].selector),this.editors[i].component.appendChild(o)),this.editors[i].component&&(this.editor=this.editors[i].component)}goBack(){this.lastEditor&&(this.editor=this.lastEditor,this.lastEditor=null)}createRenderRoot(){return this}render(){return n.dy` ${this.lastEditor?n.dy` <cdtr-row justify="end"> <paper-button @click=${this.goBack} style="margin:.5rem 0;padding:0;min-width:0;direction:var(--direction-locale);" ><cdtr-arrow-icon></cdtr-arrow-icon ><lang-text style="font-weight:700;" text="go_back"></lang-text ></paper-button> </cdtr-row>`:""} ${this.editor}`}}(0,o.Z)(l,"properties",{type:{type:String},editor:{type:Object},injected:{type:Boolean}}),customElements.define("design-factory",l)}}]);