@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
const x = "app.grapesjs.com", E = "app-stage.grapesjs.com",
|
|
1
|
+
var A = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(A || {}), B = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(B || {}), I = /* @__PURE__ */ ((e) => (e.layoutToggleId = "studio:layoutToggle:", e.toggleBlocksPanel = "studio:toggleBlocksPanel", e.pageSettingsUpdate = "studio:pageSettingsUpdate", e.toggleDataSourcesPreview = "studio:toggleDataSourcesPreview", e))(I || {});
|
|
2
|
+
const x = "app.grapesjs.com", E = "app-stage.grapesjs.com", _ = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", k = [
|
|
3
3
|
x,
|
|
4
|
-
|
|
4
|
+
_,
|
|
5
5
|
E,
|
|
6
6
|
H,
|
|
7
7
|
"localhost",
|
|
@@ -12,135 +12,140 @@ const x = "app.grapesjs.com", E = "app-stage.grapesjs.com", $ = "app2.grapesjs.c
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
], S = "license:check:start", j = "license:check:end",
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
], S = "license:check:start", j = "license:check:end", W = () => typeof window < "u", K = ({
|
|
16
|
+
isDev: e,
|
|
17
|
+
isStage: a,
|
|
18
|
+
isPlatform: o
|
|
19
|
+
}) => `${e ? "" : `https://${a ? E : x}`}/${o ? "platform-api" : "api"}`, V = () => {
|
|
20
|
+
const e = W() && window.location.hostname;
|
|
21
|
+
return !!e && (k.includes(e) || k.some((a) => e.endsWith(a)));
|
|
18
22
|
};
|
|
19
|
-
async function
|
|
23
|
+
async function m({
|
|
20
24
|
path: e,
|
|
21
25
|
baseApiUrl: a,
|
|
22
|
-
method:
|
|
23
|
-
headers:
|
|
24
|
-
params:
|
|
25
|
-
body:
|
|
26
|
+
method: o = "GET",
|
|
27
|
+
headers: r = {},
|
|
28
|
+
params: s,
|
|
29
|
+
body: h
|
|
26
30
|
}) {
|
|
27
|
-
const
|
|
28
|
-
method:
|
|
31
|
+
const d = `${a || K({ isDev: !1, isStage: !1 })}${e}`, b = {
|
|
32
|
+
method: o,
|
|
29
33
|
headers: {
|
|
30
34
|
"Content-Type": "application/json",
|
|
31
|
-
...
|
|
35
|
+
...r
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(`HTTP error! status: ${
|
|
38
|
-
return
|
|
38
|
+
h && (b.body = JSON.stringify(h));
|
|
39
|
+
const g = s ? new URLSearchParams(s).toString() : "", u = g ? `?${g}` : "", t = await fetch(`${d}${u}`, b);
|
|
40
|
+
if (!t.ok)
|
|
41
|
+
throw new Error(`HTTP error! status: ${t.status}`);
|
|
42
|
+
return t.json();
|
|
39
43
|
}
|
|
40
|
-
const
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
44
|
+
const M = {
|
|
45
|
+
[A.free]: 0,
|
|
46
|
+
[A.startup]: 10,
|
|
47
|
+
[A.business]: 20,
|
|
48
|
+
[A.enterprise]: 30
|
|
45
49
|
};
|
|
46
50
|
function F(e) {
|
|
47
51
|
const a = e;
|
|
48
|
-
return a.init = (
|
|
52
|
+
return a.init = (o) => (r) => e(r, o), a;
|
|
49
53
|
}
|
|
50
|
-
const
|
|
51
|
-
async function
|
|
54
|
+
const q = (e) => /* @__PURE__ */ F(e);
|
|
55
|
+
async function Z({
|
|
52
56
|
editor: e,
|
|
53
57
|
plan: a,
|
|
54
|
-
pluginName:
|
|
55
|
-
licenseKey:
|
|
56
|
-
|
|
58
|
+
pluginName: o,
|
|
59
|
+
licenseKey: r,
|
|
60
|
+
onLicenseCheckResponse: s,
|
|
61
|
+
cleanup: h
|
|
57
62
|
}) {
|
|
58
|
-
let
|
|
59
|
-
const b =
|
|
60
|
-
console.warn("Cleanup plugin:",
|
|
61
|
-
},
|
|
62
|
-
var
|
|
63
|
-
const { error:
|
|
64
|
-
if (!(
|
|
65
|
-
g(
|
|
66
|
-
else if (
|
|
67
|
-
const
|
|
68
|
-
|
|
63
|
+
let f = "", d = !1;
|
|
64
|
+
const b = V(), g = (t) => {
|
|
65
|
+
console.warn("Cleanup plugin:", o, "Reason:", t), h();
|
|
66
|
+
}, u = (t = {}) => {
|
|
67
|
+
var i;
|
|
68
|
+
const { error: P, sdkLicense: l } = t, c = (i = t.plan) == null ? void 0 : i.category;
|
|
69
|
+
if (!(l || t.license) || P)
|
|
70
|
+
g(P || "Invalid license");
|
|
71
|
+
else if (c) {
|
|
72
|
+
const y = M[a], p = M[c];
|
|
73
|
+
y > p && g({ pluginRequiredPlan: a, licensePlan: c });
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
76
|
e.on(S, (t) => {
|
|
72
|
-
|
|
77
|
+
f = t == null ? void 0 : t.baseApiUrl, d = !0;
|
|
73
78
|
}), e.on(j, (t) => {
|
|
74
|
-
|
|
79
|
+
s == null || s(t), u(t);
|
|
75
80
|
}), setTimeout(async () => {
|
|
76
|
-
if (!
|
|
81
|
+
if (!d) {
|
|
77
82
|
if (b) return;
|
|
78
|
-
if (
|
|
79
|
-
const t = await
|
|
80
|
-
t &&
|
|
83
|
+
if (r) {
|
|
84
|
+
const t = await z({ licenseKey: r, pluginName: o, baseApiUrl: f });
|
|
85
|
+
s == null || s(t), t && u(t);
|
|
81
86
|
} else
|
|
82
87
|
g("The `licenseKey` option not provided");
|
|
83
88
|
}
|
|
84
89
|
}, 2e3);
|
|
85
90
|
}
|
|
86
|
-
async function
|
|
87
|
-
const { licenseKey: a, pluginName:
|
|
91
|
+
async function z(e) {
|
|
92
|
+
const { licenseKey: a, pluginName: o, baseApiUrl: r } = e;
|
|
88
93
|
try {
|
|
89
|
-
return (await
|
|
90
|
-
baseApiUrl:
|
|
94
|
+
return (await m({
|
|
95
|
+
baseApiUrl: r,
|
|
91
96
|
path: `/sdk/${a || "na"}`,
|
|
92
97
|
method: "POST",
|
|
93
98
|
params: {
|
|
94
99
|
d: window.location.hostname,
|
|
95
|
-
pn:
|
|
100
|
+
pn: o
|
|
96
101
|
}
|
|
97
102
|
})).result || {};
|
|
98
|
-
} catch (
|
|
99
|
-
return console.error("Error during SDK license check:",
|
|
103
|
+
} catch (s) {
|
|
104
|
+
return console.error("Error during SDK license check:", s), !1;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
var v = /* @__PURE__ */ ((e) => (e.panelBlocks = "panelBlocks", e.panelPagesLayers = "panelPagesLayers", e.panelGlobalStyles = "panelGlobalStyles", e.panelSidebarTabs = "panelSidebarTabs", e.panelAssets = "panelAssets", e.aiChatPanel = "aiChatPanel", e.panelDataSources = "panelDataSources", e))(v || {});
|
|
103
|
-
const O = "sidebarButtonsTarget",
|
|
104
|
-
const { id:
|
|
108
|
+
const O = "sidebarButtonsTarget", D = (e, a) => {
|
|
109
|
+
const { id: o, icon: r, label: s, tooltip: h, className: f, skipSelfClose: d, removeLayouts: b, layoutComponent: g, layoutCommand: u } = e, { pluginOpts: t, breakpointProps: P } = a, l = o;
|
|
105
110
|
return {
|
|
106
|
-
id: U(
|
|
111
|
+
id: U(o),
|
|
107
112
|
type: "button",
|
|
108
|
-
icon:
|
|
109
|
-
tooltip:
|
|
113
|
+
icon: r,
|
|
114
|
+
tooltip: s || h,
|
|
110
115
|
className: f,
|
|
111
116
|
editorEvents: {
|
|
112
|
-
[`${I.layoutToggleId}${
|
|
113
|
-
|
|
117
|
+
[`${I.layoutToggleId}${l}`]: ({ fromEvent: c, setState: n, editor: i }) => {
|
|
118
|
+
n({ active: c.isOpen }), setTimeout(() => i.refresh({ tools: !0 }), 20);
|
|
114
119
|
}
|
|
115
120
|
},
|
|
116
|
-
onClick: ({ editor:
|
|
117
|
-
var
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
N(
|
|
121
|
-
const
|
|
122
|
-
id:
|
|
123
|
-
placer:
|
|
124
|
-
header: (
|
|
125
|
-
layout:
|
|
121
|
+
onClick: ({ editor: c, state: n }) => {
|
|
122
|
+
var w;
|
|
123
|
+
if (n.active && d) return;
|
|
124
|
+
const i = (u == null ? void 0 : u.placer) || { type: "static", layoutId: O }, y = { ...i, skipCleanup: i.type === "static" }, p = b || Object.keys(v).filter((G) => G !== l);
|
|
125
|
+
N(c, { removeLayouts: p, layout: { placer: y } });
|
|
126
|
+
const L = {
|
|
127
|
+
id: l,
|
|
128
|
+
placer: i,
|
|
129
|
+
header: (u == null ? void 0 : u.header) ?? { label: s, close: !d },
|
|
130
|
+
layout: g,
|
|
126
131
|
style: {
|
|
127
132
|
width: 280,
|
|
128
133
|
height: "100%",
|
|
129
134
|
borderRightWidth: 1,
|
|
130
|
-
...
|
|
135
|
+
...u == null ? void 0 : u.style
|
|
131
136
|
}
|
|
132
|
-
}, T = ((
|
|
133
|
-
...
|
|
134
|
-
layoutCommand:
|
|
137
|
+
}, T = ((w = t == null ? void 0 : t.sidebarLayoutCommand) == null ? void 0 : w.call(t, {
|
|
138
|
+
...P,
|
|
139
|
+
layoutCommand: L,
|
|
135
140
|
sidebarButtonProps: e
|
|
136
|
-
})) ||
|
|
137
|
-
|
|
141
|
+
})) || L;
|
|
142
|
+
c.runCommand(B.layoutToggle, { ...T });
|
|
138
143
|
}
|
|
139
144
|
};
|
|
140
145
|
}, U = (e) => `button__${e}`, N = (e, a = {}) => {
|
|
141
|
-
(a.removeLayouts || Object.keys(v)).forEach((
|
|
142
|
-
},
|
|
143
|
-
const a = (e == null ? void 0 : e.breakpointTablet) ?? 1024,
|
|
146
|
+
(a.removeLayouts || Object.keys(v)).forEach((r) => e.runCommand(B.layoutRemove, { id: r, layout: a.layout }));
|
|
147
|
+
}, $ = (e) => {
|
|
148
|
+
const a = (e == null ? void 0 : e.breakpointTablet) ?? 1024, o = (e == null ? void 0 : e.breakpointMobile) ?? 768, r = {}, s = [
|
|
144
149
|
{
|
|
145
150
|
id: v.panelBlocks,
|
|
146
151
|
icon: "plusBox",
|
|
@@ -167,18 +172,18 @@ const O = "sidebarButtonsTarget", R = (e, a) => {
|
|
|
167
172
|
type: "panelAssets",
|
|
168
173
|
content: { itemsPerRow: 2, header: { addUrl: !1 } },
|
|
169
174
|
style: { padding: 7 },
|
|
170
|
-
onSelect: ({ assetProps:
|
|
171
|
-
var
|
|
172
|
-
const
|
|
175
|
+
onSelect: ({ assetProps: l, editor: c }) => {
|
|
176
|
+
var p;
|
|
177
|
+
const n = c.getSelected(), i = { type: "image", src: l.src };
|
|
173
178
|
let y;
|
|
174
|
-
if (
|
|
175
|
-
return
|
|
176
|
-
|
|
179
|
+
if (n != null && n.is("image"))
|
|
180
|
+
return n.set("src", l.src);
|
|
181
|
+
n && c.Components.canMove(n, i) ? y = n.append(i)[0] : n || (y = (p = c.getWrapper()) == null ? void 0 : p.append(i)[0]), y && c.select(y, { scroll: !0 });
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
|
-
],
|
|
181
|
-
...
|
|
185
|
+
], h = [
|
|
186
|
+
...s,
|
|
182
187
|
{
|
|
183
188
|
id: v.panelSidebarTabs,
|
|
184
189
|
layoutCommand: { header: !1 },
|
|
@@ -191,86 +196,86 @@ const O = "sidebarButtonsTarget", R = (e, a) => {
|
|
|
191
196
|
type: "column",
|
|
192
197
|
className: "gs-cmp-layout-sidebar-target",
|
|
193
198
|
style: { overflow: "hidden" }
|
|
194
|
-
},
|
|
199
|
+
}, d = {
|
|
195
200
|
type: "sidebarLeft",
|
|
196
201
|
resizable: !1,
|
|
197
202
|
style: { padding: "10px 5px", alignItems: "center", width: 45, gap: 10 },
|
|
198
203
|
children: []
|
|
199
|
-
},
|
|
204
|
+
}, b = {
|
|
200
205
|
type: "canvasSidebarTop",
|
|
201
206
|
sidebarTop: {
|
|
202
207
|
leftContainer: {
|
|
203
208
|
buttons: []
|
|
204
209
|
}
|
|
205
210
|
}
|
|
206
|
-
},
|
|
207
|
-
breakpoint:
|
|
211
|
+
}, g = (l) => ({
|
|
212
|
+
breakpoint: l,
|
|
208
213
|
breakpointTablet: a,
|
|
209
|
-
breakpointMobile:
|
|
210
|
-
}),
|
|
211
|
-
const
|
|
212
|
-
const
|
|
214
|
+
breakpointMobile: o
|
|
215
|
+
}), u = (l, c, n) => {
|
|
216
|
+
const i = g(c), y = { pluginOpts: e, breakpointProps: i }, p = l.map((T) => {
|
|
217
|
+
const w = D(T, y);
|
|
213
218
|
return e != null && e.sidebarButton ? e.sidebarButton({
|
|
214
219
|
id: T.id,
|
|
215
220
|
buttonIds: v,
|
|
216
|
-
buttonProps:
|
|
221
|
+
buttonProps: w,
|
|
217
222
|
sidebarButtonProps: T,
|
|
218
|
-
...
|
|
219
|
-
createSidebarButton: (
|
|
220
|
-
}) :
|
|
223
|
+
...i,
|
|
224
|
+
createSidebarButton: (G) => D({ ...T, ...G }, y)
|
|
225
|
+
}) : w;
|
|
221
226
|
}).filter(Boolean);
|
|
222
227
|
return (e != null && e.sidebarButtons ? e == null ? void 0 : e.sidebarButtons({
|
|
223
228
|
buttonIds: v,
|
|
224
|
-
sidebarButtons:
|
|
225
|
-
...
|
|
226
|
-
createSidebarButton: (T) =>
|
|
229
|
+
sidebarButtons: p,
|
|
230
|
+
...i,
|
|
231
|
+
createSidebarButton: (T) => D(
|
|
227
232
|
{
|
|
228
233
|
...T,
|
|
229
234
|
layoutCommand: {
|
|
230
|
-
...
|
|
235
|
+
...n == null ? void 0 : n.layoutCommand,
|
|
231
236
|
...T.layoutCommand
|
|
232
237
|
}
|
|
233
238
|
},
|
|
234
239
|
y
|
|
235
240
|
)
|
|
236
|
-
}) :
|
|
237
|
-
},
|
|
238
|
-
var
|
|
239
|
-
const
|
|
240
|
-
return ((
|
|
241
|
-
sidebarButtons:
|
|
242
|
-
rootLayout:
|
|
243
|
-
layoutSidebarLeft:
|
|
241
|
+
}) : p).filter(Boolean);
|
|
242
|
+
}, t = (l, c, n) => {
|
|
243
|
+
var p;
|
|
244
|
+
const i = g(n), y = { pluginOpts: e, breakpointProps: i };
|
|
245
|
+
return ((p = e == null ? void 0 : e.rootLayout) == null ? void 0 : p.call(e, {
|
|
246
|
+
sidebarButtons: c,
|
|
247
|
+
rootLayout: l,
|
|
248
|
+
layoutSidebarLeft: d,
|
|
244
249
|
layoutSidebarTarget: f,
|
|
245
|
-
...
|
|
246
|
-
createSidebarButton: (
|
|
247
|
-
})) ??
|
|
250
|
+
...i,
|
|
251
|
+
createSidebarButton: (L) => D({ ...L }, y)
|
|
252
|
+
})) ?? l;
|
|
248
253
|
};
|
|
249
254
|
if (a) {
|
|
250
|
-
const
|
|
251
|
-
|
|
255
|
+
const l = u(h, a);
|
|
256
|
+
r[a] = t(
|
|
252
257
|
{
|
|
253
258
|
type: "row",
|
|
254
259
|
style: { height: "100%" },
|
|
255
260
|
children: [
|
|
256
261
|
{
|
|
257
|
-
...
|
|
258
|
-
children:
|
|
262
|
+
...d,
|
|
263
|
+
children: l
|
|
259
264
|
},
|
|
260
265
|
f,
|
|
261
|
-
|
|
266
|
+
b
|
|
262
267
|
]
|
|
263
268
|
},
|
|
264
|
-
|
|
269
|
+
l,
|
|
265
270
|
a
|
|
266
271
|
);
|
|
267
272
|
}
|
|
268
|
-
if (
|
|
269
|
-
const
|
|
273
|
+
if (o) {
|
|
274
|
+
const l = {
|
|
270
275
|
placer: { type: "absolute", position: "left" },
|
|
271
276
|
style: { height: "calc(100% - 40px)" }
|
|
272
|
-
},
|
|
273
|
-
|
|
277
|
+
}, c = h.map((i) => ({ ...i, layoutCommand: l })), n = u(c, o, { layoutCommand: l });
|
|
278
|
+
r[o] = t(
|
|
274
279
|
{
|
|
275
280
|
type: "column",
|
|
276
281
|
style: { height: "100%" },
|
|
@@ -280,59 +285,59 @@ const O = "sidebarButtonsTarget", R = (e, a) => {
|
|
|
280
285
|
{
|
|
281
286
|
type: "sidebarBottom",
|
|
282
287
|
style: { padding: "0 5px", alignItems: "center", gap: 10, minHeight: 39 },
|
|
283
|
-
children:
|
|
288
|
+
children: n
|
|
284
289
|
}
|
|
285
290
|
]
|
|
286
291
|
},
|
|
287
|
-
|
|
288
|
-
|
|
292
|
+
n,
|
|
293
|
+
o
|
|
289
294
|
);
|
|
290
295
|
}
|
|
291
|
-
const
|
|
296
|
+
const P = u(s, 0);
|
|
292
297
|
return {
|
|
293
|
-
default:
|
|
298
|
+
default: t(
|
|
294
299
|
{
|
|
295
300
|
type: "row",
|
|
296
301
|
style: { height: "100%" },
|
|
297
302
|
children: [
|
|
298
303
|
{
|
|
299
|
-
...
|
|
300
|
-
children:
|
|
304
|
+
...d,
|
|
305
|
+
children: P
|
|
301
306
|
},
|
|
302
307
|
f,
|
|
303
|
-
|
|
308
|
+
b,
|
|
304
309
|
{ type: "sidebarRight" }
|
|
305
310
|
]
|
|
306
311
|
},
|
|
307
|
-
|
|
312
|
+
P,
|
|
308
313
|
0
|
|
309
314
|
),
|
|
310
|
-
responsive:
|
|
315
|
+
responsive: r
|
|
311
316
|
};
|
|
312
|
-
},
|
|
313
|
-
const { Commands:
|
|
317
|
+
}, R = "layoutSidebarButtons", C = A.free, J = function(e, a = {}) {
|
|
318
|
+
const { Commands: o } = e, r = o.events, s = {
|
|
314
319
|
...a
|
|
315
320
|
};
|
|
316
321
|
(() => {
|
|
317
|
-
if (e.runCommand(
|
|
318
|
-
const
|
|
319
|
-
e.runCommand(
|
|
320
|
-
})(),
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
}), e.on(`${
|
|
322
|
+
if (e.runCommand(B.layoutConfigGet) || s.skipLayoutConfig === !0) return;
|
|
323
|
+
const d = $(s);
|
|
324
|
+
e.runCommand(B.layoutConfigSet, { ...d });
|
|
325
|
+
})(), o.add(`${R}:toggleButton`, (f, d, b) => {
|
|
326
|
+
const g = document.getElementById(U(b == null ? void 0 : b.id));
|
|
327
|
+
g == null || g.click();
|
|
328
|
+
}), e.on(`${r.runCommand}core:preview`, () => {
|
|
324
329
|
N(e);
|
|
325
|
-
}),
|
|
330
|
+
}), Z({
|
|
326
331
|
editor: e,
|
|
327
|
-
licenseKey:
|
|
328
|
-
plan:
|
|
329
|
-
pluginName:
|
|
332
|
+
licenseKey: s.licenseKey,
|
|
333
|
+
plan: C,
|
|
334
|
+
pluginName: R,
|
|
330
335
|
cleanup: () => {
|
|
331
|
-
e.runCommand(
|
|
336
|
+
e.runCommand(B.layoutConfigSet);
|
|
332
337
|
}
|
|
333
338
|
});
|
|
334
|
-
}, Q =
|
|
335
|
-
Q.createLayoutConfig = (e) =>
|
|
339
|
+
}, Q = q(J);
|
|
340
|
+
Q.createLayoutConfig = (e) => $(e);
|
|
336
341
|
export {
|
|
337
342
|
Q as default
|
|
338
343
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_layoutSidebarButtons=v())})(this,function(){"use strict";var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(v||{}),D=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(D||{});const G="app.grapesjs.com",M="app-stage.grapesjs.com",I=[G,"app2.grapesjs.com",M,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",H="license:check:end",j=()=>typeof window<"u",C=({isDev:e,isStage:o})=>`${e?"":`https://${o?M:G}`}/api`,W=()=>{const e=j()&&window.location.hostname;return!!e&&(I.includes(e)||I.some(o=>e.endsWith(o)))};async function m({path:e,baseApiUrl:o,method:n="GET",headers:i={},params:c,body:p}){const b=`${o||C({isDev:!1,isStage:!1})}${e}`,g={method:n,headers:{"Content-Type":"application/json",...i}};p&&(g.body=JSON.stringify(p));const d=c?new URLSearchParams(c).toString():"",t=d?`?${d}`:"",r=await fetch(`${b}${t}`,g);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const x={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function K(e){const o=e;return o.init=n=>i=>e(i,n),o}const V=e=>K(e);async function F({editor:e,plan:o,pluginName:n,licenseKey:i,cleanup:c}){let p="",f=!1;const b=W(),g=t=>{console.warn("Cleanup plugin:",n,"Reason:",t),c()},d=(t={})=>{var a;const{error:r,sdkLicense:A}=t,s=(a=t.plan)==null?void 0:a.category;if(!(A||t.license)||r)g(r||"Invalid license");else if(s){const l=x[o],y=x[s];l>y&&g({pluginRequiredPlan:o,licensePlan:s})}};e.on($,t=>{p=t==null?void 0:t.baseApiUrl,f=!0}),e.on(H,t=>{d(t)}),setTimeout(async()=>{if(!f){if(b)return;if(i){const t=await q({licenseKey:i,pluginName:n,baseApiUrl:p});t&&d(t)}else g("The `licenseKey` option not provided")}},2e3)}async function q(e){const{licenseKey:o,pluginName:n,baseApiUrl:i}=e;try{return(await m({baseApiUrl:i,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(c){return console.error("Error during SDK license check:",c),!1}}var T=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e.panelDataSources="panelDataSources",e))(T||{});const O="sidebarButtonsTarget",R=(e,o)=>{const{id:n,icon:i,label:c,tooltip:p,className:f,skipSelfClose:b,removeLayouts:g,layoutComponent:d,layoutCommand:t}=e,{pluginOpts:r,breakpointProps:A}=o,s=n;return{id:E(n),type:"button",icon:i,tooltip:c||p,className:f,editorEvents:{[`${D.layoutToggleId}${s}`]:({fromEvent:u,setState:a,editor:l})=>{a({active:u.isOpen}),setTimeout(()=>l.refresh({tools:!0}),20)}},onClick:({editor:u,state:a})=>{var k;if(a.active&&b)return;const l=(t==null?void 0:t.placer)||{type:"static",layoutId:O},y={...l,skipCleanup:l.type==="static"},L=g||Object.keys(T).filter(w=>w!==s);N(u,{removeLayouts:L,layout:{placer:y}});const B={id:s,placer:l,header:(t==null?void 0:t.header)??{label:c,close:!b},layout:d,style:{width:280,height:"100%",borderRightWidth:1,...t==null?void 0:t.style}},P=((k=r==null?void 0:r.sidebarLayoutCommand)==null?void 0:k.call(r,{...A,layoutCommand:B,sidebarButtonProps:e}))||B;u.runCommand(v.layoutToggle,{...P})}}},E=e=>`button__${e}`,N=(e,o={})=>{(o.removeLayouts||Object.keys(T)).forEach(i=>e.runCommand(v.layoutRemove,{id:i,layout:o.layout}))},_=e=>{const o=(e==null?void 0:e.breakpointTablet)??1024,n=(e==null?void 0:e.breakpointMobile)??768,i={},c=[{id:T.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:T.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:T.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:T.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:s,editor:u})=>{var L;const a=u.getSelected(),l={type:"image",src:s.src};let y;if(a!=null&&a.is("image"))return a.set("src",s.src);a&&u.Components.canMove(a,l)?y=a.append(l)[0]:a||(y=(L=u.getWrapper())==null?void 0:L.append(l)[0]),y&&u.select(y,{scroll:!0})}}}],p=[...c,{id:T.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],f={id:O,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},b={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},g={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},d=s=>({breakpoint:s,breakpointTablet:o,breakpointMobile:n}),t=(s,u,a)=>{const l=d(u),y={pluginOpts:e,breakpointProps:l},L=s.map(P=>{const k=R(P,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:P.id,buttonIds:T,buttonProps:k,sidebarButtonProps:P,...l,createSidebarButton:w=>R({...P,...w},y)}):k}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:T,sidebarButtons:L,...l,createSidebarButton:P=>R({...P,layoutCommand:{...a==null?void 0:a.layoutCommand,...P.layoutCommand}},y)}):L).filter(Boolean)},r=(s,u,a)=>{var L;const l=d(a),y={pluginOpts:e,breakpointProps:l};return((L=e==null?void 0:e.rootLayout)==null?void 0:L.call(e,{sidebarButtons:u,rootLayout:s,layoutSidebarLeft:b,layoutSidebarTarget:f,...l,createSidebarButton:B=>R({...B},y)}))??s};if(o){const s=t(p,o);i[o]=r({type:"row",style:{height:"100%"},children:[{...b,children:s},f,g]},s,o)}if(n){const s={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},u=p.map(l=>({...l,layoutCommand:s})),a=t(u,n,{layoutCommand:s});i[n]=r({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:a}]},a,n)}const A=t(c,0);return{default:r({type:"row",style:{height:"100%"},children:[{...b,children:A},f,g,{type:"sidebarRight"}]},A,0),responsive:i}},S="layoutSidebarButtons",Z=h.free,U=V(function(e,o={}){const{Commands:n}=e,i=n.events,c={...o};(()=>{if(e.runCommand(v.layoutConfigGet)||c.skipLayoutConfig===!0)return;const b=_(c);e.runCommand(v.layoutConfigSet,{...b})})(),n.add(`${S}:toggleButton`,(f,b,g)=>{const d=document.getElementById(E(g==null?void 0:g.id));d==null||d.click()}),e.on(`${i.runCommand}core:preview`,()=>{N(e)}),F({editor:e,licenseKey:c.licenseKey,plan:Z,pluginName:S,cleanup:()=>{e.runCommand(v.layoutConfigSet)}})});return U.createLayoutConfig=e=>_(e),U});
|
|
1
|
+
(function(h,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_layoutSidebarButtons=v())})(this,function(){"use strict";var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(v||{}),M=(e=>(e.layoutToggleId="studio:layoutToggle:",e.toggleBlocksPanel="studio:toggleBlocksPanel",e.pageSettingsUpdate="studio:pageSettingsUpdate",e.toggleDataSourcesPreview="studio:toggleDataSourcesPreview",e))(M||{});const k="app.grapesjs.com",R="app-stage.grapesjs.com",I=[k,"app2.grapesjs.com",R,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],$="license:check:start",H="license:check:end",j=()=>typeof window<"u",W=({isDev:e,isStage:a,isPlatform:o})=>`${e?"":`https://${a?R:k}`}/${o?"platform-api":"api"}`,m=()=>{const e=j()&&window.location.hostname;return!!e&&(I.includes(e)||I.some(a=>e.endsWith(a)))};async function K({path:e,baseApiUrl:a,method:o="GET",headers:r={},params:s,body:P}){const d=`${a||W({isDev:!1,isStage:!1})}${e}`,b={method:o,headers:{"Content-Type":"application/json",...r}};P&&(b.body=JSON.stringify(P));const g=s?new URLSearchParams(s).toString():"",u=g?`?${g}`:"",t=await fetch(`${d}${u}`,b);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}const x={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function V(e){const a=e;return a.init=o=>r=>e(r,o),a}const F=e=>V(e);async function q({editor:e,plan:a,pluginName:o,licenseKey:r,onLicenseCheckResponse:s,cleanup:P}){let f="",d=!1;const b=m(),g=t=>{console.warn("Cleanup plugin:",o,"Reason:",t),P()},u=(t={})=>{var i;const{error:B,sdkLicense:l}=t,c=(i=t.plan)==null?void 0:i.category;if(!(l||t.license)||B)g(B||"Invalid license");else if(c){const y=x[a],p=x[c];y>p&&g({pluginRequiredPlan:a,licensePlan:c})}};e.on($,t=>{f=t==null?void 0:t.baseApiUrl,d=!0}),e.on(H,t=>{s==null||s(t),u(t)}),setTimeout(async()=>{if(!d){if(b)return;if(r){const t=await Z({licenseKey:r,pluginName:o,baseApiUrl:f});s==null||s(t),t&&u(t)}else g("The `licenseKey` option not provided")}},2e3)}async function Z(e){const{licenseKey:a,pluginName:o,baseApiUrl:r}=e;try{return(await K({baseApiUrl:r,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var T=(e=>(e.panelBlocks="panelBlocks",e.panelPagesLayers="panelPagesLayers",e.panelGlobalStyles="panelGlobalStyles",e.panelSidebarTabs="panelSidebarTabs",e.panelAssets="panelAssets",e.aiChatPanel="aiChatPanel",e.panelDataSources="panelDataSources",e))(T||{});const O="sidebarButtonsTarget",D=(e,a)=>{const{id:o,icon:r,label:s,tooltip:P,className:f,skipSelfClose:d,removeLayouts:b,layoutComponent:g,layoutCommand:u}=e,{pluginOpts:t,breakpointProps:B}=a,l=o;return{id:E(o),type:"button",icon:r,tooltip:s||P,className:f,editorEvents:{[`${M.layoutToggleId}${l}`]:({fromEvent:c,setState:n,editor:i})=>{n({active:c.isOpen}),setTimeout(()=>i.refresh({tools:!0}),20)}},onClick:({editor:c,state:n})=>{var w;if(n.active&&d)return;const i=(u==null?void 0:u.placer)||{type:"static",layoutId:O},y={...i,skipCleanup:i.type==="static"},p=b||Object.keys(T).filter(G=>G!==l);N(c,{removeLayouts:p,layout:{placer:y}});const L={id:l,placer:i,header:(u==null?void 0:u.header)??{label:s,close:!d},layout:g,style:{width:280,height:"100%",borderRightWidth:1,...u==null?void 0:u.style}},A=((w=t==null?void 0:t.sidebarLayoutCommand)==null?void 0:w.call(t,{...B,layoutCommand:L,sidebarButtonProps:e}))||L;c.runCommand(v.layoutToggle,{...A})}}},E=e=>`button__${e}`,N=(e,a={})=>{(a.removeLayouts||Object.keys(T)).forEach(r=>e.runCommand(v.layoutRemove,{id:r,layout:a.layout}))},_=e=>{const a=(e==null?void 0:e.breakpointTablet)??1024,o=(e==null?void 0:e.breakpointMobile)??768,r={},s=[{id:T.panelBlocks,icon:"plusBox",label:"Blocks",layoutComponent:{type:"panelBlocks"}},{id:T.panelPagesLayers,icon:"layers",label:"Pages & Layers",layoutComponent:{type:"panelPagesLayers"}},{id:T.panelGlobalStyles,icon:'<svg viewBox="0 0 24 24"> <path d="M20 14H6c-2.2 0-4 1.8-4 4s1.8 4 4 4h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M6 20c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m.3-8L13 5.3a2 2 0 0 1 2.8 0l2.8 2.8c.8.8.8 2 0 2.8l-.9 1.1H6.3M2 13.5V4c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1.5l-8 8Z"/></svg>',label:"Global Styles",layoutComponent:{type:"panelGlobalStyles"}},{id:T.panelAssets,icon:'<svg viewBox="0 0 24 24"><path d="M22,16V4A2,2 0 0,0 20,2H8A2,2 0 0,0 6,4V16A2,2 0 0,0 8,18H20A2,2 0 0,0 22,16M11,12L13.03,14.71L16,11L20,16H8M2,6V20A2,2 0 0,0 4,22H18V20H4V6" /></svg>',label:"Assets",layoutComponent:{type:"panelAssets",content:{itemsPerRow:2,header:{addUrl:!1}},style:{padding:7},onSelect:({assetProps:l,editor:c})=>{var p;const n=c.getSelected(),i={type:"image",src:l.src};let y;if(n!=null&&n.is("image"))return n.set("src",l.src);n&&c.Components.canMove(n,i)?y=n.append(i)[0]:n||(y=(p=c.getWrapper())==null?void 0:p.append(i)[0]),y&&c.select(y,{scroll:!0})}}}],P=[...s,{id:T.panelSidebarTabs,layoutCommand:{header:!1},icon:'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 0 1-1.5-1.5A1.5 1.5 0 0 1 17.5 9a1.5 1.5 0 0 1 1.5 1.5 1.5 1.5 0 0 1-1.5 1.5m-3-4A1.5 1.5 0 0 1 13 6.5 1.5 1.5 0 0 1 14.5 5 1.5 1.5 0 0 1 16 6.5 1.5 1.5 0 0 1 14.5 8m-5 0A1.5 1.5 0 0 1 8 6.5 1.5 1.5 0 0 1 9.5 5 1.5 1.5 0 0 1 11 6.5 1.5 1.5 0 0 1 9.5 8m-3 4A1.5 1.5 0 0 1 5 10.5 1.5 1.5 0 0 1 6.5 9 1.5 1.5 0 0 1 8 10.5 1.5 1.5 0 0 1 6.5 12M12 3a9 9 0 0 0-9 9 9 9 0 0 0 9 9 1.5 1.5 0 0 0 1.5-1.5c0-.4-.2-.7-.4-1-.2-.3-.4-.6-.4-1a1.5 1.5 0 0 1 1.5-1.5H16a5 5 0 0 0 5-5c0-4.4-4-8-9-8Z"/></svg>',label:"Styles & Props",layoutComponent:{type:"panelSidebarTabs"}}],f={id:O,type:"column",className:"gs-cmp-layout-sidebar-target",style:{overflow:"hidden"}},d={type:"sidebarLeft",resizable:!1,style:{padding:"10px 5px",alignItems:"center",width:45,gap:10},children:[]},b={type:"canvasSidebarTop",sidebarTop:{leftContainer:{buttons:[]}}},g=l=>({breakpoint:l,breakpointTablet:a,breakpointMobile:o}),u=(l,c,n)=>{const i=g(c),y={pluginOpts:e,breakpointProps:i},p=l.map(A=>{const w=D(A,y);return e!=null&&e.sidebarButton?e.sidebarButton({id:A.id,buttonIds:T,buttonProps:w,sidebarButtonProps:A,...i,createSidebarButton:G=>D({...A,...G},y)}):w}).filter(Boolean);return(e!=null&&e.sidebarButtons?e==null?void 0:e.sidebarButtons({buttonIds:T,sidebarButtons:p,...i,createSidebarButton:A=>D({...A,layoutCommand:{...n==null?void 0:n.layoutCommand,...A.layoutCommand}},y)}):p).filter(Boolean)},t=(l,c,n)=>{var p;const i=g(n),y={pluginOpts:e,breakpointProps:i};return((p=e==null?void 0:e.rootLayout)==null?void 0:p.call(e,{sidebarButtons:c,rootLayout:l,layoutSidebarLeft:d,layoutSidebarTarget:f,...i,createSidebarButton:L=>D({...L},y)}))??l};if(a){const l=u(P,a);r[a]=t({type:"row",style:{height:"100%"},children:[{...d,children:l},f,b]},l,a)}if(o){const l={placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}},c=P.map(i=>({...i,layoutCommand:l})),n=u(c,o,{layoutCommand:l});r[o]=t({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas",grow:!0},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:n}]},n,o)}const B=u(s,0);return{default:t({type:"row",style:{height:"100%"},children:[{...d,children:B},f,b,{type:"sidebarRight"}]},B,0),responsive:r}},S="layoutSidebarButtons",z=h.free,U=F(function(e,a={}){const{Commands:o}=e,r=o.events,s={...a};(()=>{if(e.runCommand(v.layoutConfigGet)||s.skipLayoutConfig===!0)return;const d=_(s);e.runCommand(v.layoutConfigSet,{...d})})(),o.add(`${S}:toggleButton`,(f,d,b)=>{const g=document.getElementById(E(b==null?void 0:b.id));g==null||g.click()}),e.on(`${r.runCommand}core:preview`,()=>{N(e)}),q({editor:e,licenseKey:s.licenseKey,plan:z,pluginName:S,cleanup:()=>{e.runCommand(v.layoutConfigSet)}})});return U.createLayoutConfig=e=>_(e),U});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const ie="app.grapesjs.com",re="app-stage.grapesjs.com",ue="app2.grapesjs.com",he="app-stage2.grapesjs.com",Y=[ie,ue,re,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ge="license:check:start",be="license:check:end",me=()=>typeof window<"u",de=({isDev:e,isStage:l})=>`${e?"":`https://${l?re:ie}`}/api`,ye=()=>{const e=me()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function ve({path:e,baseApiUrl:l,method:a="GET",headers:n={},params:s,body:u}){const p=`${l||de({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 fe(e){const l=e;return l.init=a=>n=>e(n,a),l}const Te=e=>fe(e);async function we({editor:e,plan:l,pluginName:a,licenseKey:n,cleanup:s}){let u="",r=!1;const p=ye(),h=i=>{console.warn("Cleanup plugin:",a,"Reason:",i),s()},c=(i={})=>{var A;const{error:b,sdkLicense:G}=i,T=(A=i.plan)==null?void 0:A.category;if(!(G||i.license)||b)h(b||"Invalid license");else if(T){const C=ee[l],V=ee[T];C>V&&h({pluginRequiredPlan:l,licensePlan:T})}};e.on(ge,i=>{u=i==null?void 0:i.baseApiUrl,r=!0}),e.on(be,i=>{c(i)}),setTimeout(async()=>{if(!r){if(p)return;if(n){const i=await Se({licenseKey:n,pluginName:a,baseApiUrl:u});i&&c(i)}else h("The `licenseKey` option not provided")}},2e3)}async function Se(e){const{licenseKey:l,pluginName:a,baseApiUrl:n}=e;try{return(await ve({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))},xe="lightGalleryComponent",Ie=E.startup;var P=(e=>(e.image="image",e.video="video",e.external="external",e))(P||{});const I="lightGallery",te=`${I}-item`,K="data-lightgallery",ae=`${K}-item`,U="toggle",k={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:[]},_=(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)})},ke=(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)},Ae={[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}},Le={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"}]}}},Pe={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ee={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",N="data-iframe",R={name:"href",type:"file",label:"Image Source"},j={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},Ge={[U]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var s,u;const a=l.target,n=(s=a==null?void 0:a.closestType(I))==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:[j,F],external:[ne]},options:[{id:"image",label:R.label||"",icon:k.image},{id:"video",label:j.label||"",icon:k.video},{id:"external",label:ne.label||"",icon:k.external}]},subHtml:ce},le="lgThumbnail",Ce="lgVideo",oe="lgAutoplay",se="lgZoom",L="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Ve=function(e,l={}){const{Blocks:a,Components:n}=e,s="LightGallery",u="LightGallery Item",r={toolbarIconOpen:k.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[le,Ce,oe,se],cdnScript:[`${L}/lightgallery.min.js`,`${L}/plugins/thumbnail/lg-thumbnail.min.js`,`${L}/plugins/video/lg-video.min.js`,`${L}/plugins/autoplay/lg-autoplay.min.js`,`${L}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${L}/css/lightgallery-bundle.min.css`,...l},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,i=function(t){const o=this,g=window,{plugins:d,cdnScript:w,cdnStyle:O,inline:J,lgLicenseKey:pe,...y}=t||{},S=m=>isNaN(m)?void 0:parseInt(m,10),Q=()=>{var $;const m={...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:(d||[]).map(D=>g[D])};J&&(m.container=o,m.closable=!1);const H=($=g.lightGallery)==null?void 0:$.call(g,o,m);J&&H.openGallery()};if(g.lightGallery)Q();else{const{head:m}=document,H=Array.isArray(w)?[...w]:[w],$=Array.isArray(O)?[...O]:[O],D=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",m.appendChild(v),D(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),m.appendChild(v)}else Q()};D($),X(H)}},b=t=>{const o=t.getTrait(U);if(!h||!o)return;const{toolbar:g}=t,d={id:U,label:h,command:()=>setTimeout(()=>o.runCommand(),100)};!g.find(O=>O.id===d.id)&&(g==null||g.unshift(d))};let G=[];const T=r.plugins||[],M=_(Ae),A=T.includes(le)?_(Le):B,C=T.includes(oe)?_(Pe):B,V=T.includes(se)?_(Ee):B;n.addType(I,{block:p&&{label:s,media:k.gallery,category:"Extra",select:!0,...r.block},isComponent:t=>z(t,K),extendFn:["init","initToolbar"],model:{defaults:{name:s,icon:k.gallery,draggable:(t,o)=>!o.is(I),attributes:{[K]:!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",...M.propKeys,...A.propKeys,...C.propKeys,...V.propKeys],...M.props,...A.props,...C.props,...V.props,traits:[...M.traits,...A.traits,...C.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();G=o.getSpots(),setTimeout(()=>o.removeSpots()),g.__lgOpened=!0},onLgClose(){const t=this.getLightGallery();G.forEach(o=>this.em.Canvas.addSpot(o.attributes)),G=[],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=_(Ge);n.addType(te,{isComponent:t=>z(t,ae)||t.tagName==="A"&&z(t.parentElement,K),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:k.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(),ke(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(I))==null||o.__scriptPropsChange(...t)},updateTraits(t={}){const{changed:o}=this,{init:g}=t;if(o[f]||g){Z(this,f);const d=this.getTrait(f).getValue();if(d===P.image){this.removeAttributes([j.name,F.name,N]);const w=this.getTrait(R.name);w.setValue(w.getValue()||c)}else d===P.video?this.removeAttributes([N]):d===P.external&&this.addAttributes({[N]:!0})}},initSourceType(){const t=this.getAttributes({noClass:!0,noStyle:!0});t[N]?this.set(f,P.external):(t[j.name]||t[F.name])&&this.set(f,P.video)}}}),we({editor:e,plan:Ie,licenseKey:r.licenseKey,pluginName:xe,cleanup:()=>{a.remove(I),n.removeType(I)}})},Oe=Te(Ve);module.exports=Oe;
|
|
1
|
+
"use strict";const se="app.grapesjs.com",re="app-stage.grapesjs.com",ue="app2.grapesjs.com",he="app-stage2.grapesjs.com",Y=[se,ue,re,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ge="license:check:start",be="license:check:end",me=()=>typeof window<"u",de=({isDev:e,isStage:n,isPlatform:t})=>`${e?"":`https://${n?re:se}`}/${t?"platform-api":"api"}`,ye=()=>{const e=me()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(n=>e.endsWith(n)))};async function ve({path:e,baseApiUrl:n,method:t="GET",headers:l={},params:o,body:u}){const p=`${n||de({isDev:!1,isStage:!1})}${e}`,h={method:t,headers:{"Content-Type":"application/json",...l}};u&&(h.body=JSON.stringify(u));const c=o?new URLSearchParams(o).toString():"",b=c?`?${c}`:"",s=await fetch(`${p}${b}`,h);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var G=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(G||{});const ee={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function fe(e){const n=e;return n.init=t=>l=>e(l,t),n}const Te=e=>fe(e);async function we({editor:e,plan:n,pluginName:t,licenseKey:l,onLicenseCheckResponse:o,cleanup:u}){let r="",p=!1;const h=ye(),c=s=>{console.warn("Cleanup plugin:",t,"Reason:",s),u()},b=(s={})=>{var k;const{error:P,sdkLicense:V}=s,T=(k=s.plan)==null?void 0:k.category;if(!(V||s.license)||P)c(P||"Invalid license");else if(T){const O=ee[n],$=ee[T];O>$&&c({pluginRequiredPlan:n,licensePlan:T})}};e.on(ge,s=>{r=s==null?void 0:s.baseApiUrl,p=!0}),e.on(be,s=>{o==null||o(s),b(s)}),setTimeout(async()=>{if(!p){if(h)return;if(l){const s=await Se({licenseKey:l,pluginName:t,baseApiUrl:r});o==null||o(s),s&&b(s)}else c("The `licenseKey` option not provided")}},2e3)}async function Se(e){const{licenseKey:n,pluginName:t,baseApiUrl:l}=e;try{return(await ve({baseApiUrl:l,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const B=(e,n)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,n))},xe="lightGalleryComponent",Ie=G.startup;var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const I="lightGallery",te=`${I}-item`,U="data-lightgallery",ae=`${U}-item`,j="toggle",A={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>'},W={propKeys:[],props:{},traits:[]},_=(e,n={})=>{var o;const t={},l=[];for(const u in e){const{value:r,...p}=e[u];l.push({id:u,name:u,changeProp:!0,category:n.category,...p}),t[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(o=h[c])==null||o.forEach(b=>{const s=b.id||b.name;t[s]=b.value})}return{propKeys:Object.keys(t),props:t,traits:l}},F=(e,n)=>{const t=e.getTrait(n),l=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=o[t.getValue()],h=e.getTraitIndex(n)+1;p&&e.addTrait(p.map(c=>({category:l,...c})),{at:h})},Z=(e,n)=>{n.forEach(t=>{const l=e.getTrait(t);if(!l||!l.get("subTraits"))return;const o=l.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(o,()=>F(e,t)),F(e,t)})},Ae=(e,n,t)=>{const o=e.getTrait(n).get("subTraits")||{},r=(Object.values(o).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(" "),t)},Pe={[j]:{type:"button",label:"Toggle Gallery",command:(e,n)=>{var t,l;return(l=(t=n.target)==null?void 0:t.getView())==null?void 0:l.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},ke={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Le={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ee={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},f="sourceType",K="data-iframe",q={name:"href",type:"file",label:"Image Source"},H={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},J={name:"data-poster",label:"Video Poster",type:"file"},le={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Ge={[j]:{type:"button",label:"Toggle Gallery",command:(e,n)=>{var o,u;const t=n.target,l=(o=t==null?void 0:t.closestType(I))==null?void 0:o.getView();if(l&&t){const r=((u=l.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(t.getEl());p>=0&&l.toggleGallery(p)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[q],video:[H,J],external:[le]},options:[{id:"image",label:q.label||"",icon:A.image},{id:"video",label:H.label||"",icon:A.video},{id:"external",label:le.label||"",icon:A.external}]},subHtml:ce},ne="lgThumbnail",Ve="lgVideo",oe="lgAutoplay",ie="lgZoom",L="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Oe=function(e,n={}){const{Blocks:t,Components:l}=e,o="LightGallery",u="LightGallery Item",r={toolbarIconOpen:A.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ne,Ve,oe,ie],cdnScript:[`${L}/lightgallery.min.js`,`${L}/plugins/thumbnail/lg-thumbnail.min.js`,`${L}/plugins/video/lg-video.min.js`,`${L}/plugins/autoplay/lg-autoplay.min.js`,`${L}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${L}/css/lightgallery-bundle.min.css`,...n},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,b=function(a){const i=this,g=window,{plugins:d,cdnScript:w,cdnStyle:C,inline:R,lgLicenseKey:pe,...y}=a||{},S=m=>isNaN(m)?void 0:parseInt(m,10),Q=()=>{var D;const m={...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:(d||[]).map(N=>g[N])};R&&(m.container=i,m.closable=!1);const z=(D=g.lightGallery)==null?void 0:D.call(g,i,m);R&&z.openGallery()};if(g.lightGallery)Q();else{const{head:m}=document,z=Array.isArray(w)?[...w]:[w],D=Array.isArray(C)?[...C]:[C],N=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",m.appendChild(v),N(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),m.appendChild(v)}else Q()};N(D),X(z)}},s=a=>{const i=a.getTrait(j);if(!h||!i)return;const{toolbar:g}=a,d={id:j,label:h,command:()=>setTimeout(()=>i.runCommand(),100)};!g.find(C=>C.id===d.id)&&(g==null||g.unshift(d))};let P=[];const V=r.plugins||[],T=_(Pe),M=V.includes(ne)?_(ke):W,k=V.includes(oe)?_(Le):W,O=V.includes(ie)?_(Ee):W;l.addType(I,{block:p&&{label:o,media:A.gallery,category:"Extra",select:!0,...r.block},isComponent:a=>B(a,U),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:A.gallery,draggable:(a,i)=>!i.is(I),attributes:{[U]:!0},components:{type:te},script:b,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...T.propKeys,...M.propKeys,...k.propKeys,...O.propKeys],...T.props,...M.props,...k.props,...O.props,traits:[...T.traits,...M.traits,...k.traits,...O.traits]},init(){Z(this,["thumbnail"]),Z(this,["autoplay"]),Z(this,["zoom"])},initToolbar(){s(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,l.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var i;const a=this.getLightGallery();return((i=a==null?void 0:a.settings)==null?void 0:i.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:i}=a,g=this.getLightGallery();P=i.getSpots(),setTimeout(()=>i.removeSpots()),g.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();P.forEach(i=>this.em.Canvas.addSpot(i.attributes)),P=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const i=this.getLightGallery();if(i.__lgOpened)return i.closeGallery(!0);i.lgOpened=!1,i.openGallery(a)}}});const $=_(Ge);l.addType(te,{isComponent:a=>B(a,ae)||a.tagName==="A"&&B(a.parentElement,U),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:A.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...$.props,traits:[...$.traits]},init(){const a=[f].map(i=>`change:${i}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ae(this,f,this.triggerGalleryUpdate)},initToolbar(){s(this)},initScriptUpdate(){const a=[ce.name].map(i=>`change:attributes:${i}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var i;(i=this.closestType(I))==null||i.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:i}=this,{init:g}=a;if(i[f]||g){F(this,f);const d=this.getTrait(f).getValue();if(d===E.image){this.removeAttributes([H.name,J.name,K]);const w=this.getTrait(q.name);w.setValue(w.getValue()||c)}else d===E.video?this.removeAttributes([K]):d===E.external&&this.addAttributes({[K]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[K]?this.set(f,E.external):(a[H.name]||a[J.name])&&this.set(f,E.video)}}}),we({editor:e,plan:Ie,licenseKey:r.licenseKey,pluginName:xe,cleanup:()=>{t.remove(I),l.removeType(I)}})},Ce=Te(Oe);module.exports=Ce;
|