@storyblok/react 4.3.4 → 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +1 -1
- package/dist/client.mjs +11 -11
- package/dist/common.js +1 -1
- package/dist/common.mjs +10 -10
- package/dist/live-editing.js +1 -1
- package/dist/live-editing.mjs +12 -12
- package/dist/richtext.js +1 -1
- package/dist/richtext.mjs +4 -4
- package/dist/rsc/common.d.ts +4 -1
- package/dist/rsc/common.d.ts.map +1 -1
- package/dist/rsc/live-edit-update-action.d.ts +3 -2
- package/dist/rsc/live-edit-update-action.d.ts.map +1 -1
- package/dist/rsc/live-editing.d.ts +3 -2
- package/dist/rsc/live-editing.d.ts.map +1 -1
- package/dist/rsc/story.d.ts.map +1 -1
- package/dist/story.js +1 -1
- package/dist/story.mjs +10 -10
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +207 -207
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +51 -18
- package/package.json +19 -14
package/dist/storyblok-js.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let H = !1;
|
|
2
|
-
const U = [], F = (
|
|
2
|
+
const U = [], F = (n) => new Promise((e, t) => {
|
|
3
3
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
4
4
|
if (window.location === window.parent.location) {
|
|
5
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
@@ -9,35 +9,35 @@ const U = [], F = (o) => new Promise((e, t) => {
|
|
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
10
10
|
return;
|
|
11
11
|
const r = document.createElement("script");
|
|
12
|
-
r.async = !0, r.src =
|
|
13
|
-
U.forEach((
|
|
12
|
+
r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => t(s), r.onload = (s) => {
|
|
13
|
+
U.forEach((o) => o()), H = !0, e(s);
|
|
14
14
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
15
15
|
});
|
|
16
|
-
var Q = Object.defineProperty, Z = (
|
|
16
|
+
var Q = Object.defineProperty, Z = (n, e, t) => e in n ? Q(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, p = (n, e, t) => Z(n, typeof e != "symbol" ? e + "" : e, t);
|
|
17
17
|
class ee extends Error {
|
|
18
18
|
constructor(e) {
|
|
19
19
|
super(e), this.name = "AbortError";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
function te(
|
|
22
|
+
function te(n, e, t) {
|
|
23
23
|
if (!Number.isFinite(e))
|
|
24
24
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
25
25
|
if (!Number.isFinite(t))
|
|
26
26
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
27
27
|
const r = [];
|
|
28
|
-
let s = [],
|
|
28
|
+
let s = [], o = 0, i = !1;
|
|
29
29
|
const l = async () => {
|
|
30
|
-
|
|
30
|
+
o++;
|
|
31
31
|
const h = r.shift();
|
|
32
32
|
if (h)
|
|
33
33
|
try {
|
|
34
|
-
const d = await
|
|
34
|
+
const d = await n(...h.args);
|
|
35
35
|
h.resolve(d);
|
|
36
36
|
} catch (d) {
|
|
37
37
|
h.reject(d);
|
|
38
38
|
}
|
|
39
39
|
const u = setTimeout(() => {
|
|
40
|
-
|
|
40
|
+
o--, r.length > 0 && l(), s = s.filter((d) => d !== u);
|
|
41
41
|
}, t);
|
|
42
42
|
s.includes(u) || s.push(u);
|
|
43
43
|
}, a = (...h) => i ? Promise.reject(
|
|
@@ -49,7 +49,7 @@ function te(o, e, t) {
|
|
|
49
49
|
resolve: u,
|
|
50
50
|
reject: d,
|
|
51
51
|
args: h
|
|
52
|
-
}),
|
|
52
|
+
}), o < e && l();
|
|
53
53
|
});
|
|
54
54
|
return a.abort = () => {
|
|
55
55
|
i = !0, s.forEach(clearTimeout), s = [], r.forEach(
|
|
@@ -65,7 +65,7 @@ class A {
|
|
|
65
65
|
page: r
|
|
66
66
|
})), p(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), p(this, "arrayFrom", (e = 0, t) => Array.from({ length: e }, t)), p(this, "range", (e = 0, t = e) => {
|
|
67
67
|
const r = Math.abs(t - e) || 0, s = e < t ? 1 : -1;
|
|
68
|
-
return this.arrayFrom(r, (
|
|
68
|
+
return this.arrayFrom(r, (o, i) => i * s + e);
|
|
69
69
|
}), p(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), p(this, "flatMap", (e = [], t) => e.map(t).reduce((r, s) => [...r, ...s], [])), p(this, "escapeHTML", function(e) {
|
|
70
70
|
const t = {
|
|
71
71
|
"&": "&",
|
|
@@ -74,7 +74,7 @@ class A {
|
|
|
74
74
|
'"': """,
|
|
75
75
|
"'": "'"
|
|
76
76
|
}, r = /[&<>"']/g, s = new RegExp(r.source);
|
|
77
|
-
return e && s.test(e) ? e.replace(r, (
|
|
77
|
+
return e && s.test(e) ? e.replace(r, (o) => t[o]) : e;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -86,10 +86,10 @@ class A {
|
|
|
86
86
|
*/
|
|
87
87
|
stringify(e, t, r) {
|
|
88
88
|
const s = [];
|
|
89
|
-
for (const
|
|
90
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
89
|
+
for (const o in e) {
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(e, o))
|
|
91
91
|
continue;
|
|
92
|
-
const i = e[
|
|
92
|
+
const i = e[o], l = r ? "" : encodeURIComponent(o);
|
|
93
93
|
let a;
|
|
94
94
|
typeof i == "object" ? a = this.stringify(
|
|
95
95
|
i,
|
|
@@ -105,14 +105,14 @@ class A {
|
|
|
105
105
|
* @return {string} The base URL of the region
|
|
106
106
|
*/
|
|
107
107
|
getRegionURL(e) {
|
|
108
|
-
const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn",
|
|
108
|
+
const t = "api.storyblok.com", r = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", i = "api-ca.storyblok.com";
|
|
109
109
|
switch (e) {
|
|
110
110
|
case "us":
|
|
111
111
|
return r;
|
|
112
112
|
case "cn":
|
|
113
113
|
return s;
|
|
114
114
|
case "ap":
|
|
115
|
-
return
|
|
115
|
+
return o;
|
|
116
116
|
case "ca":
|
|
117
117
|
return i;
|
|
118
118
|
default:
|
|
@@ -120,36 +120,36 @@ class A {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
const re = function(
|
|
123
|
+
const re = function(n, e) {
|
|
124
124
|
const t = {};
|
|
125
|
-
for (const r in
|
|
126
|
-
const s =
|
|
125
|
+
for (const r in n) {
|
|
126
|
+
const s = n[r];
|
|
127
127
|
e.includes(r) && s !== null && (t[r] = s);
|
|
128
128
|
}
|
|
129
129
|
return t;
|
|
130
|
-
}, se = (
|
|
130
|
+
}, se = (n) => n === "email", ne = () => ({
|
|
131
131
|
singleTag: "hr"
|
|
132
|
-
}),
|
|
132
|
+
}), oe = () => ({
|
|
133
133
|
tag: "blockquote"
|
|
134
134
|
}), ie = () => ({
|
|
135
135
|
tag: "ul"
|
|
136
|
-
}), ae = (
|
|
136
|
+
}), ae = (n) => ({
|
|
137
137
|
tag: [
|
|
138
138
|
"pre",
|
|
139
139
|
{
|
|
140
140
|
tag: "code",
|
|
141
|
-
attrs:
|
|
141
|
+
attrs: n.attrs
|
|
142
142
|
}
|
|
143
143
|
]
|
|
144
144
|
}), le = () => ({
|
|
145
145
|
singleTag: "br"
|
|
146
|
-
}), ce = (
|
|
147
|
-
tag: `h${
|
|
148
|
-
}), he = (
|
|
146
|
+
}), ce = (n) => ({
|
|
147
|
+
tag: `h${n.attrs.level}`
|
|
148
|
+
}), he = (n) => ({
|
|
149
149
|
singleTag: [
|
|
150
150
|
{
|
|
151
151
|
tag: "img",
|
|
152
|
-
attrs: re(
|
|
152
|
+
attrs: re(n.attrs, ["src", "alt", "title"])
|
|
153
153
|
}
|
|
154
154
|
]
|
|
155
155
|
}), ue = () => ({
|
|
@@ -158,20 +158,20 @@ const re = function(o, e) {
|
|
|
158
158
|
tag: "ol"
|
|
159
159
|
}), pe = () => ({
|
|
160
160
|
tag: "p"
|
|
161
|
-
}), ge = (
|
|
161
|
+
}), ge = (n) => ({
|
|
162
162
|
tag: [
|
|
163
163
|
{
|
|
164
164
|
tag: "span",
|
|
165
165
|
attrs: {
|
|
166
166
|
"data-type": "emoji",
|
|
167
|
-
"data-name":
|
|
168
|
-
emoji:
|
|
167
|
+
"data-name": n.attrs.name,
|
|
168
|
+
emoji: n.attrs.emoji
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
]
|
|
172
|
-
}), me = () => ({
|
|
173
|
-
tag: "b"
|
|
174
172
|
}), fe = () => ({
|
|
173
|
+
tag: "b"
|
|
174
|
+
}), me = () => ({
|
|
175
175
|
tag: "s"
|
|
176
176
|
}), ye = () => ({
|
|
177
177
|
tag: "u"
|
|
@@ -179,15 +179,15 @@ const re = function(o, e) {
|
|
|
179
179
|
tag: "strong"
|
|
180
180
|
}), ke = () => ({
|
|
181
181
|
tag: "code"
|
|
182
|
-
}),
|
|
182
|
+
}), $e = () => ({
|
|
183
183
|
tag: "i"
|
|
184
|
-
}),
|
|
185
|
-
if (!
|
|
184
|
+
}), ve = (n) => {
|
|
185
|
+
if (!n.attrs)
|
|
186
186
|
return {
|
|
187
187
|
tag: ""
|
|
188
188
|
};
|
|
189
|
-
const e = new A().escapeHTML, t = { ...
|
|
190
|
-
if (delete t.linktype, t.href && (t.href = e(
|
|
189
|
+
const e = new A().escapeHTML, t = { ...n.attrs }, { linktype: r = "url" } = n.attrs;
|
|
190
|
+
if (delete t.linktype, t.href && (t.href = e(n.attrs.href || "")), se(r) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
191
191
|
for (const s in t.custom)
|
|
192
192
|
t[s] = t.custom[s];
|
|
193
193
|
delete t.custom;
|
|
@@ -200,46 +200,46 @@ const re = function(o, e) {
|
|
|
200
200
|
}
|
|
201
201
|
]
|
|
202
202
|
};
|
|
203
|
-
}, Te = (
|
|
203
|
+
}, Te = (n) => ({
|
|
204
204
|
tag: [
|
|
205
205
|
{
|
|
206
206
|
tag: "span",
|
|
207
|
-
attrs:
|
|
207
|
+
attrs: n.attrs
|
|
208
208
|
}
|
|
209
209
|
]
|
|
210
210
|
}), we = () => ({
|
|
211
211
|
tag: "sub"
|
|
212
212
|
}), Re = () => ({
|
|
213
213
|
tag: "sup"
|
|
214
|
-
}), _e = (
|
|
214
|
+
}), _e = (n) => ({
|
|
215
215
|
tag: [
|
|
216
216
|
{
|
|
217
217
|
tag: "span",
|
|
218
|
-
attrs:
|
|
218
|
+
attrs: n.attrs
|
|
219
219
|
}
|
|
220
220
|
]
|
|
221
|
-
}), Se = (
|
|
221
|
+
}), Se = (n) => {
|
|
222
222
|
var e;
|
|
223
|
-
return (e =
|
|
223
|
+
return (e = n.attrs) != null && e.color ? {
|
|
224
224
|
tag: [
|
|
225
225
|
{
|
|
226
226
|
tag: "span",
|
|
227
227
|
attrs: {
|
|
228
|
-
style: `background-color:${
|
|
228
|
+
style: `background-color:${n.attrs.color};`
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
]
|
|
232
232
|
} : {
|
|
233
233
|
tag: ""
|
|
234
234
|
};
|
|
235
|
-
}, Ee = (
|
|
235
|
+
}, Ee = (n) => {
|
|
236
236
|
var e;
|
|
237
|
-
return (e =
|
|
237
|
+
return (e = n.attrs) != null && e.color ? {
|
|
238
238
|
tag: [
|
|
239
239
|
{
|
|
240
240
|
tag: "span",
|
|
241
241
|
attrs: {
|
|
242
|
-
style: `color:${
|
|
242
|
+
style: `color:${n.attrs.color}`
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
]
|
|
@@ -248,8 +248,8 @@ const re = function(o, e) {
|
|
|
248
248
|
};
|
|
249
249
|
}, je = {
|
|
250
250
|
nodes: {
|
|
251
|
-
horizontal_rule:
|
|
252
|
-
blockquote:
|
|
251
|
+
horizontal_rule: ne,
|
|
252
|
+
blockquote: oe,
|
|
253
253
|
bullet_list: ie,
|
|
254
254
|
code_block: ae,
|
|
255
255
|
hard_break: le,
|
|
@@ -261,13 +261,13 @@ const re = function(o, e) {
|
|
|
261
261
|
emoji: ge
|
|
262
262
|
},
|
|
263
263
|
marks: {
|
|
264
|
-
bold:
|
|
265
|
-
strike:
|
|
264
|
+
bold: fe,
|
|
265
|
+
strike: me,
|
|
266
266
|
underline: ye,
|
|
267
267
|
strong: be,
|
|
268
268
|
code: ke,
|
|
269
|
-
italic:
|
|
270
|
-
link:
|
|
269
|
+
italic: $e,
|
|
270
|
+
link: ve,
|
|
271
271
|
styled: Te,
|
|
272
272
|
subscript: we,
|
|
273
273
|
superscript: Re,
|
|
@@ -275,7 +275,7 @@ const re = function(o, e) {
|
|
|
275
275
|
highlight: Se,
|
|
276
276
|
textStyle: Ee
|
|
277
277
|
}
|
|
278
|
-
}, Ie = function(
|
|
278
|
+
}, Ie = function(n) {
|
|
279
279
|
const e = {
|
|
280
280
|
"&": "&",
|
|
281
281
|
"<": "<",
|
|
@@ -283,7 +283,7 @@ const re = function(o, e) {
|
|
|
283
283
|
'"': """,
|
|
284
284
|
"'": "'"
|
|
285
285
|
}, t = /[&<>"']/g, r = new RegExp(t.source);
|
|
286
|
-
return
|
|
286
|
+
return n && r.test(n) ? n.replace(t, (s) => e[s]) : n;
|
|
287
287
|
};
|
|
288
288
|
let z = !1;
|
|
289
289
|
class xe {
|
|
@@ -301,8 +301,8 @@ class xe {
|
|
|
301
301
|
"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/"
|
|
302
302
|
), z = !0), e && e.content && Array.isArray(e.content)) {
|
|
303
303
|
let s = "";
|
|
304
|
-
return e.content.forEach((
|
|
305
|
-
s += this.renderNode(
|
|
304
|
+
return e.content.forEach((o) => {
|
|
305
|
+
s += this.renderNode(o);
|
|
306
306
|
}), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
|
|
307
307
|
}
|
|
308
308
|
return console.warn(
|
|
@@ -333,8 +333,8 @@ class xe {
|
|
|
333
333
|
), "";
|
|
334
334
|
}
|
|
335
335
|
optimizeImages(e, t) {
|
|
336
|
-
let r = 0, s = 0,
|
|
337
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
|
336
|
+
let r = 0, s = 0, o = "", i = "";
|
|
337
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, r = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, s = t.height), (t.loading === "lazy" || t.loading === "eager") && (o += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (o += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = `/filters${i}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
|
|
338
338
|
const l = r > 0 || s > 0 || i.length > 0 ? `${r}x${s}${i}` : "";
|
|
339
339
|
return e = e.replace(
|
|
340
340
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
@@ -345,7 +345,7 @@ class xe {
|
|
|
345
345
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
346
346
|
);
|
|
347
347
|
if (d && d.length > 0) {
|
|
348
|
-
const
|
|
348
|
+
const m = {
|
|
349
349
|
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
|
350
350
|
if (typeof y == "number")
|
|
351
351
|
return `//${d}/m/${y}x0${i} ${y}w`;
|
|
@@ -358,7 +358,7 @@ class xe {
|
|
|
358
358
|
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
|
359
359
|
};
|
|
360
360
|
let b = "";
|
|
361
|
-
return
|
|
361
|
+
return m.srcset && (b += `srcset="${m.srcset}" `), m.sizes && (b += `sizes="${m.sizes}" `), a.replace(/<img/g, `<img ${b.trim()}`);
|
|
362
362
|
}
|
|
363
363
|
return a;
|
|
364
364
|
})), e;
|
|
@@ -366,15 +366,15 @@ class xe {
|
|
|
366
366
|
renderNode(e) {
|
|
367
367
|
const t = [];
|
|
368
368
|
e.marks && e.marks.forEach((s) => {
|
|
369
|
-
const
|
|
370
|
-
|
|
369
|
+
const o = this.getMatchingMark(s);
|
|
370
|
+
o && o.tag !== "" && t.push(this.renderOpeningTag(o.tag));
|
|
371
371
|
});
|
|
372
372
|
const r = this.getMatchingNode(e);
|
|
373
373
|
return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((s) => {
|
|
374
374
|
t.push(this.renderNode(s));
|
|
375
375
|
}) : e.text ? t.push(Ie(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html ? t.push(r.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((s) => {
|
|
376
|
-
const
|
|
377
|
-
|
|
376
|
+
const o = this.getMatchingMark(s);
|
|
377
|
+
o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
|
|
378
378
|
}), t.join("");
|
|
379
379
|
}
|
|
380
380
|
renderTag(e, t) {
|
|
@@ -384,10 +384,10 @@ class xe {
|
|
|
384
384
|
{
|
|
385
385
|
let s = `<${r.tag}`;
|
|
386
386
|
if (r.attrs) {
|
|
387
|
-
for (const
|
|
388
|
-
if (Object.prototype.hasOwnProperty.call(r.attrs,
|
|
389
|
-
const i = r.attrs[
|
|
390
|
-
i !== null && (s += ` ${
|
|
387
|
+
for (const o in r.attrs)
|
|
388
|
+
if (Object.prototype.hasOwnProperty.call(r.attrs, o)) {
|
|
389
|
+
const i = r.attrs[o];
|
|
390
|
+
i !== null && (s += ` ${o}="${i}"`);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
return `${s}${t}>`;
|
|
@@ -473,9 +473,9 @@ class Oe {
|
|
|
473
473
|
)}`;
|
|
474
474
|
} else
|
|
475
475
|
r = JSON.stringify(this.parameters);
|
|
476
|
-
const s = new URL(t),
|
|
476
|
+
const s = new URL(t), o = new AbortController(), { signal: i } = o;
|
|
477
477
|
let l;
|
|
478
|
-
this.timeout && (l = setTimeout(() =>
|
|
478
|
+
this.timeout && (l = setTimeout(() => o.abort(), this.timeout));
|
|
479
479
|
try {
|
|
480
480
|
const a = await this.fetch(`${s}`, {
|
|
481
481
|
method: e,
|
|
@@ -506,12 +506,12 @@ class Oe {
|
|
|
506
506
|
return new Promise((r, s) => {
|
|
507
507
|
if (t.test(`${e.status}`))
|
|
508
508
|
return r(e);
|
|
509
|
-
const
|
|
509
|
+
const o = {
|
|
510
510
|
message: e.statusText,
|
|
511
511
|
status: e.status,
|
|
512
512
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
513
513
|
};
|
|
514
|
-
s(
|
|
514
|
+
s(o);
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
}
|
|
@@ -542,10 +542,10 @@ class Le {
|
|
|
542
542
|
P.defaultAgentVersion,
|
|
543
543
|
P.packageVersion
|
|
544
544
|
));
|
|
545
|
-
let
|
|
546
|
-
e.oauthToken && (s.set("Authorization", e.oauthToken),
|
|
545
|
+
let o = 5;
|
|
546
|
+
e.oauthToken && (s.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = te(
|
|
547
547
|
this.throttledRequest.bind(this),
|
|
548
|
-
|
|
548
|
+
o,
|
|
549
549
|
1e3
|
|
550
550
|
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Ae({
|
|
551
551
|
baseURL: r,
|
|
@@ -571,30 +571,30 @@ class Le {
|
|
|
571
571
|
factoryParamOptions(e, t) {
|
|
572
572
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
573
573
|
}
|
|
574
|
-
makeRequest(e, t, r, s,
|
|
574
|
+
makeRequest(e, t, r, s, o) {
|
|
575
575
|
const i = this.factoryParamOptions(
|
|
576
576
|
e,
|
|
577
577
|
this.helpers.getOptionsPage(t, r, s)
|
|
578
578
|
);
|
|
579
|
-
return this.cacheResponse(e, i, void 0,
|
|
579
|
+
return this.cacheResponse(e, i, void 0, o);
|
|
580
580
|
}
|
|
581
581
|
get(e, t, r) {
|
|
582
582
|
t || (t = {});
|
|
583
|
-
const s = `/${e}`,
|
|
584
|
-
return this.cacheResponse(s,
|
|
583
|
+
const s = `/${e}`, o = this.factoryParamOptions(s, t);
|
|
584
|
+
return this.cacheResponse(s, o, void 0, r);
|
|
585
585
|
}
|
|
586
586
|
async getAll(e, t, r, s) {
|
|
587
|
-
const
|
|
587
|
+
const o = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = r ?? i.substring(i.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
|
|
588
588
|
i,
|
|
589
589
|
t,
|
|
590
|
-
|
|
590
|
+
o,
|
|
591
591
|
a,
|
|
592
592
|
s
|
|
593
|
-
), u = h.total ? Math.ceil(h.total /
|
|
593
|
+
), u = h.total ? Math.ceil(h.total / o) : 1, d = await this.helpers.asyncMap(
|
|
594
594
|
this.helpers.range(a, u),
|
|
595
|
-
(
|
|
595
|
+
(m) => this.makeRequest(i, t, o, m + 1, s)
|
|
596
596
|
);
|
|
597
|
-
return this.helpers.flatMap([h, ...d], (
|
|
597
|
+
return this.helpers.flatMap([h, ...d], (m) => Object.values(m.data[l]));
|
|
598
598
|
}
|
|
599
599
|
post(e, t, r) {
|
|
600
600
|
const s = `/${e}`;
|
|
@@ -659,7 +659,7 @@ class Le {
|
|
|
659
659
|
_resolveField(e, t, r) {
|
|
660
660
|
const s = e[t];
|
|
661
661
|
typeof s == "string" ? e[t] = this.getStoryReference(r, s) : Array.isArray(s) && (e[t] = s.map(
|
|
662
|
-
(
|
|
662
|
+
(o) => this.getStoryReference(r, o)
|
|
663
663
|
).filter(Boolean));
|
|
664
664
|
}
|
|
665
665
|
/**
|
|
@@ -684,8 +684,8 @@ class Le {
|
|
|
684
684
|
this._resolveField(e, t, s);
|
|
685
685
|
return;
|
|
686
686
|
}
|
|
687
|
-
const
|
|
688
|
-
(Array.isArray(r) ? r.includes(
|
|
687
|
+
const o = e.component ? `${e.component}.${t}` : t;
|
|
688
|
+
(Array.isArray(r) ? r.includes(o) : r === o) && this._resolveField(e, t, s);
|
|
689
689
|
}
|
|
690
690
|
/**
|
|
691
691
|
* Recursively traverses and resolves relations in the story content tree
|
|
@@ -694,14 +694,14 @@ class Le {
|
|
|
694
694
|
* @param resolveId - The unique identifier for the current resolution context
|
|
695
695
|
*/
|
|
696
696
|
iterateTree(e, t, r) {
|
|
697
|
-
const s = (
|
|
698
|
-
if (!(!
|
|
699
|
-
if (Array.isArray(
|
|
700
|
-
|
|
701
|
-
else if (typeof
|
|
702
|
-
for (const l in
|
|
697
|
+
const s = (o, i = "") => {
|
|
698
|
+
if (!(!o || o._stopResolving)) {
|
|
699
|
+
if (Array.isArray(o))
|
|
700
|
+
o.forEach((l, a) => s(l, `${i}[${a}]`));
|
|
701
|
+
else if (typeof o == "object")
|
|
702
|
+
for (const l in o) {
|
|
703
703
|
const a = i ? `${i}.${l}` : l;
|
|
704
|
-
(
|
|
704
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(o, l, t, r), this._insertLinks(o, l, r)), s(o[l], a);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
};
|
|
@@ -710,9 +710,9 @@ class Le {
|
|
|
710
710
|
async resolveLinks(e, t, r) {
|
|
711
711
|
let s = [];
|
|
712
712
|
if (e.link_uuids) {
|
|
713
|
-
const
|
|
714
|
-
for (let a = 0; a <
|
|
715
|
-
const h = Math.min(
|
|
713
|
+
const o = e.link_uuids.length, i = [], l = 50;
|
|
714
|
+
for (let a = 0; a < o; a += l) {
|
|
715
|
+
const h = Math.min(o, a + l);
|
|
716
716
|
i.push(e.link_uuids.slice(a, h));
|
|
717
717
|
}
|
|
718
718
|
for (let a = 0; a < i.length; a++)
|
|
@@ -728,9 +728,9 @@ class Le {
|
|
|
728
728
|
);
|
|
729
729
|
} else
|
|
730
730
|
s = e.links;
|
|
731
|
-
s.forEach((
|
|
732
|
-
this.links[r][
|
|
733
|
-
...
|
|
731
|
+
s.forEach((o) => {
|
|
732
|
+
this.links[r][o.uuid] = {
|
|
733
|
+
...o,
|
|
734
734
|
_stopResolving: !0
|
|
735
735
|
};
|
|
736
736
|
});
|
|
@@ -738,9 +738,9 @@ class Le {
|
|
|
738
738
|
async resolveRelations(e, t, r) {
|
|
739
739
|
let s = [];
|
|
740
740
|
if (e.rel_uuids) {
|
|
741
|
-
const
|
|
742
|
-
for (let a = 0; a <
|
|
743
|
-
const h = Math.min(
|
|
741
|
+
const o = e.rel_uuids.length, i = [], l = 50;
|
|
742
|
+
for (let a = 0; a < o; a += l) {
|
|
743
|
+
const h = Math.min(o, a + l);
|
|
744
744
|
i.push(e.rel_uuids.slice(a, h));
|
|
745
745
|
}
|
|
746
746
|
for (let a = 0; a < i.length; a++)
|
|
@@ -755,9 +755,9 @@ class Le {
|
|
|
755
755
|
});
|
|
756
756
|
} else
|
|
757
757
|
s = e.rels;
|
|
758
|
-
s && s.length > 0 && s.forEach((
|
|
759
|
-
this.relations[r][
|
|
760
|
-
...
|
|
758
|
+
s && s.length > 0 && s.forEach((o) => {
|
|
759
|
+
this.relations[r][o.uuid] = {
|
|
760
|
+
...o,
|
|
761
761
|
_stopResolving: !0
|
|
762
762
|
};
|
|
763
763
|
});
|
|
@@ -772,9 +772,9 @@ class Le {
|
|
|
772
772
|
*
|
|
773
773
|
*/
|
|
774
774
|
async resolveStories(e, t, r) {
|
|
775
|
-
var s,
|
|
775
|
+
var s, o;
|
|
776
776
|
let i = [];
|
|
777
|
-
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (
|
|
777
|
+
if (this.links[r] = {}, this.relations[r] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, r)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((s = e.links) != null && s.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, r), this.resolveNestedRelations)
|
|
778
778
|
for (const l in this.relations[r])
|
|
779
779
|
this.iterateTree(
|
|
780
780
|
this.relations[r][l],
|
|
@@ -786,9 +786,9 @@ class Le {
|
|
|
786
786
|
}), this.stringifiedStoriesCache = {}, delete this.links[r], delete this.relations[r];
|
|
787
787
|
}
|
|
788
788
|
async cacheResponse(e, t, r, s) {
|
|
789
|
-
const
|
|
789
|
+
const o = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
790
790
|
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
|
|
791
|
-
const l = await i.get(
|
|
791
|
+
const l = await i.get(o);
|
|
792
792
|
if (l)
|
|
793
793
|
return Promise.resolve(l);
|
|
794
794
|
}
|
|
@@ -808,10 +808,10 @@ class Le {
|
|
|
808
808
|
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
|
809
809
|
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
|
810
810
|
})), d.data.story || d.data.stories) {
|
|
811
|
-
const
|
|
812
|
-
await this.resolveStories(d.data, t, `${
|
|
811
|
+
const m = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
812
|
+
await this.resolveStories(d.data, t, `${m}`);
|
|
813
813
|
}
|
|
814
|
-
return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(
|
|
814
|
+
return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(o, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), l(d);
|
|
815
815
|
} catch (u) {
|
|
816
816
|
if (u.response && u.status === 429 && (r = typeof r > "u" ? 0 : r + 1, r < this.maxRetries))
|
|
817
817
|
return console.log(
|
|
@@ -877,8 +877,8 @@ class Le {
|
|
|
877
877
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
|
-
const ze = (
|
|
881
|
-
const { apiOptions: e } =
|
|
880
|
+
const ze = (n = {}) => {
|
|
881
|
+
const { apiOptions: e } = n;
|
|
882
882
|
if (!e || !e.accessToken) {
|
|
883
883
|
console.error(
|
|
884
884
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
@@ -886,12 +886,12 @@ const ze = (o = {}) => {
|
|
|
886
886
|
return;
|
|
887
887
|
}
|
|
888
888
|
return { storyblokApi: new Le(e) };
|
|
889
|
-
}, De = (
|
|
890
|
-
if (typeof
|
|
889
|
+
}, De = (n) => {
|
|
890
|
+
if (typeof n != "object" || typeof n._editable > "u")
|
|
891
891
|
return {};
|
|
892
892
|
try {
|
|
893
893
|
const e = JSON.parse(
|
|
894
|
-
|
|
894
|
+
n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
895
895
|
);
|
|
896
896
|
return e ? {
|
|
897
897
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -901,38 +901,38 @@ const ze = (o = {}) => {
|
|
|
901
901
|
return {};
|
|
902
902
|
}
|
|
903
903
|
};
|
|
904
|
-
function Ce(
|
|
904
|
+
function Ce(n, e) {
|
|
905
905
|
if (!e)
|
|
906
|
-
return { src:
|
|
906
|
+
return { src: n, attrs: {} };
|
|
907
907
|
let t = 0, r = 0;
|
|
908
|
-
const s = {},
|
|
909
|
-
function i(a, h, u, d,
|
|
910
|
-
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) :
|
|
908
|
+
const s = {}, o = [];
|
|
909
|
+
function i(a, h, u, d, m) {
|
|
910
|
+
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : m.push(`${d}(${a})`);
|
|
911
911
|
}
|
|
912
912
|
if (typeof e == "object") {
|
|
913
913
|
if (typeof e.width == "number" && e.width > 0 ? (s.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 ? (s.height = e.height, r = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (s.loading = e.loading), e.class && (s.class = e.class), e.filters) {
|
|
914
|
-
const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format:
|
|
915
|
-
h && i(h, 0, 100, "blur",
|
|
914
|
+
const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: m, grayscale: b, quality: y, rotate: _ } = a || {};
|
|
915
|
+
h && i(h, 0, 100, "blur", o), y && i(y, 0, 100, "quality", o), u && i(u, 0, 100, "brightness", o), d && o.push(`fill(${d})`), b && o.push("grayscale()"), _ && [0, 90, 180, 270].includes(e.filters.rotate || 0) && o.push(`rotate(${_})`), m && ["webp", "png", "jpeg"].includes(m) && o.push(`format(${m})`);
|
|
916
916
|
}
|
|
917
917
|
e.srcset && (s.srcset = e.srcset.map((a) => {
|
|
918
918
|
if (typeof a == "number")
|
|
919
|
-
return `${
|
|
919
|
+
return `${n}/m/${a}x0/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${a}w`;
|
|
920
920
|
if (Array.isArray(a) && a.length === 2) {
|
|
921
921
|
const [h, u] = a;
|
|
922
|
-
return `${
|
|
922
|
+
return `${n}/m/${h}x${u}/${o.length > 0 ? `filters:${o.join(":")}` : ""} ${h}w`;
|
|
923
923
|
} else {
|
|
924
924
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
925
925
|
return;
|
|
926
926
|
}
|
|
927
927
|
}).join(", ")), e.sizes && (s.sizes = e.sizes.join(", "));
|
|
928
928
|
}
|
|
929
|
-
let l = `${
|
|
930
|
-
return t > 0 && r > 0 && (l = `${l}${t}x${r}/`),
|
|
929
|
+
let l = `${n}/m/`;
|
|
930
|
+
return t > 0 && r > 0 && (l = `${l}${t}x${r}/`), o.length > 0 && (l = `${l}filters:${o.join(":")}`), {
|
|
931
931
|
src: l,
|
|
932
932
|
attrs: s
|
|
933
933
|
};
|
|
934
934
|
}
|
|
935
|
-
var
|
|
935
|
+
var v = /* @__PURE__ */ ((n) => (n.DOCUMENT = "doc", n.HEADING = "heading", n.PARAGRAPH = "paragraph", n.QUOTE = "blockquote", n.OL_LIST = "ordered_list", n.UL_LIST = "bullet_list", n.LIST_ITEM = "list_item", n.CODE_BLOCK = "code_block", n.HR = "horizontal_rule", n.BR = "hard_break", n.IMAGE = "image", n.EMOJI = "emoji", n.COMPONENT = "blok", n))(v || {}), T = /* @__PURE__ */ ((n) => (n.BOLD = "bold", n.STRONG = "strong", n.STRIKE = "strike", n.UNDERLINE = "underline", n.ITALIC = "italic", n.CODE = "code", n.LINK = "link", n.ANCHOR = "anchor", n.STYLED = "styled", n.SUPERSCRIPT = "superscript", n.SUBSCRIPT = "subscript", n.TEXT_STYLE = "textStyle", n.HIGHLIGHT = "highlight", n))(T || {}), G = /* @__PURE__ */ ((n) => (n.TEXT = "text", n))(G || {}), I = /* @__PURE__ */ ((n) => (n.URL = "url", n.STORY = "story", n.ASSET = "asset", n.EMAIL = "email", n))(I || {});
|
|
936
936
|
const Pe = [
|
|
937
937
|
"area",
|
|
938
938
|
"base",
|
|
@@ -948,35 +948,35 @@ const Pe = [
|
|
|
948
948
|
"source",
|
|
949
949
|
"track",
|
|
950
950
|
"wbr"
|
|
951
|
-
], Ne = (
|
|
952
|
-
function He(
|
|
953
|
-
return
|
|
951
|
+
], Ne = (n = {}) => Object.keys(n).map((e) => `${e}="${n[e]}"`).join(" "), Me = (n = {}) => Object.keys(n).map((e) => `${e}: ${n[e]}`).join("; ");
|
|
952
|
+
function He(n) {
|
|
953
|
+
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
954
954
|
}
|
|
955
|
-
const B = (
|
|
956
|
-
function q(
|
|
957
|
-
const r = Ne(e), s = r ? `${
|
|
958
|
-
if (
|
|
959
|
-
if (Pe.includes(
|
|
955
|
+
const B = (n) => Object.fromEntries(Object.entries(n).filter(([e, t]) => t !== void 0));
|
|
956
|
+
function q(n, e = {}, t) {
|
|
957
|
+
const r = Ne(e), s = r ? `${n} ${r}` : n, o = Array.isArray(t) ? t.join("") : t || "";
|
|
958
|
+
if (n) {
|
|
959
|
+
if (Pe.includes(n))
|
|
960
960
|
return `<${s}>`;
|
|
961
|
-
} else return
|
|
962
|
-
return `<${s}>${
|
|
961
|
+
} else return o;
|
|
962
|
+
return `<${s}>${o}</${n}>`;
|
|
963
963
|
}
|
|
964
|
-
function Be(
|
|
964
|
+
function Be(n = {}) {
|
|
965
965
|
let e = 0;
|
|
966
966
|
const {
|
|
967
967
|
renderFn: t = q,
|
|
968
968
|
textFn: r = He,
|
|
969
969
|
resolvers: s = {},
|
|
970
|
-
optimizeImages:
|
|
970
|
+
optimizeImages: o = !1,
|
|
971
971
|
keyedResolvers: i = !1
|
|
972
|
-
} =
|
|
973
|
-
const
|
|
974
|
-
return i && (
|
|
972
|
+
} = n, l = t !== q, a = (c) => (g) => {
|
|
973
|
+
const f = g.attrs || {};
|
|
974
|
+
return i && (f.key = `${c}-${e}`), t(c, f, g.children || null);
|
|
975
975
|
}, h = (c) => {
|
|
976
|
-
const { src: g, alt:
|
|
976
|
+
const { src: g, alt: f, title: k, srcset: R, sizes: $ } = c.attrs || {};
|
|
977
977
|
let w = g, S = {};
|
|
978
|
-
if (
|
|
979
|
-
const { src: W, attrs: X } = Ce(g,
|
|
978
|
+
if (o) {
|
|
979
|
+
const { src: W, attrs: X } = Ce(g, o);
|
|
980
980
|
w = W, S = X;
|
|
981
981
|
}
|
|
982
982
|
i && (S = {
|
|
@@ -985,23 +985,23 @@ function Be(o = {}) {
|
|
|
985
985
|
});
|
|
986
986
|
const Y = {
|
|
987
987
|
src: w,
|
|
988
|
-
alt:
|
|
988
|
+
alt: f,
|
|
989
989
|
title: k,
|
|
990
990
|
srcset: R,
|
|
991
|
-
sizes:
|
|
991
|
+
sizes: $,
|
|
992
992
|
...S
|
|
993
993
|
};
|
|
994
994
|
return t("img", B(Y));
|
|
995
995
|
}, u = (c) => {
|
|
996
|
-
const { level: g, ...
|
|
997
|
-
...
|
|
996
|
+
const { level: g, ...f } = c.attrs || {}, k = {
|
|
997
|
+
...f
|
|
998
998
|
};
|
|
999
999
|
return i && (k.key = `h${g}-${e}`), t(`h${g}`, k, c.children);
|
|
1000
1000
|
}, d = (c) => {
|
|
1001
|
-
var g,
|
|
1002
|
-
const
|
|
1001
|
+
var g, f, k, R;
|
|
1002
|
+
const $ = t("img", {
|
|
1003
1003
|
src: (g = c.attrs) == null ? void 0 : g.fallbackImage,
|
|
1004
|
-
alt: (
|
|
1004
|
+
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
1005
1005
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
1006
1006
|
draggable: "false",
|
|
1007
1007
|
loading: "lazy"
|
|
@@ -1010,67 +1010,67 @@ function Be(o = {}) {
|
|
|
1010
1010
|
"data-name": (k = c.attrs) == null ? void 0 : k.name,
|
|
1011
1011
|
"data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
|
|
1012
1012
|
};
|
|
1013
|
-
return i && (w.key = `emoji-${e}`), t("span", w,
|
|
1014
|
-
},
|
|
1013
|
+
return i && (w.key = `emoji-${e}`), t("span", w, $);
|
|
1014
|
+
}, m = (c) => t("pre", {
|
|
1015
1015
|
...c.attrs,
|
|
1016
1016
|
key: `code-${e}`
|
|
1017
|
-
}, t("code", { key: `code-${e}` }, c.children || "")), b = (c, g = !1) => ({ text:
|
|
1018
|
-
const { class: R, id:
|
|
1017
|
+
}, t("code", { key: `code-${e}` }, c.children || "")), b = (c, g = !1) => ({ text: f, attrs: k }) => {
|
|
1018
|
+
const { class: R, id: $, ...w } = k || {}, S = g ? {
|
|
1019
1019
|
class: R,
|
|
1020
|
-
id:
|
|
1020
|
+
id: $,
|
|
1021
1021
|
style: Me(w) || void 0
|
|
1022
1022
|
} : k || {};
|
|
1023
|
-
return i && (S.key = `${c}-${e}`), t(c, B(S),
|
|
1023
|
+
return i && (S.key = `${c}-${e}`), t(c, B(S), f);
|
|
1024
1024
|
}, y = (c) => C(c), _ = (c) => {
|
|
1025
|
-
const { marks: g, ...
|
|
1025
|
+
const { marks: g, ...f } = c;
|
|
1026
1026
|
return "text" in c ? g ? g.reduce(
|
|
1027
1027
|
(k, R) => y({ ...R, text: k }),
|
|
1028
1028
|
// Fix: Ensure render function returns a string
|
|
1029
|
-
y({ ...
|
|
1029
|
+
y({ ...f, children: f.children })
|
|
1030
1030
|
// Fix: Cast children to string
|
|
1031
|
-
) : r(
|
|
1031
|
+
) : r(f.text) : "";
|
|
1032
1032
|
}, j = (c) => {
|
|
1033
|
-
const { linktype: g, href:
|
|
1034
|
-
let
|
|
1033
|
+
const { linktype: g, href: f, anchor: k, ...R } = c.attrs || {};
|
|
1034
|
+
let $ = "";
|
|
1035
1035
|
switch (g) {
|
|
1036
1036
|
case I.ASSET:
|
|
1037
1037
|
case I.URL:
|
|
1038
|
-
|
|
1038
|
+
$ = f;
|
|
1039
1039
|
break;
|
|
1040
1040
|
case I.EMAIL:
|
|
1041
|
-
|
|
1041
|
+
$ = `mailto:${f}`;
|
|
1042
1042
|
break;
|
|
1043
1043
|
case I.STORY:
|
|
1044
|
-
|
|
1044
|
+
$ = f, k && ($ = `${$}#${k}`);
|
|
1045
1045
|
break;
|
|
1046
1046
|
default:
|
|
1047
|
-
|
|
1047
|
+
$ = f;
|
|
1048
1048
|
break;
|
|
1049
1049
|
}
|
|
1050
1050
|
const w = { ...R };
|
|
1051
|
-
return
|
|
1051
|
+
return $ && (w.href = $), i && (w.key = `a-${e}`), t("a", w, c.text);
|
|
1052
1052
|
}, J = (c) => {
|
|
1053
|
-
var g,
|
|
1053
|
+
var g, f;
|
|
1054
1054
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
1055
1055
|
blok: (g = c == null ? void 0 : c.attrs) == null ? void 0 : g.body[0],
|
|
1056
|
-
id: (
|
|
1056
|
+
id: (f = c.attrs) == null ? void 0 : f.id,
|
|
1057
1057
|
key: `component-${e}`,
|
|
1058
1058
|
style: "display: none"
|
|
1059
1059
|
});
|
|
1060
1060
|
}, K = new Map([
|
|
1061
|
-
[
|
|
1062
|
-
[
|
|
1063
|
-
[
|
|
1064
|
-
[
|
|
1065
|
-
[
|
|
1066
|
-
[
|
|
1067
|
-
[
|
|
1068
|
-
[
|
|
1069
|
-
[
|
|
1070
|
-
[
|
|
1071
|
-
[
|
|
1072
|
-
[
|
|
1073
|
-
[
|
|
1061
|
+
[v.DOCUMENT, a("")],
|
|
1062
|
+
[v.HEADING, u],
|
|
1063
|
+
[v.PARAGRAPH, a("p")],
|
|
1064
|
+
[v.UL_LIST, a("ul")],
|
|
1065
|
+
[v.OL_LIST, a("ol")],
|
|
1066
|
+
[v.LIST_ITEM, a("li")],
|
|
1067
|
+
[v.IMAGE, h],
|
|
1068
|
+
[v.EMOJI, d],
|
|
1069
|
+
[v.CODE_BLOCK, m],
|
|
1070
|
+
[v.HR, a("hr")],
|
|
1071
|
+
[v.BR, a("br")],
|
|
1072
|
+
[v.QUOTE, a("blockquote")],
|
|
1073
|
+
[v.COMPONENT, J],
|
|
1074
1074
|
[G.TEXT, _],
|
|
1075
1075
|
[T.LINK, j],
|
|
1076
1076
|
[T.ANCHOR, j],
|
|
@@ -1093,10 +1093,10 @@ function Be(o = {}) {
|
|
|
1093
1093
|
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
1094
1094
|
if (c.type === "text")
|
|
1095
1095
|
return g(c);
|
|
1096
|
-
const
|
|
1096
|
+
const f = c.content ? c.content.map(C) : void 0;
|
|
1097
1097
|
return g({
|
|
1098
1098
|
...c,
|
|
1099
|
-
children:
|
|
1099
|
+
children: f
|
|
1100
1100
|
// Fix: Update the type of 'children' to Node[]
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
@@ -1108,25 +1108,25 @@ function Be(o = {}) {
|
|
|
1108
1108
|
};
|
|
1109
1109
|
}
|
|
1110
1110
|
let N, M = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1111
|
-
const qe = (
|
|
1111
|
+
const qe = (n, e, t = {}) => {
|
|
1112
1112
|
var r;
|
|
1113
|
-
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u",
|
|
1113
|
+
const s = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
1114
1114
|
"_storyblok"
|
|
1115
|
-
), i =
|
|
1115
|
+
), i = o !== null && +o === n;
|
|
1116
1116
|
if (!(!s || !i)) {
|
|
1117
|
-
if (!
|
|
1117
|
+
if (!n) {
|
|
1118
1118
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
1119
1119
|
return;
|
|
1120
1120
|
}
|
|
1121
1121
|
window.storyblokRegisterEvent(() => {
|
|
1122
1122
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
|
|
1123
1123
|
var a;
|
|
1124
|
-
l && (l.action === "input" && ((a = l.story) == null ? void 0 : a.id) ===
|
|
1124
|
+
l && (l.action === "input" && ((a = l.story) == null ? void 0 : a.id) === n ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === n && window.location.reload());
|
|
1125
1125
|
});
|
|
1126
1126
|
});
|
|
1127
1127
|
}
|
|
1128
|
-
}, V = (
|
|
1129
|
-
|
|
1128
|
+
}, V = (n, e) => {
|
|
1129
|
+
n.addNode("blok", (t) => {
|
|
1130
1130
|
let r = "";
|
|
1131
1131
|
return t.attrs.body.forEach((s) => {
|
|
1132
1132
|
r += e(s.component, s);
|
|
@@ -1134,28 +1134,28 @@ const qe = (o, e, t = {}) => {
|
|
|
1134
1134
|
html: r
|
|
1135
1135
|
};
|
|
1136
1136
|
});
|
|
1137
|
-
}, Fe = (
|
|
1137
|
+
}, Fe = (n = {}) => {
|
|
1138
1138
|
var e, t;
|
|
1139
1139
|
const {
|
|
1140
1140
|
bridge: r,
|
|
1141
1141
|
accessToken: s,
|
|
1142
|
-
use:
|
|
1142
|
+
use: o = [],
|
|
1143
1143
|
apiOptions: i = {},
|
|
1144
1144
|
richText: l = {},
|
|
1145
1145
|
bridgeUrl: a
|
|
1146
|
-
} =
|
|
1146
|
+
} = n;
|
|
1147
1147
|
i.accessToken = i.accessToken || s;
|
|
1148
1148
|
const h = { bridge: r, apiOptions: i };
|
|
1149
1149
|
let u = {};
|
|
1150
|
-
|
|
1151
|
-
u = { ...u, ...
|
|
1150
|
+
o.forEach((m) => {
|
|
1151
|
+
u = { ...u, ...m(h) };
|
|
1152
1152
|
}), a && (M = a);
|
|
1153
1153
|
const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1154
1154
|
return r !== !1 && d && F(M), N = new L(l.schema), l.resolver && V(N, l.resolver), u;
|
|
1155
|
-
}, Ue = (
|
|
1155
|
+
}, Ue = (n) => {
|
|
1156
1156
|
var e;
|
|
1157
|
-
return !
|
|
1158
|
-
}, Ge = (
|
|
1157
|
+
return !n || !((e = n == null ? void 0 : n.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
|
|
1158
|
+
}, Ge = (n, e, t) => {
|
|
1159
1159
|
let r = t || N;
|
|
1160
1160
|
if (!r) {
|
|
1161
1161
|
console.error(
|
|
@@ -1163,10 +1163,10 @@ const qe = (o, e, t = {}) => {
|
|
|
1163
1163
|
);
|
|
1164
1164
|
return;
|
|
1165
1165
|
}
|
|
1166
|
-
return Ue(
|
|
1166
|
+
return Ue(n) ? "" : (e && (r = new L(e.schema), e.resolver && V(r, e.resolver)), r.render(n, {}, !1));
|
|
1167
1167
|
}, Ve = () => F(M);
|
|
1168
1168
|
export {
|
|
1169
|
-
|
|
1169
|
+
v as BlockTypes,
|
|
1170
1170
|
T as MarkTypes,
|
|
1171
1171
|
L as RichTextResolver,
|
|
1172
1172
|
je as RichTextSchema,
|