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