@grapesjs/studio-sdk-plugins 1.0.14 → 1.0.15-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/components/Accordion.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionContent.d.ts +3 -0
- package/dist/accordionComponent/components/AccordionGroup.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionHeader.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionMarker.d.ts +3 -0
- package/dist/accordionComponent/index.cjs.d.ts +3 -0
- package/dist/accordionComponent/index.cjs.js +39 -0
- package/dist/accordionComponent/index.d.ts +3 -0
- package/dist/accordionComponent/index.es.d.ts +3 -0
- package/dist/accordionComponent/index.es.js +360 -0
- package/dist/accordionComponent/index.umd.js +39 -0
- package/dist/accordionComponent/types.d.ts +6 -0
- package/dist/accordionComponent/typesSchema.d.ts +22 -0
- package/dist/accordionComponent/utils.d.ts +22 -0
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +15 -15
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +5 -5
- package/dist/canvasFullSize/index.es.js +138 -118
- package/dist/canvasFullSize/index.umd.js +5 -5
- package/dist/canvasFullSize/typesSchema.d.ts +12 -8
- package/dist/flexComponent/blocks.d.ts +3 -0
- package/dist/flexComponent/components/FlexColumn.d.ts +4 -0
- package/dist/flexComponent/components/FlexRow.d.ts +4 -0
- package/dist/flexComponent/handlers.d.ts +19 -0
- package/dist/flexComponent/index.cjs.d.ts +3 -0
- package/dist/flexComponent/index.cjs.js +33 -0
- package/dist/flexComponent/index.d.ts +3 -0
- package/dist/flexComponent/index.es.d.ts +3 -0
- package/dist/flexComponent/index.es.js +715 -0
- package/dist/flexComponent/index.umd.js +33 -0
- package/dist/flexComponent/resizeDecorator.d.ts +50 -0
- package/dist/flexComponent/spots.d.ts +3 -0
- package/dist/flexComponent/types.d.ts +32 -0
- package/dist/flexComponent/typesSchema.d.ts +112 -0
- package/dist/flexComponent/utils.d.ts +63 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +128 -91
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/types.d.ts +7 -2
- package/dist/googleFontsAssetProvider/utils.d.ts +5 -0
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +39 -39
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +2 -0
- package/dist/index.cjs.js +105 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.es.d.ts +2 -0
- package/dist/index.es.js +6286 -5366
- package/dist/index.umd.js +105 -35
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +28 -28
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +31 -30
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/utils.d.ts +4 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +11 -11
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -25,7 +25,7 @@ async function K({
|
|
|
25
25
|
params: i,
|
|
26
26
|
body: u
|
|
27
27
|
}) {
|
|
28
|
-
const
|
|
28
|
+
const y = `${t || P({ isDev: !1, isStage: !1 })}${e}`, p = {
|
|
29
29
|
method: a,
|
|
30
30
|
headers: {
|
|
31
31
|
"Content-Type": "application/json",
|
|
@@ -33,7 +33,7 @@ async function K({
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
u && (p.body = JSON.stringify(u));
|
|
36
|
-
const d = i ? new URLSearchParams(i).toString() : "", s = d ? `?${d}` : "", c = await fetch(`${
|
|
36
|
+
const d = i ? new URLSearchParams(i).toString() : "", s = d ? `?${d}` : "", c = await fetch(`${y}${s}`, p);
|
|
37
37
|
if (!c.ok)
|
|
38
38
|
throw new Error(`HTTP error! status: ${c.status}`);
|
|
39
39
|
return c.json();
|
|
@@ -58,16 +58,16 @@ async function x({
|
|
|
58
58
|
cleanup: i
|
|
59
59
|
}) {
|
|
60
60
|
let u = "", h = !1;
|
|
61
|
-
const
|
|
61
|
+
const y = R(), p = (s) => {
|
|
62
62
|
console.warn("Cleanup plugin:", a, "Reason:", s), i();
|
|
63
63
|
}, d = (s = {}) => {
|
|
64
64
|
var C;
|
|
65
|
-
const { error: c, sdkLicense: E } = s,
|
|
65
|
+
const { error: c, sdkLicense: E } = s, v = (C = s.plan) == null ? void 0 : C.category;
|
|
66
66
|
if (!(E || s.license) || c)
|
|
67
67
|
p(c || "Invalid license");
|
|
68
|
-
else if (
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
else if (v) {
|
|
69
|
+
const T = A[t], b = A[v];
|
|
70
|
+
T > b && p({ pluginRequiredPlan: t, licensePlan: v });
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
e.on($, (s) => {
|
|
@@ -76,7 +76,7 @@ async function x({
|
|
|
76
76
|
d(s);
|
|
77
77
|
}), setTimeout(async () => {
|
|
78
78
|
if (!h) {
|
|
79
|
-
if (
|
|
79
|
+
if (y) return;
|
|
80
80
|
if (o) {
|
|
81
81
|
const s = await F({ licenseKey: o, pluginName: a, baseApiUrl: u });
|
|
82
82
|
s && d(s);
|
|
@@ -102,7 +102,7 @@ async function F(e) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
105
|
-
const a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new WeakMap(),
|
|
105
|
+
const a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new WeakMap(), y = {
|
|
106
106
|
emptyStates: [],
|
|
107
107
|
...t
|
|
108
108
|
}, p = (n, r) => {
|
|
@@ -122,7 +122,7 @@ const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
|
122
122
|
if (r && m)
|
|
123
123
|
s(n);
|
|
124
124
|
else if (!r && !m) {
|
|
125
|
-
const f = h.has(n) ? h.get(n) :
|
|
125
|
+
const f = h.has(n) ? h.get(n) : y.emptyStates.find((l) => p(n, l));
|
|
126
126
|
if (h.set(n, f), !f) return;
|
|
127
127
|
n.views.forEach((l) => {
|
|
128
128
|
const S = f.render({
|
|
@@ -148,16 +148,16 @@ const G = "canvasEmptyState", H = function(e, t = {}) {
|
|
|
148
148
|
}
|
|
149
149
|
}, E = (n) => {
|
|
150
150
|
i.has(n) && s(n);
|
|
151
|
-
},
|
|
151
|
+
}, v = ({ model: n }) => {
|
|
152
152
|
c(n.getComponent());
|
|
153
|
-
},
|
|
154
|
-
e.on(C, c), e.on(
|
|
153
|
+
}, L = e.Components.events, C = `${L.update}:components`, T = "component:mount", b = e.Canvas.events.frameLoadBody, U = L.removed;
|
|
154
|
+
e.on(C, c), e.on(T, c), e.on(U, E), e.on(b, v), x({
|
|
155
155
|
editor: e,
|
|
156
|
-
licenseKey:
|
|
156
|
+
licenseKey: y.licenseKey,
|
|
157
157
|
plan: w.startup,
|
|
158
158
|
pluginName: G,
|
|
159
159
|
cleanup: () => {
|
|
160
|
-
e.off(C, c), e.off(
|
|
160
|
+
e.off(C, c), e.off(T, c), e.off(U, E), e.off(b, v);
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}, B = j(H);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(y,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],g):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_canvasEmptyState=g())})(this,function(){"use strict";const y="app.grapesjs.com",g="app-stage.grapesjs.com",A=[y,g,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",N="license:check:end",P=()=>typeof window<"u",D=({isDev:e,isStage:t})=>`${e?"":`https://${t?g:y}`}/api`,_=()=>{const e=P()&&window.location.hostname;return!!e&&(A.includes(e)||A.some(t=>e.endsWith(t)))};function j(e){return typeof e=="function"}async function R({path:e,baseApiUrl:t,method:o="GET",headers:a={},params:i,body:u}){const w=`${t||D({isDev:!1,isStage:!1})}${e}`,p={method:o,headers:{"Content-Type":"application/json",...a}};u&&(p.body=JSON.stringify(u));const d=i?new URLSearchParams(i).toString():"",s=d?`?${d}`:"",c=await fetch(`${w}${s}`,p);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return c.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 K(e){const t=e;return t.init=o=>a=>e(a,o),t}const x=e=>K(e);async function O({editor:e,plan:t,pluginName:o,licenseKey:a,cleanup:i}){let u="",h=!1;const w=_(),p=s=>{console.warn("Cleanup plugin:",o,"Reason:",s),i()},d=(s={})=>{var S;const{error:c,sdkLicense:T}=s,C=(S=s.plan)==null?void 0:S.category;if(!(T||s.license)||c)p(c||"Invalid license");else if(C){const
|
|
1
|
+
(function(y,g){typeof exports=="object"&&typeof module<"u"?module.exports=g(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],g):(y=typeof globalThis<"u"?globalThis:y||self,y.StudioSdkPlugins_canvasEmptyState=g())})(this,function(){"use strict";const y="app.grapesjs.com",g="app-stage.grapesjs.com",A=[y,g,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",N="license:check:end",P=()=>typeof window<"u",D=({isDev:e,isStage:t})=>`${e?"":`https://${t?g:y}`}/api`,_=()=>{const e=P()&&window.location.hostname;return!!e&&(A.includes(e)||A.some(t=>e.endsWith(t)))};function j(e){return typeof e=="function"}async function R({path:e,baseApiUrl:t,method:o="GET",headers:a={},params:i,body:u}){const w=`${t||D({isDev:!1,isStage:!1})}${e}`,p={method:o,headers:{"Content-Type":"application/json",...a}};u&&(p.body=JSON.stringify(u));const d=i?new URLSearchParams(i).toString():"",s=d?`?${d}`:"",c=await fetch(`${w}${s}`,p);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);return c.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 K(e){const t=e;return t.init=o=>a=>e(a,o),t}const x=e=>K(e);async function O({editor:e,plan:t,pluginName:o,licenseKey:a,cleanup:i}){let u="",h=!1;const w=_(),p=s=>{console.warn("Cleanup plugin:",o,"Reason:",s),i()},d=(s={})=>{var S;const{error:c,sdkLicense:T}=s,C=(S=s.plan)==null?void 0:S.category;if(!(T||s.license)||c)p(c||"Invalid license");else if(C){const b=I[t],L=I[C];b>L&&p({pluginRequiredPlan:t,licensePlan:C})}};e.on($,s=>{u=s==null?void 0:s.baseApiUrl,h=!0}),e.on(N,s=>{d(s)}),setTimeout(async()=>{if(!h){if(w)return;if(a){const s=await q({licenseKey:a,pluginName:o,baseApiUrl:u});s&&d(s)}else p("The `licenseKey` option not provided")}},2e3)}async function q(e){const{licenseKey:t,pluginName:o,baseApiUrl:a}=e;try{return(await R({baseApiUrl:a,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const F="canvasEmptyState";return x(function(e,t={}){const o=new WeakMap,a=new WeakMap,i=new WeakMap,u=new Set,h=new WeakMap,w={emptyStates:[],...t},p=(n,r)=>{let m=!1;const{isValid:f}=r;return Array.isArray(f)?m=f.some(l=>n.is(l)):j(f)?m=f({component:n,editor:e}):m=n.is(f),m},d=n=>{const r=o.get(n);o.delete(n),r==null||r()},s=n=>{n.views.forEach(r=>d(r)),i.delete(n)},c=n=>{if(!(!n||u.has(n)))try{u.add(n);const r=n.components().length>0,m=i.get(n);if(r&&m)s(n);else if(!r&&!m){const f=h.has(n)?h.get(n):w.emptyStates.find(l=>p(n,l));if(h.set(n,f),!f)return;n.views.forEach(l=>{const U=f.render({editor:e,component:n,componentView:l,mount:E=>{a.set(l,E),i.set(n,!0);const W=l.getChildrenContainer();W==null||W.appendChild(E)},unmount:()=>d(l)});o.set(l,()=>{U==null||U();const E=a.get(l);E==null||E.remove()})})}}finally{u.delete(n)}},T=n=>{i.has(n)&&s(n)},C=({model:n})=>{c(n.getComponent())},k=e.Components.events,S=`${k.update}:components`,b="component:mount",L=e.Canvas.events.frameLoadBody,M=k.removed;e.on(S,c),e.on(b,c),e.on(M,T),e.on(L,C),O({editor:e,licenseKey:w.licenseKey,plan:v.startup,pluginName:F,cleanup:()=>{e.off(S,c),e.off(b,c),e.off(M,T),e.off(L,C)}})})});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";require("grapesjs");function
|
|
2
|
-
.gjs-frame-wrapper { transition:
|
|
3
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
4
|
-
.gjs-frame { border-radius: ${
|
|
5
|
-
`,!
|
|
1
|
+
"use strict";require("grapesjs");function j(e,a,n){let t,o,c,p,d;const r=a;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 R="app.grapesjs.com",U="app-stage.grapesjs.com",k=[R,U,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],K="license:check:start",q="license:check:end",F=()=>typeof window<"u",V=({isDev:e,isStage:a})=>`${e?"":`https://${a?U:R}`}/api`,X=()=>{const e=F()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(a=>e.endsWith(a)))};async function Y({path:e,baseApiUrl:a,method:n="GET",headers:t={},params:o,body:c}){const d=`${a||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 b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{});const z={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function B(e){const a=e;return a.init=n=>t=>e(t,n),a}const G=e=>B(e);async function Z({editor:e,plan:a,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 C;const{error:l,sdkLicense:D}=s,y=(C=s.plan)==null?void 0:C.category;if(!(D||s.license)||l)r(l||"Invalid license");else if(y){const S=z[a],T=z[y];S>T&&r({pluginRequiredPlan:a,licensePlan:y})}};e.on(K,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(q,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:a,pluginName:n,baseApiUrl:t}=e;try{return(await Y({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 N="canvasFullSize",Q=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:d,canvasTransition:r,deviceMaxWidth:u,deviceMinHeigth:s,frameBorderRadius:l,frameTransition:D}=c,y=`${s}px`,E=n.events,C=`${t.events.stopCommand}core:preview`,S=n.getConfig(),T=`${N}:disable`,P=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",y)});const L=i=>{const v="data-gs-plg-full-size",f=document.querySelector(`style[${v}]`);if(i&&f)return f.remove();const m=f||document.createElement("style"),h=n.getZoomMultiplier();m.setAttribute(v,"true"),m.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${D}s !important; }
|
|
3
|
+
.gjs-frame-wrapper__bottom { height: ${p*h}px }
|
|
4
|
+
.gjs-frame { border-radius: ${l}px }
|
|
5
|
+
`,!f&&document.body.appendChild(m)};e.on(E.frameLoadHead,i=>{if(!S.scrollableCanvas)return;const{window:v}=i,f=v.document,m=f.head,h="data-gs-plg-wrapper-style",w=m.querySelector(`style[${h}]`)||f.createElement("style");w.setAttribute(h,"true"),w.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${y}; }`,!m.contains(w)&&m.appendChild(w)}),e.onReady(()=>{const i=n.getSpotsEl(),v=n.getElement(),f=n.getFramesEl(),m=r*1e3,h=v.style;h.overflowX="hidden",f.style.transition=`transform ${r}s`;const w={x:d,y:p};L();const A=()=>i.style.display="none",_=()=>i.style.display="",$=j(()=>{n.fitViewport({zoom:g=>g>100?100:g,ignoreHeight:!0,gap:w}),L(),setTimeout(()=>{var g,W;e.em.destroyed||((W=(g=e.getSelected())==null?void 0:g.getEl())==null||W.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),_())},m)},100),H=new ResizeObserver(()=>{A(),$()});H.observe(v.parentElement);const M=()=>{A(),$()},O=(g={})=>{g.options&&g.options.from!=="fitViewport"&&n.fitViewport({zoom:n.getZoom(),ignoreHeight:!0,gap:w})},x=()=>{h.overflowX="hidden",h.overflowY="auto"},I=()=>{H.disconnect(),$.clear()};e.on(o.events.select,M),e.on(E.zoom,O),e.on(C,x),e.on(e.events.destroy,I),$(),t.add(T,()=>{o.devices.reset(P),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(E.zoom,O),e.off(C,x),I(),t.run("studio:canvasReload")})}),Z({editor:e,licenseKey:c.licenseKey,plan:b.startup,pluginName:N,cleanup:()=>{e.runCommand(T)}})},ee=G(Q);module.exports=ee;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import "grapesjs";
|
|
2
|
-
function
|
|
3
|
-
let t,
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
2
|
+
function j(e, a, n) {
|
|
3
|
+
let t, o, c, p, d;
|
|
4
|
+
const r = a;
|
|
5
|
+
function u() {
|
|
6
|
+
const l = Date.now() - p;
|
|
7
|
+
l < r && l >= 0 ? t = setTimeout(u, r - l) : (t = null, d = e.apply(c, o), c = o = null);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
return
|
|
9
|
+
const s = function() {
|
|
10
|
+
return c = this, o = arguments, p = Date.now(), t || (t = setTimeout(u, r)), d;
|
|
11
11
|
};
|
|
12
|
-
return
|
|
12
|
+
return s.clear = function() {
|
|
13
13
|
t && (clearTimeout(t), t = null);
|
|
14
|
-
},
|
|
15
|
-
t && (
|
|
16
|
-
},
|
|
14
|
+
}, s.flush = function() {
|
|
15
|
+
t && (d = e.apply(c, o), c = o = null, clearTimeout(t), t = null);
|
|
16
|
+
}, s;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const R = "app.grapesjs.com", U = "app-stage.grapesjs.com", k = [
|
|
19
|
+
R,
|
|
20
|
+
U,
|
|
21
21
|
"localhost",
|
|
22
22
|
"127.0.0.1",
|
|
23
23
|
".local-credentialless.webcontainer.io",
|
|
@@ -26,155 +26,175 @@ const $ = "app.grapesjs.com", D = "app-stage.grapesjs.com", C = [
|
|
|
26
26
|
// For stackblitz.com demos
|
|
27
27
|
"-sandpack.codesandbox.io"
|
|
28
28
|
// For Sandpack demos
|
|
29
|
-
],
|
|
30
|
-
const e =
|
|
31
|
-
return !!e && (
|
|
29
|
+
], K = "license:check:start", F = "license:check:end", q = () => typeof window < "u", V = ({ isDev: e, isStage: a }) => `${e ? "" : `https://${a ? U : R}`}/api`, X = () => {
|
|
30
|
+
const e = q() && window.location.hostname;
|
|
31
|
+
return !!e && (k.includes(e) || k.some((a) => e.endsWith(a)));
|
|
32
32
|
};
|
|
33
|
-
async function
|
|
33
|
+
async function Y({
|
|
34
34
|
path: e,
|
|
35
|
-
baseApiUrl:
|
|
36
|
-
method:
|
|
35
|
+
baseApiUrl: a,
|
|
36
|
+
method: n = "GET",
|
|
37
37
|
headers: t = {},
|
|
38
|
-
params:
|
|
39
|
-
body:
|
|
38
|
+
params: o,
|
|
39
|
+
body: c
|
|
40
40
|
}) {
|
|
41
|
-
const
|
|
42
|
-
method:
|
|
41
|
+
const d = `${a || V({ isDev: !1, isStage: !1 })}${e}`, r = {
|
|
42
|
+
method: n,
|
|
43
43
|
headers: {
|
|
44
44
|
"Content-Type": "application/json",
|
|
45
45
|
...t
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
throw new Error(`HTTP error! status: ${
|
|
52
|
-
return
|
|
48
|
+
c && (r.body = JSON.stringify(c));
|
|
49
|
+
const u = o ? new URLSearchParams(o).toString() : "", s = u ? `?${u}` : "", l = await fetch(`${d}${s}`, r);
|
|
50
|
+
if (!l.ok)
|
|
51
|
+
throw new Error(`HTTP error! status: ${l.status}`);
|
|
52
|
+
return l.json();
|
|
53
53
|
}
|
|
54
|
-
var
|
|
55
|
-
const
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
54
|
+
var b = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(b || {});
|
|
55
|
+
const z = {
|
|
56
|
+
[b.free]: 0,
|
|
57
|
+
[b.startup]: 10,
|
|
58
|
+
[b.business]: 20,
|
|
59
|
+
[b.enterprise]: 30
|
|
60
60
|
};
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
return
|
|
61
|
+
function B(e) {
|
|
62
|
+
const a = e;
|
|
63
|
+
return a.init = (n) => (t) => e(t, n), a;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
async function
|
|
65
|
+
const G = (e) => /* @__PURE__ */ B(e);
|
|
66
|
+
async function Z({
|
|
67
67
|
editor: e,
|
|
68
|
-
plan:
|
|
69
|
-
pluginName:
|
|
68
|
+
plan: a,
|
|
69
|
+
pluginName: n,
|
|
70
70
|
licenseKey: t,
|
|
71
|
-
cleanup:
|
|
71
|
+
cleanup: o
|
|
72
72
|
}) {
|
|
73
|
-
let
|
|
74
|
-
const
|
|
75
|
-
console.warn("Cleanup plugin:",
|
|
76
|
-
},
|
|
77
|
-
var
|
|
78
|
-
const { error:
|
|
79
|
-
if (!(
|
|
80
|
-
l
|
|
81
|
-
else if (
|
|
82
|
-
const
|
|
83
|
-
|
|
73
|
+
let c = "", p = !1;
|
|
74
|
+
const d = X(), r = (s) => {
|
|
75
|
+
console.warn("Cleanup plugin:", n, "Reason:", s), o();
|
|
76
|
+
}, u = (s = {}) => {
|
|
77
|
+
var C;
|
|
78
|
+
const { error: l, sdkLicense: D } = s, y = (C = s.plan) == null ? void 0 : C.category;
|
|
79
|
+
if (!(D || s.license) || l)
|
|
80
|
+
r(l || "Invalid license");
|
|
81
|
+
else if (y) {
|
|
82
|
+
const S = z[a], T = z[y];
|
|
83
|
+
S > T && r({ pluginRequiredPlan: a, licensePlan: y });
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
e.on(
|
|
87
|
-
|
|
88
|
-
}), e.on(
|
|
89
|
-
|
|
86
|
+
e.on(K, (s) => {
|
|
87
|
+
c = s == null ? void 0 : s.baseApiUrl, p = !0;
|
|
88
|
+
}), e.on(F, (s) => {
|
|
89
|
+
u(s);
|
|
90
90
|
}), setTimeout(async () => {
|
|
91
|
-
if (!
|
|
92
|
-
if (
|
|
91
|
+
if (!p) {
|
|
92
|
+
if (d) return;
|
|
93
93
|
if (t) {
|
|
94
|
-
const
|
|
95
|
-
|
|
94
|
+
const s = await J({ licenseKey: t, pluginName: n, baseApiUrl: c });
|
|
95
|
+
s && u(s);
|
|
96
96
|
} else
|
|
97
|
-
|
|
97
|
+
r("The `licenseKey` option not provided");
|
|
98
98
|
}
|
|
99
99
|
}, 2e3);
|
|
100
100
|
}
|
|
101
|
-
async function
|
|
102
|
-
const { licenseKey:
|
|
101
|
+
async function J(e) {
|
|
102
|
+
const { licenseKey: a, pluginName: n, baseApiUrl: t } = e;
|
|
103
103
|
try {
|
|
104
|
-
return (await
|
|
104
|
+
return (await Y({
|
|
105
105
|
baseApiUrl: t,
|
|
106
|
-
path: `/sdk/${
|
|
106
|
+
path: `/sdk/${a || "na"}`,
|
|
107
107
|
method: "POST",
|
|
108
108
|
params: {
|
|
109
109
|
d: window.location.hostname,
|
|
110
|
-
pn:
|
|
110
|
+
pn: n
|
|
111
111
|
}
|
|
112
112
|
})).result || {};
|
|
113
|
-
} catch (
|
|
114
|
-
return console.error("Error during SDK license check:",
|
|
113
|
+
} catch (o) {
|
|
114
|
+
return console.error("Error during SDK license check:", o), !1;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
const { Canvas:
|
|
117
|
+
const N = "canvasFullSize", Q = function(e, a = {}) {
|
|
118
|
+
const { Canvas: n, Commands: t, Devices: o } = e, c = {
|
|
119
119
|
deviceMaxWidth: 1200,
|
|
120
120
|
deviceMinHeigth: 500,
|
|
121
|
-
deviceBorderRadius: 5,
|
|
122
121
|
canvasOffsetY: 30,
|
|
123
122
|
canvasOffsetX: 50,
|
|
124
123
|
canvasTransition: 0.3,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
frameBorderRadius: 5,
|
|
125
|
+
frameTransition: 0.3,
|
|
126
|
+
...a
|
|
127
|
+
}, {
|
|
128
|
+
canvasOffsetY: p,
|
|
129
|
+
canvasOffsetX: d,
|
|
130
|
+
canvasTransition: r,
|
|
131
|
+
deviceMaxWidth: u,
|
|
132
|
+
deviceMinHeigth: s,
|
|
133
|
+
frameBorderRadius: l,
|
|
134
|
+
frameTransition: D
|
|
135
|
+
} = c, y = `${s}px`, E = n.events, C = `${t.events.stopCommand}core:preview`, S = n.getConfig(), T = `${N}:disable`, P = o.getAll().map((i) => ({ ...i.attributes }));
|
|
136
|
+
S.scrollableCanvas = !0, o.getAll().map((i) => {
|
|
137
|
+
!i.get("width") && i.set("width", `${u}px`), !i.get("height") && i.set("height", "auto"), !i.get("minHeight") && i.set("minHeight", y);
|
|
129
138
|
});
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
139
|
+
const L = (i) => {
|
|
140
|
+
const v = "data-gs-plg-full-size", f = document.querySelector(`style[${v}]`);
|
|
141
|
+
if (i && f)
|
|
142
|
+
return f.remove();
|
|
143
|
+
const m = f || document.createElement("style"), h = n.getZoomMultiplier();
|
|
144
|
+
m.setAttribute(v, "true"), m.innerHTML = `
|
|
145
|
+
.gjs-frame-wrapper { transition: width ${D}s !important; }
|
|
146
|
+
.gjs-frame-wrapper__bottom { height: ${p * h}px }
|
|
147
|
+
.gjs-frame { border-radius: ${l}px }
|
|
148
|
+
`, !f && document.body.appendChild(m);
|
|
137
149
|
};
|
|
138
|
-
e.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
e.on(E.frameLoadHead, (i) => {
|
|
151
|
+
if (!S.scrollableCanvas) return;
|
|
152
|
+
const { window: v } = i, f = v.document, m = f.head, h = "data-gs-plg-wrapper-style", w = m.querySelector(`style[${h}]`) || f.createElement("style");
|
|
153
|
+
w.setAttribute(h, "true"), w.innerHTML = `[data-gjs-type="wrapper"] { min-height: ${y}; }`, !m.contains(w) && m.appendChild(w);
|
|
154
|
+
}), e.onReady(() => {
|
|
155
|
+
const i = n.getSpotsEl(), v = n.getElement(), f = n.getFramesEl(), m = r * 1e3, h = v.style;
|
|
156
|
+
h.overflowX = "hidden", f.style.transition = `transform ${r}s`;
|
|
157
|
+
const w = { x: d, y: p };
|
|
158
|
+
L();
|
|
159
|
+
const A = () => i.style.display = "none", _ = () => i.style.display = "", $ = j(() => {
|
|
160
|
+
n.fitViewport({
|
|
161
|
+
zoom: (g) => g > 100 ? 100 : g,
|
|
146
162
|
ignoreHeight: !0,
|
|
147
|
-
gap:
|
|
148
|
-
}),
|
|
149
|
-
var
|
|
150
|
-
e.em.destroyed || ((
|
|
151
|
-
},
|
|
152
|
-
}, 100),
|
|
153
|
-
|
|
163
|
+
gap: w
|
|
164
|
+
}), L(), setTimeout(() => {
|
|
165
|
+
var g, W;
|
|
166
|
+
e.em.destroyed || ((W = (g = e.getSelected()) == null ? void 0 : g.getEl()) == null || W.scrollIntoView({ block: "nearest" }), e.refresh({ tools: !0 }), _());
|
|
167
|
+
}, m);
|
|
168
|
+
}, 100), H = new ResizeObserver(() => {
|
|
169
|
+
A(), $();
|
|
154
170
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
zoom:
|
|
171
|
+
H.observe(v.parentElement);
|
|
172
|
+
const M = () => {
|
|
173
|
+
A(), $();
|
|
174
|
+
}, O = (g = {}) => {
|
|
175
|
+
g.options && g.options.from !== "fitViewport" && n.fitViewport({
|
|
176
|
+
zoom: n.getZoom(),
|
|
161
177
|
ignoreHeight: !0,
|
|
162
|
-
gap:
|
|
178
|
+
gap: w
|
|
163
179
|
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
180
|
+
}, x = () => {
|
|
181
|
+
h.overflowX = "hidden", h.overflowY = "auto";
|
|
182
|
+
}, I = () => {
|
|
183
|
+
H.disconnect(), $.clear();
|
|
184
|
+
};
|
|
185
|
+
e.on(o.events.select, M), e.on(E.zoom, O), e.on(C, x), e.on(e.events.destroy, I), $(), t.add(T, () => {
|
|
186
|
+
o.devices.reset(P), 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(E.zoom, O), e.off(C, x), I(), t.run("studio:canvasReload");
|
|
187
|
+
});
|
|
188
|
+
}), Z({
|
|
170
189
|
editor: e,
|
|
171
|
-
licenseKey:
|
|
172
|
-
plan:
|
|
173
|
-
pluginName:
|
|
190
|
+
licenseKey: c.licenseKey,
|
|
191
|
+
plan: b.startup,
|
|
192
|
+
pluginName: N,
|
|
174
193
|
cleanup: () => {
|
|
194
|
+
e.runCommand(T);
|
|
175
195
|
}
|
|
176
196
|
});
|
|
177
|
-
},
|
|
197
|
+
}, te = G(Q);
|
|
178
198
|
export {
|
|
179
|
-
|
|
199
|
+
te as default
|
|
180
200
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
.gjs-frame-wrapper { transition:
|
|
3
|
-
.gjs-frame-wrapper__bottom { height: ${
|
|
4
|
-
.gjs-frame { border-radius: ${
|
|
5
|
-
`,!
|
|
1
|
+
(function(C,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],y):(C=typeof globalThis<"u"?globalThis:C||self,C.StudioSdkPlugins_canvasFullSize=y())})(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 y="app.grapesjs.com",H="app-stage.grapesjs.com",M=[y,H,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:start",_="license:check:end",F=()=>typeof window<"u",K=({isDev:e,isStage:i})=>`${e?"":`https://${i?H:y}`}/api`,q=()=>{const e=F()&&window.location.hostname;return!!e&&(M.includes(e)||M.some(i=>e.endsWith(i)))};async function V({path:e,baseApiUrl:i,method:n="GET",headers:t={},params:o,body:c}){const d=`${i||K({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 b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{});const O={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function X(e){const i=e;return i.init=n=>t=>e(t,n),i}const Y=e=>X(e);async function B({editor:e,plan:i,pluginName:n,licenseKey:t,cleanup:o}){let c="",p=!1;const d=q(),r=s=>{console.warn("Cleanup plugin:",n,"Reason:",s),o()},u=(s={})=>{var T;const{error:l,sdkLicense:x}=s,S=(T=s.plan)==null?void 0:T.category;if(!(x||s.license)||l)r(l||"Invalid license");else if(S){const E=O[i],D=O[S];E>D&&r({pluginRequiredPlan:i,licensePlan:S})}};e.on(U,s=>{c=s==null?void 0:s.baseApiUrl,p=!0}),e.on(_,s=>{u(s)}),setTimeout(async()=>{if(!p){if(d)return;if(t){const s=await G({licenseKey:t,pluginName:n,baseApiUrl:c});s&&u(s)}else r("The `licenseKey` option not provided")}},2e3)}async function G(e){const{licenseKey:i,pluginName:n,baseApiUrl:t}=e;try{return(await V({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 j="canvasFullSize";return Y(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:x}=c,S=`${s}px`,$=n.events,T=`${t.events.stopCommand}core:preview`,E=n.getConfig(),D=`${j}:disable`,Z=o.getAll().map(a=>({...a.attributes}));E.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",S)});const A=a=>{const v="data-gs-plg-full-size",f=document.querySelector(`style[${v}]`);if(a&&f)return f.remove();const m=f||document.createElement("style"),h=n.getZoomMultiplier();m.setAttribute(v,"true"),m.innerHTML=`
|
|
2
|
+
.gjs-frame-wrapper { transition: width ${x}s !important; }
|
|
3
|
+
.gjs-frame-wrapper__bottom { height: ${p*h}px }
|
|
4
|
+
.gjs-frame { border-radius: ${l}px }
|
|
5
|
+
`,!f&&document.body.appendChild(m)};e.on($.frameLoadHead,a=>{if(!E.scrollableCanvas)return;const{window:v}=a,f=v.document,m=f.head,h="data-gs-plg-wrapper-style",w=m.querySelector(`style[${h}]`)||f.createElement("style");w.setAttribute(h,"true"),w.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${S}; }`,!m.contains(w)&&m.appendChild(w)}),e.onReady(()=>{const a=n.getSpotsEl(),v=n.getElement(),f=n.getFramesEl(),m=r*1e3,h=v.style;h.overflowX="hidden",f.style.transition=`transform ${r}s`;const w={x:d,y:p};A();const k=()=>a.style.display="none",J=()=>a.style.display="",L=C(()=>{n.fitViewport({zoom:g=>g>100?100:g,ignoreHeight:!0,gap:w}),A(),setTimeout(()=>{var g,R;e.em.destroyed||((R=(g=e.getSelected())==null?void 0:g.getEl())==null||R.scrollIntoView({block:"nearest"}),e.refresh({tools:!0}),J())},m)},100),z=new ResizeObserver(()=>{k(),L()});z.observe(v.parentElement);const I=()=>{k(),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"},P=()=>{z.disconnect(),L.clear()};e.on(o.events.select,I),e.on($.zoom,W),e.on(T,N),e.on(e.events.destroy,P),L(),t.add(D,()=>{o.devices.reset(Z),E.scrollableCanvas=!1,n.getModel().updateDevice(),n.setZoom(100),n.setCoords(0,0),h.overflowY="hidden",A(!0),e.off(o.events.select,I),e.off($.zoom,W),e.off(T,N),P(),t.run("studio:canvasReload")})}),B({editor:e,licenseKey:c.licenseKey,plan:b.startup,pluginName:j,cleanup:()=>{e.runCommand(D)}})})});
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { SDKPluginOptions } from '../utils';
|
|
2
2
|
export interface CanvasFullSizeOptions extends SDKPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* @default 1200
|
|
5
|
+
*/
|
|
6
|
+
deviceMaxWidth?: number;
|
|
7
|
+
/**
|
|
8
|
+
* @default 500
|
|
9
|
+
*/
|
|
10
|
+
deviceMinHeigth?: number;
|
|
3
11
|
/**
|
|
4
12
|
* @default 30
|
|
5
13
|
*/
|
|
@@ -13,15 +21,11 @@ export interface CanvasFullSizeOptions extends SDKPluginOptions {
|
|
|
13
21
|
*/
|
|
14
22
|
canvasTransition?: number;
|
|
15
23
|
/**
|
|
16
|
-
* @default
|
|
17
|
-
*/
|
|
18
|
-
deviceMaxWidth?: number;
|
|
19
|
-
/**
|
|
20
|
-
* @default 1200
|
|
24
|
+
* @default 5
|
|
21
25
|
*/
|
|
22
|
-
|
|
26
|
+
frameBorderRadius?: number;
|
|
23
27
|
/**
|
|
24
|
-
* @default
|
|
28
|
+
* @default 0.3
|
|
25
29
|
*/
|
|
26
|
-
|
|
30
|
+
frameTransition?: number;
|
|
27
31
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FlexComponentOptions, FlexGetGapFnProps, FlexGetParentSizeFnProps, FlexGetSizeFnProps, FlexIsParentVerticalFnProps, FlexSetGapFnProps, FlexSetSizeFnProps } from './types';
|
|
2
|
+
export interface SizeHandler {
|
|
3
|
+
getSize(props: FlexGetSizeFnProps): number;
|
|
4
|
+
setSize(props: FlexSetSizeFnProps): void;
|
|
5
|
+
}
|
|
6
|
+
export interface GapHandler {
|
|
7
|
+
getGap(props: FlexGetGapFnProps): number;
|
|
8
|
+
setGap(props: FlexSetGapFnProps): void;
|
|
9
|
+
isGapSupported(): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ParentSizeHandler {
|
|
12
|
+
getParentSize(props: FlexGetParentSizeFnProps): number;
|
|
13
|
+
isLayoutVertical(props: FlexIsParentVerticalFnProps): boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function getHandlers(config: FlexComponentOptions): {
|
|
16
|
+
sizeHandler: SizeHandler;
|
|
17
|
+
gapHandler: GapHandler;
|
|
18
|
+
parentSizeHandler: ParentSizeHandler;
|
|
19
|
+
};
|