@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,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
U,
|
|
4
|
-
H,
|
|
1
|
+
const k = "app.grapesjs.com", U = "app-stage.grapesjs.com", B = "app2.grapesjs.com", C = "app-stage2.grapesjs.com", D = [
|
|
2
|
+
k,
|
|
5
3
|
B,
|
|
4
|
+
U,
|
|
5
|
+
C,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,208 +11,213 @@ const D = "app.grapesjs.com", H = "app-stage.grapesjs.com", U = "app2.grapesjs.c
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
], W = "license:check:start", F = "license:check:end", G = () => typeof window < "u", K = ({
|
|
15
|
+
isDev: s,
|
|
16
|
+
isStage: c,
|
|
17
|
+
isPlatform: r
|
|
18
|
+
}) => `${s ? "" : `https://${c ? U : k}`}/${r ? "platform-api" : "api"}`, Z = () => {
|
|
19
|
+
const s = G() && window.location.hostname;
|
|
20
|
+
return !!s && (D.includes(s) || D.some((c) => s.endsWith(c)));
|
|
17
21
|
};
|
|
18
|
-
async function
|
|
19
|
-
path:
|
|
20
|
-
baseApiUrl:
|
|
22
|
+
async function q({
|
|
23
|
+
path: s,
|
|
24
|
+
baseApiUrl: c,
|
|
21
25
|
method: r = "GET",
|
|
22
|
-
headers:
|
|
23
|
-
params:
|
|
24
|
-
body:
|
|
26
|
+
headers: l = {},
|
|
27
|
+
params: a,
|
|
28
|
+
body: m
|
|
25
29
|
}) {
|
|
26
|
-
const
|
|
30
|
+
const f = `${c || K({ isDev: !1, isStage: !1 })}${s}`, b = {
|
|
27
31
|
method: r,
|
|
28
32
|
headers: {
|
|
29
33
|
"Content-Type": "application/json",
|
|
30
|
-
...
|
|
34
|
+
...l
|
|
31
35
|
}
|
|
32
36
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
throw new Error(`HTTP error! status: ${
|
|
37
|
-
return
|
|
37
|
+
m && (b.body = JSON.stringify(m));
|
|
38
|
+
const d = a ? new URLSearchParams(a).toString() : "", v = d ? `?${d}` : "", n = await fetch(`${f}${v}`, b);
|
|
39
|
+
if (!n.ok)
|
|
40
|
+
throw new Error(`HTTP error! status: ${n.status}`);
|
|
41
|
+
return n.json();
|
|
38
42
|
}
|
|
39
|
-
var
|
|
40
|
-
const
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
43
|
+
var w = /* @__PURE__ */ ((s) => (s.free = "free", s.startup = "startup", s.business = "business", s.enterprise = "enterprise", s))(w || {});
|
|
44
|
+
const H = {
|
|
45
|
+
[w.free]: 0,
|
|
46
|
+
[w.startup]: 10,
|
|
47
|
+
[w.business]: 20,
|
|
48
|
+
[w.enterprise]: 30
|
|
45
49
|
};
|
|
46
|
-
function
|
|
47
|
-
const
|
|
48
|
-
return
|
|
50
|
+
function z(s) {
|
|
51
|
+
const c = s;
|
|
52
|
+
return c.init = (r) => (l) => s(l, r), c;
|
|
49
53
|
}
|
|
50
|
-
const
|
|
51
|
-
async function
|
|
52
|
-
editor:
|
|
53
|
-
plan:
|
|
54
|
+
const J = (s) => /* @__PURE__ */ z(s);
|
|
55
|
+
async function R({
|
|
56
|
+
editor: s,
|
|
57
|
+
plan: c,
|
|
54
58
|
pluginName: r,
|
|
55
|
-
licenseKey:
|
|
56
|
-
|
|
59
|
+
licenseKey: l,
|
|
60
|
+
onLicenseCheckResponse: a,
|
|
61
|
+
cleanup: m
|
|
57
62
|
}) {
|
|
58
|
-
let h = "",
|
|
59
|
-
const
|
|
60
|
-
console.warn("Cleanup plugin:", r, "Reason:", n),
|
|
61
|
-
},
|
|
63
|
+
let h = "", f = !1;
|
|
64
|
+
const b = Z(), d = (n) => {
|
|
65
|
+
console.warn("Cleanup plugin:", r, "Reason:", n), m();
|
|
66
|
+
}, v = (n = {}) => {
|
|
62
67
|
var A;
|
|
63
|
-
const { error:
|
|
64
|
-
if (!(
|
|
65
|
-
d(
|
|
66
|
-
else if (
|
|
67
|
-
const
|
|
68
|
-
|
|
68
|
+
const { error: p, sdkLicense: E } = n, y = (A = n.plan) == null ? void 0 : A.category;
|
|
69
|
+
if (!(E || n.license) || p)
|
|
70
|
+
d(p || "Invalid license");
|
|
71
|
+
else if (y) {
|
|
72
|
+
const j = H[c], t = H[y];
|
|
73
|
+
j > t && d({ pluginRequiredPlan: c, licensePlan: y });
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
|
|
72
|
-
h = n == null ? void 0 : n.baseApiUrl,
|
|
73
|
-
}),
|
|
74
|
-
|
|
76
|
+
s.on(W, (n) => {
|
|
77
|
+
h = n == null ? void 0 : n.baseApiUrl, f = !0;
|
|
78
|
+
}), s.on(F, (n) => {
|
|
79
|
+
a == null || a(n), v(n);
|
|
75
80
|
}), setTimeout(async () => {
|
|
76
|
-
if (!
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
const n = await X({ licenseKey:
|
|
80
|
-
n &&
|
|
81
|
+
if (!f) {
|
|
82
|
+
if (b) return;
|
|
83
|
+
if (l) {
|
|
84
|
+
const n = await X({ licenseKey: l, pluginName: r, baseApiUrl: h });
|
|
85
|
+
a == null || a(n), n && v(n);
|
|
81
86
|
} else
|
|
82
87
|
d("The `licenseKey` option not provided");
|
|
83
88
|
}
|
|
84
89
|
}, 2e3);
|
|
85
90
|
}
|
|
86
|
-
async function X(
|
|
87
|
-
const { licenseKey:
|
|
91
|
+
async function X(s) {
|
|
92
|
+
const { licenseKey: c, pluginName: r, baseApiUrl: l } = s;
|
|
88
93
|
try {
|
|
89
|
-
return (await
|
|
90
|
-
baseApiUrl:
|
|
91
|
-
path: `/sdk/${
|
|
94
|
+
return (await q({
|
|
95
|
+
baseApiUrl: l,
|
|
96
|
+
path: `/sdk/${c || "na"}`,
|
|
92
97
|
method: "POST",
|
|
93
98
|
params: {
|
|
94
99
|
d: window.location.hostname,
|
|
95
100
|
pn: r
|
|
96
101
|
}
|
|
97
102
|
})).result || {};
|
|
98
|
-
} catch (
|
|
99
|
-
return console.error("Error during SDK license check:",
|
|
103
|
+
} catch (a) {
|
|
104
|
+
return console.error("Error during SDK license check:", a), !1;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
const Y = "gjs-plg-", Q = "fsLightboxComponent",
|
|
107
|
+
const Y = "gjs-plg-", Q = "fsLightboxComponent", tt = w.startup, $ = "data-fslightbox", N = "data-type", et = "fslightbox-open", L = "fslightbox", x = {
|
|
103
108
|
image: '<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',
|
|
104
109
|
video: '<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',
|
|
105
110
|
imageLightbox: '<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',
|
|
106
111
|
external: '<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',
|
|
107
112
|
eye: '<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'
|
|
108
|
-
},
|
|
109
|
-
const { Blocks: r, Components:
|
|
110
|
-
toolbarIconOpen:
|
|
113
|
+
}, st = function(s, c = {}) {
|
|
114
|
+
const { Blocks: r, Components: l } = s, a = "Lightbox", m = `${Y}${L}`, h = {
|
|
115
|
+
toolbarIconOpen: x.eye,
|
|
111
116
|
block: {},
|
|
112
117
|
defaultSrc: "https://placehold.co/300/777/white.png?text=Image",
|
|
113
118
|
cdnScript: "https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",
|
|
114
|
-
...
|
|
115
|
-
}, { block:
|
|
116
|
-
const e = this, i = "data-fslightbox", o = window,
|
|
117
|
-
var
|
|
119
|
+
...c
|
|
120
|
+
}, { block: f, toolbarIconOpen: b, defaultSrc: d } = h, v = function(t) {
|
|
121
|
+
const e = this, i = "data-fslightbox", o = window, g = () => {
|
|
122
|
+
var M;
|
|
118
123
|
const u = o.refreshFsLightbox;
|
|
119
124
|
u == null || u();
|
|
120
|
-
const
|
|
121
|
-
if ((
|
|
122
|
-
Array.from(document.querySelectorAll(`[${i}]`)).forEach((
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
+
const O = e.getAttribute(i);
|
|
126
|
+
if ((M = o.fsLightboxInstances) == null || M[O], !o._isEditor) return;
|
|
127
|
+
Array.from(document.querySelectorAll(`[${i}]`)).forEach((T) => {
|
|
128
|
+
const S = T.onclick;
|
|
129
|
+
T.onclick = function(I) {
|
|
125
130
|
I.preventDefault();
|
|
126
|
-
const
|
|
127
|
-
!
|
|
131
|
+
const P = T;
|
|
132
|
+
!P.__skipLb && (S == null || S(I)), P.__skipLb = !0;
|
|
128
133
|
};
|
|
129
134
|
});
|
|
130
135
|
};
|
|
131
136
|
if (o.refreshFsLightbox)
|
|
132
|
-
|
|
137
|
+
g();
|
|
133
138
|
else {
|
|
134
139
|
const u = document.createElement("script");
|
|
135
|
-
u.src =
|
|
140
|
+
u.src = t.cdnScript, u.onload = g, document.head.appendChild(u);
|
|
136
141
|
}
|
|
137
|
-
},
|
|
138
|
-
id: `${
|
|
139
|
-
label:
|
|
142
|
+
}, n = (t) => ({
|
|
143
|
+
id: `${L}-open-lb`,
|
|
144
|
+
label: b,
|
|
140
145
|
command: () => {
|
|
141
|
-
const e =
|
|
146
|
+
const e = t.getView();
|
|
142
147
|
e == null || e.toggleLightbox();
|
|
143
148
|
}
|
|
144
|
-
}),
|
|
149
|
+
}), p = "source-type", E = {
|
|
145
150
|
type: "radio",
|
|
146
|
-
name:
|
|
151
|
+
name: p,
|
|
147
152
|
label: "Source type",
|
|
148
153
|
changeProp: !0,
|
|
149
154
|
options: [
|
|
150
|
-
{ id: "image", label: "Image", icon:
|
|
151
|
-
{ id: "video", label: "Video", icon:
|
|
152
|
-
{ id: "el", label: "Custom Element", icon:
|
|
155
|
+
{ id: "image", label: "Image", icon: x.image },
|
|
156
|
+
{ id: "video", label: "Video", icon: x.video },
|
|
157
|
+
{ id: "el", label: "Custom Element", icon: x.external }
|
|
153
158
|
],
|
|
154
159
|
// @ts-expect-error Studio related prop
|
|
155
160
|
labelToTitle: !0
|
|
156
|
-
},
|
|
161
|
+
}, y = {
|
|
157
162
|
id: "href-image",
|
|
158
163
|
name: "href",
|
|
159
164
|
type: "file",
|
|
160
165
|
label: "Source Image"
|
|
161
|
-
},
|
|
166
|
+
}, V = {
|
|
162
167
|
id: "href-video",
|
|
163
168
|
name: "href",
|
|
164
169
|
label: "Source Video",
|
|
165
170
|
placeholder: "https://www.youtube.com/watch?v=..."
|
|
166
|
-
},
|
|
171
|
+
}, A = {
|
|
167
172
|
id: "href-el",
|
|
168
173
|
name: "href",
|
|
169
174
|
label: "Source Element",
|
|
170
175
|
placeholder: "#custom-element-id"
|
|
171
|
-
},
|
|
172
|
-
image: [
|
|
173
|
-
video: [
|
|
174
|
-
el: [
|
|
176
|
+
}, j = {
|
|
177
|
+
image: [y],
|
|
178
|
+
video: [V],
|
|
179
|
+
el: [A]
|
|
175
180
|
};
|
|
176
|
-
|
|
177
|
-
block:
|
|
178
|
-
label:
|
|
179
|
-
media:
|
|
181
|
+
l.addType(L, {
|
|
182
|
+
block: f && {
|
|
183
|
+
label: a,
|
|
184
|
+
media: x.imageLightbox,
|
|
180
185
|
category: "Extra",
|
|
181
186
|
select: !0,
|
|
182
|
-
...
|
|
187
|
+
...h.block
|
|
183
188
|
},
|
|
184
|
-
isComponent: (
|
|
189
|
+
isComponent: (t) => {
|
|
185
190
|
var e;
|
|
186
|
-
return (e =
|
|
191
|
+
return (e = t.hasAttribute) == null ? void 0 : e.call(t, $);
|
|
187
192
|
},
|
|
188
193
|
extendFn: ["initToolbar"],
|
|
189
194
|
model: {
|
|
190
195
|
defaults: {
|
|
191
196
|
tagName: "a",
|
|
192
|
-
name:
|
|
193
|
-
icon:
|
|
194
|
-
classes:
|
|
195
|
-
draggable: (
|
|
197
|
+
name: a,
|
|
198
|
+
icon: x.imageLightbox,
|
|
199
|
+
classes: m,
|
|
200
|
+
draggable: (t, e) => !e.is(L),
|
|
196
201
|
attributes: {
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
href:
|
|
202
|
+
[$]: "lightbox",
|
|
203
|
+
[N]: "image",
|
|
204
|
+
href: d
|
|
200
205
|
},
|
|
201
|
-
components: { type: "image", src:
|
|
202
|
-
script:
|
|
203
|
-
cdnScript:
|
|
206
|
+
components: { type: "image", src: d },
|
|
207
|
+
script: v,
|
|
208
|
+
cdnScript: h.cdnScript,
|
|
204
209
|
"script-props": ["attributes", "cdnScript"],
|
|
205
|
-
[
|
|
210
|
+
[p]: "image",
|
|
206
211
|
traits: [
|
|
207
|
-
|
|
212
|
+
E,
|
|
208
213
|
{
|
|
209
|
-
name:
|
|
214
|
+
name: $,
|
|
210
215
|
label: "Group name"
|
|
211
216
|
},
|
|
212
217
|
{
|
|
213
218
|
type: "button",
|
|
214
219
|
label: "Toggle Lightbox",
|
|
215
|
-
command(
|
|
220
|
+
command(t, e) {
|
|
216
221
|
var o;
|
|
217
222
|
const i = (o = e.target) == null ? void 0 : o.getView();
|
|
218
223
|
i == null || i.toggleLightbox();
|
|
@@ -220,40 +225,40 @@ const Y = "gjs-plg-", Q = "fsLightboxComponent", ee = x.startup, k = "data-fslig
|
|
|
220
225
|
}
|
|
221
226
|
],
|
|
222
227
|
styles: `
|
|
223
|
-
.${
|
|
228
|
+
.${m} {
|
|
224
229
|
display: inline-block;
|
|
225
230
|
padding: 10px;
|
|
226
231
|
}
|
|
227
232
|
`
|
|
228
233
|
},
|
|
229
234
|
init() {
|
|
230
|
-
const
|
|
231
|
-
this.on(
|
|
235
|
+
const t = [p].map((e) => `change:${e}`).join(" ");
|
|
236
|
+
this.on(t, this.updateTraits), this.on(`change:${p}`, this.onSourceTypeChange), this.on("change:attributes:href", this.adjustSourceType), this.updateTraits({ init: !0 }), this.adjustSourceType();
|
|
232
237
|
},
|
|
233
|
-
onSourceTypeChange(
|
|
238
|
+
onSourceTypeChange(t, e, i) {
|
|
234
239
|
if (i.adjust) return;
|
|
235
|
-
const
|
|
236
|
-
this.addAttributes({ [
|
|
240
|
+
const g = this.get(p) === "video" ? "video" : "image";
|
|
241
|
+
this.addAttributes({ [N]: g, href: "" });
|
|
237
242
|
},
|
|
238
243
|
adjustSourceType() {
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
244
|
+
const t = this.get(p), e = this.getAttributes().href || "", i = { adjust: !0 };
|
|
245
|
+
if (t === "video") {
|
|
241
246
|
const o = e.includes("youtube.com") ? "youtube" : "video";
|
|
242
|
-
this.addAttributes({ [
|
|
243
|
-
} else
|
|
247
|
+
this.addAttributes({ [N]: o }, i);
|
|
248
|
+
} else t !== "el" && e.startsWith("#") ? this.set(p, "el", i) : t === "image" && this.addAttributes({ [N]: "image" }, i);
|
|
244
249
|
},
|
|
245
|
-
updateTraits(
|
|
246
|
-
const { changed: e } = this, { init: i } =
|
|
247
|
-
if (e[
|
|
248
|
-
this.removeTrait([
|
|
249
|
-
const o = this.get(
|
|
250
|
-
this.addTrait(
|
|
250
|
+
updateTraits(t = {}) {
|
|
251
|
+
const { changed: e } = this, { init: i } = t;
|
|
252
|
+
if (e[E.name] || i) {
|
|
253
|
+
this.removeTrait([y.name, V.name, A.name]);
|
|
254
|
+
const o = this.get(p) || "image", g = this.getTraitIndex(p) + 1;
|
|
255
|
+
this.addTrait(j[o], { at: g });
|
|
251
256
|
}
|
|
252
257
|
},
|
|
253
258
|
initToolbar() {
|
|
254
|
-
if (!
|
|
255
|
-
const { toolbar:
|
|
256
|
-
!
|
|
259
|
+
if (!b) return;
|
|
260
|
+
const { toolbar: t } = this, e = n(this);
|
|
261
|
+
!t.find((o) => o.id === e.id) && (t == null || t.unshift(e));
|
|
257
262
|
}
|
|
258
263
|
},
|
|
259
264
|
view: {
|
|
@@ -261,31 +266,31 @@ const Y = "gjs-plg-", Q = "fsLightboxComponent", ee = x.startup, k = "data-fslig
|
|
|
261
266
|
this.el.__skipLb = !0;
|
|
262
267
|
},
|
|
263
268
|
toggleLightbox() {
|
|
264
|
-
var
|
|
265
|
-
const { em:
|
|
266
|
-
if (
|
|
269
|
+
var T;
|
|
270
|
+
const { em: t, el: e, model: i } = this, { Canvas: o } = t, g = i.getAttributes()[$], { defaultView: u, documentElement: O } = e.ownerDocument, _ = (T = u.fsLightboxInstances) == null ? void 0 : T[g];
|
|
271
|
+
if (O.classList.contains(et))
|
|
267
272
|
_.close();
|
|
268
273
|
else {
|
|
269
274
|
e.__skipLb = !1;
|
|
270
|
-
let
|
|
275
|
+
let S;
|
|
271
276
|
_.props.onOpen = () => {
|
|
272
|
-
|
|
277
|
+
S = o.getSpots(), setTimeout(() => o.removeSpots());
|
|
273
278
|
}, _.props.onClose = () => {
|
|
274
|
-
|
|
279
|
+
S.forEach((I) => o.addSpot(I.attributes));
|
|
275
280
|
}, e.click();
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
}
|
|
279
|
-
}),
|
|
280
|
-
editor:
|
|
281
|
-
plan:
|
|
282
|
-
licenseKey:
|
|
284
|
+
}), R({
|
|
285
|
+
editor: s,
|
|
286
|
+
plan: tt,
|
|
287
|
+
licenseKey: h.licenseKey,
|
|
283
288
|
pluginName: Q,
|
|
284
289
|
cleanup: () => {
|
|
285
|
-
r.remove(
|
|
290
|
+
r.remove(L), l.removeType(L);
|
|
286
291
|
}
|
|
287
292
|
});
|
|
288
|
-
},
|
|
293
|
+
}, nt = J(st);
|
|
289
294
|
export {
|
|
290
|
-
|
|
295
|
+
nt as default
|
|
291
296
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(v
|
|
2
|
-
.${
|
|
1
|
+
(function(f,v){typeof exports=="object"&&typeof module<"u"?module.exports=v():typeof define=="function"&&define.amd?define(v):(f=typeof globalThis<"u"?globalThis:f||self,f.StudioSdkPlugins_fsLightboxComponent=v())})(this,function(){"use strict";const f="app.grapesjs.com",v="app-stage.grapesjs.com",k=[f,"app2.grapesjs.com",v,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],U="license:check:start",B="license:check:end",W=()=>typeof window<"u",G=({isDev:n,isStage:c,isPlatform:r})=>`${n?"":`https://${c?v:f}`}/${r?"platform-api":"api"}`,F=()=>{const n=W()&&window.location.hostname;return!!n&&(k.includes(n)||k.some(c=>n.endsWith(c)))};async function K({path:n,baseApiUrl:c,method:r="GET",headers:l={},params:a,body:m}){const x=`${c||G({isDev:!1,isStage:!1})}${n}`,b={method:r,headers:{"Content-Type":"application/json",...l}};m&&(b.body=JSON.stringify(m));const p=a?new URLSearchParams(a).toString():"",L=p?`?${p}`:"",s=await fetch(`${x}${L}`,b);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var T=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(T||{});const H={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function Z(n){const c=n;return c.init=r=>l=>n(l,r),c}const q=n=>Z(n);async function R({editor:n,plan:c,pluginName:r,licenseKey:l,onLicenseCheckResponse:a,cleanup:m}){let h="",x=!1;const b=F(),p=s=>{console.warn("Cleanup plugin:",r,"Reason:",s),m()},L=(s={})=>{var E;const{error:d,sdkLicense:O}=s,A=(E=s.plan)==null?void 0:E.category;if(!(O||s.license)||d)p(d||"Invalid license");else if(A){const M=H[c],t=H[A];M>t&&p({pluginRequiredPlan:c,licensePlan:A})}};n.on(U,s=>{h=s==null?void 0:s.baseApiUrl,x=!0}),n.on(B,s=>{a==null||a(s),L(s)}),setTimeout(async()=>{if(!x){if(b)return;if(l){const s=await z({licenseKey:l,pluginName:r,baseApiUrl:h});a==null||a(s),s&&L(s)}else p("The `licenseKey` option not provided")}},2e3)}async function z(n){const{licenseKey:c,pluginName:r,baseApiUrl:l}=n;try{return(await K({baseApiUrl:l,path:`/sdk/${c||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const J="gjs-plg-",X="fsLightboxComponent",Y=T.startup,I="data-fslightbox",N="data-type",Q="fslightbox-open",y="fslightbox",S={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',imageLightbox:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'};return q(function(n,c={}){const{Blocks:r,Components:l}=n,a="Lightbox",m=`${J}${y}`,h={toolbarIconOpen:S.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...c},{block:x,toolbarIconOpen:b,defaultSrc:p}=h,L=function(t){const e=this,i="data-fslightbox",o=window,g=()=>{var V;const u=o.refreshFsLightbox;u==null||u();const P=e.getAttribute(i);if((V=o.fsLightboxInstances)==null||V[P],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(w=>{const _=w.onclick;w.onclick=function(j){j.preventDefault();const C=w;!C.__skipLb&&(_==null||_(j)),C.__skipLb=!0}})};if(o.refreshFsLightbox)g();else{const u=document.createElement("script");u.src=t.cdnScript,u.onload=g,document.head.appendChild(u)}},s=t=>({id:`${y}-open-lb`,label:b,command:()=>{const e=t.getView();e==null||e.toggleLightbox()}}),d="source-type",O={type:"radio",name:d,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:S.image},{id:"video",label:"Video",icon:S.video},{id:"el",label:"Custom Element",icon:S.external}],labelToTitle:!0},A={id:"href-image",name:"href",type:"file",label:"Source Image"},D={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},E={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},M={image:[A],video:[D],el:[E]};l.addType(y,{block:x&&{label:a,media:S.imageLightbox,category:"Extra",select:!0,...h.block},isComponent:t=>{var e;return(e=t.hasAttribute)==null?void 0:e.call(t,I)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:a,icon:S.imageLightbox,classes:m,draggable:(t,e)=>!e.is(y),attributes:{[I]:"lightbox",[N]:"image",href:p},components:{type:"image",src:p},script:L,cdnScript:h.cdnScript,"script-props":["attributes","cdnScript"],[d]:"image",traits:[O,{name:I,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(t,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
|
|
2
|
+
.${m} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
padding: 10px;
|
|
5
5
|
}
|
|
6
|
-
`},init(){const
|
|
6
|
+
`},init(){const t=[d].map(e=>`change:${e}`).join(" ");this.on(t,this.updateTraits),this.on(`change:${d}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(t,e,i){if(i.adjust)return;const g=this.get(d)==="video"?"video":"image";this.addAttributes({[N]:g,href:""})},adjustSourceType(){const t=this.get(d),e=this.getAttributes().href||"",i={adjust:!0};if(t==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[N]:o},i)}else t!=="el"&&e.startsWith("#")?this.set(d,"el",i):t==="image"&&this.addAttributes({[N]:"image"},i)},updateTraits(t={}){const{changed:e}=this,{init:i}=t;if(e[O.name]||i){this.removeTrait([A.name,D.name,E.name]);const o=this.get(d)||"image",g=this.getTraitIndex(d)+1;this.addTrait(M[o],{at:g})}},initToolbar(){if(!b)return;const{toolbar:t}=this,e=s(this);!t.find(o=>o.id===e.id)&&(t==null||t.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var w;const{em:t,el:e,model:i}=this,{Canvas:o}=t,g=i.getAttributes()[I],{defaultView:u,documentElement:P}=e.ownerDocument,$=(w=u.fsLightboxInstances)==null?void 0:w[g];if(P.classList.contains(Q))$.close();else{e.__skipLb=!1;let _;$.props.onOpen=()=>{_=o.getSpots(),setTimeout(()=>o.removeSpots())},$.props.onClose=()=>{_.forEach(j=>o.addSpot(j.attributes))},e.click()}}}}),R({editor:n,plan:Y,licenseKey:h.licenseKey,pluginName:X,cleanup:()=>{r.remove(y),l.removeType(y)}})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(p||{}),v=(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||{});const D="app.grapesjs.com",G="app-stage.grapesjs.com",I="app2.grapesjs.com",$="app-stage2.grapesjs.com",w=[D,I,G,$,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],E="license:check:start",M="license:check:end",U=()=>typeof window<"u",j=({isDev:t,isStage:e,isPlatform:s})=>`${t?"":`https://${e?G:D}`}/${s?"platform-api":"api"}`,N=()=>{const t=U()&&window.location.hostname;return!!t&&(w.includes(t)||w.some(e=>t.endsWith(e)))};async function B({path:t,baseApiUrl:e,method:s="GET",headers:n={},params:o,body:r}){const l=`${e||j({isDev:!1,isStage:!1})}${t}`,c={method:s,headers:{"Content-Type":"application/json",...n}};r&&(c.body=JSON.stringify(r));const u=o?new URLSearchParams(o).toString():"",g=u?`?${u}`:"",a=await fetch(`${l}${g}`,c);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}const F={[p.free]:0,[p.startup]:10,[p.business]:20,[p.enterprise]:30};function k(t){const e=t;return e.init=s=>n=>t(n,s),e}const W=t=>k(t);async function _({editor:t,plan:e,pluginName:s,licenseKey:n,onLicenseCheckResponse:o,cleanup:r}){let i="",l=!1;const c=N(),u=a=>{console.warn("Cleanup plugin:",s,"Reason:",a),r()},g=(a={})=>{var A;const{error:d,sdkLicense:f}=a,b=(A=a.plan)==null?void 0:A.category;if(!(f||a.license)||d)u(d||"Invalid license");else if(b){const O=F[e],R=F[b];O>R&&u({pluginRequiredPlan:e,licensePlan:b})}};t.on(E,a=>{i=a==null?void 0:a.baseApiUrl,l=!0}),t.on(M,a=>{o==null||o(a),g(a)}),setTimeout(async()=>{if(!l){if(c)return;if(n){const a=await K({licenseKey:n,pluginName:s,baseApiUrl:i});o==null||o(a),a&&g(a)}else u("The `licenseKey` option not provided")}},2e3)}async function K(t){const{licenseKey:e,pluginName:s,baseApiUrl:n}=t;try{return(await B({baseApiUrl:n,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:s}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}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)=>{t=P(t);const{menuVariant:s,variants:n}=e;return{family:t,familyLabel:y(t),menuVariant:s&&T(P(`menuFont-${y(t)}`),"regular",s),variants:Object.assign({},...Object.entries(n).map(([o,r])=>({[o]:T(t,o,r)})))}},x=(t,e)=>{var l;const s=L(t.family,t),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=y(n.family);if(!e){const c=new FontFace(i,`url("${o}")`,r),u=Array.from(document.fonts.values()).filter(g=>g.family===i);for(const g of u)document.fonts.delete(g);document.fonts.add(c),c.load().catch(()=>{})}return P(i)},V=t=>{const{family:e,menu:s,axes:n}=t,o=!!n,r=Object.assign({},...t.variants.map(i=>{var g,a;let l,c;if(o){const d=n.find(f=>f.tag==="wght");if(d){const{start:f,end:b}=d;l=`${f} ${b}`}}return l||(l=((g=i.match(/\d+/))==null?void 0:g[0])??"400"),c=((a=i.match(/[a-zA-Z]+/))==null?void 0:a[0])==="italic"?"italic":void 0,{[i]:{source:t.files[i],descriptors:{style:c,weight:l}}}}));return L(e,{menuVariant:{source:s},variants:r})},H=t=>({id:`${t.family}/${t.version}`,type:"font",src:t.menu,name:t.family,customData:{font:V(t),needsLoading:!0}}),z=t=>{const{font:e}=t.customData;return t.customData.needsLoading?(t.customData.needsLoading=!1,x(e)):x(e,!0)};let h;const q=t=>{const e=[];for(const s of Object.keys(t)){let n=t[s];n&&(Array.isArray(n)?e.push(...n.map(o=>[s,o.toString()])):(n=n.toString(),e.push([s,n])))}return new URLSearchParams(e)},S=t=>{const{apiKey:e,searchParams:s}=t,n=(o={})=>{const r="https://www.googleapis.com/webfonts/v1/webfonts",i=q(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:e,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(H),h):[]},itemLayout:o=>{const r=h.find(l=>l.id===o.assetProps.id),i=z(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"}}]}}}},J={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},Q="googleFontsAssetProvider",Z=p.startup,X=function(t,e){const{i18n:s={}}=e,n=S(e);t.runCommand(v.assetProviderAdd,{provider:n}),t.I18n.addMessages({en:J,...s}),_({editor:t,licenseKey:e.licenseKey,plan:Z,pluginName:Q,cleanup:()=>{t.runCommand(v.assetProviderRemove,{id:n.id})}})},Y=W(X);module.exports=Y;
|