n8n-demo-component
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -51,3 +51,3 @@ /** | ||
*/ | ||
const it=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}{constructor(t){var i;if(super(t),t.type!==tt||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(t,[i]){var s,e;if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.et=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(s=this.et)||void 0===s?void 0:s.has(t))&&this.st.add(t);return this.render(i)}const o=t.element.classList;this.st.forEach((t=>{t in i||(o.remove(t),this.st.delete(t))}));for(const t in i){const s=!!i[t];s===this.st.has(t)||(null===(e=this.et)||void 0===e?void 0:e.has(t))||(s?(o.add(t),this.st.add(t)):(o.remove(t),this.st.delete(t)))}return T}});var st=function(t,i,s,e){for(var o,n=arguments.length,r=n<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(o=t[h])&&(r=(n<3?o(r):n>3?o(i,s,r):o(i,s))||r);return n>3&&r&&Object.defineProperty(i,s,r),r};let et=class extends F{constructor(){super(...arguments),this.workflow="{}",this.frame=!1,this.showCode=!1,this.nodeView=!1,this.insideIframe=!1,this.scrollX=0,this.scrollY=0}loadWorkflow(){try{const t=JSON.parse(this.workflow);if(!t)throw new Error("Missing workflow");if(!t.nodes||!Array.isArray(t.nodes))throw new Error("Must have an array of nodes");const i=this.shadowRoot.getElementById("int_iframe");this.shadowRoot.getElementById("json").textContent=JSON.stringify(t,void 0,2),i.contentWindow.postMessage(JSON.stringify({command:"openWorkflow",workflow:t}),"*")}catch(t){console.log("error invalid json")}}toggleCode(){this.showCode=!this.showCode,this.dispatchEvent(new CustomEvent("code-visibility-changed"))}onMouseEnter(){this.insideIframe=!0,this.scrollX=window.scrollX,this.scrollY=window.scrollY}onMouseLeave(){this.insideIframe=!1}connectedCallback(){super.connectedCallback(),window.addEventListener("message",(({data:t})=>{try{const i=JSON.parse(t);"n8nReady"===i.command?this.loadWorkflow():"openNDV"===i.command?this.nodeView=!0:"closeNDV"===i.command&&(this.nodeView=!1)}catch(t){this.nodeView=!1}})),document.addEventListener("scroll",(()=>{this.insideIframe&&window.scrollTo(this.scrollX,this.scrollY)}))}render(){return M` | ||
const it=(t=>(...i)=>({_$litDirective$:t,values:i}))(class extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}{constructor(t){var i;if(super(t),t.type!==tt||"class"!==t.name||(null===(i=t.strings)||void 0===i?void 0:i.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((i=>t[i])).join(" ")+" "}update(t,[i]){var s,e;if(void 0===this.st){this.st=new Set,void 0!==t.strings&&(this.et=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!(null===(s=this.et)||void 0===s?void 0:s.has(t))&&this.st.add(t);return this.render(i)}const o=t.element.classList;this.st.forEach((t=>{t in i||(o.remove(t),this.st.delete(t))}));for(const t in i){const s=!!i[t];s===this.st.has(t)||(null===(e=this.et)||void 0===e?void 0:e.has(t))||(s?(o.add(t),this.st.add(t)):(o.remove(t),this.st.delete(t)))}return T}});var st=function(t,i,s,e){for(var o,n=arguments.length,r=n<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e,h=t.length-1;h>=0;h--)(o=t[h])&&(r=(n<3?o(r):n>3?o(i,s,r):o(i,s))||r);return n>3&&r&&Object.defineProperty(i,s,r),r};let et=class extends F{constructor(){super(...arguments),this.workflow="{}",this.frame=!1,this.showCode=!1,this.nodeView=!1,this.insideIframe=!1,this.scrollX=0,this.scrollY=0}loadWorkflow(){try{const t=JSON.parse(this.workflow);if(!t)throw new Error("Missing workflow");if(!t.nodes||!Array.isArray(t.nodes))throw new Error("Must have an array of nodes");const i=this.shadowRoot.getElementById("int_iframe");this.shadowRoot.getElementById("json").textContent=JSON.stringify(t,void 0,2),i.contentWindow.postMessage(JSON.stringify({command:"openWorkflow",workflow:t}),"*")}catch(t){console.log(t),console.log(this.workflow),console.log("error invalid json")}}toggleCode(){this.showCode=!this.showCode,this.dispatchEvent(new CustomEvent("code-visibility-changed"))}onMouseEnter(){this.insideIframe=!0,this.scrollX=window.scrollX,this.scrollY=window.scrollY}onMouseLeave(){this.insideIframe=!1}connectedCallback(){super.connectedCallback(),window.addEventListener("message",(({data:t})=>{try{const i=JSON.parse(t);"n8nReady"===i.command?this.loadWorkflow():"openNDV"===i.command?this.nodeView=!0:"closeNDV"===i.command&&(this.nodeView=!1)}catch(t){this.nodeView=!1}})),document.addEventListener("scroll",(()=>{this.insideIframe&&window.scrollTo(this.scrollX,this.scrollY)}))}render(){return M` | ||
<div class="embedded_workflow" @mouseenter=${this.onMouseEnter} @mouseleave=${this.onMouseLeave} > | ||
@@ -54,0 +54,0 @@ <iframe class=${it({embedded_workflow_iframe_node_view:this.nodeView,embedded_workflow_iframe:!this.nodeView})} src="https://n8n-test3.herokuapp.com/workflows/demo" id="int_iframe"></iframe> |
{ | ||
"name": "n8n-demo-component", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "web component for workflow previews", | ||
@@ -5,0 +5,0 @@ "main": "n8n-demo.js", |
@@ -50,2 +50,4 @@ import { LitElement, html, css } from 'lit'; | ||
} catch (e) { | ||
console.log(e); | ||
console.log(this.workflow); | ||
console.log('error invalid json'); | ||
@@ -52,0 +54,0 @@ } |
Sorry, the diff of this file is not supported yet
3517387
94
5249