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