@storyblok/astro 6.1.1 → 6.2.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/storyblok-astro.es.js +430 -421
- package/dist/storyblok-astro.umd.js +10 -10
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const te = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
2
2
|
<g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
3
3
|
<g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
|
|
4
4
|
<g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
|
|
@@ -7,30 +7,30 @@ const Q = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xml
|
|
|
7
7
|
</g>
|
|
8
8
|
</g>
|
|
9
9
|
</g>
|
|
10
|
-
</svg>`,
|
|
11
|
-
let n = !1, s = !1, l = !1,
|
|
12
|
-
for (let
|
|
13
|
-
const
|
|
14
|
-
|
|
10
|
+
</svg>`, re = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, q = /([\p{Alpha}\p{N}_]|$)/u, j = /[_.\- ]+/, se = new RegExp("^" + j.source), N = new RegExp(j.source + q.source, "gu"), P = new RegExp("\\d+" + q.source, "gu"), ne = (t, e, r, o) => {
|
|
11
|
+
let n = !1, s = !1, l = !1, p = !1;
|
|
12
|
+
for (let c = 0; c < t.length; c++) {
|
|
13
|
+
const u = t[c];
|
|
14
|
+
p = c > 2 ? t[c - 3] === "-" : !0, n && re.test(u) ? (t = t.slice(0, c) + "-" + t.slice(c), n = !1, l = s, s = !0, c++) : s && l && oe.test(u) && (!p || o) ? (t = t.slice(0, c - 1) + "-" + t.slice(c - 1), l = s, s = !1, n = !0) : (n = e(u) === u && r(u) !== u, l = s, s = r(u) === u && e(u) !== u);
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
},
|
|
18
|
-
function
|
|
19
|
-
if (!(typeof
|
|
16
|
+
return t;
|
|
17
|
+
}, ae = (t, e) => (M.lastIndex = 0, t.replaceAll(M, (r) => e(r))), le = (t, e) => (N.lastIndex = 0, P.lastIndex = 0, t.replaceAll(P, (r, o, n) => ["_", "-"].includes(t.charAt(n + r.length)) ? r : e(r)).replaceAll(N, (r, o) => e(o)));
|
|
18
|
+
function ie(t, e) {
|
|
19
|
+
if (!(typeof t == "string" || Array.isArray(t)))
|
|
20
20
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
21
21
|
if (e = {
|
|
22
22
|
pascalCase: !1,
|
|
23
23
|
preserveConsecutiveUppercase: !1,
|
|
24
24
|
...e
|
|
25
|
-
}, Array.isArray(
|
|
25
|
+
}, Array.isArray(t) ? t = t.map((s) => s.trim()).filter((s) => s.length).join("-") : t = t.trim(), t.length === 0)
|
|
26
26
|
return "";
|
|
27
|
-
const
|
|
28
|
-
return
|
|
27
|
+
const r = e.locale === !1 ? (s) => s.toLowerCase() : (s) => s.toLocaleLowerCase(e.locale), o = e.locale === !1 ? (s) => s.toUpperCase() : (s) => s.toLocaleUpperCase(e.locale);
|
|
28
|
+
return t.length === 1 ? j.test(t) ? "" : e.pascalCase ? o(t) : r(t) : (t !== r(t) && (t = ne(t, r, o, e.preserveConsecutiveUppercase)), t = t.replace(se, ""), t = e.preserveConsecutiveUppercase ? ae(t, r) : r(t), e.pascalCase && (t = o(t.charAt(0)) + t.slice(1)), le(t, o));
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function B(t) {
|
|
31
|
+
return ie(t);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ce(t, e = {}, r, o) {
|
|
34
34
|
const n = "virtual:storyblok-components", s = `\0${n}`;
|
|
35
35
|
return {
|
|
36
36
|
name: "vite-plugin-storyblok-components",
|
|
@@ -40,41 +40,41 @@ function le(r, e = {}, t, o) {
|
|
|
40
40
|
},
|
|
41
41
|
async load(l) {
|
|
42
42
|
if (l === s) {
|
|
43
|
-
const
|
|
44
|
-
for await (const [
|
|
45
|
-
const
|
|
46
|
-
`/${
|
|
43
|
+
const p = [], c = [];
|
|
44
|
+
for await (const [f, $] of Object.entries(e)) {
|
|
45
|
+
const T = await this.resolve(
|
|
46
|
+
`/${t}/${$}.astro`
|
|
47
47
|
);
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
else if (
|
|
51
|
-
|
|
48
|
+
if (T)
|
|
49
|
+
p.push(`import ${B(f)} from "${T.id}"`);
|
|
50
|
+
else if (r)
|
|
51
|
+
c.push(f);
|
|
52
52
|
else
|
|
53
53
|
throw new Error(
|
|
54
|
-
`Component could not be found for blok "${
|
|
54
|
+
`Component could not be found for blok "${f}"! Does "${`/${t}/${$}`}.astro" exist?`
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
`/${
|
|
57
|
+
let u = "";
|
|
58
|
+
if (r)
|
|
59
|
+
if (u = ",FallbackComponent", o) {
|
|
60
|
+
const f = await this.resolve(
|
|
61
|
+
`/${t}/${o}.astro`
|
|
62
62
|
);
|
|
63
|
-
if (!
|
|
63
|
+
if (!f)
|
|
64
64
|
throw new Error(
|
|
65
|
-
`Custom fallback component could not be found. Does "${`/${
|
|
65
|
+
`Custom fallback component could not be found. Does "${`/${t}/${o}`}.astro" exist?`
|
|
66
66
|
);
|
|
67
|
-
|
|
68
|
-
`import FallbackComponent from "${
|
|
67
|
+
p.push(
|
|
68
|
+
`import FallbackComponent from "${f.id}"`
|
|
69
69
|
);
|
|
70
70
|
} else
|
|
71
|
-
|
|
71
|
+
p.push(
|
|
72
72
|
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
73
73
|
);
|
|
74
74
|
if (Object.values(e).length)
|
|
75
|
-
return `${
|
|
76
|
-
if (
|
|
77
|
-
return `${
|
|
75
|
+
return `${p.join(";")};export default {${Object.keys(e).filter((f) => !c.includes(f)).map((f) => B(f)).join(",")}${u}}`;
|
|
76
|
+
if (r)
|
|
77
|
+
return `${p[0]}; export default {${u.replace(",", "")}}`;
|
|
78
78
|
throw new Error(
|
|
79
79
|
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
80
80
|
Please register your components or enable the fallback component.
|
|
@@ -84,7 +84,7 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function ue(t, e, r) {
|
|
88
88
|
const o = "virtual:storyblok-init", n = `\0${o}`;
|
|
89
89
|
return {
|
|
90
90
|
name: "vite-plugin-storyblok-init",
|
|
@@ -97,63 +97,63 @@ function ie(r, e, t) {
|
|
|
97
97
|
return `
|
|
98
98
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
99
99
|
const { storyblokApi } = storyblokInit({
|
|
100
|
-
accessToken: "${
|
|
100
|
+
accessToken: "${t}",
|
|
101
101
|
use: ${e ? "[]" : "[apiPlugin]"},
|
|
102
|
-
apiOptions: ${JSON.stringify(
|
|
102
|
+
apiOptions: ${JSON.stringify(r)},
|
|
103
103
|
});
|
|
104
104
|
export const storyblokApiInstance = storyblokApi;
|
|
105
105
|
`;
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
const e = "virtual:storyblok-options",
|
|
109
|
+
function de(t) {
|
|
110
|
+
const e = "virtual:storyblok-options", r = `\0${e}`;
|
|
111
111
|
return {
|
|
112
112
|
name: "vite-plugin-storyblok-options",
|
|
113
113
|
async resolveId(o) {
|
|
114
114
|
if (o === e)
|
|
115
|
-
return
|
|
115
|
+
return r;
|
|
116
116
|
},
|
|
117
117
|
async load(o) {
|
|
118
|
-
if (o ===
|
|
119
|
-
return `export default ${JSON.stringify(
|
|
118
|
+
if (o === r)
|
|
119
|
+
return `export default ${JSON.stringify(t)}`;
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
let
|
|
124
|
-
const
|
|
123
|
+
let D = !1;
|
|
124
|
+
const U = [], ge = (t) => new Promise((e, r) => {
|
|
125
125
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
|
|
126
126
|
if (window.location === window.parent.location) {
|
|
127
127
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
D ? n() : U.push(n);
|
|
131
131
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
132
132
|
return;
|
|
133
133
|
const o = document.createElement("script");
|
|
134
|
-
o.async = !0, o.src =
|
|
135
|
-
|
|
134
|
+
o.async = !0, o.src = t, o.id = "storyblok-javascript-bridge", o.onerror = (n) => r(n), o.onload = (n) => {
|
|
135
|
+
U.forEach((s) => s()), D = !0, e(n);
|
|
136
136
|
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
137
137
|
});
|
|
138
|
-
var
|
|
139
|
-
class
|
|
138
|
+
var pe = Object.defineProperty, he = (t, e, r) => e in t ? pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, C = (t, e, r) => he(t, typeof e != "symbol" ? e + "" : e, r);
|
|
139
|
+
class fe {
|
|
140
140
|
constructor() {
|
|
141
|
-
|
|
141
|
+
C(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), C(this, "getOptionsPage", (e, r = 25, o = 1) => ({
|
|
142
142
|
...e,
|
|
143
|
-
per_page:
|
|
143
|
+
per_page: r,
|
|
144
144
|
page: o
|
|
145
|
-
})),
|
|
146
|
-
const o = Math.abs(
|
|
145
|
+
})), C(this, "delay", (e) => new Promise((r) => setTimeout(r, e))), C(this, "arrayFrom", (e = 0, r) => Array.from({ length: e }, r)), C(this, "range", (e = 0, r = e) => {
|
|
146
|
+
const o = Math.abs(r - e) || 0, n = e < r ? 1 : -1;
|
|
147
147
|
return this.arrayFrom(o, (s, l) => l * n + e);
|
|
148
|
-
}),
|
|
149
|
-
const
|
|
148
|
+
}), C(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), C(this, "flatMap", (e = [], r) => e.map(r).reduce((o, n) => [...o, ...n], [])), C(this, "escapeHTML", function(e) {
|
|
149
|
+
const r = {
|
|
150
150
|
"&": "&",
|
|
151
151
|
"<": "<",
|
|
152
152
|
">": ">",
|
|
153
153
|
'"': """,
|
|
154
154
|
"'": "'"
|
|
155
155
|
}, o = /[&<>"']/g, n = new RegExp(o.source);
|
|
156
|
-
return e && n.test(e) ? e.replace(o, (s) =>
|
|
156
|
+
return e && n.test(e) ? e.replace(o, (s) => r[s]) : e;
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
@@ -163,18 +163,21 @@ class ge {
|
|
|
163
163
|
* @param {boolean} isArray
|
|
164
164
|
* @return {string} Stringified object
|
|
165
165
|
*/
|
|
166
|
-
stringify(e,
|
|
166
|
+
stringify(e, r, o) {
|
|
167
167
|
const n = [];
|
|
168
168
|
for (const s in e) {
|
|
169
169
|
if (!Object.prototype.hasOwnProperty.call(e, s))
|
|
170
170
|
continue;
|
|
171
|
-
const l = e[s]
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
const l = e[s];
|
|
172
|
+
if (l == null)
|
|
173
|
+
continue;
|
|
174
|
+
const p = o ? "" : encodeURIComponent(s);
|
|
175
|
+
let c;
|
|
176
|
+
typeof l == "object" ? c = this.stringify(
|
|
174
177
|
l,
|
|
175
|
-
|
|
178
|
+
r ? r + encodeURIComponent(`[${p}]`) : p,
|
|
176
179
|
Array.isArray(l)
|
|
177
|
-
) :
|
|
180
|
+
) : c = `${r ? r + encodeURIComponent(`[${p}]`) : p}=${encodeURIComponent(l)}`, n.push(c);
|
|
178
181
|
}
|
|
179
182
|
return n.join("&");
|
|
180
183
|
}
|
|
@@ -184,7 +187,7 @@ class ge {
|
|
|
184
187
|
* @return {string} The base URL of the region
|
|
185
188
|
*/
|
|
186
189
|
getRegionURL(e) {
|
|
187
|
-
const
|
|
190
|
+
const r = "api.storyblok.com", o = "api-us.storyblok.com", n = "app.storyblokchina.cn", s = "api-ap.storyblok.com", l = "api-ca.storyblok.com";
|
|
188
191
|
switch (e) {
|
|
189
192
|
case "us":
|
|
190
193
|
return o;
|
|
@@ -195,194 +198,194 @@ class ge {
|
|
|
195
198
|
case "ca":
|
|
196
199
|
return l;
|
|
197
200
|
default:
|
|
198
|
-
return
|
|
201
|
+
return r;
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
for (const o in
|
|
205
|
-
const n =
|
|
206
|
-
e.includes(o) && n !== null && (
|
|
205
|
+
const be = function(t, e) {
|
|
206
|
+
const r = {};
|
|
207
|
+
for (const o in t) {
|
|
208
|
+
const n = t[o];
|
|
209
|
+
e.includes(o) && n !== null && (r[o] = n);
|
|
207
210
|
}
|
|
208
|
-
return
|
|
209
|
-
},
|
|
211
|
+
return r;
|
|
212
|
+
}, ye = (t) => t === "email", me = () => ({
|
|
210
213
|
singleTag: "hr"
|
|
211
|
-
}),
|
|
214
|
+
}), ke = () => ({
|
|
212
215
|
tag: "blockquote"
|
|
213
|
-
}),
|
|
216
|
+
}), $e = () => ({
|
|
214
217
|
tag: "ul"
|
|
215
|
-
}),
|
|
218
|
+
}), we = (t) => ({
|
|
216
219
|
tag: [
|
|
217
220
|
"pre",
|
|
218
221
|
{
|
|
219
222
|
tag: "code",
|
|
220
|
-
attrs:
|
|
223
|
+
attrs: t.attrs
|
|
221
224
|
}
|
|
222
225
|
]
|
|
223
|
-
}),
|
|
226
|
+
}), Te = () => ({
|
|
224
227
|
singleTag: "br"
|
|
225
|
-
}),
|
|
226
|
-
tag: `h${
|
|
227
|
-
}),
|
|
228
|
+
}), ve = (t) => ({
|
|
229
|
+
tag: `h${t.attrs.level}`
|
|
230
|
+
}), Ee = (t) => ({
|
|
228
231
|
singleTag: [
|
|
229
232
|
{
|
|
230
233
|
tag: "img",
|
|
231
|
-
attrs:
|
|
234
|
+
attrs: be(t.attrs, ["src", "alt", "title"])
|
|
232
235
|
}
|
|
233
236
|
]
|
|
234
|
-
}), Ee = () => ({
|
|
235
|
-
tag: "li"
|
|
236
237
|
}), Ce = () => ({
|
|
238
|
+
tag: "li"
|
|
239
|
+
}), Ie = () => ({
|
|
237
240
|
tag: "ol"
|
|
238
|
-
}),
|
|
241
|
+
}), Se = () => ({
|
|
239
242
|
tag: "p"
|
|
240
|
-
}),
|
|
243
|
+
}), Le = (t) => ({
|
|
241
244
|
tag: [
|
|
242
245
|
{
|
|
243
246
|
tag: "span",
|
|
244
247
|
attrs: {
|
|
245
248
|
"data-type": "emoji",
|
|
246
|
-
"data-name":
|
|
247
|
-
emoji:
|
|
249
|
+
"data-name": t.attrs.name,
|
|
250
|
+
emoji: t.attrs.emoji
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
253
|
]
|
|
251
|
-
}),
|
|
254
|
+
}), Ae = () => ({
|
|
252
255
|
tag: "b"
|
|
253
|
-
}),
|
|
256
|
+
}), Re = () => ({
|
|
254
257
|
tag: "s"
|
|
255
|
-
}),
|
|
258
|
+
}), xe = () => ({
|
|
256
259
|
tag: "u"
|
|
257
|
-
}),
|
|
260
|
+
}), Oe = () => ({
|
|
258
261
|
tag: "strong"
|
|
259
|
-
}), xe = () => ({
|
|
260
|
-
tag: "code"
|
|
261
262
|
}), je = () => ({
|
|
263
|
+
tag: "code"
|
|
264
|
+
}), _e = () => ({
|
|
262
265
|
tag: "i"
|
|
263
|
-
}),
|
|
264
|
-
if (!
|
|
266
|
+
}), Me = (t) => {
|
|
267
|
+
if (!t.attrs)
|
|
265
268
|
return {
|
|
266
269
|
tag: ""
|
|
267
270
|
};
|
|
268
|
-
const e = new
|
|
269
|
-
if (delete
|
|
270
|
-
for (const n in
|
|
271
|
-
|
|
272
|
-
delete
|
|
271
|
+
const e = new fe().escapeHTML, r = { ...t.attrs }, { linktype: o = "url" } = t.attrs;
|
|
272
|
+
if (delete r.linktype, r.href && (r.href = e(t.attrs.href || "")), ye(o) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
|
|
273
|
+
for (const n in r.custom)
|
|
274
|
+
r[n] = r.custom[n];
|
|
275
|
+
delete r.custom;
|
|
273
276
|
}
|
|
274
277
|
return {
|
|
275
278
|
tag: [
|
|
276
279
|
{
|
|
277
280
|
tag: "a",
|
|
278
|
-
attrs:
|
|
281
|
+
attrs: r
|
|
279
282
|
}
|
|
280
283
|
]
|
|
281
284
|
};
|
|
282
|
-
},
|
|
285
|
+
}, Ne = (t) => ({
|
|
283
286
|
tag: [
|
|
284
287
|
{
|
|
285
288
|
tag: "span",
|
|
286
|
-
attrs:
|
|
289
|
+
attrs: t.attrs
|
|
287
290
|
}
|
|
288
291
|
]
|
|
289
|
-
}),
|
|
292
|
+
}), Pe = () => ({
|
|
290
293
|
tag: "sub"
|
|
291
|
-
}),
|
|
294
|
+
}), Be = () => ({
|
|
292
295
|
tag: "sup"
|
|
293
|
-
}),
|
|
296
|
+
}), De = (t) => ({
|
|
294
297
|
tag: [
|
|
295
298
|
{
|
|
296
299
|
tag: "span",
|
|
297
|
-
attrs:
|
|
300
|
+
attrs: t.attrs
|
|
298
301
|
}
|
|
299
302
|
]
|
|
300
|
-
}),
|
|
303
|
+
}), Ue = (t) => {
|
|
301
304
|
var e;
|
|
302
|
-
return (e =
|
|
305
|
+
return (e = t.attrs) != null && e.color ? {
|
|
303
306
|
tag: [
|
|
304
307
|
{
|
|
305
308
|
tag: "span",
|
|
306
309
|
attrs: {
|
|
307
|
-
style: `background-color:${
|
|
310
|
+
style: `background-color:${t.attrs.color};`
|
|
308
311
|
}
|
|
309
312
|
}
|
|
310
313
|
]
|
|
311
314
|
} : {
|
|
312
315
|
tag: ""
|
|
313
316
|
};
|
|
314
|
-
},
|
|
317
|
+
}, ze = (t) => {
|
|
315
318
|
var e;
|
|
316
|
-
return (e =
|
|
319
|
+
return (e = t.attrs) != null && e.color ? {
|
|
317
320
|
tag: [
|
|
318
321
|
{
|
|
319
322
|
tag: "span",
|
|
320
323
|
attrs: {
|
|
321
|
-
style: `color:${
|
|
324
|
+
style: `color:${t.attrs.color}`
|
|
322
325
|
}
|
|
323
326
|
}
|
|
324
327
|
]
|
|
325
328
|
} : {
|
|
326
329
|
tag: ""
|
|
327
330
|
};
|
|
328
|
-
},
|
|
331
|
+
}, He = {
|
|
329
332
|
nodes: {
|
|
330
|
-
horizontal_rule:
|
|
331
|
-
blockquote:
|
|
332
|
-
bullet_list:
|
|
333
|
-
code_block:
|
|
334
|
-
hard_break:
|
|
335
|
-
heading:
|
|
336
|
-
image:
|
|
337
|
-
list_item:
|
|
338
|
-
ordered_list:
|
|
339
|
-
paragraph:
|
|
340
|
-
emoji:
|
|
333
|
+
horizontal_rule: me,
|
|
334
|
+
blockquote: ke,
|
|
335
|
+
bullet_list: $e,
|
|
336
|
+
code_block: we,
|
|
337
|
+
hard_break: Te,
|
|
338
|
+
heading: ve,
|
|
339
|
+
image: Ee,
|
|
340
|
+
list_item: Ce,
|
|
341
|
+
ordered_list: Ie,
|
|
342
|
+
paragraph: Se,
|
|
343
|
+
emoji: Le
|
|
341
344
|
},
|
|
342
345
|
marks: {
|
|
343
|
-
bold:
|
|
344
|
-
strike:
|
|
345
|
-
underline:
|
|
346
|
-
strong:
|
|
347
|
-
code:
|
|
348
|
-
italic:
|
|
349
|
-
link:
|
|
350
|
-
styled:
|
|
351
|
-
subscript:
|
|
352
|
-
superscript:
|
|
353
|
-
anchor:
|
|
354
|
-
highlight:
|
|
355
|
-
textStyle:
|
|
346
|
+
bold: Ae,
|
|
347
|
+
strike: Re,
|
|
348
|
+
underline: xe,
|
|
349
|
+
strong: Oe,
|
|
350
|
+
code: je,
|
|
351
|
+
italic: _e,
|
|
352
|
+
link: Me,
|
|
353
|
+
styled: Ne,
|
|
354
|
+
subscript: Pe,
|
|
355
|
+
superscript: Be,
|
|
356
|
+
anchor: De,
|
|
357
|
+
highlight: Ue,
|
|
358
|
+
textStyle: ze
|
|
356
359
|
}
|
|
357
|
-
},
|
|
360
|
+
}, Fe = function(t) {
|
|
358
361
|
const e = {
|
|
359
362
|
"&": "&",
|
|
360
363
|
"<": "<",
|
|
361
364
|
">": ">",
|
|
362
365
|
'"': """,
|
|
363
366
|
"'": "'"
|
|
364
|
-
},
|
|
365
|
-
return
|
|
367
|
+
}, r = /[&<>"']/g, o = new RegExp(r.source);
|
|
368
|
+
return t && o.test(t) ? t.replace(r, (n) => e[n]) : t;
|
|
366
369
|
};
|
|
367
|
-
let
|
|
368
|
-
class
|
|
370
|
+
let z = !1;
|
|
371
|
+
class qe {
|
|
369
372
|
constructor(e) {
|
|
370
|
-
|
|
373
|
+
C(this, "marks"), C(this, "nodes"), e || (e = He), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
371
374
|
}
|
|
372
|
-
addNode(e,
|
|
373
|
-
this.nodes[e] =
|
|
375
|
+
addNode(e, r) {
|
|
376
|
+
this.nodes[e] = r;
|
|
374
377
|
}
|
|
375
|
-
addMark(e,
|
|
376
|
-
this.marks[e] =
|
|
378
|
+
addMark(e, r) {
|
|
379
|
+
this.marks[e] = r;
|
|
377
380
|
}
|
|
378
|
-
render(e,
|
|
379
|
-
if (!
|
|
381
|
+
render(e, r = { optimizeImages: !1 }, o = !0) {
|
|
382
|
+
if (!z && o && (console.warn(
|
|
380
383
|
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
|
|
381
|
-
),
|
|
384
|
+
), z = !0), e && e.content && Array.isArray(e.content)) {
|
|
382
385
|
let n = "";
|
|
383
386
|
return e.content.forEach((s) => {
|
|
384
387
|
n += this.renderNode(s);
|
|
385
|
-
}),
|
|
388
|
+
}), r.optimizeImages ? this.optimizeImages(n, r.optimizeImages) : n;
|
|
386
389
|
}
|
|
387
390
|
return console.warn(
|
|
388
391
|
`The render method must receive an Object with a "content" field.
|
|
@@ -411,55 +414,55 @@ class He {
|
|
|
411
414
|
}`
|
|
412
415
|
), "";
|
|
413
416
|
}
|
|
414
|
-
optimizeImages(e,
|
|
417
|
+
optimizeImages(e, r) {
|
|
415
418
|
let o = 0, n = 0, s = "", l = "";
|
|
416
|
-
typeof
|
|
417
|
-
const
|
|
419
|
+
typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (s += `width="${r.width}" `, o = r.width), typeof r.height == "number" && r.height > 0 && (s += `height="${r.height}" `, n = r.height), (r.loading === "lazy" || r.loading === "eager") && (s += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (s += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (l += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (l += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-F]{6}/gi) || r.filters.fill === "transparent") && (l += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (l += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (l += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (l += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (l += `:rotate(${r.filters.rotate})`), l.length > 0 && (l = `/filters${l}`))), s.length > 0 && (e = e.replace(/<img/g, `<img ${s.trim()}`));
|
|
420
|
+
const p = o > 0 || n > 0 || l.length > 0 ? `${o}x${n}${l}` : "";
|
|
418
421
|
return e = e.replace(
|
|
419
422
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
420
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
421
|
-
), typeof
|
|
422
|
-
var
|
|
423
|
-
const $ =
|
|
423
|
+
`a.storyblok.com/f/$1/$2.$3/m/${p}`
|
|
424
|
+
), typeof r != "boolean" && (r.sizes || r.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (c) => {
|
|
425
|
+
var u, f;
|
|
426
|
+
const $ = c.match(
|
|
424
427
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
425
428
|
);
|
|
426
429
|
if ($ && $.length > 0) {
|
|
427
|
-
const
|
|
428
|
-
srcset: (
|
|
429
|
-
if (typeof
|
|
430
|
-
return `//${$}/m/${
|
|
431
|
-
if (typeof
|
|
432
|
-
let I = 0,
|
|
433
|
-
return typeof
|
|
430
|
+
const T = {
|
|
431
|
+
srcset: (u = r.srcset) == null ? void 0 : u.map((h) => {
|
|
432
|
+
if (typeof h == "number")
|
|
433
|
+
return `//${$}/m/${h}x0${l} ${h}w`;
|
|
434
|
+
if (typeof h == "object" && h.length === 2) {
|
|
435
|
+
let I = 0, A = 0;
|
|
436
|
+
return typeof h[0] == "number" && (I = h[0]), typeof h[1] == "number" && (A = h[1]), `//${$}/m/${I}x${A}${l} ${I}w`;
|
|
434
437
|
}
|
|
435
438
|
return "";
|
|
436
439
|
}).join(", "),
|
|
437
|
-
sizes: (
|
|
440
|
+
sizes: (f = r.sizes) == null ? void 0 : f.map((h) => h).join(", ")
|
|
438
441
|
};
|
|
439
|
-
let
|
|
440
|
-
return
|
|
442
|
+
let S = "";
|
|
443
|
+
return T.srcset && (S += `srcset="${T.srcset}" `), T.sizes && (S += `sizes="${T.sizes}" `), c.replace(/<img/g, `<img ${S.trim()}`);
|
|
441
444
|
}
|
|
442
|
-
return
|
|
445
|
+
return c;
|
|
443
446
|
})), e;
|
|
444
447
|
}
|
|
445
448
|
renderNode(e) {
|
|
446
|
-
const
|
|
449
|
+
const r = [];
|
|
447
450
|
e.marks && e.marks.forEach((n) => {
|
|
448
451
|
const s = this.getMatchingMark(n);
|
|
449
|
-
s && s.tag !== "" &&
|
|
452
|
+
s && s.tag !== "" && r.push(this.renderOpeningTag(s.tag));
|
|
450
453
|
});
|
|
451
454
|
const o = this.getMatchingNode(e);
|
|
452
|
-
return o && o.tag &&
|
|
453
|
-
|
|
454
|
-
}) : e.text ?
|
|
455
|
+
return o && o.tag && r.push(this.renderOpeningTag(o.tag)), e.content ? e.content.forEach((n) => {
|
|
456
|
+
r.push(this.renderNode(n));
|
|
457
|
+
}) : e.text ? r.push(Fe(e.text)) : o && o.singleTag ? r.push(this.renderTag(o.singleTag, " /")) : o && o.html ? r.push(o.html) : e.type === "emoji" && r.push(this.renderEmoji(e)), o && o.tag && r.push(this.renderClosingTag(o.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
|
|
455
458
|
const s = this.getMatchingMark(n);
|
|
456
|
-
s && s.tag !== "" &&
|
|
457
|
-
}),
|
|
459
|
+
s && s.tag !== "" && r.push(this.renderClosingTag(s.tag));
|
|
460
|
+
}), r.join("");
|
|
458
461
|
}
|
|
459
|
-
renderTag(e,
|
|
460
|
-
return e.constructor === String ? `<${e}${
|
|
462
|
+
renderTag(e, r) {
|
|
463
|
+
return e.constructor === String ? `<${e}${r}>` : e.map((o) => {
|
|
461
464
|
if (o.constructor === String)
|
|
462
|
-
return `<${o}${
|
|
465
|
+
return `<${o}${r}>`;
|
|
463
466
|
{
|
|
464
467
|
let n = `<${o.tag}`;
|
|
465
468
|
if (o.attrs) {
|
|
@@ -469,7 +472,7 @@ class He {
|
|
|
469
472
|
l !== null && (n += ` ${s}="${l}"`);
|
|
470
473
|
}
|
|
471
474
|
}
|
|
472
|
-
return `${n}${
|
|
475
|
+
return `${n}${r}>`;
|
|
473
476
|
}
|
|
474
477
|
}).join("");
|
|
475
478
|
}
|
|
@@ -477,22 +480,22 @@ class He {
|
|
|
477
480
|
return this.renderTag(e, "");
|
|
478
481
|
}
|
|
479
482
|
renderClosingTag(e) {
|
|
480
|
-
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((
|
|
483
|
+
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
|
|
481
484
|
}
|
|
482
485
|
getMatchingNode(e) {
|
|
483
|
-
const
|
|
484
|
-
if (typeof
|
|
485
|
-
return
|
|
486
|
+
const r = this.nodes[e.type];
|
|
487
|
+
if (typeof r == "function")
|
|
488
|
+
return r(e);
|
|
486
489
|
}
|
|
487
490
|
getMatchingMark(e) {
|
|
488
|
-
const
|
|
489
|
-
if (typeof
|
|
490
|
-
return
|
|
491
|
+
const r = this.marks[e.type];
|
|
492
|
+
if (typeof r == "function")
|
|
493
|
+
return r(e);
|
|
491
494
|
}
|
|
492
495
|
renderEmoji(e) {
|
|
493
496
|
if (e.attrs.emoji)
|
|
494
497
|
return e.attrs.emoji;
|
|
495
|
-
const
|
|
498
|
+
const r = [
|
|
496
499
|
{
|
|
497
500
|
tag: "img",
|
|
498
501
|
attrs: {
|
|
@@ -503,15 +506,15 @@ class He {
|
|
|
503
506
|
}
|
|
504
507
|
}
|
|
505
508
|
];
|
|
506
|
-
return this.renderTag(
|
|
509
|
+
return this.renderTag(r, " /");
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
|
-
const
|
|
510
|
-
if (typeof
|
|
512
|
+
const st = (t) => {
|
|
513
|
+
if (typeof t != "object" || typeof t._editable > "u")
|
|
511
514
|
return {};
|
|
512
515
|
try {
|
|
513
516
|
const e = JSON.parse(
|
|
514
|
-
|
|
517
|
+
t._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
515
518
|
);
|
|
516
519
|
return e ? {
|
|
517
520
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -521,39 +524,39 @@ const rt = (r) => {
|
|
|
521
524
|
return {};
|
|
522
525
|
}
|
|
523
526
|
};
|
|
524
|
-
function
|
|
527
|
+
function Ge(t, e) {
|
|
525
528
|
if (!e)
|
|
526
|
-
return { src:
|
|
527
|
-
let
|
|
529
|
+
return { src: t, attrs: {} };
|
|
530
|
+
let r = 0, o = 0;
|
|
528
531
|
const n = {}, s = [];
|
|
529
|
-
function l(
|
|
530
|
-
typeof
|
|
532
|
+
function l(c, u, f, $, T) {
|
|
533
|
+
typeof c != "number" || c <= u || c >= f ? console.warn(`[StoryblokRichText] - ${$.charAt(0).toUpperCase() + $.slice(1)} value must be a number between ${u} and ${f} (inclusive)`) : T.push(`${$}(${c})`);
|
|
531
534
|
}
|
|
532
535
|
if (typeof e == "object") {
|
|
533
|
-
if (typeof e.width == "number" && e.width > 0 ? (n.width = e.width,
|
|
534
|
-
const { filters:
|
|
535
|
-
|
|
536
|
+
if (typeof e.width == "number" && e.width > 0 ? (n.width = e.width, r = e.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), e.height && typeof e.height == "number" && e.height > 0 ? (n.height = e.height, o = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (n.loading = e.loading), e.class && (n.class = e.class), e.filters) {
|
|
537
|
+
const { filters: c } = e || {}, { blur: u, brightness: f, fill: $, format: T, grayscale: S, quality: h, rotate: I } = c || {};
|
|
538
|
+
u && l(u, 0, 100, "blur", s), h && l(h, 0, 100, "quality", s), f && l(f, 0, 100, "brightness", s), $ && s.push(`fill(${$})`), S && s.push("grayscale()"), I && [0, 90, 180, 270].includes(e.filters.rotate || 0) && s.push(`rotate(${I})`), T && ["webp", "png", "jpeg"].includes(T) && s.push(`format(${T})`);
|
|
536
539
|
}
|
|
537
|
-
e.srcset && (n.srcset = e.srcset.map((
|
|
538
|
-
if (typeof
|
|
539
|
-
return `${
|
|
540
|
-
if (Array.isArray(
|
|
541
|
-
const [
|
|
542
|
-
return `${
|
|
540
|
+
e.srcset && (n.srcset = e.srcset.map((c) => {
|
|
541
|
+
if (typeof c == "number")
|
|
542
|
+
return `${t}/m/${c}x0/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${c}w`;
|
|
543
|
+
if (Array.isArray(c) && c.length === 2) {
|
|
544
|
+
const [u, f] = c;
|
|
545
|
+
return `${t}/m/${u}x${f}/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${u}w`;
|
|
543
546
|
} else {
|
|
544
547
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
545
548
|
return;
|
|
546
549
|
}
|
|
547
550
|
}).join(", ")), e.sizes && (n.sizes = e.sizes.join(", "));
|
|
548
551
|
}
|
|
549
|
-
let
|
|
550
|
-
return
|
|
551
|
-
src:
|
|
552
|
+
let p = `${t}/m/`;
|
|
553
|
+
return r > 0 && o > 0 && (p = `${p}${r}x${o}/`), s.length > 0 && (p = `${p}filters:${s.join(":")}`), {
|
|
554
|
+
src: p,
|
|
552
555
|
attrs: n
|
|
553
556
|
};
|
|
554
557
|
}
|
|
555
|
-
var
|
|
556
|
-
const
|
|
558
|
+
var m = /* @__PURE__ */ ((t) => (t.DOCUMENT = "doc", t.HEADING = "heading", t.PARAGRAPH = "paragraph", t.QUOTE = "blockquote", t.OL_LIST = "ordered_list", t.UL_LIST = "bullet_list", t.LIST_ITEM = "list_item", t.CODE_BLOCK = "code_block", t.HR = "horizontal_rule", t.BR = "hard_break", t.IMAGE = "image", t.EMOJI = "emoji", t.COMPONENT = "blok", t.TABLE = "table", t.TABLE_ROW = "tableRow", t.TABLE_CELL = "tableCell", t.TABLE_HEADER = "tableHeader", t))(m || {}), E = /* @__PURE__ */ ((t) => (t.BOLD = "bold", t.STRONG = "strong", t.STRIKE = "strike", t.UNDERLINE = "underline", t.ITALIC = "italic", t.CODE = "code", t.LINK = "link", t.ANCHOR = "anchor", t.STYLED = "styled", t.SUPERSCRIPT = "superscript", t.SUBSCRIPT = "subscript", t.TEXT_STYLE = "textStyle", t.HIGHLIGHT = "highlight", t))(E || {}), G = /* @__PURE__ */ ((t) => (t.TEXT = "text", t))(G || {}), L = /* @__PURE__ */ ((t) => (t.URL = "url", t.STORY = "story", t.ASSET = "asset", t.EMAIL = "email", t))(L || {});
|
|
559
|
+
const Ke = [
|
|
557
560
|
"area",
|
|
558
561
|
"base",
|
|
559
562
|
"br",
|
|
@@ -568,242 +571,248 @@ const qe = [
|
|
|
568
571
|
"source",
|
|
569
572
|
"track",
|
|
570
573
|
"wbr"
|
|
571
|
-
],
|
|
572
|
-
function
|
|
573
|
-
return
|
|
574
|
+
], We = (t = {}) => Object.keys(t).map((e) => `${e}="${t[e]}"`).join(" "), Je = (t = {}) => Object.keys(t).map((e) => `${e}: ${t[e]}`).join("; ");
|
|
575
|
+
function Ye(t) {
|
|
576
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
574
577
|
}
|
|
575
|
-
const
|
|
576
|
-
function
|
|
577
|
-
const o =
|
|
578
|
-
if (
|
|
579
|
-
if (
|
|
578
|
+
const x = (t) => Object.fromEntries(Object.entries(t).filter(([e, r]) => r !== void 0));
|
|
579
|
+
function H(t, e = {}, r) {
|
|
580
|
+
const o = We(e), n = o ? `${t} ${o}` : t, s = Array.isArray(r) ? r.join("") : r || "";
|
|
581
|
+
if (t) {
|
|
582
|
+
if (Ke.includes(t))
|
|
580
583
|
return `<${n}>`;
|
|
581
584
|
} else return s;
|
|
582
|
-
return `<${n}>${s}</${
|
|
585
|
+
return `<${n}>${s}</${t}>`;
|
|
583
586
|
}
|
|
584
|
-
function
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
textFn: o = Je,
|
|
587
|
+
function nt(t = {}) {
|
|
588
|
+
const e = /* @__PURE__ */ new Map(), {
|
|
589
|
+
renderFn: r = H,
|
|
590
|
+
textFn: o = Ye,
|
|
589
591
|
resolvers: n = {},
|
|
590
592
|
optimizeImages: s = !1,
|
|
591
593
|
keyedResolvers: l = !1
|
|
592
|
-
} =
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
594
|
+
} = t, p = r !== H, c = () => ({ render: (a, i = {}, d) => {
|
|
595
|
+
if (l && a) {
|
|
596
|
+
const g = e.get(a) || 0;
|
|
597
|
+
e.set(a, g + 1), i.key = `${a}-${g}`;
|
|
598
|
+
}
|
|
599
|
+
return r(a, i, d);
|
|
600
|
+
} }), u = (a) => (i, d) => {
|
|
601
|
+
const g = i.attrs || {};
|
|
602
|
+
return d.render(a, g, i.children || null);
|
|
603
|
+
}, f = (a, i) => {
|
|
604
|
+
const { src: d, alt: g, title: b, srcset: w, sizes: y } = a.attrs || {};
|
|
605
|
+
let k = d, v = {};
|
|
598
606
|
if (s) {
|
|
599
|
-
const { src:
|
|
600
|
-
|
|
607
|
+
const { src: Q, attrs: ee } = Ge(d, s);
|
|
608
|
+
k = Q, v = ee;
|
|
601
609
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
title: f,
|
|
610
|
-
srcset: T,
|
|
611
|
-
sizes: b,
|
|
612
|
-
...k
|
|
610
|
+
const Z = {
|
|
611
|
+
src: k,
|
|
612
|
+
alt: g,
|
|
613
|
+
title: b,
|
|
614
|
+
srcset: w,
|
|
615
|
+
sizes: y,
|
|
616
|
+
...v
|
|
613
617
|
};
|
|
614
|
-
return
|
|
615
|
-
},
|
|
616
|
-
const { level:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
src: (c = a.attrs) == null ? void 0 : c.fallbackImage,
|
|
624
|
-
alt: (u = a.attrs) == null ? void 0 : u.alt,
|
|
618
|
+
return i.render("img", x(Z));
|
|
619
|
+
}, $ = (a, i) => {
|
|
620
|
+
const { level: d, ...g } = a.attrs || {};
|
|
621
|
+
return i.render(`h${d}`, g, a.children);
|
|
622
|
+
}, T = (a, i) => {
|
|
623
|
+
var d, g, b, w;
|
|
624
|
+
const y = i.render("img", {
|
|
625
|
+
src: (d = a.attrs) == null ? void 0 : d.fallbackImage,
|
|
626
|
+
alt: (g = a.attrs) == null ? void 0 : g.alt,
|
|
625
627
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
626
628
|
draggable: "false",
|
|
627
629
|
loading: "lazy"
|
|
628
|
-
})
|
|
630
|
+
});
|
|
631
|
+
return i.render("span", {
|
|
629
632
|
"data-type": "emoji",
|
|
630
|
-
"data-name": (
|
|
631
|
-
"data-emoji": (
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const { class:
|
|
639
|
-
class:
|
|
640
|
-
id:
|
|
641
|
-
style:
|
|
642
|
-
} :
|
|
643
|
-
return
|
|
644
|
-
},
|
|
645
|
-
const { marks:
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
633
|
+
"data-name": (b = a.attrs) == null ? void 0 : b.name,
|
|
634
|
+
"data-emoji": (w = a.attrs) == null ? void 0 : w.emoji
|
|
635
|
+
}, y);
|
|
636
|
+
}, S = (a, i) => i.render(
|
|
637
|
+
"pre",
|
|
638
|
+
a.attrs || {},
|
|
639
|
+
i.render("code", {}, a.children || "")
|
|
640
|
+
), h = (a, i = !1) => ({ text: d, attrs: g }, b) => {
|
|
641
|
+
const { class: w, id: y, ...k } = g || {}, v = i ? {
|
|
642
|
+
class: w,
|
|
643
|
+
id: y,
|
|
644
|
+
style: Je(k) || void 0
|
|
645
|
+
} : g || {};
|
|
646
|
+
return b.render(a, x(v), d);
|
|
647
|
+
}, I = (a) => O(a), A = (a) => {
|
|
648
|
+
const { marks: i, ...d } = a;
|
|
649
|
+
if ("text" in a) {
|
|
650
|
+
if (i)
|
|
651
|
+
return i.reduce(
|
|
652
|
+
(b, w) => I({ ...w, text: b }),
|
|
653
|
+
I({ ...d, children: d.children })
|
|
654
|
+
);
|
|
655
|
+
const g = a.attrs || {};
|
|
656
|
+
if (l) {
|
|
657
|
+
const b = e.get("txt") || 0;
|
|
658
|
+
e.set("txt", b + 1), g.key = `txt-${b}`;
|
|
659
|
+
}
|
|
660
|
+
return o(d.text, g);
|
|
661
|
+
}
|
|
662
|
+
return "";
|
|
663
|
+
}, _ = (a, i) => {
|
|
664
|
+
const { linktype: d, href: g, anchor: b, ...w } = a.attrs || {};
|
|
665
|
+
let y = "";
|
|
666
|
+
switch (d) {
|
|
656
667
|
case L.ASSET:
|
|
657
668
|
case L.URL:
|
|
658
|
-
|
|
669
|
+
y = g;
|
|
659
670
|
break;
|
|
660
671
|
case L.EMAIL:
|
|
661
|
-
|
|
672
|
+
y = `mailto:${g}`;
|
|
662
673
|
break;
|
|
663
674
|
case L.STORY:
|
|
664
|
-
|
|
675
|
+
y = g, b && (y = `${y}#${b}`);
|
|
665
676
|
break;
|
|
666
677
|
default:
|
|
667
|
-
|
|
678
|
+
y = g;
|
|
668
679
|
break;
|
|
669
680
|
}
|
|
670
|
-
const
|
|
671
|
-
return
|
|
672
|
-
},
|
|
673
|
-
var
|
|
674
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
|
675
|
-
blok: (
|
|
676
|
-
id: (
|
|
677
|
-
key: `component-${e}`,
|
|
681
|
+
const k = { ...w };
|
|
682
|
+
return y && (k.href = y), i.render("a", k, a.text);
|
|
683
|
+
}, K = (a, i) => {
|
|
684
|
+
var d, g;
|
|
685
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), i.render("span", {
|
|
686
|
+
blok: (d = a == null ? void 0 : a.attrs) == null ? void 0 : d.body[0],
|
|
687
|
+
id: (g = a.attrs) == null ? void 0 : g.id,
|
|
678
688
|
style: "display: none"
|
|
679
689
|
});
|
|
680
|
-
},
|
|
681
|
-
const
|
|
682
|
-
return
|
|
683
|
-
},
|
|
684
|
-
const
|
|
685
|
-
return
|
|
686
|
-
},
|
|
687
|
-
const { colspan:
|
|
688
|
-
...
|
|
690
|
+
}, W = (a, i) => {
|
|
691
|
+
const d = {}, g = i.render("tbody", {}, a.children);
|
|
692
|
+
return i.render("table", d, g);
|
|
693
|
+
}, J = (a, i) => {
|
|
694
|
+
const d = {};
|
|
695
|
+
return i.render("tr", d, a.children);
|
|
696
|
+
}, Y = (a, i) => {
|
|
697
|
+
const { colspan: d, rowspan: g, colwidth: b, backgroundColor: w, ...y } = a.attrs || {}, k = {
|
|
698
|
+
...y
|
|
689
699
|
};
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
return
|
|
693
|
-
},
|
|
694
|
-
const { colspan:
|
|
695
|
-
...
|
|
700
|
+
d > 1 && (k.colspan = d), g > 1 && (k.rowspan = g);
|
|
701
|
+
const v = [];
|
|
702
|
+
return b && v.push(`width: ${b}px;`), w && v.push(`background-color: ${w};`), v.length > 0 && (k.style = v.join(" ")), i.render("td", x(k), a.children);
|
|
703
|
+
}, V = (a, i) => {
|
|
704
|
+
const { colspan: d, rowspan: g, colwidth: b, backgroundColor: w, ...y } = a.attrs || {}, k = {
|
|
705
|
+
...y
|
|
696
706
|
};
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
return
|
|
700
|
-
},
|
|
701
|
-
[
|
|
702
|
-
[
|
|
703
|
-
[
|
|
704
|
-
[
|
|
705
|
-
[
|
|
706
|
-
[
|
|
707
|
-
[
|
|
708
|
-
[
|
|
709
|
-
[
|
|
710
|
-
[
|
|
711
|
-
[
|
|
712
|
-
[
|
|
713
|
-
[
|
|
714
|
-
[
|
|
715
|
-
[
|
|
716
|
-
[
|
|
717
|
-
[
|
|
718
|
-
[
|
|
719
|
-
[
|
|
720
|
-
[
|
|
721
|
-
[
|
|
722
|
-
[
|
|
723
|
-
[
|
|
724
|
-
[
|
|
725
|
-
[
|
|
726
|
-
[
|
|
727
|
-
[
|
|
728
|
-
[
|
|
729
|
-
[
|
|
730
|
-
[
|
|
731
|
-
...Object.entries(n).map(([a,
|
|
707
|
+
d > 1 && (k.colspan = d), g > 1 && (k.rowspan = g);
|
|
708
|
+
const v = [];
|
|
709
|
+
return b && v.push(`width: ${b}px;`), w && v.push(`background-color: ${w};`), v.length > 0 && (k.style = v.join(" ")), i.render("th", x(k), a.children);
|
|
710
|
+
}, X = new Map([
|
|
711
|
+
[m.DOCUMENT, u("")],
|
|
712
|
+
[m.HEADING, $],
|
|
713
|
+
[m.PARAGRAPH, u("p")],
|
|
714
|
+
[m.UL_LIST, u("ul")],
|
|
715
|
+
[m.OL_LIST, u("ol")],
|
|
716
|
+
[m.LIST_ITEM, u("li")],
|
|
717
|
+
[m.IMAGE, f],
|
|
718
|
+
[m.EMOJI, T],
|
|
719
|
+
[m.CODE_BLOCK, S],
|
|
720
|
+
[m.HR, u("hr")],
|
|
721
|
+
[m.BR, u("br")],
|
|
722
|
+
[m.QUOTE, u("blockquote")],
|
|
723
|
+
[m.COMPONENT, K],
|
|
724
|
+
[G.TEXT, A],
|
|
725
|
+
[E.LINK, _],
|
|
726
|
+
[E.ANCHOR, _],
|
|
727
|
+
[E.STYLED, h("span", !0)],
|
|
728
|
+
[E.BOLD, h("strong")],
|
|
729
|
+
[E.TEXT_STYLE, h("span", !0)],
|
|
730
|
+
[E.ITALIC, h("em")],
|
|
731
|
+
[E.UNDERLINE, h("u")],
|
|
732
|
+
[E.STRIKE, h("s")],
|
|
733
|
+
[E.CODE, h("code")],
|
|
734
|
+
[E.SUPERSCRIPT, h("sup")],
|
|
735
|
+
[E.SUBSCRIPT, h("sub")],
|
|
736
|
+
[E.HIGHLIGHT, h("mark")],
|
|
737
|
+
[m.TABLE, W],
|
|
738
|
+
[m.TABLE_ROW, J],
|
|
739
|
+
[m.TABLE_CELL, Y],
|
|
740
|
+
[m.TABLE_HEADER, V],
|
|
741
|
+
...Object.entries(n).map(([a, i]) => [a, i])
|
|
732
742
|
]);
|
|
733
|
-
function
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
if (!c)
|
|
743
|
+
function R(a) {
|
|
744
|
+
const i = X.get(a.type);
|
|
745
|
+
if (!i)
|
|
737
746
|
return console.error("<Storyblok>", `No resolver found for node type ${a.type}`), "";
|
|
747
|
+
const d = c();
|
|
738
748
|
if (a.type === "text")
|
|
739
|
-
return
|
|
740
|
-
const
|
|
741
|
-
return
|
|
749
|
+
return i(a, d);
|
|
750
|
+
const g = a.content ? a.content.map(O) : void 0;
|
|
751
|
+
return i({
|
|
742
752
|
...a,
|
|
743
|
-
children:
|
|
744
|
-
|
|
745
|
-
});
|
|
753
|
+
children: g
|
|
754
|
+
}, d);
|
|
746
755
|
}
|
|
747
|
-
function
|
|
748
|
-
return a.type === "doc" ?
|
|
756
|
+
function O(a) {
|
|
757
|
+
return a.type === "doc" ? p ? a.content.map(R) : a.content.map(R).join("") : Array.isArray(a) ? a.map(R) : R(a);
|
|
749
758
|
}
|
|
750
759
|
return {
|
|
751
|
-
render:
|
|
760
|
+
render: O
|
|
752
761
|
};
|
|
753
762
|
}
|
|
754
|
-
let
|
|
755
|
-
const
|
|
756
|
-
|
|
763
|
+
let Ve, Xe = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
764
|
+
const Ze = (t, e) => {
|
|
765
|
+
t.addNode("blok", (r) => {
|
|
757
766
|
let o = "";
|
|
758
|
-
return
|
|
767
|
+
return r.attrs.body.forEach((n) => {
|
|
759
768
|
o += e(n.component, n);
|
|
760
769
|
}), {
|
|
761
770
|
html: o
|
|
762
771
|
};
|
|
763
772
|
});
|
|
764
|
-
},
|
|
773
|
+
}, Qe = (t) => {
|
|
765
774
|
var e;
|
|
766
|
-
return !
|
|
767
|
-
},
|
|
768
|
-
let o =
|
|
775
|
+
return !t || !((e = t == null ? void 0 : t.content) != null && e.some((r) => r.content || r.type === "blok" || r.type === "horizontal_rule"));
|
|
776
|
+
}, et = (t, e, r) => {
|
|
777
|
+
let o = r || Ve;
|
|
769
778
|
if (!o) {
|
|
770
779
|
console.error(
|
|
771
780
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
772
781
|
);
|
|
773
782
|
return;
|
|
774
783
|
}
|
|
775
|
-
return
|
|
776
|
-
},
|
|
777
|
-
function
|
|
784
|
+
return Qe(t) ? "" : (e && (o = new qe(e.schema), e.resolver && Ze(o, e.resolver)), o.render(t, {}, !1));
|
|
785
|
+
}, at = () => ge(Xe);
|
|
786
|
+
function lt() {
|
|
778
787
|
if (!(globalThis != null && globalThis.storyblokApiInstance))
|
|
779
788
|
throw new Error("storyblokApiInstance has not been initialized correctly");
|
|
780
789
|
return globalThis.storyblokApiInstance;
|
|
781
790
|
}
|
|
782
|
-
async function
|
|
791
|
+
async function it(t) {
|
|
783
792
|
let e = null;
|
|
784
|
-
return
|
|
793
|
+
return t && t.locals._storyblok_preview_data && (e = t.locals._storyblok_preview_data), e;
|
|
785
794
|
}
|
|
786
|
-
function
|
|
795
|
+
function ct(t, e) {
|
|
787
796
|
var o;
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
797
|
+
const r = (o = globalThis == null ? void 0 : globalThis.storyblokApiInstance) == null ? void 0 : o.richTextResolver;
|
|
798
|
+
if (!r)
|
|
790
799
|
throw new Error(
|
|
791
800
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
792
801
|
);
|
|
793
|
-
return
|
|
802
|
+
return et(t, e, r);
|
|
794
803
|
}
|
|
795
|
-
function
|
|
796
|
-
return typeof
|
|
804
|
+
function tt(t) {
|
|
805
|
+
return typeof t == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(t)});` : "const storyblokInstance = new StoryblokBridge();";
|
|
797
806
|
}
|
|
798
|
-
function
|
|
807
|
+
function ut(t) {
|
|
799
808
|
const e = {
|
|
800
809
|
useCustomApi: !1,
|
|
801
810
|
bridge: !0,
|
|
802
811
|
componentsDir: "src",
|
|
803
812
|
enableFallbackComponent: !1,
|
|
804
813
|
livePreview: !1,
|
|
805
|
-
...
|
|
806
|
-
},
|
|
814
|
+
...t
|
|
815
|
+
}, r = tt(e.bridge);
|
|
807
816
|
return {
|
|
808
817
|
name: "@storyblok/astro",
|
|
809
818
|
hooks: {
|
|
@@ -812,26 +821,26 @@ function it(r) {
|
|
|
812
821
|
updateConfig: n,
|
|
813
822
|
addDevToolbarApp: s,
|
|
814
823
|
addMiddleware: l,
|
|
815
|
-
config:
|
|
824
|
+
config: p
|
|
816
825
|
}) => {
|
|
817
826
|
if (n({
|
|
818
827
|
vite: {
|
|
819
828
|
plugins: [
|
|
820
|
-
|
|
829
|
+
ue(
|
|
821
830
|
e.accessToken,
|
|
822
831
|
e.useCustomApi,
|
|
823
832
|
e.apiOptions
|
|
824
833
|
),
|
|
825
|
-
|
|
834
|
+
ce(
|
|
826
835
|
e.componentsDir,
|
|
827
836
|
e.components,
|
|
828
837
|
e.enableFallbackComponent,
|
|
829
838
|
e.customFallbackComponent
|
|
830
839
|
),
|
|
831
|
-
|
|
840
|
+
de(e)
|
|
832
841
|
]
|
|
833
842
|
}
|
|
834
|
-
}), e.livePreview && (
|
|
843
|
+
}), e.livePreview && (p == null ? void 0 : p.output) !== "server")
|
|
835
844
|
throw new Error(
|
|
836
845
|
"To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
|
|
837
846
|
);
|
|
@@ -846,7 +855,7 @@ function it(r) {
|
|
|
846
855
|
`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
847
856
|
loadStoryblokBridge().then(() => {
|
|
848
857
|
const { StoryblokBridge, location } = window;
|
|
849
|
-
${
|
|
858
|
+
${r}
|
|
850
859
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
851
860
|
if (!event.slugChanged) {
|
|
852
861
|
location.reload(true);
|
|
@@ -859,7 +868,7 @@ function it(r) {
|
|
|
859
868
|
`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
860
869
|
loadStoryblokBridge().then(() => {
|
|
861
870
|
const { StoryblokBridge, location } = window;
|
|
862
|
-
${
|
|
871
|
+
${r}
|
|
863
872
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
864
873
|
});
|
|
865
874
|
`
|
|
@@ -869,61 +878,61 @@ function it(r) {
|
|
|
869
878
|
})), s({
|
|
870
879
|
id: "storyblok",
|
|
871
880
|
name: "Storyblok",
|
|
872
|
-
icon:
|
|
881
|
+
icon: te,
|
|
873
882
|
entrypoint: "@storyblok/astro/toolbarApp.ts"
|
|
874
883
|
});
|
|
875
884
|
}
|
|
876
885
|
}
|
|
877
886
|
};
|
|
878
887
|
}
|
|
879
|
-
let
|
|
880
|
-
async function
|
|
881
|
-
const { action: e, story:
|
|
882
|
-
if (e === "input" &&
|
|
888
|
+
let F;
|
|
889
|
+
async function dt(t) {
|
|
890
|
+
const { action: e, story: r } = t || {};
|
|
891
|
+
if (e === "input" && r) {
|
|
883
892
|
const o = async () => {
|
|
884
|
-
const s = await
|
|
893
|
+
const s = await ot(r), l = document.body;
|
|
885
894
|
if (s.outerHTML === l.outerHTML)
|
|
886
895
|
return;
|
|
887
|
-
const
|
|
888
|
-
|
|
896
|
+
const p = document.querySelector('[data-blok-focused="true"]');
|
|
897
|
+
rt(l, s, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
|
|
889
898
|
};
|
|
890
|
-
clearTimeout(
|
|
899
|
+
clearTimeout(F), F = setTimeout(o, 500);
|
|
891
900
|
}
|
|
892
|
-
["published", "change"].includes(
|
|
901
|
+
["published", "change"].includes(t == null ? void 0 : t.action) && location.reload();
|
|
893
902
|
}
|
|
894
|
-
function
|
|
895
|
-
if (
|
|
896
|
-
const o =
|
|
903
|
+
function rt(t, e, r) {
|
|
904
|
+
if (r) {
|
|
905
|
+
const o = r.getAttribute("data-blok-uid"), n = e.querySelector(
|
|
897
906
|
`[data-blok-uid="${o}"]`
|
|
898
907
|
);
|
|
899
|
-
n && (n.setAttribute("data-blok-focused", "true"),
|
|
908
|
+
n && (n.setAttribute("data-blok-focused", "true"), r.replaceWith(n));
|
|
900
909
|
} else
|
|
901
|
-
|
|
910
|
+
t.replaceWith(e);
|
|
902
911
|
}
|
|
903
|
-
async function
|
|
904
|
-
const
|
|
912
|
+
async function ot(t) {
|
|
913
|
+
const r = await (await fetch(location.href, {
|
|
905
914
|
method: "POST",
|
|
906
915
|
body: JSON.stringify({
|
|
907
|
-
...
|
|
916
|
+
...t,
|
|
908
917
|
is_storyblok_preview: !0
|
|
909
918
|
}),
|
|
910
919
|
headers: {
|
|
911
920
|
"Content-Type": "application/json"
|
|
912
921
|
}
|
|
913
922
|
})).text();
|
|
914
|
-
return new DOMParser().parseFromString(
|
|
923
|
+
return new DOMParser().parseFromString(r, "text/html").body;
|
|
915
924
|
}
|
|
916
925
|
export {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
926
|
+
qe as RichTextResolver,
|
|
927
|
+
He as RichTextSchema,
|
|
928
|
+
G as TextTypes,
|
|
929
|
+
it as getLiveStory,
|
|
930
|
+
dt as handleStoryblokMessage,
|
|
931
|
+
at as loadStoryblokBridge,
|
|
932
|
+
ct as renderRichText,
|
|
933
|
+
nt as richTextResolver,
|
|
934
|
+
ut as storyblok,
|
|
935
|
+
st as storyblokEditable,
|
|
936
|
+
B as toCamelCase,
|
|
937
|
+
lt as useStoryblokApi
|
|
929
938
|
};
|