@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.
Files changed (50) hide show
  1. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  2. package/dist/canvasAbsoluteMode/index.es.js +98 -97
  3. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  4. package/dist/canvasFullSize/index.cjs.js +8 -7
  5. package/dist/canvasFullSize/index.es.js +145 -138
  6. package/dist/canvasFullSize/index.umd.js +9 -8
  7. package/dist/canvasFullSize/typesSchema.d.ts +5 -0
  8. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  9. package/dist/googleFontsAssetProvider/index.es.js +11 -11
  10. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  11. package/dist/iconifyComponent/index.cjs.js +2 -2
  12. package/dist/iconifyComponent/index.es.js +13 -13
  13. package/dist/iconifyComponent/index.umd.js +2 -2
  14. package/dist/index.cjs.d.ts +1 -0
  15. package/dist/index.cjs.js +192 -95
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.es.d.ts +1 -0
  18. package/dist/index.es.js +7577 -7242
  19. package/dist/index.umd.js +192 -95
  20. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  21. package/dist/layoutSidebarButtons/index.es.js +156 -154
  22. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  23. package/dist/presetPrintable/index.cjs.js +4 -4
  24. package/dist/presetPrintable/index.es.js +59 -59
  25. package/dist/presetPrintable/index.umd.js +1 -1
  26. package/dist/prosemirror/index.cjs.js +5 -5
  27. package/dist/prosemirror/index.es.js +100 -100
  28. package/dist/prosemirror/index.umd.js +1 -1
  29. package/dist/rteTinyMce/index.cjs.js +2 -2
  30. package/dist/rteTinyMce/index.es.js +10 -10
  31. package/dist/rteTinyMce/index.umd.js +1 -1
  32. package/dist/shapeDividerComponent/index.cjs.d.ts +3 -0
  33. package/dist/shapeDividerComponent/index.cjs.js +97 -0
  34. package/dist/shapeDividerComponent/index.d.ts +3 -0
  35. package/dist/shapeDividerComponent/index.es.d.ts +3 -0
  36. package/dist/shapeDividerComponent/index.es.js +427 -0
  37. package/dist/shapeDividerComponent/index.umd.js +97 -0
  38. package/dist/shapeDividerComponent/shared.d.ts +3 -0
  39. package/dist/shapeDividerComponent/types.d.ts +10 -0
  40. package/dist/shapeDividerComponent/typesSchema.d.ts +9 -0
  41. package/dist/swiperComponent/index.cjs.js +9 -9
  42. package/dist/swiperComponent/index.es.js +130 -122
  43. package/dist/swiperComponent/index.umd.js +5 -5
  44. package/dist/tableComponent/index.cjs.js +1 -1
  45. package/dist/tableComponent/index.es.js +9 -9
  46. package/dist/tableComponent/index.umd.js +1 -1
  47. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  48. package/dist/youtubeAssetProvider/index.es.js +34 -34
  49. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  50. 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:u="GET",headers:l={},params:d,body:n}){const s=`${a||z({isDev:!1,isStage:!1})}${e}`,m={method:u,headers:{"Content-Type":"application/json",...l}};n&&(m.body=JSON.stringify(n));const h=d?new URLSearchParams(d).toString():"",t=h?`?${h}`:"",o=await fetch(`${s}${t}`,m);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.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=u=>l=>e(l,u),a}const ne=e=>te(e);async function se({editor:e,plan:a,pluginName:u,licenseKey:l,cleanup:d}){let n="",c=!1;const s=Q(),m=t=>{console.warn("Cleanup plugin:",u,"Reason:",t),d()},h=(t={})=>{var E;const{error:o,sdkLicense:r}=t,i=(E=t.plan)==null?void 0:E.category;if(!(r||t.license)||o)m(o||"Invalid license");else if(i){const b=W[a],v=W[i];b>v&&m({pluginRequiredPlan:a,licensePlan:i})}};e.on(F,t=>{n=t==null?void 0:t.baseApiUrl,c=!0}),e.on(q,t=>{h(t)}),setTimeout(async()=>{if(!c){if(s)return;if(l){const t=await oe({licenseKey:l,pluginName:u,baseApiUrl:n});t&&h(t)}else m("The `licenseKey` option not provided")}},2e3)}async function oe(e){const{licenseKey:a,pluginName:u,baseApiUrl:l}=e;try{return(await ee({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const ce="canvasAbsoluteMode",ie=L.startup,ae=(e,a,u)=>{const l=u.enableAbsolute??(m=>m.hasAbsolute),n=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0];if(!n)return;const c=n.getEl();return{result:Z(l)?l({component:n,hasAbsolute:!!c&&getComputedStyle(c).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function B({guideMatched:e,canvasView:a}){var P;const u=e.guide.x===void 0?"y":"x";let l=0,d=0,n=0,c=0;const{guide:s,matched:m}=e,h=a.getElBoxRect(s.componentView.el),t=a.getElBoxRect(((P=m.componentView)==null?void 0:P.el)||m.componentEl),o=h.y,r=h.y+h.height,i=h.x,S=h.x+h.width,E=t.y,b=t.y+t.height,v=t.x,_=t.x+t.width,x=Math.max(0,o-b),p=Math.max(0,E-r),C=Math.max(0,i-_),M=Math.max(0,v-S),f=x>p,g=C>M,y=s.type;return u==="x"&&(y==="l"?(l=i,f?(d=b,n=x):(d=r,n=p)):y==="r"?(l=S,f?(d=b,n=x):(d=r,n=p)):y==="x"&&(l=i-(i-S)/2,f?(d=b,n=x):(d=r,n=p))),u==="y"&&(y==="t"?(d=o,g?(l=_,c=C):(l=S,c=M)):y==="b"?(d=r,g?(l=_,c=C):(l=S,c=M)):y==="y"&&(d=o-(o-r)/2,g?(l=_,c=C):(l=S,c=M))),{axis:u,x:l,y:d,width:c,height:n}}function le({guideMatched:e,component:a,canvasView:u}){const l=e.guide.x===void 0?"x":"y",{guide:d,matched:n}=e,c=d.type,s=n.type,m=u.getElementPos(d.componentView.el).rect,h=u.getElementPos(n.componentView.el).rect;if(l==="x"){const t=m.height,o=h.top,r=h.top+h.height;let i=0;c==="t"?s==="t"?i=o-t:s==="b"?i=r-t:s==="y"&&(i=o-t-(o-r)/2):c==="b"?s==="t"?i=o-t*2:s==="b"?i=r-t*2:s==="y"&&(i=o-t*2-(o-r)/2):c==="y"&&(s==="t"?i=o-t*1.5:s==="b"?i=r-t*1.5:s==="y"&&(i=o-t*1.5-(o-r)/2)),a.addStyle({top:`${i-5}px`},{partial:!0})}if(l==="y"){const t=m.width,o=h.left,r=h.left+h.width;let i=0;c==="l"?s==="l"?i=o:s==="r"?i=r:s==="x"&&(i=o-(o-r)/2):c==="r"?s==="l"?i=o-t:s==="r"?i=r-t:s==="x"&&(i=o-t-(o-r)/2):c==="x"&&(s==="l"?i=o-t/2:s==="r"&&(i=r-t/2)),a.addStyle({left:`${i}px`},{partial:!0})}}function H({snapping:e,editor:a,props:u}){var R,w;const{command:l,guidesMatched:d}=u,n=u.component,c=n.getEl(),s=a.Canvas.getCanvasView(),{x:m,y:h}=e??{x:10,y:10},t=l.opts.event,o=t.clientX,r=t.clientY;if(!n.__lastSnappedPosition){const A=s.getElBoxRect(c),D=o-A.x,T=r-A.y;n.__lastSnappedPosition={left:A.x,top:A.y},n.__dragOffset={x:D,y:T}}const i=((R=n.__dragOffset)==null?void 0:R.x)||0,S=((w=n.__dragOffset)==null?void 0:w.y)||0,E=n.__lastSnappedPosition,b=o-E.left-i,v=r-E.top-S;let _=E.left,x=E.top;const p=d==null?void 0:d[0],C=(p==null?void 0:p.guide.type)==="l",M=(p==null?void 0:p.guide.type)==="x",f=(p==null?void 0:p.guide.type)==="r",g=(p==null?void 0:p.guide.type)==="t",y=(p==null?void 0:p.guide.type)==="b",P=(p==null?void 0:p.guide.type)==="y";if(p){const{x:A,y:D}=B({guideMatched:p,canvasView:s}),T=c.offsetWidth,G=c.offsetHeight;C?_=A:f?_=A-T:M?_=A-T/2:g?x=D:y?x=D-G:P&&(x=D-G/2),n.__lastSnappedGuideMatched=p}else Math.abs(b)>=m&&(_=Math.round((E.left+b)/m)*m,n.__lastSnappedGuideMatched=null),Math.abs(v)>=h&&(x=Math.round((E.top+v)/h)*h,n.__lastSnappedGuideMatched=null);return n.addStyle({left:`${_}px`,top:`${x}px`},{partial:!0}),n.__lastSnappedPosition={left:_,top:x},{x:_,y:x,guideMatched:n.__lastSnappedGuideMatched}}function de({snapping:e,props:a,editor:u}){const{x:l,y:d}=H({snapping:e,props:a,editor:u}),n=a.component;n.addStyle({left:`${l}px`,top:`${d}px`}),delete n.__lastSnappedPosition,delete n.__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:u}=e,l=u.events,d=u.getConfig().defaultOptions??{},n=`${l.runBeforeCommand}tlb-move`;d[fe]={run:f=>({...f,skipGuidesRender:!0})};const{snapping:c,locking:s,globalAbsolute:m=!0}=a;m&&e.setDragMode("absolute");const h=!!(c!=null&&c.x||c!=null&&c.y),t=!!(s!=null&&s.x||s!=null&&s.y),{Canvas:o}=e;let r=null;const i=f=>{const{component:g,guidesMatched:y,command:P}=f,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(h){const{guideMatched:O}=H({snapping:c,props:f,editor:e});O?(D=[O.matched.componentEl],T=[B({guideMatched:O,canvasView:w})]):(D=[],T=[])}if(t)if(P.opts.event.shiftKey)if(!r)r=y[0];else{const N=r,I=N.guide.x===void 0?"x":"y";(I==="x"&&(s==null?void 0:s.x)||I==="y"&&(s==null?void 0:s.y))&&(le({guideMatched:N,component:g,canvasView:w}),D=[N.matched.componentEl],T=[B({guideMatched:N,canvasView:w})])}else r=null;const G={id:$,type:$,component:g,componentView:R,originComponent:A,matchedComponents:D,originMatchedDistances:T};o.addSpot(G)},S=({enabled:f})=>{e.runCommand(re,{enabled:f})},E=({type:f})=>{o.removeSpots({type:f})},b=()=>{E({type:ue}),E({type:he}),E({type:me})},v=f=>{S({enabled:!0}),i(f),b()},_=f=>{i(f),b()},x=f=>{E({type:$}),h&&de({snapping:c,props:f,editor:e}),S({enabled:!1})},M=[[pe,f=>{v(f),e.on(Y,_);const g=()=>{x(f),e.off(Y,_),e.off(K,g)};e.on(K,g)}],[n,f=>{if(m)return;const g=f.options.target,y=ae(e,g,a);y!=null&&y.result&&!y.dmode&&(f.options.mode="absolute")}]];M.forEach(([f,g])=>e.on(f,g)),se({editor:e,licenseKey:a.licenseKey,plan:ie,pluginName:ce,cleanup:()=>{S({enabled:!1}),M.forEach(([f,g])=>e.off(f,g))}})},ye=ne(ge);module.exports=ye;
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: u = "GET",
24
+ method: h = "GET",
25
25
  headers: l = {},
26
- params: d,
27
- body: n
26
+ params: f,
27
+ body: s
28
28
  }) {
29
- const s = `${a || z({ isDev: !1, isStage: !1 })}${e}`, m = {
30
- method: u,
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
- n && (m.body = JSON.stringify(n));
37
- const h = d ? new URLSearchParams(d).toString() : "", t = h ? `?${h}` : "", o = await fetch(`${s}${t}`, m);
38
- if (!o.ok)
39
- throw new Error(`HTTP error! status: ${o.status}`);
40
- return o.json();
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 = (u) => (l) => e(l, u), a;
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: u,
57
+ pluginName: h,
58
58
  licenseKey: l,
59
- cleanup: d
59
+ cleanup: f
60
60
  }) {
61
- let n = "", c = !1;
62
- const s = Q(), m = (t) => {
63
- console.warn("Cleanup plugin:", u, "Reason:", t), d();
64
- }, h = (t = {}) => {
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: o, sdkLicense: r } = t, i = (E = t.plan) == null ? void 0 : E.category;
67
- if (!(r || t.license) || o)
68
- m(o || "Invalid license");
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
- n = t == null ? void 0 : t.baseApiUrl, c = !0;
75
+ s = t == null ? void 0 : t.baseApiUrl, o = !0;
76
76
  }), e.on(q, (t) => {
77
- h(t);
77
+ d(t);
78
78
  }), setTimeout(async () => {
79
- if (!c) {
80
- if (s) return;
79
+ if (!o) {
80
+ if (n) return;
81
81
  if (l) {
82
- const t = await oe({ licenseKey: l, pluginName: u, baseApiUrl: n });
83
- t && h(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: u, baseApiUrl: l } = e;
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: u
98
+ pn: h
99
99
  }
100
100
  })).result || {};
101
- } catch (d) {
102
- return console.error("Error during SDK license check:", d), !1;
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, u) => {
106
- const l = u.enableAbsolute ?? ((m) => m.hasAbsolute), n = (Array.isArray(a) ? a : a ? [a] : [...e.getSelectedAll()])[0];
107
- if (!n) return;
108
- const c = n.getEl();
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: n, hasAbsolute: !!c && getComputedStyle(c).position === "absolute" }) : !1,
111
- component: n,
112
- dmode: n.get("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 u = e.guide.x === void 0 ? "y" : "x";
121
- let l = 0, d = 0, n = 0, c = 0;
122
- const { guide: s, matched: m } = e, h = a.getElBoxRect(s.componentView.el), t = a.getElBoxRect(((P = m.componentView) == null ? void 0 : P.el) || m.componentEl), o = h.y, r = h.y + h.height, i = h.x, S = h.x + h.width, E = t.y, b = t.y + t.height, v = t.x, _ = t.x + t.width, x = Math.max(0, o - b), p = Math.max(0, E - r), C = Math.max(0, i - _), M = Math.max(0, v - S), f = x > p, g = C > M, y = s.type;
123
- return u === "x" && (y === "l" ? (l = i, f ? (d = b, n = x) : (d = r, n = p)) : y === "r" ? (l = S, f ? (d = b, n = x) : (d = r, n = p)) : y === "x" && (l = i - (i - S) / 2, f ? (d = b, n = x) : (d = r, n = p))), u === "y" && (y === "t" ? (d = o, g ? (l = _, c = C) : (l = S, c = M)) : y === "b" ? (d = r, g ? (l = _, c = C) : (l = S, c = M)) : y === "y" && (d = o - (o - r) / 2, g ? (l = _, c = C) : (l = S, c = M))), { axis: u, x: l, y: d, width: c, height: n };
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: u
129
+ canvasView: h
129
130
  }) {
130
- const l = e.guide.x === void 0 ? "x" : "y", { guide: d, matched: n } = e, c = d.type, s = n.type, m = u.getElementPos(d.componentView.el).rect, h = u.getElementPos(n.componentView.el).rect;
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, o = h.top, r = h.top + h.height;
133
+ const t = m.height, c = d.top, p = d.top + d.height;
133
134
  let i = 0;
134
- c === "t" ? s === "t" ? i = o - t : s === "b" ? i = r - t : s === "y" && (i = o - t - (o - r) / 2) : c === "b" ? s === "t" ? i = o - t * 2 : s === "b" ? i = r - t * 2 : s === "y" && (i = o - t * 2 - (o - r) / 2) : c === "y" && (s === "t" ? i = o - t * 1.5 : s === "b" ? i = r - t * 1.5 : s === "y" && (i = o - t * 1.5 - (o - r) / 2)), a.addStyle({ top: `${i - 5}px` }, { partial: !0 });
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, o = h.left, r = h.left + h.width;
138
+ const t = m.width, c = d.left, p = d.left + d.width;
138
139
  let i = 0;
139
- c === "l" ? s === "l" ? i = o : s === "r" ? i = r : s === "x" && (i = o - (o - r) / 2) : c === "r" ? s === "l" ? i = o - t : s === "r" ? i = r - t : s === "x" && (i = o - t - (o - r) / 2) : c === "x" && (s === "l" ? i = o - t / 2 : s === "r" && (i = r - t / 2)), a.addStyle({ left: `${i}px` }, { partial: !0 });
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: u
146
+ props: h
146
147
  }) {
147
148
  var R, w;
148
- const { command: l, guidesMatched: d } = u, n = u.component, c = n.getEl(), s = a.Canvas.getCanvasView(), { x: m, y: h } = e ?? { x: 10, y: 10 }, t = l.opts.event, o = t.clientX, r = t.clientY;
149
- if (!n.__lastSnappedPosition) {
150
- const A = s.getElBoxRect(c), D = o - A.x, T = r - A.y;
151
- n.__lastSnappedPosition = { left: A.x, top: A.y }, n.__dragOffset = { x: D, y: T };
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 = n.__dragOffset) == null ? void 0 : R.x) || 0, S = ((w = n.__dragOffset) == null ? void 0 : w.y) || 0, E = n.__lastSnappedPosition, b = o - E.left - i, v = r - E.top - S;
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 p = d == null ? void 0 : d[0], C = (p == null ? void 0 : p.guide.type) === "l", M = (p == null ? void 0 : p.guide.type) === "x", f = (p == null ? void 0 : p.guide.type) === "r", g = (p == null ? void 0 : p.guide.type) === "t", y = (p == null ? void 0 : p.guide.type) === "b", P = (p == null ? void 0 : p.guide.type) === "y";
156
- if (p) {
157
- const { x: A, y: D } = B({ guideMatched: p, canvasView: s }), T = c.offsetWidth, G = c.offsetHeight;
158
- C ? _ = A : f ? _ = A - T : M ? _ = A - T / 2 : g ? x = D : y ? x = D - G : P && (x = D - G / 2), n.__lastSnappedGuideMatched = p;
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, n.__lastSnappedGuideMatched = null), Math.abs(v) >= h && (x = Math.round((E.top + v) / h) * h, n.__lastSnappedGuideMatched = null);
161
- return n.addStyle({ left: `${_}px`, top: `${x}px` }, { partial: !0 }), n.__lastSnappedPosition = { left: _, top: x }, { x: _, y: x, guideMatched: n.__lastSnappedGuideMatched };
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: u
167
+ editor: h
167
168
  }) {
168
- const { x: l, y: d } = H({ snapping: e, props: a, editor: u }), n = a.component;
169
- n.addStyle({ left: `${l}px`, top: `${d}px` }), delete n.__lastSnappedPosition, delete n.__lastSnappedGuideMatched;
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: u } = e, l = u.events, d = u.getConfig().defaultOptions ?? {}, n = `${l.runBeforeCommand}tlb-move`;
173
- d[fe] = {
174
- run: (f) => ({
175
- ...f,
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: c, locking: s, globalAbsolute: m = !0 } = a;
180
+ const { snapping: o, locking: n, globalAbsolute: m = !0 } = a;
180
181
  m && e.setDragMode("absolute");
181
- const h = !!(c != null && c.x || c != null && c.y), t = !!(s != null && s.x || s != null && s.y), { Canvas: o } = e;
182
- let r = null;
183
- const i = (f) => {
184
- const { component: g, guidesMatched: y, command: P } = f, R = g.view, w = e.Canvas.getCanvasView(), A = g.getEl();
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 (h) {
187
- const { guideMatched: O } = H({ snapping: c, props: f, editor: e });
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 (!r)
193
- r = y[0];
193
+ if (!p)
194
+ p = y[0];
194
195
  else {
195
- const N = r, I = N.guide.x === void 0 ? "x" : "y";
196
- (I === "x" && (s == null ? void 0 : s.x) || I === "y" && (s == null ? void 0 : s.y)) && (le({ guideMatched: N, component: g, canvasView: w }), D = [N.matched.componentEl], T = [B({ guideMatched: N, canvasView: w })]);
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
- r = null;
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
- o.addSpot(G);
210
- }, S = ({ enabled: f }) => {
211
- e.runCommand(re, { enabled: f });
212
- }, E = ({ type: f }) => {
213
- o.removeSpots({ type: f });
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 = (f) => {
217
- S({ enabled: !0 }), i(f), b();
218
- }, _ = (f) => {
219
- i(f), b();
220
- }, x = (f) => {
221
- E({ type: $ }), h && de({ snapping: c, props: f, editor: e }), S({ enabled: !1 });
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, (f) => {
224
- v(f), e.on(Y, _);
224
+ [pe, (r) => {
225
+ v(r), e.on(Y, _);
225
226
  const g = () => {
226
- x(f), e.off(Y, _), e.off(K, g);
227
+ x(r), e.off(Y, _), e.off(K, g);
227
228
  };
228
229
  e.on(K, g);
229
230
  }],
230
- [n, (f) => {
231
+ [s, (r) => {
231
232
  if (m) return;
232
- const g = f.options.target, y = ae(e, g, a);
233
- y != null && y.result && !y.dmode && (f.options.mode = "absolute");
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(([f, g]) => e.on(f, g)), se({
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(([f, g]) => e.off(f, g));
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:u="GET",headers:l={},params:d,body:n}){const o=`${a||q({isDev:!1,isStage:!1})}${e}`,m={method:u,headers:{"Content-Type":"application/json",...l}};n&&(m.body=JSON.stringify(n));const h=d?new URLSearchParams(d).toString():"",t=h?`?${h}`:"",s=await fetch(`${o}${t}`,m);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.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=u=>l=>e(l,u),a}const ee=e=>Z(e);async function te({editor:e,plan:a,pluginName:u,licenseKey:l,cleanup:d}){let n="",i=!1;const o=J(),m=t=>{console.warn("Cleanup plugin:",u,"Reason:",t),d()},h=(t={})=>{var E;const{error:s,sdkLicense:r}=t,c=(E=t.plan)==null?void 0:E.category;if(!(r||t.license)||s)m(s||"Invalid license");else if(c){const b=Y[a],O=Y[c];b>O&&m({pluginRequiredPlan:a,licensePlan:c})}};e.on(H,t=>{n=t==null?void 0:t.baseApiUrl,i=!0}),e.on(X,t=>{h(t)}),setTimeout(async()=>{if(!i){if(o)return;if(l){const t=await ne({licenseKey:l,pluginName:u,baseApiUrl:n});t&&h(t)}else m("The `licenseKey` option not provided")}},2e3)}async function ne(e){const{licenseKey:a,pluginName:u,baseApiUrl:l}=e;try{return(await Q({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(d){return console.error("Error during SDK license check:",d),!1}}const oe="canvasAbsoluteMode",se=L.startup,ie=(e,a,u)=>{const l=u.enableAbsolute??(m=>m.hasAbsolute),n=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0];if(!n)return;const i=n.getEl();return{result:z(l)?l({component:n,hasAbsolute:!!i&&getComputedStyle(i).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function G({guideMatched:e,canvasView:a}){var N;const u=e.guide.x===void 0?"y":"x";let l=0,d=0,n=0,i=0;const{guide:o,matched:m}=e,h=a.getElBoxRect(o.componentView.el),t=a.getElBoxRect(((N=m.componentView)==null?void 0:N.el)||m.componentEl),s=h.y,r=h.y+h.height,c=h.x,S=h.x+h.width,E=t.y,b=t.y+t.height,O=t.x,_=t.x+t.width,x=Math.max(0,s-b),p=Math.max(0,E-r),C=Math.max(0,c-_),M=Math.max(0,O-S),f=x>p,g=C>M,y=o.type;return u==="x"&&(y==="l"?(l=c,f?(d=b,n=x):(d=r,n=p)):y==="r"?(l=S,f?(d=b,n=x):(d=r,n=p)):y==="x"&&(l=c-(c-S)/2,f?(d=b,n=x):(d=r,n=p))),u==="y"&&(y==="t"?(d=s,g?(l=_,i=C):(l=S,i=M)):y==="b"?(d=r,g?(l=_,i=C):(l=S,i=M)):y==="y"&&(d=s-(s-r)/2,g?(l=_,i=C):(l=S,i=M))),{axis:u,x:l,y:d,width:i,height:n}}function ce({guideMatched:e,component:a,canvasView:u}){const l=e.guide.x===void 0?"x":"y",{guide:d,matched:n}=e,i=d.type,o=n.type,m=u.getElementPos(d.componentView.el).rect,h=u.getElementPos(n.componentView.el).rect;if(l==="x"){const t=m.height,s=h.top,r=h.top+h.height;let c=0;i==="t"?o==="t"?c=s-t:o==="b"?c=r-t:o==="y"&&(c=s-t-(s-r)/2):i==="b"?o==="t"?c=s-t*2:o==="b"?c=r-t*2:o==="y"&&(c=s-t*2-(s-r)/2):i==="y"&&(o==="t"?c=s-t*1.5:o==="b"?c=r-t*1.5:o==="y"&&(c=s-t*1.5-(s-r)/2)),a.addStyle({top:`${c-5}px`},{partial:!0})}if(l==="y"){const t=m.width,s=h.left,r=h.left+h.width;let c=0;i==="l"?o==="l"?c=s:o==="r"?c=r:o==="x"&&(c=s-(s-r)/2):i==="r"?o==="l"?c=s-t:o==="r"?c=r-t:o==="x"&&(c=s-t-(s-r)/2):i==="x"&&(o==="l"?c=s-t/2:o==="r"&&(c=r-t/2)),a.addStyle({left:`${c}px`},{partial:!0})}}function k({snapping:e,editor:a,props:u}){var B,w;const{command:l,guidesMatched:d}=u,n=u.component,i=n.getEl(),o=a.Canvas.getCanvasView(),{x:m,y:h}=e??{x:10,y:10},t=l.opts.event,s=t.clientX,r=t.clientY;if(!n.__lastSnappedPosition){const A=o.getElBoxRect(i),D=s-A.x,T=r-A.y;n.__lastSnappedPosition={left:A.x,top:A.y},n.__dragOffset={x:D,y:T}}const c=((B=n.__dragOffset)==null?void 0:B.x)||0,S=((w=n.__dragOffset)==null?void 0:w.y)||0,E=n.__lastSnappedPosition,b=s-E.left-c,O=r-E.top-S;let _=E.left,x=E.top;const p=d==null?void 0:d[0],C=(p==null?void 0:p.guide.type)==="l",M=(p==null?void 0:p.guide.type)==="x",f=(p==null?void 0:p.guide.type)==="r",g=(p==null?void 0:p.guide.type)==="t",y=(p==null?void 0:p.guide.type)==="b",N=(p==null?void 0:p.guide.type)==="y";if(p){const{x:A,y:D}=G({guideMatched:p,canvasView:o}),T=i.offsetWidth,I=i.offsetHeight;C?_=A:f?_=A-T:M?_=A-T/2:g?x=D:y?x=D-I:N&&(x=D-I/2),n.__lastSnappedGuideMatched=p}else Math.abs(b)>=m&&(_=Math.round((E.left+b)/m)*m,n.__lastSnappedGuideMatched=null),Math.abs(O)>=h&&(x=Math.round((E.top+O)/h)*h,n.__lastSnappedGuideMatched=null);return n.addStyle({left:`${_}px`,top:`${x}px`},{partial:!0}),n.__lastSnappedPosition={left:_,top:x},{x:_,y:x,guideMatched:n.__lastSnappedGuideMatched}}function ae({snapping:e,props:a,editor:u}){const{x:l,y:d}=k({snapping:e,props:a,editor:u}),n=a.component;n.addStyle({left:`${l}px`,top:`${d}px`}),delete n.__lastSnappedPosition,delete n.__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:u}=e,l=u.events,d=u.getConfig().defaultOptions??{},n=`${l.runBeforeCommand}tlb-move`;d[le]={run:f=>({...f,skipGuidesRender:!0})};const{snapping:i,locking:o,globalAbsolute:m=!0}=a;m&&e.setDragMode("absolute");const h=!!(i!=null&&i.x||i!=null&&i.y),t=!!(o!=null&&o.x||o!=null&&o.y),{Canvas:s}=e;let r=null;const c=f=>{const{component:g,guidesMatched:y,command:N}=f,B=g.view,w=e.Canvas.getCanvasView(),A=g.getEl();let D=y.map(v=>v.matched.componentEl),T=y.map(v=>G({guideMatched:v,canvasView:w}));if(h){const{guideMatched:v}=k({snapping:i,props:f,editor:e});v?(D=[v.matched.componentEl],T=[G({guideMatched:v,canvasView:w})]):(D=[],T=[])}if(t)if(N.opts.event.shiftKey)if(!r)r=y[0];else{const $=r,j=$.guide.x===void 0?"x":"y";(j==="x"&&(o==null?void 0:o.x)||j==="y"&&(o==null?void 0:o.y))&&(ce({guideMatched:$,component:g,canvasView:w}),D=[$.matched.componentEl],T=[G({guideMatched:$,canvasView:w})])}else r=null;const I={id:U,type:U,component:g,componentView:B,originComponent:A,matchedComponents:D,originMatchedDistances:T};s.addSpot(I)},S=({enabled:f})=>{e.runCommand(de,{enabled:f})},E=({type:f})=>{s.removeSpots({type:f})},b=()=>{E({type:re}),E({type:pe}),E({type:ue})},O=f=>{S({enabled:!0}),c(f),b()},_=f=>{c(f),b()},x=f=>{E({type:U}),h&&ae({snapping:i,props:f,editor:e}),S({enabled:!1})},M=[[fe,f=>{O(f),e.on(K,_);const g=()=>{x(f),e.off(K,_),e.off(V,g)};e.on(V,g)}],[n,f=>{if(m)return;const g=f.options.target,y=ie(e,g,a);y!=null&&y.result&&!y.dmode&&(f.options.mode="absolute")}]];M.forEach(([f,g])=>e.on(f,g)),te({editor:e,licenseKey:a.licenseKey,plan:se,pluginName:oe,cleanup:()=>{S({enabled:!1}),M.forEach(([f,g])=>e.off(f,g))}})})});
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 q(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 _="app.grapesjs.com",k="app-stage.grapesjs.com",B="app2.grapesjs.com",X="app-stage2.grapesjs.com",V=[_,B,k,X,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Y="license:check:start",Z="license:check:end",J=()=>typeof window<"u",Q=({isDev:e,isStage:i})=>`${e?"":`https://${i?k:_}`}/api`,ee=()=>{const e=J()&&window.location.hostname;return!!e&&(V.includes(e)||V.some(i=>e.endsWith(i)))};async function te({path:e,baseApiUrl:i,method:n="GET",headers:s={},params:a,body:c}){const m=`${i||Q({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 O={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function ne(e){const i=e;return i.init=n=>s=>e(s,n),i}const se=e=>ne(e);async function oe({editor:e,plan:i,pluginName:n,licenseKey:s,cleanup:a}){let c="",d=!1;const m=ee(),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=O[i],A=O[g];S>A&&r({pluginRequiredPlan:i,licensePlan:g})}};e.on(Y,o=>{c=o==null?void 0:o.baseApiUrl,d=!0}),e.on(Z,o=>{l(o)}),setTimeout(async()=>{if(!d){if(m)return;if(s){const o=await ae({licenseKey:s,pluginName:n,baseApiUrl:c});o&&l(o)}else r("The `licenseKey` option not provided")}},2e3)}async function ae(e){const{licenseKey:i,pluginName:n,baseApiUrl:s}=e;try{return(await te({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 U="canvasFullSize",ie=v.startup,ce=(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}}},re=e=>{["height","min-height","max-height"].forEach(i=>ce(i,e))},le=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",A=`${s.events.stopCommand}${S}`,L=n.getConfig(),M=`${U}:disable`,R=a.getAll().map(t=>({...t.attributes})),W=l*1e3,j={x:r,y:m};let C={},x,E;L.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
- .gjs-frame-wrapper { transition: width ${g}s !important; }
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
- `,!h&&document.body.appendChild(f)};e.on(b.frameLoadHead,t=>{if(!L.scrollableCanvas)return;const{window:p}=t,h=p.document,f=h.head,T="data-gs-plg-wrapper-style",D=f.querySelector(`style[${T}]`)||h.createElement("style");D.setAttribute(T,"true"),D.innerHTML=`
6
- [data-gjs-type="wrapper"] { min-height: ${y}; }
7
- [data-gjs-type="mjml"] { min-height: ${y} !important; }
8
- [data-gjs-type="mj-body"] { min-height: ${y} !important; }
9
- `,!f.contains(D)&&f.appendChild(D)});const I=()=>x.style.display="none",z=()=>x.style.display="",$=q(()=>{n.fitViewport({zoom:t=>t>100?100:t,ignoreHeight:!0,gap:j}),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())},W)},100),K=(t={})=>{t.options&&t.options.from!=="fitViewport"&&n.fitViewport({zoom:n.getZoom(),ignoreHeight:!0,gap:j})},F=()=>{I(),$()},G=()=>{C.overflowX="hidden",C.overflowY="auto"},N=()=>{E==null||E.disconnect(),$.clear()},P=[[a.events.select,F],[b.zoom,K],[A,G],[e.events.destroy,N],[c.events.mountBefore,re]];s.add(M,()=>{a.devices.reset(R),L.scrollableCanvas=!1,n.getModel().updateDevice(),n.setZoom(100),n.setCoords(0,0),C.overflowY="hidden",H(!0),P.forEach(([t,p])=>e.off(t,p)),N(),s.run("studio:canvasReload")}),P.forEach(([t,p])=>e.on(t,p)),e.onReady(()=>{const t=n.getElement(),p=n.getFramesEl(),h=n.getCanvasView();x=n.getSpotsEl(),C=t.style,C.overflowX="hidden",p.style.transition=`transform ${l}s`,document.removeEventListener("keypress",h.onKeyPress),H(),E=new ResizeObserver(()=>{I(),$()}),E.observe(t.parentElement),$()}),oe({editor:e,licenseKey:d.licenseKey,plan:ie,pluginName:U,cleanup:()=>{e.runCommand(M)}})},ue=se(le);module.exports=ue;
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;