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