@grapesjs/studio-sdk-plugins 1.0.16 → 1.0.17
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/canvasFullSize/index.cjs.js +6 -2
- package/dist/canvasFullSize/index.es.js +66 -61
- package/dist/canvasFullSize/index.umd.js +7 -3
- package/dist/canvasFullSize/typesSchema.d.ts +7 -0
- package/dist/index.cjs.js +37 -33
- package/dist/index.es.js +2537 -2528
- package/dist/index.umd.js +36 -32
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +176 -172
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +13 -7
- package/dist/layoutSidebarButtons/typesSchema.d.ts +8 -8
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function F(e,a,n){let t,o,c,p,m;const r=a;function u(){const l=Date.now()-p;l<r&&l>=0?t=setTimeout(u,r-l):(t=null,m=e.apply(c,o),c=o=null)}const s=function(){return c=this,o=arguments,p=Date.now(),t||(t=setTimeout(u,r)),m};return s.clear=function(){t&&(clearTimeout(t),t=null)},s.flush=function(){t&&(m=e.apply(c,o),c=o=null,clearTimeout(t),t=null)},s}const R="app.grapesjs.com",U="app-stage.grapesjs.com",z=[R,U,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],q="license:check:start",V="license:check:end",X=()=>typeof window<"u",Y=({isDev:e,isStage:a})=>`${e?"":`https://${a?U:R}`}/api`,B=()=>{const e=X()&&window.location.hostname;return!!e&&(z.includes(e)||z.some(a=>e.endsWith(a)))};async function G({path:e,baseApiUrl:a,method:n="GET",headers:t={},params:o,body:c}){const m=`${a||Y({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(`${m}${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 N={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function Z(e){const a=e;return a.init=n=>t=>e(t,n),a}const J=e=>Z(e);async function Q({editor:e,plan:a,pluginName:n,licenseKey:t,cleanup:o}){let c="",p=!1;const m=B(),r=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),o()},u=(s={})=>{var C;const{error:l,sdkLicense:D}=s,v=(C=s.plan)==null?void 0:C.category;if(!(D||s.license)||l)r(l||"Invalid license");else if(v){const E=N[a],S=N[v];E>S&&r({pluginRequiredPlan:a,licensePlan:v})}};e.on(q,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(V,s=>{u(s)}),setTimeout(async()=>{if(!p){if(m)return;if(t){const s=await ee({licenseKey:t,pluginName:n,baseApiUrl:c});s&&u(s)}else r("The `licenseKey` option not provided")}},2e3)}async function ee(e){const{licenseKey:a,pluginName:n,baseApiUrl:t}=e;try{return(await G({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 P="canvasFullSize",te=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:m,canvasTransition:r,deviceMaxWidth:u,deviceMinHeigth:s,frameBorderRadius:l,frameTransition:D}=c,v=`${s}px`,$=n.events,C="core:preview",E=`${t.events.stopCommand}${C}`,S=n.getConfig(),A=`${P}:disable`,_=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",v)});const L=i=>{const w="data-gs-plg-full-size",d=document.querySelector(`style[${w}]`);if(i&&d)return d.remove();const f=d||document.createElement("style"),h=n.getZoomMultiplier();f.setAttribute(w,"true"),f.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 }
|
|
5
|
-
`,!
|
|
5
|
+
`,!d&&document.body.appendChild(f)};e.on($.frameLoadHead,i=>{if(!S.scrollableCanvas)return;const{window:w}=i,d=w.document,f=d.head,h="data-gs-plg-wrapper-style",y=f.querySelector(`style[${h}]`)||d.createElement("style");y.setAttribute(h,"true"),y.innerHTML=`
|
|
6
|
+
[data-gjs-type="wrapper"] { min-height: ${v}; }
|
|
7
|
+
[data-gjs-type="mjml"] { min-height: ${v} !important; }
|
|
8
|
+
[data-gjs-type="mj-body"] { min-height: ${v} !important; }
|
|
9
|
+
`,!f.contains(y)&&f.appendChild(y)}),e.onReady(()=>{const i=n.getSpotsEl(),w=n.getElement(),d=n.getFramesEl(),f=r*1e3,h=w.style;h.overflowX="hidden",d.style.transition=`transform ${r}s`;const y={x:m,y:p};L();const H=()=>i.style.display="none",K=()=>i.style.display="",T=F(()=>{n.fitViewport({zoom:g=>g>100?100:g,ignoreHeight:!0,gap:y}),L(),setTimeout(()=>{var W,k;const{em:g}=e;g.destroyed||((k=(W=e.getSelected())==null?void 0:W.getEl())==null||k.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),K(),t.isActive(C)?g.stopDefault():g.runDefault())},f)},100),j=new ResizeObserver(()=>{H(),T()});j.observe(w.parentElement);const M=()=>{H(),T()},O=(g={})=>{g.options&&g.options.from!=="fitViewport"&&n.fitViewport({zoom:n.getZoom(),ignoreHeight:!0,gap:y})},x=()=>{h.overflowX="hidden",h.overflowY="auto"},I=()=>{j.disconnect(),T.clear()};e.on(o.events.select,M),e.on($.zoom,O),e.on(E,x),e.on(e.events.destroy,I),T(),t.add(A,()=>{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,M),e.off($.zoom,O),e.off(E,x),I(),t.run("studio:canvasReload")})}),Q({editor:e,licenseKey:c.licenseKey,plan:b.startup,pluginName:P,cleanup:()=>{e.runCommand(A)}})},ne=J(te);module.exports=ne;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
function
|
|
2
|
-
let t, o, c, p,
|
|
1
|
+
function F(e, a, n) {
|
|
2
|
+
let t, o, c, p, m;
|
|
3
3
|
const r = a;
|
|
4
4
|
function u() {
|
|
5
5
|
const l = Date.now() - p;
|
|
6
|
-
l < r && l >= 0 ? t = setTimeout(u, r - l) : (t = null,
|
|
6
|
+
l < r && l >= 0 ? t = setTimeout(u, r - l) : (t = null, m = e.apply(c, o), c = o = null);
|
|
7
7
|
}
|
|
8
8
|
const s = function() {
|
|
9
|
-
return c = this, o = arguments, p = Date.now(), t || (t = setTimeout(u, r)),
|
|
9
|
+
return c = this, o = arguments, p = Date.now(), t || (t = setTimeout(u, r)), m;
|
|
10
10
|
};
|
|
11
11
|
return s.clear = function() {
|
|
12
12
|
t && (clearTimeout(t), t = null);
|
|
13
13
|
}, s.flush = function() {
|
|
14
|
-
t && (
|
|
14
|
+
t && (m = e.apply(c, o), c = o = null, clearTimeout(t), t = null);
|
|
15
15
|
}, s;
|
|
16
16
|
}
|
|
17
|
-
const R = "app.grapesjs.com", U = "app-stage.grapesjs.com",
|
|
17
|
+
const R = "app.grapesjs.com", U = "app-stage.grapesjs.com", z = [
|
|
18
18
|
R,
|
|
19
19
|
U,
|
|
20
20
|
"localhost",
|
|
@@ -25,11 +25,11 @@ const R = "app.grapesjs.com", U = "app-stage.grapesjs.com", k = [
|
|
|
25
25
|
// For stackblitz.com demos
|
|
26
26
|
"-sandpack.codesandbox.io"
|
|
27
27
|
// For Sandpack demos
|
|
28
|
-
],
|
|
29
|
-
const e =
|
|
30
|
-
return !!e && (
|
|
28
|
+
], q = "license:check:start", V = "license:check:end", X = () => typeof window < "u", Y = ({ isDev: e, isStage: a }) => `${e ? "" : `https://${a ? U : R}`}/api`, B = () => {
|
|
29
|
+
const e = X() && window.location.hostname;
|
|
30
|
+
return !!e && (z.includes(e) || z.some((a) => e.endsWith(a)));
|
|
31
31
|
};
|
|
32
|
-
async function
|
|
32
|
+
async function G({
|
|
33
33
|
path: e,
|
|
34
34
|
baseApiUrl: a,
|
|
35
35
|
method: n = "GET",
|
|
@@ -37,7 +37,7 @@ async function Y({
|
|
|
37
37
|
params: o,
|
|
38
38
|
body: c
|
|
39
39
|
}) {
|
|
40
|
-
const
|
|
40
|
+
const m = `${a || Y({ isDev: !1, isStage: !1 })}${e}`, r = {
|
|
41
41
|
method: n,
|
|
42
42
|
headers: {
|
|
43
43
|
"Content-Type": "application/json",
|
|
@@ -45,24 +45,24 @@ async function Y({
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
c && (r.body = JSON.stringify(c));
|
|
48
|
-
const u = o ? new URLSearchParams(o).toString() : "", s = u ? `?${u}` : "", l = await fetch(`${
|
|
48
|
+
const u = o ? new URLSearchParams(o).toString() : "", s = u ? `?${u}` : "", l = await fetch(`${m}${s}`, r);
|
|
49
49
|
if (!l.ok)
|
|
50
50
|
throw new Error(`HTTP error! status: ${l.status}`);
|
|
51
51
|
return l.json();
|
|
52
52
|
}
|
|
53
53
|
var b = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(b || {});
|
|
54
|
-
const
|
|
54
|
+
const N = {
|
|
55
55
|
[b.free]: 0,
|
|
56
56
|
[b.startup]: 10,
|
|
57
57
|
[b.business]: 20,
|
|
58
58
|
[b.enterprise]: 30
|
|
59
59
|
};
|
|
60
|
-
function
|
|
60
|
+
function Z(e) {
|
|
61
61
|
const a = e;
|
|
62
62
|
return a.init = (n) => (t) => e(t, n), a;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
async function
|
|
64
|
+
const J = (e) => /* @__PURE__ */ Z(e);
|
|
65
|
+
async function Q({
|
|
66
66
|
editor: e,
|
|
67
67
|
plan: a,
|
|
68
68
|
pluginName: n,
|
|
@@ -70,37 +70,37 @@ async function Z({
|
|
|
70
70
|
cleanup: o
|
|
71
71
|
}) {
|
|
72
72
|
let c = "", p = !1;
|
|
73
|
-
const
|
|
73
|
+
const m = B(), r = (s) => {
|
|
74
74
|
console.warn("Cleanup plugin:", n, "Reason:", s), o();
|
|
75
75
|
}, u = (s = {}) => {
|
|
76
76
|
var C;
|
|
77
|
-
const { error: l, sdkLicense: D } = s,
|
|
77
|
+
const { error: l, sdkLicense: D } = s, v = (C = s.plan) == null ? void 0 : C.category;
|
|
78
78
|
if (!(D || s.license) || l)
|
|
79
79
|
r(l || "Invalid license");
|
|
80
|
-
else if (
|
|
81
|
-
const
|
|
82
|
-
|
|
80
|
+
else if (v) {
|
|
81
|
+
const E = N[a], S = N[v];
|
|
82
|
+
E > S && r({ pluginRequiredPlan: a, licensePlan: v });
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
e.on(
|
|
85
|
+
e.on(q, (s) => {
|
|
86
86
|
c = s == null ? void 0 : s.baseApiUrl, p = !0;
|
|
87
|
-
}), e.on(
|
|
87
|
+
}), e.on(V, (s) => {
|
|
88
88
|
u(s);
|
|
89
89
|
}), setTimeout(async () => {
|
|
90
90
|
if (!p) {
|
|
91
|
-
if (
|
|
91
|
+
if (m) return;
|
|
92
92
|
if (t) {
|
|
93
|
-
const s = await
|
|
93
|
+
const s = await ee({ licenseKey: t, pluginName: n, baseApiUrl: c });
|
|
94
94
|
s && u(s);
|
|
95
95
|
} else
|
|
96
96
|
r("The `licenseKey` option not provided");
|
|
97
97
|
}
|
|
98
98
|
}, 2e3);
|
|
99
99
|
}
|
|
100
|
-
async function
|
|
100
|
+
async function ee(e) {
|
|
101
101
|
const { licenseKey: a, pluginName: n, baseApiUrl: t } = e;
|
|
102
102
|
try {
|
|
103
|
-
return (await
|
|
103
|
+
return (await G({
|
|
104
104
|
baseApiUrl: t,
|
|
105
105
|
path: `/sdk/${a || "na"}`,
|
|
106
106
|
method: "POST",
|
|
@@ -113,7 +113,7 @@ async function J(e) {
|
|
|
113
113
|
return console.error("Error during SDK license check:", o), !1;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const P = "canvasFullSize", te = function(e, a = {}) {
|
|
117
117
|
const { Canvas: n, Commands: t, Devices: o } = e, c = {
|
|
118
118
|
deviceMaxWidth: 1200,
|
|
119
119
|
deviceMinHeigth: 500,
|
|
@@ -125,75 +125,80 @@ const N = "canvasFullSize", Q = function(e, a = {}) {
|
|
|
125
125
|
...a
|
|
126
126
|
}, {
|
|
127
127
|
canvasOffsetY: p,
|
|
128
|
-
canvasOffsetX:
|
|
128
|
+
canvasOffsetX: m,
|
|
129
129
|
canvasTransition: r,
|
|
130
130
|
deviceMaxWidth: u,
|
|
131
131
|
deviceMinHeigth: s,
|
|
132
132
|
frameBorderRadius: l,
|
|
133
133
|
frameTransition: D
|
|
134
|
-
} = c,
|
|
134
|
+
} = c, v = `${s}px`, $ = n.events, C = "core:preview", E = `${t.events.stopCommand}${C}`, S = n.getConfig(), A = `${P}:disable`, _ = o.getAll().map((i) => ({ ...i.attributes }));
|
|
135
135
|
S.scrollableCanvas = !0, o.getAll().map((i) => {
|
|
136
|
-
!i.get("width") && i.set("width", `${u}px`), !i.get("height") && i.set("height", "auto"), !i.get("minHeight") && i.set("minHeight",
|
|
136
|
+
!i.get("width") && i.set("width", `${u}px`), !i.get("height") && i.set("height", "auto"), !i.get("minHeight") && i.set("minHeight", v);
|
|
137
137
|
});
|
|
138
138
|
const L = (i) => {
|
|
139
|
-
const
|
|
140
|
-
if (i &&
|
|
141
|
-
return
|
|
142
|
-
const
|
|
143
|
-
|
|
139
|
+
const w = "data-gs-plg-full-size", d = document.querySelector(`style[${w}]`);
|
|
140
|
+
if (i && d)
|
|
141
|
+
return d.remove();
|
|
142
|
+
const f = d || document.createElement("style"), h = n.getZoomMultiplier();
|
|
143
|
+
f.setAttribute(w, "true"), f.innerHTML = `
|
|
144
144
|
.gjs-frame-wrapper { transition: width ${D}s !important; }
|
|
145
145
|
.gjs-frame-wrapper__bottom { height: ${p * h}px }
|
|
146
146
|
.gjs-frame { border-radius: ${l}px }
|
|
147
|
-
`, !
|
|
147
|
+
`, !d && document.body.appendChild(f);
|
|
148
148
|
};
|
|
149
|
-
e.on(
|
|
149
|
+
e.on($.frameLoadHead, (i) => {
|
|
150
150
|
if (!S.scrollableCanvas) return;
|
|
151
|
-
const { window:
|
|
152
|
-
|
|
151
|
+
const { window: w } = i, d = w.document, f = d.head, h = "data-gs-plg-wrapper-style", y = f.querySelector(`style[${h}]`) || d.createElement("style");
|
|
152
|
+
y.setAttribute(h, "true"), y.innerHTML = `
|
|
153
|
+
[data-gjs-type="wrapper"] { min-height: ${v}; }
|
|
154
|
+
[data-gjs-type="mjml"] { min-height: ${v} !important; }
|
|
155
|
+
[data-gjs-type="mj-body"] { min-height: ${v} !important; }
|
|
156
|
+
`, !f.contains(y) && f.appendChild(y);
|
|
153
157
|
}), e.onReady(() => {
|
|
154
|
-
const i = n.getSpotsEl(),
|
|
155
|
-
h.overflowX = "hidden",
|
|
156
|
-
const
|
|
158
|
+
const i = n.getSpotsEl(), w = n.getElement(), d = n.getFramesEl(), f = r * 1e3, h = w.style;
|
|
159
|
+
h.overflowX = "hidden", d.style.transition = `transform ${r}s`;
|
|
160
|
+
const y = { x: m, y: p };
|
|
157
161
|
L();
|
|
158
|
-
const
|
|
162
|
+
const H = () => i.style.display = "none", K = () => i.style.display = "", T = F(() => {
|
|
159
163
|
n.fitViewport({
|
|
160
164
|
zoom: (g) => g > 100 ? 100 : g,
|
|
161
165
|
ignoreHeight: !0,
|
|
162
|
-
gap:
|
|
166
|
+
gap: y
|
|
163
167
|
}), L(), setTimeout(() => {
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
var W, k;
|
|
169
|
+
const { em: g } = e;
|
|
170
|
+
g.destroyed || ((k = (W = e.getSelected()) == null ? void 0 : W.getEl()) == null || k.scrollIntoView({ block: "nearest" }), e.refresh({ tools: !0 }), K(), t.isActive(C) ? g.stopDefault() : g.runDefault());
|
|
171
|
+
}, f);
|
|
172
|
+
}, 100), j = new ResizeObserver(() => {
|
|
173
|
+
H(), T();
|
|
169
174
|
});
|
|
170
|
-
|
|
175
|
+
j.observe(w.parentElement);
|
|
171
176
|
const M = () => {
|
|
172
|
-
|
|
177
|
+
H(), T();
|
|
173
178
|
}, O = (g = {}) => {
|
|
174
179
|
g.options && g.options.from !== "fitViewport" && n.fitViewport({
|
|
175
180
|
zoom: n.getZoom(),
|
|
176
181
|
ignoreHeight: !0,
|
|
177
|
-
gap:
|
|
182
|
+
gap: y
|
|
178
183
|
});
|
|
179
184
|
}, x = () => {
|
|
180
185
|
h.overflowX = "hidden", h.overflowY = "auto";
|
|
181
186
|
}, I = () => {
|
|
182
|
-
|
|
187
|
+
j.disconnect(), T.clear();
|
|
183
188
|
};
|
|
184
|
-
e.on(o.events.select, M), e.on(
|
|
185
|
-
o.devices.reset(
|
|
189
|
+
e.on(o.events.select, M), e.on($.zoom, O), e.on(E, x), e.on(e.events.destroy, I), 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, M), e.off($.zoom, O), e.off(E, x), I(), t.run("studio:canvasReload");
|
|
186
191
|
});
|
|
187
|
-
}),
|
|
192
|
+
}), Q({
|
|
188
193
|
editor: e,
|
|
189
194
|
licenseKey: c.licenseKey,
|
|
190
195
|
plan: b.startup,
|
|
191
|
-
pluginName:
|
|
196
|
+
pluginName: P,
|
|
192
197
|
cleanup: () => {
|
|
193
|
-
e.runCommand(
|
|
198
|
+
e.runCommand(A);
|
|
194
199
|
}
|
|
195
200
|
});
|
|
196
|
-
},
|
|
201
|
+
}, ne = J(te);
|
|
197
202
|
export {
|
|
198
|
-
|
|
203
|
+
ne as default
|
|
199
204
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
(function(C,
|
|
2
|
-
.gjs-frame-wrapper { transition: width ${
|
|
1
|
+
(function(C,b){typeof exports=="object"&&typeof module<"u"?module.exports=b():typeof define=="function"&&define.amd?define(b):(C=typeof globalThis<"u"?globalThis:C||self,C.StudioSdkPlugins_canvasFullSize=b())})(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 b="app.grapesjs.com",x="app-stage.grapesjs.com",H=[b,x,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],F="license:check:start",K="license:check:end",q=()=>typeof window<"u",V=({isDev:e,isStage:i})=>`${e?"":`https://${i?x:b}`}/api`,X=()=>{const e=q()&&window.location.hostname;return!!e&&(H.includes(e)||H.some(i=>e.endsWith(i)))};async function Y({path:e,baseApiUrl:i,method:n="GET",headers:t={},params:o,body:c}){const d=`${i||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 S=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(S||{});const M={[S.free]:0,[S.startup]:10,[S.business]:20,[S.enterprise]:30};function B(e){const i=e;return i.init=n=>t=>e(t,n),i}const G=e=>B(e);async function Z({editor:e,plan:i,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 T;const{error:l,sdkLicense:A}=s,v=(T=s.plan)==null?void 0:T.category;if(!(A||s.license)||l)r(l||"Invalid license");else if(v){const D=M[i],$=M[v];D>$&&r({pluginRequiredPlan:i,licensePlan:v})}};e.on(F,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(K,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:i,pluginName:n,baseApiUrl:t}=e;try{return(await Y({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 O="canvasFullSize";return G(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:A}=c,v=`${s}px`,E=n.events,T="core:preview",D=`${t.events.stopCommand}${T}`,$=n.getConfig(),k=`${O}:disable`,Q=o.getAll().map(a=>({...a.attributes}));$.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",v)});const j=a=>{const y="data-gs-plg-full-size",f=document.querySelector(`style[${y}]`);if(a&&f)return f.remove();const m=f||document.createElement("style"),h=n.getZoomMultiplier();m.setAttribute(y,"true"),m.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${A}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(
|
|
5
|
+
`,!f&&document.body.appendChild(m)};e.on(E.frameLoadHead,a=>{if(!$.scrollableCanvas)return;const{window:y}=a,f=y.document,m=f.head,h="data-gs-plg-wrapper-style",w=m.querySelector(`style[${h}]`)||f.createElement("style");w.setAttribute(h,"true"),w.innerHTML=`
|
|
6
|
+
[data-gjs-type="wrapper"] { min-height: ${v}; }
|
|
7
|
+
[data-gjs-type="mjml"] { min-height: ${v} !important; }
|
|
8
|
+
[data-gjs-type="mj-body"] { min-height: ${v} !important; }
|
|
9
|
+
`,!m.contains(w)&&m.appendChild(w)}),e.onReady(()=>{const a=n.getSpotsEl(),y=n.getElement(),f=n.getFramesEl(),m=r*1e3,h=y.style;h.overflowX="hidden",f.style.transition=`transform ${r}s`;const w={x:d,y:p};j();const z=()=>a.style.display="none",ee=()=>a.style.display="",L=C(()=>{n.fitViewport({zoom:g=>g>100?100:g,ignoreHeight:!0,gap:w}),j(),setTimeout(()=>{var U,_;const{em:g}=e;g.destroyed||((_=(U=e.getSelected())==null?void 0:U.getEl())==null||_.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),ee(),t.isActive(T)?g.stopDefault():g.runDefault())},m)},100),I=new ResizeObserver(()=>{z(),L()});I.observe(y.parentElement);const P=()=>{z(),L()},W=(g={})=>{g.options&&g.options.from!=="fitViewport"&&n.fitViewport({zoom:n.getZoom(),ignoreHeight:!0,gap:w})},N=()=>{h.overflowX="hidden",h.overflowY="auto"},R=()=>{I.disconnect(),L.clear()};e.on(o.events.select,P),e.on(E.zoom,W),e.on(D,N),e.on(e.events.destroy,R),L(),t.add(k,()=>{o.devices.reset(Q),$.scrollableCanvas=!1,n.getModel().updateDevice(),n.setZoom(100),n.setCoords(0,0),h.overflowY="hidden",j(!0),e.off(o.events.select,P),e.off(E.zoom,W),e.off(D,N),R(),t.run("studio:canvasReload")})}),Z({editor:e,licenseKey:c.licenseKey,plan:S.startup,pluginName:O,cleanup:()=>{e.runCommand(k)}})})});
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { SDKPluginOptions } from '../utils';
|
|
2
2
|
export interface CanvasFullSizeOptions extends SDKPluginOptions {
|
|
3
3
|
/**
|
|
4
|
+
* Default max width for the devices.
|
|
4
5
|
* @default 1200
|
|
5
6
|
*/
|
|
6
7
|
deviceMaxWidth?: number;
|
|
7
8
|
/**
|
|
9
|
+
* Default min height for the devices.
|
|
8
10
|
* @default 500
|
|
9
11
|
*/
|
|
10
12
|
deviceMinHeigth?: number;
|
|
11
13
|
/**
|
|
14
|
+
* Offset for the canvas on the Y axis (margin between the canvas and content frame).
|
|
12
15
|
* @default 30
|
|
13
16
|
*/
|
|
14
17
|
canvasOffsetY?: number;
|
|
15
18
|
/**
|
|
19
|
+
* Offset for the canvas on the X axis (margin between the canvas and content frame).
|
|
16
20
|
* @default 50
|
|
17
21
|
*/
|
|
18
22
|
canvasOffsetX?: number;
|
|
19
23
|
/**
|
|
24
|
+
* Transition time for the canvas when the screen size changes (in seconds).
|
|
20
25
|
* @default 0.3
|
|
21
26
|
*/
|
|
22
27
|
canvasTransition?: number;
|
|
23
28
|
/**
|
|
29
|
+
* Border radius for the content frame (in px).
|
|
24
30
|
* @default 5
|
|
25
31
|
*/
|
|
26
32
|
frameBorderRadius?: number;
|
|
27
33
|
/**
|
|
34
|
+
* Transition time for the content frame when the device changes (in seconds).
|
|
28
35
|
* @default 0.3
|
|
29
36
|
*/
|
|
30
37
|
frameTransition?: number;
|