@grapesjs/studio-sdk-plugins 1.0.28-rc.2 → 1.0.28
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 +8 -8
- package/dist/accordionComponent/index.es.js +71 -69
- package/dist/accordionComponent/index.umd.js +6 -6
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +48 -46
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +86 -84
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +68 -66
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +52 -50
- package/dist/canvasFullSize/index.umd.js +7 -7
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +191 -189
- package/dist/canvasGridMode/index.umd.js +2 -2
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +32 -30
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +31 -29
- package/dist/dataSourceHandlebars/index.umd.js +2 -2
- package/dist/dialogComponent/index.cjs.js +3 -3
- package/dist/dialogComponent/index.es.js +32 -30
- package/dist/dialogComponent/index.umd.js +4 -4
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +74 -72
- package/dist/flexComponent/index.umd.js +7 -7
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +40 -38
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +70 -68
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +56 -54
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +43 -43
- package/dist/index.es.js +1442 -1440
- package/dist/index.umd.js +43 -43
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +29 -27
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +90 -88
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +20 -18
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +4 -4
- package/dist/listPagesComponent/index.es.js +42 -40
- package/dist/listPagesComponent/index.umd.js +4 -4
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +156 -154
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +165 -163
- package/dist/prosemirror/index.umd.js +7 -7
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +101 -99
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +54 -52
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/swiperComponent/index.cjs.js +7 -7
- package/dist/swiperComponent/index.es.js +60 -58
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +80 -78
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +66 -64
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
1
|
+
"use strict";const x="app.grapesjs.com",L="app-stage.grapesjs.com",z="app2.grapesjs.com",P="app-stage2.grapesjs.com",$=[x,z,L,P,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",D="license:check:end",G=()=>typeof window<"u",V=({isDev:e,isStage:t})=>`${e?"":`https://${t?L:x}`}/api`,U=()=>{const e=G()&&window.location.hostname;return!!e&&($.includes(e)||$.some(t=>e.endsWith(t)))};async function j({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:c,body:i}){const m=`${t||V({isDev:!1,isStage:!1})}${e}`,a={method:n,headers:{"Content-Type":"application/json",...s}};i&&(a.body=JSON.stringify(i));const r=c?new URLSearchParams(c).toString():"",o=r?`?${r}`:"",l=await fetch(`${m}${o}`,a);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 K(e){const t=e;return t.init=n=>s=>e(s,n),t}const R=e=>K(e);async function W({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:c}){let i="",d=!1;const m=U(),a=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)a(l||"Invalid license");else if(g){const N=E[t],_=E[g];N>_&&a({pluginRequiredPlan:t,licensePlan:g})}};e.on(B,o=>{i=o==null?void 0:o.baseApiUrl,d=!0}),e.on(D,o=>{r(o)}),setTimeout(async()=>{if(!d){if(m)return;if(s){const o=await F({licenseKey:s,pluginName:n,baseApiUrl:i});o&&r(o)}else a("The `licenseKey` option not provided")}},2e3)}async function F(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await j({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)),Y=(...e)=>(t,n)=>e.some(s=>n.is(s)),C="gjs-plg-",T="data-type-role",p="accordion",q=`${p}-group`,u=`${p}-header`,h=`${p}-content`,y=`${p}-marker`,M=`${C}${u}`,k=`${C}${y}`,Z=`${C}${h}`,S=`${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>'},H=(e,t)=>{const{toolbarIconOpen:n=v.eye}=t,s=e.is(p)?e:e.closestType(p);if(!n||!s)return;const{toolbar:c}=e,i={id:"accordion-toggle-open",label:n,command:()=>s.toggleOpen()};!c.find(m=>m.id===i.id)&&(c==null||c.unshift(i))},J=(e,t)=>{const{Components:n,Blocks:s}=e,{block:c={}}=t,i="Accordion",d=`${C}${p}`,m=function(a={}){const r=this,o=()=>{const{clsMarkerOpen:l}=a,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(p,{block:c&&{label:i,media:v.accordion,category:"Extra",select:!0,...c},isComponent:A(p),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:d,emptyState:!0,clsMarkerOpen:S,attributes:{[T]:p},droppable:O(u,h),components:[{type:u},{type:h}],"script-props":["clsMarkerOpen"],script:m,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
2
|
+
.${d}::details-content {
|
|
3
3
|
opacity: 0;
|
|
4
4
|
block-size: 0;
|
|
5
5
|
overflow: hidden;
|
|
@@ -10,30 +10,30 @@
|
|
|
10
10
|
transition-duration: 0.2s;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.${
|
|
13
|
+
.${d}[open]::details-content {
|
|
14
14
|
opacity: 1;
|
|
15
15
|
transform: translateY(0);
|
|
16
16
|
block-size: auto;
|
|
17
17
|
}
|
|
18
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){
|
|
18
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){H(this,t)}}}),()=>{s.remove(p),n.removeType(p)}},Q=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:Z,icon:v.accordionContent,attributes:{[T]:h},components:"<div>Accordion content</div>"}}}),()=>{t.removeType(h)}},X=(e,t)=>{const{Components:n,Blocks:s}=e,{blockGroup:c={}}=t,i="Accordion Group",d=function(a={}){if(!a.single)return;const r=this;r.addEventListener("details-toggle",o=>{const l=o.target;if(!a.single||!l||!l.open)return;r.querySelectorAll('[data-type-role="accordion"]').forEach(g=>{l!==g&&g.open&&(g.open=!1)})})},m=(a={})=>({type:p,attributes:{open:a.open},components:[{type:u,components:[`<div>${a.header}</div>`,{type:y}]},{type:h,components:`<div>${a.content}</div>`}]});return n.addType(q,{block:c&&{label:i,media:v.accordionGroup,category:"Extra",select:!0,...c},isComponent:A(q),model:{defaults:{name:i,attributes:{[T]:q},droppable:O(p),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,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:d}}}),()=>{s.remove(q),n.removeType(q)}},ee=(e,t)=>{const{Components:n}=e;return n.addType(u,{isComponent:A(u),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:v.accordionHeader,classes:M,attributes:{[T]:u},components:["<div>Accordion header</div>",{type:y}],styles:`
|
|
19
19
|
summary {
|
|
20
20
|
list-style: none;
|
|
21
21
|
}
|
|
22
|
-
.${
|
|
22
|
+
.${M} {
|
|
23
23
|
cursor: pointer;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
26
26
|
justify-content: space-between;
|
|
27
27
|
gap: 1rem;
|
|
28
28
|
}
|
|
29
|
-
`},initToolbar(){
|
|
29
|
+
`},initToolbar(){H(this,t)}}}),()=>{n.removeType(u)}},te=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:Y(u),styles:`
|
|
30
30
|
.${k} {
|
|
31
31
|
min-width: 24px;
|
|
32
32
|
width: 24px;
|
|
33
33
|
height: 24px;
|
|
34
34
|
transition: transform 0.2s ease-in-out;
|
|
35
35
|
}
|
|
36
|
-
.${
|
|
36
|
+
.${S} {
|
|
37
37
|
transform: rotateZ(180deg);
|
|
38
38
|
}
|
|
39
|
-
`}}}),()=>{t.removeType(y)}},
|
|
39
|
+
`}}}),()=>{t.removeType(y)}},ne="accordionComponent",oe=b.startup,se=function(e,t={}){const n=[J(e,t),X(e,t),ee(e,t),te(e),Q(e)];W({editor:e,licenseKey:t.licenseKey,plan:oe,pluginName:ne,cleanup:()=>{n.forEach(s=>s())}})},ce=R(se);module.exports=ce;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const x = "app.grapesjs.com", L = "app-stage.grapesjs.com", z = "app2.grapesjs.com", P = "app-stage2.grapesjs.com", $ = [
|
|
2
|
+
x,
|
|
3
|
+
z,
|
|
3
4
|
L,
|
|
5
|
+
P,
|
|
4
6
|
"localhost",
|
|
5
7
|
"127.0.0.1",
|
|
6
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -9,11 +11,11 @@ const M = "app.grapesjs.com", L = "app-stage.grapesjs.com", $ = [
|
|
|
9
11
|
// For stackblitz.com demos
|
|
10
12
|
"-sandpack.codesandbox.io"
|
|
11
13
|
// For Sandpack demos
|
|
12
|
-
],
|
|
13
|
-
const e =
|
|
14
|
+
], B = "license:check:start", D = "license:check:end", G = () => typeof window < "u", V = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? L : x}`}/api`, U = () => {
|
|
15
|
+
const e = G() && window.location.hostname;
|
|
14
16
|
return !!e && ($.includes(e) || $.some((t) => e.endsWith(t)));
|
|
15
17
|
};
|
|
16
|
-
async function
|
|
18
|
+
async function j({
|
|
17
19
|
path: e,
|
|
18
20
|
baseApiUrl: t,
|
|
19
21
|
method: n = "GET",
|
|
@@ -21,7 +23,7 @@ async function U({
|
|
|
21
23
|
params: c,
|
|
22
24
|
body: i
|
|
23
25
|
}) {
|
|
24
|
-
const
|
|
26
|
+
const m = `${t || V({ isDev: !1, isStage: !1 })}${e}`, a = {
|
|
25
27
|
method: n,
|
|
26
28
|
headers: {
|
|
27
29
|
"Content-Type": "application/json",
|
|
@@ -29,7 +31,7 @@ async function U({
|
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
i && (a.body = JSON.stringify(i));
|
|
32
|
-
const r = c ? new URLSearchParams(c).toString() : "", o = r ? `?${r}` : "", l = await fetch(`${
|
|
34
|
+
const r = c ? new URLSearchParams(c).toString() : "", o = r ? `?${r}` : "", l = await fetch(`${m}${o}`, a);
|
|
33
35
|
if (!l.ok)
|
|
34
36
|
throw new Error(`HTTP error! status: ${l.status}`);
|
|
35
37
|
return l.json();
|
|
@@ -41,11 +43,11 @@ const E = {
|
|
|
41
43
|
[b.business]: 20,
|
|
42
44
|
[b.enterprise]: 30
|
|
43
45
|
};
|
|
44
|
-
function
|
|
46
|
+
function K(e) {
|
|
45
47
|
const t = e;
|
|
46
48
|
return t.init = (n) => (s) => e(s, n), t;
|
|
47
49
|
}
|
|
48
|
-
const
|
|
50
|
+
const R = (e) => /* @__PURE__ */ K(e);
|
|
49
51
|
async function W({
|
|
50
52
|
editor: e,
|
|
51
53
|
plan: t,
|
|
@@ -53,8 +55,8 @@ async function W({
|
|
|
53
55
|
licenseKey: s,
|
|
54
56
|
cleanup: c
|
|
55
57
|
}) {
|
|
56
|
-
let i = "",
|
|
57
|
-
const
|
|
58
|
+
let i = "", d = !1;
|
|
59
|
+
const m = U(), a = (o) => {
|
|
58
60
|
console.warn("Cleanup plugin:", n, "Reason:", o), c();
|
|
59
61
|
}, r = (o = {}) => {
|
|
60
62
|
var w;
|
|
@@ -62,29 +64,29 @@ async function W({
|
|
|
62
64
|
if (!(f || o.license) || l)
|
|
63
65
|
a(l || "Invalid license");
|
|
64
66
|
else if (g) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
+
const N = E[t], _ = E[g];
|
|
68
|
+
N > _ && a({ pluginRequiredPlan: t, licensePlan: g });
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
|
-
e.on(
|
|
70
|
-
i = o == null ? void 0 : o.baseApiUrl,
|
|
71
|
-
}), e.on(
|
|
71
|
+
e.on(B, (o) => {
|
|
72
|
+
i = o == null ? void 0 : o.baseApiUrl, d = !0;
|
|
73
|
+
}), e.on(D, (o) => {
|
|
72
74
|
r(o);
|
|
73
75
|
}), setTimeout(async () => {
|
|
74
|
-
if (!
|
|
75
|
-
if (
|
|
76
|
+
if (!d) {
|
|
77
|
+
if (m) return;
|
|
76
78
|
if (s) {
|
|
77
|
-
const o = await
|
|
79
|
+
const o = await F({ licenseKey: s, pluginName: n, baseApiUrl: i });
|
|
78
80
|
o && r(o);
|
|
79
81
|
} else
|
|
80
82
|
a("The `licenseKey` option not provided");
|
|
81
83
|
}
|
|
82
84
|
}, 2e3);
|
|
83
85
|
}
|
|
84
|
-
async function
|
|
86
|
+
async function F(e) {
|
|
85
87
|
const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
|
|
86
88
|
try {
|
|
87
|
-
return (await
|
|
89
|
+
return (await j({
|
|
88
90
|
baseApiUrl: s,
|
|
89
91
|
path: `/sdk/${t || "na"}`,
|
|
90
92
|
method: "POST",
|
|
@@ -100,7 +102,7 @@ async function R(e) {
|
|
|
100
102
|
const A = (e) => (t) => {
|
|
101
103
|
var n;
|
|
102
104
|
return ((n = t.getAttribute) == null ? void 0 : n.call(t, T)) === e;
|
|
103
|
-
}, O = (...e) => (t) => e.some((n) => t.is(n)),
|
|
105
|
+
}, O = (...e) => (t) => e.some((n) => t.is(n)), Y = (...e) => (t, n) => e.some((s) => n.is(s)), C = "gjs-plg-", T = "data-type-role", p = "accordion", q = `${p}-group`, u = `${p}-header`, h = `${p}-content`, y = `${p}-marker`, M = `${C}${u}`, k = `${C}${y}`, Z = `${C}${h}`, S = `${k}-open`, v = {
|
|
104
106
|
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>',
|
|
105
107
|
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>',
|
|
106
108
|
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>',
|
|
@@ -108,17 +110,17 @@ const A = (e) => (t) => {
|
|
|
108
110
|
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>',
|
|
109
111
|
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>',
|
|
110
112
|
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>'
|
|
111
|
-
},
|
|
112
|
-
const { toolbarIconOpen: n = v.eye } = t, s = e.is(
|
|
113
|
+
}, H = (e, t) => {
|
|
114
|
+
const { toolbarIconOpen: n = v.eye } = t, s = e.is(p) ? e : e.closestType(p);
|
|
113
115
|
if (!n || !s) return;
|
|
114
116
|
const { toolbar: c } = e, i = {
|
|
115
117
|
id: "accordion-toggle-open",
|
|
116
118
|
label: n,
|
|
117
119
|
command: () => s.toggleOpen()
|
|
118
120
|
};
|
|
119
|
-
!c.find((
|
|
120
|
-
},
|
|
121
|
-
const { Components: n, Blocks: s } = e, { block: c = {} } = t, i = "Accordion",
|
|
121
|
+
!c.find((m) => m.id === i.id) && (c == null || c.unshift(i));
|
|
122
|
+
}, J = (e, t) => {
|
|
123
|
+
const { Components: n, Blocks: s } = e, { block: c = {} } = t, i = "Accordion", d = `${C}${p}`, m = function(a = {}) {
|
|
122
124
|
const r = this, o = () => {
|
|
123
125
|
const { clsMarkerOpen: l } = a, f = r.querySelector('[data-type-role="accordion-marker"]');
|
|
124
126
|
!f || !l || (r.open ? f.classList.add(l) : f.classList.remove(l));
|
|
@@ -127,7 +129,7 @@ const A = (e) => (t) => {
|
|
|
127
129
|
o(), r.dispatchEvent(new CustomEvent("details-toggle", { bubbles: !0 }));
|
|
128
130
|
}), o();
|
|
129
131
|
};
|
|
130
|
-
return n.addType(
|
|
132
|
+
return n.addType(p, {
|
|
131
133
|
block: c && {
|
|
132
134
|
label: i,
|
|
133
135
|
media: v.accordion,
|
|
@@ -135,20 +137,20 @@ const A = (e) => (t) => {
|
|
|
135
137
|
select: !0,
|
|
136
138
|
...c
|
|
137
139
|
},
|
|
138
|
-
isComponent: A(
|
|
140
|
+
isComponent: A(p),
|
|
139
141
|
extendFn: ["initToolbar"],
|
|
140
142
|
model: {
|
|
141
143
|
defaults: {
|
|
142
144
|
tagName: "details",
|
|
143
145
|
name: i,
|
|
144
|
-
classes:
|
|
146
|
+
classes: d,
|
|
145
147
|
emptyState: !0,
|
|
146
|
-
clsMarkerOpen:
|
|
147
|
-
attributes: { [T]:
|
|
148
|
-
droppable: O(
|
|
149
|
-
components: [{ type:
|
|
148
|
+
clsMarkerOpen: S,
|
|
149
|
+
attributes: { [T]: p },
|
|
150
|
+
droppable: O(u, h),
|
|
151
|
+
components: [{ type: u }, { type: h }],
|
|
150
152
|
"script-props": ["clsMarkerOpen"],
|
|
151
|
-
script:
|
|
153
|
+
script: m,
|
|
152
154
|
traits: [
|
|
153
155
|
{
|
|
154
156
|
type: "checkbox",
|
|
@@ -157,7 +159,7 @@ const A = (e) => (t) => {
|
|
|
157
159
|
}
|
|
158
160
|
],
|
|
159
161
|
styles: `
|
|
160
|
-
.${
|
|
162
|
+
.${d}::details-content {
|
|
161
163
|
opacity: 0;
|
|
162
164
|
block-size: 0;
|
|
163
165
|
overflow: hidden;
|
|
@@ -168,7 +170,7 @@ const A = (e) => (t) => {
|
|
|
168
170
|
transition-duration: 0.2s;
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
.${
|
|
173
|
+
.${d}[open]::details-content {
|
|
172
174
|
opacity: 1;
|
|
173
175
|
transform: translateY(0);
|
|
174
176
|
block-size: auto;
|
|
@@ -179,13 +181,13 @@ const A = (e) => (t) => {
|
|
|
179
181
|
this.addAttributes({ open: !this.getAttributes().open });
|
|
180
182
|
},
|
|
181
183
|
initToolbar() {
|
|
182
|
-
|
|
184
|
+
H(this, t);
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
}), () => {
|
|
186
|
-
s.remove(
|
|
188
|
+
s.remove(p), n.removeType(p);
|
|
187
189
|
};
|
|
188
|
-
},
|
|
190
|
+
}, Q = (e) => {
|
|
189
191
|
const { Components: t } = e;
|
|
190
192
|
return t.addType(h, {
|
|
191
193
|
isComponent: A(h),
|
|
@@ -196,7 +198,7 @@ const A = (e) => (t) => {
|
|
|
196
198
|
copyable: !1,
|
|
197
199
|
draggable: !1,
|
|
198
200
|
emptyState: !0,
|
|
199
|
-
classes:
|
|
201
|
+
classes: Z,
|
|
200
202
|
icon: v.accordionContent,
|
|
201
203
|
attributes: { [T]: h },
|
|
202
204
|
components: "<div>Accordion content</div>"
|
|
@@ -205,8 +207,8 @@ const A = (e) => (t) => {
|
|
|
205
207
|
}), () => {
|
|
206
208
|
t.removeType(h);
|
|
207
209
|
};
|
|
208
|
-
},
|
|
209
|
-
const { Components: n, Blocks: s } = e, { blockGroup: c = {} } = t, i = "Accordion Group",
|
|
210
|
+
}, X = (e, t) => {
|
|
211
|
+
const { Components: n, Blocks: s } = e, { blockGroup: c = {} } = t, i = "Accordion Group", d = function(a = {}) {
|
|
210
212
|
if (!a.single) return;
|
|
211
213
|
const r = this;
|
|
212
214
|
r.addEventListener("details-toggle", (o) => {
|
|
@@ -216,12 +218,12 @@ const A = (e) => (t) => {
|
|
|
216
218
|
l !== g && g.open && (g.open = !1);
|
|
217
219
|
});
|
|
218
220
|
});
|
|
219
|
-
},
|
|
220
|
-
type:
|
|
221
|
+
}, m = (a = {}) => ({
|
|
222
|
+
type: p,
|
|
221
223
|
attributes: { open: a.open },
|
|
222
224
|
components: [
|
|
223
225
|
{
|
|
224
|
-
type:
|
|
226
|
+
type: u,
|
|
225
227
|
components: [`<div>${a.header}</div>`, { type: y }]
|
|
226
228
|
},
|
|
227
229
|
{
|
|
@@ -243,11 +245,11 @@ const A = (e) => (t) => {
|
|
|
243
245
|
defaults: {
|
|
244
246
|
name: i,
|
|
245
247
|
attributes: { [T]: q },
|
|
246
|
-
droppable: O(
|
|
248
|
+
droppable: O(p),
|
|
247
249
|
single: !0,
|
|
248
250
|
emptyState: !0,
|
|
249
251
|
components: Array(3).fill(0).map(
|
|
250
|
-
(a, r) =>
|
|
252
|
+
(a, r) => m({
|
|
251
253
|
open: r === 0,
|
|
252
254
|
header: `Accordion header ${r + 1}`,
|
|
253
255
|
content: `Accordion content ${r + 1}`
|
|
@@ -263,16 +265,16 @@ const A = (e) => (t) => {
|
|
|
263
265
|
}
|
|
264
266
|
],
|
|
265
267
|
"script-props": ["single"],
|
|
266
|
-
script:
|
|
268
|
+
script: d
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
271
|
}), () => {
|
|
270
272
|
s.remove(q), n.removeType(q);
|
|
271
273
|
};
|
|
272
|
-
},
|
|
274
|
+
}, ee = (e, t) => {
|
|
273
275
|
const { Components: n } = e;
|
|
274
|
-
return n.addType(
|
|
275
|
-
isComponent: A(
|
|
276
|
+
return n.addType(u, {
|
|
277
|
+
isComponent: A(u),
|
|
276
278
|
extendFn: ["initToolbar"],
|
|
277
279
|
model: {
|
|
278
280
|
defaults: {
|
|
@@ -283,14 +285,14 @@ const A = (e) => (t) => {
|
|
|
283
285
|
draggable: !1,
|
|
284
286
|
emptyState: !0,
|
|
285
287
|
icon: v.accordionHeader,
|
|
286
|
-
classes:
|
|
287
|
-
attributes: { [T]:
|
|
288
|
+
classes: M,
|
|
289
|
+
attributes: { [T]: u },
|
|
288
290
|
components: ["<div>Accordion header</div>", { type: y }],
|
|
289
291
|
styles: `
|
|
290
292
|
summary {
|
|
291
293
|
list-style: none;
|
|
292
294
|
}
|
|
293
|
-
.${
|
|
295
|
+
.${M} {
|
|
294
296
|
cursor: pointer;
|
|
295
297
|
display: flex;
|
|
296
298
|
align-items: center;
|
|
@@ -300,13 +302,13 @@ const A = (e) => (t) => {
|
|
|
300
302
|
`
|
|
301
303
|
},
|
|
302
304
|
initToolbar() {
|
|
303
|
-
|
|
305
|
+
H(this, t);
|
|
304
306
|
}
|
|
305
307
|
}
|
|
306
308
|
}), () => {
|
|
307
|
-
n.removeType(
|
|
309
|
+
n.removeType(u);
|
|
308
310
|
};
|
|
309
|
-
},
|
|
311
|
+
}, te = (e) => {
|
|
310
312
|
const { Components: t } = e;
|
|
311
313
|
return t.addType(y, {
|
|
312
314
|
extend: "icon",
|
|
@@ -319,7 +321,7 @@ const A = (e) => (t) => {
|
|
|
319
321
|
attributes: { [T]: y },
|
|
320
322
|
components: v.caret,
|
|
321
323
|
droppable: !1,
|
|
322
|
-
draggable:
|
|
324
|
+
draggable: Y(u),
|
|
323
325
|
styles: `
|
|
324
326
|
.${k} {
|
|
325
327
|
min-width: 24px;
|
|
@@ -327,7 +329,7 @@ const A = (e) => (t) => {
|
|
|
327
329
|
height: 24px;
|
|
328
330
|
transition: transform 0.2s ease-in-out;
|
|
329
331
|
}
|
|
330
|
-
.${
|
|
332
|
+
.${S} {
|
|
331
333
|
transform: rotateZ(180deg);
|
|
332
334
|
}
|
|
333
335
|
`
|
|
@@ -336,24 +338,24 @@ const A = (e) => (t) => {
|
|
|
336
338
|
}), () => {
|
|
337
339
|
t.removeType(y);
|
|
338
340
|
};
|
|
339
|
-
},
|
|
341
|
+
}, ne = "accordionComponent", oe = b.startup, se = function(e, t = {}) {
|
|
340
342
|
const n = [
|
|
341
|
-
Y(e, t),
|
|
342
343
|
J(e, t),
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
X(e, t),
|
|
345
|
+
ee(e, t),
|
|
346
|
+
te(e),
|
|
347
|
+
Q(e)
|
|
346
348
|
];
|
|
347
349
|
W({
|
|
348
350
|
editor: e,
|
|
349
351
|
licenseKey: t.licenseKey,
|
|
350
|
-
plan:
|
|
351
|
-
pluginName:
|
|
352
|
+
plan: oe,
|
|
353
|
+
pluginName: ne,
|
|
352
354
|
cleanup: () => {
|
|
353
355
|
n.forEach((s) => s());
|
|
354
356
|
}
|
|
355
357
|
});
|
|
356
|
-
},
|
|
358
|
+
}, ce = R(se);
|
|
357
359
|
export {
|
|
358
|
-
|
|
360
|
+
ce as default
|
|
359
361
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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",
|
|
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",E=[v,"app2.grapesjs.com",b,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:start",I="license:check:end",N=()=>typeof window<"u",D=({isDev:e,isStage:n})=>`${e?"":`https://${n?b:v}`}/api`,P=()=>{const e=N()&&window.location.hostname;return!!e&&(E.includes(e)||E.some(n=>e.endsWith(n)))};async function z({path:e,baseApiUrl:n,method:t="GET",headers:s={},params:c,body:l}){const m=`${n||D({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 M={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function G(e){const n=e;return n.init=t=>s=>e(s,t),n}const B=e=>G(e);async function V({editor:e,plan:n,pluginName:t,licenseKey:s,cleanup:c}){let l="",p=!1;const m=P(),i=o=>{console.warn("Cleanup plugin:",t,"Reason:",o),c()},r=(o={})=>{var _;const{error:d,sdkLicense:A}=o,y=(_=o.plan)==null?void 0:_.category;if(!(A||o.license)||d)i(d||"Invalid license");else if(y){const ee=M[n],ne=M[y];ee>ne&&i({pluginRequiredPlan:n,licensePlan:y})}};e.on(H,o=>{l=o==null?void 0:o.baseApiUrl,p=!0}),e.on(I,o=>{r(o)}),setTimeout(async()=>{if(!p){if(m)return;if(s){const o=await U({licenseKey:s,pluginName:t,baseApiUrl:l});o&&r(o)}else i("The `licenseKey` option not provided")}},2e3)}async function U(e){const{licenseKey:n,pluginName:t,baseApiUrl:s}=e;try{return(await z({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},x=(...e)=>n=>e.some(t=>n.is(t)),j=(...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`,g=`${a}-marker`,O=`${w}${u}`,$=`${w}${g}`,R=`${w}${h}`,L=`${$}-open`,f={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,n)=>{const{toolbarIconOpen:t=f.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))},K=(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:f.accordion,category:"Extra",select:!0,...c},isComponent:C(a),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:l,classes:p,emptyState:!0,clsMarkerOpen:L,attributes:{[q]:a},droppable:x(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,25 +15,25 @@
|
|
|
15
15
|
transform: translateY(0);
|
|
16
16
|
block-size: auto;
|
|
17
17
|
}
|
|
18
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){
|
|
18
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){S(this,n)}}}),()=>{s.remove(a),t.removeType(a)}},W=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:R,icon:f.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:g}]},{type:h,components:`<div>${i.content}</div>`}]});return t.addType(k,{block:c&&{label:l,media:f.accordionGroup,category:"Extra",select:!0,...c},isComponent:C(k),model:{defaults:{name:l,attributes:{[q]:k},droppable:x(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:f.accordionHeader,classes:O,attributes:{[q]:u},components:["<div>Accordion header</div>",{type:g}],styles:`
|
|
19
19
|
summary {
|
|
20
20
|
list-style: none;
|
|
21
21
|
}
|
|
22
|
-
.${
|
|
22
|
+
.${O} {
|
|
23
23
|
cursor: pointer;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
26
26
|
justify-content: space-between;
|
|
27
27
|
gap: 1rem;
|
|
28
28
|
}
|
|
29
|
-
`},initToolbar(){
|
|
29
|
+
`},initToolbar(){S(this,n)}}}),()=>{t.removeType(u)}},Z=e=>{const{Components:n}=e;return n.addType(g,{extend:"icon",isComponent:C(g),model:{defaults:{name:"Accordion Marker",icon:f.accordionMarker,classes:$,attributes:{[q]:g},components:f.caret,droppable:!1,draggable:j(u),styles:`
|
|
30
30
|
.${$} {
|
|
31
31
|
min-width: 24px;
|
|
32
32
|
width: 24px;
|
|
33
33
|
height: 24px;
|
|
34
34
|
transition: transform 0.2s ease-in-out;
|
|
35
35
|
}
|
|
36
|
-
.${
|
|
36
|
+
.${L} {
|
|
37
37
|
transform: rotateZ(180deg);
|
|
38
38
|
}
|
|
39
|
-
`}}}),()=>{n.removeType(
|
|
39
|
+
`}}}),()=>{n.removeType(g)}},J="accordionComponent",Q=T.startup;return B(function(e,n={}){const t=[K(e,n),F(e,n),Y(e,n),Z(e),W(e)];V({editor:e,licenseKey:n.licenseKey,plan:Q,pluginName:J,cleanup:()=>{t.forEach(s=>s())}})})});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const T="app.grapesjs.com",
|
|
2
|
-
`)},init(){const{em:o}=this;this.addStyle({[y.name]:"fadeIn",[y.duration]:"1s",[y.fillMode]:"both",...n.animationStyle,...this.getStyle()}),this.listenTo(o,c.mount,p=>{var h;if(p!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==I||f.forEach(u=>this.removeStyle(u))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:o}=this;this.listenTo(o,c.styleUpdate,this.handleStyleChange)},onAnimationStart(){var p;if((p=this.cmpSpots)!=null&&p.length)return;const o=i.getSpots({component:this.model});this.cmpSpots=o,i.removeSpots(o),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const o=this.cmpSpots||[];i.spots.add(o),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(
|
|
1
|
+
"use strict";const T="app.grapesjs.com",P="app-stage.grapesjs.com",G="app2.grapesjs.com",O="app-stage2.grapesjs.com",U=[T,G,P,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],V="license:check:start",B="license:check:end",F=()=>typeof window<"u",X=({isDev:t,isStage:n})=>`${t?"":`https://${n?P:T}`}/api`,M=()=>{const t=F()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(n=>t.endsWith(n)))};async function j({path:t,baseApiUrl:n,method:e="GET",headers:r={},params:i,body:a}){const c=`${n||X({isDev:!1,isStage:!1})}${t}`,l={method:e,headers:{"Content-Type":"application/json",...r}};a&&(l.body=JSON.stringify(a));const f=i?new URLSearchParams(i).toString():"",s=f?`?${f}`:"",o=await fetch(`${c}${s}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var b=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(b||{});const A={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function _(t){const n=t;return n.init=e=>r=>t(r,e),n}const W=t=>_(t);async function Y({editor:t,plan:n,pluginName:e,licenseKey:r,cleanup:i}){let a="",m=!1;const c=M(),l=s=>{console.warn("Cleanup plugin:",e,"Reason:",s),i()},f=(s={})=>{var u;const{error:o,sdkLicense:p}=s,d=(u=s.plan)==null?void 0:u.category;if(!(p||s.license)||o)l(o||"Invalid license");else if(d){const C=A[n],E=A[d];C>E&&l({pluginRequiredPlan:n,licensePlan:d})}};t.on(V,s=>{a=s==null?void 0:s.baseApiUrl,m=!0}),t.on(B,s=>{f(s)}),setTimeout(async()=>{if(!m){if(c)return;if(r){const s=await $({licenseKey:r,pluginName:e,baseApiUrl:a});s&&f(s)}else l("The `licenseKey` option not provided")}},2e3)}async function $(t){const{licenseKey:n,pluginName:e,baseApiUrl:r}=t;try{return(await j({baseApiUrl:r,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const H=(...t)=>n=>t.some(e=>n.is(e));var y=(t=>(t.name="animation-name",t.duration="animation-duration",t.delay="animation-delay",t.iterationCount="animation-iteration-count",t.timingFunction="animation-timing-function",t.fillMode="animation-fill-mode",t))(y||{}),v=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(v||{});const g="animation",I="animation-group",L="animation:update",x="animation-group:update",z={category:{id:"animations",label:"Animations"},select:!0},k=t=>(t==null?void 0:t.getType())===g,w=t=>(t==null?void 0:t.getType())===I,Z=t=>k(t)||w(t),S={isVisible:({component:t})=>k(t)},K={isVisible:({component:t})=>w(t)},q={isVisible:({component:t})=>k(t)&&w(t==null?void 0:t.parent())?!1:Z(t)},D={isVisible:({component:t,sector:n})=>{var e;return k(t)&&w(t==null?void 0:t.parent())?!1:Z(t)&&((e=n.getProperty(v.onScroll))==null?void 0:e.getValue())==="true"}},N={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},J=function(t){const n=this;let e=null;const r=()=>{e==null||e.disconnect(),e=null},i=()=>{r();const a=n.style;a.animationName="",requestAnimationFrame(()=>{const m=getComputedStyle(n),c=m.getPropertyValue("animation-name").trim(),l=m.getPropertyValue("--animation-on-scroll").trim()!=="false",f=parseFloat(m.getPropertyValue("--animation-threshold").trim())||.2,s=m.getPropertyValue("--animation-repeat").trim()==="true",o=()=>{a.animationName="none",n.offsetWidth,a.animationName=c,a.animationPlayState="running"};if(!c||c==="none"){a.animationName="none",a.animationPlayState="paused";return}if(!l){o();return}a.animationPlayState="paused",e=new IntersectionObserver(p=>{p.forEach(d=>{d.isIntersecting&&(o(),!s&&r())})},{threshold:f}),e.observe(n)})};n.addEventListener(t.animationUpdateEvent,i),i()},Q=(t,n)=>{const{Components:e,Blocks:r,Canvas:i}=t,{block:a={},animationList:m=[]}=n,c=t.Components.events,l="Animation",f=Object.values(v),s=Object.values(y);return e.addType(g,{block:a?{label:l,media:N.animation,content:{type:g},...z,...a}:void 0,model:{defaults:{emptyState:!0,name:l,traits:[],script:J,animationUpdateEvent:L,"script-props":["animationUpdateEvent"],styles:m.map(o=>o.css).join(`
|
|
2
|
+
`)},init(){const{em:o}=this;this.addStyle({[y.name]:"fadeIn",[y.duration]:"1s",[y.fillMode]:"both",...n.animationStyle,...this.getStyle()}),this.listenTo(o,c.mount,p=>{var h;if(p!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==I||f.forEach(u=>this.removeStyle(u))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:o}=this;this.listenTo(o,c.styleUpdate,this.handleStyleChange)},onAnimationStart(){var p;if((p=this.cmpSpots)!=null&&p.length)return;const o=i.getSpots({component:this.model});this.cmpSpots=o,i.removeSpots(o),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const o=this.cmpSpots||[];i.spots.add(o),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(L))},handleStyleChange(o,p){Object.keys((p==null?void 0:p.style)||{}).some(u=>s.includes(u)||f.includes(u))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(g),e.removeType(g)}},tt=function(t){const n=this,e="--animation-on-scroll",r="--animation-threshold",i="--animation-repeat";let a=null;const m=()=>{a==null||a.disconnect(),a=null},c=()=>{m();const l=getComputedStyle(n),f=l.getPropertyValue(e).trim()!=="false",s=parseFloat(l.getPropertyValue(r).trim())||.2,o=l.getPropertyValue(i).trim()==="true",p=()=>{Array.from(n.children).forEach(d=>{d instanceof HTMLElement&&typeof d.dispatchEvent=="function"&&d.dispatchEvent(new CustomEvent(x,{bubbles:!1}))})};if(!f){p();return}a=new IntersectionObserver(d=>{d.forEach(h=>{h.isIntersecting?(p(),!o&&m()):o&&Array.from(n.children).forEach(u=>{u instanceof HTMLElement&&getComputedStyle(u).getPropertyValue(e).trim()!=="false"&&(u.style.opacity="0",u.style.animationPlayState="paused")})})},{threshold:s}),a.observe(n)};n.addEventListener(t.animationGroupUpdateEvent,c),c()},nt=(t,n)=>{const{Components:e,Blocks:r}=t,{blockGroup:i={}}=n,a="Animation Group";return e.addType(I,{block:i?{label:a,media:N.animationGroup,content:{type:I,components:[{type:g},{type:g},{type:g}]},...z,...i}:void 0,model:{defaults:{name:a,emptyState:!0,traits:[],script:tt,animationGroupUpdateEvent:x,"script-props":["animationGroupUpdateEvent"],droppable:H(g)},init(){this.addStyle({...n.animationGroupStyle,...this.getStyle()});const m=this.components();this.listenTo(m,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((m,c)=>{m.is(g)&&m.addStyle({"--stagger-index":c.toString(),[y.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:m}=this;this.listenTo(m,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(x))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(I),e.removeType(I)}},et="animationComponent",at=b.startup,R=[{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
3
3
|
0%, 50%, to {
|
|
4
4
|
opacity:1
|
|
5
5
|
}
|
|
@@ -516,4 +516,4 @@
|
|
|
516
516
|
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
517
517
|
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
518
518
|
}
|
|
519
|
-
}`}],
|
|
519
|
+
}`}],ot=function(t,n={}){var i;const e=((i=n.animations)==null?void 0:i.call(n,{items:R}))||R,r=[Q(t,{...n,animationList:e}),nt(t,n)];t.Styles.addSector("animation",{name:"Animation",properties:[{...S,name:"Type",property:y.name,type:"select",full:!0,default:"fadeIn",options:e},{...S,name:"Duration",property:y.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...S,name:"Delay",property:y.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...S,name:"Iteration Count",property:y.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...S,name:"Timing",property:y.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...K,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...q,name:"Animate on Scroll",property:v.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...D,name:"Scroll Threshold",property:v.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...D,name:"Repeat on Scroll",property:v.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),Y({editor:t,licenseKey:n.licenseKey,plan:at,pluginName:et,cleanup:()=>{r.forEach(a=>a())}})},it=W(ot);module.exports=it;
|