@grapesjs/studio-sdk-plugins 1.0.15 → 1.0.16
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/accordionComponent/index.cjs.js +3 -3
- package/dist/accordionComponent/index.es.js +29 -30
- package/dist/accordionComponent/index.umd.js +4 -4
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +14 -15
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.d.ts +2 -2
- package/dist/canvasFullSize/index.cjs.js +1 -1
- package/dist/canvasFullSize/index.d.ts +2 -2
- package/dist/canvasFullSize/index.es.d.ts +2 -2
- package/dist/canvasFullSize/index.es.js +2 -3
- package/dist/canvasFullSize/index.umd.js +2 -2
- package/dist/canvasFullSize/types.d.ts +1 -1
- package/dist/dialogComponent/index.cjs.js +2 -2
- package/dist/dialogComponent/index.es.js +2 -3
- package/dist/dialogComponent/index.umd.js +2 -2
- package/dist/flexComponent/index.cjs.js +1 -1
- package/dist/flexComponent/index.es.js +2 -3
- package/dist/flexComponent/index.umd.js +1 -1
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +2 -3
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +39 -40
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +31 -32
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +42 -42
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +3171 -2944
- package/dist/index.umd.js +36 -36
- package/dist/layoutSidebarButtons/index.cjs.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.cjs.js +1 -0
- package/dist/layoutSidebarButtons/index.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.es.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.es.js +328 -0
- package/dist/layoutSidebarButtons/index.umd.js +1 -0
- package/dist/layoutSidebarButtons/layout.d.ts +8 -0
- package/dist/layoutSidebarButtons/types.d.ts +75 -0
- package/dist/layoutSidebarButtons/typesSchema.d.ts +49 -0
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +2 -3
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +2 -3
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +2 -2
- package/dist/prosemirror/index.es.js +3 -4
- package/dist/prosemirror/index.umd.js +2 -2
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +20 -21
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/swiperComponent/index.cjs.js +3 -3
- package/dist/swiperComponent/index.es.js +2 -3
- package/dist/swiperComponent/index.umd.js +3 -3
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +13 -14
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +7 -8
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const M="app.grapesjs.com",L="app-stage.grapesjs.com",$=[M,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],V="license:check:start",_="license:check:end",N=()=>typeof window<"u",G=({isDev:e,isStage:t})=>`${e?"":`https://${t?L:M}`}/api`,P=()=>{const e=N()&&window.location.hostname;return!!e&&($.includes(e)||$.some(t=>e.endsWith(t)))};async function U({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:c,body:a}){const u=`${t||G({isDev:!1,isStage:!1})}${e}`,i={method:n,headers:{"Content-Type":"application/json",...s}};a&&(i.body=JSON.stringify(a));const r=c?new URLSearchParams(c).toString():"",o=r?`?${r}`:"",l=await fetch(`${u}${o}`,i);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{});const E={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function D(e){const t=e;return t.init=n=>s=>e(s,n),t}const K=e=>D(e);async function W({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:c}){let a="",p=!1;const u=P(),i=o=>{console.warn("Cleanup plugin:",n,"Reason:",o),c()},r=(o={})=>{var w;const{error:l,sdkLicense:f}=o,g=(w=o.plan)==null?void 0:w.category;if(!(f||o.license)||l)i(l||"Invalid license");else if(g){const B=E[t],I=E[g];B>I&&i({pluginRequiredPlan:t,licensePlan:g})}};e.on(V,o=>{a=o==null?void 0:o.baseApiUrl,p=!0}),e.on(_,o=>{r(o)}),setTimeout(async()=>{if(!p){if(u)return;if(s){const o=await R({licenseKey:s,pluginName:n,baseApiUrl:a});o&&r(o)}else i("The `licenseKey` option not provided")}},2e3)}async function R(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await U({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}const A=e=>t=>{var n;return((n=t.getAttribute)==null?void 0:n.call(t,T))===e},O=(...e)=>t=>e.some(n=>t.is(n)),j=(...e)=>(t,n)=>e.some(s=>n.is(s)),C="gjs-plg-",T="data-type-role",d="accordion",q=`${d}-group`,m=`${d}-header`,h=`${d}-content`,y=`${d}-marker`,x=`${C}${m}`,k=`${C}${y}`,F=`${C}${h}`,H=`${k}-open`,v={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></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>'},S=(e,t)=>{const{toolbarIconOpen:n=v.eye}=t,s=e.is(d)?e:e.closestType(d);if(!n||!s)return;const{toolbar:c}=e,a={id:"accordion-toggle-open",label:n,command:()=>s.toggleOpen()};!c.find(u=>u.id===a.id)&&(c==null||c.unshift(a))},Y=(e,t)=>{const{Components:n,Blocks:s}=e,{block:c={}}=t,a="Accordion",p=`${C}${d}`,u=function(i={}){const r=this,o=()=>{const{clsMarkerOpen:l}=i,f=r.querySelector('[data-type-role="accordion-marker"]');!f||!l||(r.open?f.classList.add(l):f.classList.remove(l))};r.addEventListener("toggle",()=>{o(),r.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),o()};return n.addType(d,{block:c&&{label:a,media:v.accordion,category:"Extra",select:!0,...c},isComponent:A(d),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:a,classes:p,emptyState:!0,clsMarkerOpen:H,attributes:{[T]:d},droppable:O(m,h),components:[{type:m},{type:h}],"script-props":["clsMarkerOpen"],script:u,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
2
2
|
.${p}::details-content {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
block-size: 0;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
transform: translateY(0);
|
|
16
16
|
block-size: auto;
|
|
17
17
|
}
|
|
18
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){S(this,t)}}}),()=>{s.remove(d),n.removeType(d)}},Z=e=>{const{Components:t}=e;return t.addType(h,{isComponent:A(h),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:F,icon:v.accordionContent,attributes:{[
|
|
18
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){S(this,t)}}}),()=>{s.remove(d),n.removeType(d)}},Z=e=>{const{Components:t}=e;return t.addType(h,{isComponent:A(h),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:F,icon:v.accordionContent,attributes:{[T]:h},components:"<div>Accordion content</div>"}}}),()=>{t.removeType(h)}},J=(e,t)=>{const{Components:n,Blocks:s}=e,{blockGroup:c={}}=t,a="Accordion Group",p=function(i={}){if(!i.single)return;const r=this;r.addEventListener("details-toggle",o=>{const l=o.target;if(!i.single||!l||!l.open)return;r.querySelectorAll('[data-type-role="accordion"]').forEach(g=>{l!==g&&g.open&&(g.open=!1)})})},u=(i={})=>({type:d,attributes:{open:i.open},components:[{type:m,components:[`<div>${i.header}</div>`,{type:y}]},{type:h,components:`<div>${i.content}</div>`}]});return n.addType(q,{block:c&&{label:a,media:v.accordionGroup,category:"Extra",select:!0,...c},isComponent:A(q),model:{defaults:{name:a,attributes:{[T]:q},droppable:O(d),single:!0,emptyState:!0,components:Array(3).fill(0).map((i,r)=>u({open:r===0,header:`Accordion header ${r+1}`,content:`Accordion content ${r+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:p}}}),()=>{s.remove(q),n.removeType(q)}},Q=(e,t)=>{const{Components:n}=e;return n.addType(m,{isComponent:A(m),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:v.accordionHeader,classes:x,attributes:{[T]:m},components:["<div>Accordion header</div>",{type:y}],styles:`
|
|
19
19
|
summary {
|
|
20
20
|
list-style: none;
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
justify-content: space-between;
|
|
27
27
|
gap: 1rem;
|
|
28
28
|
}
|
|
29
|
-
`},initToolbar(){S(this,t)}}}),()=>{n.removeType(m)}},X=e=>{const{Components:t}=e;return t.addType(y,{extend:"icon",isComponent:A(y),model:{defaults:{name:"Accordion Marker",icon:v.accordionMarker,classes:k,attributes:{[
|
|
29
|
+
`},initToolbar(){S(this,t)}}}),()=>{n.removeType(m)}},X=e=>{const{Components:t}=e;return t.addType(y,{extend:"icon",isComponent:A(y),model:{defaults:{name:"Accordion Marker",icon:v.accordionMarker,classes:k,attributes:{[T]:y},components:v.caret,droppable:!1,draggable:j(m),styles:`
|
|
30
30
|
.${k} {
|
|
31
31
|
min-width: 24px;
|
|
32
32
|
width: 24px;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "grapesjs";
|
|
2
1
|
const M = "app.grapesjs.com", L = "app-stage.grapesjs.com", $ = [
|
|
3
2
|
M,
|
|
4
3
|
L,
|
|
@@ -20,17 +19,17 @@ async function U({
|
|
|
20
19
|
method: n = "GET",
|
|
21
20
|
headers: s = {},
|
|
22
21
|
params: c,
|
|
23
|
-
body:
|
|
22
|
+
body: i
|
|
24
23
|
}) {
|
|
25
|
-
const u = `${t || G({ isDev: !1, isStage: !1 })}${e}`,
|
|
24
|
+
const u = `${t || G({ isDev: !1, isStage: !1 })}${e}`, a = {
|
|
26
25
|
method: n,
|
|
27
26
|
headers: {
|
|
28
27
|
"Content-Type": "application/json",
|
|
29
28
|
...s
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
const r = c ? new URLSearchParams(c).toString() : "", o = r ? `?${r}` : "", l = await fetch(`${u}${o}`,
|
|
31
|
+
i && (a.body = JSON.stringify(i));
|
|
32
|
+
const r = c ? new URLSearchParams(c).toString() : "", o = r ? `?${r}` : "", l = await fetch(`${u}${o}`, a);
|
|
34
33
|
if (!l.ok)
|
|
35
34
|
throw new Error(`HTTP error! status: ${l.status}`);
|
|
36
35
|
return l.json();
|
|
@@ -54,31 +53,31 @@ async function W({
|
|
|
54
53
|
licenseKey: s,
|
|
55
54
|
cleanup: c
|
|
56
55
|
}) {
|
|
57
|
-
let
|
|
58
|
-
const u = P(),
|
|
56
|
+
let i = "", p = !1;
|
|
57
|
+
const u = P(), a = (o) => {
|
|
59
58
|
console.warn("Cleanup plugin:", n, "Reason:", o), c();
|
|
60
59
|
}, r = (o = {}) => {
|
|
61
60
|
var w;
|
|
62
61
|
const { error: l, sdkLicense: f } = o, g = (w = o.plan) == null ? void 0 : w.category;
|
|
63
62
|
if (!(f || o.license) || l)
|
|
64
|
-
|
|
63
|
+
a(l || "Invalid license");
|
|
65
64
|
else if (g) {
|
|
66
65
|
const B = E[t], I = E[g];
|
|
67
|
-
B > I &&
|
|
66
|
+
B > I && a({ pluginRequiredPlan: t, licensePlan: g });
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
69
|
e.on(V, (o) => {
|
|
71
|
-
|
|
70
|
+
i = o == null ? void 0 : o.baseApiUrl, p = !0;
|
|
72
71
|
}), e.on(_, (o) => {
|
|
73
72
|
r(o);
|
|
74
73
|
}), setTimeout(async () => {
|
|
75
74
|
if (!p) {
|
|
76
75
|
if (u) return;
|
|
77
76
|
if (s) {
|
|
78
|
-
const o = await R({ licenseKey: s, pluginName: n, baseApiUrl:
|
|
77
|
+
const o = await R({ licenseKey: s, pluginName: n, baseApiUrl: i });
|
|
79
78
|
o && r(o);
|
|
80
79
|
} else
|
|
81
|
-
|
|
80
|
+
a("The `licenseKey` option not provided");
|
|
82
81
|
}
|
|
83
82
|
}, 2e3);
|
|
84
83
|
}
|
|
@@ -112,16 +111,16 @@ const A = (e) => (t) => {
|
|
|
112
111
|
}, S = (e, t) => {
|
|
113
112
|
const { toolbarIconOpen: n = v.eye } = t, s = e.is(d) ? e : e.closestType(d);
|
|
114
113
|
if (!n || !s) return;
|
|
115
|
-
const { toolbar: c } = e,
|
|
114
|
+
const { toolbar: c } = e, i = {
|
|
116
115
|
id: "accordion-toggle-open",
|
|
117
116
|
label: n,
|
|
118
117
|
command: () => s.toggleOpen()
|
|
119
118
|
};
|
|
120
|
-
!c.find((u) => u.id ===
|
|
119
|
+
!c.find((u) => u.id === i.id) && (c == null || c.unshift(i));
|
|
121
120
|
}, Y = (e, t) => {
|
|
122
|
-
const { Components: n, Blocks: s } = e, { block: c = {} } = t,
|
|
121
|
+
const { Components: n, Blocks: s } = e, { block: c = {} } = t, i = "Accordion", p = `${C}${d}`, u = function(a = {}) {
|
|
123
122
|
const r = this, o = () => {
|
|
124
|
-
const { clsMarkerOpen: l } =
|
|
123
|
+
const { clsMarkerOpen: l } = a, f = r.querySelector('[data-type-role="accordion-marker"]');
|
|
125
124
|
!f || !l || (r.open ? f.classList.add(l) : f.classList.remove(l));
|
|
126
125
|
};
|
|
127
126
|
r.addEventListener("toggle", () => {
|
|
@@ -130,7 +129,7 @@ const A = (e) => (t) => {
|
|
|
130
129
|
};
|
|
131
130
|
return n.addType(d, {
|
|
132
131
|
block: c && {
|
|
133
|
-
label:
|
|
132
|
+
label: i,
|
|
134
133
|
media: v.accordion,
|
|
135
134
|
category: "Extra",
|
|
136
135
|
select: !0,
|
|
@@ -141,7 +140,7 @@ const A = (e) => (t) => {
|
|
|
141
140
|
model: {
|
|
142
141
|
defaults: {
|
|
143
142
|
tagName: "details",
|
|
144
|
-
name:
|
|
143
|
+
name: i,
|
|
145
144
|
classes: p,
|
|
146
145
|
emptyState: !0,
|
|
147
146
|
clsMarkerOpen: H,
|
|
@@ -207,33 +206,33 @@ const A = (e) => (t) => {
|
|
|
207
206
|
t.removeType(h);
|
|
208
207
|
};
|
|
209
208
|
}, J = (e, t) => {
|
|
210
|
-
const { Components: n, Blocks: s } = e, { blockGroup: c = {} } = t,
|
|
211
|
-
if (!
|
|
209
|
+
const { Components: n, Blocks: s } = e, { blockGroup: c = {} } = t, i = "Accordion Group", p = function(a = {}) {
|
|
210
|
+
if (!a.single) return;
|
|
212
211
|
const r = this;
|
|
213
212
|
r.addEventListener("details-toggle", (o) => {
|
|
214
213
|
const l = o.target;
|
|
215
|
-
if (!
|
|
214
|
+
if (!a.single || !l || !l.open) return;
|
|
216
215
|
r.querySelectorAll('[data-type-role="accordion"]').forEach((g) => {
|
|
217
216
|
l !== g && g.open && (g.open = !1);
|
|
218
217
|
});
|
|
219
218
|
});
|
|
220
|
-
}, u = (
|
|
219
|
+
}, u = (a = {}) => ({
|
|
221
220
|
type: d,
|
|
222
|
-
attributes: { open:
|
|
221
|
+
attributes: { open: a.open },
|
|
223
222
|
components: [
|
|
224
223
|
{
|
|
225
224
|
type: m,
|
|
226
|
-
components: [`<div>${
|
|
225
|
+
components: [`<div>${a.header}</div>`, { type: y }]
|
|
227
226
|
},
|
|
228
227
|
{
|
|
229
228
|
type: h,
|
|
230
|
-
components: `<div>${
|
|
229
|
+
components: `<div>${a.content}</div>`
|
|
231
230
|
}
|
|
232
231
|
]
|
|
233
232
|
});
|
|
234
233
|
return n.addType(q, {
|
|
235
234
|
block: c && {
|
|
236
|
-
label:
|
|
235
|
+
label: i,
|
|
237
236
|
media: v.accordionGroup,
|
|
238
237
|
category: "Extra",
|
|
239
238
|
select: !0,
|
|
@@ -242,13 +241,13 @@ const A = (e) => (t) => {
|
|
|
242
241
|
isComponent: A(q),
|
|
243
242
|
model: {
|
|
244
243
|
defaults: {
|
|
245
|
-
name:
|
|
244
|
+
name: i,
|
|
246
245
|
attributes: { [T]: q },
|
|
247
246
|
droppable: O(d),
|
|
248
247
|
single: !0,
|
|
249
248
|
emptyState: !0,
|
|
250
249
|
components: Array(3).fill(0).map(
|
|
251
|
-
(
|
|
250
|
+
(a, r) => u({
|
|
252
251
|
open: r === 0,
|
|
253
252
|
header: `Accordion header ${r + 1}`,
|
|
254
253
|
content: `Accordion content ${r + 1}`
|
|
@@ -354,7 +353,7 @@ const A = (e) => (t) => {
|
|
|
354
353
|
n.forEach((s) => s());
|
|
355
354
|
}
|
|
356
355
|
});
|
|
357
|
-
},
|
|
356
|
+
}, ne = K(te);
|
|
358
357
|
export {
|
|
359
|
-
|
|
358
|
+
ne as default
|
|
360
359
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(v,b){typeof exports=="object"&&typeof module<"u"?module.exports=b(
|
|
1
|
+
(function(v,b){typeof exports=="object"&&typeof module<"u"?module.exports=b():typeof define=="function"&&define.amd?define(b):(v=typeof globalThis<"u"?globalThis:v||self,v.StudioSdkPlugins_accordionComponent=b())})(this,function(){"use strict";const v="app.grapesjs.com",b="app-stage.grapesjs.com",x=[v,b,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],z="license:check:start",_="license:check:end",B=()=>typeof window<"u",I=({isDev:e,isStage:n})=>`${e?"":`https://${n?b:v}`}/api`,V=()=>{const e=B()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(n=>e.endsWith(n)))};async function N({path:e,baseApiUrl:n,method:t="GET",headers:s={},params:c,body:l}){const m=`${n||I({isDev:!1,isStage:!1})}${e}`,i={method:t,headers:{"Content-Type":"application/json",...s}};l&&(i.body=JSON.stringify(l));const r=c?new URLSearchParams(c).toString():"",o=r?`?${r}`:"",d=await fetch(`${m}${o}`,i);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}var T=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(T||{});const E={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function P(e){const n=e;return n.init=t=>s=>e(s,t),n}const G=e=>P(e);async function U({editor:e,plan:n,pluginName:t,licenseKey:s,cleanup:c}){let l="",p=!1;const m=V(),i=o=>{console.warn("Cleanup plugin:",t,"Reason:",o),c()},r=(o={})=>{var H;const{error:d,sdkLicense:A}=o,y=(H=o.plan)==null?void 0:H.category;if(!(A||o.license)||d)i(d||"Invalid license");else if(y){const X=E[n],ee=E[y];X>ee&&i({pluginRequiredPlan:n,licensePlan:y})}};e.on(z,o=>{l=o==null?void 0:o.baseApiUrl,p=!0}),e.on(_,o=>{r(o)}),setTimeout(async()=>{if(!p){if(m)return;if(s){const o=await D({licenseKey:s,pluginName:t,baseApiUrl:l});o&&r(o)}else i("The `licenseKey` option not provided")}},2e3)}async function D(e){const{licenseKey:n,pluginName:t,baseApiUrl:s}=e;try{return(await N({baseApiUrl:s,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}const C=e=>n=>{var t;return((t=n.getAttribute)==null?void 0:t.call(n,q))===e},M=(...e)=>n=>e.some(t=>n.is(t)),K=(...e)=>(n,t)=>e.some(s=>t.is(s)),w="gjs-plg-",q="data-type-role",a="accordion",k=`${a}-group`,u=`${a}-header`,h=`${a}-content`,f=`${a}-marker`,L=`${w}${u}`,$=`${w}${f}`,W=`${w}${h}`,S=`${$}-open`,g={accordion:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V8.154H5v10.23q0 .232.192.424t.423.192"/></svg>',accordionGroup:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M8.116 16h10.769q.23 0 .423-.192t.192-.423V6h-12v9.385q0 .23.192.423t.423.192m0 1q-.69 0-1.153-.462T6.5 15.385V4.615q0-.69.463-1.153T8.116 3h10.769q.69 0 1.153.462t.462 1.153v10.77q0 .69-.462 1.152T18.884 17zm-3 3q-.69 0-1.153-.462T3.5 18.385V6.615h1v11.77q0 .23.192.423t.423.192h11.77v1zM7.5 4v12z"/></svg>',accordionHeader:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M5.616 20q-.691 0-1.153-.462T4 18.384V5.616q0-.691.463-1.153T5.616 4h12.769q.69 0 1.153.463T20 5.616v12.769q0 .69-.462 1.153T18.384 20zm0-1h12.769q.23 0 .423-.192t.192-.424V5.616q0-.231-.192-.424T18.384 5H5.616q-.231 0-.424.192T5 5.616v12.769q0 .23.192.423t.423.192M5 5v14zm2.616 4.192h6q.413 0 .706-.293q.294-.293.294-.707t-.294-.706q-.293-.294-.706-.294h-6q-.414 0-.707.294t-.293.706t.293.707t.707.293"/></svg>',accordionContent:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M4.616 19q-.691 0-1.153-.462T3 17.384V6.616q0-.691.463-1.153T4.615 5h14.77q.69 0 1.152.463T21 6.616v10.769q0 .69-.463 1.153T19.385 19zm0-1h14.769q.23 0 .423-.192t.192-.424V6.616q0-.231-.192-.424T19.385 6H4.615q-.23 0-.423.192T4 6.616v10.769q0 .23.192.423t.423.192M4 18V6zm2.23-2.116h11.54q.213 0 .356-.143t.143-.357t-.143-.356t-.357-.144H6.231q-.214 0-.357.144q-.143.143-.143.357q0 .213.143.356t.357.144m0-3.385h11.538q.214 0 .357-.143t.143-.357t-.143-.357t-.357-.143H6.231q-.214 0-.357.143T5.731 12t.143.357t.357.143m0-3.384H14q.214 0 .357-.144q.143-.143.143-.356q0-.214-.143-.357T14 8.116H6.23q-.213 0-.356.143t-.143.357t.143.356t.357.144"/></svg>',accordionMarker:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="m12 15.596l3.173-3.192H8.827zM5.616 20q-.672 0-1.144-.472T4 18.385V5.615q0-.67.472-1.143Q4.944 4 5.616 4h12.769q.67 0 1.143.472q.472.472.472 1.144v12.769q0 .67-.472 1.143q-.472.472-1.143.472zM5 9v9.385q0 .23.192.423t.423.192h12.77q.23 0 .423-.192t.192-.423V9z"/></svg>',caret:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m7.4 8.6 4.6 4.6 4.6-4.6L18 10l-6 6-6-6 1.4-1.4Z"/></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>'},O=(e,n)=>{const{toolbarIconOpen:t=g.eye}=n,s=e.is(a)?e:e.closestType(a);if(!t||!s)return;const{toolbar:c}=e,l={id:"accordion-toggle-open",label:t,command:()=>s.toggleOpen()};!c.find(m=>m.id===l.id)&&(c==null||c.unshift(l))},j=(e,n)=>{const{Components:t,Blocks:s}=e,{block:c={}}=n,l="Accordion",p=`${w}${a}`,m=function(i={}){const r=this,o=()=>{const{clsMarkerOpen:d}=i,A=r.querySelector('[data-type-role="accordion-marker"]');!A||!d||(r.open?A.classList.add(d):A.classList.remove(d))};r.addEventListener("toggle",()=>{o(),r.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),o()};return t.addType(a,{block:c&&{label:l,media:g.accordion,category:"Extra",select:!0,...c},isComponent:C(a),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:l,classes:p,emptyState:!0,clsMarkerOpen:S,attributes:{[q]:a},droppable:M(u,h),components:[{type:u},{type:h}],"script-props":["clsMarkerOpen"],script:m,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
2
2
|
.${p}::details-content {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
block-size: 0;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
transform: translateY(0);
|
|
16
16
|
block-size: auto;
|
|
17
17
|
}
|
|
18
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){O(this,n)}}}),()=>{s.remove(a),t.removeType(a)}},R=e=>{const{Components:n}=e;return n.addType(h,{isComponent:C(h),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:
|
|
18
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){O(this,n)}}}),()=>{s.remove(a),t.removeType(a)}},R=e=>{const{Components:n}=e;return n.addType(h,{isComponent:C(h),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:W,icon:g.accordionContent,attributes:{[q]:h},components:"<div>Accordion content</div>"}}}),()=>{n.removeType(h)}},F=(e,n)=>{const{Components:t,Blocks:s}=e,{blockGroup:c={}}=n,l="Accordion Group",p=function(i={}){if(!i.single)return;const r=this;r.addEventListener("details-toggle",o=>{const d=o.target;if(!i.single||!d||!d.open)return;r.querySelectorAll('[data-type-role="accordion"]').forEach(y=>{d!==y&&y.open&&(y.open=!1)})})},m=(i={})=>({type:a,attributes:{open:i.open},components:[{type:u,components:[`<div>${i.header}</div>`,{type:f}]},{type:h,components:`<div>${i.content}</div>`}]});return t.addType(k,{block:c&&{label:l,media:g.accordionGroup,category:"Extra",select:!0,...c},isComponent:C(k),model:{defaults:{name:l,attributes:{[q]:k},droppable:M(a),single:!0,emptyState:!0,components:Array(3).fill(0).map((i,r)=>m({open:r===0,header:`Accordion header ${r+1}`,content:`Accordion content ${r+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:p}}}),()=>{s.remove(k),t.removeType(k)}},Y=(e,n)=>{const{Components:t}=e;return t.addType(u,{isComponent:C(u),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:g.accordionHeader,classes:L,attributes:{[q]:u},components:["<div>Accordion header</div>",{type:f}],styles:`
|
|
19
19
|
summary {
|
|
20
20
|
list-style: none;
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
justify-content: space-between;
|
|
27
27
|
gap: 1rem;
|
|
28
28
|
}
|
|
29
|
-
`},initToolbar(){O(this,n)}}}),()=>{t.removeType(u)}},Z=e=>{const{Components:n}=e;return n.addType(
|
|
29
|
+
`},initToolbar(){O(this,n)}}}),()=>{t.removeType(u)}},Z=e=>{const{Components:n}=e;return n.addType(f,{extend:"icon",isComponent:C(f),model:{defaults:{name:"Accordion Marker",icon:g.accordionMarker,classes:$,attributes:{[q]:f},components:g.caret,droppable:!1,draggable:K(u),styles:`
|
|
30
30
|
.${$} {
|
|
31
31
|
min-width: 24px;
|
|
32
32
|
width: 24px;
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
.${S} {
|
|
37
37
|
transform: rotateZ(180deg);
|
|
38
38
|
}
|
|
39
|
-
`}}}),()=>{n.removeType(
|
|
39
|
+
`}}}),()=>{n.removeType(f)}},J="accordionComponent";return G(function(e,n={}){const t=[j(e,n),F(e,n),Y(e,n),Z(e),R(e)];U({editor:e,licenseKey:n.licenseKey,plan:T.startup,pluginName:J,cleanup:()=>{t.forEach(s=>s())}})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";const I="app.grapesjs.com",M="app-stage.grapesjs.com",W=[I,M,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",N="license:check:end",D=()=>typeof window<"u",P=({isDev:e,isStage:t})=>`${e?"":`https://${t?M:I}`}/api`,R=()=>{const e=D()&&window.location.hostname;return!!e&&(W.includes(e)||W.some(t=>e.endsWith(t)))};function _(e){return typeof e=="function"}async function K({path:e,baseApiUrl:t,method:a="GET",headers:o={},params:i,body:u}){const m=`${t||P({isDev:!1,isStage:!1})}${e}`,p={method:a,headers:{"Content-Type":"application/json",...o}};u&&(p.body=JSON.stringify(u));const d=i?new URLSearchParams(i).toString():"",s=d?`?${d}`:"",c=await fetch(`${m}${s}`,p);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return c.json()}var w=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(w||{});const A={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function O(e){const t=e;return t.init=a=>o=>e(o,a),t}const j=e=>O(e);async function x({editor:e,plan:t,pluginName:a,licenseKey:o,cleanup:i}){let u="",h=!1;const m=R(),p=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),i()},d=(s={})=>{var C;const{error:c,sdkLicense:E}=s,v=(C=s.plan)==null?void 0:C.category;if(!(E||s.license)||c)p(c||"Invalid license");else if(v){const T=A[t],b=A[v];T>b&&p({pluginRequiredPlan:t,licensePlan:v})}};e.on($,s=>{u=s==null?void 0:s.baseApiUrl,h=!0}),e.on(N,s=>{d(s)}),setTimeout(async()=>{if(!h){if(m)return;if(o){const s=await F({licenseKey:o,pluginName:a,baseApiUrl:u});s&&d(s)}else p("The `licenseKey` option not provided")}},2e3)}async function F(e){const{licenseKey:t,pluginName:a,baseApiUrl:o}=e;try{return(await K({baseApiUrl:o,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const G="canvasEmptyState",H=function(e,t={}){const a=new WeakMap,o=new WeakMap,i=new WeakMap,u=new Set,h=new WeakMap,m={emptyStates:[],...t},p=(n,r)=>{let y=!1;const{isValid:f}=r;return Array.isArray(f)?y=f.some(l=>n.is(l)):_(f)?y=f({component:n,editor:e}):y=n.is(f),y},d=n=>{const r=a.get(n);a.delete(n),r==null||r()},s=n=>{n.views.forEach(r=>d(r)),i.delete(n)},c=n=>{if(!(!n||u.has(n)))try{u.add(n);const r=n.components().length>0,y=i.get(n);if(r&&y)s(n);else if(!r&&!y){const f=h.has(n)?h.get(n):m.emptyStates.find(l=>p(n,l));if(h.set(n,f),!f)return;n.views.forEach(l=>{const S=f.render({editor:e,component:n,componentView:l,mount:g=>{o.set(l,g),i.set(n,!0);const k=l.getChildrenContainer();k==null||k.appendChild(g)},unmount:()=>d(l)});a.set(l,()=>{S==null||S();const g=o.get(l);g==null||g.remove()})})}}finally{u.delete(n)}},E=n=>{i.has(n)&&s(n)},v=({model:n})=>{c(n.getComponent())},L=e.Components.events,C=`${L.update}:components`,T="component:mount",b=e.Canvas.events.frameLoadBody,U=L.removed;e.on(C,c),e.on(T,c),e.on(U,E),e.on(b,v),x({editor:e,licenseKey:m.licenseKey,plan:w.startup,pluginName:G,cleanup:()=>{e.off(C,c),e.off(T,c),e.off(U,E),e.off(b,v)}})},q=j(H);module.exports=q;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "grapesjs";
|
|
2
1
|
const I = "app.grapesjs.com", M = "app-stage.grapesjs.com", W = [
|
|
3
2
|
I,
|
|
4
3
|
M,
|
|
@@ -25,7 +24,7 @@ async function K({
|
|
|
25
24
|
params: i,
|
|
26
25
|
body: u
|
|
27
26
|
}) {
|
|
28
|
-
const
|
|
27
|
+
const m = `${t || P({ isDev: !1, isStage: !1 })}${e}`, p = {
|
|
29
28
|
method: a,
|
|
30
29
|
headers: {
|
|
31
30
|
"Content-Type": "application/json",
|
|
@@ -33,7 +32,7 @@ async function K({
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
u && (p.body = JSON.stringify(u));
|
|
36
|
-
const d = i ? new URLSearchParams(i).toString() : "", s = d ? `?${d}` : "", c = await fetch(`${
|
|
35
|
+
const d = i ? new URLSearchParams(i).toString() : "", s = d ? `?${d}` : "", c = await fetch(`${m}${s}`, p);
|
|
37
36
|
if (!c.ok)
|
|
38
37
|
throw new Error(`HTTP error! status: ${c.status}`);
|
|
39
38
|
return c.json();
|
|
@@ -58,7 +57,7 @@ async function x({
|
|
|
58
57
|
cleanup: i
|
|
59
58
|
}) {
|
|
60
59
|
let u = "", h = !1;
|
|
61
|
-
const
|
|
60
|
+
const m = R(), p = (s) => {
|
|
62
61
|
console.warn("Cleanup plugin:", a, "Reason:", s), i();
|
|
63
62
|
}, d = (s = {}) => {
|
|
64
63
|
var C;
|
|
@@ -76,7 +75,7 @@ async function x({
|
|
|
76
75
|
d(s);
|
|
77
76
|
}), setTimeout(async () => {
|
|
78
77
|
if (!h) {
|
|
79
|
-
if (
|
|
78
|
+
if (m) return;
|
|
80
79
|
if (o) {
|
|
81
80
|
const s = await F({ licenseKey: o, pluginName: a, baseApiUrl: u });
|
|
82
81
|
s && d(s);
|
|
@@ -102,13 +101,13 @@ async function F(e) {
|
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
105
|
-
const a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new WeakMap(),
|
|
104
|
+
const a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new WeakMap(), m = {
|
|
106
105
|
emptyStates: [],
|
|
107
106
|
...t
|
|
108
107
|
}, p = (n, r) => {
|
|
109
|
-
let
|
|
108
|
+
let y = !1;
|
|
110
109
|
const { isValid: f } = r;
|
|
111
|
-
return Array.isArray(f) ?
|
|
110
|
+
return Array.isArray(f) ? y = f.some((l) => n.is(l)) : _(f) ? y = f({ component: n, editor: e }) : y = n.is(f), y;
|
|
112
111
|
}, d = (n) => {
|
|
113
112
|
const r = a.get(n);
|
|
114
113
|
a.delete(n), r == null || r();
|
|
@@ -118,11 +117,11 @@ const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
|
118
117
|
if (!(!n || u.has(n)))
|
|
119
118
|
try {
|
|
120
119
|
u.add(n);
|
|
121
|
-
const r = n.components().length > 0,
|
|
122
|
-
if (r &&
|
|
120
|
+
const r = n.components().length > 0, y = i.get(n);
|
|
121
|
+
if (r && y)
|
|
123
122
|
s(n);
|
|
124
|
-
else if (!r && !
|
|
125
|
-
const f = h.has(n) ? h.get(n) :
|
|
123
|
+
else if (!r && !y) {
|
|
124
|
+
const f = h.has(n) ? h.get(n) : m.emptyStates.find((l) => p(n, l));
|
|
126
125
|
if (h.set(n, f), !f) return;
|
|
127
126
|
n.views.forEach((l) => {
|
|
128
127
|
const S = f.render({
|
|
@@ -153,14 +152,14 @@ const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
|
153
152
|
}, L = e.Components.events, C = `${L.update}:components`, T = "component:mount", b = e.Canvas.events.frameLoadBody, U = L.removed;
|
|
154
153
|
e.on(C, c), e.on(T, c), e.on(U, E), e.on(b, v), x({
|
|
155
154
|
editor: e,
|
|
156
|
-
licenseKey:
|
|
155
|
+
licenseKey: m.licenseKey,
|
|
157
156
|
plan: w.startup,
|
|
158
157
|
pluginName: G,
|
|
159
158
|
cleanup: () => {
|
|
160
159
|
e.off(C, c), e.off(T, c), e.off(U, E), e.off(b, v);
|
|
161
160
|
}
|
|
162
161
|
});
|
|
163
|
-
},
|
|
162
|
+
}, q = j(H);
|
|
164
163
|
export {
|
|
165
|
-
|
|
164
|
+
q as default
|
|
166
165
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,
|
|
1
|
+
(function(y,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_canvasEmptyState=v())})(this,function(){"use strict";const y="app.grapesjs.com",v="app-stage.grapesjs.com",A=[y,v,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",N="license:check:end",P=()=>typeof window<"u",D=({isDev:e,isStage:t})=>`${e?"":`https://${t?v:y}`}/api`,_=()=>{const e=P()&&window.location.hostname;return!!e&&(A.includes(e)||A.some(t=>e.endsWith(t)))};function R(e){return typeof e=="function"}async function K({path:e,baseApiUrl:t,method:o="GET",headers:a={},params:i,body:u}){const w=`${t||D({isDev:!1,isStage:!1})}${e}`,p={method:o,headers:{"Content-Type":"application/json",...a}};u&&(p.body=JSON.stringify(u));const d=i?new URLSearchParams(i).toString():"",s=d?`?${d}`:"",c=await fetch(`${w}${s}`,p);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return c.json()}var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{});const I={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function j(e){const t=e;return t.init=o=>a=>e(a,o),t}const x=e=>j(e);async function O({editor:e,plan:t,pluginName:o,licenseKey:a,cleanup:i}){let u="",h=!1;const w=_(),p=s=>{console.warn("Cleanup plugin:",o,"Reason:",s),i()},d=(s={})=>{var S;const{error:c,sdkLicense:T}=s,C=(S=s.plan)==null?void 0:S.category;if(!(T||s.license)||c)p(c||"Invalid license");else if(C){const b=I[t],L=I[C];b>L&&p({pluginRequiredPlan:t,licensePlan:C})}};e.on($,s=>{u=s==null?void 0:s.baseApiUrl,h=!0}),e.on(N,s=>{d(s)}),setTimeout(async()=>{if(!h){if(w)return;if(a){const s=await F({licenseKey:a,pluginName:o,baseApiUrl:u});s&&d(s)}else p("The `licenseKey` option not provided")}},2e3)}async function F(e){const{licenseKey:t,pluginName:o,baseApiUrl:a}=e;try{return(await K({baseApiUrl:a,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const G="canvasEmptyState";return x(function(e,t={}){const o=new WeakMap,a=new WeakMap,i=new WeakMap,u=new Set,h=new WeakMap,w={emptyStates:[],...t},p=(n,r)=>{let m=!1;const{isValid:f}=r;return Array.isArray(f)?m=f.some(l=>n.is(l)):R(f)?m=f({component:n,editor:e}):m=n.is(f),m},d=n=>{const r=o.get(n);o.delete(n),r==null||r()},s=n=>{n.views.forEach(r=>d(r)),i.delete(n)},c=n=>{if(!(!n||u.has(n)))try{u.add(n);const r=n.components().length>0,m=i.get(n);if(r&&m)s(n);else if(!r&&!m){const f=h.has(n)?h.get(n):w.emptyStates.find(l=>p(n,l));if(h.set(n,f),!f)return;n.views.forEach(l=>{const U=f.render({editor:e,component:n,componentView:l,mount:E=>{a.set(l,E),i.set(n,!0);const W=l.getChildrenContainer();W==null||W.appendChild(E)},unmount:()=>d(l)});o.set(l,()=>{U==null||U();const E=a.get(l);E==null||E.remove()})})}}finally{u.delete(n)}},T=n=>{i.has(n)&&s(n)},C=({model:n})=>{c(n.getComponent())},k=e.Components.events,S=`${k.update}:components`,b="component:mount",L=e.Canvas.events.frameLoadBody,M=k.removed;e.on(S,c),e.on(b,c),e.on(M,T),e.on(L,C),O({editor:e,licenseKey:w.licenseKey,plan:g.startup,pluginName:G,cleanup:()=>{e.off(S,c),e.off(b,c),e.off(M,T),e.off(L,C)}})})});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('../utils').PluginWithInit<
|
|
1
|
+
import { CanvasFullSizeOptions } from './types';
|
|
2
|
+
declare const _default: import('../utils').PluginWithInit<CanvasFullSizeOptions>;
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";function j(e,a,n){let t,o,c,p,d;const r=a;function u(){const l=Date.now()-p;l<r&&l>=0?t=setTimeout(u,r-l):(t=null,d=e.apply(c,o),c=o=null)}const s=function(){return c=this,o=arguments,p=Date.now(),t||(t=setTimeout(u,r)),d};return s.clear=function(){t&&(clearTimeout(t),t=null)},s.flush=function(){t&&(d=e.apply(c,o),c=o=null,clearTimeout(t),t=null)},s}const R="app.grapesjs.com",U="app-stage.grapesjs.com",k=[R,U,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],K="license:check:start",F="license:check:end",q=()=>typeof window<"u",V=({isDev:e,isStage:a})=>`${e?"":`https://${a?U:R}`}/api`,X=()=>{const e=q()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(a=>e.endsWith(a)))};async function Y({path:e,baseApiUrl:a,method:n="GET",headers:t={},params:o,body:c}){const d=`${a||V({isDev:!1,isStage:!1})}${e}`,r={method:n,headers:{"Content-Type":"application/json",...t}};c&&(r.body=JSON.stringify(c));const u=o?new URLSearchParams(o).toString():"",s=u?`?${u}`:"",l=await fetch(`${d}${s}`,r);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{});const z={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function B(e){const a=e;return a.init=n=>t=>e(t,n),a}const G=e=>B(e);async function Z({editor:e,plan:a,pluginName:n,licenseKey:t,cleanup:o}){let c="",p=!1;const d=X(),r=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),o()},u=(s={})=>{var C;const{error:l,sdkLicense:D}=s,y=(C=s.plan)==null?void 0:C.category;if(!(D||s.license)||l)r(l||"Invalid license");else if(y){const S=z[a],T=z[y];S>T&&r({pluginRequiredPlan:a,licensePlan:y})}};e.on(K,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(F,s=>{u(s)}),setTimeout(async()=>{if(!p){if(d)return;if(t){const s=await J({licenseKey:t,pluginName:n,baseApiUrl:c});s&&u(s)}else r("The `licenseKey` option not provided")}},2e3)}async function J(e){const{licenseKey:a,pluginName:n,baseApiUrl:t}=e;try{return(await Y({baseApiUrl:t,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const N="canvasFullSize",Q=function(e,a={}){const{Canvas:n,Commands:t,Devices:o}=e,c={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...a},{canvasOffsetY:p,canvasOffsetX:d,canvasTransition:r,deviceMaxWidth:u,deviceMinHeigth:s,frameBorderRadius:l,frameTransition:D}=c,y=`${s}px`,E=n.events,C=`${t.events.stopCommand}core:preview`,S=n.getConfig(),T=`${N}:disable`,P=o.getAll().map(i=>({...i.attributes}));S.scrollableCanvas=!0,o.getAll().map(i=>{!i.get("width")&&i.set("width",`${u}px`),!i.get("height")&&i.set("height","auto"),!i.get("minHeight")&&i.set("minHeight",y)});const L=i=>{const v="data-gs-plg-full-size",f=document.querySelector(`style[${v}]`);if(i&&f)return f.remove();const m=f||document.createElement("style"),h=n.getZoomMultiplier();m.setAttribute(v,"true"),m.innerHTML=`
|
|
2
2
|
.gjs-frame-wrapper { transition: width ${D}s !important; }
|
|
3
3
|
.gjs-frame-wrapper__bottom { height: ${p*h}px }
|
|
4
4
|
.gjs-frame { border-radius: ${l}px }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('../utils').PluginWithInit<
|
|
1
|
+
import { CanvasFullSizeOptions } from './types';
|
|
2
|
+
declare const _default: import('../utils').PluginWithInit<CanvasFullSizeOptions>;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('../utils').PluginWithInit<
|
|
1
|
+
import { CanvasFullSizeOptions } from './types';
|
|
2
|
+
declare const _default: import('../utils').PluginWithInit<CanvasFullSizeOptions>;
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "grapesjs";
|
|
2
1
|
function j(e, a, n) {
|
|
3
2
|
let t, o, c, p, d;
|
|
4
3
|
const r = a;
|
|
@@ -194,7 +193,7 @@ const N = "canvasFullSize", Q = function(e, a = {}) {
|
|
|
194
193
|
e.runCommand(T);
|
|
195
194
|
}
|
|
196
195
|
});
|
|
197
|
-
},
|
|
196
|
+
}, ee = G(Q);
|
|
198
197
|
export {
|
|
199
|
-
|
|
198
|
+
ee as default
|
|
200
199
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(C,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(
|
|
1
|
+
(function(C,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(C=typeof globalThis<"u"?globalThis:C||self,C.StudioSdkPlugins_canvasFullSize=y())})(this,function(){"use strict";function C(e,i,n){let t,o,c,p,d;const r=i;function u(){const l=Date.now()-p;l<r&&l>=0?t=setTimeout(u,r-l):(t=null,d=e.apply(c,o),c=o=null)}const s=function(){return c=this,o=arguments,p=Date.now(),t||(t=setTimeout(u,r)),d};return s.clear=function(){t&&(clearTimeout(t),t=null)},s.flush=function(){t&&(d=e.apply(c,o),c=o=null,clearTimeout(t),t=null)},s}const y="app.grapesjs.com",H="app-stage.grapesjs.com",M=[y,H,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_="license:check:start",j="license:check:end",F=()=>typeof window<"u",K=({isDev:e,isStage:i})=>`${e?"":`https://${i?H:y}`}/api`,q=()=>{const e=F()&&window.location.hostname;return!!e&&(M.includes(e)||M.some(i=>e.endsWith(i)))};async function V({path:e,baseApiUrl:i,method:n="GET",headers:t={},params:o,body:c}){const d=`${i||K({isDev:!1,isStage:!1})}${e}`,r={method:n,headers:{"Content-Type":"application/json",...t}};c&&(r.body=JSON.stringify(c));const u=o?new URLSearchParams(o).toString():"",s=u?`?${u}`:"",l=await fetch(`${d}${s}`,r);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{});const O={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function X(e){const i=e;return i.init=n=>t=>e(t,n),i}const Y=e=>X(e);async function B({editor:e,plan:i,pluginName:n,licenseKey:t,cleanup:o}){let c="",p=!1;const d=q(),r=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),o()},u=(s={})=>{var T;const{error:l,sdkLicense:x}=s,S=(T=s.plan)==null?void 0:T.category;if(!(x||s.license)||l)r(l||"Invalid license");else if(S){const E=O[i],D=O[S];E>D&&r({pluginRequiredPlan:i,licensePlan:S})}};e.on(_,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(j,s=>{u(s)}),setTimeout(async()=>{if(!p){if(d)return;if(t){const s=await G({licenseKey:t,pluginName:n,baseApiUrl:c});s&&u(s)}else r("The `licenseKey` option not provided")}},2e3)}async function G(e){const{licenseKey:i,pluginName:n,baseApiUrl:t}=e;try{return(await V({baseApiUrl:t,path:`/sdk/${i||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const k="canvasFullSize";return Y(function(e,i={}){const{Canvas:n,Commands:t,Devices:o}=e,c={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...i},{canvasOffsetY:p,canvasOffsetX:d,canvasTransition:r,deviceMaxWidth:u,deviceMinHeigth:s,frameBorderRadius:l,frameTransition:x}=c,S=`${s}px`,$=n.events,T=`${t.events.stopCommand}core:preview`,E=n.getConfig(),D=`${k}:disable`,Z=o.getAll().map(a=>({...a.attributes}));E.scrollableCanvas=!0,o.getAll().map(a=>{!a.get("width")&&a.set("width",`${u}px`),!a.get("height")&&a.set("height","auto"),!a.get("minHeight")&&a.set("minHeight",S)});const A=a=>{const v="data-gs-plg-full-size",f=document.querySelector(`style[${v}]`);if(a&&f)return f.remove();const m=f||document.createElement("style"),h=n.getZoomMultiplier();m.setAttribute(v,"true"),m.innerHTML=`
|
|
2
2
|
.gjs-frame-wrapper { transition: width ${x}s !important; }
|
|
3
3
|
.gjs-frame-wrapper__bottom { height: ${p*h}px }
|
|
4
4
|
.gjs-frame { border-radius: ${l}px }
|
|
5
|
-
`,!f&&document.body.appendChild(m)};e.on($.frameLoadHead,a=>{if(!E.scrollableCanvas)return;const{window:v}=a,f=v.document,m=f.head,h="data-gs-plg-wrapper-style",w=m.querySelector(`style[${h}]`)||f.createElement("style");w.setAttribute(h,"true"),w.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${S}; }`,!m.contains(w)&&m.appendChild(w)}),e.onReady(()=>{const a=n.getSpotsEl(),v=n.getElement(),f=n.getFramesEl(),m=r*1e3,h=v.style;h.overflowX="hidden",f.style.transition=`transform ${r}s`;const w={x:d,y:p};A();const
|
|
5
|
+
`,!f&&document.body.appendChild(m)};e.on($.frameLoadHead,a=>{if(!E.scrollableCanvas)return;const{window:v}=a,f=v.document,m=f.head,h="data-gs-plg-wrapper-style",w=m.querySelector(`style[${h}]`)||f.createElement("style");w.setAttribute(h,"true"),w.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${S}; }`,!m.contains(w)&&m.appendChild(w)}),e.onReady(()=>{const a=n.getSpotsEl(),v=n.getElement(),f=n.getFramesEl(),m=r*1e3,h=v.style;h.overflowX="hidden",f.style.transition=`transform ${r}s`;const w={x:d,y:p};A();const z=()=>a.style.display="none",J=()=>a.style.display="",L=C(()=>{n.fitViewport({zoom:g=>g>100?100:g,ignoreHeight:!0,gap:w}),A(),setTimeout(()=>{var g,U;e.em.destroyed||((U=(g=e.getSelected())==null?void 0:g.getEl())==null||U.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),J())},m)},100),I=new ResizeObserver(()=>{z(),L()});I.observe(v.parentElement);const W=()=>{z(),L()},N=(g={})=>{g.options&&g.options.from!=="fitViewport"&&n.fitViewport({zoom:n.getZoom(),ignoreHeight:!0,gap:w})},P=()=>{h.overflowX="hidden",h.overflowY="auto"},R=()=>{I.disconnect(),L.clear()};e.on(o.events.select,W),e.on($.zoom,N),e.on(T,P),e.on(e.events.destroy,R),L(),t.add(D,()=>{o.devices.reset(Z),E.scrollableCanvas=!1,n.getModel().updateDevice(),n.setZoom(100),n.setCoords(0,0),h.overflowY="hidden",A(!0),e.off(o.events.select,W),e.off($.zoom,N),e.off(T,P),R(),t.run("studio:canvasReload")})}),B({editor:e,licenseKey:c.licenseKey,plan:b.startup,pluginName:k,cleanup:()=>{e.runCommand(D)}})})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
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",$=({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)))};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()}var W=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(W||{});const P={[W.free]:0,[W.startup]:10,[W.business]:20,[W.enterprise]:30};function A(n){const s=n;return s.init=i=>t=>n(t,i),s}const q=n=>A(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>
|
|
@@ -56,4 +56,4 @@
|
|
|
56
56
|
.${c} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
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=
|
|
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=q(B);module.exports=z;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "grapesjs";
|
|
2
1
|
const C = "app.grapesjs.com", O = "app-stage.grapesjs.com", L = [
|
|
3
2
|
C,
|
|
4
3
|
O,
|
|
@@ -370,7 +369,7 @@ const T = (...n) => n.map((s) => `[data-gjs-type="${s}"]`).join(","), I = "dialo
|
|
|
370
369
|
i.remove(l), t.removeType(l);
|
|
371
370
|
}
|
|
372
371
|
});
|
|
373
|
-
},
|
|
372
|
+
}, z = q(B);
|
|
374
373
|
export {
|
|
375
|
-
|
|
374
|
+
z as default
|
|
376
375
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(f,v){typeof exports=="object"&&typeof module<"u"?module.exports=v(
|
|
1
|
+
(function(f,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(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)))};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()}var b=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(b||{});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 A({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 q({licenseKey:t,pluginName:i,baseApiUrl:l});o&&d(o)}else r("The `licenseKey` option not provided")}},2e3)}async function q(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>
|
|
@@ -56,4 +56,4 @@
|
|
|
56
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(){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=""})}}}),
|
|
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=""})}}}),A({editor:n,licenseKey:p,plan:b.startup,pluginName:U,cleanup:()=>{i.remove(l),t.removeType(l)}})})});
|