PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / assets / chunks / ServerSidePreview.js

ServerSidePreview.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at assets/chunks/ServerSidePreview.js

2 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{h as a,v as g,j as b,e as d,o as u,b as h,d as s,x as _}from"./vue.esm-bundler.js?ver=1.6.4";import{u as E}from"./useElementor.js?ver=1.6.4";import"./ServerSidePreview.vue_vue_type_style_index_0_scoped_42048dbb_lang.js?ver=1.6.4";import{_ as k}from"./_plugin-vue_export-helper.js?ver=1.6.4";import{a as L}from"./add-query-args.js?ver=1.6.4";const S={style:{position:"relative",width:"100%",height:"600px"}},T={key:0,style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",background:"rgba(255, 255, 255, 0.8)",display:"flex","align-items":"center","justify-content":"center","z-index":"20"}},x=["src"],P={__name:"ServerSidePreview",props:{block:{type:String,required:!0},attributes:{type:Object,required:!0}},setup(f){const n=f;E();const t=a(null),r=a(!1),p=a({...n.attributes}),l=(e=n.attributes)=>window.location.origin+L("",{"fluent-cart":"block-render",block:n.block,context:"edit",attributes:e}),m=async e=>{if(t.value&&t.value.contentWindow)try{t.value.contentWindow.postMessage({type:"UPDATE_ATTRIBUTES",attributes:e,block:n.block},window.location.origin)}catch{await v()}},v=async()=>{if(!t.value)return;r.value=!0;const e=await w();t.value.src=l(),await new Promise(o=>{const i=()=>{t.value.removeEventListener("load",i),o()};t.value.addEventListener("load",i)}),e&&await y(e),r.value=!1},w=async()=>{var e;try{if((e=t.value)!=null&&e.contentWindow)return{scrollTop:t.value.contentDocument.documentElement.scrollTop,scrollLeft:t.value.contentDocument.documentElement.scrollLeft}}catch{return null}},y=async e=>{var o;try{await _(),(o=t.value)!=null&&o.contentWindow&&e&&t.value.contentWindow.scrollTo(e.scrollLeft,e.scrollTop)}catch{}};g(()=>n.attributes,async(e,o)=>{JSON.stringify(e)!==JSON.stringify(o)&&(p.value={...e},await m(e))},{deep:!0});const c=e=>{e.origin===window.location.origin&&(e.data.type==="IFRAME_READY"||e.data.type==="UPDATE_COMPLETE"&&(r.value=!1))};return typeof window<"u"&&window.addEventListener("message",c),b(()=>{typeof window<"u"&&window.removeEventListener("message",c)}),(e,o)=>(u(),d("div",S,[r.value?(u(),d("div",T,o[0]||(o[0]=[s("div",null,"Loading...",-1)]))):h("",!0),s("iframe",{class:"nuhel",ref_key:"iframeRef",ref:t,src:l(),style:{width:"100%",height:"100%",border:"none",transition:"opacity 0.3s ease"}},null,8,x),o[1]||(o[1]=s("div",{style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",cursor:"pointer",background:"transparent","z-index":"10"}},null,-1))]))}},M=k(P,[["__scopeId","data-v-42048dbb"]]);export{M as S};
2