@grapesjs/studio-sdk-plugins 1.0.36 → 1.0.38-rc.0
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 +4 -4
- package/dist/accordionComponent/index.es.js +83 -70
- package/dist/accordionComponent/index.umd.js +5 -5
- package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
- package/dist/aiChat/components/utils.d.ts +1 -0
- package/dist/aiChat/components/utilsTw.d.ts +11 -0
- package/dist/aiChat/index.cjs.js +85 -85
- package/dist/aiChat/index.es.js +11151 -10258
- package/dist/aiChat/index.js +85 -85
- package/dist/aiChat/index.umd.js +86 -86
- package/dist/aiChat/locales/en.d.ts +11 -0
- package/dist/aiChat/projectGeneration.d.ts +17 -0
- package/dist/aiChat/server/index.cjs.js +1 -1
- package/dist/aiChat/server/index.es.js +1 -1
- package/dist/aiChat/server/index.js +1 -1
- package/dist/aiChat/server/index.umd.js +1 -1
- package/dist/aiChat/types.d.ts +1 -1
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +57 -44
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +63 -50
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +60 -47
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +3 -3
- package/dist/canvasFullSize/index.es.js +49 -36
- package/dist/canvasFullSize/index.umd.js +5 -5
- package/dist/canvasGridMode/index.cjs.js +2 -2
- package/dist/canvasGridMode/index.es.js +251 -233
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +42 -29
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +3 -3
- package/dist/dataSourceEjs/index.es.js +51 -38
- package/dist/dataSourceEjs/index.umd.js +3 -3
- package/dist/dataSourceHandlebars/index.cjs.js +2 -2
- package/dist/dataSourceHandlebars/index.es.js +152 -139
- package/dist/dataSourceHandlebars/index.umd.js +4 -4
- package/dist/dialogComponent/index.cjs.js +9 -9
- package/dist/dialogComponent/index.es.js +73 -60
- package/dist/dialogComponent/index.umd.js +3 -3
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +83 -70
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +67 -54
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +92 -79
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +52 -39
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +42 -42
- package/dist/index.es.js +1167 -1149
- package/dist/index.umd.js +42 -42
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +82 -69
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +98 -85
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +71 -58
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +49 -36
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/presetPrintable/index.cjs.js +5 -5
- package/dist/presetPrintable/index.es.js +126 -113
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +97 -84
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +149 -137
- 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 +92 -79
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +3 -3
- package/dist/shapeDividerComponent/index.es.js +38 -25
- package/dist/shapeDividerComponent/index.umd.js +3 -3
- package/dist/swiperComponent/index.cjs.js +5 -5
- package/dist/swiperComponent/index.es.js +106 -93
- package/dist/swiperComponent/index.umd.js +5 -5
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +167 -154
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +35 -22
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -2
|
@@ -9,17 +9,30 @@ const k = "app.grapesjs.com", D = "app-stage.grapesjs.com", B = "app2.grapesjs.c
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
".local.webcontainer.io",
|
|
11
11
|
// For stackblitz.com demos
|
|
12
|
-
"-sandpack.codesandbox.io"
|
|
12
|
+
"-sandpack.codesandbox.io",
|
|
13
13
|
// For Sandpack demos
|
|
14
|
+
".claudemcpcontent.com",
|
|
15
|
+
// For Claude mcp app
|
|
16
|
+
".web-sandbox.oaiusercontent.com"
|
|
17
|
+
// For OpenAI mcp app
|
|
14
18
|
], F = "license:check:end", C = () => typeof window < "u", W = ({
|
|
15
19
|
isDev: e,
|
|
16
20
|
isStage: t,
|
|
17
21
|
isPlatform: o
|
|
18
22
|
}) => `${e ? "" : `https://${t ? D : k}`}/${o ? "platform-api" : "api"}`, K = () => {
|
|
19
|
-
|
|
23
|
+
if (!C()) return "";
|
|
24
|
+
const { hostname: e } = window.location;
|
|
25
|
+
if (e) return e;
|
|
26
|
+
try {
|
|
27
|
+
return window.parent.location.hostname || "";
|
|
28
|
+
} catch {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}, V = () => {
|
|
32
|
+
const e = K();
|
|
20
33
|
return !!e && (O.includes(e) || O.some((t) => e.endsWith(t)));
|
|
21
34
|
};
|
|
22
|
-
async function
|
|
35
|
+
async function m({
|
|
23
36
|
path: e,
|
|
24
37
|
baseApiUrl: t,
|
|
25
38
|
method: o = "GET",
|
|
@@ -40,7 +53,7 @@ async function V({
|
|
|
40
53
|
throw new Error(`HTTP error! status: ${r.status}`);
|
|
41
54
|
return r.json();
|
|
42
55
|
}
|
|
43
|
-
var w = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(w || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), y = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(y || {});
|
|
56
|
+
var w = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(w || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), y = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.openEditCode = "studio:openEditCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(y || {});
|
|
44
57
|
const x = {
|
|
45
58
|
[w.free]: 0,
|
|
46
59
|
[w.startup]: 10,
|
|
@@ -79,9 +92,9 @@ async function q({
|
|
|
79
92
|
};
|
|
80
93
|
if (!s) {
|
|
81
94
|
e.onReady(async () => {
|
|
82
|
-
if (!
|
|
95
|
+
if (!V())
|
|
83
96
|
if (i) {
|
|
84
|
-
const r = await
|
|
97
|
+
const r = await X({ licenseKey: i, pluginName: o, baseApiUrl: a });
|
|
85
98
|
p(r);
|
|
86
99
|
} else
|
|
87
100
|
n("The `licenseKey` option not provided");
|
|
@@ -101,10 +114,10 @@ const J = (e) => ({
|
|
|
101
114
|
error: e.licenseError,
|
|
102
115
|
plan: e.licensePlan
|
|
103
116
|
});
|
|
104
|
-
async function
|
|
117
|
+
async function X(e) {
|
|
105
118
|
const { licenseKey: t, pluginName: o, baseApiUrl: i } = e;
|
|
106
119
|
try {
|
|
107
|
-
return (await
|
|
120
|
+
return (await m({
|
|
108
121
|
baseApiUrl: i,
|
|
109
122
|
path: `/sdk/${t || "na"}`,
|
|
110
123
|
method: "POST",
|
|
@@ -117,30 +130,30 @@ async function m(e) {
|
|
|
117
130
|
return console.error("Error during SDK license check:", l), !1;
|
|
118
131
|
}
|
|
119
132
|
}
|
|
120
|
-
const
|
|
133
|
+
const Z = (e, t) => {
|
|
121
134
|
var o;
|
|
122
135
|
return !!((o = e == null ? void 0 : e.hasAttribute) != null && o.call(e, t));
|
|
123
|
-
},
|
|
136
|
+
}, Q = "iconifyComponent", S = w.startup, ee = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, E = `<svg viewBox="0 0 24 24">
|
|
124
137
|
<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" />
|
|
125
|
-
</svg>`, $ = "layout-icon-picker",
|
|
138
|
+
</svg>`, $ = "layout-icon-picker", te = "icons-layout-", G = "icons-list-layout", M = "gs-iconify-picker", A = "__iconify_collection", oe = "https://api.iconify.design", T = /* @__PURE__ */ new Map();
|
|
126
139
|
let L;
|
|
127
|
-
const
|
|
140
|
+
const ne = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
|
|
128
141
|
async function N({ collectionId: e, editor: t }) {
|
|
129
142
|
try {
|
|
130
|
-
if (
|
|
131
|
-
const o = await fetch(
|
|
143
|
+
if (T.has(e)) return T.get(e);
|
|
144
|
+
const o = await fetch(ne({ collectionId: e }));
|
|
132
145
|
if (!o.ok) throw new Error(`Failed to fetch collection: ${o.statusText}`);
|
|
133
146
|
const i = await o.json();
|
|
134
|
-
return
|
|
147
|
+
return T.set(e, i), i;
|
|
135
148
|
} catch (o) {
|
|
136
|
-
console.error("Error fetching collection", o), t.runCommand(y.toastAdd,
|
|
149
|
+
console.error("Error fetching collection", o), t.runCommand(y.toastAdd, le());
|
|
137
150
|
return;
|
|
138
151
|
}
|
|
139
152
|
}
|
|
140
|
-
async function
|
|
153
|
+
async function se({ collectionIds: e, editor: t }) {
|
|
141
154
|
try {
|
|
142
155
|
if (L) return L;
|
|
143
|
-
const o = e ? `?prefixes=${e.join(",")}` : "", i = await fetch(`${
|
|
156
|
+
const o = e ? `?prefixes=${e.join(",")}` : "", i = await fetch(`${oe}/collections${o}`);
|
|
144
157
|
if (!i.ok) throw new Error(`Failed to fetch collections: ${i.statusText}`);
|
|
145
158
|
return L = await i.json(), L;
|
|
146
159
|
} catch (o) {
|
|
@@ -160,8 +173,8 @@ function R() {
|
|
|
160
173
|
}
|
|
161
174
|
};
|
|
162
175
|
}
|
|
163
|
-
async function
|
|
164
|
-
const i = await
|
|
176
|
+
async function ie({ collectionIds: e, editor: t, component: o }) {
|
|
177
|
+
const i = await se({ collectionIds: e, editor: t });
|
|
165
178
|
if (!i) return;
|
|
166
179
|
const l = ({ icon: n, collectionId: c, iconId: p }) => {
|
|
167
180
|
o.components(n), o.set({ collectionId: c, iconId: p });
|
|
@@ -174,7 +187,7 @@ async function se({ collectionIds: e, editor: t, component: o }) {
|
|
|
174
187
|
type: "column",
|
|
175
188
|
style: { height: 500, gap: 10 },
|
|
176
189
|
children: [
|
|
177
|
-
|
|
190
|
+
ce({
|
|
178
191
|
collectionsList: g,
|
|
179
192
|
collectionId: a,
|
|
180
193
|
editor: t,
|
|
@@ -195,20 +208,20 @@ async function se({ collectionIds: e, editor: t, component: o }) {
|
|
|
195
208
|
function U({ editor: e, collection: t }) {
|
|
196
209
|
e.em.set(A, t);
|
|
197
210
|
}
|
|
198
|
-
function
|
|
211
|
+
function re(e) {
|
|
199
212
|
return e.em.get(A);
|
|
200
213
|
}
|
|
201
214
|
function P(e) {
|
|
202
215
|
const { editor: t } = e;
|
|
203
216
|
t.runCommand(y.layoutUpdate, {
|
|
204
|
-
id:
|
|
205
|
-
layout:
|
|
217
|
+
id: te,
|
|
218
|
+
layout: ae(e),
|
|
206
219
|
header: !1,
|
|
207
220
|
style: { height: "100%" },
|
|
208
221
|
placer: { type: "static", layoutId: G }
|
|
209
222
|
});
|
|
210
223
|
}
|
|
211
|
-
function
|
|
224
|
+
function ce(e) {
|
|
212
225
|
const { collectionsList: t, collectionId: o, editor: i, handleClick: l } = e, g = t.map(({ id: a, name: s, total: n }) => ({ id: a, label: `${s} (${n})` })).sort((a, s) => a.label.localeCompare(s.label));
|
|
213
226
|
return {
|
|
214
227
|
type: "column",
|
|
@@ -238,7 +251,7 @@ function re(e) {
|
|
|
238
251
|
[`change:${A}`]: ({ setState: a }) => a({ value: "" })
|
|
239
252
|
},
|
|
240
253
|
onInput: ({ setState: a, value: s, editor: n }) => {
|
|
241
|
-
const c =
|
|
254
|
+
const c = re(n);
|
|
242
255
|
if (!c) return;
|
|
243
256
|
const p = Object.fromEntries(
|
|
244
257
|
Object.entries(c.icons).filter(([r]) => r.includes(s))
|
|
@@ -255,7 +268,7 @@ function re(e) {
|
|
|
255
268
|
]
|
|
256
269
|
};
|
|
257
270
|
}
|
|
258
|
-
function
|
|
271
|
+
function ae({
|
|
259
272
|
collection: e,
|
|
260
273
|
collectionFiltered: t,
|
|
261
274
|
handleClick: o
|
|
@@ -314,41 +327,41 @@ function j() {
|
|
|
314
327
|
variant: _.Error
|
|
315
328
|
};
|
|
316
329
|
}
|
|
317
|
-
function
|
|
330
|
+
function le() {
|
|
318
331
|
return {
|
|
319
332
|
...j(),
|
|
320
333
|
id: "toast-error-getCollection",
|
|
321
334
|
content: "Error fetching collection"
|
|
322
335
|
};
|
|
323
336
|
}
|
|
324
|
-
const
|
|
337
|
+
const ue = function(e, t = {}) {
|
|
325
338
|
var u;
|
|
326
339
|
const { Components: o, Blocks: i } = e, { collections: l, extendIconComponent: g = !0, licenseKey: a, block: s = {} } = t, n = "icon", c = "iconify", p = "Iconify", r = "data-type-iconify", h = {
|
|
327
340
|
events: () => ({
|
|
328
341
|
dblclick: "onActive"
|
|
329
342
|
}),
|
|
330
343
|
onActive() {
|
|
331
|
-
|
|
344
|
+
ie({ collectionIds: l, editor: e, component: this.model });
|
|
332
345
|
}
|
|
333
346
|
};
|
|
334
347
|
if (o.addType(c, {
|
|
335
348
|
block: s && {
|
|
336
349
|
label: p,
|
|
337
|
-
media:
|
|
350
|
+
media: E,
|
|
338
351
|
content: { type: c },
|
|
339
352
|
category: "Extra",
|
|
340
353
|
activate: !0,
|
|
341
354
|
...s
|
|
342
355
|
},
|
|
343
|
-
isComponent: (d) =>
|
|
356
|
+
isComponent: (d) => Z(d, r),
|
|
344
357
|
model: {
|
|
345
358
|
defaults: {
|
|
346
359
|
name: p,
|
|
347
|
-
icon:
|
|
360
|
+
icon: E,
|
|
348
361
|
droppable: !1,
|
|
349
362
|
attributes: { [r]: !0 },
|
|
350
|
-
resizable:
|
|
351
|
-
components:
|
|
363
|
+
resizable: ee,
|
|
364
|
+
components: E,
|
|
352
365
|
style: { width: "50px", height: "50px" },
|
|
353
366
|
traits: [R()]
|
|
354
367
|
},
|
|
@@ -374,13 +387,13 @@ const le = function(e, t = {}) {
|
|
|
374
387
|
q({
|
|
375
388
|
editor: e,
|
|
376
389
|
licenseKey: a,
|
|
377
|
-
plan:
|
|
378
|
-
pluginName:
|
|
390
|
+
plan: S,
|
|
391
|
+
pluginName: Q,
|
|
379
392
|
cleanup: () => {
|
|
380
393
|
i.remove(c), o.removeType(c);
|
|
381
394
|
}
|
|
382
395
|
});
|
|
383
|
-
},
|
|
396
|
+
}, pe = z(ue);
|
|
384
397
|
export {
|
|
385
|
-
|
|
398
|
+
pe as default
|
|
386
399
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(I
|
|
1
|
+
(function(w,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(w=typeof globalThis<"u"?globalThis:w||self,w.StudioSdkPlugins_iconifyComponent=I())})(this,function(){"use strict";const w="app.grapesjs.com",I="app-stage.grapesjs.com",D=[w,"app2.grapesjs.com",I,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io",".claudemcpcontent.com",".web-sandbox.oaiusercontent.com"],B="license:check:end",H=()=>typeof window<"u",C=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?I:w}`}/${o?"platform-api":"api"}`,F=()=>{if(!H())return"";const{hostname:e}=window.location;if(e)return e;try{return window.parent.location.hostname||""}catch{return""}},W=()=>{const e=F();return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))};async function m({path:e,baseApiUrl:t,method:o="GET",headers:i={},params:l,body:d}){const s=`${t||C({isDev:!1,isStage:!1})}${e}`,n={method:o,headers:{"Content-Type":"application/json",...i}};d&&(n.body=JSON.stringify(d));const c=l?new URLSearchParams(l).toString():"",p=c?`?${c}`:"",r=await fetch(`${s}${p}`,n);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var T=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(T||{}),R=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(R||{}),y=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.openEditCode="studio:openEditCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(y||{});const _={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function K(e){const t=e;return t.init=o=>i=>e(i,o),t}const V=e=>K(e);async function Y({editor:e,plan:t,pluginName:o,licenseKey:i,onLicenseCheckResponse:l,cleanup:d}){let a="",s;const n=r=>{console.warn("Cleanup plugin:",o,"Reason:",r),d()},c=(r={})=>{var b;const{error:h,sdkLicense:u}=r,g=(b=r.plan)==null?void 0:b.category;if(!(u||r.license)||h)n(h||"Invalid license");else if(g){const f=_[t],v=_[g];f>v&&n({pluginRequiredPlan:t,licensePlan:g})}};e.Commands.has(y.settings)&&(s=e.runCommand(y.settings),a=(s==null?void 0:s.baseUrl)||"");const p=r=>{l==null||l(r),r&&c(r)};if(!s){e.onReady(async()=>{if(!W())if(i){const r=await q({licenseKey:i,pluginName:o,baseApiUrl:a});p(r)}else n("The `licenseKey` option not provided")});return}if(s.licensePlan||s.licenseError){const r=z(s);p(r);return}e.on(B,r=>p(r))}const z=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function q(e){const{licenseKey:t,pluginName:o,baseApiUrl:i}=e;try{return(await m({baseApiUrl:i,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const J=(e,t)=>{var o;return!!((o=e==null?void 0:e.hasAttribute)!=null&&o.call(e,t))},X="iconifyComponent",Z=T.startup,Q={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},P=`<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>`,k="layout-icon-picker",
|
|
3
|
+
</svg>`,k="layout-icon-picker",S="icons-layout-",M="icons-list-layout",$="gs-iconify-picker",A="__iconify_collection",ee="https://api.iconify.design",O=new Map;let E;const te=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function G({collectionId:e,editor:t}){try{if(O.has(e))return O.get(e);const o=await fetch(te({collectionId:e}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const i=await o.json();return O.set(e,i),i}catch(o){console.error("Error fetching collection",o),t.runCommand(y.toastAdd,ce());return}}async function oe({collectionIds:e,editor:t}){try{if(E)return E;const o=e?`?prefixes=${e.join(",")}`:"",i=await fetch(`${ee}/collections${o}`);if(!i.ok)throw new Error(`Failed to fetch collections: ${i.statusText}`);return E=await i.json(),E}catch(o){console.error("Error fetching collections",o),t.runCommand(y.toastAdd,j());return}}function N(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var t;(t=e.getSelected())==null||t.trigger("active")}}}async function ne({collectionIds:e,editor:t,component:o}){const i=await oe({collectionIds:e,editor:t});if(!i)return;const l=({icon:n,collectionId:c,iconId:p})=>{o.components(n),o.set({collectionId:c,iconId:p})},d=Object.entries(i).map(([n,c])=>({id:n,...c})).sort((n,c)=>n.name.localeCompare(c.name)),a=o.get("collectionId")??d[0].id;t.runCommand(y.layoutToggle,{id:k,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[ie({collectionsList:d,collectionId:a,editor:t,handleClick:l}),{id:M,type:"column",grow:!0}]}});const s=await G({collectionId:a,editor:t});s&&(U({editor:t,collection:s}),x({editor:t,collection:s,handleClick:l,collectionId:a}))}function U({editor:e,collection:t}){e.em.set(A,t)}function se(e){return e.em.get(A)}function x(e){const{editor:t}=e;t.runCommand(y.layoutUpdate,{id:S,layout:re(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:M}})}function ie(e){const{collectionsList:t,collectionId:o,editor:i,handleClick:l}=e,d=t.map(({id:a,name:s,total:n})=>({id:a,label:`${s} (${n})`})).sort((a,s)=>a.label.localeCompare(s.label));return{type:"column",style:{gap:10},className:`${$}__header`,children:[{type:"selectField",value:o,options:d,emptyState:"Select an icon collection",onChange:async({setState:a,value:s})=>{const n=await G({collectionId:s,editor:i});n&&(a({value:s}),U({editor:i,collection:n}),x({editor:i,collection:n,handleClick:l,collectionId:s}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${A}`]:({setState:a})=>a({value:""})},onInput:({setState:a,value:s,editor:n})=>{const c=se(n);if(!c)return;const p=Object.fromEntries(Object.entries(c.icons).filter(([r])=>r.includes(s)));a({value:s}),x({editor:n,collection:c,handleClick:l,collectionId:o,collectionFiltered:{...c,icons:p}})}}]}}function re({collection:e,collectionFiltered:t,handleClick:o}){const{height:i=24,width:l=24,icons:d,prefix:a}=t||e,s=Object.entries(d).map(([n,c])=>({name:n,...c}),{});return{type:"column",className:`${$}__content`,style:{height:"100%"},children:{type:"virtualList",items:s,itemLayout:({item:n})=>({type:"custom",render:c=>{const{editor:p,addEl:r,removeEl:h}=c,u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("xmlns","http://www.w3.org/2000/svg"),u.innerHTML=n.body;const g=n.width||l,L=n.height||i;u.setAttribute("viewBox",`0 0 ${g} ${L}`),u.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const b=[["click",()=>{const f=u.cloneNode(!0);f.removeAttribute("style");const v=f.outerHTML;o({icon:v,collectionId:a,iconId:n.name}),p==null||p.runCommand(y.layoutRemove,{id:k})}],["pointerover",()=>{u.style.border="2px solid currentColor",u.style.padding="4px"}],["pointerout",()=>{u.style.border="",u.style.padding=""}]];return b.forEach(([f,v])=>u.addEventListener(f,v)),r(u),()=>{b.forEach(([f,v])=>u.removeEventListener(f,v)),h(u)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:R.Error}}function ce(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}return V(function(e,t={}){var u;const{Components:o,Blocks:i}=e,{collections:l,extendIconComponent:d=!0,licenseKey:a,block:s={}}=t,n="icon",c="iconify",p="Iconify",r="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){ne({collectionIds:l,editor:e,component:this.model})}};if(o.addType(c,{block:s&&{label:p,media:P,content:{type:c},category:"Extra",activate:!0,...s},isComponent:g=>J(g,r),model:{defaults:{name:p,icon:P,droppable:!1,attributes:{[r]:!0},resizable:Q,components:P,style:{width:"50px",height:"50px"},traits:[N()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(g=>g.set({layerable:!1,locked:!0}))}},view:h}),d){const g=(u=o.getType(n))==null?void 0:u.model,[L,b,...f]=g.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[L,b,N(),...f]}},view:h})}Y({editor:e,licenseKey:a,plan:Z,pluginName:X,cleanup:()=>{i.remove(c),o.removeType(c)}})})});
|