@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.37
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/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +185 -159
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
- package/dist/aiChat/components/utils.d.ts +1 -0
- package/dist/aiChat/components/utilsTw.d.ts +11 -0
- package/dist/aiChat/index.cjs.js +75 -75
- package/dist/aiChat/index.es.js +9122 -8628
- package/dist/aiChat/index.js +75 -75
- package/dist/aiChat/index.umd.js +75 -75
- package/dist/aiChat/projectGeneration.d.ts +17 -0
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +221 -195
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +199 -173
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +149 -123
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +186 -160
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +263 -237
- package/dist/canvasGridMode/index.umd.js +2 -2
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +168 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +271 -245
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +232 -206
- package/dist/dataSourceHandlebars/index.umd.js +8 -8
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +157 -131
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +497 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +189 -163
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +175 -149
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +207 -181
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +36 -36
- package/dist/index.es.js +917 -891
- package/dist/index.umd.js +36 -36
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +192 -166
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +265 -239
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +121 -95
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +171 -145
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +227 -201
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +457 -431
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +248 -223
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +150 -124
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +143 -117
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +218 -192
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +275 -249
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +134 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self,b.StudioSdkPlugins_animationComponent=I())})(this,function(){"use strict";const b="app.grapesjs.com",I="app-stage.grapesjs.com",
|
|
2
|
-
`)},init(){const{em:
|
|
1
|
+
(function(b,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(b=typeof globalThis<"u"?globalThis:b||self,b.StudioSdkPlugins_animationComponent=I())})(this,function(){"use strict";const b="app.grapesjs.com",I="app-stage.grapesjs.com",T=[b,"app2.grapesjs.com",I,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],M="license:check:end",N=()=>typeof window<"u",F=({isDev:t,isStage:e,isPlatform:a})=>`${t?"":`https://${e?I:b}`}/${a?"platform-api":"api"}`,V=()=>{if(!N())return"";const{hostname:t}=window.location;if(t)return t;try{return window.parent.location.hostname||""}catch{return""}},X=()=>{const t=V();return!!t&&(T.includes(t)||T.some(e=>t.endsWith(e)))};async function j({path:t,baseApiUrl:e,method:a="GET",headers:r={},params:i,body:o}){const s=`${e||F({isDev:!1,isStage:!1})}${t}`,p={method:a,headers:{"Content-Type":"application/json",...r}};o&&(p.body=JSON.stringify(o));const d=i?new URLSearchParams(i).toString():"",f=d?`?${d}`:"",n=await fetch(`${s}${f}`,p);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{}),w=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.dialogImportCode="studio:dialogImportCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.settings="studio:settings",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(w||{});const S={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function _(t){const e=t;return e.init=a=>r=>t(r,a),e}const $=t=>_(t);async function C({editor:t,plan:e,pluginName:a,licenseKey:r,onLicenseCheckResponse:i,cleanup:o}){let l="",s;const p=n=>{console.warn("Cleanup plugin:",a,"Reason:",n),o()},d=(n={})=>{var E;const{error:c,sdkLicense:u}=n,h=(E=n.plan)==null?void 0:E.category;if(!(u||n.license)||c)p(c||"Invalid license");else if(h){const Z=S[e],ot=S[h];Z>ot&&p({pluginRequiredPlan:e,licensePlan:h})}};t.Commands.has(w.settings)&&(s=t.runCommand(w.settings),l=(s==null?void 0:s.baseUrl)||"");const f=n=>{i==null||i(n),n&&d(n)};if(!s){t.onReady(async()=>{if(!X())if(r){const n=await H({licenseKey:r,pluginName:a,baseApiUrl:l});f(n)}else p("The `licenseKey` option not provided")});return}if(s.licensePlan||s.licenseError){const n=Y(s);f(n);return}t.on(M,n=>f(n))}const Y=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function H(t){const{licenseKey:e,pluginName:a,baseApiUrl:r}=t;try{return(await j({baseApiUrl:r,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const W=(...t)=>e=>t.some(a=>e.is(a));var m=(t=>(t.name="animation-name",t.duration="animation-duration",t.delay="animation-delay",t.iterationCount="animation-iteration-count",t.timingFunction="animation-timing-function",t.fillMode="animation-fill-mode",t))(m||{}),x=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(x||{});const g="animation",A="animation-group",L="animation:update",D="animation-group:update",U={category:{id:"animations",label:"Animations"},select:!0},P=t=>(t==null?void 0:t.getType())===g,R=t=>(t==null?void 0:t.getType())===A,G=t=>P(t)||R(t),k={isVisible:({component:t})=>P(t)},K={isVisible:({component:t})=>R(t)},q={isVisible:({component:t})=>P(t)&&R(t==null?void 0:t.parent())?!1:G(t)},O={isVisible:({component:t,sector:e})=>{var a;return P(t)&&R(t==null?void 0:t.parent())?!1:G(t)&&((a=e.getProperty(x.onScroll))==null?void 0:a.getValue())==="true"}},z={animation:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M16.5 14a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13"/><path fill="currentColor" d="M17.14 15.98a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/><path fill="currentColor" d="M12.64 20.48a8.5 8.5 0 0 1-9.12-9.12 6.5 6.5 0 1 0 9.12 9.12"/></svg>',animationGroup:'<svg viewBox="0 0 24 24"><path d="M4 2a2 2 0 0 0-2 2v10h2V4h10V2H4m4 4a2 2 0 0 0-2 2v10h2V8h10V6H8m4 4a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2h-8Z"/></svg>'},J=function(t){const e=this;let a=null;const r=()=>{a==null||a.disconnect(),a=null},i=()=>{r();const o=e.style;o.animationName="",requestAnimationFrame(()=>{const l=getComputedStyle(e),s=l.getPropertyValue("animation-name").trim(),p=l.getPropertyValue("--animation-on-scroll").trim()!=="false",d=parseFloat(l.getPropertyValue("--animation-threshold").trim())||.2,f=l.getPropertyValue("--animation-repeat").trim()==="true",n=()=>{o.animationName="none",e.offsetWidth,o.animationName=s,o.animationPlayState="running"};if(!s||s==="none"){o.animationName="none",o.animationPlayState="paused";return}if(!p){n();return}o.animationPlayState="paused",a=new IntersectionObserver(c=>{c.forEach(u=>{u.isIntersecting&&(n(),!f&&r())})},{threshold:d}),a.observe(e)})};e.addEventListener(t.animationUpdateEvent,i),i()},Q=(t,e)=>{const{Components:a,Blocks:r,Canvas:i}=t,{block:o={},animationList:l=[]}=e,s=t.Components.events,p="Animation",d=Object.values(x),f=Object.values(m);return a.addType(g,{block:o?{label:p,media:z.animation,content:{type:g},...U,...o}:void 0,model:{defaults:{emptyState:!0,name:p,traits:[],script:J,animationUpdateEvent:L,"script-props":["animationUpdateEvent"],styles:l.map(n=>n.css).join(`
|
|
2
|
+
`)},init(){const{em:n}=this;this.addStyle({[m.name]:"fadeIn",[m.duration]:"1s",[m.fillMode]:"both",...e.animationStyle,...this.getStyle()}),this.listenTo(n,s.mount,c=>{var h;if(c!==this)return;((h=this.parent())==null?void 0:h.get("type"))!==A||d.forEach(y=>this.removeStyle(y))})}},view:{events:()=>({animationstart:"onAnimationStart",animationend:"onAnimationEnd"}),init(){const{model:n}=this;this.listenTo(n,s.styleUpdate,this.handleStyleChange)},onAnimationStart(){var c;if((c=this.cmpSpots)!=null&&c.length)return;const n=i.getSpots({component:this.model});this.cmpSpots=n,i.removeSpots(n),this.el.ownerDocument.body.style.overflowX="hidden"},onAnimationEnd(){const n=this.cmpSpots||[];i.spots.add(n),this.cmpSpots=[],this.el.ownerDocument.body.style.overflowX=""},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(L))},handleStyleChange(n,c){Object.keys((c==null?void 0:c.style)||{}).some(y=>f.includes(y)||d.includes(y))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(g),a.removeType(g)}},tt=function(t){const e=this,a="--animation-on-scroll",r="--animation-threshold",i="--animation-repeat";let o=null;const l=()=>{o==null||o.disconnect(),o=null},s=()=>{l();const p=getComputedStyle(e),d=p.getPropertyValue(a).trim()!=="false",f=parseFloat(p.getPropertyValue(r).trim())||.2,n=p.getPropertyValue(i).trim()==="true",c=()=>{Array.from(e.children).forEach(u=>{u instanceof HTMLElement&&typeof u.dispatchEvent=="function"&&u.dispatchEvent(new CustomEvent(D,{bubbles:!1}))})};if(!d){c();return}o=new IntersectionObserver(u=>{u.forEach(h=>{h.isIntersecting?(c(),!n&&l()):n&&Array.from(e.children).forEach(y=>{y instanceof HTMLElement&&getComputedStyle(y).getPropertyValue(a).trim()!=="false"&&(y.style.opacity="0",y.style.animationPlayState="paused")})})},{threshold:f}),o.observe(e)};e.addEventListener(t.animationGroupUpdateEvent,s),s()},et=(t,e)=>{const{Components:a,Blocks:r}=t,{blockGroup:i={}}=e,o="Animation Group";return a.addType(A,{block:i?{label:o,media:z.animationGroup,content:{type:A,components:[{type:g},{type:g},{type:g}]},...U,...i}:void 0,model:{defaults:{name:o,emptyState:!0,traits:[],script:tt,animationGroupUpdateEvent:D,"script-props":["animationGroupUpdateEvent"],droppable:W(g)},init(){this.addStyle({...e.animationGroupStyle,...this.getStyle()});const l=this.components();this.listenTo(l,"add remove",this.updateChildrenStaggerStyles),this.updateChildrenStaggerStyles()},updateChildrenStaggerStyles(){this.components().forEach((l,s)=>{l.is(g)&&l.addStyle({"--stagger-index":s.toString(),[m.delay]:"calc(var(--stagger-index, 0) * var(--stagger-delay, 0.3s))"},{partial:!0})})}},view:{init(){const{model:l}=this;this.listenTo(l,"component:styleUpdate",this.handleStyleChange)},triggerAnimation(){this.el.dispatchEvent(new CustomEvent(D))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(A),a.removeType(A)}},nt="animationComponent",at=v.startup,B=[{id:"flash",name:"Flash",css:`@keyframes flash {
|
|
3
3
|
0%, 50%, to {
|
|
4
4
|
opacity:1
|
|
5
5
|
}
|
|
@@ -516,4 +516,4 @@
|
|
|
516
516
|
transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
|
|
517
517
|
animation-timing-function:cubic-bezier(.175, .885, .32, 1)
|
|
518
518
|
}
|
|
519
|
-
}`}];return
|
|
519
|
+
}`}];return $(function(t,e={}){var i;const a=((i=e.animations)==null?void 0:i.call(e,{items:B}))||B,r=[Q(t,{...e,animationList:a}),et(t,e)];t.Styles.addSector("animation",{name:"Animation",properties:[{...k,name:"Type",property:m.name,type:"select",full:!0,default:"fadeIn",options:a},{...k,name:"Duration",property:m.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...k,name:"Delay",property:m.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...k,name:"Iteration Count",property:m.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...k,name:"Timing",property:m.timingFunction,type:"select",default:"ease",options:[{id:"ease",name:"Ease"},{id:"ease-in",name:"Ease in"},{id:"ease-out",name:"Ease out"},{id:"ease-in-out",name:"Ease in out"},{id:"linear",name:"Linear"}]},{...K,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...q,name:"Animate on Scroll",property:x.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...O,name:"Scroll Threshold",property:x.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...O,name:"Repeat on Scroll",property:x.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),C({editor:t,licenseKey:e.licenseKey,plan:at,pluginName:nt,cleanup:()=>{r.forEach(o=>o())}})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const V="app.grapesjs.com",H="app-stage.grapesjs.com",j="app2.grapesjs.com",F="app-stage2.grapesjs.com",U=[V,j,H,F,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],q="license:check:start",J="license:check:end",z=()=>typeof window<"u",Q=({isDev:t,isStage:a,isPlatform:u})=>`${t?"":`https://${a?H:V}`}/${u?"platform-api":"api"}`,Z=()=>{const t=z()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(a=>t.endsWith(a)))};function k(t){return typeof t=="function"}async function tt({path:t,baseApiUrl:a,method:u="GET",headers:l={},params:i,body:o}){const n=`${a||Q({isDev:!1,isStage:!1})}${t}`,g={method:u,headers:{"Content-Type":"application/json",...l}};o&&(g.body=JSON.stringify(o));const d=i?new URLSearchParams(i).toString():"",c=d?`?${d}`:"",e=await fetch(`${n}${c}`,g);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}var G=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(G||{});const W={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function et(t){const a=t;return a.init=u=>l=>t(l,u),a}const nt=t=>et(t);async function ot({editor:t,plan:a,pluginName:u,licenseKey:l,onLicenseCheckResponse:i,cleanup:o}){let s="",n=!1;const g=Z(),d=e=>{console.warn("Cleanup plugin:",u,"Reason:",e),o()},c=(e={})=>{var b;const{error:r,sdkLicense:f}=e,y=(b=e.plan)==null?void 0:b.category;if(!(f||e.license)||r)d(r||"Invalid license");else if(y){const v=W[a],E=W[y];v>E&&d({pluginRequiredPlan:a,licensePlan:y})}};t.on(q,e=>{s=e==null?void 0:e.baseApiUrl,n=!0}),t.on(J,e=>{i==null||i(e),c(e)}),setTimeout(async()=>{if(!n){if(g)return;if(l){const e=await st({licenseKey:l,pluginName:u,baseApiUrl:s});i==null||i(e),e&&c(e)}else d("The `licenseKey` option not provided")}},2e3)}async function st(t){const{licenseKey:a,pluginName:u,baseApiUrl:l}=t;try{return(await tt({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const it="canvasAbsoluteMode",ct=G.startup,at=(t,a,u)=>{var d,c;const l=u.enableAbsolute??(e=>e.hasAbsolute),o=(Array.isArray(a)?a:a?[a]:[...t.getSelectedAll()])[0],s=((c=(d=o==null?void 0:o.delegate)==null?void 0:d.move)==null?void 0:c.call(d,o))||o;if(!s)return;const n=s.getEl();return{result:k(l)?l({component:s,hasAbsolute:!!n&&getComputedStyle(n).position==="absolute"}):!1,component:s,dmode:s.get("dmode")}};function B({guideMatched:t,canvasView:a}){var C;const u=t.guide.x===void 0?"y":"x";let l=0,i=0,o=0,s=0;const{guide:n,matched:g}=t,d=a.getElBoxRect(n.componentView.el),c=a.getElBoxRect(((C=g.componentView)==null?void 0:C.el)||g.componentEl),e=d.y,r=d.y+d.height,f=d.x,y=d.x+d.width,S=c.y,b=c.y+c.height,v=c.x,E=c.x+c.width,x=Math.max(0,e-b),m=Math.max(0,S-r),w=Math.max(0,f-E),M=Math.max(0,v-y),p=x>m,h=w>M,_=n.type;return u==="x"&&(_==="l"?(l=f,p?(i=b,o=x):(i=r,o=m)):_==="r"?(l=y,p?(i=b,o=x):(i=r,o=m)):_==="x"&&(l=f-(f-y)/2,p?(i=b,o=x):(i=r,o=m))),u==="y"&&(_==="t"?(i=e,h?(l=E,s=w):(l=y,s=M)):_==="b"?(i=r,h?(l=E,s=w):(l=y,s=M)):_==="y"&&(i=e-(e-r)/2,h?(l=E,s=w):(l=y,s=M))),{axis:u,x:l,y:i,width:s,height:o}}function lt({guideMatched:t,component:a,canvasView:u}){const l=t.guide.x===void 0?"x":"y",{guide:i,matched:o}=t,s=i.type,n=o.type,g=u.getElementPos(i.componentView.el).rect,d=u.getElementPos(o.componentView.el).rect;if(l==="x"){const c=g.height,e=d.top,r=d.top+d.height;let f=0;s==="t"?n==="t"?f=e-c:n==="b"?f=r-c:n==="y"&&(f=e-c-(e-r)/2):s==="b"?n==="t"?f=e-c*2:n==="b"?f=r-c*2:n==="y"&&(f=e-c*2-(e-r)/2):s==="y"&&(n==="t"?f=e-c*1.5:n==="b"?f=r-c*1.5:n==="y"&&(f=e-c*1.5-(e-r)/2)),a.addStyle({top:`${f-5}px`},{partial:!0})}if(l==="y"){const c=g.width,e=d.left,r=d.left+d.width;let f=0;s==="l"?n==="l"?f=e:n==="r"?f=r:n==="x"&&(f=e-(e-r)/2):s==="r"?n==="l"?f=e-c:n==="r"?f=r-c:n==="x"&&(f=e-c-(e-r)/2):s==="x"&&(n==="l"?f=e-c/2:n==="r"&&(f=r-c/2)),a.addStyle({left:`${f}px`},{partial:!0})}}function X({snapping:t,editor:a,props:u}){var N,P;const{command:l,guidesMatched:i}=u,o=u.component,s=o.getEl(),n=a.Canvas.getCanvasView(),{x:g,y:d}=t??{x:10,y:10},c=l.opts.event,e=c.clientX,r=c.clientY;if(!o.__lastSnappedPosition){const A=n.getElBoxRect(s),D=e-A.x,T=r-A.y;o.__lastSnappedPosition={left:A.x,top:A.y},o.__dragOffset={x:D,y:T}}const f=((N=o.__dragOffset)==null?void 0:N.x)||0,y=((P=o.__dragOffset)==null?void 0:P.y)||0,S=o.__lastSnappedPosition,b=e-S.left-f,v=r-S.top-y;let E=S.left,x=S.top;const m=i==null?void 0:i[0],w=(m==null?void 0:m.guide.type)==="l",M=(m==null?void 0:m.guide.type)==="x",p=(m==null?void 0:m.guide.type)==="r",h=(m==null?void 0:m.guide.type)==="t",_=(m==null?void 0:m.guide.type)==="b",C=(m==null?void 0:m.guide.type)==="y";if(m){const{x:A,y:D}=B({guideMatched:m,canvasView:n}),T=s.offsetWidth,L=s.offsetHeight;w?E=A:p?E=A-T:M?E=A-T/2:h?x=D:_?x=D-L:C&&(x=D-L/2),o.__lastSnappedGuideMatched=m}else Math.abs(b)>=g&&(E=Math.round((S.left+b)/g)*g,o.__lastSnappedGuideMatched=null),Math.abs(v)>=d&&(x=Math.round((S.top+v)/d)*d,o.__lastSnappedGuideMatched=null);return o.addStyle({left:`${E}px`,top:`${x}px`},{partial:!0}),o.__lastSnappedPosition={left:E,top:x},{x:E,y:x,guideMatched:o.__lastSnappedGuideMatched}}function dt({snapping:t,props:a,editor:u}){const{x:l,y:i}=X({snapping:t,props:a,editor:u}),o=a.component;o.addStyle({left:`${l}px`,top:`${i}px`}),delete o.__lastSnappedPosition,delete o.__lastSnappedGuideMatched}const ft="core:component-drag",rt="studio:setDragAbsolute",pt="dmode:start",Y="dmode:move",K="dmode:end",$="dragAbsolute",ut="select",mt="hover",ht="spacing",gt=function(t,a={}){const{Commands:u}=t,l=u.events,i=u.getConfig().defaultOptions??{},o=`${l.runBeforeCommand}tlb-move`;i[ft]={run:p=>({...p,skipGuidesRender:!0})};const{snapping:s,locking:n,globalAbsolute:g=!0}=a;g&&t.setDragMode("absolute");const d=!!(s!=null&&s.x||s!=null&&s.y),c=!!(n!=null&&n.x||n!=null&&n.y),{Canvas:e}=t;let r=null;const f=p=>{const{component:h,guidesMatched:_,command:C}=p,N=h.view,P=t.Canvas.getCanvasView(),A=h.getEl();let D=_.map(O=>O.matched.componentEl),T=_.map(O=>B({guideMatched:O,canvasView:P}));if(d){const{guideMatched:O}=X({snapping:s,props:p,editor:t});O?(D=[O.matched.componentEl],T=[B({guideMatched:O,canvasView:P})]):(D=[],T=[])}if(c)if(C.opts.event.shiftKey)if(!r)r=_[0];else{const R=r,I=R.guide.x===void 0?"x":"y";(I==="x"&&(n==null?void 0:n.x)||I==="y"&&(n==null?void 0:n.y))&&(lt({guideMatched:R,component:h,canvasView:P}),D=[R.matched.componentEl],T=[B({guideMatched:R,canvasView:P})])}else r=null;const L={id:$,type:$,component:h,componentView:N,originComponent:A,matchedComponents:D,originMatchedDistances:T};e.addSpot(L)},y=({enabled:p})=>{t.runCommand(rt,{enabled:p})},S=({type:p})=>{e.removeSpots({type:p})},b=()=>{S({type:ut}),S({type:mt}),S({type:ht})},v=p=>{y({enabled:!0}),f(p),b()},E=p=>{f(p),b()},x=p=>{S({type:$}),d&&dt({snapping:s,props:p,editor:t}),y({enabled:!1})},M=[[pt,p=>{v(p),t.on(Y,E);const h=()=>{x(p),t.off(Y,E),t.off(K,h)};t.on(K,h)}],[o,p=>{if(g)return;const h=p.options.target,_=at(t,h,a);_!=null&&_.result&&!_.dmode&&(p.options.mode="absolute")}]];M.forEach(([p,h])=>t.on(p,h)),ot({editor:t,licenseKey:a.licenseKey,plan:ct,pluginName:it,cleanup:()=>{y({enabled:!1}),M.forEach(([p,h])=>t.off(p,h))}})},yt=nt(gt);module.exports=yt;
|
|
1
|
+
"use strict";const K="app.grapesjs.com",k="app-stage.grapesjs.com",X="app2.grapesjs.com",q="app-stage2.grapesjs.com",W=[K,X,k,q,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],J="license:check:end",z=()=>typeof window<"u",Q=({isDev:e,isStage:a,isPlatform:u})=>`${e?"":`https://${a?k:K}`}/${u?"platform-api":"api"}`,Z=()=>{if(!z())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},C=()=>{const e=Z();return!!e&&(W.includes(e)||W.some(a=>e.endsWith(a)))};function ee(e){return typeof e=="function"}async function te({path:e,baseApiUrl:a,method:u="GET",headers:c={},params:l,body:s}){const t=`${a||Q({isDev:!1,isStage:!1})}${e}`,h={method:u,headers:{"Content-Type":"application/json",...c}};s&&(h.body=JSON.stringify(s));const d=l?new URLSearchParams(l).toString():"",i=d?`?${d}`:"",o=await fetch(`${t}${i}`,h);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var m=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(m||{}),U=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(U||{});const V={[m.free]:0,[m.startup]:10,[m.business]:20,[m.enterprise]:30};function oe(e){const a=e;return a.init=u=>c=>e(c,u),a}const se=e=>oe(e);async function ne({editor:e,plan:a,pluginName:u,licenseKey:c,onLicenseCheckResponse:l,cleanup:s}){let n="",t;const h=o=>{console.warn("Cleanup plugin:",u,"Reason:",o),s()},d=(o={})=>{var A;const{error:p,sdkLicense:r}=o,b=(A=o.plan)==null?void 0:A.category;if(!(r||o.license)||p)h(p||"Invalid license");else if(b){const R=V[a],E=V[b];R>E&&h({pluginRequiredPlan:a,licensePlan:b})}};e.Commands.has(U.settings)&&(t=e.runCommand(U.settings),n=(t==null?void 0:t.baseUrl)||"");const i=o=>{l==null||l(o),o&&d(o)};if(!t){e.onReady(async()=>{if(!C())if(c){const o=await ae({licenseKey:c,pluginName:u,baseApiUrl:n});i(o)}else h("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const o=ie(t);i(o);return}e.on(J,o=>i(o))}const ie=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ae(e){const{licenseKey:a,pluginName:u,baseApiUrl:c}=e;try{return(await te({baseApiUrl:c,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:u}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const le="canvasAbsoluteMode",ce=m.startup,re=(e,a,u)=>{var d,i;const c=u.enableAbsolute??(o=>o.hasAbsolute),s=(Array.isArray(a)?a:a?[a]:[...e.getSelectedAll()])[0],n=((i=(d=s==null?void 0:s.delegate)==null?void 0:d.move)==null?void 0:i.call(d,s))||s;if(!n)return;const t=n.getEl();return{result:ee(c)?c({component:n,hasAbsolute:!!t&&getComputedStyle(t).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function I({guideMatched:e,canvasView:a}){var L;const u=e.guide.x===void 0?"y":"x";let c=0,l=0,s=0,n=0;const{guide:t,matched:h}=e,d=a.getElBoxRect(t.componentView.el),i=a.getElBoxRect(((L=h.componentView)==null?void 0:L.el)||h.componentEl),o=d.y,p=d.y+d.height,r=d.x,b=d.x+d.width,v=i.y,A=i.y+i.height,R=i.x,E=i.x+i.width,T=Math.max(0,o-A),g=Math.max(0,v-p),G=Math.max(0,r-E),D=Math.max(0,R-b),f=T>g,y=G>D,x=t.type;return u==="x"&&(x==="l"?(c=r,f?(l=A,s=T):(l=p,s=g)):x==="r"?(c=b,f?(l=A,s=T):(l=p,s=g)):x==="x"&&(c=r-(r-b)/2,f?(l=A,s=T):(l=p,s=g))),u==="y"&&(x==="t"?(l=o,y?(c=E,n=G):(c=b,n=D)):x==="b"?(l=p,y?(c=E,n=G):(c=b,n=D)):x==="y"&&(l=o-(o-p)/2,y?(c=E,n=G):(c=b,n=D))),{axis:u,x:c,y:l,width:n,height:s}}function de({guideMatched:e,component:a,canvasView:u}){const c=e.guide.x===void 0?"x":"y",{guide:l,matched:s}=e,n=l.type,t=s.type,h=u.getElementPos(l.componentView.el).rect,d=u.getElementPos(s.componentView.el).rect;if(c==="x"){const i=h.height,o=d.top,p=d.top+d.height;let r=0;n==="t"?t==="t"?r=o-i:t==="b"?r=p-i:t==="y"&&(r=o-i-(o-p)/2):n==="b"?t==="t"?r=o-i*2:t==="b"?r=p-i*2:t==="y"&&(r=o-i*2-(o-p)/2):n==="y"&&(t==="t"?r=o-i*1.5:t==="b"?r=p-i*1.5:t==="y"&&(r=o-i*1.5-(o-p)/2)),a.addStyle({top:`${r-5}px`},{partial:!0})}if(c==="y"){const i=h.width,o=d.left,p=d.left+d.width;let r=0;n==="l"?t==="l"?r=o:t==="r"?r=p:t==="x"&&(r=o-(o-p)/2):n==="r"?t==="l"?r=o-i:t==="r"?r=p-i:t==="x"&&(r=o-i-(o-p)/2):n==="x"&&(t==="l"?r=o-i/2:t==="r"&&(r=p-i/2)),a.addStyle({left:`${r}px`},{partial:!0})}}function H({snapping:e,editor:a,props:u}){var B,w;const{command:c,guidesMatched:l}=u,s=u.component,n=s.getEl(),t=a.Canvas.getCanvasView(),{x:h,y:d}=e??{x:10,y:10},i=c.opts.event,o=i.clientX,p=i.clientY;if(!s.__lastSnappedPosition){const P=t.getElBoxRect(n),_=o-P.x,M=p-P.y;s.__lastSnappedPosition={left:P.x,top:P.y},s.__dragOffset={x:_,y:M}}const r=((B=s.__dragOffset)==null?void 0:B.x)||0,b=((w=s.__dragOffset)==null?void 0:w.y)||0,v=s.__lastSnappedPosition,A=o-v.left-r,R=p-v.top-b;let E=v.left,T=v.top;const g=l==null?void 0:l[0],G=(g==null?void 0:g.guide.type)==="l",D=(g==null?void 0:g.guide.type)==="x",f=(g==null?void 0:g.guide.type)==="r",y=(g==null?void 0:g.guide.type)==="t",x=(g==null?void 0:g.guide.type)==="b",L=(g==null?void 0:g.guide.type)==="y";if(g){const{x:P,y:_}=I({guideMatched:g,canvasView:t}),M=n.offsetWidth,S=n.offsetHeight;G?E=P:f?E=P-M:D?E=P-M/2:y?T=_:x?T=_-S:L&&(T=_-S/2),s.__lastSnappedGuideMatched=g}else Math.abs(A)>=h&&(E=Math.round((v.left+A)/h)*h,s.__lastSnappedGuideMatched=null),Math.abs(R)>=d&&(T=Math.round((v.top+R)/d)*d,s.__lastSnappedGuideMatched=null);return s.addStyle({left:`${E}px`,top:`${T}px`},{partial:!0}),s.__lastSnappedPosition={left:E,top:T},{x:E,y:T,guideMatched:s.__lastSnappedGuideMatched}}function pe({snapping:e,props:a,editor:u}){const{x:c,y:l}=H({snapping:e,props:a,editor:u}),s=a.component;s.addStyle({left:`${c}px`,top:`${l}px`}),delete s.__lastSnappedPosition,delete s.__lastSnappedGuideMatched}const fe="core:component-drag",ue="studio:setDragAbsolute",ge="dmode:start",j="dmode:move",F="dmode:end",$="dragAbsolute",he="select",ye="hover",be="spacing",Ee=function(e,a={}){const{Commands:u}=e,c=u.events,l=u.getConfig().defaultOptions??{},s=`${c.runBeforeCommand}tlb-move`;l[fe]={run:f=>({...f,skipGuidesRender:!0})};const{snapping:n,locking:t,globalAbsolute:h=!0}=a;h&&e.setDragMode("absolute");const d=!!(n!=null&&n.x||n!=null&&n.y),i=!!(t!=null&&t.x||t!=null&&t.y),{Canvas:o}=e;let p=null;const r=f=>{const{component:y,guidesMatched:x,command:L}=f,B=y.view,w=e.Canvas.getCanvasView(),P=y.getEl();let _=x.map(O=>O.matched.componentEl),M=x.map(O=>I({guideMatched:O,canvasView:w}));if(d){const{guideMatched:O}=H({snapping:n,props:f,editor:e});O?(_=[O.matched.componentEl],M=[I({guideMatched:O,canvasView:w})]):(_=[],M=[])}if(i)if(L.opts.event.shiftKey)if(!p)p=x[0];else{const N=p,Y=N.guide.x===void 0?"x":"y";(Y==="x"&&(t==null?void 0:t.x)||Y==="y"&&(t==null?void 0:t.y))&&(de({guideMatched:N,component:y,canvasView:w}),_=[N.matched.componentEl],M=[I({guideMatched:N,canvasView:w})])}else p=null;const S={id:$,type:$,component:y,componentView:B,originComponent:P,matchedComponents:_,originMatchedDistances:M};o.addSpot(S)},b=({enabled:f})=>{e.runCommand(ue,{enabled:f})},v=({type:f})=>{o.removeSpots({type:f})},A=()=>{v({type:he}),v({type:ye}),v({type:be})},R=f=>{b({enabled:!0}),r(f),A()},E=f=>{r(f),A()},T=f=>{v({type:$}),d&&pe({snapping:n,props:f,editor:e}),b({enabled:!1})},D=[[ge,f=>{R(f),e.on(j,E);const y=()=>{T(f),e.off(j,E),e.off(F,y)};e.on(F,y)}],[s,f=>{if(h)return;const y=f.options.target,x=re(e,y,a);x!=null&&x.result&&!x.dmode&&(f.options.mode="absolute")}]];D.forEach(([f,y])=>e.on(f,y)),ne({editor:e,licenseKey:a.licenseKey,plan:ce,pluginName:le,cleanup:()=>{b({enabled:!1}),D.forEach(([f,y])=>e.off(f,y))}})},xe=se(Ee);module.exports=xe;
|