@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 4.95 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[49],{867:function(t,e){t.exports='<style>\n :host {\n width: 100%;\n height: 100%;\n }\n</style>\n\n<iframe id="frameID" width="100%" height="100%" style="border: none" allow="clipboard-read; clipboard-write"></iframe>\n'},909:function(t,e,i){i.r(e),i.d(e,"AuWidgetTemplateEditor",function(){return c}),i.d(e,"widget",function(){return c});var r,s=i(0),o=i(1),e=i(2),n=i(160),i=i(867),c=(r=n.c,Object(s.d)(a,r),a.prototype.updateParams=function(t,e){},a.prototype.updateParamsAsync=function(i,n){return Object(s.b)(this,void 0,void 0,function(){var e;return Object(s.e)(this,function(t){switch(t.label){case 0:return[4,r.prototype.updateParamsAsync.call(this,i,n)];case 1:return t.sent(),[4,this.resourcesPromise];case 2:return t.sent(),!i.config||this._isEditorInited?[3,4]:[4,this._initIFrame()];case 3:t.sent(),this._isEditorInited=!0,t.label=4;case 4:return[4,(e=this)._itemPromise()];case 5:return e._element=t.sent(),[4,this._initSubscribers(this._element)];case 6:return(t.sent(),this._element.configuration=Object.assign({language:this.language},i.config),i.stateId)?[4,this.setStateId(i.stateId)]:[3,8];case 7:return t.sent(),[3,11];case 8:return i.product?[4,this.setProduct(i.product)]:[3,10];case 9:return t.sent(),[3,11];case 10:console.warn("stateId or product missing."),t.label=11;case 11:return[2]}})})},a.prototype.getProduct=function(){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){return[2,this._element.getProductJson()]})})},a.prototype.setProduct=function(e){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){return this._element.setProductJson(e),[2]})})},a.prototype.setStateId=function(e){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){switch(t.label){case 0:return[4,this._element.setStateId(e)];case 1:return t.sent(),[2]}})})},a.prototype.setToken=function(e){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){return this._element.setToken(e),[2]})})},a.prototype.saveProduct=function(){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){switch(t.label){case 0:return[4,this._element.saveProduct()];case 1:return t.sent(),[2]}})})},a.prototype._itemPromise=function(){var t=this;return new Promise(function(i){var n;t._element?i(t._element):(n=function(){setTimeout(function(){return Object(s.b)(t,void 0,void 0,function(){var e;return Object(s.e)(this,function(t){return this._iframeDoc&&(e=this._iframeDoc.querySelector("au-template-editor"))&&(window.Aurigma=Object.assign(window.Aurigma,this._iframeWin.contentWindow.Aurigma),i(e)),this._element||n(),[2]})})},200)})()})},a.prototype._loadResources=function(){return Object(s.b)(this,void 0,void 0,function(){var e,i,n;return Object(s.e)(this,function(t){switch(t.label){case 0:return i=Date.now(),e="".concat(o.a.getPatchedUrl("static/template-editor/script.html"),"?t=").concat(i),i="".concat(o.a.getPatchedUrl("static/template-editor/style.html"),"?t=").concat(i),[4,Promise.all([o.a.loadHtml(e),o.a.loadHtml(i)])];case 1:return e=s.h.apply(void 0,[t.sent(),2]),i=e[0],n=e[1],this.script=i,this.styles=n,[2]}})})},a.prototype._initIFrame=function(){return Object(s.b)(this,void 0,void 0,function(){var e,i;return Object(s.e)(this,function(t){return i=this.querySelectorShadow("#frameID"),e=i||i.contentWindow,(i=i.contentDocument||e.document).write('<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet" />'),i.write('<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />'),this._monkeyPatchScript(),i.write(this.script),i.write(this.styles),i.write("<style> .mat-button-toggle-button { height: 100%; } </style>"),i.write("<style> html { overflow: hidden; } </style>"),i.write('\n <div style="width:100%;height:100%">\n <au-template-editor id="templateeditor"></au-template-editor>\n </div>\n '),this._iframeDoc=i,this._iframeWin=e,[2]})})},a.prototype._monkeyPatchScript=function(){this.script=this.script.replace("TextWhizzJS.wasm","".concat(o.a.getPatchedUrl("static/template-editor/TextWhizzJS.wasm"))),this.script=this.script.replace("/assets/sprite.svg","".concat(o.a.getPatchedUrl("static/template-editor/assets/sprite.svg")))},a.prototype._initSubscribers=function(e){return Object(s.b)(this,void 0,void 0,function(){return Object(s.e)(this,function(t){return this._eventsInited||(this._eventsInited=!0,this.$productSaved=e.$saved(),this.$productChanged=e.$changed()),[2]})})},Object(s.c)([Object(e.a)("au-widget-template-editor",i),Object(s.g)("design:paramtypes",[])],a));function a(){var t=r.call(this)||this;return t._eventsInited=!1,t._isEditorInited=!1,t.script="",t.styles="",t._initIFrame=t._initIFrame.bind(t),t.resourcesPromise=t._loadResources(),t}}}]);