@grapesjs/studio-sdk-plugins 1.0.28-rc.2 → 1.0.28
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 +8 -8
- package/dist/accordionComponent/index.es.js +71 -69
- package/dist/accordionComponent/index.umd.js +6 -6
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +48 -46
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +86 -84
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +68 -66
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +52 -50
- package/dist/canvasFullSize/index.umd.js +7 -7
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +191 -189
- package/dist/canvasGridMode/index.umd.js +2 -2
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +32 -30
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +31 -29
- package/dist/dataSourceHandlebars/index.umd.js +2 -2
- package/dist/dialogComponent/index.cjs.js +3 -3
- package/dist/dialogComponent/index.es.js +32 -30
- package/dist/dialogComponent/index.umd.js +4 -4
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +74 -72
- package/dist/flexComponent/index.umd.js +7 -7
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +40 -38
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +70 -68
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +56 -54
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +43 -43
- package/dist/index.es.js +1442 -1440
- package/dist/index.umd.js +43 -43
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +29 -27
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +90 -88
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +20 -18
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +4 -4
- package/dist/listPagesComponent/index.es.js +42 -40
- package/dist/listPagesComponent/index.umd.js +4 -4
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +156 -154
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +165 -163
- package/dist/prosemirror/index.umd.js +7 -7
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +101 -99
- 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 +54 -52
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/swiperComponent/index.cjs.js +7 -7
- package/dist/swiperComponent/index.es.js +60 -58
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +80 -78
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +66 -64
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const _ = "app.grapesjs.com",
|
|
1
|
+
const _ = "app.grapesjs.com", D = "app-stage.grapesjs.com", B = "app2.grapesjs.com", H = "app-stage2.grapesjs.com", O = [
|
|
2
2
|
_,
|
|
3
|
-
|
|
3
|
+
B,
|
|
4
|
+
D,
|
|
5
|
+
H,
|
|
4
6
|
"localhost",
|
|
5
7
|
"127.0.0.1",
|
|
6
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -9,11 +11,11 @@ const _ = "app.grapesjs.com", R = "app-stage.grapesjs.com", k = [
|
|
|
9
11
|
// For stackblitz.com demos
|
|
10
12
|
"-sandpack.codesandbox.io"
|
|
11
13
|
// For Sandpack demos
|
|
12
|
-
],
|
|
13
|
-
const e =
|
|
14
|
-
return !!e && (
|
|
14
|
+
], F = "license:check:start", C = "license:check:end", W = () => typeof window < "u", K = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? D : _}`}/api`, S = () => {
|
|
15
|
+
const e = W() && window.location.hostname;
|
|
16
|
+
return !!e && (O.includes(e) || O.some((t) => e.endsWith(t)));
|
|
15
17
|
};
|
|
16
|
-
async function
|
|
18
|
+
async function V({
|
|
17
19
|
path: e,
|
|
18
20
|
baseApiUrl: t,
|
|
19
21
|
method: o = "GET",
|
|
@@ -21,7 +23,7 @@ async function K({
|
|
|
21
23
|
params: u,
|
|
22
24
|
body: g
|
|
23
25
|
}) {
|
|
24
|
-
const r = `${t ||
|
|
26
|
+
const r = `${t || K({ isDev: !1, isStage: !1 })}${e}`, n = {
|
|
25
27
|
method: o,
|
|
26
28
|
headers: {
|
|
27
29
|
"Content-Type": "application/json",
|
|
@@ -34,19 +36,19 @@ async function K({
|
|
|
34
36
|
throw new Error(`HTTP error! status: ${p.status}`);
|
|
35
37
|
return p.json();
|
|
36
38
|
}
|
|
37
|
-
var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}),
|
|
38
|
-
const
|
|
39
|
+
var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), R = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(R || {}), L = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.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))(L || {});
|
|
40
|
+
const k = {
|
|
39
41
|
[v.free]: 0,
|
|
40
42
|
[v.startup]: 10,
|
|
41
43
|
[v.business]: 20,
|
|
42
44
|
[v.enterprise]: 30
|
|
43
45
|
};
|
|
44
|
-
function
|
|
46
|
+
function Y(e) {
|
|
45
47
|
const t = e;
|
|
46
48
|
return t.init = (o) => (s) => e(s, o), t;
|
|
47
49
|
}
|
|
48
|
-
const
|
|
49
|
-
async function
|
|
50
|
+
const m = (e) => /* @__PURE__ */ Y(e);
|
|
51
|
+
async function z({
|
|
50
52
|
editor: e,
|
|
51
53
|
plan: t,
|
|
52
54
|
pluginName: o,
|
|
@@ -54,7 +56,7 @@ async function Y({
|
|
|
54
56
|
cleanup: u
|
|
55
57
|
}) {
|
|
56
58
|
let g = "", a = !1;
|
|
57
|
-
const r =
|
|
59
|
+
const r = S(), n = (i) => {
|
|
58
60
|
console.warn("Cleanup plugin:", o, "Reason:", i), u();
|
|
59
61
|
}, c = (i = {}) => {
|
|
60
62
|
var y;
|
|
@@ -62,29 +64,29 @@ async function Y({
|
|
|
62
64
|
if (!(h || i.license) || p)
|
|
63
65
|
n(p || "Invalid license");
|
|
64
66
|
else if (l) {
|
|
65
|
-
const b =
|
|
67
|
+
const b = k[t], d = k[l];
|
|
66
68
|
b > d && n({ pluginRequiredPlan: t, licensePlan: l });
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
|
-
e.on(
|
|
71
|
+
e.on(F, (i) => {
|
|
70
72
|
g = i == null ? void 0 : i.baseApiUrl, a = !0;
|
|
71
|
-
}), e.on(
|
|
73
|
+
}), e.on(C, (i) => {
|
|
72
74
|
c(i);
|
|
73
75
|
}), setTimeout(async () => {
|
|
74
76
|
if (!a) {
|
|
75
77
|
if (r) return;
|
|
76
78
|
if (s) {
|
|
77
|
-
const i = await
|
|
79
|
+
const i = await q({ licenseKey: s, pluginName: o, baseApiUrl: g });
|
|
78
80
|
i && c(i);
|
|
79
81
|
} else
|
|
80
82
|
n("The `licenseKey` option not provided");
|
|
81
83
|
}
|
|
82
84
|
}, 2e3);
|
|
83
85
|
}
|
|
84
|
-
async function
|
|
86
|
+
async function q(e) {
|
|
85
87
|
const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
|
|
86
88
|
try {
|
|
87
|
-
return (await
|
|
89
|
+
return (await V({
|
|
88
90
|
baseApiUrl: s,
|
|
89
91
|
path: `/sdk/${t || "na"}`,
|
|
90
92
|
method: "POST",
|
|
@@ -97,30 +99,30 @@ async function z(e) {
|
|
|
97
99
|
return console.error("Error during SDK license check:", u), !1;
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
const
|
|
102
|
+
const J = (e, t) => {
|
|
101
103
|
var o;
|
|
102
104
|
return !!((o = e == null ? void 0 : e.hasAttribute) != null && o.call(e, t));
|
|
103
|
-
},
|
|
105
|
+
}, X = "iconifyComponent", Z = v.startup, Q = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, I = `<svg viewBox="0 0 24 24">
|
|
104
106
|
<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" />
|
|
105
|
-
</svg>`, $ = "layout-icon-picker",
|
|
107
|
+
</svg>`, $ = "layout-icon-picker", ee = "icons-layout-", M = "icons-list-layout", N = "gs-iconify-picker", P = "__iconify_collection", te = "https://api.iconify.design", E = /* @__PURE__ */ new Map();
|
|
106
108
|
let T;
|
|
107
|
-
const
|
|
108
|
-
async function
|
|
109
|
+
const oe = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
|
|
110
|
+
async function U({ collectionId: e, editor: t }) {
|
|
109
111
|
try {
|
|
110
112
|
if (E.has(e)) return E.get(e);
|
|
111
|
-
const o = await fetch(
|
|
113
|
+
const o = await fetch(oe({ collectionId: e }));
|
|
112
114
|
if (!o.ok) throw new Error(`Failed to fetch collection: ${o.statusText}`);
|
|
113
115
|
const s = await o.json();
|
|
114
116
|
return E.set(e, s), s;
|
|
115
117
|
} catch (o) {
|
|
116
|
-
console.error("Error fetching collection", o), t.runCommand(L.toastAdd,
|
|
118
|
+
console.error("Error fetching collection", o), t.runCommand(L.toastAdd, ae());
|
|
117
119
|
return;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
async function
|
|
122
|
+
async function ne({ collectionIds: e, editor: t }) {
|
|
121
123
|
try {
|
|
122
124
|
if (T) return T;
|
|
123
|
-
const o = e ? `?prefixes=${e.join(",")}` : "", s = await fetch(`${
|
|
125
|
+
const o = e ? `?prefixes=${e.join(",")}` : "", s = await fetch(`${te}/collections${o}`);
|
|
124
126
|
if (!s.ok) throw new Error(`Failed to fetch collections: ${s.statusText}`);
|
|
125
127
|
return T = await s.json(), T;
|
|
126
128
|
} catch (o) {
|
|
@@ -140,8 +142,8 @@ function x() {
|
|
|
140
142
|
}
|
|
141
143
|
};
|
|
142
144
|
}
|
|
143
|
-
async function
|
|
144
|
-
const s = await
|
|
145
|
+
async function se({ collectionIds: e, editor: t, component: o }) {
|
|
146
|
+
const s = await ne({ collectionIds: e, editor: t });
|
|
145
147
|
if (!s) return;
|
|
146
148
|
const u = ({ icon: n, collectionId: c, iconId: i }) => {
|
|
147
149
|
o.components(n), o.set({ collectionId: c, iconId: i });
|
|
@@ -154,17 +156,17 @@ async function oe({ collectionIds: e, editor: t, component: o }) {
|
|
|
154
156
|
type: "column",
|
|
155
157
|
style: { height: 500, gap: 10 },
|
|
156
158
|
children: [
|
|
157
|
-
|
|
159
|
+
ce({
|
|
158
160
|
collectionsList: g,
|
|
159
161
|
collectionId: a,
|
|
160
162
|
editor: t,
|
|
161
163
|
handleClick: u
|
|
162
164
|
}),
|
|
163
|
-
{ id:
|
|
165
|
+
{ id: M, type: "column", grow: !0 }
|
|
164
166
|
]
|
|
165
167
|
}
|
|
166
168
|
});
|
|
167
|
-
const r = await
|
|
169
|
+
const r = await U({ collectionId: a, editor: t });
|
|
168
170
|
r && (G({ editor: t, collection: r }), A({
|
|
169
171
|
editor: t,
|
|
170
172
|
collection: r,
|
|
@@ -175,25 +177,25 @@ async function oe({ collectionIds: e, editor: t, component: o }) {
|
|
|
175
177
|
function G({ editor: e, collection: t }) {
|
|
176
178
|
e.em.set(P, t);
|
|
177
179
|
}
|
|
178
|
-
function
|
|
180
|
+
function ie(e) {
|
|
179
181
|
return e.em.get(P);
|
|
180
182
|
}
|
|
181
183
|
function A(e) {
|
|
182
184
|
const { editor: t } = e;
|
|
183
185
|
t.runCommand(L.layoutUpdate, {
|
|
184
|
-
id:
|
|
185
|
-
layout:
|
|
186
|
+
id: ee,
|
|
187
|
+
layout: re(e),
|
|
186
188
|
header: !1,
|
|
187
189
|
style: { height: "100%" },
|
|
188
|
-
placer: { type: "static", layoutId:
|
|
190
|
+
placer: { type: "static", layoutId: M }
|
|
189
191
|
});
|
|
190
192
|
}
|
|
191
|
-
function
|
|
193
|
+
function ce(e) {
|
|
192
194
|
const { collectionsList: t, collectionId: o, editor: s, handleClick: u } = e, g = t.map(({ id: a, name: r, total: n }) => ({ id: a, label: `${r} (${n})` })).sort((a, r) => a.label.localeCompare(r.label));
|
|
193
195
|
return {
|
|
194
196
|
type: "column",
|
|
195
197
|
style: { gap: 10 },
|
|
196
|
-
className: `${
|
|
198
|
+
className: `${N}__header`,
|
|
197
199
|
children: [
|
|
198
200
|
{
|
|
199
201
|
type: "selectField",
|
|
@@ -201,7 +203,7 @@ function se(e) {
|
|
|
201
203
|
options: g,
|
|
202
204
|
emptyState: "Select an icon collection",
|
|
203
205
|
onChange: async ({ setState: a, value: r }) => {
|
|
204
|
-
const n = await
|
|
206
|
+
const n = await U({ collectionId: r, editor: s });
|
|
205
207
|
n && (a({ value: r }), G({ editor: s, collection: n }), A({
|
|
206
208
|
editor: s,
|
|
207
209
|
collection: n,
|
|
@@ -218,7 +220,7 @@ function se(e) {
|
|
|
218
220
|
[`change:${P}`]: ({ setState: a }) => a({ value: "" })
|
|
219
221
|
},
|
|
220
222
|
onInput: ({ setState: a, value: r, editor: n }) => {
|
|
221
|
-
const c =
|
|
223
|
+
const c = ie(n);
|
|
222
224
|
if (!c) return;
|
|
223
225
|
const i = Object.fromEntries(
|
|
224
226
|
Object.entries(c.icons).filter(([p]) => p.includes(r))
|
|
@@ -235,7 +237,7 @@ function se(e) {
|
|
|
235
237
|
]
|
|
236
238
|
};
|
|
237
239
|
}
|
|
238
|
-
function
|
|
240
|
+
function re({
|
|
239
241
|
collection: e,
|
|
240
242
|
collectionFiltered: t,
|
|
241
243
|
handleClick: o
|
|
@@ -243,7 +245,7 @@ function ie({
|
|
|
243
245
|
const { height: s = 24, width: u = 24, icons: g, prefix: a } = t || e, r = Object.entries(g).map(([n, c]) => ({ name: n, ...c }), {});
|
|
244
246
|
return {
|
|
245
247
|
type: "column",
|
|
246
|
-
className: `${
|
|
248
|
+
className: `${N}__content`,
|
|
247
249
|
style: { height: "100%" },
|
|
248
250
|
children: {
|
|
249
251
|
type: "virtualList",
|
|
@@ -291,24 +293,24 @@ function j() {
|
|
|
291
293
|
id: "toast-error-getCollections",
|
|
292
294
|
header: "Error",
|
|
293
295
|
content: "Error fetching collections",
|
|
294
|
-
variant:
|
|
296
|
+
variant: R.Error
|
|
295
297
|
};
|
|
296
298
|
}
|
|
297
|
-
function
|
|
299
|
+
function ae() {
|
|
298
300
|
return {
|
|
299
301
|
...j(),
|
|
300
302
|
id: "toast-error-getCollection",
|
|
301
303
|
content: "Error fetching collection"
|
|
302
304
|
};
|
|
303
305
|
}
|
|
304
|
-
const
|
|
306
|
+
const le = function(e, t = {}) {
|
|
305
307
|
var l;
|
|
306
308
|
const { Components: o, Blocks: s } = e, { collections: u, extendIconComponent: g = !0, licenseKey: a, block: r = {} } = t, n = "icon", c = "iconify", i = "Iconify", p = "data-type-iconify", h = {
|
|
307
309
|
events: () => ({
|
|
308
310
|
dblclick: "onActive"
|
|
309
311
|
}),
|
|
310
312
|
onActive() {
|
|
311
|
-
|
|
313
|
+
se({ collectionIds: u, editor: e, component: this.model });
|
|
312
314
|
}
|
|
313
315
|
};
|
|
314
316
|
if (o.addType(c, {
|
|
@@ -320,14 +322,14 @@ const re = function(e, t = {}) {
|
|
|
320
322
|
activate: !0,
|
|
321
323
|
...r
|
|
322
324
|
},
|
|
323
|
-
isComponent: (f) =>
|
|
325
|
+
isComponent: (f) => J(f, p),
|
|
324
326
|
model: {
|
|
325
327
|
defaults: {
|
|
326
328
|
name: i,
|
|
327
329
|
icon: I,
|
|
328
330
|
droppable: !1,
|
|
329
331
|
attributes: { [p]: !0 },
|
|
330
|
-
resizable:
|
|
332
|
+
resizable: Q,
|
|
331
333
|
components: I,
|
|
332
334
|
style: { width: "50px", height: "50px" },
|
|
333
335
|
traits: [x()]
|
|
@@ -351,16 +353,16 @@ const re = function(e, t = {}) {
|
|
|
351
353
|
view: h
|
|
352
354
|
});
|
|
353
355
|
}
|
|
354
|
-
|
|
356
|
+
z({
|
|
355
357
|
editor: e,
|
|
356
358
|
licenseKey: a,
|
|
357
|
-
plan:
|
|
358
|
-
pluginName:
|
|
359
|
+
plan: Z,
|
|
360
|
+
pluginName: X,
|
|
359
361
|
cleanup: () => {
|
|
360
362
|
s.remove(c), o.removeType(c);
|
|
361
363
|
}
|
|
362
364
|
});
|
|
363
|
-
},
|
|
365
|
+
}, ue = m(le);
|
|
364
366
|
export {
|
|
365
|
-
|
|
367
|
+
ue as default
|
|
366
368
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(h,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_iconifyComponent=y())})(this,function(){"use strict";const h="app.grapesjs.com",y="app-stage.grapesjs.com",
|
|
1
|
+
(function(h,y){typeof exports=="object"&&typeof module<"u"?module.exports=y():typeof define=="function"&&define.amd?define(y):(h=typeof globalThis<"u"?globalThis:h||self,h.StudioSdkPlugins_iconifyComponent=y())})(this,function(){"use strict";const h="app.grapesjs.com",y="app-stage.grapesjs.com",x=[h,"app2.grapesjs.com",y,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",H="license:check:end",C=()=>typeof window<"u",F=({isDev:e,isStage:t})=>`${e?"":`https://${t?y:h}`}/api`,S=()=>{const e=C()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(t=>e.endsWith(t)))};async function W({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:u,body:p}){const r=`${t||F({isDev:!1,isStage:!1})}${e}`,n={method:o,headers:{"Content-Type":"application/json",...s}};p&&(n.body=JSON.stringify(p));const c=u?new URLSearchParams(u).toString():"",i=c?`?${c}`:"",g=await fetch(`${r}${i}`,n);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);return g.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),_=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(_||{}),v=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.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||{});const D={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function m(e){const t=e;return t.init=o=>s=>e(s,o),t}const K=e=>m(e);async function V({editor:e,plan:t,pluginName:o,licenseKey:s,cleanup:u}){let p="",a=!1;const r=S(),n=i=>{console.warn("Cleanup plugin:",o,"Reason:",i),u()},c=(i={})=>{var L;const{error:g,sdkLicense:T}=i,l=(L=i.plan)==null?void 0:L.category;if(!(T||i.license)||g)n(g||"Invalid license");else if(l){const w=D[t],d=D[l];w>d&&n({pluginRequiredPlan:t,licensePlan:l})}};e.on(B,i=>{p=i==null?void 0:i.baseApiUrl,a=!0}),e.on(H,i=>{c(i)}),setTimeout(async()=>{if(!a){if(r)return;if(s){const i=await Y({licenseKey:s,pluginName:o,baseApiUrl:p});i&&c(i)}else n("The `licenseKey` option not provided")}},2e3)}async function Y(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await W({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(u){return console.error("Error during SDK license check:",u),!1}}const z=(e,t)=>{var o;return!!((o=e==null?void 0:e.hasAttribute)!=null&&o.call(e,t))},q="iconifyComponent",J=b.startup,X={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},A=`<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>`,
|
|
3
|
+
</svg>`,R="layout-icon-picker",Z="icons-layout-",M="icons-list-layout",N="gs-iconify-picker",P="__iconify_collection",Q="https://api.iconify.design",O=new Map;let E;const ee=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function $({collectionId:e,editor:t}){try{if(O.has(e))return O.get(e);const o=await fetch(ee({collectionId:e}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const s=await o.json();return O.set(e,s),s}catch(o){console.error("Error fetching collection",o),t.runCommand(v.toastAdd,ce());return}}async function te({collectionIds:e,editor:t}){try{if(E)return E;const o=e?`?prefixes=${e.join(",")}`:"",s=await fetch(`${Q}/collections${o}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return E=await s.json(),E}catch(o){console.error("Error fetching collections",o),t.runCommand(v.toastAdd,j());return}}function G(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var t;(t=e.getSelected())==null||t.trigger("active")}}}async function oe({collectionIds:e,editor:t,component:o}){const s=await te({collectionIds:e,editor:t});if(!s)return;const u=({icon:n,collectionId:c,iconId:i})=>{o.components(n),o.set({collectionId:c,iconId:i})},p=Object.entries(s).map(([n,c])=>({id:n,...c})).sort((n,c)=>n.name.localeCompare(c.name)),a=o.get("collectionId")??p[0].id;t.runCommand(v.layoutToggle,{id:R,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[se({collectionsList:p,collectionId:a,editor:t,handleClick:u}),{id:M,type:"column",grow:!0}]}});const r=await $({collectionId:a,editor:t});r&&(U({editor:t,collection:r}),k({editor:t,collection:r,handleClick:u,collectionId:a}))}function U({editor:e,collection:t}){e.em.set(P,t)}function ne(e){return e.em.get(P)}function k(e){const{editor:t}=e;t.runCommand(v.layoutUpdate,{id:Z,layout:ie(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:M}})}function se(e){const{collectionsList:t,collectionId:o,editor:s,handleClick:u}=e,p=t.map(({id:a,name:r,total:n})=>({id:a,label:`${r} (${n})`})).sort((a,r)=>a.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${N}__header`,children:[{type:"selectField",value:o,options:p,emptyState:"Select an icon collection",onChange:async({setState:a,value:r})=>{const n=await $({collectionId:r,editor:s});n&&(a({value:r}),U({editor:s,collection:n}),k({editor:s,collection:n,handleClick:u,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${P}`]:({setState:a})=>a({value:""})},onInput:({setState:a,value:r,editor:n})=>{const c=ne(n);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));a({value:r}),k({editor:n,collection:c,handleClick:u,collectionId:o,collectionFiltered:{...c,icons:i}})}}]}}function ie({collection:e,collectionFiltered:t,handleClick:o}){const{height:s=24,width:u=24,icons:p,prefix:a}=t||e,r=Object.entries(p).map(([n,c])=>({name:n,...c}),{});return{type:"column",className:`${N}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:n})=>({type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:T}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=n.body;const f=n.width||u,L=n.height||s;l.setAttribute("viewBox",`0 0 ${f} ${L}`),l.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const w=[["click",()=>{const d=l.cloneNode(!0);d.removeAttribute("style");const I=d.outerHTML;o({icon:I,collectionId:a,iconId:n.name}),i==null||i.runCommand(v.layoutRemove,{id:R})}],["pointerover",()=>{l.style.border="2px solid currentColor",l.style.padding="4px"}],["pointerout",()=>{l.style.border="",l.style.padding=""}]];return w.forEach(([d,I])=>l.addEventListener(d,I)),g(l),()=>{w.forEach(([d,I])=>l.removeEventListener(d,I)),T(l)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:_.Error}}function ce(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}return K(function(e,t={}){var l;const{Components:o,Blocks:s}=e,{collections:u,extendIconComponent:p=!0,licenseKey:a,block:r={}}=t,n="icon",c="iconify",i="Iconify",g="data-type-iconify",T={events:()=>({dblclick:"onActive"}),onActive(){oe({collectionIds:u,editor:e,component:this.model})}};if(o.addType(c,{block:r&&{label:i,media:A,content:{type:c},category:"Extra",activate:!0,...r},isComponent:f=>z(f,g),model:{defaults:{name:i,icon:A,droppable:!1,attributes:{[g]:!0},resizable:X,components:A,style:{width:"50px",height:"50px"},traits:[G()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:T}),p){const f=(l=o.getType(n))==null?void 0:l.model,[L,w,...d]=f.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[L,w,G(),...d]}},view:T})}V({editor:e,licenseKey:a,plan:J,pluginName:q,cleanup:()=>{s.remove(c),o.removeType(c)}})})});
|