@grapesjs/studio-sdk-plugins 1.0.8 → 1.0.9-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/dialogComponent/index.cjs.js +4 -4
- package/dist/dialogComponent/index.es.js +27 -28
- package/dist/dialogComponent/index.umd.js +4 -4
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +51 -52
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +22 -22
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +5265 -4605
- package/dist/index.umd.js +22 -22
- package/dist/lightGalleryComponent/index.cjs.d.ts +3 -0
- package/dist/lightGalleryComponent/index.cjs.js +1 -0
- package/dist/lightGalleryComponent/index.d.ts +3 -0
- package/dist/lightGalleryComponent/index.es.d.ts +3 -0
- package/dist/lightGalleryComponent/index.es.js +718 -0
- package/dist/lightGalleryComponent/index.umd.js +1 -0
- package/dist/lightGalleryComponent/types.d.ts +57 -0
- package/dist/lightGalleryComponent/typesSchema.d.ts +3 -0
- package/dist/lightGalleryComponent/utils.d.ts +47 -0
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +32 -33
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +8 -8
- package/dist/prosemirror/index.es.js +806 -786
- package/dist/prosemirror/index.umd.js +9 -9
- package/dist/prosemirror/schema.d.ts +1 -1
- package/dist/prosemirror/types.d.ts +5 -0
- package/dist/prosemirror/utils.d.ts +3 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +35 -36
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const b="app.grapesjs.com",w="app-stage.grapesjs.com",W=[b,w,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],S="license:check:start",k="license:check:end",L=()=>typeof window<"u",x=({isDev:n,isStage:t})=>`${n?"":`https://${t?w:b}`}/api`,_=()=>{const n=L()&&window.location.hostname;return!!n&&(W.includes(n)||W.some(t=>n.endsWith(t)))},j=()=>(L()&&window.location.hostname)===b;var N={};const D=N.NODE_ENV!=="production";async function $({path:n,method:t="GET",headers:l={},body:o}){const s=`${x({isDev:D,isStage:!j()})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...l}};o&&(a.body=JSON.stringify(o));const i=await fetch(s,a);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.json()}function X(n){const t=n;return t.init=l=>o=>n(o,l),t}const q=n=>X(n);async function A({editor:n,pluginName:t,licenseKey:l,cleanup:o}){let g=!1;const s=_();n.on(S,()=>{g=!0}),n.on(k,({sdkLicense:a})=>{a||o()}),setTimeout(async()=>{if(!g){if(s)return;l&&await I({licenseKey:l,pluginName:t})||o()}},2e3)}async function I({licenseKey:n,pluginName:t}){try{const l=await $({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:o}=l.result||{};return!!o}catch(l){return console.error("Error during SDK license check:",l),!1}}const E=(...n)=>n.map(t=>`[data-gjs-type="${t}"]`).join(","),B="dialogComponent",U=function(n,t={}){const{Blocks:l,Components:o}=n,{licenseKey:g}=t,s="gjs-plg-dialog",a="gjs-plg-dialog-overlay",i="gjs-plg-dialog-content",h="gjs-plg-dialog-close",u="gjs-plg-dialog-title",y="gjs-plg-dialog-body",m="gjs-plg-dialog-description",f="gjs-plg-dialog-placeholder";l.add(s,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
5
|
-
`,category:"Extra",content:{type:s},activate:!0,...t.block}),o.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:a},{type:f}],draggable:
|
|
5
|
+
`,category:"Extra",content:{type:s},activate:!0,...t.block}),o.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:a},{type:f}],draggable:E("wrapper"),droppable:E(s),styles:`
|
|
6
6
|
.${s} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
9
9
|
}
|
|
10
|
-
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(r){var e;(e=r.getSelected())==null||e.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(r){const e=this;function
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(r){var e;(e=r.getSelected())==null||e.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(r){const e=this;function T(c){const p=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),d=e.querySelector('[data-type-role="gjs-plg-dialog-close"]');function v(){p.style.display="none"}c?(e._onCloseWhenPressingX=v,d.addEventListener("click",e._onCloseWhenPressingX)):(d.removeEventListener("click",e._onCloseWhenPressingX),e._onCloseWhenPressingX=null)}function C(c){const p=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function d(v){v.key==="Escape"&&(p.style.display="none")}c?(e._onCloseWhenPressingEsc=d,e.addEventListener("keydown",e._onCloseWhenPressingEsc)):(e.removeEventListener("keydown",e._onCloseWhenPressingEsc),e._onCloseWhenPressingEsc=null)}function P(c){const p=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function d(){p.style.display="flex"}c?(e._onOpenWhenLeavingWindow=d,document.addEventListener("mouseleave",e._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",e._onOpenWhenLeavingWindow),e._onOpenWhenLeavingWindow=null)}function O(c){const p=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function d(){const v=document.documentElement.scrollTop;c&&v>=Number(c)&&(p.style.display="flex")}c?(e._onOpenWhenScrollingToLevel=d,document.addEventListener("scroll",e._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",e._onOpenWhenScrollingToLevel),e._onOpenWhenScrollingToLevel=null)}T(r.closeWhenPressingX),C(r.closeWhenPressingEsc),P(r.openWhenLeavingWindow),O(r.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const e=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');e.style.display="flex"})}},view:{onActive(){const r=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');r.style.display="flex"}}}),o.addType(a,{model:{defaults:{tagName:"div",attributes:{class:a,"data-type-role":a},components:{type:i},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${a} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
.${m} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),o.addType(f,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:f,"data-type-role":f},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){this.listenTo(this.em,"run:core:preview",()=>{this.el.style.display="none"}),this.listenTo(this.em,"stop:core:preview",()=>{this.el.style.display=""})}}}),
|
|
59
|
+
`}}}),o.addType(f,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:f,"data-type-role":f},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){this.listenTo(this.em,"run:core:preview",()=>{this.el.style.display="none"}),this.listenTo(this.em,"stop:core:preview",()=>{this.el.style.display=""})}}}),A({editor:n,licenseKey:g,pluginName:B,cleanup:()=>{l.remove(s),o.removeType(s)}})},z=q(U);module.exports=z;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const b = "app.grapesjs.com", w = "app-stage.grapesjs.com", E = [
|
|
1
|
+
const b = "app.grapesjs.com", w = "app-stage.grapesjs.com", W = [
|
|
3
2
|
b,
|
|
4
3
|
w,
|
|
5
4
|
"localhost",
|
|
@@ -10,19 +9,19 @@ const b = "app.grapesjs.com", w = "app-stage.grapesjs.com", E = [
|
|
|
10
9
|
// For stackblitz.com demos
|
|
11
10
|
"-sandpack.codesandbox.io"
|
|
12
11
|
// For Sandpack demos
|
|
13
|
-
], S = "license:check:start",
|
|
14
|
-
const n =
|
|
15
|
-
return !!n && (
|
|
16
|
-
},
|
|
17
|
-
var
|
|
18
|
-
const D =
|
|
12
|
+
], S = "license:check:start", k = "license:check:end", L = () => typeof window < "u", x = ({ isDev: n, isStage: t }) => `${n ? "" : `https://${t ? w : b}`}/api`, _ = () => {
|
|
13
|
+
const n = L() && window.location.hostname;
|
|
14
|
+
return !!n && (W.includes(n) || W.some((t) => n.endsWith(t)));
|
|
15
|
+
}, j = () => (L() && window.location.hostname) === b;
|
|
16
|
+
var N = {};
|
|
17
|
+
const D = N.NODE_ENV !== "production";
|
|
19
18
|
async function $({
|
|
20
19
|
path: n,
|
|
21
20
|
method: t = "GET",
|
|
22
21
|
headers: l = {},
|
|
23
22
|
body: o
|
|
24
23
|
}) {
|
|
25
|
-
const s = `${
|
|
24
|
+
const s = `${x({ isDev: D, isStage: !j() })}${n}`, a = {
|
|
26
25
|
method: t,
|
|
27
26
|
headers: {
|
|
28
27
|
"Content-Type": "application/json",
|
|
@@ -35,31 +34,31 @@ async function $({
|
|
|
35
34
|
throw new Error(`HTTP error! status: ${i.status}`);
|
|
36
35
|
return i.json();
|
|
37
36
|
}
|
|
38
|
-
function
|
|
37
|
+
function X(n) {
|
|
39
38
|
const t = n;
|
|
40
39
|
return t.init = (l) => (o) => n(o, l), t;
|
|
41
40
|
}
|
|
42
|
-
const
|
|
43
|
-
async function
|
|
41
|
+
const q = (n) => /* @__PURE__ */ X(n);
|
|
42
|
+
async function A({
|
|
44
43
|
editor: n,
|
|
45
44
|
pluginName: t,
|
|
46
45
|
licenseKey: l,
|
|
47
46
|
cleanup: o
|
|
48
47
|
}) {
|
|
49
48
|
let g = !1;
|
|
50
|
-
const s =
|
|
49
|
+
const s = _();
|
|
51
50
|
n.on(S, () => {
|
|
52
51
|
g = !0;
|
|
53
|
-
}), n.on(
|
|
52
|
+
}), n.on(k, ({ sdkLicense: a }) => {
|
|
54
53
|
a || o();
|
|
55
54
|
}), setTimeout(async () => {
|
|
56
55
|
if (!g) {
|
|
57
56
|
if (s) return;
|
|
58
|
-
l && await
|
|
57
|
+
l && await I({ licenseKey: l, pluginName: t }) || o();
|
|
59
58
|
}
|
|
60
59
|
}, 2e3);
|
|
61
60
|
}
|
|
62
|
-
async function
|
|
61
|
+
async function I({ licenseKey: n, pluginName: t }) {
|
|
63
62
|
try {
|
|
64
63
|
const l = await $({
|
|
65
64
|
path: `/sdk/${n}`,
|
|
@@ -74,7 +73,7 @@ async function q({ licenseKey: n, pluginName: t }) {
|
|
|
74
73
|
return console.error("Error during SDK license check:", l), !1;
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
const
|
|
76
|
+
const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialogComponent", U = function(n, t = {}) {
|
|
78
77
|
const { Blocks: l, Components: o } = n, { licenseKey: g } = t, s = "gjs-plg-dialog", a = "gjs-plg-dialog-overlay", i = "gjs-plg-dialog-content", h = "gjs-plg-dialog-close", u = "gjs-plg-dialog-title", y = "gjs-plg-dialog-body", m = "gjs-plg-dialog-description", f = "gjs-plg-dialog-placeholder";
|
|
79
78
|
l.add(s, {
|
|
80
79
|
label: "Dialog",
|
|
@@ -93,8 +92,8 @@ const W = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), M = "dialo
|
|
|
93
92
|
tagName: "div",
|
|
94
93
|
attributes: { class: s, "data-type-role": s },
|
|
95
94
|
components: [{ type: a }, { type: f }],
|
|
96
|
-
draggable:
|
|
97
|
-
droppable:
|
|
95
|
+
draggable: E("wrapper"),
|
|
96
|
+
droppable: E(s),
|
|
98
97
|
styles: `
|
|
99
98
|
.${s} {
|
|
100
99
|
position: relative;
|
|
@@ -149,28 +148,28 @@ const W = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), M = "dialo
|
|
|
149
148
|
],
|
|
150
149
|
script: function(r) {
|
|
151
150
|
const e = this;
|
|
152
|
-
function
|
|
151
|
+
function T(c) {
|
|
153
152
|
const p = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'), d = e.querySelector('[data-type-role="gjs-plg-dialog-close"]');
|
|
154
153
|
function v() {
|
|
155
154
|
p.style.display = "none";
|
|
156
155
|
}
|
|
157
156
|
c ? (e._onCloseWhenPressingX = v, d.addEventListener("click", e._onCloseWhenPressingX)) : (d.removeEventListener("click", e._onCloseWhenPressingX), e._onCloseWhenPressingX = null);
|
|
158
157
|
}
|
|
159
|
-
function
|
|
158
|
+
function C(c) {
|
|
160
159
|
const p = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
161
160
|
function d(v) {
|
|
162
161
|
v.key === "Escape" && (p.style.display = "none");
|
|
163
162
|
}
|
|
164
163
|
c ? (e._onCloseWhenPressingEsc = d, e.addEventListener("keydown", e._onCloseWhenPressingEsc)) : (e.removeEventListener("keydown", e._onCloseWhenPressingEsc), e._onCloseWhenPressingEsc = null);
|
|
165
164
|
}
|
|
166
|
-
function
|
|
165
|
+
function P(c) {
|
|
167
166
|
const p = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
168
167
|
function d() {
|
|
169
168
|
p.style.display = "flex";
|
|
170
169
|
}
|
|
171
170
|
c ? (e._onOpenWhenLeavingWindow = d, document.addEventListener("mouseleave", e._onOpenWhenLeavingWindow)) : (document.removeEventListener("mouseleave", e._onOpenWhenLeavingWindow), e._onOpenWhenLeavingWindow = null);
|
|
172
171
|
}
|
|
173
|
-
function
|
|
172
|
+
function O(c) {
|
|
174
173
|
const p = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
175
174
|
function d() {
|
|
176
175
|
const v = document.documentElement.scrollTop;
|
|
@@ -178,7 +177,7 @@ const W = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), M = "dialo
|
|
|
178
177
|
}
|
|
179
178
|
c ? (e._onOpenWhenScrollingToLevel = d, document.addEventListener("scroll", e._onOpenWhenScrollingToLevel)) : (document.removeEventListener("scroll", e._onOpenWhenScrollingToLevel), e._onOpenWhenScrollingToLevel = null);
|
|
180
179
|
}
|
|
181
|
-
|
|
180
|
+
T(r.closeWhenPressingX), C(r.closeWhenPressingEsc), P(r.openWhenLeavingWindow), O(r.openWhenScrollingToLevel);
|
|
182
181
|
}
|
|
183
182
|
},
|
|
184
183
|
init() {
|
|
@@ -336,15 +335,15 @@ const W = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), M = "dialo
|
|
|
336
335
|
});
|
|
337
336
|
}
|
|
338
337
|
}
|
|
339
|
-
}),
|
|
338
|
+
}), A({
|
|
340
339
|
editor: n,
|
|
341
340
|
licenseKey: g,
|
|
342
|
-
pluginName:
|
|
341
|
+
pluginName: B,
|
|
343
342
|
cleanup: () => {
|
|
344
343
|
l.remove(s), o.removeType(s);
|
|
345
344
|
}
|
|
346
345
|
});
|
|
347
|
-
},
|
|
346
|
+
}, H = q(U);
|
|
348
347
|
export {
|
|
349
|
-
|
|
348
|
+
H as default
|
|
350
349
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(p,
|
|
1
|
+
(function(p,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(p=typeof globalThis<"u"?globalThis:p||self,p.StudioSdkPlugins_dialogComponent=h())})(this,function(){"use strict";const p="app.grapesjs.com",h="app-stage.grapesjs.com",E=[p,h,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],C="license:check:start",L="license:check:end",w=()=>typeof window<"u",P=({isDev:n,isStage:t})=>`${n?"":`https://${t?h:p}`}/api`,S=()=>{const n=w()&&window.location.hostname;return!!n&&(E.includes(n)||E.some(t=>n.endsWith(t)))},O=()=>(w()&&window.location.hostname)===p;var k={};const x=k.NODE_ENV!=="production";async function _({path:n,method:t="GET",headers:l={},body:o}){const s=`${P({isDev:x,isStage:!O()})}${n}`,i={method:t,headers:{"Content-Type":"application/json",...l}};o&&(i.body=JSON.stringify(o));const a=await fetch(s,i);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function j(n){const t=n;return t.init=l=>o=>n(o,l),t}const N=n=>j(n);async function D({editor:n,pluginName:t,licenseKey:l,cleanup:o}){let u=!1;const s=S();n.on(C,()=>{u=!0}),n.on(L,({sdkLicense:i})=>{i||o()}),setTimeout(async()=>{if(!u){if(s)return;l&&await $({licenseKey:l,pluginName:t})||o()}},2e3)}async function $({licenseKey:n,pluginName:t}){try{const l=await _({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:o}=l.result||{};return!!o}catch(l){return console.error("Error during SDK license check:",l),!1}}const T=(...n)=>n.map(t=>`[data-gjs-type="${t}"]`).join(","),X="dialogComponent";return N(function(n,t={}){const{Blocks:l,Components:o}=n,{licenseKey:u}=t,s="gjs-plg-dialog",i="gjs-plg-dialog-overlay",a="gjs-plg-dialog-content",y="gjs-plg-dialog-close",f="gjs-plg-dialog-title",m="gjs-plg-dialog-body",v="gjs-plg-dialog-description",W="gjs-plg-dialog-placeholder";l.add(s,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
5
|
-
`,category:"Extra",content:{type:s},activate:!0,...t.block}),o.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:i},{type:
|
|
5
|
+
`,category:"Extra",content:{type:s},activate:!0,...t.block}),o.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:i},{type:W}],draggable:T("wrapper"),droppable:T(s),styles:`
|
|
6
6
|
.${s} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
9
9
|
}
|
|
10
|
-
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(r){var e;(e=r.getSelected())==null||e.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(r){const e=this;function
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(r){var e;(e=r.getSelected())==null||e.trigger("active")}},{type:"checkbox",label:"Close when pressing X",name:"closeWhenPressingX",default:!0,changeProp:!0},{type:"checkbox",label:"Close when pressing ESC",name:"closeWhenPressingEsc",default:!0,changeProp:!0},{type:"checkbox",label:"Open when leaving the window",name:"openWhenLeavingWindow",default:!1,changeProp:!0},{type:"number",label:"Open when scrolling to level",name:"openWhenScrollingToLevel",default:0,changeProp:!0}],"script-props":["closeWhenPressingX","closeWhenPressingEsc","openWhenLeavingWindow","openWhenScrollingToLevel"],script:function(r){const e=this;function q(d){const g=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),c=e.querySelector('[data-type-role="gjs-plg-dialog-close"]');function b(){g.style.display="none"}d?(e._onCloseWhenPressingX=b,c.addEventListener("click",e._onCloseWhenPressingX)):(c.removeEventListener("click",e._onCloseWhenPressingX),e._onCloseWhenPressingX=null)}function A(d){const g=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function c(b){b.key==="Escape"&&(g.style.display="none")}d?(e._onCloseWhenPressingEsc=c,e.addEventListener("keydown",e._onCloseWhenPressingEsc)):(e.removeEventListener("keydown",e._onCloseWhenPressingEsc),e._onCloseWhenPressingEsc=null)}function I(d){const g=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function c(){g.style.display="flex"}d?(e._onOpenWhenLeavingWindow=c,document.addEventListener("mouseleave",e._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",e._onOpenWhenLeavingWindow),e._onOpenWhenLeavingWindow=null)}function B(d){const g=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function c(){const b=document.documentElement.scrollTop;d&&b>=Number(d)&&(g.style.display="flex")}d?(e._onOpenWhenScrollingToLevel=c,document.addEventListener("scroll",e._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",e._onOpenWhenScrollingToLevel),e._onOpenWhenScrollingToLevel=null)}q(r.closeWhenPressingX),A(r.closeWhenPressingEsc),I(r.openWhenLeavingWindow),B(r.openWhenScrollingToLevel)}},init(){this.on("active",this.handleOpenWhenClickPlaceholder)},handleOpenWhenClickPlaceholder(){this.view.el.querySelector('[data-type-role="gjs-plg-dialog-placeholder"]').addEventListener("click",()=>{const e=this.view.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');e.style.display="flex"})}},view:{onActive(){const r=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');r.style.display="flex"}}}),o.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:{type:a},droppable:!1,draggable:!1,styles:`
|
|
11
11
|
.${i} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
.${v} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),o.addType(
|
|
59
|
+
`}}}),o.addType(W,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:W,"data-type-role":W},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){this.listenTo(this.em,"run:core:preview",()=>{this.el.style.display="none"}),this.listenTo(this.em,"stop:core:preview",()=>{this.el.style.display=""})}}}),D({editor:n,licenseKey:u,pluginName:X,cleanup:()=>{l.remove(s),o.removeType(s)}})})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
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
2
|
.${u} {
|
|
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
|
|
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;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
D,
|
|
1
|
+
const E = "app.grapesjs.com", j = "app-stage.grapesjs.com", O = [
|
|
2
|
+
E,
|
|
3
|
+
j,
|
|
5
4
|
"localhost",
|
|
6
5
|
"127.0.0.1",
|
|
7
6
|
".local-credentialless.webcontainer.io",
|
|
@@ -10,19 +9,19 @@ const _ = "app.grapesjs.com", D = "app-stage.grapesjs.com", O = [
|
|
|
10
9
|
// For stackblitz.com demos
|
|
11
10
|
"-sandpack.codesandbox.io"
|
|
12
11
|
// For Sandpack demos
|
|
13
|
-
],
|
|
14
|
-
const o =
|
|
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;
|
|
15
14
|
return !!o && (O.includes(o) || O.some((i) => o.endsWith(i)));
|
|
16
|
-
}, U = () => (
|
|
17
|
-
var
|
|
18
|
-
const
|
|
19
|
-
async function
|
|
15
|
+
}, U = () => (H() && window.location.hostname) === E;
|
|
16
|
+
var F = {};
|
|
17
|
+
const G = F.NODE_ENV !== "production";
|
|
18
|
+
async function K({
|
|
20
19
|
path: o,
|
|
21
20
|
method: i = "GET",
|
|
22
21
|
headers: c = {},
|
|
23
22
|
body: a
|
|
24
23
|
}) {
|
|
25
|
-
const u = `${W({ isDev:
|
|
24
|
+
const u = `${W({ isDev: G, isStage: !U() })}${o}`, r = {
|
|
26
25
|
method: i,
|
|
27
26
|
headers: {
|
|
28
27
|
"Content-Type": "application/json",
|
|
@@ -46,14 +45,14 @@ async function q({
|
|
|
46
45
|
licenseKey: c,
|
|
47
46
|
cleanup: a
|
|
48
47
|
}) {
|
|
49
|
-
let
|
|
48
|
+
let p = !1;
|
|
50
49
|
const u = R();
|
|
51
|
-
o.on(
|
|
52
|
-
|
|
53
|
-
}), o.on(
|
|
50
|
+
o.on(B, () => {
|
|
51
|
+
p = !0;
|
|
52
|
+
}), o.on(P, ({ sdkLicense: r }) => {
|
|
54
53
|
r || a();
|
|
55
54
|
}), setTimeout(async () => {
|
|
56
|
-
if (!
|
|
55
|
+
if (!p) {
|
|
57
56
|
if (u) return;
|
|
58
57
|
c && await z({ licenseKey: c, pluginName: i }) || a();
|
|
59
58
|
}
|
|
@@ -61,7 +60,7 @@ async function q({
|
|
|
61
60
|
}
|
|
62
61
|
async function z({ licenseKey: o, pluginName: i }) {
|
|
63
62
|
try {
|
|
64
|
-
const c = await
|
|
63
|
+
const c = await K({
|
|
65
64
|
path: `/sdk/${o}`,
|
|
66
65
|
method: "POST",
|
|
67
66
|
body: JSON.stringify({
|
|
@@ -74,44 +73,44 @@ async function z({ licenseKey: o, pluginName: i }) {
|
|
|
74
73
|
return console.error("Error during SDK license check:", c), !1;
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
const X = "gjs-plg-", Y = "fsLightboxComponent",
|
|
76
|
+
const X = "gjs-plg-", Y = "fsLightboxComponent", S = "data-fslightbox", L = "data-type", Q = "fslightbox-open", b = "fslightbox", f = {
|
|
78
77
|
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>',
|
|
79
78
|
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>',
|
|
80
79
|
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>',
|
|
81
80
|
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>',
|
|
82
81
|
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>'
|
|
83
82
|
}, tt = function(o, i = {}) {
|
|
84
|
-
const { Blocks: c, Components: a } = o,
|
|
83
|
+
const { Blocks: c, Components: a } = o, p = "Lightbox", u = `${X}${b}`, r = {
|
|
85
84
|
toolbarIconOpen: f.eye,
|
|
86
85
|
block: {},
|
|
87
86
|
defaultSrc: "https://placehold.co/300/777/white.png?text=Image",
|
|
88
87
|
cdnScript: "https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",
|
|
89
88
|
...i
|
|
90
|
-
}, { block: v, toolbarIconOpen:
|
|
91
|
-
const t = this, n = "data-fslightbox", s = window,
|
|
92
|
-
var
|
|
89
|
+
}, { block: v, toolbarIconOpen: _, defaultSrc: A } = r, $ = function(e) {
|
|
90
|
+
const t = this, n = "data-fslightbox", s = window, h = () => {
|
|
91
|
+
var w;
|
|
93
92
|
const d = s.refreshFsLightbox;
|
|
94
93
|
d == null || d();
|
|
95
94
|
const x = t.getAttribute(n);
|
|
96
|
-
if ((
|
|
95
|
+
if ((w = s.fsLightboxInstances) == null || w[x], !s._isEditor) return;
|
|
97
96
|
Array.from(document.querySelectorAll(`[${n}]`)).forEach((g) => {
|
|
98
97
|
const m = g.onclick;
|
|
99
|
-
g.onclick = function(
|
|
100
|
-
|
|
98
|
+
g.onclick = function(T) {
|
|
99
|
+
T.preventDefault();
|
|
101
100
|
const N = g;
|
|
102
|
-
!N.__skipLb && (m == null || m(
|
|
101
|
+
!N.__skipLb && (m == null || m(T)), N.__skipLb = !0;
|
|
103
102
|
};
|
|
104
103
|
});
|
|
105
104
|
};
|
|
106
105
|
if (s.refreshFsLightbox)
|
|
107
|
-
|
|
106
|
+
h();
|
|
108
107
|
else {
|
|
109
108
|
const d = document.createElement("script");
|
|
110
|
-
d.src = e.cdnScript, d.onload =
|
|
109
|
+
d.src = e.cdnScript, d.onload = h, document.head.appendChild(d);
|
|
111
110
|
}
|
|
112
|
-
},
|
|
111
|
+
}, D = (e) => ({
|
|
113
112
|
id: `${b}-open-lb`,
|
|
114
|
-
label:
|
|
113
|
+
label: _,
|
|
115
114
|
command: () => {
|
|
116
115
|
const t = e.getView();
|
|
117
116
|
t == null || t.toggleLightbox();
|
|
@@ -128,12 +127,12 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
128
127
|
],
|
|
129
128
|
// @ts-expect-error Studio related prop
|
|
130
129
|
labelToTitle: !0
|
|
131
|
-
},
|
|
130
|
+
}, C = {
|
|
132
131
|
id: "href-image",
|
|
133
132
|
name: "href",
|
|
134
133
|
type: "file",
|
|
135
134
|
label: "Source Image"
|
|
136
|
-
},
|
|
135
|
+
}, I = {
|
|
137
136
|
id: "href-video",
|
|
138
137
|
name: "href",
|
|
139
138
|
label: "Source Video",
|
|
@@ -143,14 +142,14 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
143
142
|
name: "href",
|
|
144
143
|
label: "Source Element",
|
|
145
144
|
placeholder: "#custom-element-id"
|
|
146
|
-
},
|
|
147
|
-
image: [
|
|
148
|
-
video: [
|
|
145
|
+
}, M = {
|
|
146
|
+
image: [C],
|
|
147
|
+
video: [I],
|
|
149
148
|
el: [V]
|
|
150
149
|
};
|
|
151
150
|
a.addType(b, {
|
|
152
151
|
block: v && {
|
|
153
|
-
label:
|
|
152
|
+
label: p,
|
|
154
153
|
media: f.imageLightbox,
|
|
155
154
|
category: "Extra",
|
|
156
155
|
select: !0,
|
|
@@ -158,30 +157,30 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
158
157
|
},
|
|
159
158
|
isComponent: (e) => {
|
|
160
159
|
var t;
|
|
161
|
-
return (t = e.hasAttribute) == null ? void 0 : t.call(e,
|
|
160
|
+
return (t = e.hasAttribute) == null ? void 0 : t.call(e, S);
|
|
162
161
|
},
|
|
163
162
|
extendFn: ["initToolbar"],
|
|
164
163
|
model: {
|
|
165
164
|
defaults: {
|
|
166
165
|
tagName: "a",
|
|
167
|
-
name:
|
|
166
|
+
name: p,
|
|
168
167
|
icon: f.imageLightbox,
|
|
169
168
|
classes: u,
|
|
170
169
|
draggable: (e, t) => !t.is(b),
|
|
171
170
|
attributes: {
|
|
172
|
-
[
|
|
171
|
+
[S]: "lightbox",
|
|
173
172
|
[L]: "image",
|
|
174
173
|
href: A
|
|
175
174
|
},
|
|
176
175
|
components: { type: "image", src: A },
|
|
177
|
-
script:
|
|
176
|
+
script: $,
|
|
178
177
|
cdnScript: r.cdnScript,
|
|
179
178
|
"script-props": ["attributes", "cdnScript"],
|
|
180
179
|
[l]: "image",
|
|
181
180
|
traits: [
|
|
182
181
|
k,
|
|
183
182
|
{
|
|
184
|
-
name:
|
|
183
|
+
name: S,
|
|
185
184
|
label: "Group name"
|
|
186
185
|
},
|
|
187
186
|
{
|
|
@@ -207,8 +206,8 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
207
206
|
},
|
|
208
207
|
onSourceTypeChange(e, t, n) {
|
|
209
208
|
if (n.adjust) return;
|
|
210
|
-
const
|
|
211
|
-
this.addAttributes({ [L]:
|
|
209
|
+
const h = this.get(l) === "video" ? "video" : "image";
|
|
210
|
+
this.addAttributes({ [L]: h, href: "" });
|
|
212
211
|
},
|
|
213
212
|
adjustSourceType() {
|
|
214
213
|
const e = this.get(l), t = this.getAttributes().href || "", n = { adjust: !0 };
|
|
@@ -220,14 +219,14 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
220
219
|
updateTraits(e = {}) {
|
|
221
220
|
const { changed: t } = this, { init: n } = e;
|
|
222
221
|
if (t[k.name] || n) {
|
|
223
|
-
this.removeTrait([
|
|
224
|
-
const s = this.get(l) || "image",
|
|
225
|
-
this.addTrait(
|
|
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 });
|
|
226
225
|
}
|
|
227
226
|
},
|
|
228
227
|
initToolbar() {
|
|
229
|
-
if (!
|
|
230
|
-
const { toolbar: e } = this, t =
|
|
228
|
+
if (!_) return;
|
|
229
|
+
const { toolbar: e } = this, t = D(this);
|
|
231
230
|
!e.find((s) => s.id === t.id) && (e == null || e.unshift(t));
|
|
232
231
|
}
|
|
233
232
|
},
|
|
@@ -237,7 +236,7 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
237
236
|
},
|
|
238
237
|
toggleLightbox() {
|
|
239
238
|
var g;
|
|
240
|
-
const { em: e, el: t, model: n } = this, { Canvas: s } = e,
|
|
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];
|
|
241
240
|
if (x.classList.contains(Q))
|
|
242
241
|
y.close();
|
|
243
242
|
else {
|
|
@@ -246,7 +245,7 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
246
245
|
y.props.onOpen = () => {
|
|
247
246
|
m = s.getSpots(), setTimeout(() => s.removeSpots());
|
|
248
247
|
}, y.props.onClose = () => {
|
|
249
|
-
m.forEach((
|
|
248
|
+
m.forEach((T) => s.addSpot(T.attributes));
|
|
250
249
|
}, t.click();
|
|
251
250
|
}
|
|
252
251
|
}
|
|
@@ -259,7 +258,7 @@ const X = "gjs-plg-", Y = "fsLightboxComponent", T = "data-fslightbox", L = "dat
|
|
|
259
258
|
c.remove(b), a.removeType(b);
|
|
260
259
|
}
|
|
261
260
|
});
|
|
262
|
-
},
|
|
261
|
+
}, et = J(tt);
|
|
263
262
|
export {
|
|
264
|
-
|
|
263
|
+
et as default
|
|
265
264
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(u
|
|
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
2
|
.${f} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
padding: 10px;
|
|
5
5
|
}
|
|
6
|
-
`},init(){const
|
|
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)}})})});
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as dialogComponent } from './dialogComponent';
|
|
|
2
2
|
export { default as tableComponent } from './tableComponent';
|
|
3
3
|
export { default as listPagesComponent } from './listPagesComponent';
|
|
4
4
|
export { default as fsLightboxComponent } from './fsLightboxComponent';
|
|
5
|
+
export { default as lightGalleryComponent } from './lightGalleryComponent';
|
|
5
6
|
export { default as rteProseMirror } from './prosemirror';
|