@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
B,
|
|
1
|
+
const N = "app.grapesjs.com", S = "app-stage.grapesjs.com", U = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", V = [
|
|
2
|
+
N,
|
|
4
3
|
U,
|
|
5
|
-
|
|
4
|
+
S,
|
|
5
|
+
H,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,254 +11,267 @@ const k = "app.grapesjs.com", U = "app-stage.grapesjs.com", B = "app2.grapesjs.c
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
isDev:
|
|
16
|
-
isStage:
|
|
17
|
-
isPlatform:
|
|
18
|
-
}) => `${
|
|
19
|
-
const
|
|
20
|
-
return !!
|
|
14
|
+
], F = "license:check:end", W = () => typeof window < "u", K = ({
|
|
15
|
+
isDev: e,
|
|
16
|
+
isStage: n,
|
|
17
|
+
isPlatform: c
|
|
18
|
+
}) => `${e ? "" : `https://${n ? S : N}`}/${c ? "platform-api" : "api"}`, Z = () => {
|
|
19
|
+
const e = W() && window.location.hostname;
|
|
20
|
+
return !!e && (V.includes(e) || V.some((n) => e.endsWith(n)));
|
|
21
21
|
};
|
|
22
22
|
async function q({
|
|
23
|
-
path:
|
|
24
|
-
baseApiUrl:
|
|
25
|
-
method:
|
|
23
|
+
path: e,
|
|
24
|
+
baseApiUrl: n,
|
|
25
|
+
method: c = "GET",
|
|
26
26
|
headers: l = {},
|
|
27
|
-
params:
|
|
28
|
-
body:
|
|
27
|
+
params: r,
|
|
28
|
+
body: f
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
31
|
-
method:
|
|
30
|
+
const g = `${n || K({ isDev: !1, isStage: !1 })}${e}`, u = {
|
|
31
|
+
method: c,
|
|
32
32
|
headers: {
|
|
33
33
|
"Content-Type": "application/json",
|
|
34
34
|
...l
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
throw new Error(`HTTP error! status: ${
|
|
41
|
-
return
|
|
37
|
+
f && (u.body = JSON.stringify(f));
|
|
38
|
+
const y = r ? new URLSearchParams(r).toString() : "", v = y ? `?${y}` : "", s = await fetch(`${g}${v}`, u);
|
|
39
|
+
if (!s.ok)
|
|
40
|
+
throw new Error(`HTTP error! status: ${s.status}`);
|
|
41
|
+
return s.json();
|
|
42
42
|
}
|
|
43
|
-
var w = /* @__PURE__ */ ((
|
|
44
|
-
const
|
|
43
|
+
var w = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(w || {}), j = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(j || {});
|
|
44
|
+
const m = {
|
|
45
45
|
[w.free]: 0,
|
|
46
46
|
[w.startup]: 10,
|
|
47
47
|
[w.business]: 20,
|
|
48
48
|
[w.enterprise]: 30
|
|
49
49
|
};
|
|
50
|
-
function z(
|
|
51
|
-
const
|
|
52
|
-
return
|
|
50
|
+
function z(e) {
|
|
51
|
+
const n = e;
|
|
52
|
+
return n.init = (c) => (l) => e(l, c), n;
|
|
53
53
|
}
|
|
54
|
-
const J = (
|
|
55
|
-
async function
|
|
56
|
-
editor:
|
|
57
|
-
plan:
|
|
58
|
-
pluginName:
|
|
54
|
+
const J = (e) => /* @__PURE__ */ z(e);
|
|
55
|
+
async function X({
|
|
56
|
+
editor: e,
|
|
57
|
+
plan: n,
|
|
58
|
+
pluginName: c,
|
|
59
59
|
licenseKey: l,
|
|
60
|
-
onLicenseCheckResponse:
|
|
61
|
-
cleanup:
|
|
60
|
+
onLicenseCheckResponse: r,
|
|
61
|
+
cleanup: f
|
|
62
62
|
}) {
|
|
63
|
-
let h = "",
|
|
64
|
-
const
|
|
65
|
-
console.warn("Cleanup plugin:",
|
|
66
|
-
},
|
|
67
|
-
var
|
|
68
|
-
const { error: p, sdkLicense:
|
|
69
|
-
if (!(
|
|
70
|
-
|
|
71
|
-
else if (
|
|
72
|
-
const
|
|
73
|
-
|
|
63
|
+
let h = "", g;
|
|
64
|
+
const u = (s) => {
|
|
65
|
+
console.warn("Cleanup plugin:", c, "Reason:", s), f();
|
|
66
|
+
}, y = (s = {}) => {
|
|
67
|
+
var E;
|
|
68
|
+
const { error: p, sdkLicense: I } = s, T = (E = s.plan) == null ? void 0 : E.category;
|
|
69
|
+
if (!(I || s.license) || p)
|
|
70
|
+
u(p || "Invalid license");
|
|
71
|
+
else if (T) {
|
|
72
|
+
const O = m[n], t = m[T];
|
|
73
|
+
O > t && u({ pluginRequiredPlan: n, licensePlan: T });
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
76
|
+
e.Commands.has(j.settings) && (g = e.runCommand(j.settings), h = (g == null ? void 0 : g.baseUrl) || "");
|
|
77
|
+
const v = (s) => {
|
|
78
|
+
r == null || r(s), s && y(s);
|
|
79
|
+
};
|
|
80
|
+
if (!g) {
|
|
81
|
+
e.onReady(async () => {
|
|
82
|
+
if (!Z())
|
|
83
|
+
if (l) {
|
|
84
|
+
const s = await Q({ licenseKey: l, pluginName: c, baseApiUrl: h });
|
|
85
|
+
v(s);
|
|
86
|
+
} else
|
|
87
|
+
u("The `licenseKey` option not provided");
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (g.licensePlan || g.licenseError) {
|
|
92
|
+
const s = Y(g);
|
|
93
|
+
v(s);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
e.on(F, (s) => v(s));
|
|
90
97
|
}
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
const Y = (e) => ({
|
|
99
|
+
sdkLicense: e.license,
|
|
100
|
+
license: e.license,
|
|
101
|
+
error: e.licenseError,
|
|
102
|
+
plan: e.licensePlan
|
|
103
|
+
});
|
|
104
|
+
async function Q(e) {
|
|
105
|
+
const { licenseKey: n, pluginName: c, baseApiUrl: l } = e;
|
|
93
106
|
try {
|
|
94
107
|
return (await q({
|
|
95
108
|
baseApiUrl: l,
|
|
96
|
-
path: `/sdk/${
|
|
109
|
+
path: `/sdk/${n || "na"}`,
|
|
97
110
|
method: "POST",
|
|
98
111
|
params: {
|
|
99
112
|
d: window.location.hostname,
|
|
100
|
-
pn:
|
|
113
|
+
pn: c
|
|
101
114
|
}
|
|
102
115
|
})).result || {};
|
|
103
|
-
} catch (
|
|
104
|
-
return console.error("Error during SDK license check:",
|
|
116
|
+
} catch (r) {
|
|
117
|
+
return console.error("Error during SDK license check:", r), !1;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
|
-
const
|
|
120
|
+
const C = "gjs-plg-", ee = "fsLightboxComponent", te = w.startup, D = "data-fslightbox", G = "data-type", oe = "fslightbox-open", A = "fslightbox", P = {
|
|
108
121
|
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>',
|
|
109
122
|
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>',
|
|
110
123
|
imageLightbox: '<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>',
|
|
111
124
|
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>',
|
|
112
125
|
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>'
|
|
113
|
-
},
|
|
114
|
-
const { Blocks:
|
|
115
|
-
toolbarIconOpen:
|
|
126
|
+
}, se = function(e, n = {}) {
|
|
127
|
+
const { Blocks: c, Components: l } = e, r = "Lightbox", f = `${C}${A}`, h = {
|
|
128
|
+
toolbarIconOpen: P.eye,
|
|
116
129
|
block: {},
|
|
117
130
|
defaultSrc: "https://placehold.co/300/777/white.png?text=Image",
|
|
118
131
|
cdnScript: "https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",
|
|
119
|
-
...
|
|
120
|
-
}, { block:
|
|
121
|
-
const
|
|
122
|
-
var
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
if ((
|
|
127
|
-
Array.from(document.querySelectorAll(`[${
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
132
|
+
...n
|
|
133
|
+
}, { block: g, toolbarIconOpen: u, defaultSrc: y } = h, v = function(t) {
|
|
134
|
+
const o = this, a = "data-fslightbox", i = window, b = () => {
|
|
135
|
+
var B;
|
|
136
|
+
const d = i.refreshFsLightbox;
|
|
137
|
+
d == null || d();
|
|
138
|
+
const k = o.getAttribute(a);
|
|
139
|
+
if ((B = i.fsLightboxInstances) == null || B[k], !i._isEditor) return;
|
|
140
|
+
Array.from(document.querySelectorAll(`[${a}]`)).forEach((L) => {
|
|
141
|
+
const x = L.onclick;
|
|
142
|
+
L.onclick = function(_) {
|
|
143
|
+
_.preventDefault();
|
|
144
|
+
const $ = L;
|
|
145
|
+
!$.__skipLb && (x == null || x(_)), $.__skipLb = !0;
|
|
133
146
|
};
|
|
134
147
|
});
|
|
135
148
|
};
|
|
136
|
-
if (
|
|
137
|
-
|
|
149
|
+
if (i.refreshFsLightbox)
|
|
150
|
+
b();
|
|
138
151
|
else {
|
|
139
|
-
const
|
|
140
|
-
|
|
152
|
+
const d = document.createElement("script");
|
|
153
|
+
d.src = t.cdnScript, d.onload = b, document.head.appendChild(d);
|
|
141
154
|
}
|
|
142
|
-
},
|
|
143
|
-
id: `${
|
|
144
|
-
label:
|
|
155
|
+
}, s = (t) => ({
|
|
156
|
+
id: `${A}-open-lb`,
|
|
157
|
+
label: u,
|
|
145
158
|
command: () => {
|
|
146
|
-
const
|
|
147
|
-
|
|
159
|
+
const o = t.getView();
|
|
160
|
+
o == null || o.toggleLightbox();
|
|
148
161
|
}
|
|
149
|
-
}), p = "source-type",
|
|
162
|
+
}), p = "source-type", I = {
|
|
150
163
|
type: "radio",
|
|
151
164
|
name: p,
|
|
152
165
|
label: "Source type",
|
|
153
166
|
changeProp: !0,
|
|
154
167
|
options: [
|
|
155
|
-
{ id: "image", label: "Image", icon:
|
|
156
|
-
{ id: "video", label: "Video", icon:
|
|
157
|
-
{ id: "el", label: "Custom Element", icon:
|
|
168
|
+
{ id: "image", label: "Image", icon: P.image },
|
|
169
|
+
{ id: "video", label: "Video", icon: P.video },
|
|
170
|
+
{ id: "el", label: "Custom Element", icon: P.external }
|
|
158
171
|
],
|
|
159
172
|
// @ts-expect-error Studio related prop
|
|
160
173
|
labelToTitle: !0
|
|
161
|
-
},
|
|
174
|
+
}, T = {
|
|
162
175
|
id: "href-image",
|
|
163
176
|
name: "href",
|
|
164
177
|
type: "file",
|
|
165
178
|
label: "Source Image"
|
|
166
|
-
},
|
|
179
|
+
}, M = {
|
|
167
180
|
id: "href-video",
|
|
168
181
|
name: "href",
|
|
169
182
|
label: "Source Video",
|
|
170
183
|
placeholder: "https://www.youtube.com/watch?v=..."
|
|
171
|
-
},
|
|
184
|
+
}, E = {
|
|
172
185
|
id: "href-el",
|
|
173
186
|
name: "href",
|
|
174
187
|
label: "Source Element",
|
|
175
188
|
placeholder: "#custom-element-id"
|
|
176
|
-
},
|
|
177
|
-
image: [
|
|
178
|
-
video: [
|
|
179
|
-
el: [
|
|
189
|
+
}, O = {
|
|
190
|
+
image: [T],
|
|
191
|
+
video: [M],
|
|
192
|
+
el: [E]
|
|
180
193
|
};
|
|
181
|
-
l.addType(
|
|
182
|
-
block:
|
|
183
|
-
label:
|
|
184
|
-
media:
|
|
194
|
+
l.addType(A, {
|
|
195
|
+
block: g && {
|
|
196
|
+
label: r,
|
|
197
|
+
media: P.imageLightbox,
|
|
185
198
|
category: "Extra",
|
|
186
199
|
select: !0,
|
|
187
200
|
...h.block
|
|
188
201
|
},
|
|
189
202
|
isComponent: (t) => {
|
|
190
|
-
var
|
|
191
|
-
return (
|
|
203
|
+
var o;
|
|
204
|
+
return (o = t.hasAttribute) == null ? void 0 : o.call(t, D);
|
|
192
205
|
},
|
|
193
206
|
extendFn: ["initToolbar"],
|
|
194
207
|
model: {
|
|
195
208
|
defaults: {
|
|
196
209
|
tagName: "a",
|
|
197
|
-
name:
|
|
198
|
-
icon:
|
|
199
|
-
classes:
|
|
200
|
-
draggable: (t,
|
|
210
|
+
name: r,
|
|
211
|
+
icon: P.imageLightbox,
|
|
212
|
+
classes: f,
|
|
213
|
+
draggable: (t, o) => !o.is(A),
|
|
201
214
|
attributes: {
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
href:
|
|
215
|
+
[D]: "lightbox",
|
|
216
|
+
[G]: "image",
|
|
217
|
+
href: y
|
|
205
218
|
},
|
|
206
|
-
components: { type: "image", src:
|
|
219
|
+
components: { type: "image", src: y },
|
|
207
220
|
script: v,
|
|
208
221
|
cdnScript: h.cdnScript,
|
|
209
222
|
"script-props": ["attributes", "cdnScript"],
|
|
210
223
|
[p]: "image",
|
|
211
224
|
traits: [
|
|
212
|
-
|
|
225
|
+
I,
|
|
213
226
|
{
|
|
214
|
-
name:
|
|
227
|
+
name: D,
|
|
215
228
|
label: "Group name"
|
|
216
229
|
},
|
|
217
230
|
{
|
|
218
231
|
type: "button",
|
|
219
232
|
label: "Toggle Lightbox",
|
|
220
|
-
command(t,
|
|
221
|
-
var
|
|
222
|
-
const
|
|
223
|
-
|
|
233
|
+
command(t, o) {
|
|
234
|
+
var i;
|
|
235
|
+
const a = (i = o.target) == null ? void 0 : i.getView();
|
|
236
|
+
a == null || a.toggleLightbox();
|
|
224
237
|
}
|
|
225
238
|
}
|
|
226
239
|
],
|
|
227
240
|
styles: `
|
|
228
|
-
.${
|
|
241
|
+
.${f} {
|
|
229
242
|
display: inline-block;
|
|
230
243
|
padding: 10px;
|
|
231
244
|
}
|
|
232
245
|
`
|
|
233
246
|
},
|
|
234
247
|
init() {
|
|
235
|
-
const t = [p].map((
|
|
248
|
+
const t = [p].map((o) => `change:${o}`).join(" ");
|
|
236
249
|
this.on(t, this.updateTraits), this.on(`change:${p}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
|
|
237
250
|
},
|
|
238
|
-
onSourceTypeChange(t,
|
|
239
|
-
if (
|
|
240
|
-
const
|
|
241
|
-
this.addAttributes({ [
|
|
251
|
+
onSourceTypeChange(t, o, a) {
|
|
252
|
+
if (a.adjust) return;
|
|
253
|
+
const b = this.get(p) === "video" ? "video" : "image";
|
|
254
|
+
this.addAttributes({ [G]: b, href: "" });
|
|
242
255
|
},
|
|
243
256
|
adjustSourceType() {
|
|
244
|
-
const t = this.get(p),
|
|
257
|
+
const t = this.get(p), o = this.getAttributes().href || "", a = { adjust: !0 };
|
|
245
258
|
if (t === "video") {
|
|
246
|
-
const
|
|
247
|
-
this.addAttributes({ [
|
|
248
|
-
} else t !== "el" &&
|
|
259
|
+
const i = o.includes("youtube.com") ? "youtube" : "video";
|
|
260
|
+
this.addAttributes({ [G]: i }, a);
|
|
261
|
+
} else t !== "el" && o.startsWith("#") ? this.set(p, "el", a) : t === "image" && this.addAttributes({ [G]: "image" }, a);
|
|
249
262
|
},
|
|
250
263
|
updateTraits(t = {}) {
|
|
251
|
-
const { changed:
|
|
252
|
-
if (
|
|
253
|
-
this.removeTrait([
|
|
254
|
-
const
|
|
255
|
-
this.addTrait(
|
|
264
|
+
const { changed: o } = this, { init: a } = t;
|
|
265
|
+
if (o[I.name] || a) {
|
|
266
|
+
this.removeTrait([T.name, M.name, E.name]);
|
|
267
|
+
const i = this.get(p) || "image", b = this.getTraitIndex(p) + 1;
|
|
268
|
+
this.addTrait(O[i], { at: b });
|
|
256
269
|
}
|
|
257
270
|
},
|
|
258
271
|
initToolbar() {
|
|
259
|
-
if (!
|
|
260
|
-
const { toolbar: t } = this,
|
|
261
|
-
!t.find((
|
|
272
|
+
if (!u) return;
|
|
273
|
+
const { toolbar: t } = this, o = s(this);
|
|
274
|
+
!t.find((i) => i.id === o.id) && (t == null || t.unshift(o));
|
|
262
275
|
}
|
|
263
276
|
},
|
|
264
277
|
view: {
|
|
@@ -266,31 +279,31 @@ const Y = "gjs-plg-", Q = "fsLightboxComponent", tt = w.startup, $ = "data-fslig
|
|
|
266
279
|
this.el.__skipLb = !0;
|
|
267
280
|
},
|
|
268
281
|
toggleLightbox() {
|
|
269
|
-
var
|
|
270
|
-
const { em: t, el:
|
|
271
|
-
if (
|
|
272
|
-
|
|
282
|
+
var L;
|
|
283
|
+
const { em: t, el: o, model: a } = this, { Canvas: i } = t, b = a.getAttributes()[D], { defaultView: d, documentElement: k } = o.ownerDocument, R = (L = d.fsLightboxInstances) == null ? void 0 : L[b];
|
|
284
|
+
if (k.classList.contains(oe))
|
|
285
|
+
R.close();
|
|
273
286
|
else {
|
|
274
|
-
|
|
275
|
-
let
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
},
|
|
287
|
+
o.__skipLb = !1;
|
|
288
|
+
let x;
|
|
289
|
+
R.props.onOpen = () => {
|
|
290
|
+
x = i.getSpots(), setTimeout(() => i.removeSpots());
|
|
291
|
+
}, R.props.onClose = () => {
|
|
292
|
+
x.forEach((_) => i.addSpot(_.attributes));
|
|
293
|
+
}, o.click();
|
|
281
294
|
}
|
|
282
295
|
}
|
|
283
296
|
}
|
|
284
|
-
}),
|
|
285
|
-
editor:
|
|
286
|
-
plan:
|
|
297
|
+
}), X({
|
|
298
|
+
editor: e,
|
|
299
|
+
plan: te,
|
|
287
300
|
licenseKey: h.licenseKey,
|
|
288
|
-
pluginName:
|
|
301
|
+
pluginName: ee,
|
|
289
302
|
cleanup: () => {
|
|
290
|
-
|
|
303
|
+
c.remove(A), l.removeType(A);
|
|
291
304
|
}
|
|
292
305
|
});
|
|
293
|
-
},
|
|
306
|
+
}, ie = J(se);
|
|
294
307
|
export {
|
|
295
|
-
|
|
308
|
+
ie as default
|
|
296
309
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
.${
|
|
1
|
+
(function(T,L){typeof exports=="object"&&typeof module<"u"?module.exports=L():typeof define=="function"&&define.amd?define(L):(T=typeof globalThis<"u"?globalThis:T||self,T.StudioSdkPlugins_fsLightboxComponent=L())})(this,function(){"use strict";const T="app.grapesjs.com",L="app-stage.grapesjs.com",S=[T,"app2.grapesjs.com",L,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:end",H=()=>typeof window<"u",F=({isDev:e,isStage:a,isPlatform:c})=>`${e?"":`https://${a?L:T}`}/${c?"platform-api":"api"}`,W=()=>{const e=H()&&window.location.hostname;return!!e&&(S.includes(e)||S.some(a=>e.endsWith(a)))};async function K({path:e,baseApiUrl:a,method:c="GET",headers:l={},params:r,body:f}){const g=`${a||F({isDev:!1,isStage:!1})}${e}`,u={method:c,headers:{"Content-Type":"application/json",...l}};f&&(u.body=JSON.stringify(f));const y=r?new URLSearchParams(r).toString():"",v=y?`?${y}`:"",s=await fetch(`${g}${v}`,u);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var x=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(x||{}),k=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(k||{});const $={[x.free]:0,[x.startup]:10,[x.business]:20,[x.enterprise]:30};function Z(e){const a=e;return a.init=c=>l=>e(l,c),a}const q=e=>Z(e);async function z({editor:e,plan:a,pluginName:c,licenseKey:l,onLicenseCheckResponse:r,cleanup:f}){let h="",g;const u=s=>{console.warn("Cleanup plugin:",c,"Reason:",s),f()},y=(s={})=>{var R;const{error:p,sdkLicense:M}=s,w=(R=s.plan)==null?void 0:R.category;if(!(M||s.license)||p)u(p||"Invalid license");else if(w){const m=$[a],t=$[w];m>t&&u({pluginRequiredPlan:a,licensePlan:w})}};e.Commands.has(k.settings)&&(g=e.runCommand(k.settings),h=(g==null?void 0:g.baseUrl)||"");const v=s=>{r==null||r(s),s&&y(s)};if(!g){e.onReady(async()=>{if(!W())if(l){const s=await X({licenseKey:l,pluginName:c,baseApiUrl:h});v(s)}else u("The `licenseKey` option not provided")});return}if(g.licensePlan||g.licenseError){const s=J(g);v(s);return}e.on(U,s=>v(s))}const J=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function X(e){const{licenseKey:a,pluginName:c,baseApiUrl:l}=e;try{return(await K({baseApiUrl:l,path:`/sdk/${a||"na"}`,method:"POST",params:{d:window.location.hostname,pn:c}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}const Y="gjs-plg-",Q="fsLightboxComponent",C=x.startup,_="data-fslightbox",D="data-type",ee="fslightbox-open",A="fslightbox",P={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>',imageLightbox:'<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>',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>'};return q(function(e,a={}){const{Blocks:c,Components:l}=e,r="Lightbox",f=`${Y}${A}`,h={toolbarIconOpen:P.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...a},{block:g,toolbarIconOpen:u,defaultSrc:y}=h,v=function(t){const o=this,n="data-fslightbox",i=window,b=()=>{var N;const d=i.refreshFsLightbox;d==null||d();const j=o.getAttribute(n);if((N=i.fsLightboxInstances)==null||N[j],!i._isEditor)return;Array.from(document.querySelectorAll(`[${n}]`)).forEach(E=>{const I=E.onclick;E.onclick=function(G){G.preventDefault();const V=E;!V.__skipLb&&(I==null||I(G)),V.__skipLb=!0}})};if(i.refreshFsLightbox)b();else{const d=document.createElement("script");d.src=t.cdnScript,d.onload=b,document.head.appendChild(d)}},s=t=>({id:`${A}-open-lb`,label:u,command:()=>{const o=t.getView();o==null||o.toggleLightbox()}}),p="source-type",M={type:"radio",name:p,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:P.image},{id:"video",label:"Video",icon:P.video},{id:"el",label:"Custom Element",icon:P.external}],labelToTitle:!0},w={id:"href-image",name:"href",type:"file",label:"Source Image"},B={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},R={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},m={image:[w],video:[B],el:[R]};l.addType(A,{block:g&&{label:r,media:P.imageLightbox,category:"Extra",select:!0,...h.block},isComponent:t=>{var o;return(o=t.hasAttribute)==null?void 0:o.call(t,_)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:r,icon:P.imageLightbox,classes:f,draggable:(t,o)=>!o.is(A),attributes:{[_]:"lightbox",[D]:"image",href:y},components:{type:"image",src:y},script:v,cdnScript:h.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[M,{name:_,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(t,o){var i;const n=(i=o.target)==null?void 0:i.getView();n==null||n.toggleLightbox()}}],styles:`
|
|
2
|
+
.${f} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
padding: 10px;
|
|
5
5
|
}
|
|
6
|
-
`},init(){const t=[
|
|
6
|
+
`},init(){const t=[p].map(o=>`change:${o}`).join(" ");this.on(t,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(t,o,n){if(n.adjust)return;const b=this.get(p)==="video"?"video":"image";this.addAttributes({[D]:b,href:""})},adjustSourceType(){const t=this.get(p),o=this.getAttributes().href||"",n={adjust:!0};if(t==="video"){const i=o.includes("youtube.com")?"youtube":"video";this.addAttributes({[D]:i},n)}else t!=="el"&&o.startsWith("#")?this.set(p,"el",n):t==="image"&&this.addAttributes({[D]:"image"},n)},updateTraits(t={}){const{changed:o}=this,{init:n}=t;if(o[M.name]||n){this.removeTrait([w.name,B.name,R.name]);const i=this.get(p)||"image",b=this.getTraitIndex(p)+1;this.addTrait(m[i],{at:b})}},initToolbar(){if(!u)return;const{toolbar:t}=this,o=s(this);!t.find(i=>i.id===o.id)&&(t==null||t.unshift(o))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var E;const{em:t,el:o,model:n}=this,{Canvas:i}=t,b=n.getAttributes()[_],{defaultView:d,documentElement:j}=o.ownerDocument,O=(E=d.fsLightboxInstances)==null?void 0:E[b];if(j.classList.contains(ee))O.close();else{o.__skipLb=!1;let I;O.props.onOpen=()=>{I=i.getSpots(),setTimeout(()=>i.removeSpots())},O.props.onClose=()=>{I.forEach(G=>i.addSpot(G.attributes))},o.click()}}}}),z({editor:e,plan:C,licenseKey:h.licenseKey,pluginName:Q,cleanup:()=>{c.remove(A),l.removeType(A)}})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(d||{}),y=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(y||{});const x="app.grapesjs.com",T="app-stage.grapesjs.com",I="app2.grapesjs.com",$="app-stage2.grapesjs.com",w=[x,I,T,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],E="license:check:end",M=()=>typeof window<"u",U=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?T:x}`}/${s?"platform-api":"api"}`,j=()=>{const e=M()&&window.location.hostname;return!!e&&(w.includes(e)||w.some(t=>e.endsWith(t)))};async function k({path:e,baseApiUrl:t,method:s="GET",headers:o={},params:n,body:i}){const a=`${t||U({isDev:!1,isStage:!1})}${e}`,l={method:s,headers:{"Content-Type":"application/json",...o}};i&&(l.body=JSON.stringify(i));const p=n?new URLSearchParams(n).toString():"",u=p?`?${p}`:"",r=await fetch(`${a}${u}`,l);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}const F={[d.free]:0,[d.startup]:10,[d.business]:20,[d.enterprise]:30};function B(e){const t=e;return t.init=s=>o=>e(o,s),t}const N=e=>B(e);async function W({editor:e,plan:t,pluginName:s,licenseKey:o,onLicenseCheckResponse:n,cleanup:i}){let c="",a;const l=r=>{console.warn("Cleanup plugin:",s,"Reason:",r),i()},p=(r={})=>{var A;const{error:g,sdkLicense:f}=r,b=(A=r.plan)==null?void 0:A.category;if(!(f||r.license)||g)l(g||"Invalid license");else if(b){const G=F[t],O=F[b];G>O&&l({pluginRequiredPlan:t,licensePlan:b})}};e.Commands.has(y.settings)&&(a=e.runCommand(y.settings),c=(a==null?void 0:a.baseUrl)||"");const u=r=>{n==null||n(r),r&&p(r)};if(!a){e.onReady(async()=>{if(!j())if(o){const r=await V({licenseKey:o,pluginName:s,baseApiUrl:c});u(r)}else l("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const r=_(a);u(r);return}e.on(E,r=>u(r))}const _=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function V(e){const{licenseKey:t,pluginName:s,baseApiUrl:o}=e;try{return(await k({baseApiUrl:o,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const v=e=>e.replaceAll('"',"").replaceAll("'",""),P=e=>e.includes(",")?e:/\s/.test(e)?`'${v(e)}'`:v(e),L=(e,t,s)=>({family:e,variant:t,...s}),D=(e,t)=>{e=P(e);const{menuVariant:s,variants:o}=t;return{family:e,familyLabel:v(e),menuVariant:s&&L(P(`menuFont-${v(e)}`),"regular",s),variants:Object.assign({},...Object.entries(o).map(([n,i])=>({[n]:L(e,n,i)})))}},R=(e,t)=>{var a;const s=D(e.family,e),o=s.menuVariant??((a=Object.values(s.variants))==null?void 0:a[0]);if(!o)return"Arial, Helvetica, sans-serif";const{source:n,descriptors:i}=o,c=v(o.family);if(!t){const l=new FontFace(c,`url("${n}")`,i),p=Array.from(document.fonts.values()).filter(u=>u.family===c);for(const u of p)document.fonts.delete(u);document.fonts.add(l),l.load().catch(()=>{})}return P(c)},K=e=>{const{family:t,menu:s,axes:o}=e,n=!!o,i=Object.assign({},...e.variants.map(c=>{var u,r;let a,l;if(n){const g=o.find(f=>f.tag==="wght");if(g){const{start:f,end:b}=g;a=`${f} ${b}`}}return a||(a=((u=c.match(/\d+/))==null?void 0:u[0])??"400"),l=((r=c.match(/[a-zA-Z]+/))==null?void 0:r[0])==="italic"?"italic":void 0,{[c]:{source:e.files[c],descriptors:{style:l,weight:a}}}}));return D(t,{menuVariant:{source:s},variants:i})},z=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:K(e),needsLoading:!0}}),H=e=>{const{font:t}=e.customData;return e.customData.needsLoading?(e.customData.needsLoading=!1,R(t)):R(t,!0)};let h;const q=e=>{const t=[];for(const s of Object.keys(e)){let o=e[s];o&&(Array.isArray(o)?t.push(...o.map(n=>[s,n.toString()])):(o=o.toString(),t.push([s,o])))}return new URLSearchParams(t)},J=e=>{const{apiKey:t,searchParams:s}=e,o=(n={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",c=q(n);return`${i}?${c}`};return{id:"google-fonts",types:["font"],label:({editor:n})=>n.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var p;if(h)return h;const n={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=s==null?void 0:s(),c={...n,...i},l=await(await fetch(o(c))).json();return(p=l.items)!=null&&p.length?(h=l.items.map(z),h):[]},itemLayout:n=>{const i=h.find(a=>a.id===n.assetProps.id),c=H(i);return{type:"column",onClick:()=>n.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:c,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},Q={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Z="googleFontsAssetProvider",X=d.startup,Y=function(e,t){const{i18n:s={}}=t,o=J(t);e.runCommand(y.assetProviderAdd,{provider:o}),e.I18n.addMessages({en:Q,...s}),W({editor:e,licenseKey:t.licenseKey,plan:X,pluginName:Z,cleanup:()=>{e.runCommand(y.assetProviderRemove,{id:o.id})}})},S=N(Y);module.exports=S;
|