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