@grapesjs/studio-sdk-plugins 1.0.12 → 1.0.13-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iconifyComponent/index.d.ts +3 -0
- package/dist/iconifyComponent/types.d.ts +42 -0
- package/dist/iconifyComponent/typesSchema.d.ts +19 -0
- package/dist/iconifyComponent/utils.d.ts +18 -0
- package/dist/index.cjs.d.ts +2 -0
- package/dist/index.cjs.js +182 -170
- package/dist/index.d.ts +2 -0
- package/dist/index.es.d.ts +2 -0
- package/dist/index.es.js +21738 -16239
- package/dist/index.umd.js +182 -170
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +29 -30
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +97 -96
- package/dist/prosemirror/index.umd.js +6 -6
- package/dist/prosemirror/types.d.ts +3 -3
- package/dist/rteTinyMce/index.cjs.js +81 -71
- package/dist/rteTinyMce/index.es.js +9747 -4641
- package/dist/rteTinyMce/index.umd.js +81 -71
- package/dist/swiperComponent/index.cjs.js +3 -3
- package/dist/swiperComponent/index.es.js +50 -53
- package/dist/swiperComponent/index.umd.js +3 -3
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +121 -121
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/assetProviders/youtube.d.ts +3 -0
- package/dist/youtubeAssetProvider/index.cjs.d.ts +3 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -0
- package/dist/youtubeAssetProvider/index.d.ts +3 -0
- package/dist/youtubeAssetProvider/index.es.d.ts +3 -0
- package/dist/youtubeAssetProvider/index.es.js +242 -0
- package/dist/youtubeAssetProvider/index.umd.js +1 -0
- package/dist/youtubeAssetProvider/types.d.ts +202 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require("grapesjs");const ie="app.grapesjs.com",re="app-stage.grapesjs.com",Y=[ie,re,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:start",he="license:check:end",ge=()=>typeof window<"u",be=({isDev:e,isStage:l})=>`${e?"":`https://${l?re:ie}`}/api`,me=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{});async function de({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:s,body:u}){const p=`${l||be({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=s?new URLSearchParams(s).toString():"",i=c?`?${c}`:"",b=await fetch(`${p}${i}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const ee={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function ye(e){const l=e;return l.init=a=>n=>e(n,a),l}const ve=e=>ye(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:s}){let u="",r=!1;const p=me(),h=i=>{console.warn("Cleanup plugin:",a,"Reason:",i),s()},c=(i={})=>{var L;const{error:b,sdkLicense:C}=i,T=(L=i.plan)==null?void 0:L.category;if(!(C||i.license)||b)h(b||"Invalid license");else if(T){const G=ee[l],V=ee[T];G>V&&h({pluginRequiredPlan:l,licensePlan:T})}};e.on(ue,i=>{u=i==null?void 0:i.baseApiUrl,r=!0}),e.on(he,i=>{c(i)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const i=await Te({licenseKey:n,pluginName:a,baseApiUrl:u});i&&c(i)}else h("The `licenseKey` option not provided")}},2e3)}async function Te(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await de({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const z=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var P=(e=>(e.image="image",e.video="video",e.external="external",e))(P||{});const k="lightGallery",te=`${k}-item`,D="data-lightgallery",ae=`${D}-item`,H="toggle",I={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},B={propKeys:[],props:{},traits:[]},M=(e,l={})=>{var s;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(s=h[c])==null||s.forEach(i=>{const b=i.id||i.name;a[b]=i.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),s=a.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=s[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},W=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const s=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(s,()=>Z(e,a)),Z(e,a)})},we=(e,l,a)=>{const s=e.getTrait(l).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},Se={[H]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},xe={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},ke={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ie={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",U="data-iframe",R={name:"href",type:"file",label:"Image Source"},N={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},F={name:"data-poster",label:"Video Poster",type:"file"},ne={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Le={[H]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var s,u;const a=l.target,n=(s=a==null?void 0:a.closestType(k))==null?void 0:s.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[R],video:[N,F],external:[ne]},options:[{id:"image",label:R.label||"",icon:I.image},{id:"video",label:N.label||"",icon:I.video},{id:"external",label:ne.label||"",icon:I.external}]},subHtml:ce},Ae="lightGalleryComponent",le="lgThumbnail",Pe="lgVideo",oe="lgAutoplay",se="lgZoom",A="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ee=function(e,l={}){const{Blocks:a,Components:n}=e,s="LightGallery",u="LightGallery Item",r={toolbarIconOpen:I.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[le,Pe,oe,se],cdnScript:[`${A}/lightgallery.min.js`,`${A}/plugins/thumbnail/lg-thumbnail.min.js`,`${A}/plugins/video/lg-video.min.js`,`${A}/plugins/autoplay/lg-autoplay.min.js`,`${A}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${A}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,i=function(t){const o=this,g=window,{plugins:d,cdnScript:w,cdnStyle:O,inline:J,lgLicenseKey:pe,...y}=t||{},S=m=>isNaN(m)?void 0:parseInt(m,10),Q=()=>{var $;const m={...y,licenseKey:pe,speed:S(y.speed),startAnimationDuration:S(y.startAnimationDuration),thumbMargin:S(y.thumbMargin),thumbWidth:S(y.thumbWidth),slideShowInterval:S(y.slideShowInterval),scale:S(y.scale),enableZoomAfter:S(y.enableZoomAfter),plugins:(d||[]).map(K=>g[K])};J&&(m.container=o,m.closable=!1);const j=($=g.lightGallery)==null?void 0:$.call(g,o,m);J&&j.openGallery()};if(g.lightGallery)Q();else{const{head:m}=document,j=Array.isArray(w)?[...w]:[w],$=Array.isArray(O)?[...O]:[O],K=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",m.appendChild(v),K(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),m.appendChild(v)}else Q()};K($),X(j)}},b=t=>{const o=t.getTrait(H);if(!h||!o)return;const{toolbar:g}=t,d={id:H,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find(O=>O.id===d.id)&&(g==null||g.unshift(d))};let C=[];const T=r.plugins||[],_=M(Se),L=T.includes(le)?M(xe):B,G=T.includes(oe)?M(ke):B,V=T.includes(se)?M(Ie):B;n.addType(k,{block:p&&{label:s,media:I.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>z(t,D),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:I.gallery,draggable:(t,o)=>!o.is(k),attributes:{[D]:!0},components:{type:te},script:i,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",..._.propKeys,...L.propKeys,...G.propKeys,...V.propKeys],..._.props,...L.props,...G.props,...V.props,traits:[..._.traits,...L.traits,...G.traits,...V.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){const t=n.events.scriptUnmount;t&&this.listenTo(this.model,t,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();C=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();C.forEach(o=>this.em.Canvas.addSpot(o.attributes)),C=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const q=M(Le);n.addType(te,{isComponent:t=>z(t,ae)||t.tagName==="A"&&z(t.parentElement,D),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:I.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...q.props,traits:[...q.traits]},init(){const t=[f].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),we(this,f,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ce.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(k))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[f]||g){Z(this,f);const d=this.getTrait(f).getValue();if(d===P.image){this.removeAttributes([N.name,F.name,U]);const w=this.getTrait(R.name);w.setValue(w.getValue()||c)}else d===P.video?this.removeAttributes([U]):d===P.external&&this.addAttributes({[U]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[U]?this.set(f,P.external):(t[N.name]||t[F.name])&&this.set(f,P.video)}}}),fe({editor:e,plan:E.startup,licenseKey:r.licenseKey,pluginName:Ae,cleanup:()=>{a.remove(k),n.removeType(k)}})},Ce=ve(Ee);module.exports=Ce;
|
|
1
|
+
"use strict";require("grapesjs");const ie="app.grapesjs.com",re="app-stage.grapesjs.com",Y=[ie,re,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:start",he="license:check:end",ge=()=>typeof window<"u",be=({isDev:e,isStage:l})=>`${e?"":`https://${l?re:ie}`}/api`,de=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{});async function me({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:s,body:u}){const p=`${l||be({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=s?new URLSearchParams(s).toString():"",i=c?`?${c}`:"",b=await fetch(`${p}${i}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const ee={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function ye(e){const l=e;return l.init=a=>n=>e(n,a),l}const ve=e=>ye(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:s}){let u="",r=!1;const p=de(),h=i=>{console.warn("Cleanup plugin:",a,"Reason:",i),s()},c=(i={})=>{var L;const{error:b,sdkLicense:C}=i,T=(L=i.plan)==null?void 0:L.category;if(!(C||i.license)||b)h(b||"Invalid license");else if(T){const G=ee[l],V=ee[T];G>V&&h({pluginRequiredPlan:l,licensePlan:T})}};e.on(ue,i=>{u=i==null?void 0:i.baseApiUrl,r=!0}),e.on(he,i=>{c(i)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const i=await Te({licenseKey:n,pluginName:a,baseApiUrl:u});i&&c(i)}else h("The `licenseKey` option not provided")}},2e3)}async function Te(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await me({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const z=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var P=(e=>(e.image="image",e.video="video",e.external="external",e))(P||{});const k="lightGallery",te=`${k}-item`,H="data-lightgallery",ae=`${H}-item`,U="toggle",I={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},B={propKeys:[],props:{},traits:[]},M=(e,l={})=>{var s;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(s=h[c])==null||s.forEach(i=>{const b=i.id||i.name;a[b]=i.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),s=a.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=s[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},W=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const s=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(s,()=>Z(e,a)),Z(e,a)})},we=(e,l,a)=>{const s=e.getTrait(l).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},Se={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},xe={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},ke={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ie={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",D="data-iframe",R={name:"href",type:"file",label:"Image Source"},N={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},F={name:"data-poster",label:"Video Poster",type:"file"},ne={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Le={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var s,u;const a=l.target,n=(s=a==null?void 0:a.closestType(k))==null?void 0:s.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[R],video:[N,F],external:[ne]},options:[{id:"image",label:R.label||"",icon:I.image},{id:"video",label:N.label||"",icon:I.video},{id:"external",label:ne.label||"",icon:I.external}]},subHtml:ce},Ae="lightGalleryComponent",le="lgThumbnail",Pe="lgVideo",oe="lgAutoplay",se="lgZoom",A="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ee=function(e,l={}){const{Blocks:a,Components:n}=e,s="LightGallery",u="LightGallery Item",r={toolbarIconOpen:I.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[le,Pe,oe,se],cdnScript:[`${A}/lightgallery.min.js`,`${A}/plugins/thumbnail/lg-thumbnail.min.js`,`${A}/plugins/video/lg-video.min.js`,`${A}/plugins/autoplay/lg-autoplay.min.js`,`${A}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${A}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,i=function(t){const o=this,g=window,{plugins:m,cdnScript:w,cdnStyle:O,inline:J,lgLicenseKey:pe,...y}=t||{},S=d=>isNaN(d)?void 0:parseInt(d,10),Q=()=>{var $;const d={...y,licenseKey:pe,speed:S(y.speed),startAnimationDuration:S(y.startAnimationDuration),thumbMargin:S(y.thumbMargin),thumbWidth:S(y.thumbWidth),slideShowInterval:S(y.slideShowInterval),scale:S(y.scale),enableZoomAfter:S(y.enableZoomAfter),plugins:(m||[]).map(K=>g[K])};J&&(d.container=o,d.closable=!1);const j=($=g.lightGallery)==null?void 0:$.call(g,o,d);J&&j.openGallery()};if(g.lightGallery)Q();else{const{head:d}=document,j=Array.isArray(w)?[...w]:[w],$=Array.isArray(O)?[...O]:[O],K=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",d.appendChild(v),K(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),d.appendChild(v)}else Q()};K($),X(j)}},b=t=>{const o=t.getTrait(U);if(!h||!o)return;const{toolbar:g}=t,m={id:U,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find(O=>O.id===m.id)&&(g==null||g.unshift(m))};let C=[];const T=r.plugins||[],_=M(Se),L=T.includes(le)?M(xe):B,G=T.includes(oe)?M(ke):B,V=T.includes(se)?M(Ie):B;n.addType(k,{block:p&&{label:s,media:I.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>z(t,H),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:I.gallery,draggable:(t,o)=>!o.is(k),attributes:{[H]:!0},components:{type:te},script:i,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",..._.propKeys,...L.propKeys,...G.propKeys,...V.propKeys],..._.props,...L.props,...G.props,...V.props,traits:[..._.traits,...L.traits,...G.traits,...V.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,n.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();C=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();C.forEach(o=>this.em.Canvas.addSpot(o.attributes)),C=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const q=M(Le);n.addType(te,{isComponent:t=>z(t,ae)||t.tagName==="A"&&z(t.parentElement,H),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:I.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...q.props,traits:[...q.traits]},init(){const t=[f].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),we(this,f,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ce.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(k))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[f]||g){Z(this,f);const m=this.getTrait(f).getValue();if(m===P.image){this.removeAttributes([N.name,F.name,D]);const w=this.getTrait(R.name);w.setValue(w.getValue()||c)}else m===P.video?this.removeAttributes([D]):m===P.external&&this.addAttributes({[D]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[D]?this.set(f,P.external):(t[N.name]||t[F.name])&&this.set(f,P.video)}}}),fe({editor:e,plan:E.startup,licenseKey:r.licenseKey,pluginName:Ae,cleanup:()=>{a.remove(k),n.removeType(k)}})},Ce=ve(Ee);module.exports=Ce;
|
|
@@ -10,12 +10,12 @@ const ie = "app.grapesjs.com", re = "app-stage.grapesjs.com", Y = [
|
|
|
10
10
|
// For stackblitz.com demos
|
|
11
11
|
"-sandpack.codesandbox.io"
|
|
12
12
|
// For Sandpack demos
|
|
13
|
-
], ue = "license:check:start", he = "license:check:end", ge = () => typeof window < "u", be = ({ isDev: e, isStage: l }) => `${e ? "" : `https://${l ? re : ie}`}/api`,
|
|
13
|
+
], ue = "license:check:start", he = "license:check:end", ge = () => typeof window < "u", be = ({ isDev: e, isStage: l }) => `${e ? "" : `https://${l ? re : ie}`}/api`, de = () => {
|
|
14
14
|
const e = ge() && window.location.hostname;
|
|
15
15
|
return !!e && (Y.includes(e) || Y.some((l) => e.endsWith(l)));
|
|
16
16
|
};
|
|
17
17
|
var E = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(E || {});
|
|
18
|
-
async function
|
|
18
|
+
async function me({
|
|
19
19
|
path: e,
|
|
20
20
|
baseApiUrl: l,
|
|
21
21
|
method: a = "GET",
|
|
@@ -55,7 +55,7 @@ async function fe({
|
|
|
55
55
|
cleanup: s
|
|
56
56
|
}) {
|
|
57
57
|
let u = "", r = !1;
|
|
58
|
-
const p =
|
|
58
|
+
const p = de(), h = (i) => {
|
|
59
59
|
console.warn("Cleanup plugin:", a, "Reason:", i), s();
|
|
60
60
|
}, c = (i = {}) => {
|
|
61
61
|
var L;
|
|
@@ -85,7 +85,7 @@ async function fe({
|
|
|
85
85
|
async function Te(e) {
|
|
86
86
|
const { licenseKey: l, pluginName: a, baseApiUrl: n } = e;
|
|
87
87
|
try {
|
|
88
|
-
return (await
|
|
88
|
+
return (await me({
|
|
89
89
|
baseApiUrl: n,
|
|
90
90
|
path: `/sdk/${l || "na"}`,
|
|
91
91
|
method: "POST",
|
|
@@ -103,7 +103,7 @@ const z = (e, l) => {
|
|
|
103
103
|
return !!((a = e == null ? void 0 : e.hasAttribute) != null && a.call(e, l));
|
|
104
104
|
};
|
|
105
105
|
var P = /* @__PURE__ */ ((e) => (e.image = "image", e.video = "video", e.external = "external", e))(P || {});
|
|
106
|
-
const k = "lightGallery", te = `${k}-item`,
|
|
106
|
+
const k = "lightGallery", te = `${k}-item`, H = "data-lightgallery", ae = `${H}-item`, U = "toggle", I = {
|
|
107
107
|
image: '<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',
|
|
108
108
|
video: '<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',
|
|
109
109
|
gallery: '<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',
|
|
@@ -158,7 +158,7 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
158
158
|
// step: 50,
|
|
159
159
|
// min: 0
|
|
160
160
|
// },
|
|
161
|
-
[
|
|
161
|
+
[U]: {
|
|
162
162
|
type: "button",
|
|
163
163
|
label: "Toggle Gallery",
|
|
164
164
|
command: (e, l) => {
|
|
@@ -471,7 +471,7 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
471
471
|
]
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
-
}, f = "sourceType",
|
|
474
|
+
}, f = "sourceType", D = "data-iframe", R = {
|
|
475
475
|
name: "href",
|
|
476
476
|
type: "file",
|
|
477
477
|
label: "Image Source"
|
|
@@ -493,7 +493,7 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
493
493
|
placeholder: "My caption",
|
|
494
494
|
changeProp: !1
|
|
495
495
|
}, Le = {
|
|
496
|
-
[
|
|
496
|
+
[U]: {
|
|
497
497
|
type: "button",
|
|
498
498
|
label: "Toggle Gallery",
|
|
499
499
|
command: (e, l) => {
|
|
@@ -541,9 +541,9 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
541
541
|
cdnStyle: `${A}/css/lightgallery-bundle.min.css`,
|
|
542
542
|
...l
|
|
543
543
|
}, { block: p, toolbarIconOpen: h, defaultSrc: c } = r, i = function(t) {
|
|
544
|
-
const o = this, g = window, { plugins:
|
|
544
|
+
const o = this, g = window, { plugins: m, cdnScript: w, cdnStyle: O, inline: J, lgLicenseKey: pe, ...y } = t || {}, S = (d) => isNaN(d) ? void 0 : parseInt(d, 10), Q = () => {
|
|
545
545
|
var $;
|
|
546
|
-
const
|
|
546
|
+
const d = {
|
|
547
547
|
...y,
|
|
548
548
|
licenseKey: pe,
|
|
549
549
|
speed: S(y.speed),
|
|
@@ -553,38 +553,38 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
553
553
|
slideShowInterval: S(y.slideShowInterval),
|
|
554
554
|
scale: S(y.scale),
|
|
555
555
|
enableZoomAfter: S(y.enableZoomAfter),
|
|
556
|
-
plugins: (
|
|
556
|
+
plugins: (m || []).map((K) => g[K])
|
|
557
557
|
};
|
|
558
|
-
J && (
|
|
559
|
-
const j = ($ = g.lightGallery) == null ? void 0 : $.call(g, o,
|
|
558
|
+
J && (d.container = o, d.closable = !1);
|
|
559
|
+
const j = ($ = g.lightGallery) == null ? void 0 : $.call(g, o, d);
|
|
560
560
|
J && j.openGallery();
|
|
561
561
|
};
|
|
562
562
|
if (g.lightGallery)
|
|
563
563
|
Q();
|
|
564
564
|
else {
|
|
565
|
-
const { head:
|
|
565
|
+
const { head: d } = document, j = Array.isArray(w) ? [...w] : [w], $ = Array.isArray(O) ? [...O] : [O], K = (x) => {
|
|
566
566
|
if (x.length) {
|
|
567
567
|
const v = document.createElement("link");
|
|
568
|
-
v.href = x.shift(), v.rel = "stylesheet",
|
|
568
|
+
v.href = x.shift(), v.rel = "stylesheet", d.appendChild(v), K(x);
|
|
569
569
|
}
|
|
570
570
|
}, X = (x) => {
|
|
571
571
|
if (x.length) {
|
|
572
572
|
const v = document.createElement("script");
|
|
573
|
-
v.src = x.shift(), v.onerror = v.onload = X.bind(null, x),
|
|
573
|
+
v.src = x.shift(), v.onerror = v.onload = X.bind(null, x), d.appendChild(v);
|
|
574
574
|
} else
|
|
575
575
|
Q();
|
|
576
576
|
};
|
|
577
577
|
K($), X(j);
|
|
578
578
|
}
|
|
579
579
|
}, b = (t) => {
|
|
580
|
-
const o = t.getTrait(
|
|
580
|
+
const o = t.getTrait(U);
|
|
581
581
|
if (!h || !o) return;
|
|
582
|
-
const { toolbar: g } = t,
|
|
583
|
-
id:
|
|
582
|
+
const { toolbar: g } = t, m = {
|
|
583
|
+
id: U,
|
|
584
584
|
label: h,
|
|
585
585
|
command: () => setTimeout(() => o.runCommand(), 100)
|
|
586
586
|
};
|
|
587
|
-
!g.find((O) => O.id ===
|
|
587
|
+
!g.find((O) => O.id === m.id) && (g == null || g.unshift(m));
|
|
588
588
|
};
|
|
589
589
|
let C = [];
|
|
590
590
|
const T = r.plugins || [], _ = M(Se), L = T.includes(le) ? M(xe) : B, G = T.includes(oe) ? M(ke) : B, V = T.includes(se) ? M(Ie) : B;
|
|
@@ -596,14 +596,14 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
596
596
|
select: !0,
|
|
597
597
|
...r.block
|
|
598
598
|
},
|
|
599
|
-
isComponent: (t) => z(t,
|
|
599
|
+
isComponent: (t) => z(t, H),
|
|
600
600
|
extendFn: ["init", "initToolbar"],
|
|
601
601
|
model: {
|
|
602
602
|
defaults: {
|
|
603
603
|
name: s,
|
|
604
604
|
icon: I.gallery,
|
|
605
605
|
draggable: (t, o) => !o.is(k),
|
|
606
|
-
attributes: { [
|
|
606
|
+
attributes: { [H]: !0 },
|
|
607
607
|
components: { type: te },
|
|
608
608
|
script: i,
|
|
609
609
|
selector: "",
|
|
@@ -646,8 +646,7 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
646
646
|
lgAfterClose: "onLgClose"
|
|
647
647
|
}),
|
|
648
648
|
init() {
|
|
649
|
-
|
|
650
|
-
t && this.listenTo(this.model, t, this.destroyLightGallery);
|
|
649
|
+
this.listenTo(this.model, n.events.scriptUnmount, this.destroyLightGallery);
|
|
651
650
|
},
|
|
652
651
|
getLightGallery() {
|
|
653
652
|
return this.el.__lg;
|
|
@@ -685,7 +684,7 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
685
684
|
});
|
|
686
685
|
const q = M(Le);
|
|
687
686
|
n.addType(te, {
|
|
688
|
-
isComponent: (t) => z(t, ae) || t.tagName === "A" && z(t.parentElement,
|
|
687
|
+
isComponent: (t) => z(t, ae) || t.tagName === "A" && z(t.parentElement, H),
|
|
689
688
|
extendFn: ["init", "initToolbar"],
|
|
690
689
|
model: {
|
|
691
690
|
defaults: {
|
|
@@ -716,17 +715,17 @@ const k = "lightGallery", te = `${k}-item`, D = "data-lightgallery", ae = `${D}-
|
|
|
716
715
|
const { changed: o } = this, { init: g } = t;
|
|
717
716
|
if (o[f] || g) {
|
|
718
717
|
Z(this, f);
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
721
|
-
this.removeAttributes([N.name, F.name,
|
|
718
|
+
const m = this.getTrait(f).getValue();
|
|
719
|
+
if (m === P.image) {
|
|
720
|
+
this.removeAttributes([N.name, F.name, D]);
|
|
722
721
|
const w = this.getTrait(R.name);
|
|
723
722
|
w.setValue(w.getValue() || c);
|
|
724
|
-
} else
|
|
723
|
+
} else m === P.video ? this.removeAttributes([D]) : m === P.external && this.addAttributes({ [D]: !0 });
|
|
725
724
|
}
|
|
726
725
|
},
|
|
727
726
|
initSourceType() {
|
|
728
727
|
const t = this.getAttributes({ noClass: !0, noStyle: !0 });
|
|
729
|
-
t[
|
|
728
|
+
t[D] ? this.set(f, P.external) : (t[N.name] || t[F.name]) && this.set(f, P.video);
|
|
730
729
|
}
|
|
731
730
|
}
|
|
732
731
|
}), fe({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(L,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],A):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_lightGalleryComponent=A())})(this,function(){"use strict";const L="app.grapesjs.com",A="app-stage.grapesjs.com",Q=[L,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],pe="license:check:start",ue="license:check:end",he=()=>typeof window<"u",ge=({isDev:e,isStage:l})=>`${e?"":`https://${l?A:L}`}/api`,be=()=>{const e=he()&&window.location.hostname;return!!e&&(Q.includes(e)||Q.some(l=>e.endsWith(l)))};var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{});async function de({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:i,body:u}){const p=`${l||ge({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=i?new URLSearchParams(i).toString():"",s=c?`?${c}`:"",b=await fetch(`${p}${s}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const X={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function me(e){const l=e;return l.init=a=>n=>e(n,a),l}const ye=e=>me(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:i}){let u="",r=!1;const p=be(),h=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),i()},c=(s={})=>{var G;const{error:b,sdkLicense:O}=s,S=(G=s.plan)==null?void 0:G.category;if(!(O||s.license)||b)h(b||"Invalid license");else if(S){const _=X[l],M=X[S];_>M&&h({pluginRequiredPlan:l,licensePlan:S})}};e.on(pe,s=>{u=s==null?void 0:s.baseApiUrl,r=!0}),e.on(ue,s=>{c(s)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const s=await ve({licenseKey:n,pluginName:a,baseApiUrl:u});s&&c(s)}else h("The `licenseKey` option not provided")}},2e3)}async function ve(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await de({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const B=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const T="lightGallery",Y=`${T}-item`,j="data-lightgallery",ee=`${j}-item`,K="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},W={propKeys:[],props:{},traits:[]},V=(e,l={})=>{var i;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(i=h[c])==null||i.forEach(s=>{const b=s.id||s.name;a[b]=s.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),i=a.get("subTraits")||{},r=(Object.values(i).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=i[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},R=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const i=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(i,()=>Z(e,a)),Z(e,a)})},Te=(e,l,a)=>{const i=e.getTrait(l).get("subTraits")||{},r=(Object.values(i).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},we={[K]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Se={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},xe={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},ke={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},m="sourceType",U="data-iframe",F={name:"href",type:"file",label:"Image Source"},D={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},q={name:"data-poster",label:"Video Poster",type:"file"},te={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ae={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Ie={[K]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,u;const a=l.target,n=(i=a==null?void 0:a.closestType(T))==null?void 0:i.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[m]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[F],video:[D,q],external:[te]},options:[{id:"image",label:F.label||"",icon:w.image},{id:"video",label:D.label||"",icon:w.video},{id:"external",label:te.label||"",icon:w.external}]},subHtml:ae},Le="lightGalleryComponent",ne="lgThumbnail",Ae="lgVideo",le="lgAutoplay",oe="lgZoom",C="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return ye(function(e,l={}){const{Blocks:a,Components:n}=e,i="LightGallery",u="LightGallery Item",r={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ne,Ae,le,oe],cdnScript:[`${C}/lightgallery.min.js`,`${C}/plugins/thumbnail/lg-thumbnail.min.js`,`${C}/plugins/video/lg-video.min.js`,`${C}/plugins/autoplay/lg-autoplay.min.js`,`${C}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${C}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,s=function(t){const o=this,g=window,{plugins:y,cdnScript:x,cdnStyle:$,inline:se,lgLicenseKey:Pe,...f}=t||{},k=d=>isNaN(d)?void 0:parseInt(d,10),re=()=>{var N;const d={...f,licenseKey:Pe,speed:k(f.speed),startAnimationDuration:k(f.startAnimationDuration),thumbMargin:k(f.thumbMargin),thumbWidth:k(f.thumbWidth),slideShowInterval:k(f.slideShowInterval),scale:k(f.scale),enableZoomAfter:k(f.enableZoomAfter),plugins:(y||[]).map(z=>g[z])};se&&(d.container=o,d.closable=!1);const J=(N=g.lightGallery)==null?void 0:N.call(g,o,d);se&&J.openGallery()};if(g.lightGallery)re();else{const{head:d}=document,J=Array.isArray(x)?[...x]:[x],N=Array.isArray($)?[...$]:[$],z=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),z(I)}},ce=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=ce.bind(null,I),d.appendChild(v)}else re()};z(N),ce(J)}},b=t=>{const o=t.getTrait(K);if(!h||!o)return;const{toolbar:g}=t,y={id:K,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find($=>$.id===y.id)&&(g==null||g.unshift(y))};let O=[];const S=r.plugins||[],H=V(we),G=S.includes(ne)?V(Se):W,_=S.includes(le)?V(xe):W,M=S.includes(oe)?V(ke):W;n.addType(T,{block:p&&{label:i,media:w.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>B(t,j),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:w.gallery,draggable:(t,o)=>!o.is(T),attributes:{[j]:!0},components:{type:Y},script:s,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...H.propKeys,...G.propKeys,..._.propKeys,...M.propKeys],...H.props,...G.props,..._.props,...M.props,traits:[...H.traits,...G.traits,..._.traits,...M.traits]},init(){R(this,["thumbnail"]),R(this,["autoplay"]),R(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){const t=n.events.scriptUnmount;t&&this.listenTo(this.model,t,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();O=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();O.forEach(o=>this.em.Canvas.addSpot(o.attributes)),O=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const ie=V(Ie);n.addType(Y,{isComponent:t=>B(t,ee)||t.tagName==="A"&&B(t.parentElement,j),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:w.galleryItem,attributes:{[ee]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...ie.props,traits:[...ie.traits]},init(){const t=[m].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Te(this,m,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ae.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(T))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[m]||g){Z(this,m);const y=this.getTrait(m).getValue();if(y===E.image){this.removeAttributes([D.name,q.name,U]);const x=this.getTrait(F.name);x.setValue(x.getValue()||c)}else y===E.video?this.removeAttributes([U]):y===E.external&&this.addAttributes({[U]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[U]?this.set(m,E.external):(t[D.name]||t[q.name])&&this.set(m,E.video)}}}),fe({editor:e,plan:P.startup,licenseKey:r.licenseKey,pluginName:Le,cleanup:()=>{a.remove(T),n.removeType(T)}})})});
|
|
1
|
+
(function(L,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],A):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_lightGalleryComponent=A())})(this,function(){"use strict";const L="app.grapesjs.com",A="app-stage.grapesjs.com",Q=[L,A,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],pe="license:check:start",ue="license:check:end",he=()=>typeof window<"u",ge=({isDev:e,isStage:l})=>`${e?"":`https://${l?A:L}`}/api`,be=()=>{const e=he()&&window.location.hostname;return!!e&&(Q.includes(e)||Q.some(l=>e.endsWith(l)))};var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{});async function de({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:i,body:u}){const p=`${l||ge({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=i?new URLSearchParams(i).toString():"",s=c?`?${c}`:"",b=await fetch(`${p}${s}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const X={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function me(e){const l=e;return l.init=a=>n=>e(n,a),l}const ye=e=>me(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:i}){let u="",r=!1;const p=be(),h=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),i()},c=(s={})=>{var G;const{error:b,sdkLicense:O}=s,S=(G=s.plan)==null?void 0:G.category;if(!(O||s.license)||b)h(b||"Invalid license");else if(S){const _=X[l],M=X[S];_>M&&h({pluginRequiredPlan:l,licensePlan:S})}};e.on(pe,s=>{u=s==null?void 0:s.baseApiUrl,r=!0}),e.on(ue,s=>{c(s)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const s=await ve({licenseKey:n,pluginName:a,baseApiUrl:u});s&&c(s)}else h("The `licenseKey` option not provided")}},2e3)}async function ve(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await de({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const B=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const T="lightGallery",Y=`${T}-item`,j="data-lightgallery",ee=`${j}-item`,K="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},W={propKeys:[],props:{},traits:[]},V=(e,l={})=>{var i;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(i=h[c])==null||i.forEach(s=>{const b=s.id||s.name;a[b]=s.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),i=a.get("subTraits")||{},r=(Object.values(i).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=i[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},R=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const i=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(i,()=>Z(e,a)),Z(e,a)})},Te=(e,l,a)=>{const i=e.getTrait(l).get("subTraits")||{},r=(Object.values(i).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},we={[K]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Se={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},xe={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},ke={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},m="sourceType",D="data-iframe",F={name:"href",type:"file",label:"Image Source"},H={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},q={name:"data-poster",label:"Video Poster",type:"file"},te={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ae={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Ie={[K]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,u;const a=l.target,n=(i=a==null?void 0:a.closestType(T))==null?void 0:i.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[m]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[F],video:[H,q],external:[te]},options:[{id:"image",label:F.label||"",icon:w.image},{id:"video",label:H.label||"",icon:w.video},{id:"external",label:te.label||"",icon:w.external}]},subHtml:ae},Le="lightGalleryComponent",ne="lgThumbnail",Ae="lgVideo",le="lgAutoplay",oe="lgZoom",C="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return ye(function(e,l={}){const{Blocks:a,Components:n}=e,i="LightGallery",u="LightGallery Item",r={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ne,Ae,le,oe],cdnScript:[`${C}/lightgallery.min.js`,`${C}/plugins/thumbnail/lg-thumbnail.min.js`,`${C}/plugins/video/lg-video.min.js`,`${C}/plugins/autoplay/lg-autoplay.min.js`,`${C}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${C}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,s=function(t){const o=this,g=window,{plugins:y,cdnScript:x,cdnStyle:$,inline:se,lgLicenseKey:Pe,...f}=t||{},k=d=>isNaN(d)?void 0:parseInt(d,10),re=()=>{var N;const d={...f,licenseKey:Pe,speed:k(f.speed),startAnimationDuration:k(f.startAnimationDuration),thumbMargin:k(f.thumbMargin),thumbWidth:k(f.thumbWidth),slideShowInterval:k(f.slideShowInterval),scale:k(f.scale),enableZoomAfter:k(f.enableZoomAfter),plugins:(y||[]).map(z=>g[z])};se&&(d.container=o,d.closable=!1);const J=(N=g.lightGallery)==null?void 0:N.call(g,o,d);se&&J.openGallery()};if(g.lightGallery)re();else{const{head:d}=document,J=Array.isArray(x)?[...x]:[x],N=Array.isArray($)?[...$]:[$],z=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),z(I)}},ce=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=ce.bind(null,I),d.appendChild(v)}else re()};z(N),ce(J)}},b=t=>{const o=t.getTrait(K);if(!h||!o)return;const{toolbar:g}=t,y={id:K,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find($=>$.id===y.id)&&(g==null||g.unshift(y))};let O=[];const S=r.plugins||[],U=V(we),G=S.includes(ne)?V(Se):W,_=S.includes(le)?V(xe):W,M=S.includes(oe)?V(ke):W;n.addType(T,{block:p&&{label:i,media:w.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>B(t,j),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:w.gallery,draggable:(t,o)=>!o.is(T),attributes:{[j]:!0},components:{type:Y},script:s,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...U.propKeys,...G.propKeys,..._.propKeys,...M.propKeys],...U.props,...G.props,..._.props,...M.props,traits:[...U.traits,...G.traits,..._.traits,...M.traits]},init(){R(this,["thumbnail"]),R(this,["autoplay"]),R(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,n.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();O=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();O.forEach(o=>this.em.Canvas.addSpot(o.attributes)),O=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const ie=V(Ie);n.addType(Y,{isComponent:t=>B(t,ee)||t.tagName==="A"&&B(t.parentElement,j),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:w.galleryItem,attributes:{[ee]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...ie.props,traits:[...ie.traits]},init(){const t=[m].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Te(this,m,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ae.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(T))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[m]||g){Z(this,m);const y=this.getTrait(m).getValue();if(y===E.image){this.removeAttributes([H.name,q.name,D]);const x=this.getTrait(F.name);x.setValue(x.getValue()||c)}else y===E.video?this.removeAttributes([D]):y===E.external&&this.addAttributes({[D]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[D]?this.set(m,E.external):(t[H.name]||t[q.name])&&this.set(m,E.video)}}}),fe({editor:e,plan:P.startup,licenseKey:r.licenseKey,pluginName:Le,cleanup:()=>{a.remove(T),n.removeType(T)}})})});
|