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