@grapesjs/studio-sdk-plugins 1.0.9 → 1.0.10-rc.0

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.
@@ -1,6 +1,6 @@
1
- "use strict";const E="app.grapesjs.com",j="app-stage.grapesjs.com",O=[E,j,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",P="license:check:end",H=()=>typeof window<"u",W=({isDev:o,isStage:i})=>`${o?"":`https://${i?j:E}`}/api`,R=()=>{const o=H()&&window.location.hostname;return!!o&&(O.includes(o)||O.some(i=>o.endsWith(i)))},U=()=>(H()&&window.location.hostname)===E;var F={};const G=F.NODE_ENV!=="production";async function K({path:o,method:i="GET",headers:c={},body:a}){const u=`${W({isDev:G,isStage:!U()})}${o}`,r={method:i,headers:{"Content-Type":"application/json",...c}};a&&(r.body=JSON.stringify(a));const v=await fetch(u,r);if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);return v.json()}function Z(o){const i=o;return i.init=c=>a=>o(a,c),i}const J=o=>Z(o);async function q({editor:o,pluginName:i,licenseKey:c,cleanup:a}){let p=!1;const u=R();o.on(B,()=>{p=!0}),o.on(P,({sdkLicense:r})=>{r||a()}),setTimeout(async()=>{if(!p){if(u)return;c&&await z({licenseKey:c,pluginName:i})||a()}},2e3)}async function z({licenseKey:o,pluginName:i}){try{const c=await K({path:`/sdk/${o}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:i})}),{license:a}=c.result||{};return!!a}catch(c){return console.error("Error during SDK license check:",c),!1}}const X="gjs-plg-",Y="fsLightboxComponent",S="data-fslightbox",L="data-type",Q="fslightbox-open",b="fslightbox",f={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>',imageLightbox:'<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>',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>'},tt=function(o,i={}){const{Blocks:c,Components:a}=o,p="Lightbox",u=`${X}${b}`,r={toolbarIconOpen:f.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...i},{block:v,toolbarIconOpen:_,defaultSrc:A}=r,$=function(e){const t=this,n="data-fslightbox",s=window,h=()=>{var w;const d=s.refreshFsLightbox;d==null||d();const x=t.getAttribute(n);if((w=s.fsLightboxInstances)==null||w[x],!s._isEditor)return;Array.from(document.querySelectorAll(`[${n}]`)).forEach(g=>{const m=g.onclick;g.onclick=function(T){T.preventDefault();const N=g;!N.__skipLb&&(m==null||m(T)),N.__skipLb=!0}})};if(s.refreshFsLightbox)h();else{const d=document.createElement("script");d.src=e.cdnScript,d.onload=h,document.head.appendChild(d)}},D=e=>({id:`${b}-open-lb`,label:_,command:()=>{const t=e.getView();t==null||t.toggleLightbox()}}),l="source-type",k={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:f.image},{id:"video",label:"Video",icon:f.video},{id:"el",label:"Custom Element",icon:f.external}],labelToTitle:!0},C={id:"href-image",name:"href",type:"file",label:"Source Image"},I={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},V={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},M={image:[C],video:[I],el:[V]};a.addType(b,{block:v&&{label:p,media:f.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:e=>{var t;return(t=e.hasAttribute)==null?void 0:t.call(e,S)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:f.imageLightbox,classes:u,draggable:(e,t)=>!t.is(b),attributes:{[S]:"lightbox",[L]:"image",href:A},components:{type:"image",src:A},script:$,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[k,{name:S,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(e,t){var s;const n=(s=t.target)==null?void 0:s.getView();n==null||n.toggleLightbox()}}],styles:`
2
- .${u} {
1
+ "use strict";const P="app.grapesjs.com",B="app-stage.grapesjs.com",N=[P,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?B:P}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(N.includes(t)||N.some(a=>t.endsWith(a)))};var x=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(x||{});async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:p,body:h}){const w=`${a||W({isDev:!1,isStage:!1})}${t}`,d={method:r,headers:{"Content-Type":"application/json",...c}};h&&(d.body=JSON.stringify(h));const m=p?new URLSearchParams(p).toString():"",n=m?`?${m}`:"",b=await fetch(`${w}${n}`,d);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const O={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:p}){let h="",g=!1;const w=F(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),p()},m=(n={})=>{var A;const{error:b,sdkLicense:l}=n,v=(A=n.plan)==null?void 0:A.category;if(!(l||n.license)||b)d(b||"Invalid license");else if(v){const E=O[a],$=O[v];E>$&&d({pluginRequiredPlan:a,licensePlan:v})}};t.on(D,n=>{h=n==null?void 0:n.baseApiUrl,g=!0}),t.on(U,n=>{m(n)}),setTimeout(async()=>{if(!g){if(w)return;if(c){const n=await z({licenseKey:c,pluginName:r,baseApiUrl:h});n&&m(n)}else d("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",C="data-type",Y="fslightbox-open",T="fslightbox",S={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>',imageLightbox:'<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>',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>'},Q=function(t,a={}){const{Blocks:r,Components:c}=t,p="Lightbox",h=`${J}${T}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:w,toolbarIconOpen:d,defaultSrc:m}=g,n=function(s){const e=this,i="data-fslightbox",o=window,f=()=>{var H;const u=o.refreshFsLightbox;u==null||u();const j=e.getAttribute(i);if((H=o.fsLightboxInstances)==null||H[j],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(y=>{const L=y.onclick;y.onclick=function(I){I.preventDefault();const M=y;!M.__skipLb&&(L==null||L(I)),M.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=s.cdnScript,u.onload=f,document.head.appendChild(u)}},b=s=>({id:`${T}-open-lb`,label:d,command:()=>{const e=s.getView();e==null||e.toggleLightbox()}}),l="source-type",v={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},V={id:"href-image",name:"href",type:"file",label:"Source Image"},A={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},$={image:[V],video:[A],el:[E]};c.addType(T,{block:w&&{label:p,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:s=>{var e;return(e=s.hasAttribute)==null?void 0:e.call(s,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:p,icon:S.imageLightbox,classes:h,draggable:(s,e)=>!e.is(T),attributes:{[k]:"lightbox",[C]:"image",href:m},components:{type:"image",src:m},script:n,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[v,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(s,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
+ .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const e=[l].map(t=>`change:${t}`).join(" ");this.on(e,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(e,t,n){if(n.adjust)return;const h=this.get(l)==="video"?"video":"image";this.addAttributes({[L]:h,href:""})},adjustSourceType(){const e=this.get(l),t=this.getAttributes().href||"",n={adjust:!0};if(e==="video"){const s=t.includes("youtube.com")?"youtube":"video";this.addAttributes({[L]:s},n)}else e!=="el"&&t.startsWith("#")?this.set(l,"el",n):e==="image"&&this.addAttributes({[L]:"image"},n)},updateTraits(e={}){const{changed:t}=this,{init:n}=e;if(t[k.name]||n){this.removeTrait([C.name,I.name,V.name]);const s=this.get(l)||"image",h=this.getTraitIndex(l)+1;this.addTrait(M[s],{at:h})}},initToolbar(){if(!_)return;const{toolbar:e}=this,t=D(this);!e.find(s=>s.id===t.id)&&(e==null||e.unshift(t))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var g;const{em:e,el:t,model:n}=this,{Canvas:s}=e,h=n.getAttributes()[S],{defaultView:d,documentElement:x}=t.ownerDocument,y=(g=d.fsLightboxInstances)==null?void 0:g[h];if(x.classList.contains(Q))y.close();else{t.__skipLb=!1;let m;y.props.onOpen=()=>{m=s.getSpots(),setTimeout(()=>s.removeSpots())},y.props.onClose=()=>{m.forEach(T=>s.addSpot(T.attributes))},t.click()}}}}),q({editor:o,licenseKey:r.licenseKey,pluginName:Y,cleanup:()=>{c.remove(b),a.removeType(b)}})},et=J(tt);module.exports=et;
6
+ `},init(){const s=[l].map(e=>`change:${e}`).join(" ");this.on(s,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(s,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[C]:f,href:""})},adjustSourceType(){const s=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(s==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[C]:o},i)}else s!=="el"&&e.startsWith("#")?this.set(l,"el",i):s==="image"&&this.addAttributes({[C]:"image"},i)},updateTraits(s={}){const{changed:e}=this,{init:i}=s;if(e[v.name]||i){this.removeTrait([V.name,A.name,E.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait($[o],{at:f})}},initToolbar(){if(!d)return;const{toolbar:s}=this,e=b(this);!s.find(o=>o.id===e.id)&&(s==null||s.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var y;const{em:s,el:e,model:i}=this,{Canvas:o}=s,f=i.getAttributes()[k],{defaultView:u,documentElement:j}=e.ownerDocument,_=(y=u.fsLightboxInstances)==null?void 0:y[f];if(j.classList.contains(Y))_.close();else{e.__skipLb=!1;let L;_.props.onOpen=()=>{L=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{L.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),q({editor:t,plan:x.free,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(T),c.removeType(T)}})},ee=Z(Q);module.exports=ee;
@@ -1,6 +1,6 @@
1
- const E = "app.grapesjs.com", j = "app-stage.grapesjs.com", O = [
2
- E,
3
- j,
1
+ const P = "app.grapesjs.com", B = "app-stage.grapesjs.com", N = [
2
+ P,
3
+ B,
4
4
  "localhost",
5
5
  "127.0.0.1",
6
6
  ".local-credentialless.webcontainer.io",
@@ -9,225 +9,249 @@ const E = "app.grapesjs.com", j = "app-stage.grapesjs.com", O = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
12
- ], B = "license:check:start", P = "license:check:end", H = () => typeof window < "u", W = ({ isDev: o, isStage: i }) => `${o ? "" : `https://${i ? j : E}`}/api`, R = () => {
13
- const o = H() && window.location.hostname;
14
- return !!o && (O.includes(o) || O.some((i) => o.endsWith(i)));
15
- }, U = () => (H() && window.location.hostname) === E;
16
- var F = {};
17
- const G = F.NODE_ENV !== "production";
12
+ ], D = "license:check:start", U = "license:check:end", R = () => typeof window < "u", W = ({ isDev: t, isStage: a }) => `${t ? "" : `https://${a ? B : P}`}/api`, F = () => {
13
+ const t = R() && window.location.hostname;
14
+ return !!t && (N.includes(t) || N.some((a) => t.endsWith(a)));
15
+ };
16
+ var x = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(x || {});
18
17
  async function K({
19
- path: o,
20
- method: i = "GET",
18
+ path: t,
19
+ baseApiUrl: a,
20
+ method: r = "GET",
21
21
  headers: c = {},
22
- body: a
22
+ params: p,
23
+ body: h
23
24
  }) {
24
- const u = `${W({ isDev: G, isStage: !U() })}${o}`, r = {
25
- method: i,
25
+ const w = `${a || W({ isDev: !1, isStage: !1 })}${t}`, d = {
26
+ method: r,
26
27
  headers: {
27
28
  "Content-Type": "application/json",
28
29
  ...c
29
30
  }
30
31
  };
31
- a && (r.body = JSON.stringify(a));
32
- const v = await fetch(u, r);
33
- if (!v.ok)
34
- throw new Error(`HTTP error! status: ${v.status}`);
35
- return v.json();
32
+ h && (d.body = JSON.stringify(h));
33
+ const m = p ? new URLSearchParams(p).toString() : "", n = m ? `?${m}` : "", b = await fetch(`${w}${n}`, d);
34
+ if (!b.ok)
35
+ throw new Error(`HTTP error! status: ${b.status}`);
36
+ return b.json();
36
37
  }
37
- function Z(o) {
38
- const i = o;
39
- return i.init = (c) => (a) => o(a, c), i;
38
+ const O = {
39
+ [x.free]: 0,
40
+ [x.startup]: 10,
41
+ [x.business]: 20,
42
+ [x.enterprise]: 30
43
+ };
44
+ function G(t) {
45
+ const a = t;
46
+ return a.init = (r) => (c) => t(c, r), a;
40
47
  }
41
- const J = (o) => /* @__PURE__ */ Z(o);
48
+ const Z = (t) => /* @__PURE__ */ G(t);
42
49
  async function q({
43
- editor: o,
44
- pluginName: i,
50
+ editor: t,
51
+ plan: a,
52
+ pluginName: r,
45
53
  licenseKey: c,
46
- cleanup: a
54
+ cleanup: p
47
55
  }) {
48
- let p = !1;
49
- const u = R();
50
- o.on(B, () => {
51
- p = !0;
52
- }), o.on(P, ({ sdkLicense: r }) => {
53
- r || a();
56
+ let h = "", g = !1;
57
+ const w = F(), d = (n) => {
58
+ console.warn("Cleanup plugin:", r, "Reason:", n), p();
59
+ }, m = (n = {}) => {
60
+ var A;
61
+ const { error: b, sdkLicense: l } = n, v = (A = n.plan) == null ? void 0 : A.category;
62
+ if (!(l || n.license) || b)
63
+ d(b || "Invalid license");
64
+ else if (v) {
65
+ const E = O[a], $ = O[v];
66
+ E > $ && d({ pluginRequiredPlan: a, licensePlan: v });
67
+ }
68
+ };
69
+ t.on(D, (n) => {
70
+ h = n == null ? void 0 : n.baseApiUrl, g = !0;
71
+ }), t.on(U, (n) => {
72
+ m(n);
54
73
  }), setTimeout(async () => {
55
- if (!p) {
56
- if (u) return;
57
- c && await z({ licenseKey: c, pluginName: i }) || a();
74
+ if (!g) {
75
+ if (w) return;
76
+ if (c) {
77
+ const n = await z({ licenseKey: c, pluginName: r, baseApiUrl: h });
78
+ n && m(n);
79
+ } else
80
+ d("The `licenseKey` option not provided");
58
81
  }
59
82
  }, 2e3);
60
83
  }
61
- async function z({ licenseKey: o, pluginName: i }) {
84
+ async function z(t) {
85
+ const { licenseKey: a, pluginName: r, baseApiUrl: c } = t;
62
86
  try {
63
- const c = await K({
64
- path: `/sdk/${o}`,
87
+ return (await K({
88
+ baseApiUrl: c,
89
+ path: `/sdk/${a || "na"}`,
65
90
  method: "POST",
66
- body: JSON.stringify({
91
+ params: {
67
92
  d: window.location.hostname,
68
- pn: i
69
- })
70
- }), { license: a } = c.result || {};
71
- return !!a;
72
- } catch (c) {
73
- return console.error("Error during SDK license check:", c), !1;
93
+ pn: r
94
+ }
95
+ })).result || {};
96
+ } catch (p) {
97
+ return console.error("Error during SDK license check:", p), !1;
74
98
  }
75
99
  }
76
- const X = "gjs-plg-", Y = "fsLightboxComponent", S = "data-fslightbox", L = "data-type", Q = "fslightbox-open", b = "fslightbox", f = {
100
+ const J = "gjs-plg-", X = "fsLightboxComponent", k = "data-fslightbox", C = "data-type", Y = "fslightbox-open", T = "fslightbox", S = {
77
101
  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>',
78
102
  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>',
79
103
  imageLightbox: '<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>',
80
104
  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>',
81
105
  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>'
82
- }, tt = function(o, i = {}) {
83
- const { Blocks: c, Components: a } = o, p = "Lightbox", u = `${X}${b}`, r = {
84
- toolbarIconOpen: f.eye,
106
+ }, Q = function(t, a = {}) {
107
+ const { Blocks: r, Components: c } = t, p = "Lightbox", h = `${J}${T}`, g = {
108
+ toolbarIconOpen: S.eye,
85
109
  block: {},
86
110
  defaultSrc: "https://placehold.co/300/777/white.png?text=Image",
87
111
  cdnScript: "https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",
88
- ...i
89
- }, { block: v, toolbarIconOpen: _, defaultSrc: A } = r, $ = function(e) {
90
- const t = this, n = "data-fslightbox", s = window, h = () => {
91
- var w;
92
- const d = s.refreshFsLightbox;
93
- d == null || d();
94
- const x = t.getAttribute(n);
95
- if ((w = s.fsLightboxInstances) == null || w[x], !s._isEditor) return;
96
- Array.from(document.querySelectorAll(`[${n}]`)).forEach((g) => {
97
- const m = g.onclick;
98
- g.onclick = function(T) {
99
- T.preventDefault();
100
- const N = g;
101
- !N.__skipLb && (m == null || m(T)), N.__skipLb = !0;
112
+ ...a
113
+ }, { block: w, toolbarIconOpen: d, defaultSrc: m } = g, n = function(s) {
114
+ const e = this, i = "data-fslightbox", o = window, f = () => {
115
+ var H;
116
+ const u = o.refreshFsLightbox;
117
+ u == null || u();
118
+ const j = e.getAttribute(i);
119
+ if ((H = o.fsLightboxInstances) == null || H[j], !o._isEditor) return;
120
+ Array.from(document.querySelectorAll(`[${i}]`)).forEach((y) => {
121
+ const L = y.onclick;
122
+ y.onclick = function(I) {
123
+ I.preventDefault();
124
+ const M = y;
125
+ !M.__skipLb && (L == null || L(I)), M.__skipLb = !0;
102
126
  };
103
127
  });
104
128
  };
105
- if (s.refreshFsLightbox)
106
- h();
129
+ if (o.refreshFsLightbox)
130
+ f();
107
131
  else {
108
- const d = document.createElement("script");
109
- d.src = e.cdnScript, d.onload = h, document.head.appendChild(d);
132
+ const u = document.createElement("script");
133
+ u.src = s.cdnScript, u.onload = f, document.head.appendChild(u);
110
134
  }
111
- }, D = (e) => ({
112
- id: `${b}-open-lb`,
113
- label: _,
135
+ }, b = (s) => ({
136
+ id: `${T}-open-lb`,
137
+ label: d,
114
138
  command: () => {
115
- const t = e.getView();
116
- t == null || t.toggleLightbox();
139
+ const e = s.getView();
140
+ e == null || e.toggleLightbox();
117
141
  }
118
- }), l = "source-type", k = {
142
+ }), l = "source-type", v = {
119
143
  type: "radio",
120
144
  name: l,
121
145
  label: "Source type",
122
146
  changeProp: !0,
123
147
  options: [
124
- { id: "image", label: "Image", icon: f.image },
125
- { id: "video", label: "Video", icon: f.video },
126
- { id: "el", label: "Custom Element", icon: f.external }
148
+ { id: "image", label: "Image", icon: S.image },
149
+ { id: "video", label: "Video", icon: S.video },
150
+ { id: "el", label: "Custom Element", icon: S.external }
127
151
  ],
128
152
  // @ts-expect-error Studio related prop
129
153
  labelToTitle: !0
130
- }, C = {
154
+ }, V = {
131
155
  id: "href-image",
132
156
  name: "href",
133
157
  type: "file",
134
158
  label: "Source Image"
135
- }, I = {
159
+ }, A = {
136
160
  id: "href-video",
137
161
  name: "href",
138
162
  label: "Source Video",
139
163
  placeholder: "https://www.youtube.com/watch?v=..."
140
- }, V = {
164
+ }, E = {
141
165
  id: "href-el",
142
166
  name: "href",
143
167
  label: "Source Element",
144
168
  placeholder: "#custom-element-id"
145
- }, M = {
146
- image: [C],
147
- video: [I],
148
- el: [V]
169
+ }, $ = {
170
+ image: [V],
171
+ video: [A],
172
+ el: [E]
149
173
  };
150
- a.addType(b, {
151
- block: v && {
174
+ c.addType(T, {
175
+ block: w && {
152
176
  label: p,
153
- media: f.imageLightbox,
177
+ media: S.imageLightbox,
154
178
  category: "Extra",
155
179
  select: !0,
156
- ...r.block
180
+ ...g.block
157
181
  },
158
- isComponent: (e) => {
159
- var t;
160
- return (t = e.hasAttribute) == null ? void 0 : t.call(e, S);
182
+ isComponent: (s) => {
183
+ var e;
184
+ return (e = s.hasAttribute) == null ? void 0 : e.call(s, k);
161
185
  },
162
186
  extendFn: ["initToolbar"],
163
187
  model: {
164
188
  defaults: {
165
189
  tagName: "a",
166
190
  name: p,
167
- icon: f.imageLightbox,
168
- classes: u,
169
- draggable: (e, t) => !t.is(b),
191
+ icon: S.imageLightbox,
192
+ classes: h,
193
+ draggable: (s, e) => !e.is(T),
170
194
  attributes: {
171
- [S]: "lightbox",
172
- [L]: "image",
173
- href: A
195
+ [k]: "lightbox",
196
+ [C]: "image",
197
+ href: m
174
198
  },
175
- components: { type: "image", src: A },
176
- script: $,
177
- cdnScript: r.cdnScript,
199
+ components: { type: "image", src: m },
200
+ script: n,
201
+ cdnScript: g.cdnScript,
178
202
  "script-props": ["attributes", "cdnScript"],
179
203
  [l]: "image",
180
204
  traits: [
181
- k,
205
+ v,
182
206
  {
183
- name: S,
207
+ name: k,
184
208
  label: "Group name"
185
209
  },
186
210
  {
187
211
  type: "button",
188
212
  label: "Toggle Lightbox",
189
- command(e, t) {
190
- var s;
191
- const n = (s = t.target) == null ? void 0 : s.getView();
192
- n == null || n.toggleLightbox();
213
+ command(s, e) {
214
+ var o;
215
+ const i = (o = e.target) == null ? void 0 : o.getView();
216
+ i == null || i.toggleLightbox();
193
217
  }
194
218
  }
195
219
  ],
196
220
  styles: `
197
- .${u} {
221
+ .${h} {
198
222
  display: inline-block;
199
223
  padding: 10px;
200
224
  }
201
225
  `
202
226
  },
203
227
  init() {
204
- const e = [l].map((t) => `change:${t}`).join(" ");
205
- this.on(e, this.updateTraits), this.on(`change:${l}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
228
+ const s = [l].map((e) => `change:${e}`).join(" ");
229
+ this.on(s, this.updateTraits), this.on(`change:${l}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
206
230
  },
207
- onSourceTypeChange(e, t, n) {
208
- if (n.adjust) return;
209
- const h = this.get(l) === "video" ? "video" : "image";
210
- this.addAttributes({ [L]: h, href: "" });
231
+ onSourceTypeChange(s, e, i) {
232
+ if (i.adjust) return;
233
+ const f = this.get(l) === "video" ? "video" : "image";
234
+ this.addAttributes({ [C]: f, href: "" });
211
235
  },
212
236
  adjustSourceType() {
213
- const e = this.get(l), t = this.getAttributes().href || "", n = { adjust: !0 };
214
- if (e === "video") {
215
- const s = t.includes("youtube.com") ? "youtube" : "video";
216
- this.addAttributes({ [L]: s }, n);
217
- } else e !== "el" && t.startsWith("#") ? this.set(l, "el", n) : e === "image" && this.addAttributes({ [L]: "image" }, n);
237
+ const s = this.get(l), e = this.getAttributes().href || "", i = { adjust: !0 };
238
+ if (s === "video") {
239
+ const o = e.includes("youtube.com") ? "youtube" : "video";
240
+ this.addAttributes({ [C]: o }, i);
241
+ } else s !== "el" && e.startsWith("#") ? this.set(l, "el", i) : s === "image" && this.addAttributes({ [C]: "image" }, i);
218
242
  },
219
- updateTraits(e = {}) {
220
- const { changed: t } = this, { init: n } = e;
221
- if (t[k.name] || n) {
222
- this.removeTrait([C.name, I.name, V.name]);
223
- const s = this.get(l) || "image", h = this.getTraitIndex(l) + 1;
224
- this.addTrait(M[s], { at: h });
243
+ updateTraits(s = {}) {
244
+ const { changed: e } = this, { init: i } = s;
245
+ if (e[v.name] || i) {
246
+ this.removeTrait([V.name, A.name, E.name]);
247
+ const o = this.get(l) || "image", f = this.getTraitIndex(l) + 1;
248
+ this.addTrait($[o], { at: f });
225
249
  }
226
250
  },
227
251
  initToolbar() {
228
- if (!_) return;
229
- const { toolbar: e } = this, t = D(this);
230
- !e.find((s) => s.id === t.id) && (e == null || e.unshift(t));
252
+ if (!d) return;
253
+ const { toolbar: s } = this, e = b(this);
254
+ !s.find((o) => o.id === e.id) && (s == null || s.unshift(e));
231
255
  }
232
256
  },
233
257
  view: {
@@ -235,30 +259,31 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", S = "data-fslightbox", L = "dat
235
259
  this.el.__skipLb = !0;
236
260
  },
237
261
  toggleLightbox() {
238
- var g;
239
- const { em: e, el: t, model: n } = this, { Canvas: s } = e, h = n.getAttributes()[S], { defaultView: d, documentElement: x } = t.ownerDocument, y = (g = d.fsLightboxInstances) == null ? void 0 : g[h];
240
- if (x.classList.contains(Q))
241
- y.close();
262
+ var y;
263
+ const { em: s, el: e, model: i } = this, { Canvas: o } = s, f = i.getAttributes()[k], { defaultView: u, documentElement: j } = e.ownerDocument, _ = (y = u.fsLightboxInstances) == null ? void 0 : y[f];
264
+ if (j.classList.contains(Y))
265
+ _.close();
242
266
  else {
243
- t.__skipLb = !1;
244
- let m;
245
- y.props.onOpen = () => {
246
- m = s.getSpots(), setTimeout(() => s.removeSpots());
247
- }, y.props.onClose = () => {
248
- m.forEach((T) => s.addSpot(T.attributes));
249
- }, t.click();
267
+ e.__skipLb = !1;
268
+ let L;
269
+ _.props.onOpen = () => {
270
+ L = o.getSpots(), setTimeout(() => o.removeSpots());
271
+ }, _.props.onClose = () => {
272
+ L.forEach((I) => o.addSpot(I.attributes));
273
+ }, e.click();
250
274
  }
251
275
  }
252
276
  }
253
277
  }), q({
254
- editor: o,
255
- licenseKey: r.licenseKey,
256
- pluginName: Y,
278
+ editor: t,
279
+ plan: x.free,
280
+ licenseKey: g.licenseKey,
281
+ pluginName: X,
257
282
  cleanup: () => {
258
- c.remove(b), a.removeType(b);
283
+ r.remove(T), c.removeType(T);
259
284
  }
260
285
  });
261
- }, et = J(tt);
286
+ }, ee = Z(Q);
262
287
  export {
263
- et as default
288
+ ee as default
264
289
  };
@@ -1,6 +1,6 @@
1
- (function(h,u){typeof exports=="object"&&typeof module<"u"?module.exports=u():typeof define=="function"&&define.amd?define(u):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_fsLightboxComponent=u())})(this,function(){"use strict";const h="app.grapesjs.com",u="app-stage.grapesjs.com",k=[h,u,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",D="license:check:end",A=()=>typeof window<"u",M=({isDev:o,isStage:i})=>`${o?"":`https://${i?u:h}`}/api`,B=()=>{const o=A()&&window.location.hostname;return!!o&&(k.includes(o)||k.some(i=>o.endsWith(i)))},P=()=>(A()&&window.location.hostname)===h;var W={};const R=W.NODE_ENV!=="production";async function U({path:o,method:i="GET",headers:c={},body:a}){const f=`${M({isDev:R,isStage:!P()})}${o}`,r={method:i,headers:{"Content-Type":"application/json",...c}};a&&(r.body=JSON.stringify(a));const v=await fetch(f,r);if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);return v.json()}function F(o){const i=o;return i.init=c=>a=>o(a,c),i}const G=o=>F(o);async function K({editor:o,pluginName:i,licenseKey:c,cleanup:a}){let b=!1;const f=B();o.on($,()=>{b=!0}),o.on(D,({sdkLicense:r})=>{r||a()}),setTimeout(async()=>{if(!b){if(f)return;c&&await Z({licenseKey:c,pluginName:i})||a()}},2e3)}async function Z({licenseKey:o,pluginName:i}){try{const c=await U({path:`/sdk/${o}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:i})}),{license:a}=c.result||{};return!!a}catch(c){return console.error("Error during SDK license check:",c),!1}}const J="gjs-plg-",q="fsLightboxComponent",S="data-fslightbox",L="data-type",z="fslightbox-open",g="fslightbox",m={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>',imageLightbox:'<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>',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>'};return G(function(o,i={}){const{Blocks:c,Components:a}=o,b="Lightbox",f=`${J}${g}`,r={toolbarIconOpen:m.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...i},{block:v,toolbarIconOpen:C,defaultSrc:I}=r,X=function(e){const t=this,s="data-fslightbox",n=window,p=()=>{var E;const d=n.refreshFsLightbox;d==null||d();const _=t.getAttribute(s);if((E=n.fsLightboxInstances)==null||E[_],!n._isEditor)return;Array.from(document.querySelectorAll(`[${s}]`)).forEach(y=>{const T=y.onclick;y.onclick=function(w){w.preventDefault();const H=y;!H.__skipLb&&(T==null||T(w)),H.__skipLb=!0}})};if(n.refreshFsLightbox)p();else{const d=document.createElement("script");d.src=e.cdnScript,d.onload=p,document.head.appendChild(d)}},Y=e=>({id:`${g}-open-lb`,label:C,command:()=>{const t=e.getView();t==null||t.toggleLightbox()}}),l="source-type",V={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:m.image},{id:"video",label:"Video",icon:m.video},{id:"el",label:"Custom Element",icon:m.external}],labelToTitle:!0},N={id:"href-image",name:"href",type:"file",label:"Source Image"},j={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},O={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},Q={image:[N],video:[j],el:[O]};a.addType(g,{block:v&&{label:b,media:m.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:e=>{var t;return(t=e.hasAttribute)==null?void 0:t.call(e,S)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:b,icon:m.imageLightbox,classes:f,draggable:(e,t)=>!t.is(g),attributes:{[S]:"lightbox",[L]:"image",href:I},components:{type:"image",src:I},script:X,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[V,{name:S,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(e,t){var n;const s=(n=t.target)==null?void 0:n.getView();s==null||s.toggleLightbox()}}],styles:`
2
- .${f} {
1
+ (function(v,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_fsLightboxComponent=y())})(this,function(){"use strict";const v="app.grapesjs.com",y="app-stage.grapesjs.com",O=[v,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],D="license:check:start",U="license:check:end",R=()=>typeof window<"u",W=({isDev:t,isStage:a})=>`${t?"":`https://${a?y:v}`}/api`,F=()=>{const t=R()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(a=>t.endsWith(a)))};var T=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(T||{});async function K({path:t,baseApiUrl:a,method:r="GET",headers:c={},params:d,body:h}){const E=`${a||W({isDev:!1,isStage:!1})}${t}`,p={method:r,headers:{"Content-Type":"application/json",...c}};h&&(p.body=JSON.stringify(h));const m=d?new URLSearchParams(d).toString():"",s=m?`?${m}`:"",b=await fetch(`${E}${s}`,p);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const P={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function G(t){const a=t;return a.init=r=>c=>t(c,r),a}const Z=t=>G(t);async function q({editor:t,plan:a,pluginName:r,licenseKey:c,cleanup:d}){let h="",g=!1;const E=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),d()},m=(s={})=>{var _;const{error:b,sdkLicense:l}=s,x=(_=s.plan)==null?void 0:_.category;if(!(l||s.license)||b)p(b||"Invalid license");else if(x){const C=P[a],H=P[x];C>H&&p({pluginRequiredPlan:a,licensePlan:x})}};t.on(D,s=>{h=s==null?void 0:s.baseApiUrl,g=!0}),t.on(U,s=>{m(s)}),setTimeout(async()=>{if(!g){if(E)return;if(c){const s=await z({licenseKey:c,pluginName:r,baseApiUrl:h});s&&m(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(t){const{licenseKey:a,pluginName:r,baseApiUrl:c}=t;try{return(await K({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const J="gjs-plg-",X="fsLightboxComponent",k="data-fslightbox",I="data-type",Y="fslightbox-open",L="fslightbox",S={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>',imageLightbox:'<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>',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>'};return Z(function(t,a={}){const{Blocks:r,Components:c}=t,d="Lightbox",h=`${J}${L}`,g={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:E,toolbarIconOpen:p,defaultSrc:m}=g,s=function(n){const e=this,i="data-fslightbox",o=window,f=()=>{var N;const u=o.refreshFsLightbox;u==null||u();const M=e.getAttribute(i);if((N=o.fsLightboxInstances)==null||N[M],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const A=w.onclick;w.onclick=function($){$.preventDefault();const B=w;!B.__skipLb&&(A==null||A($)),B.__skipLb=!0}})};if(o.refreshFsLightbox)f();else{const u=document.createElement("script");u.src=n.cdnScript,u.onload=f,document.head.appendChild(u)}},b=n=>({id:`${L}-open-lb`,label:p,command:()=>{const e=n.getView();e==null||e.toggleLightbox()}}),l="source-type",x={type:"radio",name:l,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},j={id:"href-image",name:"href",type:"file",label:"Source Image"},_={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},C={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},H={image:[j],video:[_],el:[C]};c.addType(L,{block:E&&{label:d,media:S.imageLightbox,category:"Extra",select:!0,...g.block},isComponent:n=>{var e;return(e=n.hasAttribute)==null?void 0:e.call(n,k)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:d,icon:S.imageLightbox,classes:h,draggable:(n,e)=>!e.is(L),attributes:{[k]:"lightbox",[I]:"image",href:m},components:{type:"image",src:m},script:s,cdnScript:g.cdnScript,"script-props":["attributes","cdnScript"],[l]:"image",traits:[x,{name:k,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(n,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
2
+ .${h} {
3
3
  display: inline-block;
4
4
  padding: 10px;
5
5
  }
6
- `},init(){const e=[l].map(t=>`change:${t}`).join(" ");this.on(e,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(e,t,s){if(s.adjust)return;const p=this.get(l)==="video"?"video":"image";this.addAttributes({[L]:p,href:""})},adjustSourceType(){const e=this.get(l),t=this.getAttributes().href||"",s={adjust:!0};if(e==="video"){const n=t.includes("youtube.com")?"youtube":"video";this.addAttributes({[L]:n},s)}else e!=="el"&&t.startsWith("#")?this.set(l,"el",s):e==="image"&&this.addAttributes({[L]:"image"},s)},updateTraits(e={}){const{changed:t}=this,{init:s}=e;if(t[V.name]||s){this.removeTrait([N.name,j.name,O.name]);const n=this.get(l)||"image",p=this.getTraitIndex(l)+1;this.addTrait(Q[n],{at:p})}},initToolbar(){if(!C)return;const{toolbar:e}=this,t=Y(this);!e.find(n=>n.id===t.id)&&(e==null||e.unshift(t))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var y;const{em:e,el:t,model:s}=this,{Canvas:n}=e,p=s.getAttributes()[S],{defaultView:d,documentElement:_}=t.ownerDocument,x=(y=d.fsLightboxInstances)==null?void 0:y[p];if(_.classList.contains(z))x.close();else{t.__skipLb=!1;let T;x.props.onOpen=()=>{T=n.getSpots(),setTimeout(()=>n.removeSpots())},x.props.onClose=()=>{T.forEach(w=>n.addSpot(w.attributes))},t.click()}}}}),K({editor:o,licenseKey:r.licenseKey,pluginName:q,cleanup:()=>{c.remove(g),a.removeType(g)}})})});
6
+ `},init(){const n=[l].map(e=>`change:${e}`).join(" ");this.on(n,this.updateTraits),this.on(`change:${l}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(n,e,i){if(i.adjust)return;const f=this.get(l)==="video"?"video":"image";this.addAttributes({[I]:f,href:""})},adjustSourceType(){const n=this.get(l),e=this.getAttributes().href||"",i={adjust:!0};if(n==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[I]:o},i)}else n!=="el"&&e.startsWith("#")?this.set(l,"el",i):n==="image"&&this.addAttributes({[I]:"image"},i)},updateTraits(n={}){const{changed:e}=this,{init:i}=n;if(e[x.name]||i){this.removeTrait([j.name,_.name,C.name]);const o=this.get(l)||"image",f=this.getTraitIndex(l)+1;this.addTrait(H[o],{at:f})}},initToolbar(){if(!p)return;const{toolbar:n}=this,e=b(this);!n.find(o=>o.id===e.id)&&(n==null||n.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:n,el:e,model:i}=this,{Canvas:o}=n,f=i.getAttributes()[k],{defaultView:u,documentElement:M}=e.ownerDocument,V=(w=u.fsLightboxInstances)==null?void 0:w[f];if(M.classList.contains(Y))V.close();else{e.__skipLb=!1;let A;V.props.onOpen=()=>{A=o.getSpots(),setTimeout(()=>o.removeSpots())},V.props.onClose=()=>{A.forEach($=>o.addSpot($.attributes))},e.click()}}}}),q({editor:t,plan:T.free,licenseKey:g.licenseKey,pluginName:X,cleanup:()=>{r.remove(L),c.removeType(L)}})})});