@grapesjs/studio-sdk-plugins 1.0.21 → 1.0.22
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/animationComponent/components/Animation.d.ts +6 -0
- package/dist/animationComponent/components/AnimationGroup.d.ts +4 -0
- package/dist/animationComponent/index.cjs.d.ts +3 -0
- package/dist/animationComponent/index.cjs.js +507 -0
- package/dist/animationComponent/index.d.ts +3 -0
- package/dist/animationComponent/index.es.d.ts +3 -0
- package/dist/animationComponent/index.es.js +1111 -0
- package/dist/animationComponent/index.umd.js +507 -0
- package/dist/animationComponent/shared.d.ts +3 -0
- package/dist/animationComponent/types.d.ts +28 -0
- package/dist/animationComponent/typesSchema.d.ts +48 -0
- package/dist/animationComponent/utils.d.ts +19 -0
- package/dist/dataSourceEjs/EjsExporter.d.ts +13 -0
- package/dist/dataSourceEjs/EjsImporter.d.ts +29 -0
- package/dist/dataSourceEjs/index.cjs.d.ts +2 -2
- package/dist/dataSourceEjs/index.cjs.js +24 -3
- package/dist/dataSourceEjs/index.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.js +697 -114
- package/dist/dataSourceEjs/index.umd.js +24 -3
- package/dist/dataSourceEjs/shared.d.ts +3 -0
- package/dist/dataSourceEjs/types.d.ts +2 -2
- package/dist/dataSourceEjs/typesSchema.d.ts +3 -0
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +16 -0
- package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +20 -0
- package/dist/dataSourceHandlebars/helperImplementations.d.ts +1 -0
- package/dist/dataSourceHandlebars/index.cjs.js +20 -1
- package/dist/dataSourceHandlebars/index.es.js +401 -99
- package/dist/dataSourceHandlebars/index.umd.js +20 -1
- package/dist/dataSourceHandlebars/shared.d.ts +3 -0
- package/dist/dataSourceHandlebars/types.d.ts +2 -2
- package/dist/dataSourceHandlebars/typesSchema.d.ts +3 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +29 -29
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +64 -64
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +587 -51
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +4809 -3046
- package/dist/index.umd.js +584 -48
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +59 -59
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +136 -131
- package/dist/presetPrintable/index.umd.js +4 -4
- 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 +2 -2
- package/dist/rteTinyMce/index.es.js +67 -67
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +14 -14
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/utilsDataSources.d.ts +28 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +26 -26
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -1
- package/dist/dataSourceEjs/EjsStrategy.d.ts +0 -15
- package/dist/dataSourceHandlebars/HandlebarsStrategy.d.ts +0 -17
|
@@ -9,19 +9,19 @@ const x = "app.grapesjs.com", R = "app-stage.grapesjs.com", P = [
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
"-sandpack.codesandbox.io"
|
|
11
11
|
// For Sandpack demos
|
|
12
|
-
],
|
|
13
|
-
const e =
|
|
12
|
+
], j = "license:check:start", H = "license:check:end", B = () => typeof window < "u", C = ({ isDev: e, isStage: o }) => `${e ? "" : `https://${o ? R : x}`}/api`, F = () => {
|
|
13
|
+
const e = B() && window.location.hostname;
|
|
14
14
|
return !!e && (P.includes(e) || P.some((o) => e.endsWith(o)));
|
|
15
15
|
};
|
|
16
|
-
async function
|
|
16
|
+
async function W({
|
|
17
17
|
path: e,
|
|
18
18
|
baseApiUrl: o,
|
|
19
19
|
method: t = "GET",
|
|
20
20
|
headers: n = {},
|
|
21
|
-
params:
|
|
21
|
+
params: l,
|
|
22
22
|
body: g
|
|
23
23
|
}) {
|
|
24
|
-
const r = `${o ||
|
|
24
|
+
const r = `${o || C({ isDev: !1, isStage: !1 })}${e}`, s = {
|
|
25
25
|
method: t,
|
|
26
26
|
headers: {
|
|
27
27
|
"Content-Type": "application/json",
|
|
@@ -29,62 +29,62 @@ async function F({
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
g && (s.body = JSON.stringify(g));
|
|
32
|
-
const c =
|
|
32
|
+
const c = l ? new URLSearchParams(l).toString() : "", i = c ? `?${c}` : "", d = await fetch(`${r}${i}`, s);
|
|
33
33
|
if (!d.ok)
|
|
34
34
|
throw new Error(`HTTP error! status: ${d.status}`);
|
|
35
35
|
return d.json();
|
|
36
36
|
}
|
|
37
|
-
var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), f = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.setDragAbsolute = "studio:setDragAbsolute", e))(f || {});
|
|
37
|
+
var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), f = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.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))(f || {});
|
|
38
38
|
const k = {
|
|
39
39
|
[L.free]: 0,
|
|
40
40
|
[L.startup]: 10,
|
|
41
41
|
[L.business]: 20,
|
|
42
42
|
[L.enterprise]: 30
|
|
43
43
|
};
|
|
44
|
-
function
|
|
44
|
+
function m(e) {
|
|
45
45
|
const o = e;
|
|
46
46
|
return o.init = (t) => (n) => e(n, t), o;
|
|
47
47
|
}
|
|
48
|
-
const K = (e) => /* @__PURE__ */
|
|
49
|
-
async function
|
|
48
|
+
const K = (e) => /* @__PURE__ */ m(e);
|
|
49
|
+
async function S({
|
|
50
50
|
editor: e,
|
|
51
51
|
plan: o,
|
|
52
52
|
pluginName: t,
|
|
53
53
|
licenseKey: n,
|
|
54
|
-
cleanup:
|
|
54
|
+
cleanup: l
|
|
55
55
|
}) {
|
|
56
56
|
let g = "", u = !1;
|
|
57
|
-
const r =
|
|
58
|
-
console.warn("Cleanup plugin:", t, "Reason:", i),
|
|
57
|
+
const r = F(), s = (i) => {
|
|
58
|
+
console.warn("Cleanup plugin:", t, "Reason:", i), l();
|
|
59
59
|
}, c = (i = {}) => {
|
|
60
60
|
var y;
|
|
61
|
-
const { error: d, sdkLicense: h } = i,
|
|
61
|
+
const { error: d, sdkLicense: h } = i, a = (y = i.plan) == null ? void 0 : y.category;
|
|
62
62
|
if (!(h || i.license) || d)
|
|
63
63
|
s(d || "Invalid license");
|
|
64
|
-
else if (
|
|
65
|
-
const b = k[o], v = k[
|
|
66
|
-
b > v && s({ pluginRequiredPlan: o, licensePlan:
|
|
64
|
+
else if (a) {
|
|
65
|
+
const b = k[o], v = k[a];
|
|
66
|
+
b > v && s({ pluginRequiredPlan: o, licensePlan: a });
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
e.on(
|
|
69
|
+
e.on(j, (i) => {
|
|
70
70
|
g = i == null ? void 0 : i.baseApiUrl, u = !0;
|
|
71
|
-
}), e.on(
|
|
71
|
+
}), e.on(H, (i) => {
|
|
72
72
|
c(i);
|
|
73
73
|
}), setTimeout(async () => {
|
|
74
74
|
if (!u) {
|
|
75
75
|
if (r) return;
|
|
76
76
|
if (n) {
|
|
77
|
-
const i = await
|
|
77
|
+
const i = await V({ licenseKey: n, pluginName: t, baseApiUrl: g });
|
|
78
78
|
i && c(i);
|
|
79
79
|
} else
|
|
80
80
|
s("The `licenseKey` option not provided");
|
|
81
81
|
}
|
|
82
82
|
}, 2e3);
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function V(e) {
|
|
85
85
|
const { licenseKey: o, pluginName: t, baseApiUrl: n } = e;
|
|
86
86
|
try {
|
|
87
|
-
return (await
|
|
87
|
+
return (await W({
|
|
88
88
|
baseApiUrl: n,
|
|
89
89
|
path: `/sdk/${o || "na"}`,
|
|
90
90
|
method: "POST",
|
|
@@ -93,22 +93,22 @@ async function Y(e) {
|
|
|
93
93
|
pn: t
|
|
94
94
|
}
|
|
95
95
|
})).result || {};
|
|
96
|
-
} catch (
|
|
97
|
-
return console.error("Error during SDK license check:",
|
|
96
|
+
} catch (l) {
|
|
97
|
+
return console.error("Error during SDK license check:", l), !1;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const Y = (e, o) => {
|
|
101
101
|
var t;
|
|
102
102
|
return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, o));
|
|
103
|
-
},
|
|
103
|
+
}, z = "iconifyComponent", q = L.startup, J = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, w = `<svg viewBox="0 0 24 24">
|
|
104
104
|
<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",
|
|
105
|
+
</svg>`, $ = "layout-icon-picker", X = "icons-layout-", D = "icons-list-layout", M = "gs-iconify-picker", A = "__iconify_collection", Z = "https://api.iconify.design", I = /* @__PURE__ */ new Map();
|
|
106
106
|
let T;
|
|
107
|
-
const
|
|
107
|
+
const Q = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
|
|
108
108
|
async function N({ collectionId: e, editor: o }) {
|
|
109
109
|
try {
|
|
110
110
|
if (I.has(e)) return I.get(e);
|
|
111
|
-
const t = await fetch(
|
|
111
|
+
const t = await fetch(Q({ collectionId: e }));
|
|
112
112
|
if (!t.ok) throw new Error(`Failed to fetch collection: ${t.statusText}`);
|
|
113
113
|
const n = await t.json();
|
|
114
114
|
return I.set(e, n), n;
|
|
@@ -120,7 +120,7 @@ async function N({ collectionId: e, editor: o }) {
|
|
|
120
120
|
async function ee({ collectionIds: e, editor: o }) {
|
|
121
121
|
try {
|
|
122
122
|
if (T) return T;
|
|
123
|
-
const t = e ? `?prefixes=${e.join(",")}` : "", n = await fetch(`${
|
|
123
|
+
const t = e ? `?prefixes=${e.join(",")}` : "", n = await fetch(`${Z}/collections${t}`);
|
|
124
124
|
if (!n.ok) throw new Error(`Failed to fetch collections: ${n.statusText}`);
|
|
125
125
|
return T = await n.json(), T;
|
|
126
126
|
} catch (t) {
|
|
@@ -143,7 +143,7 @@ function O() {
|
|
|
143
143
|
async function te({ collectionIds: e, editor: o, component: t }) {
|
|
144
144
|
const n = await ee({ collectionIds: e, editor: o });
|
|
145
145
|
if (!n) return;
|
|
146
|
-
const
|
|
146
|
+
const l = ({ icon: s, collectionId: c, iconId: i }) => {
|
|
147
147
|
t.components(s), t.set({ collectionId: c, iconId: i });
|
|
148
148
|
}, g = Object.entries(n).map(([s, c]) => ({ id: s, ...c })).sort((s, c) => s.name.localeCompare(c.name)), u = t.get("collectionId") ?? g[0].id;
|
|
149
149
|
o.runCommand(f.layoutToggle, {
|
|
@@ -158,7 +158,7 @@ async function te({ collectionIds: e, editor: o, component: t }) {
|
|
|
158
158
|
collectionsList: g,
|
|
159
159
|
collectionId: u,
|
|
160
160
|
editor: o,
|
|
161
|
-
handleClick:
|
|
161
|
+
handleClick: l
|
|
162
162
|
}),
|
|
163
163
|
{ id: D, type: "column", grow: !0 }
|
|
164
164
|
]
|
|
@@ -168,7 +168,7 @@ async function te({ collectionIds: e, editor: o, component: t }) {
|
|
|
168
168
|
r && E({
|
|
169
169
|
editor: o,
|
|
170
170
|
collection: r,
|
|
171
|
-
handleClick:
|
|
171
|
+
handleClick: l,
|
|
172
172
|
collectionId: u
|
|
173
173
|
});
|
|
174
174
|
}
|
|
@@ -180,7 +180,7 @@ function ne(e) {
|
|
|
180
180
|
}
|
|
181
181
|
function E(e) {
|
|
182
182
|
const { editor: o } = e, t = {
|
|
183
|
-
id:
|
|
183
|
+
id: X,
|
|
184
184
|
layout: ie(e),
|
|
185
185
|
header: !1,
|
|
186
186
|
style: { height: "100%" },
|
|
@@ -189,7 +189,7 @@ function E(e) {
|
|
|
189
189
|
o.runCommand(f.layoutRemove, { id: t.id, force: !0 }), setTimeout(() => o.runCommand(f.layoutAdd, t), 10);
|
|
190
190
|
}
|
|
191
191
|
function se(e) {
|
|
192
|
-
const { collectionsList: o, collectionId: t, editor: n, handleClick:
|
|
192
|
+
const { collectionsList: o, collectionId: t, editor: n, handleClick: l } = e, g = o.map(({ id: u, name: r, total: s }) => ({ id: u, label: `${r} (${s})` })).sort((u, r) => u.label.localeCompare(r.label));
|
|
193
193
|
return {
|
|
194
194
|
type: "column",
|
|
195
195
|
style: { gap: 10 },
|
|
@@ -205,7 +205,7 @@ function se(e) {
|
|
|
205
205
|
s && (u({ value: r }), oe({ editor: n, collection: s }), E({
|
|
206
206
|
editor: n,
|
|
207
207
|
collection: s,
|
|
208
|
-
handleClick:
|
|
208
|
+
handleClick: l,
|
|
209
209
|
collectionId: r
|
|
210
210
|
}));
|
|
211
211
|
}
|
|
@@ -226,7 +226,7 @@ function se(e) {
|
|
|
226
226
|
u({ value: r }), E({
|
|
227
227
|
editor: s,
|
|
228
228
|
collection: c,
|
|
229
|
-
handleClick:
|
|
229
|
+
handleClick: l,
|
|
230
230
|
collectionId: r,
|
|
231
231
|
collectionFiltered: { ...c, icons: i }
|
|
232
232
|
});
|
|
@@ -240,7 +240,7 @@ function ie({
|
|
|
240
240
|
collectionFiltered: o,
|
|
241
241
|
handleClick: t
|
|
242
242
|
}) {
|
|
243
|
-
const { height: n = 24, width:
|
|
243
|
+
const { height: n = 24, width: l = 24, icons: g, prefix: u } = o || e, r = Object.entries(g).map(([s, { body: c }]) => ({ name: s, body: c }), {});
|
|
244
244
|
return {
|
|
245
245
|
type: "column",
|
|
246
246
|
className: `${M}__content`,
|
|
@@ -252,22 +252,22 @@ function ie({
|
|
|
252
252
|
{
|
|
253
253
|
type: "custom",
|
|
254
254
|
render: (c) => {
|
|
255
|
-
const { editor: i, addEl: d, removeEl: h } = c,
|
|
256
|
-
|
|
257
|
-
const { cssWidth: p, cssHeight: y } = ce(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}),
|
|
261
|
-
|
|
255
|
+
const { editor: i, addEl: d, removeEl: h } = c, a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
256
|
+
a.setAttribute("xmlns", "http://www.w3.org/2000/svg"), a.innerHTML = s.body, a.setAttribute("viewBox", `0 0 ${l} ${n}`);
|
|
257
|
+
const { cssWidth: p, cssHeight: y } = ce(l, n);
|
|
258
|
+
a.style.cssText = `width: ${p}px; height: ${y}px; cursor: pointer;`, a.addEventListener("mouseover", () => {
|
|
259
|
+
a.style.border = "2px solid currentColor", a.style.borderRadius = "4px", a.style.padding = "4px";
|
|
260
|
+
}), a.addEventListener("mouseout", () => {
|
|
261
|
+
a.style.border = "none";
|
|
262
262
|
});
|
|
263
263
|
const b = () => {
|
|
264
|
-
const v =
|
|
264
|
+
const v = a.cloneNode(!0);
|
|
265
265
|
v.removeAttribute("style");
|
|
266
|
-
const
|
|
267
|
-
t({ icon:
|
|
266
|
+
const G = v.outerHTML;
|
|
267
|
+
t({ icon: G, collectionId: u, iconId: s.name }), i == null || i.runCommand(f.layoutRemove, { id: $ });
|
|
268
268
|
};
|
|
269
|
-
return
|
|
270
|
-
|
|
269
|
+
return a.addEventListener("click", b), d(a), () => {
|
|
270
|
+
a.removeEventListener("click", b), h(a);
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -277,8 +277,8 @@ function ie({
|
|
|
277
277
|
}
|
|
278
278
|
function ce(e, o) {
|
|
279
279
|
const t = e / o;
|
|
280
|
-
let n = 48,
|
|
281
|
-
return t > 1 ?
|
|
280
|
+
let n = 48, l = 48;
|
|
281
|
+
return t > 1 ? l = 48 / t : t < 1 && (n = 48 * t), { cssWidth: n, cssHeight: l };
|
|
282
282
|
}
|
|
283
283
|
function U() {
|
|
284
284
|
return {
|
|
@@ -295,14 +295,14 @@ function re() {
|
|
|
295
295
|
content: "Error fetching collection"
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
const
|
|
299
|
-
var
|
|
300
|
-
const { Components: t, Blocks: n } = e, { collections:
|
|
298
|
+
const ae = function(e, o = {}) {
|
|
299
|
+
var a;
|
|
300
|
+
const { Components: t, Blocks: n } = e, { collections: l, extendIconComponent: g = !0, licenseKey: u, block: r = {} } = o, s = "icon", c = "iconify", i = "Iconify", d = "data-type-iconify", h = {
|
|
301
301
|
events: () => ({
|
|
302
302
|
dblclick: "onActive"
|
|
303
303
|
}),
|
|
304
304
|
onActive() {
|
|
305
|
-
te({ collectionIds:
|
|
305
|
+
te({ collectionIds: l, editor: e, component: this.model });
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
308
|
if (t.addType(c, {
|
|
@@ -314,14 +314,14 @@ const le = function(e, o = {}) {
|
|
|
314
314
|
activate: !0,
|
|
315
315
|
...r
|
|
316
316
|
},
|
|
317
|
-
isComponent: (p) =>
|
|
317
|
+
isComponent: (p) => Y(p, d),
|
|
318
318
|
model: {
|
|
319
319
|
defaults: {
|
|
320
320
|
name: i,
|
|
321
321
|
icon: w,
|
|
322
322
|
droppable: !1,
|
|
323
323
|
attributes: { [d]: !0 },
|
|
324
|
-
resizable:
|
|
324
|
+
resizable: J,
|
|
325
325
|
components: w,
|
|
326
326
|
style: { width: "50px", height: "50px" },
|
|
327
327
|
traits: [O()]
|
|
@@ -335,7 +335,7 @@ const le = function(e, o = {}) {
|
|
|
335
335
|
},
|
|
336
336
|
view: h
|
|
337
337
|
}), g) {
|
|
338
|
-
const p = (
|
|
338
|
+
const p = (a = t.getType(s)) == null ? void 0 : a.model, [y, b, ...v] = p.getDefaults().traits;
|
|
339
339
|
t.addType(s, {
|
|
340
340
|
model: {
|
|
341
341
|
defaults: {
|
|
@@ -345,16 +345,16 @@ const le = function(e, o = {}) {
|
|
|
345
345
|
view: h
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
-
|
|
348
|
+
S({
|
|
349
349
|
editor: e,
|
|
350
350
|
licenseKey: u,
|
|
351
|
-
plan:
|
|
352
|
-
pluginName:
|
|
351
|
+
plan: q,
|
|
352
|
+
pluginName: z,
|
|
353
353
|
cleanup: () => {
|
|
354
354
|
n.remove(c), t.removeType(c);
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
|
-
},
|
|
357
|
+
}, le = K(ae);
|
|
358
358
|
export {
|
|
359
|
-
|
|
359
|
+
le as default
|
|
360
360
|
};
|
|
@@ -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,y,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],G="license:check:start",j="license:check:end",H=()=>typeof window<"u",B=({isDev:e,isStage:o})=>`${e?"":`https://${o?y:h}`}/api`,C=()=>{const e=H()&&window.location.hostname;return!!e&&(x.includes(e)||x.some(o=>e.endsWith(o)))};async function m({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:a,body:d}){const r=`${o||B({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()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),O=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(O||{}),f=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.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))(f||{});const R={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function F(e){const o=e;return o.init=t=>n=>e(n,t),o}const W=e=>F(e);async function S({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:a}){let d="",u=!1;const r=C(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),a()},c=(i={})=>{var L;const{error:g,sdkLicense:v}=i,l=(L=i.plan)==null?void 0:L.category;if(!(v||i.license)||g)s(g||"Invalid license");else if(l){const T=R[o],w=R[l];T>w&&s({pluginRequiredPlan:o,licensePlan:l})}};e.on(G,i=>{d=i==null?void 0:i.baseApiUrl,u=!0}),e.on(j,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await K({licenseKey:n,pluginName:t,baseApiUrl:d});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function K(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await m({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 V=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},Y="iconifyComponent",z=b.startup,q={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},E=`<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>`,_="layout-icon-picker",
|
|
3
|
+
</svg>`,_="layout-icon-picker",J="icons-layout-",$="icons-list-layout",D="gs-iconify-picker",A="__iconify_collection",X="https://api.iconify.design",P=new Map;let I;const Z=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function M({collectionId:e,editor:o}){try{if(P.has(e))return P.get(e);const t=await fetch(Z({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return P.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(f.toastAdd,ce());return}}async function Q({collectionIds:e,editor:o}){try{if(I)return I;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${X}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return I=await n.json(),I}catch(t){console.error("Error fetching collections",t),o.runCommand(f.toastAdd,U());return}}function N(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function ee({collectionIds:e,editor:o,component:t}){const n=await Q({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(f.layoutToggle,{id:_,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[ne({collectionsList:d,collectionId:u,editor:o,handleClick:a}),{id:$,type:"column",grow:!0}]}});const r=await M({collectionId:u,editor:o});r&&k({editor:o,collection:r,handleClick:a,collectionId:u})}function te({editor:e,collection:o}){e.em.set(A,o)}function oe(e){return e.em.get(A)}function k(e){const{editor:o}=e,t={id:J,layout:se(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:$}};o.runCommand(f.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(f.layoutAdd,t),10)}function ne(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:`${D}__header`,children:[{type:"selectField",value:t,options:d,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await M({collectionId:r,editor:n});s&&(u({value:r}),te({editor:n,collection:s}),k({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=oe(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([g])=>g.includes(r)));u({value:r}),k({editor:s,collection:c,handleClick:a,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function se({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:`${D}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:g,removeEl:v}=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:L}=ie(a,n);l.style.cssText=`width: ${p}px; height: ${L}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 T=()=>{const w=l.cloneNode(!0);w.removeAttribute("style");const re=w.outerHTML;t({icon:re,collectionId:u,iconId:s.name}),i==null||i.runCommand(f.layoutRemove,{id:_})};return l.addEventListener("click",T),g(l),()=>{l.removeEventListener("click",T),v(l)}}}]}}}function ie(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 U(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:O.Error}}function ce(){return{...U(),id:"toast-error-getCollection",content:"Error fetching collection"}}return W(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",v={events:()=>({dblclick:"onActive"}),onActive(){ee({collectionIds:a,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:E,content:{type:c},category:"Extra",activate:!0,...r},isComponent:p=>V(p,g),model:{defaults:{name:i,icon:E,droppable:!1,attributes:{[g]:!0},resizable:q,components:E,style:{width:"50px",height:"50px"},traits:[N()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:v}),d){const p=(l=t.getType(s))==null?void 0:l.model,[L,T,...w]=p.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[L,T,N(),...w]}},view:v})}S({editor:e,licenseKey:u,plan:z,pluginName:Y,cleanup:()=>{n.remove(c),t.removeType(c)}})})});
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as lightGalleryComponent } from './lightGalleryComponent';
|
|
|
7
7
|
export { default as swiperComponent } from './swiperComponent';
|
|
8
8
|
export { default as accordionComponent } from './accordionComponent';
|
|
9
9
|
export { default as flexComponent } from './flexComponent';
|
|
10
|
+
export { default as animationComponent } from './animationComponent';
|
|
10
11
|
export { default as rteTinyMce } from './rteTinyMce';
|
|
11
12
|
export { default as rteProseMirror } from './prosemirror';
|
|
12
13
|
export { default as canvasEmptyState } from './canvasEmptyState';
|