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