@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.
- package/dist/api.d.ts +3 -1
- package/dist/dialogComponent/index.cjs.js +15 -15
- package/dist/dialogComponent/index.es.js +136 -111
- package/dist/dialogComponent/index.umd.js +15 -15
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +168 -143
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +1886 -1856
- package/dist/index.umd.js +14 -14
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -220
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/lightGalleryComponent/types.d.ts +3 -3
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +136 -111
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/prosemirror/index.cjs.js +9 -9
- package/dist/prosemirror/index.es.js +1267 -1242
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +315 -290
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/utils.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
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
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
],
|
|
13
|
-
const
|
|
14
|
-
return !!
|
|
15
|
-
}
|
|
16
|
-
var
|
|
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:
|
|
20
|
-
|
|
18
|
+
path: t,
|
|
19
|
+
baseApiUrl: a,
|
|
20
|
+
method: r = "GET",
|
|
21
21
|
headers: c = {},
|
|
22
|
-
|
|
22
|
+
params: p,
|
|
23
|
+
body: h
|
|
23
24
|
}) {
|
|
24
|
-
const
|
|
25
|
-
method:
|
|
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
|
-
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`HTTP error! status: ${
|
|
35
|
-
return
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
48
|
+
const Z = (t) => /* @__PURE__ */ G(t);
|
|
42
49
|
async function q({
|
|
43
|
-
editor:
|
|
44
|
-
|
|
50
|
+
editor: t,
|
|
51
|
+
plan: a,
|
|
52
|
+
pluginName: r,
|
|
45
53
|
licenseKey: c,
|
|
46
|
-
cleanup:
|
|
54
|
+
cleanup: p
|
|
47
55
|
}) {
|
|
48
|
-
let
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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 (!
|
|
56
|
-
if (
|
|
57
|
-
|
|
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(
|
|
84
|
+
async function z(t) {
|
|
85
|
+
const { licenseKey: a, pluginName: r, baseApiUrl: c } = t;
|
|
62
86
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
87
|
+
return (await K({
|
|
88
|
+
baseApiUrl: c,
|
|
89
|
+
path: `/sdk/${a || "na"}`,
|
|
65
90
|
method: "POST",
|
|
66
|
-
|
|
91
|
+
params: {
|
|
67
92
|
d: window.location.hostname,
|
|
68
|
-
pn:
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
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
|
-
},
|
|
83
|
-
const { Blocks:
|
|
84
|
-
toolbarIconOpen:
|
|
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
|
-
...
|
|
89
|
-
}, { block:
|
|
90
|
-
const
|
|
91
|
-
var
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
if ((
|
|
96
|
-
Array.from(document.querySelectorAll(`[${
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
!
|
|
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 (
|
|
106
|
-
|
|
129
|
+
if (o.refreshFsLightbox)
|
|
130
|
+
f();
|
|
107
131
|
else {
|
|
108
|
-
const
|
|
109
|
-
|
|
132
|
+
const u = document.createElement("script");
|
|
133
|
+
u.src = s.cdnScript, u.onload = f, document.head.appendChild(u);
|
|
110
134
|
}
|
|
111
|
-
},
|
|
112
|
-
id: `${
|
|
113
|
-
label:
|
|
135
|
+
}, b = (s) => ({
|
|
136
|
+
id: `${T}-open-lb`,
|
|
137
|
+
label: d,
|
|
114
138
|
command: () => {
|
|
115
|
-
const
|
|
116
|
-
|
|
139
|
+
const e = s.getView();
|
|
140
|
+
e == null || e.toggleLightbox();
|
|
117
141
|
}
|
|
118
|
-
}), l = "source-type",
|
|
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:
|
|
125
|
-
{ id: "video", label: "Video", icon:
|
|
126
|
-
{ id: "el", label: "Custom Element", icon:
|
|
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
|
-
},
|
|
154
|
+
}, V = {
|
|
131
155
|
id: "href-image",
|
|
132
156
|
name: "href",
|
|
133
157
|
type: "file",
|
|
134
158
|
label: "Source Image"
|
|
135
|
-
},
|
|
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
|
-
},
|
|
164
|
+
}, E = {
|
|
141
165
|
id: "href-el",
|
|
142
166
|
name: "href",
|
|
143
167
|
label: "Source Element",
|
|
144
168
|
placeholder: "#custom-element-id"
|
|
145
|
-
},
|
|
146
|
-
image: [
|
|
147
|
-
video: [
|
|
148
|
-
el: [
|
|
169
|
+
}, $ = {
|
|
170
|
+
image: [V],
|
|
171
|
+
video: [A],
|
|
172
|
+
el: [E]
|
|
149
173
|
};
|
|
150
|
-
|
|
151
|
-
block:
|
|
174
|
+
c.addType(T, {
|
|
175
|
+
block: w && {
|
|
152
176
|
label: p,
|
|
153
|
-
media:
|
|
177
|
+
media: S.imageLightbox,
|
|
154
178
|
category: "Extra",
|
|
155
179
|
select: !0,
|
|
156
|
-
...
|
|
180
|
+
...g.block
|
|
157
181
|
},
|
|
158
|
-
isComponent: (
|
|
159
|
-
var
|
|
160
|
-
return (
|
|
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:
|
|
168
|
-
classes:
|
|
169
|
-
draggable: (
|
|
191
|
+
icon: S.imageLightbox,
|
|
192
|
+
classes: h,
|
|
193
|
+
draggable: (s, e) => !e.is(T),
|
|
170
194
|
attributes: {
|
|
171
|
-
[
|
|
172
|
-
[
|
|
173
|
-
href:
|
|
195
|
+
[k]: "lightbox",
|
|
196
|
+
[C]: "image",
|
|
197
|
+
href: m
|
|
174
198
|
},
|
|
175
|
-
components: { type: "image", src:
|
|
176
|
-
script:
|
|
177
|
-
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
|
-
|
|
205
|
+
v,
|
|
182
206
|
{
|
|
183
|
-
name:
|
|
207
|
+
name: k,
|
|
184
208
|
label: "Group name"
|
|
185
209
|
},
|
|
186
210
|
{
|
|
187
211
|
type: "button",
|
|
188
212
|
label: "Toggle Lightbox",
|
|
189
|
-
command(
|
|
190
|
-
var
|
|
191
|
-
const
|
|
192
|
-
|
|
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
|
-
.${
|
|
221
|
+
.${h} {
|
|
198
222
|
display: inline-block;
|
|
199
223
|
padding: 10px;
|
|
200
224
|
}
|
|
201
225
|
`
|
|
202
226
|
},
|
|
203
227
|
init() {
|
|
204
|
-
const
|
|
205
|
-
this.on(
|
|
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(
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
this.addAttributes({ [
|
|
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
|
|
214
|
-
if (
|
|
215
|
-
const
|
|
216
|
-
this.addAttributes({ [
|
|
217
|
-
} else
|
|
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(
|
|
220
|
-
const { changed:
|
|
221
|
-
if (
|
|
222
|
-
this.removeTrait([
|
|
223
|
-
const
|
|
224
|
-
this.addTrait(
|
|
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 (!
|
|
229
|
-
const { toolbar:
|
|
230
|
-
!
|
|
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
|
|
239
|
-
const { em:
|
|
240
|
-
if (
|
|
241
|
-
|
|
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
|
-
|
|
244
|
-
let
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
},
|
|
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:
|
|
255
|
-
|
|
256
|
-
|
|
278
|
+
editor: t,
|
|
279
|
+
plan: x.free,
|
|
280
|
+
licenseKey: g.licenseKey,
|
|
281
|
+
pluginName: X,
|
|
257
282
|
cleanup: () => {
|
|
258
|
-
|
|
283
|
+
r.remove(T), c.removeType(T);
|
|
259
284
|
}
|
|
260
285
|
});
|
|
261
|
-
},
|
|
286
|
+
}, ee = Z(Q);
|
|
262
287
|
export {
|
|
263
|
-
|
|
288
|
+
ee as default
|
|
264
289
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
.${
|
|
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
|
|
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)}})})});
|