@grapesjs/studio-sdk-plugins 1.0.14 → 1.0.15-rc.1
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/components/Accordion.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionContent.d.ts +3 -0
- package/dist/accordionComponent/components/AccordionGroup.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionHeader.d.ts +4 -0
- package/dist/accordionComponent/components/AccordionMarker.d.ts +3 -0
- package/dist/accordionComponent/index.cjs.d.ts +3 -0
- package/dist/accordionComponent/index.cjs.js +39 -0
- package/dist/accordionComponent/index.d.ts +3 -0
- package/dist/accordionComponent/index.es.d.ts +3 -0
- package/dist/accordionComponent/index.es.js +360 -0
- package/dist/accordionComponent/index.umd.js +39 -0
- package/dist/accordionComponent/types.d.ts +6 -0
- package/dist/accordionComponent/typesSchema.d.ts +22 -0
- package/dist/accordionComponent/utils.d.ts +22 -0
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +15 -15
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +5 -5
- package/dist/canvasFullSize/index.es.js +138 -118
- package/dist/canvasFullSize/index.umd.js +5 -5
- package/dist/canvasFullSize/typesSchema.d.ts +12 -8
- package/dist/flexComponent/blocks.d.ts +3 -0
- package/dist/flexComponent/components/FlexColumn.d.ts +4 -0
- package/dist/flexComponent/components/FlexRow.d.ts +4 -0
- package/dist/flexComponent/handlers.d.ts +19 -0
- package/dist/flexComponent/index.cjs.d.ts +3 -0
- package/dist/flexComponent/index.cjs.js +33 -0
- package/dist/flexComponent/index.d.ts +3 -0
- package/dist/flexComponent/index.es.d.ts +3 -0
- package/dist/flexComponent/index.es.js +715 -0
- package/dist/flexComponent/index.umd.js +33 -0
- package/dist/flexComponent/resizeDecorator.d.ts +50 -0
- package/dist/flexComponent/spots.d.ts +3 -0
- package/dist/flexComponent/types.d.ts +32 -0
- package/dist/flexComponent/typesSchema.d.ts +112 -0
- package/dist/flexComponent/utils.d.ts +63 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +128 -91
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/types.d.ts +7 -2
- package/dist/googleFontsAssetProvider/utils.d.ts +5 -0
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +39 -39
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +2 -0
- package/dist/index.cjs.js +105 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.es.d.ts +2 -0
- package/dist/index.es.js +6286 -5366
- package/dist/index.umd.js +105 -35
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +28 -28
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +31 -30
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/utils.d.ts +4 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +11 -11
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "grapesjs";
|
|
2
|
-
var
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), b = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e))(b || {});
|
|
3
|
+
const A = "app.grapesjs.com", T = "app-stage.grapesjs.com", v = [
|
|
4
|
+
A,
|
|
5
|
+
T,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,143 +11,180 @@ const v = "app.grapesjs.com", w = "app-stage.grapesjs.com", y = [
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
const e =
|
|
16
|
-
return !!e && (
|
|
14
|
+
], $ = "license:check:start", k = "license:check:end", x = () => typeof window < "u", D = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? T : A}`}/api`, F = () => {
|
|
15
|
+
const e = x() && window.location.hostname;
|
|
16
|
+
return !!e && (v.includes(e) || v.some((t) => e.endsWith(t)));
|
|
17
17
|
};
|
|
18
|
-
async function
|
|
18
|
+
async function G({
|
|
19
19
|
path: e,
|
|
20
20
|
baseApiUrl: t,
|
|
21
|
-
method:
|
|
22
|
-
headers:
|
|
23
|
-
params:
|
|
21
|
+
method: n = "GET",
|
|
22
|
+
headers: s = {},
|
|
23
|
+
params: o,
|
|
24
24
|
body: i
|
|
25
25
|
}) {
|
|
26
|
-
const
|
|
27
|
-
method:
|
|
26
|
+
const l = `${t || D({ isDev: !1, isStage: !1 })}${e}`, c = {
|
|
27
|
+
method: n,
|
|
28
28
|
headers: {
|
|
29
29
|
"Content-Type": "application/json",
|
|
30
|
-
...
|
|
30
|
+
...s
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
i && (c.body = JSON.stringify(i));
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
throw new Error(`HTTP error! status: ${
|
|
37
|
-
return
|
|
34
|
+
const d = o ? new URLSearchParams(o).toString() : "", a = d ? `?${d}` : "", u = await fetch(`${l}${a}`, c);
|
|
35
|
+
if (!u.ok)
|
|
36
|
+
throw new Error(`HTTP error! status: ${u.status}`);
|
|
37
|
+
return u.json();
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
39
|
+
const w = {
|
|
40
|
+
[p.free]: 0,
|
|
41
|
+
[p.startup]: 10,
|
|
42
|
+
[p.business]: 20,
|
|
43
|
+
[p.enterprise]: 30
|
|
44
44
|
};
|
|
45
45
|
function O(e) {
|
|
46
46
|
const t = e;
|
|
47
|
-
return t.init = (
|
|
47
|
+
return t.init = (n) => (s) => e(s, n), t;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
async function
|
|
49
|
+
const M = (e) => /* @__PURE__ */ O(e);
|
|
50
|
+
async function U({
|
|
51
51
|
editor: e,
|
|
52
52
|
plan: t,
|
|
53
|
-
pluginName:
|
|
54
|
-
licenseKey:
|
|
55
|
-
cleanup:
|
|
53
|
+
pluginName: n,
|
|
54
|
+
licenseKey: s,
|
|
55
|
+
cleanup: o
|
|
56
56
|
}) {
|
|
57
57
|
let i = "", r = !1;
|
|
58
|
-
const
|
|
59
|
-
console.warn("Cleanup plugin:",
|
|
60
|
-
},
|
|
61
|
-
var
|
|
62
|
-
const { error:
|
|
63
|
-
if (!(
|
|
64
|
-
c(
|
|
65
|
-
else if (
|
|
66
|
-
const
|
|
67
|
-
|
|
58
|
+
const l = F(), c = (a) => {
|
|
59
|
+
console.warn("Cleanup plugin:", n, "Reason:", a), o();
|
|
60
|
+
}, d = (a = {}) => {
|
|
61
|
+
var P;
|
|
62
|
+
const { error: u, sdkLicense: f } = a, g = (P = a.plan) == null ? void 0 : P.category;
|
|
63
|
+
if (!(f || a.license) || u)
|
|
64
|
+
c(u || "Invalid license");
|
|
65
|
+
else if (g) {
|
|
66
|
+
const L = w[t], R = w[g];
|
|
67
|
+
L > R && c({ pluginRequiredPlan: t, licensePlan: g });
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
e.on(
|
|
70
|
+
e.on($, (a) => {
|
|
71
71
|
i = a == null ? void 0 : a.baseApiUrl, r = !0;
|
|
72
72
|
}), e.on(k, (a) => {
|
|
73
|
-
|
|
73
|
+
d(a);
|
|
74
74
|
}), setTimeout(async () => {
|
|
75
75
|
if (!r) {
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
-
const a = await
|
|
79
|
-
a &&
|
|
76
|
+
if (l) return;
|
|
77
|
+
if (s) {
|
|
78
|
+
const a = await B({ licenseKey: s, pluginName: n, baseApiUrl: i });
|
|
79
|
+
a && d(a);
|
|
80
80
|
} else
|
|
81
81
|
c("The `licenseKey` option not provided");
|
|
82
82
|
}
|
|
83
83
|
}, 2e3);
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
86
|
-
const { licenseKey: t, pluginName:
|
|
85
|
+
async function B(e) {
|
|
86
|
+
const { licenseKey: t, pluginName: n, baseApiUrl: s } = e;
|
|
87
87
|
try {
|
|
88
|
-
return (await
|
|
89
|
-
baseApiUrl:
|
|
88
|
+
return (await G({
|
|
89
|
+
baseApiUrl: s,
|
|
90
90
|
path: `/sdk/${t || "na"}`,
|
|
91
91
|
method: "POST",
|
|
92
92
|
params: {
|
|
93
93
|
d: window.location.hostname,
|
|
94
|
-
pn:
|
|
94
|
+
pn: n
|
|
95
95
|
}
|
|
96
96
|
})).result || {};
|
|
97
|
-
} catch (
|
|
98
|
-
return console.error("Error during SDK license check:",
|
|
97
|
+
} catch (o) {
|
|
98
|
+
return console.error("Error during SDK license check:", o), !1;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
const E = (e) => {
|
|
102
|
+
const { family: t, menu: n, axes: s } = e, o = !!s, i = Object.assign(
|
|
103
|
+
{},
|
|
104
|
+
...e.variants.map((r) => {
|
|
105
|
+
var a, u;
|
|
106
|
+
let l, c;
|
|
107
|
+
if (o) {
|
|
108
|
+
const f = s.find((g) => g.tag === "wght");
|
|
109
|
+
if (f) {
|
|
110
|
+
const { start: g, end: y } = f;
|
|
111
|
+
l = `${g} ${y}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return l || (l = ((a = r.match(/\d+/)) == null ? void 0 : a[0]) ?? "400"), c = ((u = r.match(/[a-zA-Z]+/)) == null ? void 0 : u[0]) === "italic" ? "italic" : void 0, {
|
|
115
|
+
[r]: {
|
|
116
|
+
family: t,
|
|
117
|
+
source: e.files[r],
|
|
118
|
+
variant: r,
|
|
119
|
+
options: {
|
|
120
|
+
style: c,
|
|
121
|
+
weight: l
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
return {
|
|
128
|
+
family: t,
|
|
129
|
+
menuVariant: {
|
|
130
|
+
family: `assetManagerMenu-${t}`,
|
|
131
|
+
source: n,
|
|
132
|
+
variant: "menu"
|
|
133
|
+
},
|
|
134
|
+
variants: i
|
|
135
|
+
};
|
|
109
136
|
}, I = (e) => ({
|
|
110
137
|
id: `${e.family}/${e.version}`,
|
|
138
|
+
type: "font",
|
|
111
139
|
src: e.menu,
|
|
112
140
|
name: e.family,
|
|
113
|
-
customData: { font: e, needsLoading: !0 }
|
|
114
|
-
}),
|
|
141
|
+
customData: { font: E(e), needsLoading: !0 }
|
|
142
|
+
}), m = (e) => {
|
|
115
143
|
if (e.customData.needsLoading) {
|
|
116
144
|
e.customData.needsLoading = !1;
|
|
117
|
-
const t = e.customData
|
|
118
|
-
document.fonts.add(
|
|
145
|
+
const { font: t } = e.customData, { family: n, source: s, options: o } = t.menuVariant, i = new FontFace(n, `url("${s}")`, o);
|
|
146
|
+
document.fonts.add(i), i.load().catch(() => {
|
|
119
147
|
});
|
|
120
148
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
149
|
+
};
|
|
150
|
+
let h;
|
|
151
|
+
const W = (e) => {
|
|
152
|
+
const t = [];
|
|
153
|
+
for (const n of Object.keys(e)) {
|
|
154
|
+
let s = e[n];
|
|
155
|
+
s && (Array.isArray(s) ? t.push(...s.map((o) => [n, o.toString()])) : (s = s.toString(), t.push([n, s])));
|
|
156
|
+
}
|
|
157
|
+
return new URLSearchParams(t);
|
|
158
|
+
}, j = (e) => {
|
|
159
|
+
const { apiKey: t, searchParams: n } = e, s = (o = {}) => {
|
|
160
|
+
const i = "https://www.googleapis.com/webfonts/v1/webfonts", r = W(o);
|
|
124
161
|
return `${i}?${r}`;
|
|
125
162
|
};
|
|
126
163
|
return {
|
|
127
164
|
id: "google-fonts",
|
|
128
165
|
types: ["font"],
|
|
129
|
-
label: ({ editor:
|
|
166
|
+
label: ({ editor: o }) => o.I18n.t("googleFontsAssetProvider.providerLabel"),
|
|
130
167
|
search: { reloadOnInput: !1 },
|
|
131
168
|
async onLoad() {
|
|
132
|
-
var
|
|
133
|
-
if (
|
|
134
|
-
return
|
|
135
|
-
const
|
|
169
|
+
var d;
|
|
170
|
+
if (h)
|
|
171
|
+
return h;
|
|
172
|
+
const o = {
|
|
136
173
|
key: t,
|
|
137
174
|
sort: "alpha",
|
|
138
175
|
subset: "latin",
|
|
139
176
|
capability: ["WOFF2", "VF"]
|
|
140
|
-
}, i =
|
|
141
|
-
...
|
|
177
|
+
}, i = n == null ? void 0 : n(), r = {
|
|
178
|
+
...o,
|
|
142
179
|
...i
|
|
143
|
-
}, c = await (await fetch(
|
|
144
|
-
return (
|
|
180
|
+
}, c = await (await fetch(s(r))).json();
|
|
181
|
+
return (d = c.items) != null && d.length ? (h = c.items.map(I), h) : [];
|
|
145
182
|
},
|
|
146
|
-
itemLayout: (
|
|
147
|
-
const i =
|
|
148
|
-
return
|
|
183
|
+
itemLayout: (o) => {
|
|
184
|
+
const i = h.find((r) => r.id === o.assetProps.id);
|
|
185
|
+
return m(i), {
|
|
149
186
|
type: "column",
|
|
150
|
-
onClick: () =>
|
|
187
|
+
onClick: () => o.onSelect(i),
|
|
151
188
|
htmlAttrs: {
|
|
152
189
|
title: i.name
|
|
153
190
|
},
|
|
@@ -165,7 +202,7 @@ const G = (e) => {
|
|
|
165
202
|
overflow: "hidden",
|
|
166
203
|
textOverflow: "ellipsis",
|
|
167
204
|
whiteSpace: "nowrap",
|
|
168
|
-
fontFamily:
|
|
205
|
+
fontFamily: i.customData.font.menuVariant.family,
|
|
169
206
|
fontSize: "24px",
|
|
170
207
|
paddingLeft: "8px",
|
|
171
208
|
paddingRight: "8px"
|
|
@@ -175,27 +212,27 @@ const G = (e) => {
|
|
|
175
212
|
};
|
|
176
213
|
}
|
|
177
214
|
};
|
|
178
|
-
},
|
|
215
|
+
}, N = {
|
|
179
216
|
googleFontsAssetProvider: {
|
|
180
217
|
searchBtn: "Search on Google Fonts",
|
|
181
218
|
modalTitle: "Select Font",
|
|
182
219
|
providerLabel: "Google Fonts"
|
|
183
220
|
}
|
|
184
221
|
}, K = "googleFontsAssetProvider", _ = function(e, t) {
|
|
185
|
-
const { i18n:
|
|
186
|
-
e.runCommand(
|
|
187
|
-
en:
|
|
188
|
-
...
|
|
189
|
-
}),
|
|
222
|
+
const { i18n: n = {} } = t, s = j(t);
|
|
223
|
+
e.runCommand(b.assetProviderAdd, { provider: s }), e.I18n.addMessages({
|
|
224
|
+
en: N,
|
|
225
|
+
...n
|
|
226
|
+
}), U({
|
|
190
227
|
editor: e,
|
|
191
228
|
licenseKey: t.licenseKey,
|
|
192
|
-
plan:
|
|
229
|
+
plan: p.startup,
|
|
193
230
|
pluginName: K,
|
|
194
231
|
cleanup: () => {
|
|
195
|
-
e.runCommand(
|
|
232
|
+
e.runCommand(b.assetProviderRemove, { id: s.id });
|
|
196
233
|
}
|
|
197
234
|
});
|
|
198
|
-
},
|
|
235
|
+
}, H = M(_);
|
|
199
236
|
export {
|
|
200
|
-
|
|
237
|
+
H as default
|
|
201
238
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],p):(l=typeof globalThis<"u"?globalThis:l||self,l.StudioSdkPlugins_googleFontsAssetProvider=p())})(this,function(){"use strict";var l=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(l||{}),p=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e))(p||{});const y="app.grapesjs.com",P="app-stage.grapesjs.com",v=[y,P,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",R="license:check:end",x=()=>typeof window<"u",k=({isDev:e,isStage:t})=>`${e?"":`https://${t?P:y}`}/api`,$=()=>{const e=x()&&window.location.hostname;return!!e&&(v.includes(e)||v.some(t=>e.endsWith(t)))};async function F({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:o,body:i}){const d=`${t||k({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...s}};i&&(c.body=JSON.stringify(i));const u=o?new URLSearchParams(o).toString():"",r=u?`?${u}`:"",g=await fetch(`${d}${r}`,c);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const w={[l.free]:0,[l.startup]:10,[l.business]:20,[l.enterprise]:30};function D(e){const t=e;return t.init=n=>s=>e(s,n),t}const G=e=>D(e);async function O({editor:e,plan:t,pluginName:n,licenseKey:s,cleanup:o}){let i="",a=!1;const d=$(),c=r=>{console.warn("Cleanup plugin:",n,"Reason:",r),o()},u=(r={})=>{var T;const{error:g,sdkLicense:b}=r,f=(T=r.plan)==null?void 0:T.category;if(!(b||r.license)||g)c(g||"Invalid license");else if(f){const N=w[t],_=w[f];N>_&&c({pluginRequiredPlan:t,licensePlan:f})}};e.on(L,r=>{i=r==null?void 0:r.baseApiUrl,a=!0}),e.on(R,r=>{u(r)}),setTimeout(async()=>{if(!a){if(d)return;if(s){const r=await M({licenseKey:s,pluginName:n,baseApiUrl:i});r&&u(r)}else c("The `licenseKey` option not provided")}},2e3)}async function M(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await F({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const U=e=>{const{family:t,menu:n,axes:s}=e,o=!!s,i=Object.assign({},...e.variants.map(a=>{var r,g;let d,c;if(o){const b=s.find(f=>f.tag==="wght");if(b){const{start:f,end:A}=b;d=`${f} ${A}`}}return d||(d=((r=a.match(/\d+/))==null?void 0:r[0])??"400"),c=((g=a.match(/[a-zA-Z]+/))==null?void 0:g[0])==="italic"?"italic":void 0,{[a]:{family:t,source:e.files[a],variant:a,options:{style:c,weight:d}}}}));return{family:t,menuVariant:{family:`assetManagerMenu-${t}`,source:n,variant:"menu"},variants:i}},j=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:U(e),needsLoading:!0}}),m=e=>{if(e.customData.needsLoading){e.customData.needsLoading=!1;const{font:t}=e.customData,{family:n,source:s,options:o}=t.menuVariant,i=new FontFace(n,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let h;const B=e=>{const t=[];for(const n of Object.keys(e)){let s=e[n];s&&(Array.isArray(s)?t.push(...s.map(o=>[n,o.toString()])):(s=s.toString(),t.push([n,s])))}return new URLSearchParams(t)},E=e=>{const{apiKey:t,searchParams:n}=e,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",a=B(o);return`${i}?${a}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=n==null?void 0:n(),a={...o,...i},c=await(await fetch(s(a))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(j),h):[]},itemLayout:o=>{const i=h.find(a=>a.id===o.assetProps.id);return m(i),{type:"column",onClick:()=>o.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:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},I={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},W="googleFontsAssetProvider";return G(function(e,t){const{i18n:n={}}=t,s=E(t);e.runCommand(p.assetProviderAdd,{provider:s}),e.I18n.addMessages({en:I,...n}),O({editor:e,licenseKey:t.licenseKey,plan:l.startup,pluginName:W,cleanup:()=>{e.runCommand(p.assetProviderRemove,{id:s.id})}})})});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseGoogleFontsAssetProviderOptions, BaseGoogleFontsSearchParams } from './typesSchema';
|
|
2
2
|
export interface GoogleFontsSearchParams extends BaseGoogleFontsSearchParams {
|
|
3
3
|
}
|
|
4
|
-
export interface
|
|
4
|
+
export interface GoogleFontFamily {
|
|
5
5
|
category?: string | undefined;
|
|
6
6
|
kind: string;
|
|
7
7
|
family: string;
|
|
@@ -13,10 +13,15 @@ export interface WebfontFamily {
|
|
|
13
13
|
[variant: string]: string;
|
|
14
14
|
};
|
|
15
15
|
menu: string;
|
|
16
|
+
axes: {
|
|
17
|
+
tag: string;
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
}[];
|
|
16
21
|
}
|
|
17
22
|
export interface GoogleFontsApiResponse {
|
|
18
23
|
kind: string;
|
|
19
|
-
items:
|
|
24
|
+
items: GoogleFontFamily[];
|
|
20
25
|
}
|
|
21
26
|
export interface GoogleFontsAssetProviderOptions extends Omit<BaseGoogleFontsAssetProviderOptions, 'searchParams'> {
|
|
22
27
|
/**
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Font, FontAssetProps } from '../types';
|
|
2
|
+
import { GoogleFontFamily } from './types';
|
|
3
|
+
export declare const toFont: (googleFont: GoogleFontFamily) => Font;
|
|
4
|
+
export declare const toAssetProps: (googleFont: GoogleFontFamily) => FontAssetProps;
|
|
5
|
+
export declare const loadMenuFont: (assetProps: FontAssetProps) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";require("grapesjs");var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),O=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(O||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e))(h||{});const H={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},w=`<svg viewBox="0 0 24 24">
|
|
1
|
+
"use strict";require("grapesjs");var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),O=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(O||{}),h=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.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))(h||{});const H={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},w=`<svg viewBox="0 0 24 24">
|
|
2
2
|
<path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
|
|
3
|
-
</svg>`,x="layout-icon-picker",U="icons-layout-",
|
|
3
|
+
</svg>`,x="layout-icon-picker",U="icons-layout-",R="icons-list-layout",_="gs-iconify-picker",A="__iconify_collection",B="https://api.iconify.design",I=new Map;let T;const D=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function $({collectionId:e,editor:o}){try{if(I.has(e))return I.get(e);const t=await fetch(D({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return I.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(h.toastAdd,z());return}}async function G({collectionIds:e,editor:o}){try{if(T)return T;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${B}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return T=await n.json(),T}catch(t){console.error("Error fetching collections",t),o.runCommand(h.toastAdd,C());return}}function P(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function W({collectionIds:e,editor:o,component:t}){const n=await G({collectionIds:e,editor:o});if(!n)return;const a=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},d=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??d[0].id;o.runCommand(h.layoutToggle,{id:x,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[V({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:R,type:"column",grow:!0}]}});const r=await $({collectionId:u,editor:o});r&&E({editor:o,collection:r,handleClick:a,collectionId:u})}function F({editor:e,collection:o}){e.em.set(A,o)}function K(e){return e.em.get(A)}function E(e){const{editor:o}=e,t={id:U,layout:Y(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:R}};o.runCommand(h.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(h.layoutAdd,t),10)}function V(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:a}=e,d=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${_}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await $({collectionId:r,editor:n});s&&(u({value:r}),F({editor:n,collection:s}),E({editor:n,collection:s,handleClick:a,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${A}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=K(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));u({value:r}),E({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function Y({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:a=24,icons:d,prefix:u}=o||e,r=Object.entries(d).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${_}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:f}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=s.body,l.setAttribute("viewBox",`0 0 ${a} ${n}`);const{cssWidth:p,cssHeight:y}=q(a,n);l.style.cssText=`width: ${p}px; height: ${y}px; cursor: pointer;`,l.addEventListener("mouseover",()=>{l.style.border="2px solid currentColor",l.style.borderRadius="4px",l.style.padding="4px"}),l.addEventListener("mouseout",()=>{l.style.border="none"});const b=()=>{const v=l.cloneNode(!0);v.removeAttribute("style");const j=v.outerHTML;t({icon:j,collectionId:u,iconId:s.name}),i==null||i.runCommand(h.layoutRemove,{id:x})};return l.addEventListener("click",b),g(l),()=>{l.removeEventListener("click",b),f(l)}}}]}}}function q(e,o){const t=e/o;let n=48,a=48;return t>1?a=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:a}}function C(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:O.Error}}function z(){return{...C(),id:"toast-error-getCollection",content:"Error fetching collection"}}const M="app.grapesjs.com",N="app-stage.grapesjs.com",k=[M,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],J="license:check:start",X="license:check:end",Z=()=>typeof window<"u",Q=({isDev:e,isStage:o})=>`${e?"":`https://${o?N:M}`}/api`,S=()=>{const e=Z()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(o=>e.endsWith(o)))};async function ee({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||Q({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};d&&(s.body=JSON.stringify(d));const c=a?new URLSearchParams(a).toString():"",i=c?`?${c}`:"",g=await fetch(`${r}${i}`,s);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}const m={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function te(e){const o=e;return o.init=t=>n=>e(n,t),o}const oe=e=>te(e);async function ne({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=S(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var y;const{error:g,sdkLicense:f}=i,l=(y=i.plan)==null?void 0:y.category;if(!(f||i.license)||g)s(g||"Invalid license");else if(l){const b=m[o],v=m[l];b>v&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(J,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(X,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await se({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function se(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await ee({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const ie=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},ce="iconifyComponent",re=function(e,o={}){var l;const{Components:t,Blocks:n}=e,{collections:a,extendIconComponent:d=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",g="data-type-iconify",f={events:()=>({dblclick:"onActive"}),onActive(){W({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:w,content:{type:c},category:"Extra",activate:!0,...r},isComponent:p=>ie(p,g),model:{defaults:{name:i,icon:w,droppable:!1,attributes:{[g]:!0},resizable:H,components:w,style:{width:"50px",height:"50px"},traits:[P()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:f}),d){const p=(l=t.getType(s))==null?void 0:l.model,[y,b,...v]=p.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[y,b,P(),...v]}},view:f})}ne({editor:e,licenseKey:u,plan:L.startup,pluginName:ce,cleanup:()=>{n.remove(c),t.removeType(c)}})},le=oe(re);module.exports=le;
|