@grapesjs/studio-sdk-plugins 1.0.36 → 1.0.38-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +4 -4
- package/dist/accordionComponent/index.es.js +83 -70
- package/dist/accordionComponent/index.umd.js +5 -5
- package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
- package/dist/aiChat/components/utils.d.ts +1 -0
- package/dist/aiChat/components/utilsTw.d.ts +11 -0
- package/dist/aiChat/index.cjs.js +85 -85
- package/dist/aiChat/index.es.js +11151 -10258
- package/dist/aiChat/index.js +85 -85
- package/dist/aiChat/index.umd.js +86 -86
- package/dist/aiChat/locales/en.d.ts +11 -0
- package/dist/aiChat/projectGeneration.d.ts +17 -0
- package/dist/aiChat/server/index.cjs.js +1 -1
- package/dist/aiChat/server/index.es.js +1 -1
- package/dist/aiChat/server/index.js +1 -1
- package/dist/aiChat/server/index.umd.js +1 -1
- package/dist/aiChat/types.d.ts +1 -1
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +57 -44
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +63 -50
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +60 -47
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +49 -36
- package/dist/canvasFullSize/index.umd.js +5 -5
- package/dist/canvasGridMode/index.cjs.js +2 -2
- package/dist/canvasGridMode/index.es.js +251 -233
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +42 -29
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +51 -38
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +2 -2
- package/dist/dataSourceHandlebars/index.es.js +152 -139
- package/dist/dataSourceHandlebars/index.umd.js +4 -4
- package/dist/dialogComponent/index.cjs.js +9 -9
- package/dist/dialogComponent/index.es.js +73 -60
- package/dist/dialogComponent/index.umd.js +3 -3
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +83 -70
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +67 -54
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +92 -79
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +52 -39
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +42 -42
- package/dist/index.es.js +1167 -1149
- package/dist/index.umd.js +42 -42
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +82 -69
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +98 -85
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +71 -58
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +49 -36
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/presetPrintable/index.cjs.js +5 -5
- package/dist/presetPrintable/index.es.js +126 -113
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +97 -84
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +149 -137
- 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 +92 -79
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +3 -3
- package/dist/shapeDividerComponent/index.es.js +38 -25
- package/dist/shapeDividerComponent/index.umd.js +3 -3
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +106 -93
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +167 -154
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +35 -22
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
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
|
+
"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.openEditCode="studio:openEditCode",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",E="app-stage.grapesjs.com",_="app2.grapesjs.com",j="app-stage2.grapesjs.com",D=[x,_,E,j,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],m="license:check:end",W=()=>typeof window<"u",C=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?E:x}`}/${a?"platform-api":"api"}`,F=()=>{if(!W())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},S=()=>{const e=F();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||C({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 K(e){const o=e;return o.init=a=>c=>e(c,a),o}const q=e=>K(e);async function Z({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(!S())if(c){const t=await J({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(m,t=>u(t))}const z=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function J(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 O="sidebarButtonsTarget",R=(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 w;if(s.active&&r)return;const l=(u==null?void 0:u.placer)||{type:"static",layoutId:O},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=((w=t==null?void 0:t.sidebarLayoutCommand)==null?void 0:w.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: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},p=n.map(P=>{const w=R(P,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:P.id,buttonIds:v,buttonProps:w,sidebarButtonProps:P,...l,createSidebarButton:k=>R({...P,...k},y)}):w}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:v,sidebarButtons:p,...l,createSidebarButton:P=>R({...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=>R({...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",Q=B.free,X=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)}),Z({editor:e,licenseKey:i.licenseKey,plan:Q,pluginName:M,cleanup:()=>{e.runCommand(T.layoutConfigSet)}})},H=q(X);H.createLayoutConfig=e=>N(e);module.exports=H;
|
|
@@ -1,35 +1,48 @@
|
|
|
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",
|
|
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.openEditCode = "studio:openEditCode", 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", E = "app-stage.grapesjs.com", H = "app2.grapesjs.com", _ = "app-stage2.grapesjs.com", D = [
|
|
3
3
|
x,
|
|
4
|
-
_,
|
|
5
|
-
O,
|
|
6
4
|
H,
|
|
5
|
+
E,
|
|
6
|
+
_,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
10
10
|
// For stackblitz.com demos
|
|
11
11
|
".local.webcontainer.io",
|
|
12
12
|
// For stackblitz.com demos
|
|
13
|
-
"-sandpack.codesandbox.io"
|
|
13
|
+
"-sandpack.codesandbox.io",
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
|
|
15
|
+
".claudemcpcontent.com",
|
|
16
|
+
// For Claude mcp app
|
|
17
|
+
".web-sandbox.oaiusercontent.com"
|
|
18
|
+
// For OpenAI mcp app
|
|
19
|
+
], j = "license:check:end", m = () => typeof window < "u", W = ({
|
|
16
20
|
isDev: e,
|
|
17
|
-
isStage:
|
|
18
|
-
isPlatform:
|
|
19
|
-
}) => `${e ? "" : `https://${
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
isStage: o,
|
|
22
|
+
isPlatform: a
|
|
23
|
+
}) => `${e ? "" : `https://${o ? E : x}`}/${a ? "platform-api" : "api"}`, C = () => {
|
|
24
|
+
if (!m()) return "";
|
|
25
|
+
const { hostname: e } = window.location;
|
|
26
|
+
if (e) return e;
|
|
27
|
+
try {
|
|
28
|
+
return window.parent.location.hostname || "";
|
|
29
|
+
} catch {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
}, F = () => {
|
|
33
|
+
const e = C();
|
|
34
|
+
return !!e && (D.includes(e) || D.some((o) => e.endsWith(o)));
|
|
22
35
|
};
|
|
23
|
-
async function
|
|
36
|
+
async function S({
|
|
24
37
|
path: e,
|
|
25
|
-
baseApiUrl:
|
|
26
|
-
method:
|
|
38
|
+
baseApiUrl: o,
|
|
39
|
+
method: a = "GET",
|
|
27
40
|
headers: c = {},
|
|
28
41
|
params: i,
|
|
29
42
|
body: h
|
|
30
43
|
}) {
|
|
31
|
-
const r = `${
|
|
32
|
-
method:
|
|
44
|
+
const r = `${o || W({ isDev: !1, isStage: !1 })}${e}`, d = {
|
|
45
|
+
method: a,
|
|
33
46
|
headers: {
|
|
34
47
|
"Content-Type": "application/json",
|
|
35
48
|
...c
|
|
@@ -48,29 +61,29 @@ const G = {
|
|
|
48
61
|
[B.enterprise]: 30
|
|
49
62
|
};
|
|
50
63
|
function V(e) {
|
|
51
|
-
const
|
|
52
|
-
return
|
|
64
|
+
const o = e;
|
|
65
|
+
return o.init = (a) => (c) => e(c, a), o;
|
|
53
66
|
}
|
|
54
|
-
const
|
|
55
|
-
async function
|
|
67
|
+
const K = (e) => /* @__PURE__ */ V(e);
|
|
68
|
+
async function q({
|
|
56
69
|
editor: e,
|
|
57
|
-
plan:
|
|
58
|
-
pluginName:
|
|
70
|
+
plan: o,
|
|
71
|
+
pluginName: a,
|
|
59
72
|
licenseKey: c,
|
|
60
73
|
onLicenseCheckResponse: i,
|
|
61
74
|
cleanup: h
|
|
62
75
|
}) {
|
|
63
76
|
let f = "", r;
|
|
64
77
|
const d = (t) => {
|
|
65
|
-
console.warn("Cleanup plugin:",
|
|
78
|
+
console.warn("Cleanup plugin:", a, "Reason:", t), h();
|
|
66
79
|
}, b = (t = {}) => {
|
|
67
80
|
var l;
|
|
68
81
|
const { error: L, sdkLicense: n } = t, g = (l = t.plan) == null ? void 0 : l.category;
|
|
69
82
|
if (!(n || t.license) || L)
|
|
70
83
|
d(L || "Invalid license");
|
|
71
84
|
else if (g) {
|
|
72
|
-
const y = G[
|
|
73
|
-
y > p && d({ pluginRequiredPlan:
|
|
85
|
+
const y = G[o], p = G[g];
|
|
86
|
+
y > p && d({ pluginRequiredPlan: o, licensePlan: g });
|
|
74
87
|
}
|
|
75
88
|
};
|
|
76
89
|
e.Commands.has(T.settings) && (r = e.runCommand(T.settings), f = (r == null ? void 0 : r.baseUrl) || "");
|
|
@@ -79,9 +92,9 @@ async function K({
|
|
|
79
92
|
};
|
|
80
93
|
if (!r) {
|
|
81
94
|
e.onReady(async () => {
|
|
82
|
-
if (!
|
|
95
|
+
if (!F())
|
|
83
96
|
if (c) {
|
|
84
|
-
const t = await
|
|
97
|
+
const t = await z({ licenseKey: c, pluginName: a, baseApiUrl: f });
|
|
85
98
|
u(t);
|
|
86
99
|
} else
|
|
87
100
|
d("The `licenseKey` option not provided");
|
|
@@ -89,28 +102,28 @@ async function K({
|
|
|
89
102
|
return;
|
|
90
103
|
}
|
|
91
104
|
if (r.licensePlan || r.licenseError) {
|
|
92
|
-
const t =
|
|
105
|
+
const t = Z(r);
|
|
93
106
|
u(t);
|
|
94
107
|
return;
|
|
95
108
|
}
|
|
96
109
|
e.on(j, (t) => u(t));
|
|
97
110
|
}
|
|
98
|
-
const
|
|
111
|
+
const Z = (e) => ({
|
|
99
112
|
sdkLicense: e.license,
|
|
100
113
|
license: e.license,
|
|
101
114
|
error: e.licenseError,
|
|
102
115
|
plan: e.licensePlan
|
|
103
116
|
});
|
|
104
|
-
async function
|
|
105
|
-
const { licenseKey:
|
|
117
|
+
async function z(e) {
|
|
118
|
+
const { licenseKey: o, pluginName: a, baseApiUrl: c } = e;
|
|
106
119
|
try {
|
|
107
|
-
return (await
|
|
120
|
+
return (await S({
|
|
108
121
|
baseApiUrl: c,
|
|
109
|
-
path: `/sdk/${
|
|
122
|
+
path: `/sdk/${o || "na"}`,
|
|
110
123
|
method: "POST",
|
|
111
124
|
params: {
|
|
112
125
|
d: window.location.hostname,
|
|
113
|
-
pn:
|
|
126
|
+
pn: a
|
|
114
127
|
}
|
|
115
128
|
})).result || {};
|
|
116
129
|
} catch (i) {
|
|
@@ -118,10 +131,10 @@ async function Z(e) {
|
|
|
118
131
|
}
|
|
119
132
|
}
|
|
120
133
|
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 || {});
|
|
121
|
-
const
|
|
122
|
-
const { id:
|
|
134
|
+
const O = "sidebarButtonsTarget", R = (e, o) => {
|
|
135
|
+
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;
|
|
123
136
|
return {
|
|
124
|
-
id: U(
|
|
137
|
+
id: U(a),
|
|
125
138
|
type: "button",
|
|
126
139
|
icon: c,
|
|
127
140
|
tooltip: i || h,
|
|
@@ -132,9 +145,9 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
132
145
|
}
|
|
133
146
|
},
|
|
134
147
|
onClick: ({ editor: g, state: s }) => {
|
|
135
|
-
var
|
|
148
|
+
var w;
|
|
136
149
|
if (s.active && r) return;
|
|
137
|
-
const l = (u == null ? void 0 : u.placer) || { type: "static", layoutId:
|
|
150
|
+
const l = (u == null ? void 0 : u.placer) || { type: "static", layoutId: O }, y = { ...l, skipCleanup: l.type === "static" }, p = d || Object.keys(v).filter((k) => k !== n);
|
|
138
151
|
$(g, { removeLayouts: p, layout: { placer: y } });
|
|
139
152
|
const A = {
|
|
140
153
|
id: n,
|
|
@@ -147,7 +160,7 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
147
160
|
borderRightWidth: 1,
|
|
148
161
|
...u == null ? void 0 : u.style
|
|
149
162
|
}
|
|
150
|
-
}, P = ((
|
|
163
|
+
}, P = ((w = t == null ? void 0 : t.sidebarLayoutCommand) == null ? void 0 : w.call(t, {
|
|
151
164
|
...L,
|
|
152
165
|
layoutCommand: A,
|
|
153
166
|
sidebarButtonProps: e
|
|
@@ -155,10 +168,10 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
155
168
|
g.runCommand(T.layoutToggle, { ...P });
|
|
156
169
|
}
|
|
157
170
|
};
|
|
158
|
-
}, U = (e) => `button__${e}`, $ = (e,
|
|
159
|
-
(
|
|
171
|
+
}, U = (e) => `button__${e}`, $ = (e, o = {}) => {
|
|
172
|
+
(o.removeLayouts || Object.keys(v)).forEach((c) => e.runCommand(T.layoutRemove, { id: c, layout: o.layout }));
|
|
160
173
|
}, N = (e) => {
|
|
161
|
-
const
|
|
174
|
+
const o = (e == null ? void 0 : e.breakpointTablet) ?? 1024, a = (e == null ? void 0 : e.breakpointMobile) ?? 768, c = {}, i = [
|
|
162
175
|
{
|
|
163
176
|
id: v.panelBlocks,
|
|
164
177
|
icon: "plusBox",
|
|
@@ -205,7 +218,7 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
205
218
|
layoutComponent: { type: "panelSidebarTabs" }
|
|
206
219
|
}
|
|
207
220
|
], f = {
|
|
208
|
-
id:
|
|
221
|
+
id: O,
|
|
209
222
|
type: "column",
|
|
210
223
|
className: "gs-cmp-layout-sidebar-target",
|
|
211
224
|
style: { overflow: "hidden" }
|
|
@@ -223,25 +236,25 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
223
236
|
}
|
|
224
237
|
}, b = (n) => ({
|
|
225
238
|
breakpoint: n,
|
|
226
|
-
breakpointTablet:
|
|
227
|
-
breakpointMobile:
|
|
239
|
+
breakpointTablet: o,
|
|
240
|
+
breakpointMobile: a
|
|
228
241
|
}), u = (n, g, s) => {
|
|
229
242
|
const l = b(g), y = { pluginOpts: e, breakpointProps: l }, p = n.map((P) => {
|
|
230
|
-
const
|
|
243
|
+
const w = R(P, y);
|
|
231
244
|
return e != null && e.sidebarButton ? e.sidebarButton({
|
|
232
245
|
id: P.id,
|
|
233
246
|
buttonIds: v,
|
|
234
|
-
buttonProps:
|
|
247
|
+
buttonProps: w,
|
|
235
248
|
sidebarButtonProps: P,
|
|
236
249
|
...l,
|
|
237
|
-
createSidebarButton: (k) =>
|
|
238
|
-
}) :
|
|
250
|
+
createSidebarButton: (k) => R({ ...P, ...k }, y)
|
|
251
|
+
}) : w;
|
|
239
252
|
}).filter(Boolean);
|
|
240
253
|
return (e != null && e.sidebarButtons ? e == null ? void 0 : e.sidebarButtons({
|
|
241
254
|
buttonIds: v,
|
|
242
255
|
sidebarButtons: p,
|
|
243
256
|
...l,
|
|
244
|
-
createSidebarButton: (P) =>
|
|
257
|
+
createSidebarButton: (P) => R(
|
|
245
258
|
{
|
|
246
259
|
...P,
|
|
247
260
|
layoutCommand: {
|
|
@@ -261,12 +274,12 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
261
274
|
layoutSidebarLeft: r,
|
|
262
275
|
layoutSidebarTarget: f,
|
|
263
276
|
...l,
|
|
264
|
-
createSidebarButton: (A) =>
|
|
277
|
+
createSidebarButton: (A) => R({ ...A }, y)
|
|
265
278
|
})) ?? n;
|
|
266
279
|
};
|
|
267
|
-
if (
|
|
268
|
-
const n = u(h,
|
|
269
|
-
c[
|
|
280
|
+
if (o) {
|
|
281
|
+
const n = u(h, o);
|
|
282
|
+
c[o] = t(
|
|
270
283
|
{
|
|
271
284
|
type: "row",
|
|
272
285
|
style: { height: "100%" },
|
|
@@ -280,15 +293,15 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
280
293
|
]
|
|
281
294
|
},
|
|
282
295
|
n,
|
|
283
|
-
|
|
296
|
+
o
|
|
284
297
|
);
|
|
285
298
|
}
|
|
286
|
-
if (
|
|
299
|
+
if (a) {
|
|
287
300
|
const n = {
|
|
288
301
|
placer: { type: "absolute", position: "left" },
|
|
289
302
|
style: { height: "calc(100% - 40px)" }
|
|
290
|
-
}, g = h.map((l) => ({ ...l, layoutCommand: n })), s = u(g,
|
|
291
|
-
c[
|
|
303
|
+
}, g = h.map((l) => ({ ...l, layoutCommand: n })), s = u(g, a, { layoutCommand: n });
|
|
304
|
+
c[a] = t(
|
|
292
305
|
{
|
|
293
306
|
type: "column",
|
|
294
307
|
style: { height: "100%" },
|
|
@@ -303,7 +316,7 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
303
316
|
]
|
|
304
317
|
},
|
|
305
318
|
s,
|
|
306
|
-
|
|
319
|
+
a
|
|
307
320
|
);
|
|
308
321
|
}
|
|
309
322
|
const L = u(i, 0);
|
|
@@ -327,30 +340,30 @@ const E = "sidebarButtonsTarget", w = (e, a) => {
|
|
|
327
340
|
),
|
|
328
341
|
responsive: c
|
|
329
342
|
};
|
|
330
|
-
}, M = "layoutSidebarButtons",
|
|
331
|
-
const { Commands:
|
|
332
|
-
...
|
|
343
|
+
}, M = "layoutSidebarButtons", J = B.free, Q = function(e, o = {}) {
|
|
344
|
+
const { Commands: a } = e, c = a.events, i = {
|
|
345
|
+
...o
|
|
333
346
|
};
|
|
334
347
|
(() => {
|
|
335
348
|
if (e.runCommand(T.layoutConfigGet) || i.skipLayoutConfig === !0) return;
|
|
336
349
|
const r = N(i);
|
|
337
350
|
e.runCommand(T.layoutConfigSet, { ...r });
|
|
338
|
-
})(),
|
|
351
|
+
})(), a.add(`${M}:toggleButton`, (f, r, d) => {
|
|
339
352
|
const b = document.getElementById(U(d == null ? void 0 : d.id));
|
|
340
353
|
b == null || b.click();
|
|
341
354
|
}), e.on(`${c.runCommand}core:preview`, () => {
|
|
342
355
|
$(e);
|
|
343
|
-
}),
|
|
356
|
+
}), q({
|
|
344
357
|
editor: e,
|
|
345
358
|
licenseKey: i.licenseKey,
|
|
346
|
-
plan:
|
|
359
|
+
plan: J,
|
|
347
360
|
pluginName: M,
|
|
348
361
|
cleanup: () => {
|
|
349
362
|
e.runCommand(T.layoutConfigSet);
|
|
350
363
|
}
|
|
351
364
|
});
|
|
352
|
-
},
|
|
353
|
-
|
|
365
|
+
}, X = K(Q);
|
|
366
|
+
X.createLayoutConfig = (e) => N(e);
|
|
354
367
|
export {
|
|
355
|
-
|
|
368
|
+
X as default
|
|
356
369
|
};
|
|
@@ -1 +1 @@
|
|
|
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),$});
|
|
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.openEditCode="studio:openEditCode",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",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],m="license:check:end",H=()=>typeof window<"u",j=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?M:G}`}/${a?"platform-api":"api"}`,S=()=>{if(!H())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},W=()=>{const e=S();return!!e&&(I.includes(e)||I.some(o=>e.endsWith(o)))};async function C({path:e,baseApiUrl:o,method:a="GET",headers:c={},params:i,body:T}){const r=`${o||j({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 K({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:s}=t,g=(l=t.plan)==null?void 0:l.category;if(!(s||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(!W())if(c){const t=await Z({licenseKey:c,pluginName:a,baseApiUrl:h});u(t)}else d("The `licenseKey` option not provided")});return}if(r.licensePlan||r.licenseError){const t=q(r);u(t);return}e.on(m,t=>u(t))}const q=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 C({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",R=(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,s=a;return{id:E(a),type:"button",icon:c,tooltip:i||T,className:h,editorEvents:{[`${D.layoutToggleId}${s}`]:({fromEvent:g,setState:n,editor:l})=>{n({active:g.isOpen}),setTimeout(()=>l.refresh({tools:!0}),20)}},onClick:({editor:g,state:n})=>{var w;if(n.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(k=>k!==s);N(g,{removeLayouts:f,layout:{placer:y}});const B={id:s,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=((w=t==null?void 0:t.sidebarLayoutCommand)==null?void 0:w.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:s,editor:g})=>{var f;const n=g.getSelected(),l={type:"image",src:s.src};let y;if(n!=null&&n.is("image"))return n.set("src",s.src);n&&g.Components.canMove(n,l)?y=n.append(l)[0]:n||(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=s=>({breakpoint:s,breakpointTablet:o,breakpointMobile:a}),u=(s,g,n)=>{const l=b(g),y={pluginOpts:e,breakpointProps:l},f=s.map(L=>{const w=R(L,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:L.id,buttonIds:P,buttonProps:w,sidebarButtonProps:L,...l,createSidebarButton:k=>R({...L,...k},y)}):w}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:P,sidebarButtons:f,...l,createSidebarButton:L=>R({...L,layoutCommand:{...n==null?void 0:n.layoutCommand,...L.layoutCommand}},y)}):f).filter(Boolean)},t=(s,g,n)=>{var f;const l=b(n),y={pluginOpts:e,breakpointProps:l};return((f=e==null?void 0:e.rootLayout)==null?void 0:f.call(e,{sidebarButtons:g,rootLayout:s,layoutSidebarLeft:r,layoutSidebarTarget:h,...l,createSidebarButton:B=>R({...B},y)}))??s};if(o){const s=u(T,o);c[o]=t({type:"row",style:{height:"100%"},children:[{...r,children:s},h,d]},s,o)}if(a){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},g=T.map(l=>({...l,layoutCommand:s})),n=u(g,a,{layoutCommand:s});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:n}]},n,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)}),K({editor:e,licenseKey:i.licenseKey,plan:z,pluginName:_,cleanup:()=>{e.runCommand(p.layoutConfigSet)}})});return $.createLayoutConfig=e=>U(e),$});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const re="app.grapesjs.com",ce="app-stage.grapesjs.com",ge="app2.grapesjs.com",he="app-stage2.grapesjs.com",ee=[re,ge,ce,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],be="license:check:end",de=()=>typeof window<"u",ye=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?ce:re}`}/${t?"platform-api":"api"}`,me=()=>{const e=de()&&window.location.hostname;return!!e&&(ee.includes(e)||ee.some(l=>e.endsWith(l)))};async function ve({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:i,body:g}){const n=`${l||ye({isDev:!1,isStage:!1})}${e}`,u={method:t,headers:{"Content-Type":"application/json",...o}};g&&(u.body=JSON.stringify(g));const p=i?new URLSearchParams(i).toString():"",b=p?`?${p}`:"",r=await fetch(`${n}${b}`,u);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{}),Z=(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))(Z||{});const te={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function fe(e){const l=e;return l.init=t=>o=>e(o,t),l}const Te=e=>fe(e);async function we({editor:e,plan:l,pluginName:t,licenseKey:o,onLicenseCheckResponse:i,cleanup:g}){let c="",n;const u=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),g()},p=(r={})=>{var G;const{error:I,sdkLicense:O}=r,T=(G=r.plan)==null?void 0:G.category;if(!(O||r.license)||I)u(I||"Invalid license");else if(T){const M=te[l],_=te[T];M>_&&u({pluginRequiredPlan:l,licensePlan:T})}};e.Commands.has(Z.settings)&&(n=e.runCommand(Z.settings),c=(n==null?void 0:n.baseUrl)||"");const b=r=>{i==null||i(r),r&&p(r)};if(!n){e.onReady(async()=>{if(!me())if(o){const r=await Pe({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const r=xe(n);b(r);return}e.on(be,r=>b(r))}const xe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Pe(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await ve({baseApiUrl:o,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const z=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},Ae="lightGalleryComponent",Le=E.startup;var S=(e=>(e.image="image",e.video="video",e.external="external",e))(S||{});const A="lightGallery",ae=`${A}-item`,j="data-lightgallery",oe=`${j}-item`,N="toggle",L={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},F={propKeys:[],props:{},traits:[]},V=(e,l={})=>{var i;const t={},o=[];for(const g in e){const{value:c,...n}=e[g];o.push({id:g,name:g,changeProp:!0,category:l.category,...n}),t[g]=c;const{subTraits:u={}}=n;for(const p in n.subTraits)(i=u[p])==null||i.forEach(b=>{const r=b.id||b.name;t[r]=b.value})}return{propKeys:Object.keys(t),props:t,traits:o}},q=(e,l)=>{const t=e.getTrait(l),o=t.get("category"),i=t.get("subTraits")||{},c=(Object.values(i).flat()||[]).map(p=>p.id||p.name);e.removeTrait(c);const n=i[t.getValue()],u=e.getTraitIndex(l)+1;n&&e.addTrait(n.map(p=>({category:o,...p})),{at:u})},W=(e,l)=>{l.forEach(t=>{const o=e.getTrait(t);if(!o||!o.get("subTraits"))return;const i=o.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(i,()=>q(e,t)),q(e,t)})},Ie=(e,l,t)=>{const i=e.getTrait(l).get("subTraits")||{},c=(Object.values(i).flat()||[]).map(u=>{const p=u.name||u.id;return u.changeProp?`change:${p}`:`change:attributes:${p}`}),n=Array.from(new Set(c));n.length&&e.on(n.join(" "),t)},Ge={[N]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var t,o;return(o=(t=l.target)==null?void 0:t.getView())==null?void 0:o.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},ke={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Se={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ee={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",U="data-iframe",J={name:"href",type:"file",label:"Image Source"},K={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},C={name:"data-poster",label:"Video Poster",type:"file"},le={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},pe={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Oe={[N]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,g;const t=l.target,o=(i=t==null?void 0:t.closestType(A))==null?void 0:i.getView();if(o&&t){const c=((g=o.getLightGallery())==null?void 0:g.items)||[],n=Array.from(c).indexOf(t.getEl());n>=0&&o.toggleGallery(n)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[J],video:[K,C],external:[le]},options:[{id:"image",label:J.label||"",icon:L.image},{id:"video",label:K.label||"",icon:L.video},{id:"external",label:le.label||"",icon:L.external}]},subHtml:pe},se="lgThumbnail",Me="lgVideo",ie="lgAutoplay",ne="lgZoom",k="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",De=function(e,l={}){const{Blocks:t,Components:o}=e,i="LightGallery",g="LightGallery Item",c={toolbarIconOpen:L.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,Me,ie,ne],cdnScript:[`${k}/lightgallery.min.js`,`${k}/plugins/thumbnail/lg-thumbnail.min.js`,`${k}/plugins/video/lg-video.min.js`,`${k}/plugins/autoplay/lg-autoplay.min.js`,`${k}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${k}/css/lightgallery-bundle.min.css`,...l},{block:n,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:y,cdnScript:w,cdnStyle:D,inline:Q,lgLicenseKey:ue,...m}=a||{},x=d=>isNaN(d)?void 0:parseInt(d,10),X=()=>{var B;const d={...m,licenseKey:ue,speed:x(m.speed),startAnimationDuration:x(m.startAnimationDuration),thumbMargin:x(m.thumbMargin),thumbWidth:x(m.thumbWidth),slideShowInterval:x(m.slideShowInterval),scale:x(m.scale),enableZoomAfter:x(m.enableZoomAfter),plugins:(y||[]).map($=>h[$])};Q&&(d.container=s,d.closable=!1);const H=(B=h.lightGallery)==null?void 0:B.call(h,s,d);Q&&H.openGallery()};if(h.lightGallery)X();else{const{head:d}=document,H=Array.isArray(w)?[...w]:[w],B=Array.isArray(D)?[...D]:[D],$=P=>{if(P.length){const v=document.createElement("link");v.href=P.shift(),v.rel="stylesheet",d.appendChild(v),$(P)}},Y=P=>{if(P.length){const v=document.createElement("script");v.src=P.shift(),v.onerror=v.onload=Y.bind(null,P),d.appendChild(v)}else X()};$(B),Y(H)}},r=a=>{const s=a.getTrait(N);if(!u||!s)return;const{toolbar:h}=a,y={id:N,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(D=>D.id===y.id)&&(h==null||h.unshift(y))};let I=[];const O=c.plugins||[],T=V(Ge),R=O.includes(se)?V(ke):F,G=O.includes(ie)?V(Se):F,M=O.includes(ne)?V(Ee):F;o.addType(A,{block:n&&{label:i,media:L.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>z(a,j),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:L.gallery,draggable:(a,s)=>!s.is(A),attributes:{[j]:!0},components:{type:ae},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...T.propKeys,...R.propKeys,...G.propKeys,...M.propKeys],...T.props,...R.props,...G.props,...M.props,traits:[...T.traits,...R.traits,...G.traits,...M.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){r(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var s;const a=this.getLightGallery();return((s=a==null?void 0:a.settings)==null?void 0:s.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:s}=a,h=this.getLightGallery();I=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();I.forEach(s=>this.em.Canvas.addSpot(s.attributes)),I=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const s=this.getLightGallery();if(s.__lgOpened)return s.closeGallery(!0);s.lgOpened=!1,s.openGallery(a)}}});const _=V(Oe);o.addType(ae,{isComponent:a=>z(a,oe)||a.tagName==="A"&&z(a.parentElement,j),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:L.galleryItem,attributes:{[oe]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},..._.props,traits:[..._.traits]},init(){const a=[f].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ie(this,f,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[pe.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(A))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[f]||h){q(this,f);const y=this.getTrait(f).getValue();if(y===S.image){this.removeAttributes([K.name,C.name,U]);const w=this.getTrait(J.name);w.setValue(w.getValue()||p)}else y===S.video?this.removeAttributes([U]):y===S.external&&this.addAttributes({[U]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[U]?this.set(f,S.external):(a[K.name]||a[C.name])&&this.set(f,S.video)}}}),we({editor:e,plan:Le,licenseKey:c.licenseKey,pluginName:Ae,cleanup:()=>{t.remove(A),o.removeType(A)}})},Ve=Te(De);module.exports=Ve;
|
|
1
|
+
"use strict";const re="app.grapesjs.com",ce="app-stage.grapesjs.com",ge="app2.grapesjs.com",he="app-stage2.grapesjs.com",ee=[re,ge,ce,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],be="license:check:end",de=()=>typeof window<"u",ye=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?ce:re}`}/${t?"platform-api":"api"}`,me=()=>{if(!de())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},ve=()=>{const e=me();return!!e&&(ee.includes(e)||ee.some(l=>e.endsWith(l)))};async function fe({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:n,body:g}){const i=`${l||ye({isDev:!1,isStage:!1})}${e}`,u={method:t,headers:{"Content-Type":"application/json",...o}};g&&(u.body=JSON.stringify(g));const p=n?new URLSearchParams(n).toString():"",b=p?`?${p}`:"",r=await fetch(`${i}${b}`,u);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var S=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(S||{}),Z=(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.openEditCode="studio:openEditCode",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))(Z||{});const te={[S.free]:0,[S.startup]:10,[S.business]:20,[S.enterprise]:30};function Te(e){const l=e;return l.init=t=>o=>e(o,t),l}const we=e=>Te(e);async function xe({editor:e,plan:l,pluginName:t,licenseKey:o,onLicenseCheckResponse:n,cleanup:g}){let c="",i;const u=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),g()},p=(r={})=>{var G;const{error:I,sdkLicense:O}=r,T=(G=r.plan)==null?void 0:G.category;if(!(O||r.license)||I)u(I||"Invalid license");else if(T){const M=te[l],_=te[T];M>_&&u({pluginRequiredPlan:l,licensePlan:T})}};e.Commands.has(Z.settings)&&(i=e.runCommand(Z.settings),c=(i==null?void 0:i.baseUrl)||"");const b=r=>{n==null||n(r),r&&p(r)};if(!i){e.onReady(async()=>{if(!ve())if(o){const r=await Ae({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const r=Pe(i);b(r);return}e.on(be,r=>b(r))}const Pe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Ae(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await fe({baseApiUrl:o,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const z=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},Le="lightGalleryComponent",Ie=S.startup;var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const A="lightGallery",ae=`${A}-item`,j="data-lightgallery",oe=`${j}-item`,N="toggle",L={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},F={propKeys:[],props:{},traits:[]},V=(e,l={})=>{var n;const t={},o=[];for(const g in e){const{value:c,...i}=e[g];o.push({id:g,name:g,changeProp:!0,category:l.category,...i}),t[g]=c;const{subTraits:u={}}=i;for(const p in i.subTraits)(n=u[p])==null||n.forEach(b=>{const r=b.id||b.name;t[r]=b.value})}return{propKeys:Object.keys(t),props:t,traits:o}},q=(e,l)=>{const t=e.getTrait(l),o=t.get("category"),n=t.get("subTraits")||{},c=(Object.values(n).flat()||[]).map(p=>p.id||p.name);e.removeTrait(c);const i=n[t.getValue()],u=e.getTraitIndex(l)+1;i&&e.addTrait(i.map(p=>({category:o,...p})),{at:u})},W=(e,l)=>{l.forEach(t=>{const o=e.getTrait(t);if(!o||!o.get("subTraits"))return;const n=o.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(n,()=>q(e,t)),q(e,t)})},Ge=(e,l,t)=>{const n=e.getTrait(l).get("subTraits")||{},c=(Object.values(n).flat()||[]).map(u=>{const p=u.name||u.id;return u.changeProp?`change:${p}`:`change:attributes:${p}`}),i=Array.from(new Set(c));i.length&&e.on(i.join(" "),t)},ke={[N]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var t,o;return(o=(t=l.target)==null?void 0:t.getView())==null?void 0:o.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Ee={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Se={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Oe={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",U="data-iframe",C={name:"href",type:"file",label:"Image Source"},H={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},J={name:"data-poster",label:"Video Poster",type:"file"},le={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},pe={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Me={[N]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var n,g;const t=l.target,o=(n=t==null?void 0:t.closestType(A))==null?void 0:n.getView();if(o&&t){const c=((g=o.getLightGallery())==null?void 0:g.items)||[],i=Array.from(c).indexOf(t.getEl());i>=0&&o.toggleGallery(i)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[C],video:[H,J],external:[le]},options:[{id:"image",label:C.label||"",icon:L.image},{id:"video",label:H.label||"",icon:L.video},{id:"external",label:le.label||"",icon:L.external}]},subHtml:pe},se="lgThumbnail",De="lgVideo",ne="lgAutoplay",ie="lgZoom",k="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ve=function(e,l={}){const{Blocks:t,Components:o}=e,n="LightGallery",g="LightGallery Item",c={toolbarIconOpen:L.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,De,ne,ie],cdnScript:[`${k}/lightgallery.min.js`,`${k}/plugins/thumbnail/lg-thumbnail.min.js`,`${k}/plugins/video/lg-video.min.js`,`${k}/plugins/autoplay/lg-autoplay.min.js`,`${k}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${k}/css/lightgallery-bundle.min.css`,...l},{block:i,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:y,cdnScript:w,cdnStyle:D,inline:Q,lgLicenseKey:ue,...m}=a||{},x=d=>isNaN(d)?void 0:parseInt(d,10),X=()=>{var B;const d={...m,licenseKey:ue,speed:x(m.speed),startAnimationDuration:x(m.startAnimationDuration),thumbMargin:x(m.thumbMargin),thumbWidth:x(m.thumbWidth),slideShowInterval:x(m.slideShowInterval),scale:x(m.scale),enableZoomAfter:x(m.enableZoomAfter),plugins:(y||[]).map($=>h[$])};Q&&(d.container=s,d.closable=!1);const K=(B=h.lightGallery)==null?void 0:B.call(h,s,d);Q&&K.openGallery()};if(h.lightGallery)X();else{const{head:d}=document,K=Array.isArray(w)?[...w]:[w],B=Array.isArray(D)?[...D]:[D],$=P=>{if(P.length){const v=document.createElement("link");v.href=P.shift(),v.rel="stylesheet",d.appendChild(v),$(P)}},Y=P=>{if(P.length){const v=document.createElement("script");v.src=P.shift(),v.onerror=v.onload=Y.bind(null,P),d.appendChild(v)}else X()};$(B),Y(K)}},r=a=>{const s=a.getTrait(N);if(!u||!s)return;const{toolbar:h}=a,y={id:N,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(D=>D.id===y.id)&&(h==null||h.unshift(y))};let I=[];const O=c.plugins||[],T=V(ke),R=O.includes(se)?V(Ee):F,G=O.includes(ne)?V(Se):F,M=O.includes(ie)?V(Oe):F;o.addType(A,{block:i&&{label:n,media:L.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>z(a,j),extendFn:["init","initToolbar"],model:{defaults:{name:n,icon:L.gallery,draggable:(a,s)=>!s.is(A),attributes:{[j]:!0},components:{type:ae},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...T.propKeys,...R.propKeys,...G.propKeys,...M.propKeys],...T.props,...R.props,...G.props,...M.props,traits:[...T.traits,...R.traits,...G.traits,...M.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){r(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var s;const a=this.getLightGallery();return((s=a==null?void 0:a.settings)==null?void 0:s.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:s}=a,h=this.getLightGallery();I=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();I.forEach(s=>this.em.Canvas.addSpot(s.attributes)),I=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const s=this.getLightGallery();if(s.__lgOpened)return s.closeGallery(!0);s.lgOpened=!1,s.openGallery(a)}}});const _=V(Me);o.addType(ae,{isComponent:a=>z(a,oe)||a.tagName==="A"&&z(a.parentElement,j),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:L.galleryItem,attributes:{[oe]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},..._.props,traits:[..._.traits]},init(){const a=[f].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ge(this,f,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[pe.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(A))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[f]||h){q(this,f);const y=this.getTrait(f).getValue();if(y===E.image){this.removeAttributes([H.name,J.name,U]);const w=this.getTrait(C.name);w.setValue(w.getValue()||p)}else y===E.video?this.removeAttributes([U]):y===E.external&&this.addAttributes({[U]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[U]?this.set(f,E.external):(a[H.name]||a[J.name])&&this.set(f,E.video)}}}),xe({editor:e,plan:Ie,licenseKey:c.licenseKey,pluginName:Le,cleanup:()=>{t.remove(A),o.removeType(A)}})},Re=we(Ve);module.exports=Re;
|