@grapesjs/studio-sdk-plugins 1.0.15 → 1.0.16

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.
Files changed (66) hide show
  1. package/dist/accordionComponent/index.cjs.js +3 -3
  2. package/dist/accordionComponent/index.es.js +29 -30
  3. package/dist/accordionComponent/index.umd.js +4 -4
  4. package/dist/canvasEmptyState/index.cjs.js +1 -1
  5. package/dist/canvasEmptyState/index.es.js +14 -15
  6. package/dist/canvasEmptyState/index.umd.js +1 -1
  7. package/dist/canvasFullSize/index.cjs.d.ts +2 -2
  8. package/dist/canvasFullSize/index.cjs.js +1 -1
  9. package/dist/canvasFullSize/index.d.ts +2 -2
  10. package/dist/canvasFullSize/index.es.d.ts +2 -2
  11. package/dist/canvasFullSize/index.es.js +2 -3
  12. package/dist/canvasFullSize/index.umd.js +2 -2
  13. package/dist/canvasFullSize/types.d.ts +1 -1
  14. package/dist/dialogComponent/index.cjs.js +2 -2
  15. package/dist/dialogComponent/index.es.js +2 -3
  16. package/dist/dialogComponent/index.umd.js +2 -2
  17. package/dist/flexComponent/index.cjs.js +1 -1
  18. package/dist/flexComponent/index.es.js +2 -3
  19. package/dist/flexComponent/index.umd.js +1 -1
  20. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  21. package/dist/fsLightboxComponent/index.es.js +2 -3
  22. package/dist/fsLightboxComponent/index.umd.js +2 -2
  23. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  24. package/dist/googleFontsAssetProvider/index.es.js +39 -40
  25. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  26. package/dist/iconifyComponent/index.cjs.js +2 -2
  27. package/dist/iconifyComponent/index.es.js +31 -32
  28. package/dist/iconifyComponent/index.umd.js +2 -2
  29. package/dist/index.cjs.d.ts +1 -0
  30. package/dist/index.cjs.js +42 -42
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.es.d.ts +1 -0
  33. package/dist/index.es.js +3171 -2944
  34. package/dist/index.umd.js +36 -36
  35. package/dist/layoutSidebarButtons/index.cjs.d.ts +3 -0
  36. package/dist/layoutSidebarButtons/index.cjs.js +1 -0
  37. package/dist/layoutSidebarButtons/index.d.ts +3 -0
  38. package/dist/layoutSidebarButtons/index.es.d.ts +3 -0
  39. package/dist/layoutSidebarButtons/index.es.js +328 -0
  40. package/dist/layoutSidebarButtons/index.umd.js +1 -0
  41. package/dist/layoutSidebarButtons/layout.d.ts +8 -0
  42. package/dist/layoutSidebarButtons/types.d.ts +75 -0
  43. package/dist/layoutSidebarButtons/typesSchema.d.ts +49 -0
  44. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  45. package/dist/lightGalleryComponent/index.es.js +2 -3
  46. package/dist/lightGalleryComponent/index.umd.js +1 -1
  47. package/dist/listPagesComponent/index.cjs.js +3 -3
  48. package/dist/listPagesComponent/index.es.js +2 -3
  49. package/dist/listPagesComponent/index.umd.js +3 -3
  50. package/dist/prosemirror/index.cjs.js +2 -2
  51. package/dist/prosemirror/index.es.js +3 -4
  52. package/dist/prosemirror/index.umd.js +2 -2
  53. package/dist/rteTinyMce/index.cjs.js +1 -1
  54. package/dist/rteTinyMce/index.es.js +20 -21
  55. package/dist/rteTinyMce/index.umd.js +1 -1
  56. package/dist/swiperComponent/index.cjs.js +3 -3
  57. package/dist/swiperComponent/index.es.js +2 -3
  58. package/dist/swiperComponent/index.umd.js +3 -3
  59. package/dist/tableComponent/index.cjs.js +1 -1
  60. package/dist/tableComponent/index.es.js +13 -14
  61. package/dist/tableComponent/index.umd.js +1 -1
  62. package/dist/types.d.ts +4 -3
  63. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  64. package/dist/youtubeAssetProvider/index.es.js +7 -8
  65. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  66. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ import { SDKPluginWithLayoutConfig } from './types';
2
+ declare const pluginInit: SDKPluginWithLayoutConfig;
3
+ export default pluginInit;
@@ -0,0 +1 @@
1
+ "use strict";var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),p=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e))(p||{}),M=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e))(M||{});const G="app.grapesjs.com",x="app-stage.grapesjs.com",k=[G,x,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:start",O="license:check:end",_=()=>typeof window<"u",N=({isDev:e,isStage:s})=>`${e?"":`https://${s?x:G}`}/api`,W=()=>{const e=_()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(s=>e.endsWith(s)))};async function j({path:e,baseApiUrl:s,method:t="GET",headers:a={},params:n,body:c}){const y=`${s||N({isDev:!1,isStage:!1})}${e}`,g={method:t,headers:{"Content-Type":"application/json",...a}};c&&(g.body=JSON.stringify(c));const l=n?new URLSearchParams(n).toString():"",o=l?`?${l}`:"",i=await fetch(`${y}${o}`,g);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.json()}const w={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function C(e){const s=e;return s.init=t=>a=>e(a,t),s}const K=e=>C(e);async function S({editor:e,plan:s,pluginName:t,licenseKey:a,cleanup:n}){let c="",u=!1;const y=W(),g=o=>{console.warn("Cleanup plugin:",t,"Reason:",o),n()},l=(o={})=>{var b;const{error:i,sdkLicense:r}=o,d=(b=o.plan)==null?void 0:b.category;if(!(r||o.license)||i)g(i||"Invalid license");else if(d){const L=w[s],B=w[d];L>B&&g({pluginRequiredPlan:s,licensePlan:d})}};e.on(H,o=>{c=o==null?void 0:o.baseApiUrl,u=!0}),e.on(O,o=>{l(o)}),setTimeout(async()=>{if(!u){if(y)return;if(a){const o=await V({licenseKey:a,pluginName:t,baseApiUrl:c});o&&l(o)}else g("The `licenseKey` option not provided")}},2e3)}async function V(e){const{licenseKey:s,pluginName:t,baseApiUrl:a}=e;try{return(await j({baseApiUrl:a,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}var f=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e))(f||{});const I="sidebarButtonsTarget",T=e=>{const{id:s,icon:t,label:a,tooltip:n,className:c,skipSelfClose:u,removeLayouts:y,layoutComponent:g,layoutCommand:l}=e,o=s;return{id:U(s),type:"button",icon:t,tooltip:a||n,className:c,editorEvents:{[`${M.layoutToggleId}${o}`]:({fromEvent:i,setState:r,editor:d})=>{r({active:i.isOpen}),setTimeout(()=>d.refresh({tools:!0}),20)}},onClick:({editor:i,state:r})=>{if(r.active&&u)return;const d=(l==null?void 0:l.placer)||{type:"static",layoutId:I},v={...d,skipCleanup:d.type==="static"},b=y||Object.keys(f).filter(B=>B!==o);E(i,{removeLayouts:b,layout:{placer:v}});const L={id:o,placer:d,header:(l==null?void 0:l.header)??{label:a,close:!u},layout:g,style:{width:250,height:"100%",borderRightWidth:1,...l==null?void 0:l.style}};i.runCommand(p.layoutToggle,L)}}},U=e=>`button__${e}`,E=(e,s={})=>{(s.removeLayouts||Object.keys(f)).forEach(a=>e.runCommand(p.layoutRemove,{id:a,layout:s.layout}))},A=(e,s,t)=>{const a=e.map(n=>{const c=T(n);return t!=null&&t.sidebarButton?t.sidebarButton({id:n.id,breakpoint:s,buttonProps:c,sidebarButtonProps:n,createSidebarButton:u=>T({...n,...u})}):c}).filter(Boolean);return t!=null&&t.sidebarButtons?t==null?void 0:t.sidebarButtons({breakpoint:s,sidebarButtons:a,createSidebarButton:n=>T({...n})}):a},P=(e,s,t,a)=>{var n;return((n=a==null?void 0:a.rootLayout)==null?void 0:n.call(a,{breakpoint:t,sidebarButtons:s,rootLayout:e,createSidebarButton:c=>T({...c})}))??e},$=e=>{const s=(e==null?void 0:e.breakpointTablet)??1024,t=(e==null?void 0:e.breakpointMobile)??768,a={},n=[{id:f.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:f.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:f.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:f.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:o,editor:i})=>{var v;const r=i.getSelected(),d={type:"image",src:o.src};if(r!=null&&r.is("image"))return r.set("src",o.src);if(r&&i.Components.canMove(r,d)){const b=r.append(d)[0];b&&i.select(b)}else if(!r){const b=(v=i.getWrapper())==null?void 0:v.append(d)[0];b&&i.select(b)}}}}],c=[...n,{id:f.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"}}],u={id:I,type:"column",style:{overflow:"hidden"}},y={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},g={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}};if(s){const o=A(c,s,e);a[s]=P({type:"row",style:{height:"100%"},children:[{...y,children:o},u,g]},o,s,e)}if(t){const o=c.map(r=>({...r,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),i=A(o,t,e);a[t]=P({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:i}]},i,t,e)}const l=A(n,0,e);return{default:P({type:"row",style:{height:"100%"},children:[{...y,children:l},u,g,{type:"sidebarRight"}]},l,0,e),responsive:a}},R="layoutSidebarButtons",m=function(e,s={}){const{Commands:t}=e,a=t.events,n={...s};(()=>{if(e.runCommand(p.layoutConfigGet)||n.skipLayoutConfig===!0)return;const y=$(n);e.runCommand(p.layoutConfigSet,{...y})})(),t.add(`${R}:toggleButton`,(u,y,g={})=>{const l=document.getElementById(U(g.id));l==null||l.click()}),e.on(`${a.runCommand}core:preview`,()=>{E(e)}),S({editor:e,licenseKey:n.licenseKey,plan:h.startup,pluginName:R,cleanup:()=>{e.runCommand(p.layoutConfigSet)}})},D=K(m);D.createLayoutConfig=e=>$(e);module.exports=D;
@@ -0,0 +1,3 @@
1
+ import { SDKPluginWithLayoutConfig } from './types';
2
+ declare const pluginInit: SDKPluginWithLayoutConfig;
3
+ export default pluginInit;
@@ -0,0 +1,3 @@
1
+ import { SDKPluginWithLayoutConfig } from './types';
2
+ declare const pluginInit: SDKPluginWithLayoutConfig;
3
+ export default pluginInit;
@@ -0,0 +1,328 @@
1
+ var h = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(h || {}), p = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e))(p || {}), M = /* @__PURE__ */ ((e) => (e.layoutToggleId = "studio:layoutToggle:", e.toggleBlocksPanel = "studio:toggleBlocksPanel", e.pageSettingsUpdate = "studio:pageSettingsUpdate", e))(M || {});
2
+ const G = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = [
3
+ G,
4
+ x,
5
+ "localhost",
6
+ "127.0.0.1",
7
+ ".local-credentialless.webcontainer.io",
8
+ // For stackblitz.com demos
9
+ ".local.webcontainer.io",
10
+ // For stackblitz.com demos
11
+ "-sandpack.codesandbox.io"
12
+ // For Sandpack demos
13
+ ], D = "license:check:start", H = "license:check:end", O = () => typeof window < "u", _ = ({ isDev: e, isStage: s }) => `${e ? "" : `https://${s ? x : G}`}/api`, N = () => {
14
+ const e = O() && window.location.hostname;
15
+ return !!e && (k.includes(e) || k.some((s) => e.endsWith(s)));
16
+ };
17
+ async function W({
18
+ path: e,
19
+ baseApiUrl: s,
20
+ method: t = "GET",
21
+ headers: a = {},
22
+ params: n,
23
+ body: c
24
+ }) {
25
+ const y = `${s || _({ isDev: !1, isStage: !1 })}${e}`, g = {
26
+ method: t,
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ ...a
30
+ }
31
+ };
32
+ c && (g.body = JSON.stringify(c));
33
+ const l = n ? new URLSearchParams(n).toString() : "", o = l ? `?${l}` : "", i = await fetch(`${y}${o}`, g);
34
+ if (!i.ok)
35
+ throw new Error(`HTTP error! status: ${i.status}`);
36
+ return i.json();
37
+ }
38
+ const w = {
39
+ [h.free]: 0,
40
+ [h.startup]: 10,
41
+ [h.business]: 20,
42
+ [h.enterprise]: 30
43
+ };
44
+ function j(e) {
45
+ const s = e;
46
+ return s.init = (t) => (a) => e(a, t), s;
47
+ }
48
+ const C = (e) => /* @__PURE__ */ j(e);
49
+ async function K({
50
+ editor: e,
51
+ plan: s,
52
+ pluginName: t,
53
+ licenseKey: a,
54
+ cleanup: n
55
+ }) {
56
+ let c = "", u = !1;
57
+ const y = N(), g = (o) => {
58
+ console.warn("Cleanup plugin:", t, "Reason:", o), n();
59
+ }, l = (o = {}) => {
60
+ var b;
61
+ const { error: i, sdkLicense: r } = o, d = (b = o.plan) == null ? void 0 : b.category;
62
+ if (!(r || o.license) || i)
63
+ g(i || "Invalid license");
64
+ else if (d) {
65
+ const L = w[s], B = w[d];
66
+ L > B && g({ pluginRequiredPlan: s, licensePlan: d });
67
+ }
68
+ };
69
+ e.on(D, (o) => {
70
+ c = o == null ? void 0 : o.baseApiUrl, u = !0;
71
+ }), e.on(H, (o) => {
72
+ l(o);
73
+ }), setTimeout(async () => {
74
+ if (!u) {
75
+ if (y) return;
76
+ if (a) {
77
+ const o = await S({ licenseKey: a, pluginName: t, baseApiUrl: c });
78
+ o && l(o);
79
+ } else
80
+ g("The `licenseKey` option not provided");
81
+ }
82
+ }, 2e3);
83
+ }
84
+ async function S(e) {
85
+ const { licenseKey: s, pluginName: t, baseApiUrl: a } = e;
86
+ try {
87
+ return (await W({
88
+ baseApiUrl: a,
89
+ path: `/sdk/${s || "na"}`,
90
+ method: "POST",
91
+ params: {
92
+ d: window.location.hostname,
93
+ pn: t
94
+ }
95
+ })).result || {};
96
+ } catch (n) {
97
+ return console.error("Error during SDK license check:", n), !1;
98
+ }
99
+ }
100
+ var f = /* @__PURE__ */ ((e) => (e.panelBlocks = "panelBlocks", e.panelPagesLayers = "panelPagesLayers", e.panelGlobalStyles = "panelGlobalStyles", e.panelSidebarTabs = "panelSidebarTabs", e.panelAssets = "panelAssets", e))(f || {});
101
+ const I = "sidebarButtonsTarget", T = (e) => {
102
+ const { id: s, icon: t, label: a, tooltip: n, className: c, skipSelfClose: u, removeLayouts: y, layoutComponent: g, layoutCommand: l } = e, o = s;
103
+ return {
104
+ id: U(s),
105
+ type: "button",
106
+ icon: t,
107
+ tooltip: a || n,
108
+ className: c,
109
+ editorEvents: {
110
+ [`${M.layoutToggleId}${o}`]: ({ fromEvent: i, setState: r, editor: d }) => {
111
+ r({ active: i.isOpen }), setTimeout(() => d.refresh({ tools: !0 }), 20);
112
+ }
113
+ },
114
+ onClick: ({ editor: i, state: r }) => {
115
+ if (r.active && u) return;
116
+ const d = (l == null ? void 0 : l.placer) || {
117
+ type: "static",
118
+ layoutId: I
119
+ }, v = { ...d, skipCleanup: d.type === "static" }, b = y || Object.keys(f).filter((B) => B !== o);
120
+ E(i, { removeLayouts: b, layout: { placer: v } });
121
+ const L = {
122
+ id: o,
123
+ placer: d,
124
+ header: (l == null ? void 0 : l.header) ?? { label: a, close: !u },
125
+ layout: g,
126
+ style: {
127
+ width: 250,
128
+ height: "100%",
129
+ borderRightWidth: 1,
130
+ ...l == null ? void 0 : l.style
131
+ }
132
+ };
133
+ i.runCommand(p.layoutToggle, L);
134
+ }
135
+ };
136
+ }, U = (e) => `button__${e}`, E = (e, s = {}) => {
137
+ (s.removeLayouts || Object.keys(f)).forEach((a) => e.runCommand(p.layoutRemove, { id: a, layout: s.layout }));
138
+ }, A = (e, s, t) => {
139
+ const a = e.map((n) => {
140
+ const c = T(n);
141
+ return t != null && t.sidebarButton ? t.sidebarButton({
142
+ id: n.id,
143
+ breakpoint: s,
144
+ buttonProps: c,
145
+ sidebarButtonProps: n,
146
+ createSidebarButton: (u) => T({ ...n, ...u })
147
+ }) : c;
148
+ }).filter(Boolean);
149
+ return t != null && t.sidebarButtons ? t == null ? void 0 : t.sidebarButtons({
150
+ breakpoint: s,
151
+ sidebarButtons: a,
152
+ createSidebarButton: (n) => T({ ...n })
153
+ }) : a;
154
+ }, P = (e, s, t, a) => {
155
+ var n;
156
+ return ((n = a == null ? void 0 : a.rootLayout) == null ? void 0 : n.call(a, {
157
+ breakpoint: t,
158
+ sidebarButtons: s,
159
+ rootLayout: e,
160
+ createSidebarButton: (c) => T({ ...c })
161
+ })) ?? e;
162
+ }, $ = (e) => {
163
+ const s = (e == null ? void 0 : e.breakpointTablet) ?? 1024, t = (e == null ? void 0 : e.breakpointMobile) ?? 768, a = {}, n = [
164
+ {
165
+ id: f.panelBlocks,
166
+ icon: "plusBox",
167
+ label: "Blocks",
168
+ layoutComponent: { type: "panelBlocks" }
169
+ },
170
+ {
171
+ id: f.panelPagesLayers,
172
+ icon: "layers",
173
+ label: "Pages & Layers",
174
+ layoutComponent: { type: "panelPagesLayers" }
175
+ },
176
+ {
177
+ id: f.panelGlobalStyles,
178
+ 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>',
179
+ label: "Global Styles",
180
+ layoutComponent: { type: "panelGlobalStyles" }
181
+ },
182
+ {
183
+ id: f.panelAssets,
184
+ 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>',
185
+ label: "Assets",
186
+ layoutComponent: {
187
+ type: "panelAssets",
188
+ content: { itemsPerRow: 2, header: { addUrl: !1 } },
189
+ style: { padding: 7 },
190
+ onSelect: ({ assetProps: o, editor: i }) => {
191
+ var v;
192
+ const r = i.getSelected(), d = { type: "image", src: o.src };
193
+ if (r != null && r.is("image"))
194
+ return r.set("src", o.src);
195
+ if (r && i.Components.canMove(r, d)) {
196
+ const b = r.append(d)[0];
197
+ b && i.select(b);
198
+ } else if (!r) {
199
+ const b = (v = i.getWrapper()) == null ? void 0 : v.append(d)[0];
200
+ b && i.select(b);
201
+ }
202
+ }
203
+ }
204
+ }
205
+ ], c = [
206
+ ...n,
207
+ {
208
+ id: f.panelSidebarTabs,
209
+ layoutCommand: { header: !1 },
210
+ 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>',
211
+ label: "Styles & Props",
212
+ layoutComponent: { type: "panelSidebarTabs" }
213
+ }
214
+ ], u = {
215
+ id: I,
216
+ type: "column",
217
+ style: { overflow: "hidden" }
218
+ }, y = {
219
+ type: "sidebarLeft",
220
+ resizable: !1,
221
+ style: { padding: "10px 5px", alignItems: "center", width: 45, gap: 10 },
222
+ children: []
223
+ }, g = {
224
+ type: "canvasSidebarTop",
225
+ sidebarTop: {
226
+ leftContainer: {
227
+ buttons: []
228
+ }
229
+ }
230
+ };
231
+ if (s) {
232
+ const o = A(c, s, e);
233
+ a[s] = P(
234
+ {
235
+ type: "row",
236
+ style: { height: "100%" },
237
+ children: [
238
+ {
239
+ ...y,
240
+ children: o
241
+ },
242
+ u,
243
+ g
244
+ ]
245
+ },
246
+ o,
247
+ s,
248
+ e
249
+ );
250
+ }
251
+ if (t) {
252
+ const o = c.map(
253
+ (r) => ({
254
+ ...r,
255
+ layoutCommand: {
256
+ placer: { type: "absolute", position: "left" },
257
+ style: { height: "calc(100% - 40px)" }
258
+ }
259
+ })
260
+ ), i = A(o, t, e);
261
+ a[t] = P(
262
+ {
263
+ type: "column",
264
+ style: { height: "100%" },
265
+ children: [
266
+ { type: "sidebarTop", leftContainer: { buttons: [] } },
267
+ { type: "canvas" },
268
+ {
269
+ type: "sidebarBottom",
270
+ style: { padding: "0 5px", alignItems: "center", gap: 10, minHeight: 39 },
271
+ children: i
272
+ }
273
+ ]
274
+ },
275
+ i,
276
+ t,
277
+ e
278
+ );
279
+ }
280
+ const l = A(n, 0, e);
281
+ return {
282
+ default: P(
283
+ {
284
+ type: "row",
285
+ style: { height: "100%" },
286
+ children: [
287
+ {
288
+ ...y,
289
+ children: l
290
+ },
291
+ u,
292
+ g,
293
+ { type: "sidebarRight" }
294
+ ]
295
+ },
296
+ l,
297
+ 0,
298
+ e
299
+ ),
300
+ responsive: a
301
+ };
302
+ }, R = "layoutSidebarButtons", V = function(e, s = {}) {
303
+ const { Commands: t } = e, a = t.events, n = {
304
+ ...s
305
+ };
306
+ (() => {
307
+ if (e.runCommand(p.layoutConfigGet) || n.skipLayoutConfig === !0) return;
308
+ const y = $(n);
309
+ e.runCommand(p.layoutConfigSet, { ...y });
310
+ })(), t.add(`${R}:toggleButton`, (u, y, g = {}) => {
311
+ const l = document.getElementById(U(g.id));
312
+ l == null || l.click();
313
+ }), e.on(`${a.runCommand}core:preview`, () => {
314
+ E(e);
315
+ }), K({
316
+ editor: e,
317
+ licenseKey: n.licenseKey,
318
+ plan: h.startup,
319
+ pluginName: R,
320
+ cleanup: () => {
321
+ e.runCommand(p.layoutConfigSet);
322
+ }
323
+ });
324
+ }, m = C(V);
325
+ m.createLayoutConfig = (e) => $(e);
326
+ export {
327
+ m as default
328
+ };
@@ -0,0 +1 @@
1
+ (function(b,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(b=typeof globalThis<"u"?globalThis:b||self,b.StudioSdkPlugins_layoutSidebarButtons=f())})(this,function(){"use strict";var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),f=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e))(f||{}),k=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e))(k||{});const w="app.grapesjs.com",R="app-stage.grapesjs.com",M=[w,R,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],H="license:check:start",O="license:check:end",_=()=>typeof window<"u",N=({isDev:e,isStage:s})=>`${e?"":`https://${s?R:w}`}/api`,W=()=>{const e=_()&&window.location.hostname;return!!e&&(M.includes(e)||M.some(s=>e.endsWith(s)))};async function j({path:e,baseApiUrl:s,method:t="GET",headers:n={},params:a,body:c}){const y=`${s||N({isDev:!1,isStage:!1})}${e}`,g={method:t,headers:{"Content-Type":"application/json",...n}};c&&(g.body=JSON.stringify(c));const i=a?new URLSearchParams(a).toString():"",o=i?`?${i}`:"",l=await fetch(`${y}${o}`,g);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}const G={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function S(e){const s=e;return s.init=t=>n=>e(n,t),s}const m=e=>S(e);async function C({editor:e,plan:s,pluginName:t,licenseKey:n,cleanup:a}){let c="",u=!1;const y=W(),g=o=>{console.warn("Cleanup plugin:",t,"Reason:",o),a()},i=(o={})=>{var p;const{error:l,sdkLicense:r}=o,d=(p=o.plan)==null?void 0:p.category;if(!(r||o.license)||l)g(l||"Invalid license");else if(d){const A=G[s],P=G[d];A>P&&g({pluginRequiredPlan:s,licensePlan:d})}};e.on(H,o=>{c=o==null?void 0:o.baseApiUrl,u=!0}),e.on(O,o=>{i(o)}),setTimeout(async()=>{if(!u){if(y)return;if(n){const o=await K({licenseKey:n,pluginName:t,baseApiUrl:c});o&&i(o)}else g("The `licenseKey` option not provided")}},2e3)}async function K(e){const{licenseKey:s,pluginName:t,baseApiUrl:n}=e;try{return(await j({baseApiUrl:n,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}var h=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e))(h||{});const x="sidebarButtonsTarget",T=e=>{const{id:s,icon:t,label:n,tooltip:a,className:c,skipSelfClose:u,removeLayouts:y,layoutComponent:g,layoutCommand:i}=e,o=s;return{id:I(s),type:"button",icon:t,tooltip:n||a,className:c,editorEvents:{[`${k.layoutToggleId}${o}`]:({fromEvent:l,setState:r,editor:d})=>{r({active:l.isOpen}),setTimeout(()=>d.refresh({tools:!0}),20)}},onClick:({editor:l,state:r})=>{if(r.active&&u)return;const d=(i==null?void 0:i.placer)||{type:"static",layoutId:x},v={...d,skipCleanup:d.type==="static"},p=y||Object.keys(h).filter(P=>P!==o);U(l,{removeLayouts:p,layout:{placer:v}});const A={id:o,placer:d,header:(i==null?void 0:i.header)??{label:n,close:!u},layout:g,style:{width:250,height:"100%",borderRightWidth:1,...i==null?void 0:i.style}};l.runCommand(f.layoutToggle,A)}}},I=e=>`button__${e}`,U=(e,s={})=>{(s.removeLayouts||Object.keys(h)).forEach(n=>e.runCommand(f.layoutRemove,{id:n,layout:s.layout}))},L=(e,s,t)=>{const n=e.map(a=>{const c=T(a);return t!=null&&t.sidebarButton?t.sidebarButton({id:a.id,breakpoint:s,buttonProps:c,sidebarButtonProps:a,createSidebarButton:u=>T({...a,...u})}):c}).filter(Boolean);return t!=null&&t.sidebarButtons?t==null?void 0:t.sidebarButtons({breakpoint:s,sidebarButtons:n,createSidebarButton:a=>T({...a})}):n},B=(e,s,t,n)=>{var a;return((a=n==null?void 0:n.rootLayout)==null?void 0:a.call(n,{breakpoint:t,sidebarButtons:s,rootLayout:e,createSidebarButton:c=>T({...c})}))??e},E=e=>{const s=(e==null?void 0:e.breakpointTablet)??1024,t=(e==null?void 0:e.breakpointMobile)??768,n={},a=[{id:h.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:h.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:h.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:h.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:o,editor:l})=>{var v;const r=l.getSelected(),d={type:"image",src:o.src};if(r!=null&&r.is("image"))return r.set("src",o.src);if(r&&l.Components.canMove(r,d)){const p=r.append(d)[0];p&&l.select(p)}else if(!r){const p=(v=l.getWrapper())==null?void 0:v.append(d)[0];p&&l.select(p)}}}}],c=[...a,{id:h.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],u={id:x,type:"column",style:{overflow:"hidden"}},y={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},g={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}};if(s){const o=L(c,s,e);n[s]=B({type:"row",style:{height:"100%"},children:[{...y,children:o},u,g]},o,s,e)}if(t){const o=c.map(r=>({...r,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),l=L(o,t,e);n[t]=B({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:l}]},l,t,e)}const i=L(a,0,e);return{default:B({type:"row",style:{height:"100%"},children:[{...y,children:i},u,g,{type:"sidebarRight"}]},i,0,e),responsive:n}},$="layoutSidebarButtons",D=m(function(e,s={}){const{Commands:t}=e,n=t.events,a={...s};(()=>{if(e.runCommand(f.layoutConfigGet)||a.skipLayoutConfig===!0)return;const y=E(a);e.runCommand(f.layoutConfigSet,{...y})})(),t.add(`${$}:toggleButton`,(u,y,g={})=>{const i=document.getElementById(I(g.id));i==null||i.click()}),e.on(`${n.runCommand}core:preview`,()=>{U(e)}),C({editor:e,licenseKey:a.licenseKey,plan:b.startup,pluginName:$,cleanup:()=>{e.runCommand(f.layoutConfigSet)}})});return D.createLayoutConfig=e=>E(e),D});
@@ -0,0 +1,8 @@
1
+ import { Editor, LayoutCommandProps, LayoutConfig } from '../types';
2
+ import { LayoutSidebarButtonsOptions } from './types';
3
+ export declare const createButtonId: (id: string) => string;
4
+ export declare const removeSidebarLayouts: (editor: Editor, props?: {
5
+ removeLayouts?: string[];
6
+ layout?: Partial<LayoutCommandProps>;
7
+ }) => void;
8
+ export declare const createLayoutConfig: (props?: LayoutSidebarButtonsOptions) => LayoutConfig;
@@ -0,0 +1,75 @@
1
+ import { LayoutCommandProps, LayoutConfig, RootLayoutConfig, StudioLayoutButtonConfigProps, StudioLayoutComponentsConfigProps } from '../types';
2
+ import { PluginWithInit } from '../utils';
3
+ import { LayoutSidebarButtonsOptions as LayoutSidebarButtonsOptionsSchema } from './typesSchema';
4
+ export interface LayoutSidebarButtonsOptions extends Omit<LayoutSidebarButtonsOptionsSchema, 'sidebarButton' | 'rootLayout' | 'sidebarButtons'> {
5
+ /**
6
+ * Customize each sidebar button.
7
+ * @example
8
+ * sidebarButton: ({ id, buttonProps, breakpoint, createSidebarButton }) => ({
9
+ * ...buttonProps,
10
+ * // custom icon for panelBlocks button
11
+ * icon: buttonProps.id === 'panelBlocks' ? '<svg ...>' : buttonProps.icon,
12
+ * })
13
+ */
14
+ sidebarButton?: SidebarButtonFn;
15
+ /**
16
+ * Add or filter the resultant buttons per breakpoint.
17
+ * @example
18
+ * sidebarButtons: ({ breakpoint, sidebarButtons, createSidebarButton }) => {
19
+ * // Add a new button for the default layout
20
+ * return !breakpoint ? [...sidebarButtons, createSidebarButton({...})] : sidebarButtons;
21
+ * }
22
+ */
23
+ sidebarButtons?: SidebarButtonsFn;
24
+ /**
25
+ * Customize the root layout per breakpoint.
26
+ */
27
+ rootLayout?: CustomRootLayoutFn;
28
+ /**
29
+ * Skip loading the layout config.
30
+ * This might be useful if you're loading the layout config directly in the config.
31
+ * @default false
32
+ */
33
+ skipLayoutConfig?: boolean;
34
+ }
35
+ export type SidebarButtonResult = StudioLayoutComponentsConfigProps | undefined | null | false;
36
+ export type CreateSidebarButtonFn = (props: SidebarButtonProps) => StudioLayoutButtonConfigProps;
37
+ export type SidebarButtonFn = (props: {
38
+ id: string;
39
+ breakpoint: number;
40
+ sidebarButtonProps: SidebarButtonProps;
41
+ buttonProps: StudioLayoutButtonConfigProps;
42
+ createSidebarButton: (props: Partial<SidebarButtonProps>) => StudioLayoutButtonConfigProps;
43
+ }) => SidebarButtonResult;
44
+ export type SidebarButtonsFn = (props: {
45
+ breakpoint: number;
46
+ sidebarButtons: SidebarButtonResult[];
47
+ createSidebarButton: CreateSidebarButtonFn;
48
+ }) => SidebarButtonResult[];
49
+ export type CustomRootLayoutFn = (props: {
50
+ breakpoint: number;
51
+ sidebarButtons: SidebarButtonResult[];
52
+ rootLayout: RootLayoutConfig;
53
+ createSidebarButton: CreateSidebarButtonFn;
54
+ }) => RootLayoutConfig;
55
+ export interface SidebarButtonProps {
56
+ id: string;
57
+ icon: string;
58
+ label?: string;
59
+ className?: string;
60
+ layoutComponent: StudioLayoutComponentsConfigProps;
61
+ layoutCommand?: Partial<LayoutCommandProps>;
62
+ tooltip?: string;
63
+ skipSelfClose?: boolean;
64
+ removeLayouts?: string[];
65
+ }
66
+ export declare enum SidebarButtonIds {
67
+ panelBlocks = "panelBlocks",
68
+ panelPagesLayers = "panelPagesLayers",
69
+ panelGlobalStyles = "panelGlobalStyles",
70
+ panelSidebarTabs = "panelSidebarTabs",
71
+ panelAssets = "panelAssets"
72
+ }
73
+ export interface SDKPluginWithLayoutConfig extends PluginWithInit<LayoutSidebarButtonsOptions> {
74
+ createLayoutConfig: (options?: Pick<LayoutSidebarButtonsOptions, 'sidebarButton' | 'sidebarButtons' | 'rootLayout'>) => LayoutConfig;
75
+ }
@@ -0,0 +1,49 @@
1
+ import { SDKPluginOptions } from '../utils';
2
+ export interface LayoutSidebarButtonsOptions extends SDKPluginOptions {
3
+ /**
4
+ * Extend each sidebar button per breakpoint.
5
+ * @example
6
+ * sidebarButton: ({ id, buttonProps, breakpoint, createSidebarButton }) => ({
7
+ * ...buttonProps,
8
+ * // custom icon for panelBlocks button
9
+ * icon: buttonProps.id === 'panelBlocks' ? '<svg ...>' : buttonProps.icon,
10
+ * })
11
+ */
12
+ sidebarButton?: '__fn__';
13
+ /**
14
+ * Add or filter the resultant buttons per breakpoint.
15
+ * @example
16
+ * sidebarButtons: ({ breakpoint, sidebarButtons, createSidebarButton }) => {
17
+ * // Add a new button for the default layout
18
+ * return !breakpoint ? [...sidebarButtons, createSidebarButton({...})] sidebarButtons;
19
+ * }
20
+ */
21
+ sidebarButtons?: '__fn__';
22
+ /**
23
+ * Customize the resultant root layout per breakpoint.
24
+ * @example
25
+ * rootLayout({ breakpoint, rootLayout, sidebarButtons, createSidebarButton }) {
26
+ * if (breakpoint === 768) {
27
+ * return {
28
+ * ...rootLayout,
29
+ * children: [
30
+ * { type: 'canvas' },
31
+ * { type: 'sidebarBottom', children: [ ...sidebarButtons, createSidebarButton({...}) ] }
32
+ * ]
33
+ * };
34
+ * }
35
+ * return rootLayout;
36
+ * }
37
+ */
38
+ rootLayout?: '__fn__';
39
+ /**
40
+ * Custom tablet breakpoint.
41
+ * @default 1024
42
+ */
43
+ breakpointTablet?: number;
44
+ /**
45
+ * Custom mobile breakpoint.
46
+ * @default 768
47
+ */
48
+ breakpointMobile?: number;
49
+ }
@@ -1 +1 @@
1
- "use strict";require("grapesjs");const ie="app.grapesjs.com",re="app-stage.grapesjs.com",Y=[ie,re,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:start",he="license:check:end",ge=()=>typeof window<"u",be=({isDev:e,isStage:l})=>`${e?"":`https://${l?re:ie}`}/api`,de=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function me({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:s,body:u}){const p=`${l||be({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=s?new URLSearchParams(s).toString():"",i=c?`?${c}`:"",b=await fetch(`${p}${i}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{});const ee={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function ye(e){const l=e;return l.init=a=>n=>e(n,a),l}const ve=e=>ye(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:s}){let u="",r=!1;const p=de(),h=i=>{console.warn("Cleanup plugin:",a,"Reason:",i),s()},c=(i={})=>{var L;const{error:b,sdkLicense:C}=i,T=(L=i.plan)==null?void 0:L.category;if(!(C||i.license)||b)h(b||"Invalid license");else if(T){const G=ee[l],V=ee[T];G>V&&h({pluginRequiredPlan:l,licensePlan:T})}};e.on(ue,i=>{u=i==null?void 0:i.baseApiUrl,r=!0}),e.on(he,i=>{c(i)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const i=await Te({licenseKey:n,pluginName:a,baseApiUrl:u});i&&c(i)}else h("The `licenseKey` option not provided")}},2e3)}async function Te(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await me({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const z=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var P=(e=>(e.image="image",e.video="video",e.external="external",e))(P||{});const k="lightGallery",te=`${k}-item`,H="data-lightgallery",ae=`${H}-item`,U="toggle",I={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>'},B={propKeys:[],props:{},traits:[]},M=(e,l={})=>{var s;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(s=h[c])==null||s.forEach(i=>{const b=i.id||i.name;a[b]=i.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),s=a.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=s[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},W=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const s=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(s,()=>Z(e,a)),Z(e,a)})},we=(e,l,a)=>{const s=e.getTrait(l).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},Se={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.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}},xe={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"}]}}},ke={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}]}}},Ie={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",D="data-iframe",R={name:"href",type:"file",label:"Image Source"},N={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},F={name:"data-poster",label:"Video Poster",type:"file"},ne={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Le={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var s,u;const a=l.target,n=(s=a==null?void 0:a.closestType(k))==null?void 0:s.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[R],video:[N,F],external:[ne]},options:[{id:"image",label:R.label||"",icon:I.image},{id:"video",label:N.label||"",icon:I.video},{id:"external",label:ne.label||"",icon:I.external}]},subHtml:ce},Ae="lightGalleryComponent",le="lgThumbnail",Pe="lgVideo",oe="lgAutoplay",se="lgZoom",A="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ee=function(e,l={}){const{Blocks:a,Components:n}=e,s="LightGallery",u="LightGallery Item",r={toolbarIconOpen:I.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[le,Pe,oe,se],cdnScript:[`${A}/lightgallery.min.js`,`${A}/plugins/thumbnail/lg-thumbnail.min.js`,`${A}/plugins/video/lg-video.min.js`,`${A}/plugins/autoplay/lg-autoplay.min.js`,`${A}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${A}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,i=function(t){const o=this,g=window,{plugins:m,cdnScript:w,cdnStyle:O,inline:J,lgLicenseKey:pe,...y}=t||{},S=d=>isNaN(d)?void 0:parseInt(d,10),Q=()=>{var $;const d={...y,licenseKey:pe,speed:S(y.speed),startAnimationDuration:S(y.startAnimationDuration),thumbMargin:S(y.thumbMargin),thumbWidth:S(y.thumbWidth),slideShowInterval:S(y.slideShowInterval),scale:S(y.scale),enableZoomAfter:S(y.enableZoomAfter),plugins:(m||[]).map(K=>g[K])};J&&(d.container=o,d.closable=!1);const j=($=g.lightGallery)==null?void 0:$.call(g,o,d);J&&j.openGallery()};if(g.lightGallery)Q();else{const{head:d}=document,j=Array.isArray(w)?[...w]:[w],$=Array.isArray(O)?[...O]:[O],K=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",d.appendChild(v),K(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),d.appendChild(v)}else Q()};K($),X(j)}},b=t=>{const o=t.getTrait(U);if(!h||!o)return;const{toolbar:g}=t,m={id:U,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find(O=>O.id===m.id)&&(g==null||g.unshift(m))};let C=[];const T=r.plugins||[],_=M(Se),L=T.includes(le)?M(xe):B,G=T.includes(oe)?M(ke):B,V=T.includes(se)?M(Ie):B;n.addType(k,{block:p&&{label:s,media:I.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>z(t,H),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:I.gallery,draggable:(t,o)=>!o.is(k),attributes:{[H]:!0},components:{type:te},script:i,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",..._.propKeys,...L.propKeys,...G.propKeys,...V.propKeys],..._.props,...L.props,...G.props,...V.props,traits:[..._.traits,...L.traits,...G.traits,...V.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,n.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();C=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();C.forEach(o=>this.em.Canvas.addSpot(o.attributes)),C=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const q=M(Le);n.addType(te,{isComponent:t=>z(t,ae)||t.tagName==="A"&&z(t.parentElement,H),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:I.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...q.props,traits:[...q.traits]},init(){const t=[f].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),we(this,f,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ce.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(k))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[f]||g){Z(this,f);const m=this.getTrait(f).getValue();if(m===P.image){this.removeAttributes([N.name,F.name,D]);const w=this.getTrait(R.name);w.setValue(w.getValue()||c)}else m===P.video?this.removeAttributes([D]):m===P.external&&this.addAttributes({[D]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[D]?this.set(f,P.external):(t[N.name]||t[F.name])&&this.set(f,P.video)}}}),fe({editor:e,plan:E.startup,licenseKey:r.licenseKey,pluginName:Ae,cleanup:()=>{a.remove(k),n.removeType(k)}})},Ce=ve(Ee);module.exports=Ce;
1
+ "use strict";const ie="app.grapesjs.com",re="app-stage.grapesjs.com",Y=[ie,re,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:start",he="license:check:end",ge=()=>typeof window<"u",be=({isDev:e,isStage:l})=>`${e?"":`https://${l?re:ie}`}/api`,de=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function me({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:s,body:u}){const p=`${l||be({isDev:!1,isStage:!1})}${e}`,h={method:a,headers:{"Content-Type":"application/json",...n}};u&&(h.body=JSON.stringify(u));const c=s?new URLSearchParams(s).toString():"",i=c?`?${c}`:"",b=await fetch(`${p}${i}`,h);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}var E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{});const ee={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function ye(e){const l=e;return l.init=a=>n=>e(n,a),l}const ve=e=>ye(e);async function fe({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:s}){let u="",r=!1;const p=de(),h=i=>{console.warn("Cleanup plugin:",a,"Reason:",i),s()},c=(i={})=>{var L;const{error:b,sdkLicense:C}=i,T=(L=i.plan)==null?void 0:L.category;if(!(C||i.license)||b)h(b||"Invalid license");else if(T){const G=ee[l],V=ee[T];G>V&&h({pluginRequiredPlan:l,licensePlan:T})}};e.on(ue,i=>{u=i==null?void 0:i.baseApiUrl,r=!0}),e.on(he,i=>{c(i)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const i=await Te({licenseKey:n,pluginName:a,baseApiUrl:u});i&&c(i)}else h("The `licenseKey` option not provided")}},2e3)}async function Te(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await me({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}const z=(e,l)=>{var a;return!!((a=e==null?void 0:e.hasAttribute)!=null&&a.call(e,l))};var P=(e=>(e.image="image",e.video="video",e.external="external",e))(P||{});const k="lightGallery",te=`${k}-item`,H="data-lightgallery",ae=`${H}-item`,U="toggle",I={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>'},B={propKeys:[],props:{},traits:[]},M=(e,l={})=>{var s;const a={},n=[];for(const u in e){const{value:r,...p}=e[u];n.push({id:u,name:u,changeProp:!0,category:l.category,...p}),a[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(s=h[c])==null||s.forEach(i=>{const b=i.id||i.name;a[b]=i.value})}return{propKeys:Object.keys(a),props:a,traits:n}},Z=(e,l)=>{const a=e.getTrait(l),n=a.get("category"),s=a.get("subTraits")||{},r=(Object.values(s).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=s[a.getValue()],h=e.getTraitIndex(l)+1;p&&e.addTrait(p.map(c=>({category:n,...c})),{at:h})},W=(e,l)=>{l.forEach(a=>{const n=e.getTrait(a);if(!n||!n.get("subTraits"))return;const s=n.changeProp?`change:${a}`:`change:attributes:${a}`;e.on(s,()=>Z(e,a)),Z(e,a)})},we=(e,l,a)=>{const s=e.getTrait(l).get("subTraits")||{},r=(Object.values(s).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),a)},Se={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var a,n;return(n=(a=l.target)==null?void 0:a.getView())==null?void 0:n.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}},xe={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"}]}}},ke={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}]}}},Ie={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",D="data-iframe",R={name:"href",type:"file",label:"Image Source"},N={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},F={name:"data-poster",label:"Video Poster",type:"file"},ne={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Le={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var s,u;const a=l.target,n=(s=a==null?void 0:a.closestType(k))==null?void 0:s.getView();if(n&&a){const r=((u=n.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(a.getEl());p>=0&&n.toggleGallery(p)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[R],video:[N,F],external:[ne]},options:[{id:"image",label:R.label||"",icon:I.image},{id:"video",label:N.label||"",icon:I.video},{id:"external",label:ne.label||"",icon:I.external}]},subHtml:ce},Ae="lightGalleryComponent",le="lgThumbnail",Pe="lgVideo",oe="lgAutoplay",se="lgZoom",A="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ee=function(e,l={}){const{Blocks:a,Components:n}=e,s="LightGallery",u="LightGallery Item",r={toolbarIconOpen:I.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[le,Pe,oe,se],cdnScript:[`${A}/lightgallery.min.js`,`${A}/plugins/thumbnail/lg-thumbnail.min.js`,`${A}/plugins/video/lg-video.min.js`,`${A}/plugins/autoplay/lg-autoplay.min.js`,`${A}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${A}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,i=function(t){const o=this,g=window,{plugins:m,cdnScript:w,cdnStyle:O,inline:J,lgLicenseKey:pe,...y}=t||{},S=d=>isNaN(d)?void 0:parseInt(d,10),Q=()=>{var $;const d={...y,licenseKey:pe,speed:S(y.speed),startAnimationDuration:S(y.startAnimationDuration),thumbMargin:S(y.thumbMargin),thumbWidth:S(y.thumbWidth),slideShowInterval:S(y.slideShowInterval),scale:S(y.scale),enableZoomAfter:S(y.enableZoomAfter),plugins:(m||[]).map(K=>g[K])};J&&(d.container=o,d.closable=!1);const j=($=g.lightGallery)==null?void 0:$.call(g,o,d);J&&j.openGallery()};if(g.lightGallery)Q();else{const{head:d}=document,j=Array.isArray(w)?[...w]:[w],$=Array.isArray(O)?[...O]:[O],K=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",d.appendChild(v),K(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),d.appendChild(v)}else Q()};K($),X(j)}},b=t=>{const o=t.getTrait(U);if(!h||!o)return;const{toolbar:g}=t,m={id:U,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find(O=>O.id===m.id)&&(g==null||g.unshift(m))};let C=[];const T=r.plugins||[],_=M(Se),L=T.includes(le)?M(xe):B,G=T.includes(oe)?M(ke):B,V=T.includes(se)?M(Ie):B;n.addType(k,{block:p&&{label:s,media:I.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>z(t,H),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:I.gallery,draggable:(t,o)=>!o.is(k),attributes:{[H]:!0},components:{type:te},script:i,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",..._.propKeys,...L.propKeys,...G.propKeys,...V.propKeys],..._.props,...L.props,...G.props,...V.props,traits:[..._.traits,...L.traits,...G.traits,...V.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(this,["zoom"])},initToolbar(){b(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,n.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const t=this.getLightGallery();t==null||t.destroy()},disableLgInCanvas(){const t=this.getLightGallery();t.lgOpened=!0},isInlineGallery(){var o;const t=this.getLightGallery();return((o=t==null?void 0:t.settings)==null?void 0:o.container)===this.el},onLgInit(t){this.el.__lg=t.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:t}=this,{Canvas:o}=t,g=this.getLightGallery();C=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();C.forEach(o=>this.em.Canvas.addSpot(o.attributes)),C=[],t.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(t){const o=this.getLightGallery();if(o.__lgOpened)return o.closeGallery(!0);o.lgOpened=!1,o.openGallery(t)}}});const q=M(Le);n.addType(te,{isComponent:t=>z(t,ae)||t.tagName==="A"&&z(t.parentElement,H),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:I.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...q.props,traits:[...q.traits]},init(){const t=[f].map(o=>`change:${o}`).join(" ");this.initSourceType(),this.on(t,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),we(this,f,this.triggerGalleryUpdate)},initToolbar(){b(this)},initScriptUpdate(){const t=[ce.name].map(o=>`change:attributes:${o}`).join(" ");this.on(t,this.triggerGalleryUpdate)},triggerGalleryUpdate(...t){var o;(o=this.closestType(k))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[f]||g){Z(this,f);const m=this.getTrait(f).getValue();if(m===P.image){this.removeAttributes([N.name,F.name,D]);const w=this.getTrait(R.name);w.setValue(w.getValue()||c)}else m===P.video?this.removeAttributes([D]):m===P.external&&this.addAttributes({[D]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[D]?this.set(f,P.external):(t[N.name]||t[F.name])&&this.set(f,P.video)}}}),fe({editor:e,plan:E.startup,licenseKey:r.licenseKey,pluginName:Ae,cleanup:()=>{a.remove(k),n.removeType(k)}})},Ce=ve(Ee);module.exports=Ce;
@@ -1,4 +1,3 @@
1
- import "grapesjs";
2
1
  const ie = "app.grapesjs.com", re = "app-stage.grapesjs.com", Y = [
3
2
  ie,
4
3
  re,
@@ -737,7 +736,7 @@ const k = "lightGallery", te = `${k}-item`, H = "data-lightgallery", ae = `${H}-
737
736
  a.remove(k), n.removeType(k);
738
737
  }
739
738
  });
740
- }, Ge = ve(Ee);
739
+ }, Ce = ve(Ee);
741
740
  export {
742
- Ge as default
741
+ Ce as default
743
742
  };