@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- 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 +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
var p = /* @__PURE__ */ ((t) => (t.free = "free", t.startup = "startup", t.business = "business", t.enterprise = "enterprise", t))(p || {}), v = /* @__PURE__ */ ((t) => (t.toastAdd = "studio:toastAdd", t.toastRemove = "studio:toastRemove", t.dialogOpen = "studio:dialogOpen", t.dialogClose = "studio:dialogClose", t.dialogExportCode = "studio:dialogExportCode", t.sidebarLeftSet = "studio:sidebarLeft:set", t.sidebarLeftGet = "studio:sidebarLeft:get", t.sidebarLeftToggle = "studio:sidebarLeft:toggle", t.sidebarRightSet = "studio:sidebarRight:set", t.sidebarRightGet = "studio:sidebarRight:get", t.sidebarRightToggle = "studio:sidebarRight:toggle", t.sidebarTopSet = "studio:sidebarTop:set", t.sidebarTopGet = "studio:sidebarTop:get", t.sidebarTopToggle = "studio:sidebarTop:toggle", t.sidebarBottomSet = "studio:sidebarBottom:set", t.sidebarBottomGet = "studio:sidebarBottom:get", t.sidebarBottomToggle = "studio:sidebarBottom:toggle", t.symbolAdd = "studio:symbolAdd", t.symbolDetach = "studio:symbolDetach", t.symbolOverride = "studio:symbolOverride", t.symbolPropagateStyles = "studio:propagateStyles", t.getPagesConfig = "studio:getPagesConfig", t.setPagesConfig = "studio:setPagesConfig", t.getPageSettings = "studio:getPageSettings", t.setPageSettings = "studio:setPageSettings", t.clearPage = "studio:clearPage", t.projectFiles = "studio:projectFiles", t.validateCode = "studio:validateCode", t.canvasReload = "studio:canvasReload", t.getBlocksPanel = "studio:getBlocksPanel", t.setBlocksPanel = "studio:setBlocksPanel", t.getStateContextMenu = "studio:getStateContextMenu", t.setStateContextMenu = "studio:setStateContextMenu", t.contextMenuComponent = "studio:contextMenuComponent", t.layoutAdd = "studio:layoutAdd", t.layoutRemove = "studio:layoutRemove", t.layoutToggle = "studio:layoutToggle", t.layoutUpdate = "studio:layoutUpdate", t.layoutGet = "studio:layoutGet", t.layoutConfigGet = "studio:layoutConfigGet", t.layoutConfigSet = "studio:layoutConfigSet", t.layoutComponentAdd = "studio:layoutComponentAdd", t.layoutComponentGet = "studio:layoutComponentGet", t.layoutComponentRemove = "studio:layoutComponentRemove", t.layoutComponentRender = "studio:layoutComponentRender", t.getStateTheme = "studio:getStateTheme", t.setStateTheme = "studio:setStateTheme", t.assetProviderGet = "studio:assetProviderGet", t.assetProviderAdd = "studio:assetProviderAdd", t.assetProviderRemove = "studio:assetProviderRemove", t.fontGet = "studio:fontGet", t.fontAdd = "studio:fontAdd", t.fontRemove = "studio:fontRemove", t.fontManagerOpen = "studio:fontManagerOpen", t.menuFontLoad = "studio:menuFontLoad", t.toggleStateDataSource = "studio:toggleStateDataSource", t.getStateDataSource = "studio:getStateDataSource", t.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", t.dataSourceSetImporter = "studio:dataSourceSetImporter", t.dataSourceSetExporter = "studio:dataSourceSetExporter", t.setDragAbsolute = "studio:setDragAbsolute", t))(v || {});
|
|
2
|
+
const D = "app.grapesjs.com", G = "app-stage.grapesjs.com", I = "app2.grapesjs.com", $ = "app-stage2.grapesjs.com", w = [
|
|
3
|
+
D,
|
|
4
4
|
I,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
G,
|
|
6
|
+
$,
|
|
7
7
|
"localhost",
|
|
8
8
|
"127.0.0.1",
|
|
9
9
|
".local-credentialless.webcontainer.io",
|
|
@@ -12,141 +12,146 @@ const T = "app.grapesjs.com", x = "app-stage.grapesjs.com", I = "app2.grapesjs.c
|
|
|
12
12
|
// For stackblitz.com demos
|
|
13
13
|
"-sandpack.codesandbox.io"
|
|
14
14
|
// For Sandpack demos
|
|
15
|
-
],
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
], E = "license:check:start", M = "license:check:end", U = () => typeof window < "u", j = ({
|
|
16
|
+
isDev: t,
|
|
17
|
+
isStage: e,
|
|
18
|
+
isPlatform: s
|
|
19
|
+
}) => `${t ? "" : `https://${e ? G : D}`}/${s ? "platform-api" : "api"}`, N = () => {
|
|
20
|
+
const t = U() && window.location.hostname;
|
|
21
|
+
return !!t && (w.includes(t) || w.some((e) => t.endsWith(e)));
|
|
18
22
|
};
|
|
19
|
-
async function
|
|
20
|
-
path:
|
|
21
|
-
baseApiUrl:
|
|
23
|
+
async function B({
|
|
24
|
+
path: t,
|
|
25
|
+
baseApiUrl: e,
|
|
22
26
|
method: s = "GET",
|
|
23
|
-
headers:
|
|
24
|
-
params:
|
|
27
|
+
headers: a = {},
|
|
28
|
+
params: o,
|
|
25
29
|
body: r
|
|
26
30
|
}) {
|
|
27
|
-
const l = `${
|
|
31
|
+
const l = `${e || j({ isDev: !1, isStage: !1 })}${t}`, c = {
|
|
28
32
|
method: s,
|
|
29
33
|
headers: {
|
|
30
34
|
"Content-Type": "application/json",
|
|
31
|
-
...
|
|
35
|
+
...a
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
r && (c.body = JSON.stringify(r));
|
|
35
|
-
const u =
|
|
36
|
-
if (!
|
|
37
|
-
throw new Error(`HTTP error! status: ${
|
|
38
|
-
return
|
|
39
|
+
const u = o ? new URLSearchParams(o).toString() : "", g = u ? `?${u}` : "", n = await fetch(`${l}${g}`, c);
|
|
40
|
+
if (!n.ok)
|
|
41
|
+
throw new Error(`HTTP error! status: ${n.status}`);
|
|
42
|
+
return n.json();
|
|
39
43
|
}
|
|
40
|
-
const
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
44
|
+
const F = {
|
|
45
|
+
[p.free]: 0,
|
|
46
|
+
[p.startup]: 10,
|
|
47
|
+
[p.business]: 20,
|
|
48
|
+
[p.enterprise]: 30
|
|
45
49
|
};
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return
|
|
50
|
+
function k(t) {
|
|
51
|
+
const e = t;
|
|
52
|
+
return e.init = (s) => (a) => t(a, s), e;
|
|
49
53
|
}
|
|
50
|
-
const W = (
|
|
54
|
+
const W = (t) => /* @__PURE__ */ k(t);
|
|
51
55
|
async function _({
|
|
52
|
-
editor:
|
|
53
|
-
plan:
|
|
56
|
+
editor: t,
|
|
57
|
+
plan: e,
|
|
54
58
|
pluginName: s,
|
|
55
|
-
licenseKey:
|
|
56
|
-
|
|
59
|
+
licenseKey: a,
|
|
60
|
+
onLicenseCheckResponse: o,
|
|
61
|
+
cleanup: r
|
|
57
62
|
}) {
|
|
58
|
-
let
|
|
59
|
-
const
|
|
60
|
-
console.warn("Cleanup plugin:", s, "Reason:",
|
|
61
|
-
},
|
|
63
|
+
let i = "", l = !1;
|
|
64
|
+
const c = N(), u = (n) => {
|
|
65
|
+
console.warn("Cleanup plugin:", s, "Reason:", n), r();
|
|
66
|
+
}, g = (n = {}) => {
|
|
62
67
|
var A;
|
|
63
|
-
const { error:
|
|
64
|
-
if (!(f ||
|
|
65
|
-
|
|
66
|
-
else if (
|
|
67
|
-
const
|
|
68
|
-
|
|
68
|
+
const { error: d, sdkLicense: f } = n, b = (A = n.plan) == null ? void 0 : A.category;
|
|
69
|
+
if (!(f || n.license) || d)
|
|
70
|
+
u(d || "Invalid license");
|
|
71
|
+
else if (b) {
|
|
72
|
+
const O = F[e], R = F[b];
|
|
73
|
+
O > R && u({ pluginRequiredPlan: e, licensePlan: b });
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}),
|
|
74
|
-
|
|
76
|
+
t.on(E, (n) => {
|
|
77
|
+
i = n == null ? void 0 : n.baseApiUrl, l = !0;
|
|
78
|
+
}), t.on(M, (n) => {
|
|
79
|
+
o == null || o(n), g(n);
|
|
75
80
|
}), setTimeout(async () => {
|
|
76
|
-
if (!
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
+
if (!l) {
|
|
82
|
+
if (c) return;
|
|
83
|
+
if (a) {
|
|
84
|
+
const n = await K({ licenseKey: a, pluginName: s, baseApiUrl: i });
|
|
85
|
+
o == null || o(n), n && g(n);
|
|
81
86
|
} else
|
|
82
|
-
|
|
87
|
+
u("The `licenseKey` option not provided");
|
|
83
88
|
}
|
|
84
89
|
}, 2e3);
|
|
85
90
|
}
|
|
86
|
-
async function K(
|
|
87
|
-
const { licenseKey:
|
|
91
|
+
async function K(t) {
|
|
92
|
+
const { licenseKey: e, pluginName: s, baseApiUrl: a } = t;
|
|
88
93
|
try {
|
|
89
|
-
return (await
|
|
90
|
-
baseApiUrl:
|
|
91
|
-
path: `/sdk/${
|
|
94
|
+
return (await B({
|
|
95
|
+
baseApiUrl: a,
|
|
96
|
+
path: `/sdk/${e || "na"}`,
|
|
92
97
|
method: "POST",
|
|
93
98
|
params: {
|
|
94
99
|
d: window.location.hostname,
|
|
95
100
|
pn: s
|
|
96
101
|
}
|
|
97
102
|
})).result || {};
|
|
98
|
-
} catch (
|
|
99
|
-
return console.error("Error during SDK license check:",
|
|
103
|
+
} catch (o) {
|
|
104
|
+
return console.error("Error during SDK license check:", o), !1;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
const { menuVariant: s, variants:
|
|
107
|
+
const y = (t) => t.replaceAll('"', "").replaceAll("'", ""), P = (t) => t.includes(",") ? t : /\s/.test(t) ? `'${y(t)}'` : y(t), T = (t, e, s) => ({ family: t, variant: e, ...s }), L = (t, e) => {
|
|
108
|
+
t = P(t);
|
|
109
|
+
const { menuVariant: s, variants: a } = e;
|
|
105
110
|
return {
|
|
106
|
-
family:
|
|
107
|
-
familyLabel:
|
|
108
|
-
menuVariant: s &&
|
|
109
|
-
|
|
111
|
+
family: t,
|
|
112
|
+
familyLabel: y(t),
|
|
113
|
+
menuVariant: s && T(
|
|
114
|
+
P(`menuFont-${y(t)}`),
|
|
110
115
|
"regular",
|
|
111
116
|
s
|
|
112
117
|
),
|
|
113
118
|
variants: Object.assign(
|
|
114
119
|
{},
|
|
115
|
-
...Object.entries(
|
|
116
|
-
[
|
|
120
|
+
...Object.entries(a).map(([o, r]) => ({
|
|
121
|
+
[o]: T(t, o, r)
|
|
117
122
|
}))
|
|
118
123
|
)
|
|
119
124
|
};
|
|
120
|
-
},
|
|
125
|
+
}, x = (t, e) => {
|
|
121
126
|
var l;
|
|
122
|
-
const s =
|
|
123
|
-
if (!
|
|
127
|
+
const s = L(t.family, t), a = s.menuVariant ?? ((l = Object.values(s.variants)) == null ? void 0 : l[0]);
|
|
128
|
+
if (!a)
|
|
124
129
|
return "Arial, Helvetica, sans-serif";
|
|
125
|
-
const { source:
|
|
126
|
-
if (!
|
|
127
|
-
const c = new FontFace(i, `url("${
|
|
128
|
-
for (const
|
|
129
|
-
document.fonts.delete(
|
|
130
|
+
const { source: o, descriptors: r } = a, i = y(a.family);
|
|
131
|
+
if (!e) {
|
|
132
|
+
const c = new FontFace(i, `url("${o}")`, r), u = Array.from(document.fonts.values()).filter((g) => g.family === i);
|
|
133
|
+
for (const g of u)
|
|
134
|
+
document.fonts.delete(g);
|
|
130
135
|
document.fonts.add(c), c.load().catch(() => {
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
|
-
return
|
|
134
|
-
}, V = (
|
|
135
|
-
const { family:
|
|
138
|
+
return P(i);
|
|
139
|
+
}, V = (t) => {
|
|
140
|
+
const { family: e, menu: s, axes: a } = t, o = !!a, r = Object.assign(
|
|
136
141
|
{},
|
|
137
|
-
...
|
|
138
|
-
var
|
|
142
|
+
...t.variants.map((i) => {
|
|
143
|
+
var g, n;
|
|
139
144
|
let l, c;
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
const { start:
|
|
144
|
-
l = `${
|
|
145
|
+
if (o) {
|
|
146
|
+
const d = a.find((f) => f.tag === "wght");
|
|
147
|
+
if (d) {
|
|
148
|
+
const { start: f, end: b } = d;
|
|
149
|
+
l = `${f} ${b}`;
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
|
-
return l || (l = ((
|
|
152
|
+
return l || (l = ((g = i.match(/\d+/)) == null ? void 0 : g[0]) ?? "400"), c = ((n = i.match(/[a-zA-Z]+/)) == null ? void 0 : n[0]) === "italic" ? "italic" : void 0, {
|
|
148
153
|
[i]: {
|
|
149
|
-
source:
|
|
154
|
+
source: t.files[i],
|
|
150
155
|
descriptors: {
|
|
151
156
|
style: c,
|
|
152
157
|
weight: l
|
|
@@ -155,60 +160,60 @@ const b = (e) => e.replaceAll('"', "").replaceAll("'", ""), v = (e) => e.include
|
|
|
155
160
|
};
|
|
156
161
|
})
|
|
157
162
|
);
|
|
158
|
-
return
|
|
163
|
+
return L(e, {
|
|
159
164
|
menuVariant: {
|
|
160
165
|
source: s
|
|
161
166
|
},
|
|
162
167
|
variants: r
|
|
163
168
|
});
|
|
164
|
-
}, H = (
|
|
165
|
-
id: `${
|
|
169
|
+
}, H = (t) => ({
|
|
170
|
+
id: `${t.family}/${t.version}`,
|
|
166
171
|
type: "font",
|
|
167
|
-
src:
|
|
168
|
-
name:
|
|
169
|
-
customData: { font: V(
|
|
170
|
-
}), z = (
|
|
171
|
-
const { font:
|
|
172
|
-
return
|
|
172
|
+
src: t.menu,
|
|
173
|
+
name: t.family,
|
|
174
|
+
customData: { font: V(t), needsLoading: !0 }
|
|
175
|
+
}), z = (t) => {
|
|
176
|
+
const { font: e } = t.customData;
|
|
177
|
+
return t.customData.needsLoading ? (t.customData.needsLoading = !1, x(e)) : x(e, !0);
|
|
173
178
|
};
|
|
174
179
|
let h;
|
|
175
|
-
const q = (
|
|
176
|
-
const
|
|
177
|
-
for (const s of Object.keys(
|
|
178
|
-
let
|
|
179
|
-
|
|
180
|
+
const q = (t) => {
|
|
181
|
+
const e = [];
|
|
182
|
+
for (const s of Object.keys(t)) {
|
|
183
|
+
let a = t[s];
|
|
184
|
+
a && (Array.isArray(a) ? e.push(...a.map((o) => [s, o.toString()])) : (a = a.toString(), e.push([s, a])));
|
|
180
185
|
}
|
|
181
|
-
return new URLSearchParams(
|
|
182
|
-
}, S = (
|
|
183
|
-
const { apiKey:
|
|
184
|
-
const r = "https://www.googleapis.com/webfonts/v1/webfonts", i = q(
|
|
186
|
+
return new URLSearchParams(e);
|
|
187
|
+
}, S = (t) => {
|
|
188
|
+
const { apiKey: e, searchParams: s } = t, a = (o = {}) => {
|
|
189
|
+
const r = "https://www.googleapis.com/webfonts/v1/webfonts", i = q(o);
|
|
185
190
|
return `${r}?${i}`;
|
|
186
191
|
};
|
|
187
192
|
return {
|
|
188
193
|
id: "google-fonts",
|
|
189
194
|
types: ["font"],
|
|
190
|
-
label: ({ editor:
|
|
195
|
+
label: ({ editor: o }) => o.I18n.t("googleFontsAssetProvider.providerLabel"),
|
|
191
196
|
search: { reloadOnInput: !1 },
|
|
192
197
|
async onLoad() {
|
|
193
198
|
var u;
|
|
194
199
|
if (h)
|
|
195
200
|
return h;
|
|
196
|
-
const
|
|
197
|
-
key:
|
|
201
|
+
const o = {
|
|
202
|
+
key: e,
|
|
198
203
|
sort: "alpha",
|
|
199
204
|
subset: "latin",
|
|
200
205
|
capability: ["WOFF2", "VF"]
|
|
201
206
|
}, r = s == null ? void 0 : s(), i = {
|
|
202
|
-
...
|
|
207
|
+
...o,
|
|
203
208
|
...r
|
|
204
|
-
}, c = await (await fetch(
|
|
209
|
+
}, c = await (await fetch(a(i))).json();
|
|
205
210
|
return (u = c.items) != null && u.length ? (h = c.items.map(H), h) : [];
|
|
206
211
|
},
|
|
207
|
-
itemLayout: (
|
|
208
|
-
const r = h.find((l) => l.id ===
|
|
212
|
+
itemLayout: (o) => {
|
|
213
|
+
const r = h.find((l) => l.id === o.assetProps.id), i = z(r);
|
|
209
214
|
return {
|
|
210
215
|
type: "column",
|
|
211
|
-
onClick: () =>
|
|
216
|
+
onClick: () => o.onSelect(r),
|
|
212
217
|
htmlAttrs: {
|
|
213
218
|
title: r.name
|
|
214
219
|
},
|
|
@@ -254,21 +259,21 @@ const q = (e) => {
|
|
|
254
259
|
modalTitle: "Select Font",
|
|
255
260
|
providerLabel: "Google Fonts"
|
|
256
261
|
}
|
|
257
|
-
}, Q = "googleFontsAssetProvider", Z =
|
|
258
|
-
const { i18n: s = {} } =
|
|
259
|
-
|
|
262
|
+
}, Q = "googleFontsAssetProvider", Z = p.startup, X = function(t, e) {
|
|
263
|
+
const { i18n: s = {} } = e, a = S(e);
|
|
264
|
+
t.runCommand(v.assetProviderAdd, { provider: a }), t.I18n.addMessages({
|
|
260
265
|
en: J,
|
|
261
266
|
...s
|
|
262
267
|
}), _({
|
|
263
|
-
editor:
|
|
264
|
-
licenseKey:
|
|
268
|
+
editor: t,
|
|
269
|
+
licenseKey: e.licenseKey,
|
|
265
270
|
plan: Z,
|
|
266
271
|
pluginName: Q,
|
|
267
272
|
cleanup: () => {
|
|
268
|
-
|
|
273
|
+
t.runCommand(v.assetProviderRemove, { id: a.id });
|
|
269
274
|
}
|
|
270
275
|
});
|
|
271
|
-
},
|
|
276
|
+
}, m = W(X);
|
|
272
277
|
export {
|
|
273
|
-
|
|
278
|
+
m as default
|
|
274
279
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,p){typeof exports=="object"&&typeof module<"u"?module.exports=p():typeof define=="function"&&define.amd?define(p):(g=typeof globalThis<"u"?globalThis:g||self,g.StudioSdkPlugins_googleFontsAssetProvider=p())})(this,function(){"use strict";var g=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(g||{}),p=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",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.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))(p||{});const A="app.grapesjs.com",w="app-stage.grapesjs.com",T=[A,"app2.grapesjs.com",w,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",R="license:check:end",I=()=>typeof window<"u",$=({isDev:e,isStage:t,isPlatform:s})=>`${e?"":`https://${t?w:A}`}/${s?"platform-api":"api"}`,E=()=>{const e=I()&&window.location.hostname;return!!e&&(T.includes(e)||T.some(t=>e.endsWith(t)))};async function M({path:e,baseApiUrl:t,method:s="GET",headers:n={},params:o,body:r}){const l=`${t||$({isDev:!1,isStage:!1})}${e}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=o?new URLSearchParams(o).toString():"",d=u?`?${u}`:"",a=await fetch(`${l}${d}`,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}const F={[g.free]:0,[g.startup]:10,[g.business]:20,[g.enterprise]:30};function U(e){const t=e;return t.init=s=>n=>e(n,s),t}const j=e=>U(e);async function N({editor:e,plan:t,pluginName:s,licenseKey:n,onLicenseCheckResponse:o,cleanup:r}){let i="",l=!1;const c=E(),u=a=>{console.warn("Cleanup plugin:",s,"Reason:",a),r()},d=(a={})=>{var G;const{error:f,sdkLicense:y}=a,v=(G=a.plan)==null?void 0:G.category;if(!(y||a.license)||f)u(f||"Invalid license");else if(v){const q=F[t],J=F[v];q>J&&u({pluginRequiredPlan:t,licensePlan:v})}};e.on(L,a=>{i=a==null?void 0:a.baseApiUrl,l=!0}),e.on(R,a=>{o==null||o(a),d(a)}),setTimeout(async()=>{if(!l){if(c)return;if(n){const a=await _({licenseKey:n,pluginName:s,baseApiUrl:i});o==null||o(a),a&&d(a)}else u("The `licenseKey` option not provided")}},2e3)}async function _(e){const{licenseKey:t,pluginName:s,baseApiUrl:n}=e;try{return(await M({baseApiUrl:n,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const b=e=>e.replaceAll('"',"").replaceAll("'",""),P=e=>e.includes(",")?e:/\s/.test(e)?`'${b(e)}'`:b(e),x=(e,t,s)=>({family:e,variant:t,...s}),D=(e,t)=>{e=P(e);const{menuVariant:s,variants:n}=t;return{family:e,familyLabel:b(e),menuVariant:s&&x(P(`menuFont-${b(e)}`),"regular",s),variants:Object.assign({},...Object.entries(n).map(([o,r])=>({[o]:x(e,o,r)})))}},O=(e,t)=>{var l;const s=D(e.family,e),n=s.menuVariant??((l=Object.values(s.variants))==null?void 0:l[0]);if(!n)return"Arial, Helvetica, sans-serif";const{source:o,descriptors:r}=n,i=b(n.family);if(!t){const c=new FontFace(i,`url("${o}")`,r),u=Array.from(document.fonts.values()).filter(d=>d.family===i);for(const d of u)document.fonts.delete(d);document.fonts.add(c),c.load().catch(()=>{})}return P(i)},B=e=>{const{family:t,menu:s,axes:n}=e,o=!!n,r=Object.assign({},...e.variants.map(i=>{var d,a;let l,c;if(o){const f=n.find(y=>y.tag==="wght");if(f){const{start:y,end:v}=f;l=`${y} ${v}`}}return l||(l=((d=i.match(/\d+/))==null?void 0:d[0])??"400"),c=((a=i.match(/[a-zA-Z]+/))==null?void 0:a[0])==="italic"?"italic":void 0,{[i]:{source:e.files[i],descriptors:{style:c,weight:l}}}}));return D(t,{menuVariant:{source:s},variants:r})},k=e=>({id:`${e.family}/${e.version}`,type:"font",src:e.menu,name:e.family,customData:{font:B(e),needsLoading:!0}}),W=e=>{const{font:t}=e.customData;return e.customData.needsLoading?(e.customData.needsLoading=!1,O(t)):O(t,!0)};let h;const K=e=>{const t=[];for(const s of Object.keys(e)){let n=e[s];n&&(Array.isArray(n)?t.push(...n.map(o=>[s,o.toString()])):(n=n.toString(),t.push([s,n])))}return new URLSearchParams(t)},V=e=>{const{apiKey:t,searchParams:s}=e,n=(o={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=K(o);return`${r}?${i}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var u;if(h)return h;const o={key:t,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},r=s==null?void 0:s(),i={...o,...r},c=await(await fetch(n(i))).json();return(u=c.items)!=null&&u.length?(h=c.items.map(k),h):[]},itemLayout:o=>{const r=h.find(l=>l.id===o.assetProps.id),i=W(r);return{type:"column",onClick:()=>o.onSelect(r),htmlAttrs:{title:r.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}},{type:"text",content:r.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"16px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},S={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},H="googleFontsAssetProvider",z=g.startup;return j(function(e,t){const{i18n:s={}}=t,n=V(t);e.runCommand(p.assetProviderAdd,{provider:n}),e.I18n.addMessages({en:S,...s}),N({editor:e,licenseKey:t.licenseKey,plan:z,pluginName:H,cleanup:()=>{e.runCommand(p.assetProviderRemove,{id:n.id})}})})});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const D="app.grapesjs.com",$="app-stage.grapesjs.com",B="app2.grapesjs.com",H="app-stage2.grapesjs.com",O=[D,B,$,H,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],F="license:check:start",W="license:check:end",K=()=>typeof window<"u",C=({isDev:t,isStage:e,isPlatform:o})=>`${t?"":`https://${e?$:D}`}/${o?"platform-api":"api"}`,V=()=>{const t=K()&&window.location.hostname;return!!t&&(O.includes(t)||O.some(e=>t.endsWith(e)))};async function Y({path:t,baseApiUrl:e,method:o="GET",headers:s={},params:a,body:p}){const c=`${e||C({isDev:!1,isStage:!1})}${t}`,n={method:o,headers:{"Content-Type":"application/json",...s}};p&&(n.body=JSON.stringify(p));const r=a?new URLSearchParams(a).toString():"",g=r?`?${r}`:"",i=await fetch(`${c}${g}`,n);if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.json()}var v=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(v||{}),k=(t=>(t.Info="info",t.Error="error",t.Success="success",t.Warning="warning",t))(k||{}),w=(t=>(t.toastAdd="studio:toastAdd",t.toastRemove="studio:toastRemove",t.dialogOpen="studio:dialogOpen",t.dialogClose="studio:dialogClose",t.dialogExportCode="studio:dialogExportCode",t.sidebarLeftSet="studio:sidebarLeft:set",t.sidebarLeftGet="studio:sidebarLeft:get",t.sidebarLeftToggle="studio:sidebarLeft:toggle",t.sidebarRightSet="studio:sidebarRight:set",t.sidebarRightGet="studio:sidebarRight:get",t.sidebarRightToggle="studio:sidebarRight:toggle",t.sidebarTopSet="studio:sidebarTop:set",t.sidebarTopGet="studio:sidebarTop:get",t.sidebarTopToggle="studio:sidebarTop:toggle",t.sidebarBottomSet="studio:sidebarBottom:set",t.sidebarBottomGet="studio:sidebarBottom:get",t.sidebarBottomToggle="studio:sidebarBottom:toggle",t.symbolAdd="studio:symbolAdd",t.symbolDetach="studio:symbolDetach",t.symbolOverride="studio:symbolOverride",t.symbolPropagateStyles="studio:propagateStyles",t.getPagesConfig="studio:getPagesConfig",t.setPagesConfig="studio:setPagesConfig",t.getPageSettings="studio:getPageSettings",t.setPageSettings="studio:setPageSettings",t.clearPage="studio:clearPage",t.projectFiles="studio:projectFiles",t.validateCode="studio:validateCode",t.canvasReload="studio:canvasReload",t.getBlocksPanel="studio:getBlocksPanel",t.setBlocksPanel="studio:setBlocksPanel",t.getStateContextMenu="studio:getStateContextMenu",t.setStateContextMenu="studio:setStateContextMenu",t.contextMenuComponent="studio:contextMenuComponent",t.layoutAdd="studio:layoutAdd",t.layoutRemove="studio:layoutRemove",t.layoutToggle="studio:layoutToggle",t.layoutUpdate="studio:layoutUpdate",t.layoutGet="studio:layoutGet",t.layoutConfigGet="studio:layoutConfigGet",t.layoutConfigSet="studio:layoutConfigSet",t.layoutComponentAdd="studio:layoutComponentAdd",t.layoutComponentGet="studio:layoutComponentGet",t.layoutComponentRemove="studio:layoutComponentRemove",t.layoutComponentRender="studio:layoutComponentRender",t.getStateTheme="studio:getStateTheme",t.setStateTheme="studio:setStateTheme",t.assetProviderGet="studio:assetProviderGet",t.assetProviderAdd="studio:assetProviderAdd",t.assetProviderRemove="studio:assetProviderRemove",t.fontGet="studio:fontGet",t.fontAdd="studio:fontAdd",t.fontRemove="studio:fontRemove",t.fontManagerOpen="studio:fontManagerOpen",t.menuFontLoad="studio:menuFontLoad",t.toggleStateDataSource="studio:toggleStateDataSource",t.getStateDataSource="studio:getStateDataSource",t.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",t.dataSourceSetImporter="studio:dataSourceSetImporter",t.dataSourceSetExporter="studio:dataSourceSetExporter",t.setDragAbsolute="studio:setDragAbsolute",t))(w||{});const x={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function z(t){const e=t;return e.init=o=>s=>t(s,o),e}const q=t=>z(t);async function J({editor:t,plan:e,pluginName:o,licenseKey:s,onLicenseCheckResponse:a,cleanup:p}){let l="",c=!1;const n=V(),r=i=>{console.warn("Cleanup plugin:",o,"Reason:",i),p()},g=(i={})=>{var h;const{error:f,sdkLicense:u}=i,d=(h=i.plan)==null?void 0:h.category;if(!(u||i.license)||f)r(f||"Invalid license");else if(d){const y=x[e],b=x[d];y>b&&r({pluginRequiredPlan:e,licensePlan:d})}};t.on(F,i=>{l=i==null?void 0:i.baseApiUrl,c=!0}),t.on(W,i=>{a==null||a(i),g(i)}),setTimeout(async()=>{if(!c){if(n)return;if(s){const i=await X({licenseKey:s,pluginName:o,baseApiUrl:l});a==null||a(i),i&&g(i)}else r("The `licenseKey` option not provided")}},2e3)}async function X(t){const{licenseKey:e,pluginName:o,baseApiUrl:s}=t;try{return(await Y({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const Z=(t,e)=>{var o;return!!((o=t==null?void 0:t.hasAttribute)!=null&&o.call(t,e))},m="iconifyComponent",Q=v.startup,S={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
|
|
3
|
+
</svg>`,G="layout-icon-picker",tt="icons-layout-",M="icons-list-layout",N="gs-iconify-picker",P="__iconify_collection",et="https://api.iconify.design",A=new Map;let I;const ot=({collectionId:t})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${t}@latest/icons.json`;async function R({collectionId:t,editor:e}){try{if(A.has(t))return A.get(t);const o=await fetch(ot({collectionId:t}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const s=await o.json();return A.set(t,s),s}catch(o){console.error("Error fetching collection",o),e.runCommand(w.toastAdd,at());return}}async function nt({collectionIds:t,editor:e}){try{if(I)return I;const o=t?`?prefixes=${t.join(",")}`:"",s=await fetch(`${et}/collections${o}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return I=await s.json(),I}catch(o){console.error("Error fetching collections",o),e.runCommand(w.toastAdd,j());return}}function _(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(t){var e;(e=t.getSelected())==null||e.trigger("active")}}}async function st({collectionIds:t,editor:e,component:o}){const s=await nt({collectionIds:t,editor:e});if(!s)return;const a=({icon:n,collectionId:r,iconId:g})=>{o.components(n),o.set({collectionId:r,iconId:g})},p=Object.entries(s).map(([n,r])=>({id:n,...r})).sort((n,r)=>n.name.localeCompare(r.name)),l=o.get("collectionId")??p[0].id;e.runCommand(w.layoutToggle,{id:G,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[rt({collectionsList:p,collectionId:l,editor:e,handleClick:a}),{id:M,type:"column",grow:!0}]}});const c=await R({collectionId:l,editor:e});c&&(U({editor:e,collection:c}),L({editor:e,collection:c,handleClick:a,collectionId:l}))}function U({editor:t,collection:e}){t.em.set(P,e)}function it(t){return t.em.get(P)}function L(t){const{editor:e}=t;e.runCommand(w.layoutUpdate,{id:tt,layout:ct(t),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:M}})}function rt(t){const{collectionsList:e,collectionId:o,editor:s,handleClick:a}=t,p=e.map(({id:l,name:c,total:n})=>({id:l,label:`${c} (${n})`})).sort((l,c)=>l.label.localeCompare(c.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:l,value:c})=>{const n=await R({collectionId:c,editor:s});n&&(l({value:c}),U({editor:s,collection:n}),L({editor:s,collection:n,handleClick:a,collectionId:c}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${P}`]:({setState:l})=>l({value:""})},onInput:({setState:l,value:c,editor:n})=>{const r=it(n);if(!r)return;const g=Object.fromEntries(Object.entries(r.icons).filter(([i])=>i.includes(c)));l({value:c}),L({editor:n,collection:r,handleClick:a,collectionId:o,collectionFiltered:{...r,icons:g}})}}]}}function ct({collection:t,collectionFiltered:e,handleClick:o}){const{height:s=24,width:a=24,icons:p,prefix:l}=e||t,c=Object.entries(p).map(([n,r])=>({name:n,...r}),{});return{type:"column",className:`${N}__content`,style:{height:"100%"},children:{type:"virtualList",items:c,itemLayout:({item:n})=>({type:"custom",render:r=>{const{editor:g,addEl:i,removeEl:f}=r,u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("xmlns","http://www.w3.org/2000/svg"),u.innerHTML=n.body;const d=n.width||a,T=n.height||s;u.setAttribute("viewBox",`0 0 ${d} ${T}`),u.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const h=[["click",()=>{const y=u.cloneNode(!0);y.removeAttribute("style");const b=y.outerHTML;o({icon:b,collectionId:l,iconId:n.name}),g==null||g.runCommand(w.layoutRemove,{id:G})}],["pointerover",()=>{u.style.border="2px solid currentColor",u.style.padding="4px"}],["pointerout",()=>{u.style.border="",u.style.padding=""}]];return h.forEach(([y,b])=>u.addEventListener(y,b)),i(u),()=>{h.forEach(([y,b])=>u.removeEventListener(y,b)),f(u)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:k.Error}}function at(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}const lt=function(t,e={}){var u;const{Components:o,Blocks:s}=t,{collections:a,extendIconComponent:p=!0,licenseKey:l,block:c={}}=e,n="icon",r="iconify",g="Iconify",i="data-type-iconify",f={events:()=>({dblclick:"onActive"}),onActive(){st({collectionIds:a,editor:t,component:this.model})}};if(o.addType(r,{block:c&&{label:g,media:E,content:{type:r},category:"Extra",activate:!0,...c},isComponent:d=>Z(d,i),model:{defaults:{name:g,icon:E,droppable:!1,attributes:{[i]:!0},resizable:S,components:E,style:{width:"50px",height:"50px"},traits:[_()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(d=>d.set({layerable:!1,locked:!0}))}},view:f}),p){const d=(u=o.getType(n))==null?void 0:u.model,[T,h,...y]=d.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[T,h,_(),...y]}},view:f})}J({editor:t,licenseKey:l,plan:Q,pluginName:m,cleanup:()=>{s.remove(r),o.removeType(r)}})},ut=q(lt);module.exports=ut;
|