@grapesjs/studio-sdk-plugins 1.0.23 → 1.0.24
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/animationComponent/index.es.js +0 -4
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +156 -136
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasFullSize/utils.d.ts +8 -0
- package/dist/dataSourceEjs/EjsExporter.d.ts +11 -4
- package/dist/dataSourceEjs/index.cjs.js +10 -20
- package/dist/dataSourceEjs/index.es.js +179 -302
- package/dist/dataSourceEjs/index.umd.js +10 -20
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +11 -4
- package/dist/dataSourceHandlebars/index.cjs.js +6 -16
- package/dist/dataSourceHandlebars/index.es.js +141 -263
- package/dist/dataSourceHandlebars/index.umd.js +6 -16
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +1 -1
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/index.cjs.js +50 -60
- package/dist/index.es.js +2263 -2370
- package/dist/index.umd.js +57 -67
- package/dist/rendererReact/types.d.ts +1 -2
- package/dist/utilsDataSources.d.ts +4 -24
- package/package.json +2 -2
|
@@ -103,16 +103,12 @@ const y = "animation", v = "animation-group", E = "animation:update", k = "anima
|
|
|
103
103
|
category: { id: "animations", label: "Animations" },
|
|
104
104
|
select: !0
|
|
105
105
|
}, w = (t) => (t == null ? void 0 : t.type) === y, x = (t) => (t == null ? void 0 : t.type) === v, N = (t) => w(t) || x(t), _ = {
|
|
106
|
-
// @ts-expect-error available from the next release
|
|
107
106
|
isVisible: ({ component: t }) => N(t)
|
|
108
107
|
}, S = {
|
|
109
|
-
// @ts-expect-error available from the next release
|
|
110
108
|
isVisible: ({ component: t }) => w(t)
|
|
111
109
|
}, K = {
|
|
112
|
-
// @ts-expect-error available from the next release
|
|
113
110
|
isVisible: ({ component: t }) => x(t)
|
|
114
111
|
}, D = {
|
|
115
|
-
// @ts-expect-error available from the next release
|
|
116
112
|
isVisible: ({ component: t, sector: n }) => {
|
|
117
113
|
var e;
|
|
118
114
|
return w(t) && x(t == null ? void 0 : t.parent()) ? !1 : N(t) && ((e = n.getProperty(d.onScroll)) == null ? void 0 : e.getValue()) === "true";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";function
|
|
2
|
-
.gjs-frame-wrapper { transition: width ${
|
|
3
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
4
|
-
.gjs-frame { border-radius: ${
|
|
5
|
-
`,!
|
|
6
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
7
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
8
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
9
|
-
`,!
|
|
1
|
+
"use strict";function B(e,a,s){let n,i,c,r,m;const l=a;function u(){const p=Date.now()-r;p<l&&p>=0?n=setTimeout(u,l-p):(n=null,m=e.apply(c,i),c=i=null)}const o=function(){return c=this,i=arguments,r=Date.now(),n||(n=setTimeout(u,l)),m};return o.clear=function(){n&&(clearTimeout(n),n=null)},o.flush=function(){n&&(m=e.apply(c,i),c=i=null,clearTimeout(n),n=null)},o}const O="app.grapesjs.com",R="app-stage.grapesjs.com",U=[O,R,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],G="license:check:start",X="license:check:end",Y=()=>typeof window<"u",Z=({isDev:e,isStage:a})=>`${e?"":`https://${a?R:O}`}/api`,J=()=>{const e=Y()&&window.location.hostname;return!!e&&(U.includes(e)||U.some(a=>e.endsWith(a)))};async function Q({path:e,baseApiUrl:a,method:s="GET",headers:n={},params:i,body:c}){const m=`${a||Z({isDev:!1,isStage:!1})}${e}`,l={method:s,headers:{"Content-Type":"application/json",...n}};c&&(l.body=JSON.stringify(c));const u=i?new URLSearchParams(i).toString():"",o=u?`?${u}`:"",p=await fetch(`${m}${o}`,l);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{});const W={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function ee(e){const a=e;return a.init=s=>n=>e(n,s),a}const te=e=>ee(e);async function ne({editor:e,plan:a,pluginName:s,licenseKey:n,cleanup:i}){let c="",r=!1;const m=J(),l=o=>{console.warn("Cleanup plugin:",s,"Reason:",o),i()},u=(o={})=>{var y;const{error:p,sdkLicense:D}=o,v=(y=o.plan)==null?void 0:y.category;if(!(D||o.license)||p)l(p||"Invalid license");else if(v){const S=W[a],L=W[v];S>L&&l({pluginRequiredPlan:a,licensePlan:v})}};e.on(G,o=>{c=o==null?void 0:o.baseApiUrl,r=!0}),e.on(X,o=>{u(o)}),setTimeout(async()=>{if(!r){if(m)return;if(n){const o=await se({licenseKey:n,pluginName:s,baseApiUrl:c});o&&u(o)}else l("The `licenseKey` option not provided")}},2e3)}async function se(e){const{licenseKey:a,pluginName:s,baseApiUrl:n}=e;try{return(await Q({baseApiUrl:n,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const k="canvasFullSize",oe=g.startup,ie=(e,a)=>{var c;const{rule:s,ruleView:n}=a,{style:i}=s.attributes;if(i&&i[e]){const r=i[e],m=(c=r==null?void 0:r.endsWith)==null?void 0:c.call(r,"vh"),l=n.frameView.model;if(m&&l.hasAutoHeight()){const u=parseFloat(r),o=s.toCSS({style:{...i,[e]:`${window.outerHeight*(u/100)}px`}});a.css=o}}},ae=e=>{["height","min-height","max-height"].forEach(a=>ie(a,e))},ce=function(e,a={}){const{Canvas:s,Commands:n,Devices:i,Css:c}=e,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...a},{canvasOffsetY:m,canvasOffsetX:l,canvasTransition:u,deviceMaxWidth:o,deviceMinHeigth:p,frameBorderRadius:D,frameTransition:v}=r,w=`${p}px`,y=s.events,S="core:preview",L=`${n.events.stopCommand}${S}`,A=s.getConfig(),M=`${k}:disable`,_=i.getAll().map(t=>({...t.attributes})),z=u*1e3,N={x:l,y:m};let b={},H,C;A.scrollableCanvas=!0,i.getAll().map(t=>{!t.get("width")&&t.set("width",`${o}px`),!t.get("height")&&t.set("height","auto"),!t.get("minHeight")&&t.set("minHeight",w)});const x=t=>{const d="data-gs-plg-full-size",f=document.querySelector(`style[${d}]`);if(t&&f)return f.remove();const h=f||document.createElement("style"),$=s.getZoomMultiplier();h.setAttribute(d,"true"),h.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${v}s !important; }
|
|
3
|
+
.gjs-frame-wrapper__bottom { height: ${m*$}px }
|
|
4
|
+
.gjs-frame { border-radius: ${D}px }
|
|
5
|
+
`,!f&&document.body.appendChild(h)};e.on(y.frameLoadHead,t=>{if(!A.scrollableCanvas)return;const{window:d}=t,f=d.document,h=f.head,$="data-gs-plg-wrapper-style",T=h.querySelector(`style[${$}]`)||f.createElement("style");T.setAttribute($,"true"),T.innerHTML=`
|
|
6
|
+
[data-gjs-type="wrapper"] { min-height: ${w}; }
|
|
7
|
+
[data-gjs-type="mjml"] { min-height: ${w} !important; }
|
|
8
|
+
[data-gjs-type="mj-body"] { min-height: ${w} !important; }
|
|
9
|
+
`,!h.contains(T)&&h.appendChild(T)});const j=()=>H.style.display="none",F=()=>H.style.display="",E=B(()=>{s.fitViewport({zoom:t=>t>100?100:t,ignoreHeight:!0,gap:N}),x(),setTimeout(()=>{var d,f;const{em:t}=e;t.destroyed||((f=(d=e.getSelected())==null?void 0:d.getEl())==null||f.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),F(),n.isActive(S)?t.stopDefault():t.runDefault())},z)},100),K=(t={})=>{t.options&&t.options.from!=="fitViewport"&&s.fitViewport({zoom:s.getZoom(),ignoreHeight:!0,gap:N})},V=()=>{j(),E()},q=()=>{b.overflowX="hidden",b.overflowY="auto"},I=()=>{C==null||C.disconnect(),E.clear()},P=[[i.events.select,V],[y.zoom,K],[L,q],[e.events.destroy,I],[c.events.mountBefore,ae]];n.add(M,()=>{i.devices.reset(_),A.scrollableCanvas=!1,s.getModel().updateDevice(),s.setZoom(100),s.setCoords(0,0),b.overflowY="hidden",x(!0),P.forEach(([t,d])=>e.off(t,d)),I(),n.run("studio:canvasReload")}),P.forEach(([t,d])=>e.on(t,d)),e.onReady(()=>{const t=s.getElement(),d=s.getFramesEl();H=s.getSpotsEl(),b=t.style,b.overflowX="hidden",d.style.transition=`transform ${u}s`,x(),C=new ResizeObserver(()=>{j(),E()}),C.observe(t.parentElement),E()}),ne({editor:e,licenseKey:r.licenseKey,plan:oe,pluginName:k,cleanup:()=>{e.runCommand(M)}})},re=te(ce);module.exports=re;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
function
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
function B(e, a, s) {
|
|
2
|
+
let n, i, c, r, m;
|
|
3
|
+
const l = a;
|
|
4
4
|
function u() {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const p = Date.now() - r;
|
|
6
|
+
p < l && p >= 0 ? n = setTimeout(u, l - p) : (n = null, m = e.apply(c, i), c = i = null);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
return c = this,
|
|
8
|
+
const o = function() {
|
|
9
|
+
return c = this, i = arguments, r = Date.now(), n || (n = setTimeout(u, l)), m;
|
|
10
10
|
};
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
11
|
+
return o.clear = function() {
|
|
12
|
+
n && (clearTimeout(n), n = null);
|
|
13
|
+
}, o.flush = function() {
|
|
14
|
+
n && (m = e.apply(c, i), c = i = null, clearTimeout(n), n = null);
|
|
15
|
+
}, o;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const O = "app.grapesjs.com", R = "app-stage.grapesjs.com", U = [
|
|
18
|
+
O,
|
|
19
19
|
R,
|
|
20
20
|
"localhost",
|
|
21
21
|
"127.0.0.1",
|
|
@@ -25,96 +25,113 @@ const z = "app.grapesjs.com", R = "app-stage.grapesjs.com", U = [
|
|
|
25
25
|
// For stackblitz.com demos
|
|
26
26
|
"-sandpack.codesandbox.io"
|
|
27
27
|
// For Sandpack demos
|
|
28
|
-
],
|
|
29
|
-
const e =
|
|
28
|
+
], G = "license:check:start", X = "license:check:end", Y = () => typeof window < "u", Z = ({ isDev: e, isStage: a }) => `${e ? "" : `https://${a ? R : O}`}/api`, J = () => {
|
|
29
|
+
const e = Y() && window.location.hostname;
|
|
30
30
|
return !!e && (U.includes(e) || U.some((a) => e.endsWith(a)));
|
|
31
31
|
};
|
|
32
|
-
async function
|
|
32
|
+
async function Q({
|
|
33
33
|
path: e,
|
|
34
34
|
baseApiUrl: a,
|
|
35
|
-
method:
|
|
36
|
-
headers:
|
|
37
|
-
params:
|
|
35
|
+
method: s = "GET",
|
|
36
|
+
headers: n = {},
|
|
37
|
+
params: i,
|
|
38
38
|
body: c
|
|
39
39
|
}) {
|
|
40
|
-
const m = `${a ||
|
|
41
|
-
method:
|
|
40
|
+
const m = `${a || Z({ isDev: !1, isStage: !1 })}${e}`, l = {
|
|
41
|
+
method: s,
|
|
42
42
|
headers: {
|
|
43
43
|
"Content-Type": "application/json",
|
|
44
|
-
...
|
|
44
|
+
...n
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
c && (
|
|
48
|
-
const u =
|
|
49
|
-
if (!
|
|
50
|
-
throw new Error(`HTTP error! status: ${
|
|
51
|
-
return
|
|
47
|
+
c && (l.body = JSON.stringify(c));
|
|
48
|
+
const u = i ? new URLSearchParams(i).toString() : "", o = u ? `?${u}` : "", p = await fetch(`${m}${o}`, l);
|
|
49
|
+
if (!p.ok)
|
|
50
|
+
throw new Error(`HTTP error! status: ${p.status}`);
|
|
51
|
+
return p.json();
|
|
52
52
|
}
|
|
53
|
-
var
|
|
53
|
+
var g = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(g || {});
|
|
54
54
|
const W = {
|
|
55
|
-
[
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
55
|
+
[g.free]: 0,
|
|
56
|
+
[g.startup]: 10,
|
|
57
|
+
[g.business]: 20,
|
|
58
|
+
[g.enterprise]: 30
|
|
59
59
|
};
|
|
60
|
-
function
|
|
60
|
+
function ee(e) {
|
|
61
61
|
const a = e;
|
|
62
|
-
return a.init = (
|
|
62
|
+
return a.init = (s) => (n) => e(n, s), a;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
async function
|
|
64
|
+
const te = (e) => /* @__PURE__ */ ee(e);
|
|
65
|
+
async function ne({
|
|
66
66
|
editor: e,
|
|
67
67
|
plan: a,
|
|
68
|
-
pluginName:
|
|
69
|
-
licenseKey:
|
|
70
|
-
cleanup:
|
|
68
|
+
pluginName: s,
|
|
69
|
+
licenseKey: n,
|
|
70
|
+
cleanup: i
|
|
71
71
|
}) {
|
|
72
|
-
let c = "",
|
|
73
|
-
const m =
|
|
74
|
-
console.warn("Cleanup plugin:",
|
|
75
|
-
}, u = (
|
|
76
|
-
var
|
|
77
|
-
const { error:
|
|
78
|
-
if (!(D ||
|
|
79
|
-
|
|
72
|
+
let c = "", r = !1;
|
|
73
|
+
const m = J(), l = (o) => {
|
|
74
|
+
console.warn("Cleanup plugin:", s, "Reason:", o), i();
|
|
75
|
+
}, u = (o = {}) => {
|
|
76
|
+
var y;
|
|
77
|
+
const { error: p, sdkLicense: D } = o, v = (y = o.plan) == null ? void 0 : y.category;
|
|
78
|
+
if (!(D || o.license) || p)
|
|
79
|
+
l(p || "Invalid license");
|
|
80
80
|
else if (v) {
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const S = W[a], L = W[v];
|
|
82
|
+
S > L && l({ pluginRequiredPlan: a, licensePlan: v });
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
e.on(
|
|
86
|
-
c =
|
|
87
|
-
}), e.on(
|
|
88
|
-
u(
|
|
85
|
+
e.on(G, (o) => {
|
|
86
|
+
c = o == null ? void 0 : o.baseApiUrl, r = !0;
|
|
87
|
+
}), e.on(X, (o) => {
|
|
88
|
+
u(o);
|
|
89
89
|
}), setTimeout(async () => {
|
|
90
|
-
if (!
|
|
90
|
+
if (!r) {
|
|
91
91
|
if (m) return;
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
92
|
+
if (n) {
|
|
93
|
+
const o = await se({ licenseKey: n, pluginName: s, baseApiUrl: c });
|
|
94
|
+
o && u(o);
|
|
95
95
|
} else
|
|
96
|
-
|
|
96
|
+
l("The `licenseKey` option not provided");
|
|
97
97
|
}
|
|
98
98
|
}, 2e3);
|
|
99
99
|
}
|
|
100
|
-
async function
|
|
101
|
-
const { licenseKey: a, pluginName:
|
|
100
|
+
async function se(e) {
|
|
101
|
+
const { licenseKey: a, pluginName: s, baseApiUrl: n } = e;
|
|
102
102
|
try {
|
|
103
|
-
return (await
|
|
104
|
-
baseApiUrl:
|
|
103
|
+
return (await Q({
|
|
104
|
+
baseApiUrl: n,
|
|
105
105
|
path: `/sdk/${a || "na"}`,
|
|
106
106
|
method: "POST",
|
|
107
107
|
params: {
|
|
108
108
|
d: window.location.hostname,
|
|
109
|
-
pn:
|
|
109
|
+
pn: s
|
|
110
110
|
}
|
|
111
111
|
})).result || {};
|
|
112
|
-
} catch (
|
|
113
|
-
return console.error("Error during SDK license check:",
|
|
112
|
+
} catch (i) {
|
|
113
|
+
return console.error("Error during SDK license check:", i), !1;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
const k = "canvasFullSize",
|
|
117
|
-
|
|
116
|
+
const k = "canvasFullSize", oe = g.startup, ie = (e, a) => {
|
|
117
|
+
var c;
|
|
118
|
+
const { rule: s, ruleView: n } = a, { style: i } = s.attributes;
|
|
119
|
+
if (i && i[e]) {
|
|
120
|
+
const r = i[e], m = (c = r == null ? void 0 : r.endsWith) == null ? void 0 : c.call(r, "vh"), l = n.frameView.model;
|
|
121
|
+
if (m && l.hasAutoHeight()) {
|
|
122
|
+
const u = parseFloat(r), o = s.toCSS({
|
|
123
|
+
style: {
|
|
124
|
+
...i,
|
|
125
|
+
[e]: `${window.outerHeight * (u / 100)}px`
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
a.css = o;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}, ae = (e) => {
|
|
132
|
+
["height", "min-height", "max-height"].forEach((a) => ie(a, e));
|
|
133
|
+
}, ce = function(e, a = {}) {
|
|
134
|
+
const { Canvas: s, Commands: n, Devices: i, Css: c } = e, r = {
|
|
118
135
|
deviceMaxWidth: 1200,
|
|
119
136
|
deviceMinHeigth: 500,
|
|
120
137
|
canvasOffsetY: 30,
|
|
@@ -124,81 +141,84 @@ const k = "canvasFullSize", te = b.startup, ne = function(e, a = {}) {
|
|
|
124
141
|
frameTransition: 0.3,
|
|
125
142
|
...a
|
|
126
143
|
}, {
|
|
127
|
-
canvasOffsetY:
|
|
128
|
-
canvasOffsetX:
|
|
129
|
-
canvasTransition:
|
|
130
|
-
deviceMaxWidth:
|
|
131
|
-
deviceMinHeigth:
|
|
132
|
-
frameBorderRadius:
|
|
133
|
-
frameTransition:
|
|
134
|
-
} =
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
canvasOffsetY: m,
|
|
145
|
+
canvasOffsetX: l,
|
|
146
|
+
canvasTransition: u,
|
|
147
|
+
deviceMaxWidth: o,
|
|
148
|
+
deviceMinHeigth: p,
|
|
149
|
+
frameBorderRadius: D,
|
|
150
|
+
frameTransition: v
|
|
151
|
+
} = r, w = `${p}px`, y = s.events, S = "core:preview", L = `${n.events.stopCommand}${S}`, A = s.getConfig(), M = `${k}:disable`, _ = i.getAll().map((t) => ({ ...t.attributes })), z = u * 1e3, N = { x: l, y: m };
|
|
152
|
+
let b = {}, H, C;
|
|
153
|
+
A.scrollableCanvas = !0, i.getAll().map((t) => {
|
|
154
|
+
!t.get("width") && t.set("width", `${o}px`), !t.get("height") && t.set("height", "auto"), !t.get("minHeight") && t.set("minHeight", w);
|
|
137
155
|
});
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
return
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
.gjs-frame-wrapper { transition: width ${
|
|
145
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
146
|
-
.gjs-frame { border-radius: ${
|
|
147
|
-
`, !
|
|
156
|
+
const x = (t) => {
|
|
157
|
+
const d = "data-gs-plg-full-size", f = document.querySelector(`style[${d}]`);
|
|
158
|
+
if (t && f)
|
|
159
|
+
return f.remove();
|
|
160
|
+
const h = f || document.createElement("style"), $ = s.getZoomMultiplier();
|
|
161
|
+
h.setAttribute(d, "true"), h.innerHTML = `
|
|
162
|
+
.gjs-frame-wrapper { transition: width ${v}s !important; }
|
|
163
|
+
.gjs-frame-wrapper__bottom { height: ${m * $}px }
|
|
164
|
+
.gjs-frame { border-radius: ${D}px }
|
|
165
|
+
`, !f && document.body.appendChild(h);
|
|
148
166
|
};
|
|
149
|
-
e.on(
|
|
150
|
-
if (!
|
|
151
|
-
const { window:
|
|
152
|
-
|
|
153
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
154
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
155
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
156
|
-
`, !
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
H(), T();
|
|
174
|
-
});
|
|
175
|
-
j.observe(w.parentElement);
|
|
176
|
-
const I = () => {
|
|
177
|
-
H(), T();
|
|
178
|
-
}, M = (g = {}) => {
|
|
179
|
-
g.options && g.options.from !== "fitViewport" && n.fitViewport({
|
|
180
|
-
zoom: n.getZoom(),
|
|
181
|
-
ignoreHeight: !0,
|
|
182
|
-
gap: y
|
|
183
|
-
});
|
|
184
|
-
}, N = () => {
|
|
185
|
-
h.overflowX = "hidden", h.overflowY = "auto";
|
|
186
|
-
}, O = () => {
|
|
187
|
-
j.disconnect(), T.clear();
|
|
188
|
-
};
|
|
189
|
-
e.on(o.events.select, I), e.on($.zoom, M), e.on(E, N), e.on(e.events.destroy, O), T(), t.add(A, () => {
|
|
190
|
-
o.devices.reset(_), S.scrollableCanvas = !1, n.getModel().updateDevice(), n.setZoom(100), n.setCoords(0, 0), h.overflowY = "hidden", L(!0), e.off(o.events.select, I), e.off($.zoom, M), e.off(E, N), O(), t.run("studio:canvasReload");
|
|
167
|
+
e.on(y.frameLoadHead, (t) => {
|
|
168
|
+
if (!A.scrollableCanvas) return;
|
|
169
|
+
const { window: d } = t, f = d.document, h = f.head, $ = "data-gs-plg-wrapper-style", T = h.querySelector(`style[${$}]`) || f.createElement("style");
|
|
170
|
+
T.setAttribute($, "true"), T.innerHTML = `
|
|
171
|
+
[data-gjs-type="wrapper"] { min-height: ${w}; }
|
|
172
|
+
[data-gjs-type="mjml"] { min-height: ${w} !important; }
|
|
173
|
+
[data-gjs-type="mj-body"] { min-height: ${w} !important; }
|
|
174
|
+
`, !h.contains(T) && h.appendChild(T);
|
|
175
|
+
});
|
|
176
|
+
const j = () => H.style.display = "none", F = () => H.style.display = "", E = B(() => {
|
|
177
|
+
s.fitViewport({
|
|
178
|
+
zoom: (t) => t > 100 ? 100 : t,
|
|
179
|
+
ignoreHeight: !0,
|
|
180
|
+
gap: N
|
|
181
|
+
}), x(), setTimeout(() => {
|
|
182
|
+
var d, f;
|
|
183
|
+
const { em: t } = e;
|
|
184
|
+
t.destroyed || ((f = (d = e.getSelected()) == null ? void 0 : d.getEl()) == null || f.scrollIntoView({ block: "nearest" }), e.refresh({ tools: !0 }), F(), n.isActive(S) ? t.stopDefault() : t.runDefault());
|
|
185
|
+
}, z);
|
|
186
|
+
}, 100), K = (t = {}) => {
|
|
187
|
+
t.options && t.options.from !== "fitViewport" && s.fitViewport({
|
|
188
|
+
zoom: s.getZoom(),
|
|
189
|
+
ignoreHeight: !0,
|
|
190
|
+
gap: N
|
|
191
191
|
});
|
|
192
|
-
}
|
|
192
|
+
}, V = () => {
|
|
193
|
+
j(), E();
|
|
194
|
+
}, q = () => {
|
|
195
|
+
b.overflowX = "hidden", b.overflowY = "auto";
|
|
196
|
+
}, I = () => {
|
|
197
|
+
C == null || C.disconnect(), E.clear();
|
|
198
|
+
}, P = [
|
|
199
|
+
[i.events.select, V],
|
|
200
|
+
[y.zoom, K],
|
|
201
|
+
[L, q],
|
|
202
|
+
[e.events.destroy, I],
|
|
203
|
+
[c.events.mountBefore, ae]
|
|
204
|
+
];
|
|
205
|
+
n.add(M, () => {
|
|
206
|
+
i.devices.reset(_), A.scrollableCanvas = !1, s.getModel().updateDevice(), s.setZoom(100), s.setCoords(0, 0), b.overflowY = "hidden", x(!0), P.forEach(([t, d]) => e.off(t, d)), I(), n.run("studio:canvasReload");
|
|
207
|
+
}), P.forEach(([t, d]) => e.on(t, d)), e.onReady(() => {
|
|
208
|
+
const t = s.getElement(), d = s.getFramesEl();
|
|
209
|
+
H = s.getSpotsEl(), b = t.style, b.overflowX = "hidden", d.style.transition = `transform ${u}s`, x(), C = new ResizeObserver(() => {
|
|
210
|
+
j(), E();
|
|
211
|
+
}), C.observe(t.parentElement), E();
|
|
212
|
+
}), ne({
|
|
193
213
|
editor: e,
|
|
194
|
-
licenseKey:
|
|
195
|
-
plan:
|
|
214
|
+
licenseKey: r.licenseKey,
|
|
215
|
+
plan: oe,
|
|
196
216
|
pluginName: k,
|
|
197
217
|
cleanup: () => {
|
|
198
|
-
e.runCommand(
|
|
218
|
+
e.runCommand(M);
|
|
199
219
|
}
|
|
200
220
|
});
|
|
201
|
-
},
|
|
221
|
+
}, re = te(ce);
|
|
202
222
|
export {
|
|
203
|
-
|
|
223
|
+
re as default
|
|
204
224
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
.gjs-frame-wrapper { transition: width ${
|
|
3
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
4
|
-
.gjs-frame { border-radius: ${
|
|
5
|
-
`,!
|
|
6
|
-
[data-gjs-type="wrapper"] { min-height: ${
|
|
7
|
-
[data-gjs-type="mjml"] { min-height: ${
|
|
8
|
-
[data-gjs-type="mj-body"] { min-height: ${
|
|
9
|
-
`,!
|
|
1
|
+
(function(w,g){typeof exports=="object"&&typeof module<"u"?module.exports=g():typeof define=="function"&&define.amd?define(g):(w=typeof globalThis<"u"?globalThis:w||self,w.StudioSdkPlugins_canvasFullSize=g())})(this,function(){"use strict";function w(e,a,s){let n,i,c,r,f;const l=a;function u(){const m=Date.now()-r;m<l&&m>=0?n=setTimeout(u,l-m):(n=null,f=e.apply(c,i),c=i=null)}const o=function(){return c=this,i=arguments,r=Date.now(),n||(n=setTimeout(u,l)),f};return o.clear=function(){n&&(clearTimeout(n),n=null)},o.flush=function(){n&&(f=e.apply(c,i),c=i=null,clearTimeout(n),n=null)},o}const g="app.grapesjs.com",N="app-stage.grapesjs.com",P=[g,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],z="license:check:start",F="license:check:end",K=()=>typeof window<"u",V=({isDev:e,isStage:a})=>`${e?"":`https://${a?N:g}`}/api`,q=()=>{const e=K()&&window.location.hostname;return!!e&&(P.includes(e)||P.some(a=>e.endsWith(a)))};async function B({path:e,baseApiUrl:a,method:s="GET",headers:n={},params:i,body:c}){const f=`${a||V({isDev:!1,isStage:!1})}${e}`,l={method:s,headers:{"Content-Type":"application/json",...n}};c&&(l.body=JSON.stringify(c));const u=i?new URLSearchParams(i).toString():"",o=u?`?${u}`:"",m=await fetch(`${f}${o}`,l);if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);return m.json()}var v=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(v||{});const I={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function G(e){const a=e;return a.init=s=>n=>e(n,s),a}const X=e=>G(e);async function Y({editor:e,plan:a,pluginName:s,licenseKey:n,cleanup:i}){let c="",r=!1;const f=q(),l=o=>{console.warn("Cleanup plugin:",s,"Reason:",o),i()},u=(o={})=>{var S;const{error:m,sdkLicense:A}=o,y=(S=o.plan)==null?void 0:S.category;if(!(A||o.license)||m)l(m||"Invalid license");else if(y){const T=I[a],H=I[y];T>H&&l({pluginRequiredPlan:a,licensePlan:y})}};e.on(z,o=>{c=o==null?void 0:o.baseApiUrl,r=!0}),e.on(F,o=>{u(o)}),setTimeout(async()=>{if(!r){if(f)return;if(n){const o=await Z({licenseKey:n,pluginName:s,baseApiUrl:c});o&&u(o)}else l("The `licenseKey` option not provided")}},2e3)}async function Z(e){const{licenseKey:a,pluginName:s,baseApiUrl:n}=e;try{return(await B({baseApiUrl:n,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const U="canvasFullSize",J=v.startup,Q=(e,a)=>{var c;const{rule:s,ruleView:n}=a,{style:i}=s.attributes;if(i&&i[e]){const r=i[e],f=(c=r==null?void 0:r.endsWith)==null?void 0:c.call(r,"vh"),l=n.frameView.model;if(f&&l.hasAutoHeight()){const u=parseFloat(r),o=s.toCSS({style:{...i,[e]:`${window.outerHeight*(u/100)}px`}});a.css=o}}},ee=e=>{["height","min-height","max-height"].forEach(a=>Q(a,e))};return X(function(e,a={}){const{Canvas:s,Commands:n,Devices:i,Css:c}=e,r={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...a},{canvasOffsetY:f,canvasOffsetX:l,canvasTransition:u,deviceMaxWidth:o,deviceMinHeigth:m,frameBorderRadius:A,frameTransition:y}=r,b=`${m}px`,S=s.events,T="core:preview",H=`${n.events.stopCommand}${T}`,x=s.getConfig(),W=`${U}:disable`,te=i.getAll().map(t=>({...t.attributes})),ne=u*1e3,k={x:l,y:f};let C={},j,E;x.scrollableCanvas=!0,i.getAll().map(t=>{!t.get("width")&&t.set("width",`${o}px`),!t.get("height")&&t.set("height","auto"),!t.get("minHeight")&&t.set("minHeight",b)});const M=t=>{const d="data-gs-plg-full-size",p=document.querySelector(`style[${d}]`);if(t&&p)return p.remove();const h=p||document.createElement("style"),D=s.getZoomMultiplier();h.setAttribute(d,"true"),h.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${y}s !important; }
|
|
3
|
+
.gjs-frame-wrapper__bottom { height: ${f*D}px }
|
|
4
|
+
.gjs-frame { border-radius: ${A}px }
|
|
5
|
+
`,!p&&document.body.appendChild(h)};e.on(S.frameLoadHead,t=>{if(!x.scrollableCanvas)return;const{window:d}=t,p=d.document,h=p.head,D="data-gs-plg-wrapper-style",L=h.querySelector(`style[${D}]`)||p.createElement("style");L.setAttribute(D,"true"),L.innerHTML=`
|
|
6
|
+
[data-gjs-type="wrapper"] { min-height: ${b}; }
|
|
7
|
+
[data-gjs-type="mjml"] { min-height: ${b} !important; }
|
|
8
|
+
[data-gjs-type="mj-body"] { min-height: ${b} !important; }
|
|
9
|
+
`,!h.contains(L)&&h.appendChild(L)});const _=()=>j.style.display="none",se=()=>j.style.display="",$=w(()=>{s.fitViewport({zoom:t=>t>100?100:t,ignoreHeight:!0,gap:k}),M(),setTimeout(()=>{var d,p;const{em:t}=e;t.destroyed||((p=(d=e.getSelected())==null?void 0:d.getEl())==null||p.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),se(),n.isActive(T)?t.stopDefault():t.runDefault())},ne)},100),oe=(t={})=>{t.options&&t.options.from!=="fitViewport"&&s.fitViewport({zoom:s.getZoom(),ignoreHeight:!0,gap:k})},ie=()=>{_(),$()},ae=()=>{C.overflowX="hidden",C.overflowY="auto"},O=()=>{E==null||E.disconnect(),$.clear()},R=[[i.events.select,ie],[S.zoom,oe],[H,ae],[e.events.destroy,O],[c.events.mountBefore,ee]];n.add(W,()=>{i.devices.reset(te),x.scrollableCanvas=!1,s.getModel().updateDevice(),s.setZoom(100),s.setCoords(0,0),C.overflowY="hidden",M(!0),R.forEach(([t,d])=>e.off(t,d)),O(),n.run("studio:canvasReload")}),R.forEach(([t,d])=>e.on(t,d)),e.onReady(()=>{const t=s.getElement(),d=s.getFramesEl();j=s.getSpotsEl(),C=t.style,C.overflowX="hidden",d.style.transition=`transform ${u}s`,M(),E=new ResizeObserver(()=>{_(),$()}),E.observe(t.parentElement),$()}),Y({editor:e,licenseKey:r.licenseKey,plan:J,pluginName:U,cleanup:()=>{e.runCommand(W)}})})});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CssRule } from 'grapesjs';
|
|
2
|
+
export interface OnCssMountProps {
|
|
3
|
+
rule: CssRule;
|
|
4
|
+
ruleView: CssRule['views'][0];
|
|
5
|
+
css: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const updateVhHeight: (prop: string, props: OnCssMountProps) => void;
|
|
8
|
+
export declare const onCssMount: (props: OnCssMountProps) => void;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataCollectionResolverProps, DataVariableResolverProps, IDataSourceExporter } from '@studio/editor/src/typeConfigs/dataSources';
|
|
2
|
+
import { DataConditionResolverProps } from '@studio/editor/src/components/public/StudioDataConditionPicker';
|
|
2
3
|
export declare class EjsExporter implements IDataSourceExporter {
|
|
3
|
-
getVariableSyntax(
|
|
4
|
-
|
|
4
|
+
getVariableSyntax({ dataResolver }: {
|
|
5
|
+
dataResolver: DataVariableResolverProps;
|
|
6
|
+
}): string;
|
|
7
|
+
getCollectionStartSyntax({ dataResolver }: {
|
|
8
|
+
dataResolver: DataCollectionResolverProps;
|
|
9
|
+
}): string;
|
|
5
10
|
private _sanitizeVariableName;
|
|
6
11
|
getCollectionEndSyntax(): string;
|
|
7
|
-
getConditionalStartSyntax(
|
|
12
|
+
getConditionalStartSyntax({ dataResolver }: {
|
|
13
|
+
dataResolver: DataConditionResolverProps;
|
|
14
|
+
}): string;
|
|
8
15
|
getConditionElseSyntax(): string;
|
|
9
16
|
getConditionalEndSyntax(): string;
|
|
10
17
|
private getFullPath;
|