@grapesjs/studio-sdk-plugins 1.0.28 → 1.0.29
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/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +98 -97
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +8 -7
- package/dist/canvasFullSize/index.es.js +145 -138
- package/dist/canvasFullSize/index.umd.js +9 -8
- package/dist/canvasFullSize/typesSchema.d.ts +5 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +11 -11
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +13 -13
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +192 -95
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +7577 -7242
- package/dist/index.umd.js +192 -95
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -154
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +59 -59
- package/dist/presetPrintable/index.umd.js +1 -1
- package/dist/prosemirror/index.cjs.js +5 -5
- package/dist/prosemirror/index.es.js +100 -100
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +10 -10
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/shapeDividerComponent/index.cjs.d.ts +3 -0
- package/dist/shapeDividerComponent/index.cjs.js +97 -0
- package/dist/shapeDividerComponent/index.d.ts +3 -0
- package/dist/shapeDividerComponent/index.es.d.ts +3 -0
- package/dist/shapeDividerComponent/index.es.js +427 -0
- package/dist/shapeDividerComponent/index.umd.js +97 -0
- package/dist/shapeDividerComponent/shared.d.ts +3 -0
- package/dist/shapeDividerComponent/types.d.ts +10 -0
- package/dist/shapeDividerComponent/typesSchema.d.ts +9 -0
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +130 -122
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +9 -9
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +34 -34
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const V="app.grapesjs.com",k="app-stage.grapesjs.com",X="app2.grapesjs.com",j="app-stage2.grapesjs.com",U=[V,X,k,j,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],F="license:check:start",q="license:check:end",J=()=>typeof window<"u",z=({isDev:e,isStage:a})=>`${e?"":`https://${a?k:V}`}/api`,Q=()=>{const e=J()&&window.location.hostname;return!!e&&(U.includes(e)||U.some(a=>e.endsWith(a)))};function Z(e){return typeof e=="function"}async function ee({path:e,baseApiUrl:a,method:
|
|
1
|
+
"use strict";const V="app.grapesjs.com",k="app-stage.grapesjs.com",X="app2.grapesjs.com",j="app-stage2.grapesjs.com",U=[V,X,k,j,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],F="license:check:start",q="license:check:end",J=()=>typeof window<"u",z=({isDev:e,isStage:a})=>`${e?"":`https://${a?k:V}`}/api`,Q=()=>{const e=J()&&window.location.hostname;return!!e&&(U.includes(e)||U.some(a=>e.endsWith(a)))};function Z(e){return typeof e=="function"}async function ee({path:e,baseApiUrl:a,method:h="GET",headers:l={},params:f,body:s}){const n=`${a||z({isDev:!1,isStage:!1})}${e}`,m={method:h,headers:{"Content-Type":"application/json",...l}};s&&(m.body=JSON.stringify(s));const d=f?new URLSearchParams(f).toString():"",t=d?`?${d}`:"",c=await fetch(`${n}${t}`,m);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return c.json()}var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{});const W={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function te(e){const a=e;return a.init=h=>l=>e(l,h),a}const ne=e=>te(e);async function se({editor:e,plan:a,pluginName:h,licenseKey:l,cleanup:f}){let s="",o=!1;const n=Q(),m=t=>{console.warn("Cleanup plugin:",h,"Reason:",t),f()},d=(t={})=>{var E;const{error:c,sdkLicense:p}=t,i=(E=t.plan)==null?void 0:E.category;if(!(p||t.license)||c)m(c||"Invalid license");else if(i){const b=W[a],v=W[i];b>v&&m({pluginRequiredPlan:a,licensePlan:i})}};e.on(F,t=>{s=t==null?void 0:t.baseApiUrl,o=!0}),e.on(q,t=>{d(t)}),setTimeout(async()=>{if(!o){if(n)return;if(l){const t=await oe({licenseKey:l,pluginName:h,baseApiUrl:s});t&&d(t)}else m("The `licenseKey` option not provided")}},2e3)}async function oe(e){const{licenseKey:a,pluginName:h,baseApiUrl:l}=e;try{return(await ee({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:h}})).result||{}}catch(f){return console.error("Error during SDK license check:",f),!1}}const ce="canvasAbsoluteMode",ie=L.startup,ae=(e,a,h)=>{var d,t;const l=h.enableAbsolute??(c=>c.hasAbsolute),s=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0],o=((t=(d=s==null?void 0:s.delegate)==null?void 0:d.move)==null?void 0:t.call(d,s))||s;if(!o)return;const n=o.getEl();return{result:Z(l)?l({component:o,hasAbsolute:!!n&&getComputedStyle(n).position==="absolute"}):!1,component:o,dmode:o.get("dmode")}};function B({guideMatched:e,canvasView:a}){var P;const h=e.guide.x===void 0?"y":"x";let l=0,f=0,s=0,o=0;const{guide:n,matched:m}=e,d=a.getElBoxRect(n.componentView.el),t=a.getElBoxRect(((P=m.componentView)==null?void 0:P.el)||m.componentEl),c=d.y,p=d.y+d.height,i=d.x,S=d.x+d.width,E=t.y,b=t.y+t.height,v=t.x,_=t.x+t.width,x=Math.max(0,c-b),u=Math.max(0,E-p),C=Math.max(0,i-_),M=Math.max(0,v-S),r=x>u,g=C>M,y=n.type;return h==="x"&&(y==="l"?(l=i,r?(f=b,s=x):(f=p,s=u)):y==="r"?(l=S,r?(f=b,s=x):(f=p,s=u)):y==="x"&&(l=i-(i-S)/2,r?(f=b,s=x):(f=p,s=u))),h==="y"&&(y==="t"?(f=c,g?(l=_,o=C):(l=S,o=M)):y==="b"?(f=p,g?(l=_,o=C):(l=S,o=M)):y==="y"&&(f=c-(c-p)/2,g?(l=_,o=C):(l=S,o=M))),{axis:h,x:l,y:f,width:o,height:s}}function le({guideMatched:e,component:a,canvasView:h}){const l=e.guide.x===void 0?"x":"y",{guide:f,matched:s}=e,o=f.type,n=s.type,m=h.getElementPos(f.componentView.el).rect,d=h.getElementPos(s.componentView.el).rect;if(l==="x"){const t=m.height,c=d.top,p=d.top+d.height;let i=0;o==="t"?n==="t"?i=c-t:n==="b"?i=p-t:n==="y"&&(i=c-t-(c-p)/2):o==="b"?n==="t"?i=c-t*2:n==="b"?i=p-t*2:n==="y"&&(i=c-t*2-(c-p)/2):o==="y"&&(n==="t"?i=c-t*1.5:n==="b"?i=p-t*1.5:n==="y"&&(i=c-t*1.5-(c-p)/2)),a.addStyle({top:`${i-5}px`},{partial:!0})}if(l==="y"){const t=m.width,c=d.left,p=d.left+d.width;let i=0;o==="l"?n==="l"?i=c:n==="r"?i=p:n==="x"&&(i=c-(c-p)/2):o==="r"?n==="l"?i=c-t:n==="r"?i=p-t:n==="x"&&(i=c-t-(c-p)/2):o==="x"&&(n==="l"?i=c-t/2:n==="r"&&(i=p-t/2)),a.addStyle({left:`${i}px`},{partial:!0})}}function H({snapping:e,editor:a,props:h}){var R,w;const{command:l,guidesMatched:f}=h,s=h.component,o=s.getEl(),n=a.Canvas.getCanvasView(),{x:m,y:d}=e??{x:10,y:10},t=l.opts.event,c=t.clientX,p=t.clientY;if(!s.__lastSnappedPosition){const A=n.getElBoxRect(o),D=c-A.x,T=p-A.y;s.__lastSnappedPosition={left:A.x,top:A.y},s.__dragOffset={x:D,y:T}}const i=((R=s.__dragOffset)==null?void 0:R.x)||0,S=((w=s.__dragOffset)==null?void 0:w.y)||0,E=s.__lastSnappedPosition,b=c-E.left-i,v=p-E.top-S;let _=E.left,x=E.top;const u=f==null?void 0:f[0],C=(u==null?void 0:u.guide.type)==="l",M=(u==null?void 0:u.guide.type)==="x",r=(u==null?void 0:u.guide.type)==="r",g=(u==null?void 0:u.guide.type)==="t",y=(u==null?void 0:u.guide.type)==="b",P=(u==null?void 0:u.guide.type)==="y";if(u){const{x:A,y:D}=B({guideMatched:u,canvasView:n}),T=o.offsetWidth,G=o.offsetHeight;C?_=A:r?_=A-T:M?_=A-T/2:g?x=D:y?x=D-G:P&&(x=D-G/2),s.__lastSnappedGuideMatched=u}else Math.abs(b)>=m&&(_=Math.round((E.left+b)/m)*m,s.__lastSnappedGuideMatched=null),Math.abs(v)>=d&&(x=Math.round((E.top+v)/d)*d,s.__lastSnappedGuideMatched=null);return s.addStyle({left:`${_}px`,top:`${x}px`},{partial:!0}),s.__lastSnappedPosition={left:_,top:x},{x:_,y:x,guideMatched:s.__lastSnappedGuideMatched}}function de({snapping:e,props:a,editor:h}){const{x:l,y:f}=H({snapping:e,props:a,editor:h}),s=a.component;s.addStyle({left:`${l}px`,top:`${f}px`}),delete s.__lastSnappedPosition,delete s.__lastSnappedGuideMatched}const fe="core:component-drag",re="studio:setDragAbsolute",pe="dmode:start",Y="dmode:move",K="dmode:end",$="dragAbsolute",ue="select",he="hover",me="spacing",ge=function(e,a={}){const{Commands:h}=e,l=h.events,f=h.getConfig().defaultOptions??{},s=`${l.runBeforeCommand}tlb-move`;f[fe]={run:r=>({...r,skipGuidesRender:!0})};const{snapping:o,locking:n,globalAbsolute:m=!0}=a;m&&e.setDragMode("absolute");const d=!!(o!=null&&o.x||o!=null&&o.y),t=!!(n!=null&&n.x||n!=null&&n.y),{Canvas:c}=e;let p=null;const i=r=>{const{component:g,guidesMatched:y,command:P}=r,R=g.view,w=e.Canvas.getCanvasView(),A=g.getEl();let D=y.map(O=>O.matched.componentEl),T=y.map(O=>B({guideMatched:O,canvasView:w}));if(d){const{guideMatched:O}=H({snapping:o,props:r,editor:e});O?(D=[O.matched.componentEl],T=[B({guideMatched:O,canvasView:w})]):(D=[],T=[])}if(t)if(P.opts.event.shiftKey)if(!p)p=y[0];else{const N=p,I=N.guide.x===void 0?"x":"y";(I==="x"&&(n==null?void 0:n.x)||I==="y"&&(n==null?void 0:n.y))&&(le({guideMatched:N,component:g,canvasView:w}),D=[N.matched.componentEl],T=[B({guideMatched:N,canvasView:w})])}else p=null;const G={id:$,type:$,component:g,componentView:R,originComponent:A,matchedComponents:D,originMatchedDistances:T};c.addSpot(G)},S=({enabled:r})=>{e.runCommand(re,{enabled:r})},E=({type:r})=>{c.removeSpots({type:r})},b=()=>{E({type:ue}),E({type:he}),E({type:me})},v=r=>{S({enabled:!0}),i(r),b()},_=r=>{i(r),b()},x=r=>{E({type:$}),d&&de({snapping:o,props:r,editor:e}),S({enabled:!1})},M=[[pe,r=>{v(r),e.on(Y,_);const g=()=>{x(r),e.off(Y,_),e.off(K,g)};e.on(K,g)}],[s,r=>{if(m)return;const g=r.options.target,y=ae(e,g,a);y!=null&&y.result&&!y.dmode&&(r.options.mode="absolute")}]];M.forEach(([r,g])=>e.on(r,g)),se({editor:e,licenseKey:a.licenseKey,plan:ie,pluginName:ce,cleanup:()=>{S({enabled:!1}),M.forEach(([r,g])=>e.off(r,g))}})},ye=ne(ge);module.exports=ye;
|
|
@@ -21,23 +21,23 @@ function Z(e) {
|
|
|
21
21
|
async function ee({
|
|
22
22
|
path: e,
|
|
23
23
|
baseApiUrl: a,
|
|
24
|
-
method:
|
|
24
|
+
method: h = "GET",
|
|
25
25
|
headers: l = {},
|
|
26
|
-
params:
|
|
27
|
-
body:
|
|
26
|
+
params: f,
|
|
27
|
+
body: s
|
|
28
28
|
}) {
|
|
29
|
-
const
|
|
30
|
-
method:
|
|
29
|
+
const n = `${a || z({ isDev: !1, isStage: !1 })}${e}`, m = {
|
|
30
|
+
method: h,
|
|
31
31
|
headers: {
|
|
32
32
|
"Content-Type": "application/json",
|
|
33
33
|
...l
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
throw new Error(`HTTP error! status: ${
|
|
40
|
-
return
|
|
36
|
+
s && (m.body = JSON.stringify(s));
|
|
37
|
+
const d = f ? new URLSearchParams(f).toString() : "", t = d ? `?${d}` : "", c = await fetch(`${n}${t}`, m);
|
|
38
|
+
if (!c.ok)
|
|
39
|
+
throw new Error(`HTTP error! status: ${c.status}`);
|
|
40
|
+
return c.json();
|
|
41
41
|
}
|
|
42
42
|
var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {});
|
|
43
43
|
const W = {
|
|
@@ -48,46 +48,46 @@ const W = {
|
|
|
48
48
|
};
|
|
49
49
|
function te(e) {
|
|
50
50
|
const a = e;
|
|
51
|
-
return a.init = (
|
|
51
|
+
return a.init = (h) => (l) => e(l, h), a;
|
|
52
52
|
}
|
|
53
53
|
const ne = (e) => /* @__PURE__ */ te(e);
|
|
54
54
|
async function se({
|
|
55
55
|
editor: e,
|
|
56
56
|
plan: a,
|
|
57
|
-
pluginName:
|
|
57
|
+
pluginName: h,
|
|
58
58
|
licenseKey: l,
|
|
59
|
-
cleanup:
|
|
59
|
+
cleanup: f
|
|
60
60
|
}) {
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
console.warn("Cleanup plugin:",
|
|
64
|
-
},
|
|
61
|
+
let s = "", o = !1;
|
|
62
|
+
const n = Q(), m = (t) => {
|
|
63
|
+
console.warn("Cleanup plugin:", h, "Reason:", t), f();
|
|
64
|
+
}, d = (t = {}) => {
|
|
65
65
|
var E;
|
|
66
|
-
const { error:
|
|
67
|
-
if (!(
|
|
68
|
-
m(
|
|
66
|
+
const { error: c, sdkLicense: p } = t, i = (E = t.plan) == null ? void 0 : E.category;
|
|
67
|
+
if (!(p || t.license) || c)
|
|
68
|
+
m(c || "Invalid license");
|
|
69
69
|
else if (i) {
|
|
70
70
|
const b = W[a], v = W[i];
|
|
71
71
|
b > v && m({ pluginRequiredPlan: a, licensePlan: i });
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
e.on(F, (t) => {
|
|
75
|
-
|
|
75
|
+
s = t == null ? void 0 : t.baseApiUrl, o = !0;
|
|
76
76
|
}), e.on(q, (t) => {
|
|
77
|
-
|
|
77
|
+
d(t);
|
|
78
78
|
}), setTimeout(async () => {
|
|
79
|
-
if (!
|
|
80
|
-
if (
|
|
79
|
+
if (!o) {
|
|
80
|
+
if (n) return;
|
|
81
81
|
if (l) {
|
|
82
|
-
const t = await oe({ licenseKey: l, pluginName:
|
|
83
|
-
t &&
|
|
82
|
+
const t = await oe({ licenseKey: l, pluginName: h, baseApiUrl: s });
|
|
83
|
+
t && d(t);
|
|
84
84
|
} else
|
|
85
85
|
m("The `licenseKey` option not provided");
|
|
86
86
|
}
|
|
87
87
|
}, 2e3);
|
|
88
88
|
}
|
|
89
89
|
async function oe(e) {
|
|
90
|
-
const { licenseKey: a, pluginName:
|
|
90
|
+
const { licenseKey: a, pluginName: h, baseApiUrl: l } = e;
|
|
91
91
|
try {
|
|
92
92
|
return (await ee({
|
|
93
93
|
baseApiUrl: l,
|
|
@@ -95,21 +95,22 @@ async function oe(e) {
|
|
|
95
95
|
method: "POST",
|
|
96
96
|
params: {
|
|
97
97
|
d: window.location.hostname,
|
|
98
|
-
pn:
|
|
98
|
+
pn: h
|
|
99
99
|
}
|
|
100
100
|
})).result || {};
|
|
101
|
-
} catch (
|
|
102
|
-
return console.error("Error during SDK license check:",
|
|
101
|
+
} catch (f) {
|
|
102
|
+
return console.error("Error during SDK license check:", f), !1;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
const ce = "canvasAbsoluteMode", ie = L.startup, ae = (e, a,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
const ce = "canvasAbsoluteMode", ie = L.startup, ae = (e, a, h) => {
|
|
106
|
+
var d, t;
|
|
107
|
+
const l = h.enableAbsolute ?? ((c) => c.hasAbsolute), s = (Array.isArray(a) ? a : a ? [a] : [...e.getSelectedAll()])[0], o = ((t = (d = s == null ? void 0 : s.delegate) == null ? void 0 : d.move) == null ? void 0 : t.call(d, s)) || s;
|
|
108
|
+
if (!o) return;
|
|
109
|
+
const n = o.getEl();
|
|
109
110
|
return {
|
|
110
|
-
result: Z(l) ? l({ component:
|
|
111
|
-
component:
|
|
112
|
-
dmode:
|
|
111
|
+
result: Z(l) ? l({ component: o, hasAbsolute: !!n && getComputedStyle(n).position === "absolute" }) : !1,
|
|
112
|
+
component: o,
|
|
113
|
+
dmode: o.get("dmode")
|
|
113
114
|
};
|
|
114
115
|
};
|
|
115
116
|
function B({
|
|
@@ -117,86 +118,86 @@ function B({
|
|
|
117
118
|
canvasView: a
|
|
118
119
|
}) {
|
|
119
120
|
var P;
|
|
120
|
-
const
|
|
121
|
-
let l = 0,
|
|
122
|
-
const { guide:
|
|
123
|
-
return
|
|
121
|
+
const h = e.guide.x === void 0 ? "y" : "x";
|
|
122
|
+
let l = 0, f = 0, s = 0, o = 0;
|
|
123
|
+
const { guide: n, matched: m } = e, d = a.getElBoxRect(n.componentView.el), t = a.getElBoxRect(((P = m.componentView) == null ? void 0 : P.el) || m.componentEl), c = d.y, p = d.y + d.height, i = d.x, S = d.x + d.width, E = t.y, b = t.y + t.height, v = t.x, _ = t.x + t.width, x = Math.max(0, c - b), u = Math.max(0, E - p), C = Math.max(0, i - _), M = Math.max(0, v - S), r = x > u, g = C > M, y = n.type;
|
|
124
|
+
return h === "x" && (y === "l" ? (l = i, r ? (f = b, s = x) : (f = p, s = u)) : y === "r" ? (l = S, r ? (f = b, s = x) : (f = p, s = u)) : y === "x" && (l = i - (i - S) / 2, r ? (f = b, s = x) : (f = p, s = u))), h === "y" && (y === "t" ? (f = c, g ? (l = _, o = C) : (l = S, o = M)) : y === "b" ? (f = p, g ? (l = _, o = C) : (l = S, o = M)) : y === "y" && (f = c - (c - p) / 2, g ? (l = _, o = C) : (l = S, o = M))), { axis: h, x: l, y: f, width: o, height: s };
|
|
124
125
|
}
|
|
125
126
|
function le({
|
|
126
127
|
guideMatched: e,
|
|
127
128
|
component: a,
|
|
128
|
-
canvasView:
|
|
129
|
+
canvasView: h
|
|
129
130
|
}) {
|
|
130
|
-
const l = e.guide.x === void 0 ? "x" : "y", { guide:
|
|
131
|
+
const l = e.guide.x === void 0 ? "x" : "y", { guide: f, matched: s } = e, o = f.type, n = s.type, m = h.getElementPos(f.componentView.el).rect, d = h.getElementPos(s.componentView.el).rect;
|
|
131
132
|
if (l === "x") {
|
|
132
|
-
const t = m.height,
|
|
133
|
+
const t = m.height, c = d.top, p = d.top + d.height;
|
|
133
134
|
let i = 0;
|
|
134
|
-
|
|
135
|
+
o === "t" ? n === "t" ? i = c - t : n === "b" ? i = p - t : n === "y" && (i = c - t - (c - p) / 2) : o === "b" ? n === "t" ? i = c - t * 2 : n === "b" ? i = p - t * 2 : n === "y" && (i = c - t * 2 - (c - p) / 2) : o === "y" && (n === "t" ? i = c - t * 1.5 : n === "b" ? i = p - t * 1.5 : n === "y" && (i = c - t * 1.5 - (c - p) / 2)), a.addStyle({ top: `${i - 5}px` }, { partial: !0 });
|
|
135
136
|
}
|
|
136
137
|
if (l === "y") {
|
|
137
|
-
const t = m.width,
|
|
138
|
+
const t = m.width, c = d.left, p = d.left + d.width;
|
|
138
139
|
let i = 0;
|
|
139
|
-
|
|
140
|
+
o === "l" ? n === "l" ? i = c : n === "r" ? i = p : n === "x" && (i = c - (c - p) / 2) : o === "r" ? n === "l" ? i = c - t : n === "r" ? i = p - t : n === "x" && (i = c - t - (c - p) / 2) : o === "x" && (n === "l" ? i = c - t / 2 : n === "r" && (i = p - t / 2)), a.addStyle({ left: `${i}px` }, { partial: !0 });
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
function H({
|
|
143
144
|
snapping: e,
|
|
144
145
|
editor: a,
|
|
145
|
-
props:
|
|
146
|
+
props: h
|
|
146
147
|
}) {
|
|
147
148
|
var R, w;
|
|
148
|
-
const { command: l, guidesMatched:
|
|
149
|
-
if (!
|
|
150
|
-
const A =
|
|
151
|
-
|
|
149
|
+
const { command: l, guidesMatched: f } = h, s = h.component, o = s.getEl(), n = a.Canvas.getCanvasView(), { x: m, y: d } = e ?? { x: 10, y: 10 }, t = l.opts.event, c = t.clientX, p = t.clientY;
|
|
150
|
+
if (!s.__lastSnappedPosition) {
|
|
151
|
+
const A = n.getElBoxRect(o), D = c - A.x, T = p - A.y;
|
|
152
|
+
s.__lastSnappedPosition = { left: A.x, top: A.y }, s.__dragOffset = { x: D, y: T };
|
|
152
153
|
}
|
|
153
|
-
const i = ((R =
|
|
154
|
+
const i = ((R = s.__dragOffset) == null ? void 0 : R.x) || 0, S = ((w = s.__dragOffset) == null ? void 0 : w.y) || 0, E = s.__lastSnappedPosition, b = c - E.left - i, v = p - E.top - S;
|
|
154
155
|
let _ = E.left, x = E.top;
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
const { x: A, y: D } = B({ guideMatched:
|
|
158
|
-
C ? _ = A :
|
|
156
|
+
const u = f == null ? void 0 : f[0], C = (u == null ? void 0 : u.guide.type) === "l", M = (u == null ? void 0 : u.guide.type) === "x", r = (u == null ? void 0 : u.guide.type) === "r", g = (u == null ? void 0 : u.guide.type) === "t", y = (u == null ? void 0 : u.guide.type) === "b", P = (u == null ? void 0 : u.guide.type) === "y";
|
|
157
|
+
if (u) {
|
|
158
|
+
const { x: A, y: D } = B({ guideMatched: u, canvasView: n }), T = o.offsetWidth, G = o.offsetHeight;
|
|
159
|
+
C ? _ = A : r ? _ = A - T : M ? _ = A - T / 2 : g ? x = D : y ? x = D - G : P && (x = D - G / 2), s.__lastSnappedGuideMatched = u;
|
|
159
160
|
} else
|
|
160
|
-
Math.abs(b) >= m && (_ = Math.round((E.left + b) / m) * m,
|
|
161
|
-
return
|
|
161
|
+
Math.abs(b) >= m && (_ = Math.round((E.left + b) / m) * m, s.__lastSnappedGuideMatched = null), Math.abs(v) >= d && (x = Math.round((E.top + v) / d) * d, s.__lastSnappedGuideMatched = null);
|
|
162
|
+
return s.addStyle({ left: `${_}px`, top: `${x}px` }, { partial: !0 }), s.__lastSnappedPosition = { left: _, top: x }, { x: _, y: x, guideMatched: s.__lastSnappedGuideMatched };
|
|
162
163
|
}
|
|
163
164
|
function de({
|
|
164
165
|
snapping: e,
|
|
165
166
|
props: a,
|
|
166
|
-
editor:
|
|
167
|
+
editor: h
|
|
167
168
|
}) {
|
|
168
|
-
const { x: l, y:
|
|
169
|
-
|
|
169
|
+
const { x: l, y: f } = H({ snapping: e, props: a, editor: h }), s = a.component;
|
|
170
|
+
s.addStyle({ left: `${l}px`, top: `${f}px` }), delete s.__lastSnappedPosition, delete s.__lastSnappedGuideMatched;
|
|
170
171
|
}
|
|
171
172
|
const fe = "core:component-drag", re = "studio:setDragAbsolute", pe = "dmode:start", Y = "dmode:move", K = "dmode:end", $ = "dragAbsolute", ue = "select", he = "hover", me = "spacing", ge = function(e, a = {}) {
|
|
172
|
-
const { Commands:
|
|
173
|
-
|
|
174
|
-
run: (
|
|
175
|
-
...
|
|
173
|
+
const { Commands: h } = e, l = h.events, f = h.getConfig().defaultOptions ?? {}, s = `${l.runBeforeCommand}tlb-move`;
|
|
174
|
+
f[fe] = {
|
|
175
|
+
run: (r) => ({
|
|
176
|
+
...r,
|
|
176
177
|
skipGuidesRender: !0
|
|
177
178
|
})
|
|
178
179
|
};
|
|
179
|
-
const { snapping:
|
|
180
|
+
const { snapping: o, locking: n, globalAbsolute: m = !0 } = a;
|
|
180
181
|
m && e.setDragMode("absolute");
|
|
181
|
-
const
|
|
182
|
-
let
|
|
183
|
-
const i = (
|
|
184
|
-
const { component: g, guidesMatched: y, command: P } =
|
|
182
|
+
const d = !!(o != null && o.x || o != null && o.y), t = !!(n != null && n.x || n != null && n.y), { Canvas: c } = e;
|
|
183
|
+
let p = null;
|
|
184
|
+
const i = (r) => {
|
|
185
|
+
const { component: g, guidesMatched: y, command: P } = r, R = g.view, w = e.Canvas.getCanvasView(), A = g.getEl();
|
|
185
186
|
let D = y.map((O) => O.matched.componentEl), T = y.map((O) => B({ guideMatched: O, canvasView: w }));
|
|
186
|
-
if (
|
|
187
|
-
const { guideMatched: O } = H({ snapping:
|
|
187
|
+
if (d) {
|
|
188
|
+
const { guideMatched: O } = H({ snapping: o, props: r, editor: e });
|
|
188
189
|
O ? (D = [O.matched.componentEl], T = [B({ guideMatched: O, canvasView: w })]) : (D = [], T = []);
|
|
189
190
|
}
|
|
190
191
|
if (t)
|
|
191
192
|
if (P.opts.event.shiftKey)
|
|
192
|
-
if (!
|
|
193
|
-
|
|
193
|
+
if (!p)
|
|
194
|
+
p = y[0];
|
|
194
195
|
else {
|
|
195
|
-
const N =
|
|
196
|
-
(I === "x" && (
|
|
196
|
+
const N = p, I = N.guide.x === void 0 ? "x" : "y";
|
|
197
|
+
(I === "x" && (n == null ? void 0 : n.x) || I === "y" && (n == null ? void 0 : n.y)) && (le({ guideMatched: N, component: g, canvasView: w }), D = [N.matched.componentEl], T = [B({ guideMatched: N, canvasView: w })]);
|
|
197
198
|
}
|
|
198
199
|
else
|
|
199
|
-
|
|
200
|
+
p = null;
|
|
200
201
|
const G = {
|
|
201
202
|
id: $,
|
|
202
203
|
type: $,
|
|
@@ -206,40 +207,40 @@ const fe = "core:component-drag", re = "studio:setDragAbsolute", pe = "dmode:sta
|
|
|
206
207
|
matchedComponents: D,
|
|
207
208
|
originMatchedDistances: T
|
|
208
209
|
};
|
|
209
|
-
|
|
210
|
-
}, S = ({ enabled:
|
|
211
|
-
e.runCommand(re, { enabled:
|
|
212
|
-
}, E = ({ type:
|
|
213
|
-
|
|
210
|
+
c.addSpot(G);
|
|
211
|
+
}, S = ({ enabled: r }) => {
|
|
212
|
+
e.runCommand(re, { enabled: r });
|
|
213
|
+
}, E = ({ type: r }) => {
|
|
214
|
+
c.removeSpots({ type: r });
|
|
214
215
|
}, b = () => {
|
|
215
216
|
E({ type: ue }), E({ type: he }), E({ type: me });
|
|
216
|
-
}, v = (
|
|
217
|
-
S({ enabled: !0 }), i(
|
|
218
|
-
}, _ = (
|
|
219
|
-
i(
|
|
220
|
-
}, x = (
|
|
221
|
-
E({ type: $ }),
|
|
217
|
+
}, v = (r) => {
|
|
218
|
+
S({ enabled: !0 }), i(r), b();
|
|
219
|
+
}, _ = (r) => {
|
|
220
|
+
i(r), b();
|
|
221
|
+
}, x = (r) => {
|
|
222
|
+
E({ type: $ }), d && de({ snapping: o, props: r, editor: e }), S({ enabled: !1 });
|
|
222
223
|
}, M = [
|
|
223
|
-
[pe, (
|
|
224
|
-
v(
|
|
224
|
+
[pe, (r) => {
|
|
225
|
+
v(r), e.on(Y, _);
|
|
225
226
|
const g = () => {
|
|
226
|
-
x(
|
|
227
|
+
x(r), e.off(Y, _), e.off(K, g);
|
|
227
228
|
};
|
|
228
229
|
e.on(K, g);
|
|
229
230
|
}],
|
|
230
|
-
[
|
|
231
|
+
[s, (r) => {
|
|
231
232
|
if (m) return;
|
|
232
|
-
const g =
|
|
233
|
-
y != null && y.result && !y.dmode && (
|
|
233
|
+
const g = r.options.target, y = ae(e, g, a);
|
|
234
|
+
y != null && y.result && !y.dmode && (r.options.mode = "absolute");
|
|
234
235
|
}]
|
|
235
236
|
];
|
|
236
|
-
M.forEach(([
|
|
237
|
+
M.forEach(([r, g]) => e.on(r, g)), se({
|
|
237
238
|
editor: e,
|
|
238
239
|
licenseKey: a.licenseKey,
|
|
239
240
|
plan: ie,
|
|
240
241
|
pluginName: ce,
|
|
241
242
|
cleanup: () => {
|
|
242
|
-
S({ enabled: !1 }), M.forEach(([
|
|
243
|
+
S({ enabled: !1 }), M.forEach(([r, g]) => e.off(r, g));
|
|
243
244
|
}
|
|
244
245
|
});
|
|
245
246
|
}, Ee = ne(ge);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(P,R){typeof exports=="object"&&typeof module<"u"?module.exports=R():typeof define=="function"&&define.amd?define(R):(P=typeof globalThis<"u"?globalThis:P||self,P.StudioSdkPlugins_canvasAbsoluteMode=R())})(this,function(){"use strict";const P="app.grapesjs.com",R="app-stage.grapesjs.com",W=[P,"app2.grapesjs.com",R,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:start",X="license:check:end",F=()=>typeof window<"u",q=({isDev:e,isStage:a})=>`${e?"":`https://${a?R:P}`}/api`,J=()=>{const e=F()&&window.location.hostname;return!!e&&(W.includes(e)||W.some(a=>e.endsWith(a)))};function z(e){return typeof e=="function"}async function Q({path:e,baseApiUrl:a,method:
|
|
1
|
+
(function(P,R){typeof exports=="object"&&typeof module<"u"?module.exports=R():typeof define=="function"&&define.amd?define(R):(P=typeof globalThis<"u"?globalThis:P||self,P.StudioSdkPlugins_canvasAbsoluteMode=R())})(this,function(){"use strict";const P="app.grapesjs.com",R="app-stage.grapesjs.com",W=[P,"app2.grapesjs.com",R,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:start",X="license:check:end",F=()=>typeof window<"u",q=({isDev:e,isStage:a})=>`${e?"":`https://${a?R:P}`}/api`,J=()=>{const e=F()&&window.location.hostname;return!!e&&(W.includes(e)||W.some(a=>e.endsWith(a)))};function z(e){return typeof e=="function"}async function Q({path:e,baseApiUrl:a,method:h="GET",headers:l={},params:f,body:o}){const n=`${a||q({isDev:!1,isStage:!1})}${e}`,m={method:h,headers:{"Content-Type":"application/json",...l}};o&&(m.body=JSON.stringify(o));const d=f?new URLSearchParams(f).toString():"",t=d?`?${d}`:"",i=await fetch(`${n}${t}`,m);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.json()}var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{});const Y={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function Z(e){const a=e;return a.init=h=>l=>e(l,h),a}const ee=e=>Z(e);async function te({editor:e,plan:a,pluginName:h,licenseKey:l,cleanup:f}){let o="",s=!1;const n=J(),m=t=>{console.warn("Cleanup plugin:",h,"Reason:",t),f()},d=(t={})=>{var E;const{error:i,sdkLicense:p}=t,c=(E=t.plan)==null?void 0:E.category;if(!(p||t.license)||i)m(i||"Invalid license");else if(c){const b=Y[a],v=Y[c];b>v&&m({pluginRequiredPlan:a,licensePlan:c})}};e.on(H,t=>{o=t==null?void 0:t.baseApiUrl,s=!0}),e.on(X,t=>{d(t)}),setTimeout(async()=>{if(!s){if(n)return;if(l){const t=await ne({licenseKey:l,pluginName:h,baseApiUrl:o});t&&d(t)}else m("The `licenseKey` option not provided")}},2e3)}async function ne(e){const{licenseKey:a,pluginName:h,baseApiUrl:l}=e;try{return(await Q({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:h}})).result||{}}catch(f){return console.error("Error during SDK license check:",f),!1}}const oe="canvasAbsoluteMode",se=L.startup,ie=(e,a,h)=>{var d,t;const l=h.enableAbsolute??(i=>i.hasAbsolute),o=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0],s=((t=(d=o==null?void 0:o.delegate)==null?void 0:d.move)==null?void 0:t.call(d,o))||o;if(!s)return;const n=s.getEl();return{result:z(l)?l({component:s,hasAbsolute:!!n&&getComputedStyle(n).position==="absolute"}):!1,component:s,dmode:s.get("dmode")}};function G({guideMatched:e,canvasView:a}){var N;const h=e.guide.x===void 0?"y":"x";let l=0,f=0,o=0,s=0;const{guide:n,matched:m}=e,d=a.getElBoxRect(n.componentView.el),t=a.getElBoxRect(((N=m.componentView)==null?void 0:N.el)||m.componentEl),i=d.y,p=d.y+d.height,c=d.x,S=d.x+d.width,E=t.y,b=t.y+t.height,v=t.x,_=t.x+t.width,x=Math.max(0,i-b),u=Math.max(0,E-p),C=Math.max(0,c-_),M=Math.max(0,v-S),r=x>u,g=C>M,y=n.type;return h==="x"&&(y==="l"?(l=c,r?(f=b,o=x):(f=p,o=u)):y==="r"?(l=S,r?(f=b,o=x):(f=p,o=u)):y==="x"&&(l=c-(c-S)/2,r?(f=b,o=x):(f=p,o=u))),h==="y"&&(y==="t"?(f=i,g?(l=_,s=C):(l=S,s=M)):y==="b"?(f=p,g?(l=_,s=C):(l=S,s=M)):y==="y"&&(f=i-(i-p)/2,g?(l=_,s=C):(l=S,s=M))),{axis:h,x:l,y:f,width:s,height:o}}function ce({guideMatched:e,component:a,canvasView:h}){const l=e.guide.x===void 0?"x":"y",{guide:f,matched:o}=e,s=f.type,n=o.type,m=h.getElementPos(f.componentView.el).rect,d=h.getElementPos(o.componentView.el).rect;if(l==="x"){const t=m.height,i=d.top,p=d.top+d.height;let c=0;s==="t"?n==="t"?c=i-t:n==="b"?c=p-t:n==="y"&&(c=i-t-(i-p)/2):s==="b"?n==="t"?c=i-t*2:n==="b"?c=p-t*2:n==="y"&&(c=i-t*2-(i-p)/2):s==="y"&&(n==="t"?c=i-t*1.5:n==="b"?c=p-t*1.5:n==="y"&&(c=i-t*1.5-(i-p)/2)),a.addStyle({top:`${c-5}px`},{partial:!0})}if(l==="y"){const t=m.width,i=d.left,p=d.left+d.width;let c=0;s==="l"?n==="l"?c=i:n==="r"?c=p:n==="x"&&(c=i-(i-p)/2):s==="r"?n==="l"?c=i-t:n==="r"?c=p-t:n==="x"&&(c=i-t-(i-p)/2):s==="x"&&(n==="l"?c=i-t/2:n==="r"&&(c=p-t/2)),a.addStyle({left:`${c}px`},{partial:!0})}}function k({snapping:e,editor:a,props:h}){var B,w;const{command:l,guidesMatched:f}=h,o=h.component,s=o.getEl(),n=a.Canvas.getCanvasView(),{x:m,y:d}=e??{x:10,y:10},t=l.opts.event,i=t.clientX,p=t.clientY;if(!o.__lastSnappedPosition){const A=n.getElBoxRect(s),D=i-A.x,T=p-A.y;o.__lastSnappedPosition={left:A.x,top:A.y},o.__dragOffset={x:D,y:T}}const c=((B=o.__dragOffset)==null?void 0:B.x)||0,S=((w=o.__dragOffset)==null?void 0:w.y)||0,E=o.__lastSnappedPosition,b=i-E.left-c,v=p-E.top-S;let _=E.left,x=E.top;const u=f==null?void 0:f[0],C=(u==null?void 0:u.guide.type)==="l",M=(u==null?void 0:u.guide.type)==="x",r=(u==null?void 0:u.guide.type)==="r",g=(u==null?void 0:u.guide.type)==="t",y=(u==null?void 0:u.guide.type)==="b",N=(u==null?void 0:u.guide.type)==="y";if(u){const{x:A,y:D}=G({guideMatched:u,canvasView:n}),T=s.offsetWidth,I=s.offsetHeight;C?_=A:r?_=A-T:M?_=A-T/2:g?x=D:y?x=D-I:N&&(x=D-I/2),o.__lastSnappedGuideMatched=u}else Math.abs(b)>=m&&(_=Math.round((E.left+b)/m)*m,o.__lastSnappedGuideMatched=null),Math.abs(v)>=d&&(x=Math.round((E.top+v)/d)*d,o.__lastSnappedGuideMatched=null);return o.addStyle({left:`${_}px`,top:`${x}px`},{partial:!0}),o.__lastSnappedPosition={left:_,top:x},{x:_,y:x,guideMatched:o.__lastSnappedGuideMatched}}function ae({snapping:e,props:a,editor:h}){const{x:l,y:f}=k({snapping:e,props:a,editor:h}),o=a.component;o.addStyle({left:`${l}px`,top:`${f}px`}),delete o.__lastSnappedPosition,delete o.__lastSnappedGuideMatched}const le="core:component-drag",de="studio:setDragAbsolute",fe="dmode:start",K="dmode:move",V="dmode:end",U="dragAbsolute",re="select",pe="hover",ue="spacing";return ee(function(e,a={}){const{Commands:h}=e,l=h.events,f=h.getConfig().defaultOptions??{},o=`${l.runBeforeCommand}tlb-move`;f[le]={run:r=>({...r,skipGuidesRender:!0})};const{snapping:s,locking:n,globalAbsolute:m=!0}=a;m&&e.setDragMode("absolute");const d=!!(s!=null&&s.x||s!=null&&s.y),t=!!(n!=null&&n.x||n!=null&&n.y),{Canvas:i}=e;let p=null;const c=r=>{const{component:g,guidesMatched:y,command:N}=r,B=g.view,w=e.Canvas.getCanvasView(),A=g.getEl();let D=y.map(O=>O.matched.componentEl),T=y.map(O=>G({guideMatched:O,canvasView:w}));if(d){const{guideMatched:O}=k({snapping:s,props:r,editor:e});O?(D=[O.matched.componentEl],T=[G({guideMatched:O,canvasView:w})]):(D=[],T=[])}if(t)if(N.opts.event.shiftKey)if(!p)p=y[0];else{const $=p,j=$.guide.x===void 0?"x":"y";(j==="x"&&(n==null?void 0:n.x)||j==="y"&&(n==null?void 0:n.y))&&(ce({guideMatched:$,component:g,canvasView:w}),D=[$.matched.componentEl],T=[G({guideMatched:$,canvasView:w})])}else p=null;const I={id:U,type:U,component:g,componentView:B,originComponent:A,matchedComponents:D,originMatchedDistances:T};i.addSpot(I)},S=({enabled:r})=>{e.runCommand(de,{enabled:r})},E=({type:r})=>{i.removeSpots({type:r})},b=()=>{E({type:re}),E({type:pe}),E({type:ue})},v=r=>{S({enabled:!0}),c(r),b()},_=r=>{c(r),b()},x=r=>{E({type:U}),d&&ae({snapping:s,props:r,editor:e}),S({enabled:!1})},M=[[fe,r=>{v(r),e.on(K,_);const g=()=>{x(r),e.off(K,_),e.off(V,g)};e.on(V,g)}],[o,r=>{if(m)return;const g=r.options.target,y=ie(e,g,a);y!=null&&y.result&&!y.dmode&&(r.options.mode="absolute")}]];M.forEach(([r,g])=>e.on(r,g)),te({editor:e,licenseKey:a.licenseKey,plan:se,pluginName:oe,cleanup:()=>{S({enabled:!1}),M.forEach(([r,g])=>e.off(r,g))}})})});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
"use strict";function
|
|
2
|
-
.gjs-frame-wrapper { transition: width ${
|
|
1
|
+
"use strict";function X(e,i,t){let s,o,c,h,m;const r=i;function d(){const l=Date.now()-h;l<r&&l>=0?s=setTimeout(d,r-l):(s=null,m=e.apply(c,o),c=o=null)}const a=function(){return c=this,o=arguments,h=Date.now(),s||(s=setTimeout(d,r)),m};return a.clear=function(){s&&(clearTimeout(s),s=null)},a.flush=function(){s&&(m=e.apply(c,o),c=o=null,clearTimeout(s),s=null)},a}const U="app.grapesjs.com",k="app-stage.grapesjs.com",Y="app2.grapesjs.com",J="app-stage2.grapesjs.com",j=[U,Y,k,J,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Q="license:check:start",ee="license:check:end",te=()=>typeof window<"u",ne=({isDev:e,isStage:i})=>`${e?"":`https://${i?k:U}`}/api`,se=()=>{const e=te()&&window.location.hostname;return!!e&&(j.includes(e)||j.some(i=>e.endsWith(i)))};async function oe({path:e,baseApiUrl:i,method:t="GET",headers:s={},params:o,body:c}){const m=`${i||ne({isDev:!1,isStage:!1})}${e}`,r={method:t,headers:{"Content-Type":"application/json",...s}};c&&(r.body=JSON.stringify(c));const d=o?new URLSearchParams(o).toString():"",a=d?`?${d}`:"",l=await fetch(`${m}${a}`,r);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{});const I={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ae(e){const i=e;return i.init=t=>s=>e(s,t),i}const ie=e=>ae(e);async function ce({editor:e,plan:i,pluginName:t,licenseKey:s,cleanup:o}){let c="",h=!1;const m=se(),r=a=>{console.warn("Cleanup plugin:",t,"Reason:",a),o()},d=(a={})=>{var v;const{error:l,sdkLicense:g}=a,w=(v=a.plan)==null?void 0:v.category;if(!(g||a.license)||l)r(l||"Invalid license");else if(w){const S=I[i],E=I[w];S>E&&r({pluginRequiredPlan:i,licensePlan:w})}};e.on(Q,a=>{c=a==null?void 0:a.baseApiUrl,h=!0}),e.on(ee,a=>{d(a)}),setTimeout(async()=>{if(!h){if(m)return;if(s){const a=await re({licenseKey:s,pluginName:t,baseApiUrl:c});a&&d(a)}else r("The `licenseKey` option not provided")}},2e3)}async function re(e){const{licenseKey:i,pluginName:t,baseApiUrl:s}=e;try{return(await oe({baseApiUrl:s,path:`/sdk/${i||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const N="data-gs-plg-",O="canvasFullSize",le=y.startup,ue=(e,i)=>{const{rule:t,ruleView:s}=i,{style:o}=t.attributes;if(o&&o[e]){const c=o[e],h=/([0-9.]+)(vh|dvh|lvh|svh)/g,m=h.test(c),r=s.frameView.model;if(m&&r.hasAutoHeight()){const d=c.replace(h,(l,g)=>`${window.innerHeight*(parseFloat(g)/100)}px`),a=t.toCSS({style:{...o,[e]:d}});i.css=a}}},pe=e=>{["height","min-height","max-height"].forEach(i=>ue(i,e))},me=function(e,i={}){const{Canvas:t,Commands:s,Devices:o,Css:c}=e,h={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...i},{canvasOffsetY:m,canvasOffsetX:r,canvasTransition:d,deviceMaxWidth:a,deviceMinHeigth:l,deviceFixedHeight:g,frameBorderRadius:w,frameTransition:M}=h,v=`${l}px`,S=t.events,E="core:preview",W=`${s.events.stopCommand}${E}`,D=t.getConfig(),P=`${O}:disable`,z=o.getAll().map(n=>({...n.attributes})),F=d*1e3,x={x:r,y:m};let b={},H,C;D.scrollableCanvas=!g,o.getAll().map(n=>{!n.get("width")&&n.set("width",`${a}px`),!n.get("height")&&n.set("height",g?"100vh":"auto"),!n.get("minHeight")&&n.set("minHeight",v)});const L=n=>{const u=`${N}canvas-full-size`,p=document.querySelector(`style[${u}]`);if(n&&p)return p.remove();const f=p||document.createElement("style"),T=t.getZoomMultiplier();f.setAttribute(u,"true"),f.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${M}s !important; }
|
|
3
3
|
.gjs-frame-wrapper__bottom { height: ${m*T}px }
|
|
4
4
|
.gjs-frame { border-radius: ${w}px }
|
|
5
|
-
`,!
|
|
6
|
-
|
|
7
|
-
[data-gjs-type="
|
|
8
|
-
[data-gjs-type="
|
|
9
|
-
|
|
5
|
+
`,!p&&document.body.appendChild(f)};e.on(S.frameLoadHead,n=>{if(!D.scrollableCanvas)return;const{window:u}=n,p=u.document,f=p.head,T=`${N}canvas-full-size-wrappers`,A=f.querySelector(`style[${T}]`)||p.createElement("style");A.setAttribute(T,"true"),A.innerHTML=`
|
|
6
|
+
body { height: auto !important; }
|
|
7
|
+
[data-gjs-type="wrapper"] { min-height: ${v} !important; }
|
|
8
|
+
[data-gjs-type="mjml"] { min-height: ${v} !important; }
|
|
9
|
+
[data-gjs-type="mj-body"] { min-height: ${v} !important; }
|
|
10
|
+
`,!f.contains(A)&&f.appendChild(A)});const R=()=>H.style.display="none",K=()=>H.style.display="",G=()=>{var f;if(!g)return;const n=t.getZoomMultiplier(),p=t.getRect().height*n-m*2;(f=o.getSelected())==null||f.set("height",`${Math.max(p,l)}px`),t.fitViewport({zoom:t.getZoom(),gap:x})},$=X(()=>{t.fitViewport({zoom:n=>n>100?100:n,ignoreHeight:!0,gap:x}),G(),L(),setTimeout(()=>{var u,p;const{em:n}=e;n.destroyed||((p=(u=e.getSelected())==null?void 0:u.getEl())==null||p.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),K(),s.isActive(E)?n.stopDefault():n.runDefault())},F)},100),Z=(n={})=>{n.options&&n.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:x})},q=()=>{R(),$()},B=()=>{b.overflowX="hidden",b.overflowY="auto"},V=()=>{C==null||C.disconnect(),$.clear()},_=[[o.events.select,q],[S.zoom,Z],[W,B],[e.events.destroy,V],[c.events.mountBefore,pe]];s.add(P,()=>{o.devices.reset(z),D.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),b.overflowY="hidden",L(!0),_.forEach(([n,u])=>e.off(n,u)),V(),s.run("studio:canvasReload")}),_.forEach(([n,u])=>e.on(n,u)),e.onReady(()=>{const n=t.getElement(),u=t.getFramesEl(),p=t.getCanvasView();H=t.getSpotsEl(),b=n.style,b.overflowX="hidden",u.style.transition=`transform ${d}s`,document.removeEventListener("keypress",p.onKeyPress),L(),C=new ResizeObserver(()=>{R(),$()}),C.observe(n.parentElement),$()}),ce({editor:e,licenseKey:h.licenseKey,plan:le,pluginName:O,cleanup:()=>{e.runCommand(P)}})},de=ie(me);module.exports=de;
|