@grapesjs/studio-sdk-plugins 1.0.29 → 1.0.30
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/canvasScreenshot/index.cjs.d.ts +3 -0
- package/dist/canvasScreenshot/index.cjs.js +1 -0
- package/dist/canvasScreenshot/index.d.ts +3 -0
- package/dist/canvasScreenshot/index.es.d.ts +3 -0
- package/dist/canvasScreenshot/index.es.js +212 -0
- package/dist/canvasScreenshot/index.umd.js +1 -0
- package/dist/canvasScreenshot/shared.d.ts +3 -0
- package/dist/canvasScreenshot/types.d.ts +61 -0
- package/dist/canvasScreenshot/typesSchema.d.ts +17 -0
- package/dist/canvasScreenshot/utils.d.ts +3 -0
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +48 -48
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +2400 -2302
- package/dist/index.umd.js +50 -50
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +173 -171
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/types.d.ts +29 -6
- package/dist/layoutSidebarButtons/typesSchema.d.ts +16 -0
- package/dist/prosemirror/index.cjs.js +9 -9
- package/dist/prosemirror/index.es.js +894 -885
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/prosemirror/utils.d.ts +4 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +96 -96
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +103 -101
- package/dist/swiperComponent/index.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),P=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",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))(P||{}),D=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(D||{});const M="app.grapesjs.com",G="app-stage.grapesjs.com",N="app2.grapesjs.com",_="app-stage2.grapesjs.com",k=[M,N,G,_,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",H="license:check:end",j=()=>typeof window<"u",W=({isDev:e,isStage:t})=>`${e?"":`https://${t?G:M}`}/api`,K=()=>{const e=j()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(t=>e.endsWith(t)))};async function V({path:e,baseApiUrl:t,method:l="GET",headers:i={},params:c,body:p}){const b=`${t||W({isDev:!1,isStage:!1})}${e}`,r={method:l,headers:{"Content-Type":"application/json",...i}};p&&(r.body=JSON.stringify(p));const o=c?new URLSearchParams(c).toString():"",a=o?`?${o}`:"",u=await fetch(`${b}${a}`,r);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}const w={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function F(e){const t=e;return t.init=l=>i=>e(i,l),t}const q=e=>F(e);async function C({editor:e,plan:t,pluginName:l,licenseKey:i,cleanup:c}){let p="",f=!1;const b=K(),r=a=>{console.warn("Cleanup plugin:",l,"Reason:",a),c()},o=(a={})=>{var n;const{error:u,sdkLicense:T}=a,s=(n=a.plan)==null?void 0:n.category;if(!(T||a.license)||u)r(u||"Invalid license");else if(s){const d=w[t],v=w[s];d>v&&r({pluginRequiredPlan:t,licensePlan:s})}};e.on($,a=>{p=a==null?void 0:a.baseApiUrl,f=!0}),e.on(H,a=>{o(a)}),setTimeout(async()=>{if(!f){if(b)return;if(i){const a=await Z({licenseKey:i,pluginName:l,baseApiUrl:p});a&&o(a)}else r("The `licenseKey` option not provided")}},2e3)}async function Z(e){const{licenseKey:t,pluginName:l,baseApiUrl:i}=e;try{return(await V({baseApiUrl:i,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:l}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}var h=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e))(h||{});const I="sidebarButtonsTarget",A=e=>{const{id:t,icon:l,label:i,tooltip:c,className:p,skipSelfClose:f,removeLayouts:b,layoutComponent:r,layoutCommand:o}=e,a=t;return{id:x(t),type:"button",icon:l,tooltip:i||c,className:p,editorEvents:{[`${D.layoutToggleId}${a}`]:({fromEvent:u,setState:T,editor:s})=>{T({active:u.isOpen}),setTimeout(()=>s.refresh({tools:!0}),20)}},onClick:({editor:u,state:T})=>{if(T.active&&f)return;const s=(o==null?void 0:o.placer)||{type:"static",layoutId:I},g={...s,skipCleanup:s.type==="static"},n=b||Object.keys(h).filter(v=>v!==a);O(u,{removeLayouts:n,layout:{placer:g}});const d={id:a,placer:s,header:(o==null?void 0:o.header)??{label:i,close:!f},layout:r,style:{width:280,height:"100%",borderRightWidth:1,...o==null?void 0:o.style}};u.runCommand(P.layoutToggle,d)}}},x=e=>`button__${e}`,O=(e,t={})=>{(t.removeLayouts||Object.keys(h)).forEach(i=>e.runCommand(P.layoutRemove,{id:i,layout:t.layout}))},E=e=>{const t=(e==null?void 0:e.breakpointTablet)??1024,l=(e==null?void 0:e.breakpointMobile)??768,i={breakpointTablet:t,breakpointMobile:l},c={},p=[{id:h.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:h.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:h.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:h.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:s,editor:g})=>{var v;const n=g.getSelected(),d={type:"image",src:s.src};if(n!=null&&n.is("image"))return n.set("src",s.src);if(n&&g.Components.canMove(n,d)){const y=n.append(d)[0];y&&g.select(y)}else if(!n){const y=(v=g.getWrapper())==null?void 0:v.append(d)[0];y&&g.select(y)}}}}],f=[...p,{id:h.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],b={id:I,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},r={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},o={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},a=(s,g,n)=>{const d=s.map(y=>{const B=A(y);return e!=null&&e.sidebarButton?e.sidebarButton({id:y.id,buttonIds:h,breakpoint:g,buttonProps:B,sidebarButtonProps:y,...i,createSidebarButton:U=>A({...y,...U})}):B}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:h,breakpoint:g,sidebarButtons:d,...i,createSidebarButton:y=>A({...y,layoutCommand:{...n==null?void 0:n.layoutCommand,...y.layoutCommand}})}):d).filter(Boolean)},u=(s,g,n)=>{var d;return((d=e==null?void 0:e.rootLayout)==null?void 0:d.call(e,{breakpoint:n,sidebarButtons:g,rootLayout:s,layoutSidebarLeft:r,layoutSidebarTarget:b,...i,createSidebarButton:v=>A({...v})}))??s};if(t){const s=a(f,t);c[t]=u({type:"row",style:{height:"100%"},children:[{...r,children:s},b,o]},s,t)}if(l){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},g=f.map(d=>({...d,layoutCommand:s})),n=a(g,l,{layoutCommand:s});c[l]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:n}]},n,l)}const T=a(p,0);return{default:u({type:"row",style:{height:"100%"},children:[{...r,children:T},b,o,{type:"sidebarRight"}]},T,0),responsive:c}},R="layoutSidebarButtons",z=L.free,J=function(e,t={}){const{Commands:l}=e,i=l.events,c={...t};(()=>{if(e.runCommand(P.layoutConfigGet)||c.skipLayoutConfig===!0)return;const b=E(c);e.runCommand(P.layoutConfigSet,{...b})})(),l.add(`${R}:toggleButton`,(f,b,r)=>{const o=document.getElementById(x(r==null?void 0:r.id));o==null||o.click()}),e.on(`${i.runCommand}core:preview`,()=>{O(e)}),C({editor:e,licenseKey:c.licenseKey,plan:z,pluginName:R,cleanup:()=>{e.runCommand(P.layoutConfigSet)}})},S=q(J);S.createLayoutConfig=e=>E(e);module.exports=S;
|
|
1
|
+
"use strict";var P=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(P||{}),B=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",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))(B||{}),I=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(I||{});const x="app.grapesjs.com",O="app-stage.grapesjs.com",$="app2.grapesjs.com",H="app-stage2.grapesjs.com",M=[x,$,O,H,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],j="license:check:start",W="license:check:end",K=()=>typeof window<"u",V=({isDev:e,isStage:a})=>`${e?"":`https://${a?O:x}`}/api`,C=()=>{const e=K()&&window.location.hostname;return!!e&&(M.includes(e)||M.some(a=>e.endsWith(a)))};async function F({path:e,baseApiUrl:a,method:n="GET",headers:i={},params:c,body:p}){const b=`${a||V({isDev:!1,isStage:!1})}${e}`,g={method:n,headers:{"Content-Type":"application/json",...i}};p&&(g.body=JSON.stringify(p));const d=c?new URLSearchParams(c).toString():"",t=d?`?${d}`:"",r=await fetch(`${b}${t}`,g);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const D={[P.free]:0,[P.startup]:10,[P.business]:20,[P.enterprise]:30};function m(e){const a=e;return a.init=n=>i=>e(i,n),a}const q=e=>m(e);async function Z({editor:e,plan:a,pluginName:n,licenseKey:i,cleanup:c}){let p="",f=!1;const b=C(),g=t=>{console.warn("Cleanup plugin:",n,"Reason:",t),c()},d=(t={})=>{var o;const{error:r,sdkLicense:L}=t,s=(o=t.plan)==null?void 0:o.category;if(!(L||t.license)||r)g(r||"Invalid license");else if(s){const l=D[a],y=D[s];l>y&&g({pluginRequiredPlan:a,licensePlan:s})}};e.on(j,t=>{p=t==null?void 0:t.baseApiUrl,f=!0}),e.on(W,t=>{d(t)}),setTimeout(async()=>{if(!f){if(b)return;if(i){const t=await z({licenseKey:i,pluginName:n,baseApiUrl:p});t&&d(t)}else g("The `licenseKey` option not provided")}},2e3)}async function z(e){const{licenseKey:a,pluginName:n,baseApiUrl:i}=e;try{return(await F({baseApiUrl:i,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}var v=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e.dataSourceManagerPanel="dataSourceManagerPanel",e))(v||{});const S="sidebarButtonsTarget",w=(e,a)=>{const{id:n,icon:i,label:c,tooltip:p,className:f,skipSelfClose:b,removeLayouts:g,layoutComponent:d,layoutCommand:t}=e,{pluginOpts:r,breakpointProps:L}=a,s=n;return{id:E(n),type:"button",icon:i,tooltip:c||p,className:f,editorEvents:{[`${I.layoutToggleId}${s}`]:({fromEvent:u,setState:o,editor:l})=>{o({active:u.isOpen}),setTimeout(()=>l.refresh({tools:!0}),20)}},onClick:({editor:u,state:o})=>{var k;if(o.active&&b)return;const l=(t==null?void 0:t.placer)||{type:"static",layoutId:S},y={...l,skipCleanup:l.type==="static"},h=g||Object.keys(v).filter(R=>R!==s);U(u,{removeLayouts:h,layout:{placer:y}});const A={id:s,placer:l,header:(t==null?void 0:t.header)??{label:c,close:!b},layout:d,style:{width:280,height:"100%",borderRightWidth:1,...t==null?void 0:t.style}},T=((k=r==null?void 0:r.sidebarLayoutCommand)==null?void 0:k.call(r,{...L,layoutCommand:A,sidebarButtonProps:e}))||A;u.runCommand(B.layoutToggle,{...T})}}},E=e=>`button__${e}`,U=(e,a={})=>{(a.removeLayouts||Object.keys(v)).forEach(i=>e.runCommand(B.layoutRemove,{id:i,layout:a.layout}))},N=e=>{const a=(e==null?void 0:e.breakpointTablet)??1024,n=(e==null?void 0:e.breakpointMobile)??768,i={},c=[{id:v.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:v.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:v.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:v.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:s,editor:u})=>{var h;const o=u.getSelected(),l={type:"image",src:s.src};let y;if(o!=null&&o.is("image"))return o.set("src",s.src);o&&u.Components.canMove(o,l)?y=o.append(l)[0]:o||(y=(h=u.getWrapper())==null?void 0:h.append(l)[0]),y&&u.select(y,{scroll:!0})}}}],p=[...c,{id:v.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],f={id:S,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},b={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},g={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=s=>({breakpoint:s,breakpointTablet:a,breakpointMobile:n}),t=(s,u,o)=>{const l=d(u),y={pluginOpts:e,breakpointProps:l},h=s.map(T=>{const k=w(T,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:T.id,buttonIds:v,buttonProps:k,sidebarButtonProps:T,...l,createSidebarButton:R=>w({...T,...R},y)}):k}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:v,sidebarButtons:h,...l,createSidebarButton:T=>w({...T,layoutCommand:{...o==null?void 0:o.layoutCommand,...T.layoutCommand}},y)}):h).filter(Boolean)},r=(s,u,o)=>{var h;const l=d(o),y={pluginOpts:e,breakpointProps:l};return((h=e==null?void 0:e.rootLayout)==null?void 0:h.call(e,{sidebarButtons:u,rootLayout:s,layoutSidebarLeft:b,layoutSidebarTarget:f,...l,createSidebarButton:A=>w({...A},y)}))??s};if(a){const s=t(p,a);i[a]=r({type:"row",style:{height:"100%"},children:[{...b,children:s},f,g]},s,a)}if(n){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},u=p.map(l=>({...l,layoutCommand:s})),o=t(u,n,{layoutCommand:s});i[n]=r({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:o}]},o,n)}const L=t(c,0);return{default:r({type:"row",style:{height:"100%"},children:[{...b,children:L},f,g,{type:"sidebarRight"}]},L,0),responsive:i}},G="layoutSidebarButtons",J=P.free,Q=function(e,a={}){const{Commands:n}=e,i=n.events,c={...a};(()=>{if(e.runCommand(B.layoutConfigGet)||c.skipLayoutConfig===!0)return;const b=N(c);e.runCommand(B.layoutConfigSet,{...b})})(),n.add(`${G}:toggleButton`,(f,b,g)=>{const d=document.getElementById(E(g==null?void 0:g.id));d==null||d.click()}),e.on(`${i.runCommand}core:preview`,()=>{U(e)}),Z({editor:e,licenseKey:c.licenseKey,plan:J,pluginName:G,cleanup:()=>{e.runCommand(B.layoutConfigSet)}})},_=q(Q);_.createLayoutConfig=e=>N(e);module.exports=_;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var P = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(P || {}), B = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", 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.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", 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))(B || {}), I = /* @__PURE__ */ ((e) => (e.layoutToggleId = "studio:layoutToggle:", e.toggleBlocksPanel = "studio:toggleBlocksPanel", e.pageSettingsUpdate = "studio:pageSettingsUpdate", e.toggleDataSourcesPreview = "studio:toggleDataSourcesPreview", e))(I || {});
|
|
2
|
+
const x = "app.grapesjs.com", O = "app-stage.grapesjs.com", _ = "app2.grapesjs.com", $ = "app-stage2.grapesjs.com", M = [
|
|
3
|
+
x,
|
|
4
|
+
_,
|
|
5
|
+
O,
|
|
6
|
+
$,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -12,263 +12,265 @@ const M = "app.grapesjs.com", G = "app-stage.grapesjs.com", U = "app2.grapesjs.c
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
],
|
|
16
|
-
const e =
|
|
17
|
-
return !!e && (
|
|
15
|
+
], H = "license:check:start", j = "license:check:end", W = () => typeof window < "u", K = ({ isDev: e, isStage: a }) => `${e ? "" : `https://${a ? O : x}`}/api`, V = () => {
|
|
16
|
+
const e = W() && window.location.hostname;
|
|
17
|
+
return !!e && (M.includes(e) || M.some((a) => e.endsWith(a)));
|
|
18
18
|
};
|
|
19
|
-
async function
|
|
19
|
+
async function C({
|
|
20
20
|
path: e,
|
|
21
|
-
baseApiUrl:
|
|
22
|
-
method:
|
|
21
|
+
baseApiUrl: a,
|
|
22
|
+
method: n = "GET",
|
|
23
23
|
headers: i = {},
|
|
24
24
|
params: c,
|
|
25
25
|
body: p
|
|
26
26
|
}) {
|
|
27
|
-
const b = `${
|
|
28
|
-
method:
|
|
27
|
+
const b = `${a || K({ isDev: !1, isStage: !1 })}${e}`, g = {
|
|
28
|
+
method: n,
|
|
29
29
|
headers: {
|
|
30
30
|
"Content-Type": "application/json",
|
|
31
31
|
...i
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
p && (
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(`HTTP error! status: ${
|
|
38
|
-
return
|
|
34
|
+
p && (g.body = JSON.stringify(p));
|
|
35
|
+
const d = c ? new URLSearchParams(c).toString() : "", t = d ? `?${d}` : "", r = await fetch(`${b}${t}`, g);
|
|
36
|
+
if (!r.ok)
|
|
37
|
+
throw new Error(`HTTP error! status: ${r.status}`);
|
|
38
|
+
return r.json();
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
40
|
+
const D = {
|
|
41
|
+
[P.free]: 0,
|
|
42
|
+
[P.startup]: 10,
|
|
43
|
+
[P.business]: 20,
|
|
44
|
+
[P.enterprise]: 30
|
|
45
45
|
};
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return
|
|
46
|
+
function F(e) {
|
|
47
|
+
const a = e;
|
|
48
|
+
return a.init = (n) => (i) => e(i, n), a;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const m = (e) => /* @__PURE__ */ F(e);
|
|
51
51
|
async function q({
|
|
52
52
|
editor: e,
|
|
53
|
-
plan:
|
|
54
|
-
pluginName:
|
|
53
|
+
plan: a,
|
|
54
|
+
pluginName: n,
|
|
55
55
|
licenseKey: i,
|
|
56
56
|
cleanup: c
|
|
57
57
|
}) {
|
|
58
58
|
let p = "", f = !1;
|
|
59
|
-
const b =
|
|
60
|
-
console.warn("Cleanup plugin:",
|
|
61
|
-
},
|
|
62
|
-
var
|
|
63
|
-
const { error:
|
|
64
|
-
if (!(
|
|
65
|
-
r
|
|
59
|
+
const b = V(), g = (t) => {
|
|
60
|
+
console.warn("Cleanup plugin:", n, "Reason:", t), c();
|
|
61
|
+
}, d = (t = {}) => {
|
|
62
|
+
var o;
|
|
63
|
+
const { error: r, sdkLicense: L } = t, s = (o = t.plan) == null ? void 0 : o.category;
|
|
64
|
+
if (!(L || t.license) || r)
|
|
65
|
+
g(r || "Invalid license");
|
|
66
66
|
else if (s) {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const l = D[a], y = D[s];
|
|
68
|
+
l > y && g({ pluginRequiredPlan: a, licensePlan: s });
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
e.on(
|
|
72
|
-
p =
|
|
73
|
-
}), e.on(
|
|
74
|
-
|
|
71
|
+
e.on(H, (t) => {
|
|
72
|
+
p = t == null ? void 0 : t.baseApiUrl, f = !0;
|
|
73
|
+
}), e.on(j, (t) => {
|
|
74
|
+
d(t);
|
|
75
75
|
}), setTimeout(async () => {
|
|
76
76
|
if (!f) {
|
|
77
77
|
if (b) return;
|
|
78
78
|
if (i) {
|
|
79
|
-
const
|
|
80
|
-
|
|
79
|
+
const t = await Z({ licenseKey: i, pluginName: n, baseApiUrl: p });
|
|
80
|
+
t && d(t);
|
|
81
81
|
} else
|
|
82
|
-
|
|
82
|
+
g("The `licenseKey` option not provided");
|
|
83
83
|
}
|
|
84
84
|
}, 2e3);
|
|
85
85
|
}
|
|
86
|
-
async function
|
|
87
|
-
const { licenseKey:
|
|
86
|
+
async function Z(e) {
|
|
87
|
+
const { licenseKey: a, pluginName: n, baseApiUrl: i } = e;
|
|
88
88
|
try {
|
|
89
|
-
return (await
|
|
89
|
+
return (await C({
|
|
90
90
|
baseApiUrl: i,
|
|
91
|
-
path: `/sdk/${
|
|
91
|
+
path: `/sdk/${a || "na"}`,
|
|
92
92
|
method: "POST",
|
|
93
93
|
params: {
|
|
94
94
|
d: window.location.hostname,
|
|
95
|
-
pn:
|
|
95
|
+
pn: n
|
|
96
96
|
}
|
|
97
97
|
})).result || {};
|
|
98
98
|
} catch (c) {
|
|
99
99
|
return console.error("Error during SDK license check:", c), !1;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
var
|
|
103
|
-
const
|
|
104
|
-
const { id:
|
|
102
|
+
var v = /* @__PURE__ */ ((e) => (e.panelBlocks = "panelBlocks", e.panelPagesLayers = "panelPagesLayers", e.panelGlobalStyles = "panelGlobalStyles", e.panelSidebarTabs = "panelSidebarTabs", e.panelAssets = "panelAssets", e.aiChatPanel = "aiChatPanel", e.dataSourceManagerPanel = "dataSourceManagerPanel", e))(v || {});
|
|
103
|
+
const S = "sidebarButtonsTarget", w = (e, a) => {
|
|
104
|
+
const { id: n, icon: i, label: c, tooltip: p, className: f, skipSelfClose: b, removeLayouts: g, layoutComponent: d, layoutCommand: t } = e, { pluginOpts: r, breakpointProps: L } = a, s = n;
|
|
105
105
|
return {
|
|
106
|
-
id:
|
|
106
|
+
id: E(n),
|
|
107
107
|
type: "button",
|
|
108
|
-
icon:
|
|
109
|
-
tooltip:
|
|
110
|
-
className:
|
|
108
|
+
icon: i,
|
|
109
|
+
tooltip: c || p,
|
|
110
|
+
className: f,
|
|
111
111
|
editorEvents: {
|
|
112
|
-
[`${
|
|
113
|
-
|
|
112
|
+
[`${I.layoutToggleId}${s}`]: ({ fromEvent: u, setState: o, editor: l }) => {
|
|
113
|
+
o({ active: u.isOpen }), setTimeout(() => l.refresh({ tools: !0 }), 20);
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
|
-
onClick: ({ editor: u, state:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
header: (o == null ? void 0 : o.header) ?? { label: i, close: !f },
|
|
127
|
-
layout: r,
|
|
116
|
+
onClick: ({ editor: u, state: o }) => {
|
|
117
|
+
var k;
|
|
118
|
+
if (o.active && b) return;
|
|
119
|
+
const l = (t == null ? void 0 : t.placer) || { type: "static", layoutId: S }, y = { ...l, skipCleanup: l.type === "static" }, h = g || Object.keys(v).filter((R) => R !== s);
|
|
120
|
+
U(u, { removeLayouts: h, layout: { placer: y } });
|
|
121
|
+
const A = {
|
|
122
|
+
id: s,
|
|
123
|
+
placer: l,
|
|
124
|
+
header: (t == null ? void 0 : t.header) ?? { label: c, close: !b },
|
|
125
|
+
layout: d,
|
|
128
126
|
style: {
|
|
129
127
|
width: 280,
|
|
130
128
|
height: "100%",
|
|
131
129
|
borderRightWidth: 1,
|
|
132
|
-
...
|
|
130
|
+
...t == null ? void 0 : t.style
|
|
133
131
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
132
|
+
}, T = ((k = r == null ? void 0 : r.sidebarLayoutCommand) == null ? void 0 : k.call(r, {
|
|
133
|
+
...L,
|
|
134
|
+
layoutCommand: A,
|
|
135
|
+
sidebarButtonProps: e
|
|
136
|
+
})) || A;
|
|
137
|
+
u.runCommand(B.layoutToggle, { ...T });
|
|
136
138
|
}
|
|
137
139
|
};
|
|
138
|
-
},
|
|
139
|
-
(
|
|
140
|
-
},
|
|
141
|
-
const
|
|
140
|
+
}, E = (e) => `button__${e}`, U = (e, a = {}) => {
|
|
141
|
+
(a.removeLayouts || Object.keys(v)).forEach((i) => e.runCommand(B.layoutRemove, { id: i, layout: a.layout }));
|
|
142
|
+
}, N = (e) => {
|
|
143
|
+
const a = (e == null ? void 0 : e.breakpointTablet) ?? 1024, n = (e == null ? void 0 : e.breakpointMobile) ?? 768, i = {}, c = [
|
|
142
144
|
{
|
|
143
|
-
id:
|
|
145
|
+
id: v.panelBlocks,
|
|
144
146
|
icon: "plusBox",
|
|
145
147
|
label: "Blocks",
|
|
146
148
|
layoutComponent: { type: "panelBlocks" }
|
|
147
149
|
},
|
|
148
150
|
{
|
|
149
|
-
id:
|
|
151
|
+
id: v.panelPagesLayers,
|
|
150
152
|
icon: "layers",
|
|
151
153
|
label: "Pages & Layers",
|
|
152
154
|
layoutComponent: { type: "panelPagesLayers" }
|
|
153
155
|
},
|
|
154
156
|
{
|
|
155
|
-
id:
|
|
157
|
+
id: v.panelGlobalStyles,
|
|
156
158
|
icon: '<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',
|
|
157
159
|
label: "Global Styles",
|
|
158
160
|
layoutComponent: { type: "panelGlobalStyles" }
|
|
159
161
|
},
|
|
160
162
|
{
|
|
161
|
-
id:
|
|
163
|
+
id: v.panelAssets,
|
|
162
164
|
icon: '<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',
|
|
163
165
|
label: "Assets",
|
|
164
166
|
layoutComponent: {
|
|
165
167
|
type: "panelAssets",
|
|
166
168
|
content: { itemsPerRow: 2, header: { addUrl: !1 } },
|
|
167
169
|
style: { padding: 7 },
|
|
168
|
-
onSelect: ({ assetProps: s, editor:
|
|
169
|
-
var
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
y && g.select(y);
|
|
176
|
-
} else if (!n) {
|
|
177
|
-
const y = (v = g.getWrapper()) == null ? void 0 : v.append(d)[0];
|
|
178
|
-
y && g.select(y);
|
|
179
|
-
}
|
|
170
|
+
onSelect: ({ assetProps: s, editor: u }) => {
|
|
171
|
+
var h;
|
|
172
|
+
const o = u.getSelected(), l = { type: "image", src: s.src };
|
|
173
|
+
let y;
|
|
174
|
+
if (o != null && o.is("image"))
|
|
175
|
+
return o.set("src", s.src);
|
|
176
|
+
o && u.Components.canMove(o, l) ? y = o.append(l)[0] : o || (y = (h = u.getWrapper()) == null ? void 0 : h.append(l)[0]), y && u.select(y, { scroll: !0 });
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
179
|
}
|
|
183
|
-
],
|
|
184
|
-
...
|
|
180
|
+
], p = [
|
|
181
|
+
...c,
|
|
185
182
|
{
|
|
186
|
-
id:
|
|
183
|
+
id: v.panelSidebarTabs,
|
|
187
184
|
layoutCommand: { header: !1 },
|
|
188
185
|
icon: '<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',
|
|
189
186
|
label: "Styles & Props",
|
|
190
187
|
layoutComponent: { type: "panelSidebarTabs" }
|
|
191
188
|
}
|
|
192
|
-
],
|
|
193
|
-
id:
|
|
189
|
+
], f = {
|
|
190
|
+
id: S,
|
|
194
191
|
type: "column",
|
|
195
192
|
className: "gs-cmp-layout-sidebar-target",
|
|
196
193
|
style: { overflow: "hidden" }
|
|
197
|
-
},
|
|
194
|
+
}, b = {
|
|
198
195
|
type: "sidebarLeft",
|
|
199
196
|
resizable: !1,
|
|
200
197
|
style: { padding: "10px 5px", alignItems: "center", width: 45, gap: 10 },
|
|
201
198
|
children: []
|
|
202
|
-
},
|
|
199
|
+
}, g = {
|
|
203
200
|
type: "canvasSidebarTop",
|
|
204
201
|
sidebarTop: {
|
|
205
202
|
leftContainer: {
|
|
206
203
|
buttons: []
|
|
207
204
|
}
|
|
208
205
|
}
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
}, d = (s) => ({
|
|
207
|
+
breakpoint: s,
|
|
208
|
+
breakpointTablet: a,
|
|
209
|
+
breakpointMobile: n
|
|
210
|
+
}), t = (s, u, o) => {
|
|
211
|
+
const l = d(u), y = { pluginOpts: e, breakpointProps: l }, h = s.map((T) => {
|
|
212
|
+
const k = w(T, y);
|
|
212
213
|
return e != null && e.sidebarButton ? e.sidebarButton({
|
|
213
|
-
id:
|
|
214
|
-
buttonIds:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
...
|
|
219
|
-
|
|
220
|
-
}) : B;
|
|
214
|
+
id: T.id,
|
|
215
|
+
buttonIds: v,
|
|
216
|
+
buttonProps: k,
|
|
217
|
+
sidebarButtonProps: T,
|
|
218
|
+
...l,
|
|
219
|
+
createSidebarButton: (R) => w({ ...T, ...R }, y)
|
|
220
|
+
}) : k;
|
|
221
221
|
}).filter(Boolean);
|
|
222
222
|
return (e != null && e.sidebarButtons ? e == null ? void 0 : e.sidebarButtons({
|
|
223
|
-
buttonIds:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
223
|
+
buttonIds: v,
|
|
224
|
+
sidebarButtons: h,
|
|
225
|
+
...l,
|
|
226
|
+
createSidebarButton: (T) => w(
|
|
227
|
+
{
|
|
228
|
+
...T,
|
|
229
|
+
layoutCommand: {
|
|
230
|
+
...o == null ? void 0 : o.layoutCommand,
|
|
231
|
+
...T.layoutCommand
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
y
|
|
235
|
+
)
|
|
236
|
+
}) : h).filter(Boolean);
|
|
237
|
+
}, r = (s, u, o) => {
|
|
238
|
+
var h;
|
|
239
|
+
const l = d(o), y = { pluginOpts: e, breakpointProps: l };
|
|
240
|
+
return ((h = e == null ? void 0 : e.rootLayout) == null ? void 0 : h.call(e, {
|
|
241
|
+
sidebarButtons: u,
|
|
240
242
|
rootLayout: s,
|
|
241
|
-
layoutSidebarLeft:
|
|
242
|
-
layoutSidebarTarget:
|
|
243
|
-
...
|
|
244
|
-
createSidebarButton: (
|
|
243
|
+
layoutSidebarLeft: b,
|
|
244
|
+
layoutSidebarTarget: f,
|
|
245
|
+
...l,
|
|
246
|
+
createSidebarButton: (A) => w({ ...A }, y)
|
|
245
247
|
})) ?? s;
|
|
246
248
|
};
|
|
247
|
-
if (
|
|
248
|
-
const s =
|
|
249
|
-
|
|
249
|
+
if (a) {
|
|
250
|
+
const s = t(p, a);
|
|
251
|
+
i[a] = r(
|
|
250
252
|
{
|
|
251
253
|
type: "row",
|
|
252
254
|
style: { height: "100%" },
|
|
253
255
|
children: [
|
|
254
256
|
{
|
|
255
|
-
...
|
|
257
|
+
...b,
|
|
256
258
|
children: s
|
|
257
259
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
+
f,
|
|
261
|
+
g
|
|
260
262
|
]
|
|
261
263
|
},
|
|
262
264
|
s,
|
|
263
|
-
|
|
265
|
+
a
|
|
264
266
|
);
|
|
265
267
|
}
|
|
266
|
-
if (
|
|
268
|
+
if (n) {
|
|
267
269
|
const s = {
|
|
268
270
|
placer: { type: "absolute", position: "left" },
|
|
269
271
|
style: { height: "calc(100% - 40px)" }
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
+
}, u = p.map((l) => ({ ...l, layoutCommand: s })), o = t(u, n, { layoutCommand: s });
|
|
273
|
+
i[n] = r(
|
|
272
274
|
{
|
|
273
275
|
type: "column",
|
|
274
276
|
style: { height: "100%" },
|
|
@@ -278,59 +280,59 @@ const I = "sidebarButtonsTarget", A = (e) => {
|
|
|
278
280
|
{
|
|
279
281
|
type: "sidebarBottom",
|
|
280
282
|
style: { padding: "0 5px", alignItems: "center", gap: 10, minHeight: 39 },
|
|
281
|
-
children:
|
|
283
|
+
children: o
|
|
282
284
|
}
|
|
283
285
|
]
|
|
284
286
|
},
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
o,
|
|
288
|
+
n
|
|
287
289
|
);
|
|
288
290
|
}
|
|
289
|
-
const
|
|
291
|
+
const L = t(c, 0);
|
|
290
292
|
return {
|
|
291
|
-
default:
|
|
293
|
+
default: r(
|
|
292
294
|
{
|
|
293
295
|
type: "row",
|
|
294
296
|
style: { height: "100%" },
|
|
295
297
|
children: [
|
|
296
298
|
{
|
|
297
|
-
...
|
|
298
|
-
children:
|
|
299
|
+
...b,
|
|
300
|
+
children: L
|
|
299
301
|
},
|
|
300
|
-
|
|
301
|
-
|
|
302
|
+
f,
|
|
303
|
+
g,
|
|
302
304
|
{ type: "sidebarRight" }
|
|
303
305
|
]
|
|
304
306
|
},
|
|
305
|
-
|
|
307
|
+
L,
|
|
306
308
|
0
|
|
307
309
|
),
|
|
308
|
-
responsive:
|
|
310
|
+
responsive: i
|
|
309
311
|
};
|
|
310
|
-
},
|
|
311
|
-
const { Commands:
|
|
312
|
-
...
|
|
312
|
+
}, G = "layoutSidebarButtons", z = P.free, J = function(e, a = {}) {
|
|
313
|
+
const { Commands: n } = e, i = n.events, c = {
|
|
314
|
+
...a
|
|
313
315
|
};
|
|
314
316
|
(() => {
|
|
315
|
-
if (e.runCommand(
|
|
316
|
-
const b =
|
|
317
|
-
e.runCommand(
|
|
318
|
-
})(),
|
|
319
|
-
const
|
|
320
|
-
|
|
317
|
+
if (e.runCommand(B.layoutConfigGet) || c.skipLayoutConfig === !0) return;
|
|
318
|
+
const b = N(c);
|
|
319
|
+
e.runCommand(B.layoutConfigSet, { ...b });
|
|
320
|
+
})(), n.add(`${G}:toggleButton`, (f, b, g) => {
|
|
321
|
+
const d = document.getElementById(E(g == null ? void 0 : g.id));
|
|
322
|
+
d == null || d.click();
|
|
321
323
|
}), e.on(`${i.runCommand}core:preview`, () => {
|
|
322
|
-
|
|
324
|
+
U(e);
|
|
323
325
|
}), q({
|
|
324
326
|
editor: e,
|
|
325
327
|
licenseKey: c.licenseKey,
|
|
326
|
-
plan:
|
|
327
|
-
pluginName:
|
|
328
|
+
plan: z,
|
|
329
|
+
pluginName: G,
|
|
328
330
|
cleanup: () => {
|
|
329
|
-
e.runCommand(
|
|
331
|
+
e.runCommand(B.layoutConfigSet);
|
|
330
332
|
}
|
|
331
333
|
});
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
+
}, Q = m(J);
|
|
335
|
+
Q.createLayoutConfig = (e) => N(e);
|
|
334
336
|
export {
|
|
335
|
-
|
|
337
|
+
Q as default
|
|
336
338
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_layoutSidebarButtons=v())})(this,function(){"use strict";var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",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))(v||{}),B=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(B||{});const k="app.grapesjs.com",R="app-stage.grapesjs.com",w=[k,"app2.grapesjs.com",R,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],N="license:check:start",_="license:check:end",U=()=>typeof window<"u",$=({isDev:e,isStage:t})=>`${e?"":`https://${t?R:k}`}/api`,H=()=>{const e=U()&&window.location.hostname;return!!e&&(w.includes(e)||w.some(t=>e.endsWith(t)))};async function j({path:e,baseApiUrl:t,method:l="GET",headers:i={},params:c,body:f}){const b=`${t||$({isDev:!1,isStage:!1})}${e}`,r={method:l,headers:{"Content-Type":"application/json",...i}};f&&(r.body=JSON.stringify(f));const o=c?new URLSearchParams(c).toString():"",a=o?`?${o}`:"",u=await fetch(`${b}${a}`,r);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}const D={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function W(e){const t=e;return t.init=l=>i=>e(i,l),t}const K=e=>W(e);async function V({editor:e,plan:t,pluginName:l,licenseKey:i,cleanup:c}){let f="",p=!1;const b=H(),r=a=>{console.warn("Cleanup plugin:",l,"Reason:",a),c()},o=(a={})=>{var n;const{error:u,sdkLicense:P}=a,s=(n=a.plan)==null?void 0:n.category;if(!(P||a.license)||u)r(u||"Invalid license");else if(s){const d=D[t],L=D[s];d>L&&r({pluginRequiredPlan:t,licensePlan:s})}};e.on(N,a=>{f=a==null?void 0:a.baseApiUrl,p=!0}),e.on(_,a=>{o(a)}),setTimeout(async()=>{if(!p){if(b)return;if(i){const a=await F({licenseKey:i,pluginName:l,baseApiUrl:f});a&&o(a)}else r("The `licenseKey` option not provided")}},2e3)}async function F(e){const{licenseKey:t,pluginName:l,baseApiUrl:i}=e;try{return(await j({baseApiUrl:i,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:l}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}var T=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e))(T||{});const M="sidebarButtonsTarget",A=e=>{const{id:t,icon:l,label:i,tooltip:c,className:f,skipSelfClose:p,removeLayouts:b,layoutComponent:r,layoutCommand:o}=e,a=t;return{id:G(t),type:"button",icon:l,tooltip:i||c,className:f,editorEvents:{[`${B.layoutToggleId}${a}`]:({fromEvent:u,setState:P,editor:s})=>{P({active:u.isOpen}),setTimeout(()=>s.refresh({tools:!0}),20)}},onClick:({editor:u,state:P})=>{if(P.active&&p)return;const s=(o==null?void 0:o.placer)||{type:"static",layoutId:M},g={...s,skipCleanup:s.type==="static"},n=b||Object.keys(T).filter(L=>L!==a);I(u,{removeLayouts:n,layout:{placer:g}});const d={id:a,placer:s,header:(o==null?void 0:o.header)??{label:i,close:!p},layout:r,style:{width:280,height:"100%",borderRightWidth:1,...o==null?void 0:o.style}};u.runCommand(v.layoutToggle,d)}}},G=e=>`button__${e}`,I=(e,t={})=>{(t.removeLayouts||Object.keys(T)).forEach(i=>e.runCommand(v.layoutRemove,{id:i,layout:t.layout}))},O=e=>{const t=(e==null?void 0:e.breakpointTablet)??1024,l=(e==null?void 0:e.breakpointMobile)??768,i={breakpointTablet:t,breakpointMobile:l},c={},f=[{id:T.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:T.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:T.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:T.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:s,editor:g})=>{var L;const n=g.getSelected(),d={type:"image",src:s.src};if(n!=null&&n.is("image"))return n.set("src",s.src);if(n&&g.Components.canMove(n,d)){const y=n.append(d)[0];y&&g.select(y)}else if(!n){const y=(L=g.getWrapper())==null?void 0:L.append(d)[0];y&&g.select(y)}}}}],p=[...f,{id:T.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],b={id:M,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},r={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},o={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},a=(s,g,n)=>{const d=s.map(y=>{const E=A(y);return e!=null&&e.sidebarButton?e.sidebarButton({id:y.id,buttonIds:T,breakpoint:g,buttonProps:E,sidebarButtonProps:y,...i,createSidebarButton:C=>A({...y,...C})}):E}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:T,breakpoint:g,sidebarButtons:d,...i,createSidebarButton:y=>A({...y,layoutCommand:{...n==null?void 0:n.layoutCommand,...y.layoutCommand}})}):d).filter(Boolean)},u=(s,g,n)=>{var d;return((d=e==null?void 0:e.rootLayout)==null?void 0:d.call(e,{breakpoint:n,sidebarButtons:g,rootLayout:s,layoutSidebarLeft:r,layoutSidebarTarget:b,...i,createSidebarButton:L=>A({...L})}))??s};if(t){const s=a(p,t);c[t]=u({type:"row",style:{height:"100%"},children:[{...r,children:s},b,o]},s,t)}if(l){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},g=p.map(d=>({...d,layoutCommand:s})),n=a(g,l,{layoutCommand:s});c[l]=u({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:n}]},n,l)}const P=a(f,0);return{default:u({type:"row",style:{height:"100%"},children:[{...r,children:P},b,o,{type:"sidebarRight"}]},P,0),responsive:c}},S="layoutSidebarButtons",q=h.free,x=K(function(e,t={}){const{Commands:l}=e,i=l.events,c={...t};(()=>{if(e.runCommand(v.layoutConfigGet)||c.skipLayoutConfig===!0)return;const b=O(c);e.runCommand(v.layoutConfigSet,{...b})})(),l.add(`${S}:toggleButton`,(p,b,r)=>{const o=document.getElementById(G(r==null?void 0:r.id));o==null||o.click()}),e.on(`${i.runCommand}core:preview`,()=>{I(e)}),V({editor:e,licenseKey:c.licenseKey,plan:q,pluginName:S,cleanup:()=>{e.runCommand(v.layoutConfigSet)}})});return x.createLayoutConfig=e=>O(e),x});
|
|
1
|
+
(function(h,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_layoutSidebarButtons=v())})(this,function(){"use strict";var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",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.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",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))(v||{}),M=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(M||{});const D="app.grapesjs.com",G="app-stage.grapesjs.com",I=[D,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",H="license:check:end",j=()=>typeof window<"u",W=({isDev:e,isStage:a})=>`${e?"":`https://${a?G:D}`}/api`,m=()=>{const e=j()&&window.location.hostname;return!!e&&(I.includes(e)||I.some(a=>e.endsWith(a)))};async function K({path:e,baseApiUrl:a,method:n="GET",headers:i={},params:c,body:p}){const b=`${a||W({isDev:!1,isStage:!1})}${e}`,g={method:n,headers:{"Content-Type":"application/json",...i}};p&&(g.body=JSON.stringify(p));const d=c?new URLSearchParams(c).toString():"",t=d?`?${d}`:"",r=await fetch(`${b}${t}`,g);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const O={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function V(e){const a=e;return a.init=n=>i=>e(i,n),a}const C=e=>V(e);async function F({editor:e,plan:a,pluginName:n,licenseKey:i,cleanup:c}){let p="",f=!1;const b=m(),g=t=>{console.warn("Cleanup plugin:",n,"Reason:",t),c()},d=(t={})=>{var o;const{error:r,sdkLicense:A}=t,s=(o=t.plan)==null?void 0:o.category;if(!(A||t.license)||r)g(r||"Invalid license");else if(s){const l=O[a],y=O[s];l>y&&g({pluginRequiredPlan:a,licensePlan:s})}};e.on($,t=>{p=t==null?void 0:t.baseApiUrl,f=!0}),e.on(H,t=>{d(t)}),setTimeout(async()=>{if(!f){if(b)return;if(i){const t=await q({licenseKey:i,pluginName:n,baseApiUrl:p});t&&d(t)}else g("The `licenseKey` option not provided")}},2e3)}async function q(e){const{licenseKey:a,pluginName:n,baseApiUrl:i}=e;try{return(await K({baseApiUrl:i,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}var T=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e.dataSourceManagerPanel="dataSourceManagerPanel",e))(T||{});const S="sidebarButtonsTarget",R=(e,a)=>{const{id:n,icon:i,label:c,tooltip:p,className:f,skipSelfClose:b,removeLayouts:g,layoutComponent:d,layoutCommand:t}=e,{pluginOpts:r,breakpointProps:A}=a,s=n;return{id:x(n),type:"button",icon:i,tooltip:c||p,className:f,editorEvents:{[`${M.layoutToggleId}${s}`]:({fromEvent:u,setState:o,editor:l})=>{o({active:u.isOpen}),setTimeout(()=>l.refresh({tools:!0}),20)}},onClick:({editor:u,state:o})=>{var k;if(o.active&&b)return;const l=(t==null?void 0:t.placer)||{type:"static",layoutId:S},y={...l,skipCleanup:l.type==="static"},P=g||Object.keys(T).filter(w=>w!==s);E(u,{removeLayouts:P,layout:{placer:y}});const B={id:s,placer:l,header:(t==null?void 0:t.header)??{label:c,close:!b},layout:d,style:{width:280,height:"100%",borderRightWidth:1,...t==null?void 0:t.style}},L=((k=r==null?void 0:r.sidebarLayoutCommand)==null?void 0:k.call(r,{...A,layoutCommand:B,sidebarButtonProps:e}))||B;u.runCommand(v.layoutToggle,{...L})}}},x=e=>`button__${e}`,E=(e,a={})=>{(a.removeLayouts||Object.keys(T)).forEach(i=>e.runCommand(v.layoutRemove,{id:i,layout:a.layout}))},N=e=>{const a=(e==null?void 0:e.breakpointTablet)??1024,n=(e==null?void 0:e.breakpointMobile)??768,i={},c=[{id:T.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:T.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:T.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:T.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:s,editor:u})=>{var P;const o=u.getSelected(),l={type:"image",src:s.src};let y;if(o!=null&&o.is("image"))return o.set("src",s.src);o&&u.Components.canMove(o,l)?y=o.append(l)[0]:o||(y=(P=u.getWrapper())==null?void 0:P.append(l)[0]),y&&u.select(y,{scroll:!0})}}}],p=[...c,{id:T.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],f={id:S,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},b={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},g={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=s=>({breakpoint:s,breakpointTablet:a,breakpointMobile:n}),t=(s,u,o)=>{const l=d(u),y={pluginOpts:e,breakpointProps:l},P=s.map(L=>{const k=R(L,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:L.id,buttonIds:T,buttonProps:k,sidebarButtonProps:L,...l,createSidebarButton:w=>R({...L,...w},y)}):k}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:T,sidebarButtons:P,...l,createSidebarButton:L=>R({...L,layoutCommand:{...o==null?void 0:o.layoutCommand,...L.layoutCommand}},y)}):P).filter(Boolean)},r=(s,u,o)=>{var P;const l=d(o),y={pluginOpts:e,breakpointProps:l};return((P=e==null?void 0:e.rootLayout)==null?void 0:P.call(e,{sidebarButtons:u,rootLayout:s,layoutSidebarLeft:b,layoutSidebarTarget:f,...l,createSidebarButton:B=>R({...B},y)}))??s};if(a){const s=t(p,a);i[a]=r({type:"row",style:{height:"100%"},children:[{...b,children:s},f,g]},s,a)}if(n){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},u=p.map(l=>({...l,layoutCommand:s})),o=t(u,n,{layoutCommand:s});i[n]=r({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:o}]},o,n)}const A=t(c,0);return{default:r({type:"row",style:{height:"100%"},children:[{...b,children:A},f,g,{type:"sidebarRight"}]},A,0),responsive:i}},_="layoutSidebarButtons",Z=h.free,U=C(function(e,a={}){const{Commands:n}=e,i=n.events,c={...a};(()=>{if(e.runCommand(v.layoutConfigGet)||c.skipLayoutConfig===!0)return;const b=N(c);e.runCommand(v.layoutConfigSet,{...b})})(),n.add(`${_}:toggleButton`,(f,b,g)=>{const d=document.getElementById(x(g==null?void 0:g.id));d==null||d.click()}),e.on(`${i.runCommand}core:preview`,()=>{E(e)}),F({editor:e,licenseKey:c.licenseKey,plan:Z,pluginName:_,cleanup:()=>{e.runCommand(v.layoutConfigSet)}})});return U.createLayoutConfig=e=>N(e),U});
|