UNPKG

@aurigma/ui-framework

Version:

A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.

1 lines 5.04 kB
(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){"use strict";i.r(e),i.d(e,"AuWidgetTemplateEditor",(function(){return a})),i.d(e,"widget",(function(){return a}));var n=i(0),r=i(1),s=i(2),o=i(160),c=i(867),a=function(t){function e(){var e=t.call(this)||this;return e._eventsInited=!1,e._isEditorInited=!1,e.script="",e.styles="",e._initIFrame=e._initIFrame.bind(e),e.resourcesPromise=e._loadResources(),e}return Object(n.d)(e,t),e.prototype.updateParams=function(t,e){},e.prototype.updateParamsAsync=function(e,i){return Object(n.b)(this,void 0,void 0,(function(){var r;return Object(n.e)(this,(function(n){switch(n.label){case 0:return[4,t.prototype.updateParamsAsync.call(this,e,i)];case 1:return n.sent(),[4,this.resourcesPromise];case 2:return n.sent(),!e.config||this._isEditorInited?[3,4]:[4,this._initIFrame()];case 3:n.sent(),this._isEditorInited=!0,n.label=4;case 4:return r=this,[4,this._itemPromise()];case 5:return r._element=n.sent(),[4,this._initSubscribers(this._element)];case 6:return n.sent(),this._element.configuration=Object.assign({language:this.language},e.config),e.stateId?[4,this.setStateId(e.stateId)]:[3,8];case 7:return n.sent(),[3,11];case 8:return e.product?[4,this.setProduct(e.product)]:[3,10];case 9:return n.sent(),[3,11];case 10:console.warn("stateId or product missing."),n.label=11;case 11:return[2]}}))}))},e.prototype.getProduct=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){return[2,this._element.getProductJson()]}))}))},e.prototype.setProduct=function(t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return this._element.setProductJson(t),[2]}))}))},e.prototype.setStateId=function(t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){switch(e.label){case 0:return[4,this._element.setStateId(t)];case 1:return e.sent(),[2]}}))}))},e.prototype.setToken=function(t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return this._element.setToken(t),[2]}))}))},e.prototype.saveProduct=function(){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(t){switch(t.label){case 0:return[4,this._element.saveProduct()];case 1:return t.sent(),[2]}}))}))},e.prototype._itemPromise=function(){var t=this;return new Promise((function(e){if(t._element)e(t._element);else{var i=function(){setTimeout((function(){return Object(n.b)(t,void 0,void 0,(function(){var t;return Object(n.e)(this,(function(n){return this._iframeDoc&&(t=this._iframeDoc.querySelector("au-template-editor"))&&(window.Aurigma=Object.assign(window.Aurigma,this._iframeWin.contentWindow.Aurigma),e(t)),this._element||i(),[2]}))}))}),200)};i()}}))},e.prototype._loadResources=function(){return Object(n.b)(this,void 0,void 0,(function(){var t,e,i,s,o,c;return Object(n.e)(this,(function(a){switch(a.label){case 0:return t=Date.now(),e="".concat(r.a.getPatchedUrl("static/template-editor/script.html"),"?t=").concat(t),i="".concat(r.a.getPatchedUrl("static/template-editor/style.html"),"?t=").concat(t),[4,Promise.all([r.a.loadHtml(e),r.a.loadHtml(i)])];case 1:return s=n.h.apply(void 0,[a.sent(),2]),o=s[0],c=s[1],this.script=o,this.styles=c,[2]}}))}))},e.prototype._initIFrame=function(){return Object(n.b)(this,void 0,void 0,(function(){var t,e,i;return Object(n.e)(this,(function(n){return t=this.querySelectorShadow("#frameID"),e=t||t.contentWindow,(i=t.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]}))}))},e.prototype._monkeyPatchScript=function(){this.script=this.script.replace("TextWhizzJS.wasm","".concat(r.a.getPatchedUrl("static/template-editor/TextWhizzJS.wasm"))),this.script=this.script.replace("/assets/sprite.svg","".concat(r.a.getPatchedUrl("static/template-editor/assets/sprite.svg")))},e.prototype._initSubscribers=function(t){return Object(n.b)(this,void 0,void 0,(function(){return Object(n.e)(this,(function(e){return this._eventsInited||(this._eventsInited=!0,this.$productSaved=t.$saved(),this.$productChanged=t.$changed()),[2]}))}))},Object(n.c)([Object(s.a)("au-widget-template-editor",c),Object(n.g)("design:paramtypes",[])],e)}(o.c)}}]);