@grapesjs/studio-sdk-plugins 1.0.36 → 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 +4 -4
- package/dist/accordionComponent/index.es.js +83 -70
- package/dist/accordionComponent/index.umd.js +4 -4
- 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 +70 -70
- package/dist/aiChat/index.es.js +8627 -8161
- package/dist/aiChat/index.js +70 -70
- package/dist/aiChat/index.umd.js +70 -70
- package/dist/aiChat/projectGeneration.d.ts +17 -0
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +55 -42
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +67 -54
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +59 -46
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +4 -4
- package/dist/canvasFullSize/index.es.js +59 -46
- package/dist/canvasFullSize/index.umd.js +4 -4
- package/dist/canvasGridMode/index.cjs.js +2 -2
- package/dist/canvasGridMode/index.es.js +70 -57
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +37 -24
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +51 -38
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +2 -2
- package/dist/dataSourceHandlebars/index.es.js +50 -37
- package/dist/dataSourceHandlebars/index.umd.js +6 -6
- package/dist/dialogComponent/index.cjs.js +9 -9
- package/dist/dialogComponent/index.es.js +58 -45
- package/dist/dialogComponent/index.umd.js +3 -3
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +82 -69
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +70 -57
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +84 -71
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +82 -69
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +36 -36
- package/dist/index.es.js +843 -830
- package/dist/index.umd.js +36 -36
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +81 -68
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +86 -73
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +70 -57
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +49 -36
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +130 -117
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +96 -83
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +143 -131
- 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 +74 -61
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +3 -3
- package/dist/shapeDividerComponent/index.es.js +33 -20
- package/dist/shapeDividerComponent/index.umd.js +3 -3
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +105 -92
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +163 -150
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +36 -23
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component, Editor } from 'grapesjs';
|
|
2
|
+
export declare const commandMjmlToHtml = "mjml-code-to-html";
|
|
3
|
+
export declare function resolveProjectGenerationPreviewContent(props: {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
content: string;
|
|
6
|
+
isEmail: boolean;
|
|
7
|
+
}): any;
|
|
8
|
+
export declare function updateProjectGenerationPreview(props: {
|
|
9
|
+
editor: Editor;
|
|
10
|
+
component?: Component;
|
|
11
|
+
content: string;
|
|
12
|
+
isEmail: boolean;
|
|
13
|
+
scrollDocument?: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
export declare function completeProjectGeneration(editor: Editor, content: string, name: string): void;
|
|
16
|
+
export declare function startProjectGenerationPreview(editor: Editor): void;
|
|
17
|
+
export declare function stopProjectGenerationPreview(editor: Editor): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const G="app.grapesjs.com",z="app-stage.grapesjs.com",F="app2.grapesjs.com",N="app-stage2.grapesjs.com",D=[G,F,z,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],V="license:check:end",X=()=>typeof window<"u",j=({isDev:t,isStage:e,isPlatform:a})=>`${t?"":`https://${e?z:G}`}/${a?"platform-api":"api"}`,$=()=>{const
|
|
2
|
-
`)},init(){const{em:n}=this;this.addStyle({[u.name]:"fadeIn",[u.duration]:"1s",[u.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"))!==I||m.forEach(g=>this.removeStyle(g))})}},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(T))},handleStyleChange(n,c){Object.keys((c==null?void 0:c.style)||{}).some(g=>d.includes(g)||m.includes(g))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(y),a.removeType(y)}},
|
|
1
|
+
"use strict";const G="app.grapesjs.com",z="app-stage.grapesjs.com",F="app2.grapesjs.com",N="app-stage2.grapesjs.com",D=[G,F,z,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],V="license:check:end",X=()=>typeof window<"u",j=({isDev:t,isStage:e,isPlatform:a})=>`${t?"":`https://${e?z:G}`}/${a?"platform-api":"api"}`,$=()=>{if(!X())return"";const{hostname:t}=window.location;if(t)return t;try{return window.parent.location.hostname||""}catch{return""}},Y=()=>{const t=$();return!!t&&(D.includes(t)||D.some(e=>t.endsWith(e)))};async function C({path:t,baseApiUrl:e,method:a="GET",headers:r={},params:i,body:o}){const s=`${e||j({isDev:!1,isStage:!1})}${t}`,p={method:a,headers:{"Content-Type":"application/json",...r}};o&&(p.body=JSON.stringify(o));const m=i?new URLSearchParams(i).toString():"",d=m?`?${m}`:"",n=await fetch(`${s}${d}`,p);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var b=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(b||{}),R=(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))(R||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function H(t){const e=t;return e.init=a=>r=>t(r,a),e}const W=t=>H(t);async function _({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()},m=(n={})=>{var A;const{error:c,sdkLicense:f}=n,h=(A=n.plan)==null?void 0:A.category;if(!(f||n.license)||c)p(c||"Invalid license");else if(h){const E=L[e],M=L[h];E>M&&p({pluginRequiredPlan:e,licensePlan:h})}};t.Commands.has(R.settings)&&(s=t.runCommand(R.settings),l=(s==null?void 0:s.baseUrl)||"");const d=n=>{i==null||i(n),n&&m(n)};if(!s){t.onReady(async()=>{if(!Y())if(r){const n=await q({licenseKey:r,pluginName:a,baseApiUrl:l});d(n)}else p("The `licenseKey` option not provided")});return}if(s.licensePlan||s.licenseError){const n=K(s);d(n);return}t.on(V,n=>d(n))}const K=t=>({sdkLicense:t.license,license:t.license,error:t.licenseError,plan:t.licensePlan});async function q(t){const{licenseKey:e,pluginName:a,baseApiUrl:r}=t;try{return(await C({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 J=(...t)=>e=>t.some(a=>e.is(a));var u=(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))(u||{}),v=(t=>(t.onScroll="--animation-on-scroll",t.threshold="--animation-threshold",t.repeat="--animation-repeat",t))(v||{});const y="animation",I="animation-group",T="animation:update",P="animation-group:update",B={category:{id:"animations",label:"Animations"},select:!0},k=t=>(t==null?void 0:t.getType())===y,w=t=>(t==null?void 0:t.getType())===I,O=t=>k(t)||w(t),x={isVisible:({component:t})=>k(t)},Q={isVisible:({component:t})=>w(t)},tt={isVisible:({component:t})=>k(t)&&w(t==null?void 0:t.parent())?!1:O(t)},S={isVisible:({component:t,sector:e})=>{var a;return k(t)&&w(t==null?void 0:t.parent())?!1:O(t)&&((a=e.getProperty(v.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>'},et=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",m=parseFloat(l.getPropertyValue("--animation-threshold").trim())||.2,d=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(f=>{f.isIntersecting&&(n(),!d&&r())})},{threshold:m}),a.observe(e)})};e.addEventListener(t.animationUpdateEvent,i),i()},nt=(t,e)=>{const{Components:a,Blocks:r,Canvas:i}=t,{block:o={},animationList:l=[]}=e,s=t.Components.events,p="Animation",m=Object.values(v),d=Object.values(u);return a.addType(y,{block:o?{label:p,media:Z.animation,content:{type:y},...B,...o}:void 0,model:{defaults:{emptyState:!0,name:p,traits:[],script:et,animationUpdateEvent:T,"script-props":["animationUpdateEvent"],styles:l.map(n=>n.css).join(`
|
|
2
|
+
`)},init(){const{em:n}=this;this.addStyle({[u.name]:"fadeIn",[u.duration]:"1s",[u.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"))!==I||m.forEach(g=>this.removeStyle(g))})}},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(T))},handleStyleChange(n,c){Object.keys((c==null?void 0:c.style)||{}).some(g=>d.includes(g)||m.includes(g))&&this.triggerAnimation()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(y),a.removeType(y)}},at=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),m=p.getPropertyValue(a).trim()!=="false",d=parseFloat(p.getPropertyValue(r).trim())||.2,n=p.getPropertyValue(i).trim()==="true",c=()=>{Array.from(e.children).forEach(f=>{f instanceof HTMLElement&&typeof f.dispatchEvent=="function"&&f.dispatchEvent(new CustomEvent(P,{bubbles:!1}))})};if(!m){c();return}o=new IntersectionObserver(f=>{f.forEach(h=>{h.isIntersecting?(c(),!n&&l()):n&&Array.from(e.children).forEach(g=>{g instanceof HTMLElement&&getComputedStyle(g).getPropertyValue(a).trim()!=="false"&&(g.style.opacity="0",g.style.animationPlayState="paused")})})},{threshold:d}),o.observe(e)};e.addEventListener(t.animationGroupUpdateEvent,s),s()},ot=(t,e)=>{const{Components:a,Blocks:r}=t,{blockGroup:i={}}=e,o="Animation Group";return a.addType(I,{block:i?{label:o,media:Z.animationGroup,content:{type:I,components:[{type:y},{type:y},{type:y}]},...B,...i}:void 0,model:{defaults:{name:o,emptyState:!0,traits:[],script:at,animationGroupUpdateEvent:P,"script-props":["animationGroupUpdateEvent"],droppable:J(y)},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(y)&&l.addStyle({"--stagger-index":s.toString(),[u.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(P))},handleStyleChange(){this.triggerAnimation(),this.model.updateChildrenStaggerStyles()},onRender(){this.triggerAnimation()}}}),()=>{r.remove(I),a.removeType(I)}},it="animationComponent",st=b.startup,U=[{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
|
-
}`}],
|
|
519
|
+
}`}],rt=function(t,e={}){var i;const a=((i=e.animations)==null?void 0:i.call(e,{items:U}))||U,r=[nt(t,{...e,animationList:a}),ot(t,e)];t.Styles.addSector("animation",{name:"Animation",properties:[{...x,name:"Type",property:u.name,type:"select",full:!0,default:"fadeIn",options:a},{...x,name:"Duration",property:u.duration,type:"number",units:["s"],min:.1,max:10,step:.1,default:"1s"},{...x,name:"Delay",property:u.delay,type:"number",units:["s"],min:0,max:10,step:.1,default:"1s"},{...x,name:"Iteration Count",property:u.iterationCount,type:"select",default:"1",options:[{id:"1",name:"One time"},{id:"infinite",name:"Infinite"}]},{...x,name:"Timing",property:u.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"}]},{...Q,name:"Stagger Delay",property:"--stagger-delay",type:"slider",units:["s"],min:.1,max:5,step:.1,default:"0.3s"},{...tt,name:"Animate on Scroll",property:v.onScroll,type:"radio",default:"true",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]},{...S,name:"Scroll Threshold",property:v.threshold,type:"number",full:!0,min:.1,max:1,step:.01,default:"0.2"},{...S,name:"Repeat on Scroll",property:v.repeat,type:"radio",default:"false",options:[{name:"Yes",id:"true"},{name:"No",id:"false"}]}]}),_({editor:t,licenseKey:e.licenseKey,plan:st,pluginName:it,cleanup:()=>{r.forEach(o=>o())}})},lt=W(rt);module.exports=lt;
|
|
@@ -9,17 +9,30 @@ const G = "app.grapesjs.com", z = "app-stage.grapesjs.com", F = "app2.grapesjs.c
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
".local.webcontainer.io",
|
|
11
11
|
// For stackblitz.com demos
|
|
12
|
-
"-sandpack.codesandbox.io"
|
|
12
|
+
"-sandpack.codesandbox.io",
|
|
13
13
|
// For Sandpack demos
|
|
14
|
+
".claudemcpcontent.com",
|
|
15
|
+
// For Claude mcp app
|
|
16
|
+
".web-sandbox.oaiusercontent.com"
|
|
17
|
+
// For OpenAI mcp app
|
|
14
18
|
], V = "license:check:end", X = () => typeof window < "u", j = ({
|
|
15
19
|
isDev: t,
|
|
16
20
|
isStage: e,
|
|
17
21
|
isPlatform: a
|
|
18
22
|
}) => `${t ? "" : `https://${e ? z : G}`}/${a ? "platform-api" : "api"}`, $ = () => {
|
|
19
|
-
|
|
23
|
+
if (!X()) return "";
|
|
24
|
+
const { hostname: t } = window.location;
|
|
25
|
+
if (t) return t;
|
|
26
|
+
try {
|
|
27
|
+
return window.parent.location.hostname || "";
|
|
28
|
+
} catch {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}, Y = () => {
|
|
32
|
+
const t = $();
|
|
20
33
|
return !!t && (D.includes(t) || D.some((e) => t.endsWith(e)));
|
|
21
34
|
};
|
|
22
|
-
async function
|
|
35
|
+
async function C({
|
|
23
36
|
path: t,
|
|
24
37
|
baseApiUrl: e,
|
|
25
38
|
method: a = "GET",
|
|
@@ -40,18 +53,18 @@ async function Y({
|
|
|
40
53
|
throw new Error(`HTTP error! status: ${n.status}`);
|
|
41
54
|
return n.json();
|
|
42
55
|
}
|
|
43
|
-
var b = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(b || {}),
|
|
56
|
+
var b = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(b || {}), R = /* @__PURE__ */ ((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))(R || {});
|
|
44
57
|
const L = {
|
|
45
58
|
[b.free]: 0,
|
|
46
59
|
[b.startup]: 10,
|
|
47
60
|
[b.business]: 20,
|
|
48
61
|
[b.enterprise]: 30
|
|
49
62
|
};
|
|
50
|
-
function
|
|
63
|
+
function H(t) {
|
|
51
64
|
const e = t;
|
|
52
65
|
return e.init = (a) => (r) => t(r, a), e;
|
|
53
66
|
}
|
|
54
|
-
const W = (t) => /* @__PURE__ */
|
|
67
|
+
const W = (t) => /* @__PURE__ */ H(t);
|
|
55
68
|
async function _({
|
|
56
69
|
editor: t,
|
|
57
70
|
plan: e,
|
|
@@ -64,8 +77,8 @@ async function _({
|
|
|
64
77
|
const p = (n) => {
|
|
65
78
|
console.warn("Cleanup plugin:", a, "Reason:", n), o();
|
|
66
79
|
}, m = (n = {}) => {
|
|
67
|
-
var
|
|
68
|
-
const { error: c, sdkLicense: f } = n, h = (
|
|
80
|
+
var A;
|
|
81
|
+
const { error: c, sdkLicense: f } = n, h = (A = n.plan) == null ? void 0 : A.category;
|
|
69
82
|
if (!(f || n.license) || c)
|
|
70
83
|
p(c || "Invalid license");
|
|
71
84
|
else if (h) {
|
|
@@ -73,15 +86,15 @@ async function _({
|
|
|
73
86
|
E > M && p({ pluginRequiredPlan: e, licensePlan: h });
|
|
74
87
|
}
|
|
75
88
|
};
|
|
76
|
-
t.Commands.has(
|
|
89
|
+
t.Commands.has(R.settings) && (s = t.runCommand(R.settings), l = (s == null ? void 0 : s.baseUrl) || "");
|
|
77
90
|
const d = (n) => {
|
|
78
91
|
i == null || i(n), n && m(n);
|
|
79
92
|
};
|
|
80
93
|
if (!s) {
|
|
81
94
|
t.onReady(async () => {
|
|
82
|
-
if (
|
|
95
|
+
if (!Y())
|
|
83
96
|
if (r) {
|
|
84
|
-
const n = await
|
|
97
|
+
const n = await q({ licenseKey: r, pluginName: a, baseApiUrl: l });
|
|
85
98
|
d(n);
|
|
86
99
|
} else
|
|
87
100
|
p("The `licenseKey` option not provided");
|
|
@@ -89,22 +102,22 @@ async function _({
|
|
|
89
102
|
return;
|
|
90
103
|
}
|
|
91
104
|
if (s.licensePlan || s.licenseError) {
|
|
92
|
-
const n =
|
|
105
|
+
const n = K(s);
|
|
93
106
|
d(n);
|
|
94
107
|
return;
|
|
95
108
|
}
|
|
96
109
|
t.on(V, (n) => d(n));
|
|
97
110
|
}
|
|
98
|
-
const
|
|
111
|
+
const K = (t) => ({
|
|
99
112
|
sdkLicense: t.license,
|
|
100
113
|
license: t.license,
|
|
101
114
|
error: t.licenseError,
|
|
102
115
|
plan: t.licensePlan
|
|
103
116
|
});
|
|
104
|
-
async function
|
|
117
|
+
async function q(t) {
|
|
105
118
|
const { licenseKey: e, pluginName: a, baseApiUrl: r } = t;
|
|
106
119
|
try {
|
|
107
|
-
return (await
|
|
120
|
+
return (await C({
|
|
108
121
|
baseApiUrl: r,
|
|
109
122
|
path: `/sdk/${e || "na"}`,
|
|
110
123
|
method: "POST",
|
|
@@ -117,26 +130,26 @@ async function K(t) {
|
|
|
117
130
|
return console.error("Error during SDK license check:", i), !1;
|
|
118
131
|
}
|
|
119
132
|
}
|
|
120
|
-
const
|
|
133
|
+
const J = (...t) => (e) => t.some((a) => e.is(a));
|
|
121
134
|
var u = /* @__PURE__ */ ((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))(u || {}), v = /* @__PURE__ */ ((t) => (t.onScroll = "--animation-on-scroll", t.threshold = "--animation-threshold", t.repeat = "--animation-repeat", t))(v || {});
|
|
122
|
-
const y = "animation", I = "animation-group", T = "animation:update",
|
|
135
|
+
const y = "animation", I = "animation-group", T = "animation:update", P = "animation-group:update", B = {
|
|
123
136
|
category: { id: "animations", label: "Animations" },
|
|
124
137
|
select: !0
|
|
125
|
-
}, k = (t) => (t == null ? void 0 : t.getType()) === y,
|
|
138
|
+
}, k = (t) => (t == null ? void 0 : t.getType()) === y, w = (t) => (t == null ? void 0 : t.getType()) === I, O = (t) => k(t) || w(t), x = {
|
|
126
139
|
isVisible: ({ component: t }) => k(t)
|
|
127
|
-
}, J = {
|
|
128
|
-
isVisible: ({ component: t }) => A(t)
|
|
129
140
|
}, Q = {
|
|
130
|
-
isVisible: ({ component: t }) =>
|
|
141
|
+
isVisible: ({ component: t }) => w(t)
|
|
142
|
+
}, tt = {
|
|
143
|
+
isVisible: ({ component: t }) => k(t) && w(t == null ? void 0 : t.parent()) ? !1 : O(t)
|
|
131
144
|
}, S = {
|
|
132
145
|
isVisible: ({ component: t, sector: e }) => {
|
|
133
146
|
var a;
|
|
134
|
-
return k(t) &&
|
|
147
|
+
return k(t) && w(t == null ? void 0 : t.parent()) ? !1 : O(t) && ((a = e.getProperty(v.onScroll)) == null ? void 0 : a.getValue()) === "true";
|
|
135
148
|
}
|
|
136
149
|
}, Z = {
|
|
137
150
|
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>',
|
|
138
151
|
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>'
|
|
139
|
-
},
|
|
152
|
+
}, et = function(t) {
|
|
140
153
|
const e = this;
|
|
141
154
|
let a = null;
|
|
142
155
|
const r = () => {
|
|
@@ -167,7 +180,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
167
180
|
});
|
|
168
181
|
};
|
|
169
182
|
e.addEventListener(t.animationUpdateEvent, i), i();
|
|
170
|
-
},
|
|
183
|
+
}, nt = (t, e) => {
|
|
171
184
|
const { Components: a, Blocks: r, Canvas: i } = t, { block: o = {}, animationList: l = [] } = e, s = t.Components.events, p = "Animation", m = Object.values(v), d = Object.values(u);
|
|
172
185
|
return a.addType(y, {
|
|
173
186
|
block: o ? {
|
|
@@ -182,7 +195,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
182
195
|
emptyState: !0,
|
|
183
196
|
name: p,
|
|
184
197
|
traits: [],
|
|
185
|
-
script:
|
|
198
|
+
script: et,
|
|
186
199
|
animationUpdateEvent: T,
|
|
187
200
|
"script-props": ["animationUpdateEvent"],
|
|
188
201
|
styles: l.map((n) => n.css).join(`
|
|
@@ -235,7 +248,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
235
248
|
}), () => {
|
|
236
249
|
r.remove(y), a.removeType(y);
|
|
237
250
|
};
|
|
238
|
-
},
|
|
251
|
+
}, at = function(t) {
|
|
239
252
|
const e = this, a = "--animation-on-scroll", r = "--animation-threshold", i = "--animation-repeat";
|
|
240
253
|
let o = null;
|
|
241
254
|
const l = () => {
|
|
@@ -244,7 +257,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
244
257
|
l();
|
|
245
258
|
const p = getComputedStyle(e), m = p.getPropertyValue(a).trim() !== "false", d = parseFloat(p.getPropertyValue(r).trim()) || 0.2, n = p.getPropertyValue(i).trim() === "true", c = () => {
|
|
246
259
|
Array.from(e.children).forEach((f) => {
|
|
247
|
-
f instanceof HTMLElement && typeof f.dispatchEvent == "function" && f.dispatchEvent(new CustomEvent(
|
|
260
|
+
f instanceof HTMLElement && typeof f.dispatchEvent == "function" && f.dispatchEvent(new CustomEvent(P, { bubbles: !1 }));
|
|
248
261
|
});
|
|
249
262
|
};
|
|
250
263
|
if (!m) {
|
|
@@ -263,7 +276,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
263
276
|
), o.observe(e);
|
|
264
277
|
};
|
|
265
278
|
e.addEventListener(t.animationGroupUpdateEvent, s), s();
|
|
266
|
-
},
|
|
279
|
+
}, ot = (t, e) => {
|
|
267
280
|
const { Components: a, Blocks: r } = t, { blockGroup: i = {} } = e, o = "Animation Group";
|
|
268
281
|
return a.addType(I, {
|
|
269
282
|
block: i ? {
|
|
@@ -285,10 +298,10 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
285
298
|
name: o,
|
|
286
299
|
emptyState: !0,
|
|
287
300
|
traits: [],
|
|
288
|
-
script:
|
|
289
|
-
animationGroupUpdateEvent:
|
|
301
|
+
script: at,
|
|
302
|
+
animationGroupUpdateEvent: P,
|
|
290
303
|
"script-props": ["animationGroupUpdateEvent"],
|
|
291
|
-
droppable:
|
|
304
|
+
droppable: J(y)
|
|
292
305
|
},
|
|
293
306
|
init() {
|
|
294
307
|
this.addStyle({
|
|
@@ -316,7 +329,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
316
329
|
this.listenTo(l, "component:styleUpdate", this.handleStyleChange);
|
|
317
330
|
},
|
|
318
331
|
triggerAnimation() {
|
|
319
|
-
this.el.dispatchEvent(new CustomEvent(
|
|
332
|
+
this.el.dispatchEvent(new CustomEvent(P));
|
|
320
333
|
},
|
|
321
334
|
handleStyleChange() {
|
|
322
335
|
this.triggerAnimation(), this.model.updateChildrenStaggerStyles();
|
|
@@ -328,7 +341,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
328
341
|
}), () => {
|
|
329
342
|
r.remove(I), a.removeType(I);
|
|
330
343
|
};
|
|
331
|
-
},
|
|
344
|
+
}, it = "animationComponent", st = b.startup, U = [
|
|
332
345
|
{
|
|
333
346
|
id: "flash",
|
|
334
347
|
name: "Flash",
|
|
@@ -1006,11 +1019,11 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
1006
1019
|
}
|
|
1007
1020
|
}`
|
|
1008
1021
|
}
|
|
1009
|
-
],
|
|
1022
|
+
], rt = function(t, e = {}) {
|
|
1010
1023
|
var i;
|
|
1011
1024
|
const a = ((i = e.animations) == null ? void 0 : i.call(e, { items: U })) || U, r = [
|
|
1012
|
-
|
|
1013
|
-
|
|
1025
|
+
nt(t, { ...e, animationList: a }),
|
|
1026
|
+
ot(t, e)
|
|
1014
1027
|
];
|
|
1015
1028
|
t.Styles.addSector("animation", {
|
|
1016
1029
|
name: "Animation",
|
|
@@ -1072,7 +1085,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
1072
1085
|
]
|
|
1073
1086
|
},
|
|
1074
1087
|
{
|
|
1075
|
-
...
|
|
1088
|
+
...Q,
|
|
1076
1089
|
name: "Stagger Delay",
|
|
1077
1090
|
property: "--stagger-delay",
|
|
1078
1091
|
type: "slider",
|
|
@@ -1083,7 +1096,7 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
1083
1096
|
default: "0.3s"
|
|
1084
1097
|
},
|
|
1085
1098
|
{
|
|
1086
|
-
...
|
|
1099
|
+
...tt,
|
|
1087
1100
|
name: "Animate on Scroll",
|
|
1088
1101
|
property: v.onScroll,
|
|
1089
1102
|
type: "radio",
|
|
@@ -1131,13 +1144,13 @@ const y = "animation", I = "animation-group", T = "animation:update", w = "anima
|
|
|
1131
1144
|
}), _({
|
|
1132
1145
|
editor: t,
|
|
1133
1146
|
licenseKey: e.licenseKey,
|
|
1134
|
-
plan:
|
|
1135
|
-
pluginName:
|
|
1147
|
+
plan: st,
|
|
1148
|
+
pluginName: it,
|
|
1136
1149
|
cleanup: () => {
|
|
1137
1150
|
r.forEach((o) => o());
|
|
1138
1151
|
}
|
|
1139
1152
|
});
|
|
1140
|
-
},
|
|
1153
|
+
}, lt = W(rt);
|
|
1141
1154
|
export {
|
|
1142
|
-
|
|
1155
|
+
lt as default
|
|
1143
1156
|
};
|
|
@@ -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",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"],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=()=>{const
|
|
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)}},
|
|
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 K="app.grapesjs.com",k="app-stage.grapesjs.com",H="app2.grapesjs.com",q="app-stage2.grapesjs.com",W=[K,H,k,q,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],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=()=>{const e=z()&&window.location.hostname;return!!e&&(W.includes(e)||W.some(a=>e.endsWith(a)))};function C(e){return typeof e=="function"}async function ee({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 B=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(B||{}),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={[B.free]:0,[B.startup]:10,[B.business]:20,[B.enterprise]:30};function te(e){const a=e;return a.init=u=>c=>e(c,u),a}const oe=e=>te(e);async function se({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(!Z())if(c){const o=await ie({licenseKey:c,pluginName:u,baseApiUrl:n});i(o)}else h("The `licenseKey` option not provided")});return}if(t.licensePlan||t.licenseError){const o=ne(t);i(o);return}e.on(J,o=>i(o))}const ne=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function ie(e){const{licenseKey:a,pluginName:u,baseApiUrl:c}=e;try{return(await ee({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 ae="canvasAbsoluteMode",le=B.startup,ce=(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:C(c)?c({component:n,hasAbsolute:!!t&&getComputedStyle(t).position==="absolute"}):!1,component:n,dmode:n.get("dmode")}};function I({guideMatched:e,canvasView:a}){var w;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(((w=h.componentView)==null?void 0:w.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 re({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 X({snapping:e,editor:a,props:u}){var S,L;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=((S=s.__dragOffset)==null?void 0:S.x)||0,b=((L=s.__dragOffset)==null?void 0:L.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",w=(g==null?void 0:g.guide.type)==="y";if(g){const{x:P,y:_}=I({guideMatched:g,canvasView:t}),M=n.offsetWidth,m=n.offsetHeight;G?E=P:f?E=P-M:D?E=P-M/2:y?T=_:x?T=_-m:w&&(T=_-m/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 de({snapping:e,props:a,editor:u}){const{x:c,y:l}=X({snapping:e,props:a,editor:u}),s=a.component;s.addStyle({left:`${c}px`,top:`${l}px`}),delete s.__lastSnappedPosition,delete s.__lastSnappedGuideMatched}const pe="core:component-drag",fe="studio:setDragAbsolute",ue="dmode:start",j="dmode:move",F="dmode:end",$="dragAbsolute",ge="select",he="hover",ye="spacing",be=function(e,a={}){const{Commands:u}=e,c=u.events,l=u.getConfig().defaultOptions??{},s=`${c.runBeforeCommand}tlb-move`;l[pe]={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:w}=f,S=y.view,L=e.Canvas.getCanvasView(),P=y.getEl();let _=x.map(O=>O.matched.componentEl),M=x.map(O=>I({guideMatched:O,canvasView:L}));if(d){const{guideMatched:O}=X({snapping:n,props:f,editor:e});O?(_=[O.matched.componentEl],M=[I({guideMatched:O,canvasView:L})]):(_=[],M=[])}if(i)if(w.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))&&(re({guideMatched:N,component:y,canvasView:L}),_=[N.matched.componentEl],M=[I({guideMatched:N,canvasView:L})])}else p=null;const m={id:$,type:$,component:y,componentView:S,originComponent:P,matchedComponents:_,originMatchedDistances:M};o.addSpot(m)},b=({enabled:f})=>{e.runCommand(fe,{enabled:f})},v=({type:f})=>{o.removeSpots({type:f})},A=()=>{v({type:ge}),v({type:he}),v({type:ye})},R=f=>{b({enabled:!0}),r(f),A()},E=f=>{r(f),A()},T=f=>{v({type:$}),d&&de({snapping:n,props:f,editor:e}),b({enabled:!1})},D=[[ue,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=ce(e,y,a);x!=null&&x.result&&!x.dmode&&(f.options.mode="absolute")}]];D.forEach(([f,y])=>e.on(f,y)),se({editor:e,licenseKey:a.licenseKey,plan:le,pluginName:ae,cleanup:()=>{b({enabled:!1}),D.forEach(([f,y])=>e.off(f,y))}})},Ee=oe(be);module.exports=Ee;
|
|
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;
|