@grapesjs/studio-sdk-plugins 1.0.9 → 1.0.10
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
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare function api({ path, method, headers, body }: {
|
|
1
|
+
export declare function api({ path, baseApiUrl, method, headers, params, body }: {
|
|
2
2
|
path: string;
|
|
3
|
+
baseApiUrl?: string;
|
|
3
4
|
method: RequestInit['method'];
|
|
4
5
|
headers?: RequestInit['headers'];
|
|
5
6
|
body?: RequestInit['body'];
|
|
7
|
+
params?: Record<string, any>;
|
|
6
8
|
}): Promise<Record<string, any>>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const C="app.grapesjs.com",O="app-stage.grapesjs.com",L=[C,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],S="license:check:start",j="license:check:end",_=()=>typeof window<"u",N=({isDev:n,isStage:l})=>`${n?"":`https://${l?O:C}`}/api`,$=()=>{const n=_()&&window.location.hostname;return!!n&&(L.includes(n)||L.some(l=>n.endsWith(l)))};var f=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(f||{});async function D({path:n,baseApiUrl:l,method:a="GET",headers:t={},params:p,body:s}){const u=`${l||N({isDev:!1,isStage:!1})}${n}`,i={method:a,headers:{"Content-Type":"application/json",...t}};s&&(i.body=JSON.stringify(s));const c=p?new URLSearchParams(p).toString():"",o=c?`?${c}`:"",r=await fetch(`${u}${o}`,i);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const P={[f.free]:0,[f.startup]:10,[f.business]:20,[f.enterprise]:30};function A(n){const l=n;return l.init=a=>t=>n(t,a),l}const q=n=>A(n);async function U({editor:n,plan:l,pluginName:a,licenseKey:t,cleanup:p}){let s="",g=!1;const u=$(),i=o=>{console.warn("Cleanup plugin:",a,"Reason:",o),p()},c=(o={})=>{var e;const{error:r,sdkLicense:m}=o,W=(e=o.plan)==null?void 0:e.category;if(!(m||o.license)||r)i(r||"Invalid license");else if(W){const w=P[l],E=P[W];w>E&&i({pluginRequiredPlan:l,licensePlan:W})}};n.on(S,o=>{s=o==null?void 0:o.baseApiUrl,g=!0}),n.on(j,o=>{c(o)}),setTimeout(async()=>{if(!g){if(u)return;if(t){const o=await X({licenseKey:t,pluginName:a,baseApiUrl:s});o&&c(o)}else i("The `licenseKey` option not provided")}},2e3)}async function X(n){const{licenseKey:l,pluginName:a,baseApiUrl:t}=n;try{return(await D({baseApiUrl:t,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const T=(...n)=>n.map(l=>`[data-gjs-type="${l}"]`).join(","),I="dialogComponent",B=function(n,l={}){const{Blocks:a,Components:t}=n,{licenseKey:p}=l,s="gjs-plg-dialog",g="gjs-plg-dialog-overlay",u="gjs-plg-dialog-content",i="gjs-plg-dialog-close",c="gjs-plg-dialog-title",o="gjs-plg-dialog-body",r="gjs-plg-dialog-description",m="gjs-plg-dialog-placeholder";a.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,...
|
|
5
|
+
`,category:"Extra",content:{type:s},activate:!0,...l.block}),t.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:g},{type:m}],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(
|
|
11
|
-
.${
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(d){var e;(e=d.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(d){const e=this;function w(h){const v=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),y=e.querySelector('[data-type-role="gjs-plg-dialog-close"]');function b(){v.style.display="none"}h?(e._onCloseWhenPressingX=b,y.addEventListener("click",e._onCloseWhenPressingX)):(y.removeEventListener("click",e._onCloseWhenPressingX),e._onCloseWhenPressingX=null)}function E(h){const v=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(b){b.key==="Escape"&&(v.style.display="none")}h?(e._onCloseWhenPressingEsc=y,e.addEventListener("keydown",e._onCloseWhenPressingEsc)):(e.removeEventListener("keydown",e._onCloseWhenPressingEsc),e._onCloseWhenPressingEsc=null)}function x(h){const v=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(){v.style.display="flex"}h?(e._onOpenWhenLeavingWindow=y,document.addEventListener("mouseleave",e._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",e._onOpenWhenLeavingWindow),e._onOpenWhenLeavingWindow=null)}function k(h){const v=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(){const b=document.documentElement.scrollTop;h&&b>=Number(h)&&(v.style.display="flex")}h?(e._onOpenWhenScrollingToLevel=y,document.addEventListener("scroll",e._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",e._onOpenWhenScrollingToLevel),e._onOpenWhenScrollingToLevel=null)}w(d.closeWhenPressingX),E(d.closeWhenPressingEsc),x(d.openWhenLeavingWindow),k(d.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 d=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');d.style.display="flex"}}}),t.addType(g,{model:{defaults:{tagName:"div",attributes:{class:g,"data-type-role":g},components:{type:u},droppable:!1,draggable:!1,styles:`
|
|
11
|
+
.${g} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
14
14
|
left: 0;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
justify-content: center;
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.5);
|
|
21
21
|
}
|
|
22
|
-
`}}}),
|
|
23
|
-
.${
|
|
22
|
+
`}}}),t.addType(u,{model:{defaults:{tagName:"div",attributes:{class:u,"data-type-role":u},components:[{type:i},{type:c},{type:o}],droppable:!1,draggable:!1,styles:`
|
|
23
|
+
.${u} {
|
|
24
24
|
position: relative;
|
|
25
25
|
background-color: #fff;
|
|
26
26
|
border-radius: 10px;
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
height: 600px;
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
|
-
`}}}),
|
|
34
|
-
.${
|
|
33
|
+
`}}}),t.addType(i,{model:{defaults:{tagName:"button",attributes:{class:i,"data-type-role":i},components:"×",droppable:!1,draggable:!1,styles:`
|
|
34
|
+
.${i} {
|
|
35
35
|
position: absolute;
|
|
36
36
|
top: 10px;
|
|
37
37
|
right: 10px;
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
font-size: 20px;
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
|
-
`}}}),
|
|
46
|
-
.${
|
|
45
|
+
`}}}),t.addType(c,{model:{defaults:{tagName:"h2",attributes:{class:c,"data-type-role":c},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
|
|
46
|
+
.${c} {
|
|
47
47
|
margin: 0;
|
|
48
48
|
padding: 0 40px 20px 0;
|
|
49
49
|
}
|
|
50
|
-
`}}}),
|
|
51
|
-
.${
|
|
50
|
+
`}}}),t.addType(o,{model:{defaults:{tagName:"div",attributes:{class:o,"data-type-role":o},components:[{type:r}],styles:`
|
|
51
|
+
.${o} {
|
|
52
52
|
height: 90%;
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
`}}}),
|
|
56
|
-
.${
|
|
55
|
+
`}}}),t.addType(r,{model:{defaults:{tagName:"p",attributes:{class:r,"data-type-role":r},components:"This is a customizable dialog!",editable:!0,styles:`
|
|
56
|
+
.${r} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),
|
|
59
|
+
`}}}),t.addType(m,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:m,"data-type-role":m},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=""})}}}),U({editor:n,licenseKey:p,plan:f.free,pluginName:I,cleanup:()=>{a.remove(s),t.removeType(s)}})},z=q(B);module.exports=z;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const C = "app.grapesjs.com", O = "app-stage.grapesjs.com", L = [
|
|
2
|
+
C,
|
|
3
|
+
O,
|
|
4
4
|
"localhost",
|
|
5
5
|
"127.0.0.1",
|
|
6
6
|
".local-credentialless.webcontainer.io",
|
|
@@ -9,73 +9,97 @@ const b = "app.grapesjs.com", w = "app-stage.grapesjs.com", W = [
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
"-sandpack.codesandbox.io"
|
|
11
11
|
// For Sandpack demos
|
|
12
|
-
], S = "license:check:start",
|
|
13
|
-
const n =
|
|
14
|
-
return !!n && (
|
|
15
|
-
}
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
async function $({
|
|
12
|
+
], S = "license:check:start", j = "license:check:end", _ = () => typeof window < "u", N = ({ isDev: n, isStage: l }) => `${n ? "" : `https://${l ? O : C}`}/api`, $ = () => {
|
|
13
|
+
const n = _() && window.location.hostname;
|
|
14
|
+
return !!n && (L.includes(n) || L.some((l) => n.endsWith(l)));
|
|
15
|
+
};
|
|
16
|
+
var f = /* @__PURE__ */ ((n) => (n.free = "free", n.startup = "startup", n.business = "business", n.enterprise = "enterprise", n))(f || {});
|
|
17
|
+
async function D({
|
|
19
18
|
path: n,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
baseApiUrl: l,
|
|
20
|
+
method: a = "GET",
|
|
21
|
+
headers: t = {},
|
|
22
|
+
params: p,
|
|
23
|
+
body: s
|
|
23
24
|
}) {
|
|
24
|
-
const
|
|
25
|
-
method:
|
|
25
|
+
const u = `${l || N({ isDev: !1, isStage: !1 })}${n}`, i = {
|
|
26
|
+
method: a,
|
|
26
27
|
headers: {
|
|
27
28
|
"Content-Type": "application/json",
|
|
28
|
-
...
|
|
29
|
+
...t
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`HTTP error! status: ${
|
|
35
|
-
return
|
|
32
|
+
s && (i.body = JSON.stringify(s));
|
|
33
|
+
const c = p ? new URLSearchParams(p).toString() : "", o = c ? `?${c}` : "", r = await fetch(`${u}${o}`, i);
|
|
34
|
+
if (!r.ok)
|
|
35
|
+
throw new Error(`HTTP error! status: ${r.status}`);
|
|
36
|
+
return r.json();
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const P = {
|
|
39
|
+
[f.free]: 0,
|
|
40
|
+
[f.startup]: 10,
|
|
41
|
+
[f.business]: 20,
|
|
42
|
+
[f.enterprise]: 30
|
|
43
|
+
};
|
|
44
|
+
function A(n) {
|
|
45
|
+
const l = n;
|
|
46
|
+
return l.init = (a) => (t) => n(t, a), l;
|
|
40
47
|
}
|
|
41
|
-
const q = (n) => /* @__PURE__ */
|
|
42
|
-
async function
|
|
48
|
+
const q = (n) => /* @__PURE__ */ A(n);
|
|
49
|
+
async function U({
|
|
43
50
|
editor: n,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
plan: l,
|
|
52
|
+
pluginName: a,
|
|
53
|
+
licenseKey: t,
|
|
54
|
+
cleanup: p
|
|
47
55
|
}) {
|
|
48
|
-
let g = !1;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
let s = "", g = !1;
|
|
57
|
+
const u = $(), i = (o) => {
|
|
58
|
+
console.warn("Cleanup plugin:", a, "Reason:", o), p();
|
|
59
|
+
}, c = (o = {}) => {
|
|
60
|
+
var e;
|
|
61
|
+
const { error: r, sdkLicense: m } = o, W = (e = o.plan) == null ? void 0 : e.category;
|
|
62
|
+
if (!(m || o.license) || r)
|
|
63
|
+
i(r || "Invalid license");
|
|
64
|
+
else if (W) {
|
|
65
|
+
const w = P[l], E = P[W];
|
|
66
|
+
w > E && i({ pluginRequiredPlan: l, licensePlan: W });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
n.on(S, (o) => {
|
|
70
|
+
s = o == null ? void 0 : o.baseApiUrl, g = !0;
|
|
71
|
+
}), n.on(j, (o) => {
|
|
72
|
+
c(o);
|
|
54
73
|
}), setTimeout(async () => {
|
|
55
74
|
if (!g) {
|
|
56
|
-
if (
|
|
57
|
-
|
|
75
|
+
if (u) return;
|
|
76
|
+
if (t) {
|
|
77
|
+
const o = await X({ licenseKey: t, pluginName: a, baseApiUrl: s });
|
|
78
|
+
o && c(o);
|
|
79
|
+
} else
|
|
80
|
+
i("The `licenseKey` option not provided");
|
|
58
81
|
}
|
|
59
82
|
}, 2e3);
|
|
60
83
|
}
|
|
61
|
-
async function
|
|
84
|
+
async function X(n) {
|
|
85
|
+
const { licenseKey: l, pluginName: a, baseApiUrl: t } = n;
|
|
62
86
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
87
|
+
return (await D({
|
|
88
|
+
baseApiUrl: t,
|
|
89
|
+
path: `/sdk/${l || "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:", l), !1;
|
|
93
|
+
pn: a
|
|
94
|
+
}
|
|
95
|
+
})).result || {};
|
|
96
|
+
} catch (p) {
|
|
97
|
+
return console.error("Error during SDK license check:", p), !1;
|
|
74
98
|
}
|
|
75
99
|
}
|
|
76
|
-
const
|
|
77
|
-
const { Blocks:
|
|
78
|
-
|
|
100
|
+
const T = (...n) => n.map((l) => `[data-gjs-type="${l}"]`).join(","), I = "dialogComponent", B = function(n, l = {}) {
|
|
101
|
+
const { Blocks: a, Components: t } = n, { licenseKey: p } = l, s = "gjs-plg-dialog", g = "gjs-plg-dialog-overlay", u = "gjs-plg-dialog-content", i = "gjs-plg-dialog-close", c = "gjs-plg-dialog-title", o = "gjs-plg-dialog-body", r = "gjs-plg-dialog-description", m = "gjs-plg-dialog-placeholder";
|
|
102
|
+
a.add(s, {
|
|
79
103
|
label: "Dialog",
|
|
80
104
|
media: `
|
|
81
105
|
<svg viewBox="0 0 24 24">
|
|
@@ -85,15 +109,15 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
85
109
|
category: "Extra",
|
|
86
110
|
content: { type: s },
|
|
87
111
|
activate: !0,
|
|
88
|
-
...
|
|
89
|
-
}),
|
|
112
|
+
...l.block
|
|
113
|
+
}), t.addType(s, {
|
|
90
114
|
model: {
|
|
91
115
|
defaults: {
|
|
92
116
|
tagName: "div",
|
|
93
117
|
attributes: { class: s, "data-type-role": s },
|
|
94
|
-
components: [{ type:
|
|
95
|
-
draggable:
|
|
96
|
-
droppable:
|
|
118
|
+
components: [{ type: g }, { type: m }],
|
|
119
|
+
draggable: T("wrapper"),
|
|
120
|
+
droppable: T(s),
|
|
97
121
|
styles: `
|
|
98
122
|
.${s} {
|
|
99
123
|
position: relative;
|
|
@@ -106,9 +130,9 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
106
130
|
label: "Open dialog",
|
|
107
131
|
name: "onActive",
|
|
108
132
|
changeProp: !0,
|
|
109
|
-
command(
|
|
133
|
+
command(d) {
|
|
110
134
|
var e;
|
|
111
|
-
(e =
|
|
135
|
+
(e = d.getSelected()) == null || e.trigger("active");
|
|
112
136
|
}
|
|
113
137
|
},
|
|
114
138
|
{
|
|
@@ -146,38 +170,38 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
146
170
|
"openWhenLeavingWindow",
|
|
147
171
|
"openWhenScrollingToLevel"
|
|
148
172
|
],
|
|
149
|
-
script: function(
|
|
173
|
+
script: function(d) {
|
|
150
174
|
const e = this;
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
function
|
|
154
|
-
|
|
175
|
+
function w(h) {
|
|
176
|
+
const v = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'), y = e.querySelector('[data-type-role="gjs-plg-dialog-close"]');
|
|
177
|
+
function b() {
|
|
178
|
+
v.style.display = "none";
|
|
155
179
|
}
|
|
156
|
-
|
|
180
|
+
h ? (e._onCloseWhenPressingX = b, y.addEventListener("click", e._onCloseWhenPressingX)) : (y.removeEventListener("click", e._onCloseWhenPressingX), e._onCloseWhenPressingX = null);
|
|
157
181
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
function
|
|
161
|
-
|
|
182
|
+
function E(h) {
|
|
183
|
+
const v = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
184
|
+
function y(b) {
|
|
185
|
+
b.key === "Escape" && (v.style.display = "none");
|
|
162
186
|
}
|
|
163
|
-
|
|
187
|
+
h ? (e._onCloseWhenPressingEsc = y, e.addEventListener("keydown", e._onCloseWhenPressingEsc)) : (e.removeEventListener("keydown", e._onCloseWhenPressingEsc), e._onCloseWhenPressingEsc = null);
|
|
164
188
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
function
|
|
168
|
-
|
|
189
|
+
function x(h) {
|
|
190
|
+
const v = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
191
|
+
function y() {
|
|
192
|
+
v.style.display = "flex";
|
|
169
193
|
}
|
|
170
|
-
|
|
194
|
+
h ? (e._onOpenWhenLeavingWindow = y, document.addEventListener("mouseleave", e._onOpenWhenLeavingWindow)) : (document.removeEventListener("mouseleave", e._onOpenWhenLeavingWindow), e._onOpenWhenLeavingWindow = null);
|
|
171
195
|
}
|
|
172
|
-
function
|
|
173
|
-
const
|
|
174
|
-
function
|
|
175
|
-
const
|
|
176
|
-
|
|
196
|
+
function k(h) {
|
|
197
|
+
const v = e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
198
|
+
function y() {
|
|
199
|
+
const b = document.documentElement.scrollTop;
|
|
200
|
+
h && b >= Number(h) && (v.style.display = "flex");
|
|
177
201
|
}
|
|
178
|
-
|
|
202
|
+
h ? (e._onOpenWhenScrollingToLevel = y, document.addEventListener("scroll", e._onOpenWhenScrollingToLevel)) : (document.removeEventListener("scroll", e._onOpenWhenScrollingToLevel), e._onOpenWhenScrollingToLevel = null);
|
|
179
203
|
}
|
|
180
|
-
|
|
204
|
+
w(d.closeWhenPressingX), E(d.closeWhenPressingEsc), x(d.openWhenLeavingWindow), k(d.openWhenScrollingToLevel);
|
|
181
205
|
}
|
|
182
206
|
},
|
|
183
207
|
init() {
|
|
@@ -196,20 +220,20 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
196
220
|
},
|
|
197
221
|
view: {
|
|
198
222
|
onActive() {
|
|
199
|
-
const
|
|
200
|
-
|
|
223
|
+
const d = this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');
|
|
224
|
+
d.style.display = "flex";
|
|
201
225
|
}
|
|
202
226
|
}
|
|
203
|
-
}),
|
|
227
|
+
}), t.addType(g, {
|
|
204
228
|
model: {
|
|
205
229
|
defaults: {
|
|
206
230
|
tagName: "div",
|
|
207
|
-
attributes: { class:
|
|
208
|
-
components: { type:
|
|
231
|
+
attributes: { class: g, "data-type-role": g },
|
|
232
|
+
components: { type: u },
|
|
209
233
|
droppable: !1,
|
|
210
234
|
draggable: !1,
|
|
211
235
|
styles: `
|
|
212
|
-
.${
|
|
236
|
+
.${g} {
|
|
213
237
|
position: fixed;
|
|
214
238
|
top: 0;
|
|
215
239
|
left: 0;
|
|
@@ -223,16 +247,16 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
223
247
|
`
|
|
224
248
|
}
|
|
225
249
|
}
|
|
226
|
-
}),
|
|
250
|
+
}), t.addType(u, {
|
|
227
251
|
model: {
|
|
228
252
|
defaults: {
|
|
229
253
|
tagName: "div",
|
|
230
|
-
attributes: { class:
|
|
231
|
-
components: [{ type:
|
|
254
|
+
attributes: { class: u, "data-type-role": u },
|
|
255
|
+
components: [{ type: i }, { type: c }, { type: o }],
|
|
232
256
|
droppable: !1,
|
|
233
257
|
draggable: !1,
|
|
234
258
|
styles: `
|
|
235
|
-
.${
|
|
259
|
+
.${u} {
|
|
236
260
|
position: relative;
|
|
237
261
|
background-color: #fff;
|
|
238
262
|
border-radius: 10px;
|
|
@@ -245,16 +269,16 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
245
269
|
`
|
|
246
270
|
}
|
|
247
271
|
}
|
|
248
|
-
}),
|
|
272
|
+
}), t.addType(i, {
|
|
249
273
|
model: {
|
|
250
274
|
defaults: {
|
|
251
275
|
tagName: "button",
|
|
252
|
-
attributes: { class:
|
|
276
|
+
attributes: { class: i, "data-type-role": i },
|
|
253
277
|
components: "×",
|
|
254
278
|
droppable: !1,
|
|
255
279
|
draggable: !1,
|
|
256
280
|
styles: `
|
|
257
|
-
.${
|
|
281
|
+
.${i} {
|
|
258
282
|
position: absolute;
|
|
259
283
|
top: 10px;
|
|
260
284
|
right: 10px;
|
|
@@ -268,59 +292,59 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
268
292
|
`
|
|
269
293
|
}
|
|
270
294
|
}
|
|
271
|
-
}),
|
|
295
|
+
}), t.addType(c, {
|
|
272
296
|
model: {
|
|
273
297
|
defaults: {
|
|
274
298
|
tagName: "h2",
|
|
275
|
-
attributes: { class:
|
|
299
|
+
attributes: { class: c, "data-type-role": c },
|
|
276
300
|
components: "Dialog Title",
|
|
277
301
|
editable: !0,
|
|
278
302
|
droppable: !1,
|
|
279
303
|
draggable: !1,
|
|
280
304
|
styles: `
|
|
281
|
-
.${
|
|
305
|
+
.${c} {
|
|
282
306
|
margin: 0;
|
|
283
307
|
padding: 0 40px 20px 0;
|
|
284
308
|
}
|
|
285
309
|
`
|
|
286
310
|
}
|
|
287
311
|
}
|
|
288
|
-
}),
|
|
312
|
+
}), t.addType(o, {
|
|
289
313
|
model: {
|
|
290
314
|
defaults: {
|
|
291
315
|
tagName: "div",
|
|
292
|
-
attributes: { class:
|
|
293
|
-
components: [{ type:
|
|
316
|
+
attributes: { class: o, "data-type-role": o },
|
|
317
|
+
components: [{ type: r }],
|
|
294
318
|
styles: `
|
|
295
|
-
.${
|
|
319
|
+
.${o} {
|
|
296
320
|
height: 90%;
|
|
297
321
|
overflow: auto;
|
|
298
322
|
}
|
|
299
323
|
`
|
|
300
324
|
}
|
|
301
325
|
}
|
|
302
|
-
}),
|
|
326
|
+
}), t.addType(r, {
|
|
303
327
|
model: {
|
|
304
328
|
defaults: {
|
|
305
329
|
tagName: "p",
|
|
306
|
-
attributes: { class:
|
|
330
|
+
attributes: { class: r, "data-type-role": r },
|
|
307
331
|
components: "This is a customizable dialog!",
|
|
308
332
|
editable: !0,
|
|
309
333
|
styles: `
|
|
310
|
-
.${
|
|
334
|
+
.${r} {
|
|
311
335
|
margin: 0;
|
|
312
336
|
}
|
|
313
337
|
`
|
|
314
338
|
}
|
|
315
339
|
}
|
|
316
|
-
}),
|
|
340
|
+
}), t.addType(m, {
|
|
317
341
|
model: {
|
|
318
342
|
toHTML() {
|
|
319
343
|
return "";
|
|
320
344
|
},
|
|
321
345
|
defaults: {
|
|
322
346
|
tagName: "button",
|
|
323
|
-
attributes: { class:
|
|
347
|
+
attributes: { class: m, "data-type-role": m },
|
|
324
348
|
components: "Dialog (click me to open)",
|
|
325
349
|
droppable: !1,
|
|
326
350
|
draggable: !1
|
|
@@ -335,15 +359,16 @@ const E = (...n) => n.map((t) => `[data-gjs-type="${t}"]`).join(","), B = "dialo
|
|
|
335
359
|
});
|
|
336
360
|
}
|
|
337
361
|
}
|
|
338
|
-
}),
|
|
362
|
+
}), U({
|
|
339
363
|
editor: n,
|
|
340
|
-
licenseKey:
|
|
341
|
-
|
|
364
|
+
licenseKey: p,
|
|
365
|
+
plan: f.free,
|
|
366
|
+
pluginName: I,
|
|
342
367
|
cleanup: () => {
|
|
343
|
-
|
|
368
|
+
a.remove(s), t.removeType(s);
|
|
344
369
|
}
|
|
345
370
|
});
|
|
346
|
-
},
|
|
371
|
+
}, z = q(B);
|
|
347
372
|
export {
|
|
348
|
-
|
|
373
|
+
z as default
|
|
349
374
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(m,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(m=typeof globalThis<"u"?globalThis:m||self,m.StudioSdkPlugins_dialogComponent=v())})(this,function(){"use strict";const m="app.grapesjs.com",v="app-stage.grapesjs.com",P=[m,v,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],O="license:check:start",S="license:check:end",k=()=>typeof window<"u",j=({isDev:n,isStage:l})=>`${n?"":`https://${l?v:m}`}/api`,_=()=>{const n=k()&&window.location.hostname;return!!n&&(P.includes(n)||P.some(l=>n.endsWith(l)))};var b=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(b||{});async function N({path:n,baseApiUrl:l,method:i="GET",headers:t={},params:p,body:s}){const u=`${l||j({isDev:!1,isStage:!1})}${n}`,a={method:i,headers:{"Content-Type":"application/json",...t}};s&&(a.body=JSON.stringify(s));const c=p?new URLSearchParams(p).toString():"",o=c?`?${c}`:"",r=await fetch(`${u}${o}`,a);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const C={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function $(n){const l=n;return l.init=i=>t=>n(t,i),l}const D=n=>$(n);async function A({editor:n,plan:l,pluginName:i,licenseKey:t,cleanup:p}){let s="",g=!1;const u=_(),a=o=>{console.warn("Cleanup plugin:",i,"Reason:",o),p()},c=(o={})=>{var e;const{error:r,sdkLicense:W}=o,E=(e=o.plan)==null?void 0:e.category;if(!(W||o.license)||r)a(r||"Invalid license");else if(E){const L=C[l],T=C[E];L>T&&a({pluginRequiredPlan:l,licensePlan:E})}};n.on(O,o=>{s=o==null?void 0:o.baseApiUrl,g=!0}),n.on(S,o=>{c(o)}),setTimeout(async()=>{if(!g){if(u)return;if(t){const o=await q({licenseKey:t,pluginName:i,baseApiUrl:s});o&&c(o)}else a("The `licenseKey` option not provided")}},2e3)}async function q(n){const{licenseKey:l,pluginName:i,baseApiUrl:t}=n;try{return(await N({baseApiUrl:t,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:i}})).result||{}}catch(p){return console.error("Error during SDK license check:",p),!1}}const x=(...n)=>n.map(l=>`[data-gjs-type="${l}"]`).join(","),U="dialogComponent";return D(function(n,l={}){const{Blocks:i,Components:t}=n,{licenseKey:p}=l,s="gjs-plg-dialog",g="gjs-plg-dialog-overlay",u="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",o="gjs-plg-dialog-body",r="gjs-plg-dialog-description",W="gjs-plg-dialog-placeholder";i.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,...
|
|
5
|
+
`,category:"Extra",content:{type:s},activate:!0,...l.block}),t.addType(s,{model:{defaults:{tagName:"div",attributes:{class:s,"data-type-role":s},components:[{type:g},{type:W}],draggable:x("wrapper"),droppable:x(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(
|
|
11
|
-
.${
|
|
10
|
+
`,traits:[{type:"button",label:"Open dialog",name:"onActive",changeProp:!0,command(d){var e;(e=d.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(d){const e=this;function L(h){const f=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]'),y=e.querySelector('[data-type-role="gjs-plg-dialog-close"]');function w(){f.style.display="none"}h?(e._onCloseWhenPressingX=w,y.addEventListener("click",e._onCloseWhenPressingX)):(y.removeEventListener("click",e._onCloseWhenPressingX),e._onCloseWhenPressingX=null)}function T(h){const f=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(w){w.key==="Escape"&&(f.style.display="none")}h?(e._onCloseWhenPressingEsc=y,e.addEventListener("keydown",e._onCloseWhenPressingEsc)):(e.removeEventListener("keydown",e._onCloseWhenPressingEsc),e._onCloseWhenPressingEsc=null)}function X(h){const f=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(){f.style.display="flex"}h?(e._onOpenWhenLeavingWindow=y,document.addEventListener("mouseleave",e._onOpenWhenLeavingWindow)):(document.removeEventListener("mouseleave",e._onOpenWhenLeavingWindow),e._onOpenWhenLeavingWindow=null)}function I(h){const f=e.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');function y(){const w=document.documentElement.scrollTop;h&&w>=Number(h)&&(f.style.display="flex")}h?(e._onOpenWhenScrollingToLevel=y,document.addEventListener("scroll",e._onOpenWhenScrollingToLevel)):(document.removeEventListener("scroll",e._onOpenWhenScrollingToLevel),e._onOpenWhenScrollingToLevel=null)}L(d.closeWhenPressingX),T(d.closeWhenPressingEsc),X(d.openWhenLeavingWindow),I(d.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 d=this.el.querySelector('[data-type-role="gjs-plg-dialog-overlay"]');d.style.display="flex"}}}),t.addType(g,{model:{defaults:{tagName:"div",attributes:{class:g,"data-type-role":g},components:{type:u},droppable:!1,draggable:!1,styles:`
|
|
11
|
+
.${g} {
|
|
12
12
|
position: fixed;
|
|
13
13
|
top: 0;
|
|
14
14
|
left: 0;
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
justify-content: center;
|
|
20
20
|
background-color: rgba(0, 0, 0, 0.5);
|
|
21
21
|
}
|
|
22
|
-
`}}}),
|
|
23
|
-
.${
|
|
22
|
+
`}}}),t.addType(u,{model:{defaults:{tagName:"div",attributes:{class:u,"data-type-role":u},components:[{type:a},{type:c},{type:o}],droppable:!1,draggable:!1,styles:`
|
|
23
|
+
.${u} {
|
|
24
24
|
position: relative;
|
|
25
25
|
background-color: #fff;
|
|
26
26
|
border-radius: 10px;
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
height: 600px;
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
|
-
`}}}),
|
|
34
|
-
.${
|
|
33
|
+
`}}}),t.addType(a,{model:{defaults:{tagName:"button",attributes:{class:a,"data-type-role":a},components:"×",droppable:!1,draggable:!1,styles:`
|
|
34
|
+
.${a} {
|
|
35
35
|
position: absolute;
|
|
36
36
|
top: 10px;
|
|
37
37
|
right: 10px;
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
font-size: 20px;
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
}
|
|
45
|
-
`}}}),
|
|
46
|
-
.${
|
|
45
|
+
`}}}),t.addType(c,{model:{defaults:{tagName:"h2",attributes:{class:c,"data-type-role":c},components:"Dialog Title",editable:!0,droppable:!1,draggable:!1,styles:`
|
|
46
|
+
.${c} {
|
|
47
47
|
margin: 0;
|
|
48
48
|
padding: 0 40px 20px 0;
|
|
49
49
|
}
|
|
50
|
-
`}}}),
|
|
51
|
-
.${
|
|
50
|
+
`}}}),t.addType(o,{model:{defaults:{tagName:"div",attributes:{class:o,"data-type-role":o},components:[{type:r}],styles:`
|
|
51
|
+
.${o} {
|
|
52
52
|
height: 90%;
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
`}}}),
|
|
56
|
-
.${
|
|
55
|
+
`}}}),t.addType(r,{model:{defaults:{tagName:"p",attributes:{class:r,"data-type-role":r},components:"This is a customizable dialog!",editable:!0,styles:`
|
|
56
|
+
.${r} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),
|
|
59
|
+
`}}}),t.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=""})}}}),A({editor:n,licenseKey:p,plan:b.free,pluginName:U,cleanup:()=>{i.remove(s),t.removeType(s)}})})});
|