@storyblok/react 4.2.1 → 4.3.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 +108 -1
- package/dist/client.js +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/storyblok-component.d.ts +2 -2
- package/dist/common/storyblok-component.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +39 -29
- package/dist/index2.js +1 -1
- package/dist/index2.mjs +22 -18
- package/dist/live-editing.js +1 -1
- package/dist/richtext.d.ts +7 -0
- package/dist/richtext.d.ts.map +1 -0
- package/dist/richtext.js +1 -0
- package/dist/richtext.mjs +26 -0
- package/dist/rsc/index.d.ts +3 -0
- package/dist/rsc/index.d.ts.map +1 -1
- package/dist/rsc/server-component.d.ts +2 -2
- package/dist/rsc/server-component.d.ts.map +1 -1
- package/dist/rsc/story.d.ts +2 -2
- package/dist/rsc/story.d.ts.map +1 -1
- package/dist/rsc.js +1 -1
- package/dist/rsc.mjs +29 -21
- package/dist/server-component.js +1 -1
- package/dist/server-component.mjs +2 -0
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +541 -339
- package/dist/storyblok-rich-text.d.ts +5 -0
- package/dist/storyblok-rich-text.d.ts.map +1 -0
- package/dist/storyblok-rich-text.js +1 -0
- package/dist/storyblok-rich-text.mjs +15 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +1 -0
- package/dist/utils.mjs +33 -0
- package/package.json +9 -2
package/dist/storyblok-js.mjs
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
3
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (
|
|
1
|
+
let H = !1;
|
|
2
|
+
const U = [], q = (r) => new Promise((e, t) => {
|
|
3
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
|
|
4
4
|
if (window.location === window.parent.location) {
|
|
5
5
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
H ? o() : U.push(o);
|
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge"))) return;
|
|
10
10
|
const s = document.createElement("script");
|
|
11
|
-
s.async = !0, s.src =
|
|
12
|
-
|
|
11
|
+
s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
|
|
12
|
+
U.forEach((n) => n()), H = !0, e(o);
|
|
13
13
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
14
14
|
});
|
|
15
|
-
var
|
|
16
|
-
class
|
|
15
|
+
var X = Object.defineProperty, W = (r, e, t) => e in r ? X(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => W(r, typeof e != "symbol" ? e + "" : e, t);
|
|
16
|
+
class Q extends Error {
|
|
17
17
|
constructor(e) {
|
|
18
18
|
super(e), this.name = "AbortError";
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function Z(r, e, t) {
|
|
22
22
|
if (!Number.isFinite(e))
|
|
23
23
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
24
24
|
if (!Number.isFinite(t))
|
|
25
25
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
26
26
|
const s = [];
|
|
27
|
-
let
|
|
28
|
-
const
|
|
29
|
-
|
|
27
|
+
let o = [], n = 0, i = !1;
|
|
28
|
+
const l = async () => {
|
|
29
|
+
n++;
|
|
30
30
|
const h = s.shift();
|
|
31
31
|
if (h)
|
|
32
32
|
try {
|
|
33
|
-
const d = await
|
|
33
|
+
const d = await r(...h.args);
|
|
34
34
|
h.resolve(d);
|
|
35
35
|
} catch (d) {
|
|
36
36
|
h.reject(d);
|
|
37
37
|
}
|
|
38
38
|
const u = setTimeout(() => {
|
|
39
|
-
|
|
39
|
+
n--, s.length > 0 && l(), o = o.filter((d) => d !== u);
|
|
40
40
|
}, t);
|
|
41
|
-
|
|
42
|
-
},
|
|
41
|
+
o.includes(u) || o.push(u);
|
|
42
|
+
}, a = (...h) => i ? Promise.reject(
|
|
43
43
|
new Error(
|
|
44
44
|
"Throttled function is already aborted and not accepting new promises"
|
|
45
45
|
)
|
|
@@ -48,24 +48,24 @@ function N(o, e, t) {
|
|
|
48
48
|
resolve: u,
|
|
49
49
|
reject: d,
|
|
50
50
|
args: h
|
|
51
|
-
}),
|
|
51
|
+
}), n < e && l();
|
|
52
52
|
});
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
(h) => h.reject(() => new
|
|
53
|
+
return a.abort = () => {
|
|
54
|
+
i = !0, o.forEach(clearTimeout), o = [], s.forEach(
|
|
55
|
+
(h) => h.reject(() => new Q("Throttle function aborted"))
|
|
56
56
|
), s.length = 0;
|
|
57
|
-
},
|
|
57
|
+
}, a;
|
|
58
58
|
}
|
|
59
|
-
let
|
|
59
|
+
let O = class {
|
|
60
60
|
constructor() {
|
|
61
|
-
|
|
62
|
-
...
|
|
61
|
+
p(this, "isCDNUrl", (r = "") => r.includes("/cdn/")), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
|
|
62
|
+
...r,
|
|
63
63
|
per_page: e,
|
|
64
64
|
page: t
|
|
65
|
-
})),
|
|
66
|
-
const t = Math.abs(e -
|
|
67
|
-
return this.arrayFrom(t, (
|
|
68
|
-
}),
|
|
65
|
+
})), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => Array.from({ length: r }, e)), p(this, "range", (r = 0, e = r) => {
|
|
66
|
+
const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
67
|
+
return this.arrayFrom(t, (o, n) => n * s + r);
|
|
68
|
+
}), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
|
|
69
69
|
const e = {
|
|
70
70
|
"&": "&",
|
|
71
71
|
"<": "<",
|
|
@@ -73,7 +73,7 @@ let y = class {
|
|
|
73
73
|
'"': """,
|
|
74
74
|
"'": "'"
|
|
75
75
|
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
76
|
-
return
|
|
76
|
+
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
@@ -83,18 +83,18 @@ let y = class {
|
|
|
83
83
|
* @param {boolean} isArray
|
|
84
84
|
* @return {string} Stringified object
|
|
85
85
|
*/
|
|
86
|
-
stringify(
|
|
86
|
+
stringify(r, e, t) {
|
|
87
87
|
const s = [];
|
|
88
|
-
for (const
|
|
89
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
88
|
+
for (const o in r) {
|
|
89
|
+
if (!Object.prototype.hasOwnProperty.call(r, o))
|
|
90
90
|
continue;
|
|
91
|
-
const
|
|
92
|
-
let
|
|
93
|
-
typeof
|
|
94
|
-
|
|
95
|
-
e ? e + encodeURIComponent(`[${
|
|
96
|
-
Array.isArray(
|
|
97
|
-
) :
|
|
91
|
+
const n = r[o], i = t ? "" : encodeURIComponent(o);
|
|
92
|
+
let l;
|
|
93
|
+
typeof n == "object" ? l = this.stringify(
|
|
94
|
+
n,
|
|
95
|
+
e ? e + encodeURIComponent(`[${i}]`) : i,
|
|
96
|
+
Array.isArray(n)
|
|
97
|
+
) : l = `${e ? e + encodeURIComponent(`[${i}]`) : i}=${encodeURIComponent(n)}`, s.push(l);
|
|
98
98
|
}
|
|
99
99
|
return s.join("&");
|
|
100
100
|
}
|
|
@@ -103,92 +103,92 @@ let y = class {
|
|
|
103
103
|
* @param {string} regionCode region code, could be eu, us, cn, ap or ca
|
|
104
104
|
* @return {string} The base URL of the region
|
|
105
105
|
*/
|
|
106
|
-
getRegionURL(
|
|
107
|
-
const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn",
|
|
108
|
-
switch (
|
|
106
|
+
getRegionURL(r) {
|
|
107
|
+
const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
108
|
+
switch (r) {
|
|
109
109
|
case "us":
|
|
110
110
|
return t;
|
|
111
111
|
case "cn":
|
|
112
112
|
return s;
|
|
113
113
|
case "ap":
|
|
114
|
-
return
|
|
114
|
+
return o;
|
|
115
115
|
case "ca":
|
|
116
|
-
return
|
|
116
|
+
return n;
|
|
117
117
|
default:
|
|
118
118
|
return e;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
const
|
|
122
|
+
const ee = function(r, e) {
|
|
123
123
|
const t = {};
|
|
124
|
-
for (const s in
|
|
125
|
-
const
|
|
126
|
-
e.includes(s) &&
|
|
124
|
+
for (const s in r) {
|
|
125
|
+
const o = r[s];
|
|
126
|
+
e.includes(s) && o !== null && (t[s] = o);
|
|
127
127
|
}
|
|
128
128
|
return t;
|
|
129
|
-
},
|
|
129
|
+
}, te = (r) => r === "email", re = () => ({
|
|
130
130
|
singleTag: "hr"
|
|
131
|
-
}),
|
|
131
|
+
}), se = () => ({
|
|
132
132
|
tag: "blockquote"
|
|
133
|
-
}),
|
|
133
|
+
}), oe = () => ({
|
|
134
134
|
tag: "ul"
|
|
135
|
-
}),
|
|
135
|
+
}), ne = (r) => ({
|
|
136
136
|
tag: [
|
|
137
137
|
"pre",
|
|
138
138
|
{
|
|
139
139
|
tag: "code",
|
|
140
|
-
attrs:
|
|
140
|
+
attrs: r.attrs
|
|
141
141
|
}
|
|
142
142
|
]
|
|
143
|
-
}),
|
|
143
|
+
}), ie = () => ({
|
|
144
144
|
singleTag: "br"
|
|
145
|
-
}),
|
|
146
|
-
tag: `h${
|
|
147
|
-
}),
|
|
145
|
+
}), ae = (r) => ({
|
|
146
|
+
tag: `h${r.attrs.level}`
|
|
147
|
+
}), le = (r) => ({
|
|
148
148
|
singleTag: [
|
|
149
149
|
{
|
|
150
150
|
tag: "img",
|
|
151
|
-
attrs:
|
|
151
|
+
attrs: ee(r.attrs, ["src", "alt", "title"])
|
|
152
152
|
}
|
|
153
153
|
]
|
|
154
|
-
}),
|
|
154
|
+
}), ce = () => ({
|
|
155
155
|
tag: "li"
|
|
156
|
-
}),
|
|
156
|
+
}), he = () => ({
|
|
157
157
|
tag: "ol"
|
|
158
|
-
}),
|
|
158
|
+
}), ue = () => ({
|
|
159
159
|
tag: "p"
|
|
160
|
-
}),
|
|
160
|
+
}), de = (r) => ({
|
|
161
161
|
tag: [
|
|
162
162
|
{
|
|
163
163
|
tag: "span",
|
|
164
164
|
attrs: {
|
|
165
165
|
"data-type": "emoji",
|
|
166
|
-
"data-name":
|
|
167
|
-
emoji:
|
|
166
|
+
"data-name": r.attrs.name,
|
|
167
|
+
emoji: r.attrs.emoji
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
]
|
|
171
|
-
}),
|
|
171
|
+
}), pe = () => ({
|
|
172
172
|
tag: "b"
|
|
173
|
-
}),
|
|
173
|
+
}), ge = () => ({
|
|
174
174
|
tag: "s"
|
|
175
|
-
}),
|
|
175
|
+
}), me = () => ({
|
|
176
176
|
tag: "u"
|
|
177
|
-
}),
|
|
177
|
+
}), fe = () => ({
|
|
178
178
|
tag: "strong"
|
|
179
|
-
}),
|
|
179
|
+
}), ye = () => ({
|
|
180
180
|
tag: "code"
|
|
181
|
-
}),
|
|
181
|
+
}), be = () => ({
|
|
182
182
|
tag: "i"
|
|
183
|
-
}),
|
|
184
|
-
if (!
|
|
183
|
+
}), ke = (r) => {
|
|
184
|
+
if (!r.attrs)
|
|
185
185
|
return {
|
|
186
186
|
tag: ""
|
|
187
187
|
};
|
|
188
|
-
const e = new
|
|
189
|
-
if (delete t.linktype, t.href && (t.href = e(
|
|
190
|
-
for (const
|
|
191
|
-
t[
|
|
188
|
+
const e = new O().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
|
|
189
|
+
if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), te(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
190
|
+
for (const o in t.custom)
|
|
191
|
+
t[o] = t.custom[o];
|
|
192
192
|
delete t.custom;
|
|
193
193
|
}
|
|
194
194
|
return {
|
|
@@ -199,82 +199,82 @@ const A = function(o, e) {
|
|
|
199
199
|
}
|
|
200
200
|
]
|
|
201
201
|
};
|
|
202
|
-
},
|
|
202
|
+
}, ve = (r) => ({
|
|
203
203
|
tag: [
|
|
204
204
|
{
|
|
205
205
|
tag: "span",
|
|
206
|
-
attrs:
|
|
206
|
+
attrs: r.attrs
|
|
207
207
|
}
|
|
208
208
|
]
|
|
209
|
-
}),
|
|
209
|
+
}), $e = () => ({
|
|
210
210
|
tag: "sub"
|
|
211
|
-
}),
|
|
211
|
+
}), Te = () => ({
|
|
212
212
|
tag: "sup"
|
|
213
|
-
}),
|
|
213
|
+
}), we = (r) => ({
|
|
214
214
|
tag: [
|
|
215
215
|
{
|
|
216
216
|
tag: "span",
|
|
217
|
-
attrs:
|
|
217
|
+
attrs: r.attrs
|
|
218
218
|
}
|
|
219
219
|
]
|
|
220
|
-
}),
|
|
220
|
+
}), Re = (r) => {
|
|
221
221
|
var e;
|
|
222
|
-
return (e =
|
|
222
|
+
return (e = r.attrs) != null && e.color ? {
|
|
223
223
|
tag: [
|
|
224
224
|
{
|
|
225
225
|
tag: "span",
|
|
226
226
|
attrs: {
|
|
227
|
-
style: `background-color:${
|
|
227
|
+
style: `background-color:${r.attrs.color};`
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
]
|
|
231
231
|
} : {
|
|
232
232
|
tag: ""
|
|
233
233
|
};
|
|
234
|
-
},
|
|
234
|
+
}, Se = (r) => {
|
|
235
235
|
var e;
|
|
236
|
-
return (e =
|
|
236
|
+
return (e = r.attrs) != null && e.color ? {
|
|
237
237
|
tag: [
|
|
238
238
|
{
|
|
239
239
|
tag: "span",
|
|
240
240
|
attrs: {
|
|
241
|
-
style: `color:${
|
|
241
|
+
style: `color:${r.attrs.color}`
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
]
|
|
245
245
|
} : {
|
|
246
246
|
tag: ""
|
|
247
247
|
};
|
|
248
|
-
},
|
|
248
|
+
}, _e = {
|
|
249
249
|
nodes: {
|
|
250
|
-
horizontal_rule:
|
|
251
|
-
blockquote:
|
|
252
|
-
bullet_list:
|
|
253
|
-
code_block:
|
|
254
|
-
hard_break:
|
|
255
|
-
heading:
|
|
256
|
-
image:
|
|
257
|
-
list_item:
|
|
258
|
-
ordered_list:
|
|
259
|
-
paragraph:
|
|
260
|
-
emoji:
|
|
250
|
+
horizontal_rule: re,
|
|
251
|
+
blockquote: se,
|
|
252
|
+
bullet_list: oe,
|
|
253
|
+
code_block: ne,
|
|
254
|
+
hard_break: ie,
|
|
255
|
+
heading: ae,
|
|
256
|
+
image: le,
|
|
257
|
+
list_item: ce,
|
|
258
|
+
ordered_list: he,
|
|
259
|
+
paragraph: ue,
|
|
260
|
+
emoji: de
|
|
261
261
|
},
|
|
262
262
|
marks: {
|
|
263
|
-
bold:
|
|
264
|
-
strike:
|
|
265
|
-
underline:
|
|
266
|
-
strong:
|
|
267
|
-
code:
|
|
268
|
-
italic:
|
|
269
|
-
link:
|
|
270
|
-
styled:
|
|
271
|
-
subscript:
|
|
272
|
-
superscript:
|
|
273
|
-
anchor:
|
|
274
|
-
highlight:
|
|
275
|
-
textStyle:
|
|
276
|
-
}
|
|
277
|
-
},
|
|
263
|
+
bold: pe,
|
|
264
|
+
strike: ge,
|
|
265
|
+
underline: me,
|
|
266
|
+
strong: fe,
|
|
267
|
+
code: ye,
|
|
268
|
+
italic: be,
|
|
269
|
+
link: ke,
|
|
270
|
+
styled: ve,
|
|
271
|
+
subscript: $e,
|
|
272
|
+
superscript: Te,
|
|
273
|
+
anchor: we,
|
|
274
|
+
highlight: Re,
|
|
275
|
+
textStyle: Se
|
|
276
|
+
}
|
|
277
|
+
}, Ee = function(r) {
|
|
278
278
|
const e = {
|
|
279
279
|
"&": "&",
|
|
280
280
|
"<": "<",
|
|
@@ -282,12 +282,12 @@ const A = function(o, e) {
|
|
|
282
282
|
'"': """,
|
|
283
283
|
"'": "'"
|
|
284
284
|
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
|
285
|
-
return
|
|
285
|
+
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
286
286
|
};
|
|
287
|
-
let
|
|
288
|
-
class
|
|
287
|
+
let z = !1;
|
|
288
|
+
class je {
|
|
289
289
|
constructor(e) {
|
|
290
|
-
|
|
290
|
+
p(this, "marks"), p(this, "nodes"), e || (e = _e), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
291
291
|
}
|
|
292
292
|
addNode(e, t) {
|
|
293
293
|
this.nodes[e] = t;
|
|
@@ -296,13 +296,13 @@ class ce {
|
|
|
296
296
|
this.marks[e] = t;
|
|
297
297
|
}
|
|
298
298
|
render(e, t = { optimizeImages: !1 }, s = !0) {
|
|
299
|
-
if (!
|
|
299
|
+
if (!z && s && (console.warn(
|
|
300
300
|
"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/"
|
|
301
|
-
),
|
|
302
|
-
let
|
|
303
|
-
return e.content.forEach((
|
|
304
|
-
|
|
305
|
-
}), t.optimizeImages ? this.optimizeImages(
|
|
301
|
+
), z = !0), e && e.content && Array.isArray(e.content)) {
|
|
302
|
+
let o = "";
|
|
303
|
+
return e.content.forEach((n) => {
|
|
304
|
+
o += this.renderNode(n);
|
|
305
|
+
}), t.optimizeImages ? this.optimizeImages(o, t.optimizeImages) : o;
|
|
306
306
|
}
|
|
307
307
|
return console.warn(
|
|
308
308
|
`The render method must receive an Object with a "content" field.
|
|
@@ -332,48 +332,48 @@ class ce {
|
|
|
332
332
|
), "";
|
|
333
333
|
}
|
|
334
334
|
optimizeImages(e, t) {
|
|
335
|
-
let s = 0,
|
|
336
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
|
337
|
-
const
|
|
335
|
+
let s = 0, o = 0, n = "", i = "";
|
|
336
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `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}`))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
|
337
|
+
const l = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
|
|
338
338
|
return e = e.replace(
|
|
339
339
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
|
340
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
341
|
-
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (
|
|
340
|
+
`a.storyblok.com/f/$1/$2.$3/m/${l}`
|
|
341
|
+
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
342
342
|
var h, u;
|
|
343
|
-
const d =
|
|
343
|
+
const d = a.match(
|
|
344
344
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
|
345
345
|
);
|
|
346
346
|
if (d && d.length > 0) {
|
|
347
|
-
const
|
|
348
|
-
srcset: (h = t.srcset) == null ? void 0 : h.map((
|
|
349
|
-
if (typeof
|
|
350
|
-
return `//${d}/m/${
|
|
351
|
-
if (typeof
|
|
352
|
-
let
|
|
353
|
-
return typeof
|
|
347
|
+
const g = {
|
|
348
|
+
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
|
349
|
+
if (typeof y == "number")
|
|
350
|
+
return `//${d}/m/${y}x0${i} ${y}w`;
|
|
351
|
+
if (typeof y == "object" && y.length === 2) {
|
|
352
|
+
let w = 0, I = 0;
|
|
353
|
+
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (I = y[1]), `//${d}/m/${w}x${I}${i} ${w}w`;
|
|
354
354
|
}
|
|
355
355
|
return "";
|
|
356
356
|
}).join(", "),
|
|
357
|
-
sizes: (u = t.sizes) == null ? void 0 : u.map((
|
|
357
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
|
358
358
|
};
|
|
359
|
-
let
|
|
360
|
-
return
|
|
359
|
+
let R = "";
|
|
360
|
+
return g.srcset && (R += `srcset="${g.srcset}" `), g.sizes && (R += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${R.trim()}`);
|
|
361
361
|
}
|
|
362
|
-
return
|
|
362
|
+
return a;
|
|
363
363
|
})), e;
|
|
364
364
|
}
|
|
365
365
|
renderNode(e) {
|
|
366
366
|
const t = [];
|
|
367
|
-
e.marks && e.marks.forEach((
|
|
368
|
-
const
|
|
369
|
-
|
|
367
|
+
e.marks && e.marks.forEach((o) => {
|
|
368
|
+
const n = this.getMatchingMark(o);
|
|
369
|
+
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
|
370
370
|
});
|
|
371
371
|
const s = this.getMatchingNode(e);
|
|
372
|
-
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((
|
|
373
|
-
t.push(this.renderNode(
|
|
374
|
-
}) : e.text ? t.push(
|
|
375
|
-
const
|
|
376
|
-
|
|
372
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((o) => {
|
|
373
|
+
t.push(this.renderNode(o));
|
|
374
|
+
}) : e.text ? t.push(Ee(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((o) => {
|
|
375
|
+
const n = this.getMatchingMark(o);
|
|
376
|
+
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
377
377
|
}), t.join("");
|
|
378
378
|
}
|
|
379
379
|
renderTag(e, t) {
|
|
@@ -381,15 +381,15 @@ class ce {
|
|
|
381
381
|
if (s.constructor === String)
|
|
382
382
|
return `<${s}${t}>`;
|
|
383
383
|
{
|
|
384
|
-
let
|
|
384
|
+
let o = `<${s.tag}`;
|
|
385
385
|
if (s.attrs) {
|
|
386
|
-
for (const
|
|
387
|
-
if (Object.prototype.hasOwnProperty.call(s.attrs,
|
|
388
|
-
const
|
|
389
|
-
|
|
386
|
+
for (const n in s.attrs)
|
|
387
|
+
if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
|
|
388
|
+
const i = s.attrs[n];
|
|
389
|
+
i !== null && (o += ` ${n}="${i}"`);
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
return `${
|
|
392
|
+
return `${o}${t}>`;
|
|
393
393
|
}
|
|
394
394
|
}).join("");
|
|
395
395
|
}
|
|
@@ -426,10 +426,10 @@ class ce {
|
|
|
426
426
|
return this.renderTag(t, " /");
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
const
|
|
430
|
-
class
|
|
429
|
+
const A = je;
|
|
430
|
+
class Ie {
|
|
431
431
|
constructor(e) {
|
|
432
|
-
|
|
432
|
+
p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(this, "fetchOptions"), this.baseURL = e.baseURL, this.headers = e.headers || new Headers(), this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {}, this.fetchOptions = {};
|
|
433
433
|
}
|
|
434
434
|
/**
|
|
435
435
|
*
|
|
@@ -456,41 +456,41 @@ class he {
|
|
|
456
456
|
status: 0,
|
|
457
457
|
statusText: ""
|
|
458
458
|
};
|
|
459
|
-
e.status !== 204 && await e.json().then((
|
|
460
|
-
s.data =
|
|
459
|
+
e.status !== 204 && await e.json().then((o) => {
|
|
460
|
+
s.data = o;
|
|
461
461
|
});
|
|
462
|
-
for (const
|
|
463
|
-
t[
|
|
462
|
+
for (const o of e.headers.entries())
|
|
463
|
+
t[o[0]] = o[1];
|
|
464
464
|
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
465
465
|
}
|
|
466
466
|
async _methodHandler(e) {
|
|
467
467
|
let t = `${this.baseURL}${this.url}`, s = null;
|
|
468
468
|
if (e === "get") {
|
|
469
|
-
const
|
|
470
|
-
t = `${this.baseURL}${this.url}?${
|
|
469
|
+
const a = new O();
|
|
470
|
+
t = `${this.baseURL}${this.url}?${a.stringify(
|
|
471
471
|
this.parameters
|
|
472
472
|
)}`;
|
|
473
473
|
} else
|
|
474
474
|
s = JSON.stringify(this.parameters);
|
|
475
|
-
const
|
|
476
|
-
let
|
|
477
|
-
this.timeout && (
|
|
475
|
+
const o = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
476
|
+
let l;
|
|
477
|
+
this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
|
|
478
478
|
try {
|
|
479
|
-
const
|
|
479
|
+
const a = await this.fetch(`${o}`, {
|
|
480
480
|
method: e,
|
|
481
481
|
headers: this.headers,
|
|
482
482
|
body: s,
|
|
483
|
-
signal:
|
|
483
|
+
signal: i,
|
|
484
484
|
...this.fetchOptions
|
|
485
485
|
});
|
|
486
|
-
this.timeout && clearTimeout(
|
|
486
|
+
this.timeout && clearTimeout(l);
|
|
487
487
|
const h = await this._responseHandler(
|
|
488
|
-
|
|
488
|
+
a
|
|
489
489
|
);
|
|
490
490
|
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
|
|
491
|
-
} catch (
|
|
491
|
+
} catch (a) {
|
|
492
492
|
return {
|
|
493
|
-
message:
|
|
493
|
+
message: a
|
|
494
494
|
};
|
|
495
495
|
}
|
|
496
496
|
}
|
|
@@ -502,54 +502,54 @@ class he {
|
|
|
502
502
|
}
|
|
503
503
|
_statusHandler(e) {
|
|
504
504
|
const t = /20[0-6]/g;
|
|
505
|
-
return new Promise((s,
|
|
505
|
+
return new Promise((s, o) => {
|
|
506
506
|
if (t.test(`${e.status}`))
|
|
507
507
|
return s(e);
|
|
508
|
-
const
|
|
508
|
+
const n = {
|
|
509
509
|
message: e.statusText,
|
|
510
510
|
status: e.status,
|
|
511
511
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
|
512
512
|
};
|
|
513
|
-
|
|
513
|
+
o(n);
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
-
const
|
|
517
|
+
const xe = Ie, D = "SB-Agent", L = {
|
|
518
518
|
defaultAgentName: "SB-JS-CLIENT",
|
|
519
519
|
defaultAgentVersion: "SB-Agent-Version",
|
|
520
520
|
packageVersion: "6.0.0"
|
|
521
521
|
};
|
|
522
|
-
let
|
|
523
|
-
const
|
|
524
|
-
class
|
|
522
|
+
let x = {};
|
|
523
|
+
const E = {};
|
|
524
|
+
class Oe {
|
|
525
525
|
/**
|
|
526
526
|
*
|
|
527
527
|
* @param config ISbConfig interface
|
|
528
528
|
* @param pEndpoint string, optional
|
|
529
529
|
*/
|
|
530
530
|
constructor(e, t) {
|
|
531
|
-
|
|
531
|
+
p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
|
|
532
532
|
let s = e.endpoint || t;
|
|
533
533
|
if (!s) {
|
|
534
|
-
const
|
|
535
|
-
e.oauthToken ? s = `${
|
|
534
|
+
const i = new O().getRegionURL, l = e.https === !1 ? "http" : "https";
|
|
535
|
+
e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
|
|
536
536
|
}
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}),
|
|
541
|
-
|
|
542
|
-
|
|
537
|
+
const o = new Headers();
|
|
538
|
+
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
|
|
539
|
+
o.set(i, l);
|
|
540
|
+
}), o.has(D) || (o.set(D, L.defaultAgentName), o.set(
|
|
541
|
+
L.defaultAgentVersion,
|
|
542
|
+
L.packageVersion
|
|
543
543
|
));
|
|
544
|
-
let
|
|
545
|
-
e.oauthToken && (
|
|
544
|
+
let n = 5;
|
|
545
|
+
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new A(e.richTextSchema) : this.richTextResolver = new A(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = Z(
|
|
546
546
|
this.throttledRequest.bind(this),
|
|
547
|
-
|
|
547
|
+
n,
|
|
548
548
|
1e3
|
|
549
|
-
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new
|
|
549
|
+
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new O(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new xe({
|
|
550
550
|
baseURL: s,
|
|
551
551
|
timeout: e.timeout || 0,
|
|
552
|
-
headers:
|
|
552
|
+
headers: o,
|
|
553
553
|
responseInterceptor: e.responseInterceptor,
|
|
554
554
|
fetch: e.fetch
|
|
555
555
|
});
|
|
@@ -557,60 +557,60 @@ class de {
|
|
|
557
557
|
setComponentResolver(e) {
|
|
558
558
|
this.richTextResolver.addNode("blok", (t) => {
|
|
559
559
|
let s = "";
|
|
560
|
-
return t.attrs.body && t.attrs.body.forEach((
|
|
561
|
-
s += e(
|
|
560
|
+
return t.attrs.body && t.attrs.body.forEach((o) => {
|
|
561
|
+
s += e(o.component, o);
|
|
562
562
|
}), {
|
|
563
563
|
html: s
|
|
564
564
|
};
|
|
565
565
|
});
|
|
566
566
|
}
|
|
567
567
|
parseParams(e) {
|
|
568
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
568
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
569
569
|
}
|
|
570
570
|
factoryParamOptions(e, t) {
|
|
571
571
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
572
572
|
}
|
|
573
|
-
makeRequest(e, t, s,
|
|
574
|
-
const
|
|
573
|
+
makeRequest(e, t, s, o, n) {
|
|
574
|
+
const i = this.factoryParamOptions(
|
|
575
575
|
e,
|
|
576
|
-
this.helpers.getOptionsPage(t, s,
|
|
576
|
+
this.helpers.getOptionsPage(t, s, o)
|
|
577
577
|
);
|
|
578
|
-
return this.cacheResponse(e,
|
|
578
|
+
return this.cacheResponse(e, i, void 0, n);
|
|
579
579
|
}
|
|
580
580
|
get(e, t, s) {
|
|
581
581
|
t || (t = {});
|
|
582
|
-
const
|
|
583
|
-
return this.cacheResponse(
|
|
582
|
+
const o = `/${e}`, n = this.factoryParamOptions(o, t);
|
|
583
|
+
return this.cacheResponse(o, n, void 0, s);
|
|
584
584
|
}
|
|
585
|
-
async getAll(e, t, s,
|
|
586
|
-
const
|
|
587
|
-
n,
|
|
588
|
-
t,
|
|
585
|
+
async getAll(e, t, s, o) {
|
|
586
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`.replace(/\/$/, ""), l = s ?? i.substring(i.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
|
|
589
587
|
i,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
588
|
+
t,
|
|
589
|
+
n,
|
|
590
|
+
a,
|
|
591
|
+
o
|
|
592
|
+
), u = h.total ? Math.ceil(h.total / n) : 1, d = await this.helpers.asyncMap(
|
|
593
|
+
this.helpers.range(a, u),
|
|
594
|
+
(g) => this.makeRequest(i, t, n, g + 1, o)
|
|
595
595
|
);
|
|
596
|
-
return this.helpers.flatMap([h, ...d], (
|
|
596
|
+
return this.helpers.flatMap([h, ...d], (g) => Object.values(g.data[l]));
|
|
597
597
|
}
|
|
598
598
|
post(e, t, s) {
|
|
599
|
-
const
|
|
599
|
+
const o = `/${e}`;
|
|
600
600
|
return Promise.resolve(
|
|
601
|
-
this.throttle("post",
|
|
601
|
+
this.throttle("post", o, t, s)
|
|
602
602
|
);
|
|
603
603
|
}
|
|
604
604
|
put(e, t, s) {
|
|
605
|
-
const
|
|
605
|
+
const o = `/${e}`;
|
|
606
606
|
return Promise.resolve(
|
|
607
|
-
this.throttle("put",
|
|
607
|
+
this.throttle("put", o, t, s)
|
|
608
608
|
);
|
|
609
609
|
}
|
|
610
610
|
delete(e, t, s) {
|
|
611
|
-
const
|
|
611
|
+
const o = `/${e}`;
|
|
612
612
|
return Promise.resolve(
|
|
613
|
-
this.throttle("delete",
|
|
613
|
+
this.throttle("delete", o, t, s)
|
|
614
614
|
);
|
|
615
615
|
}
|
|
616
616
|
getStories(e, t) {
|
|
@@ -632,8 +632,8 @@ class de {
|
|
|
632
632
|
return JSON.parse(JSON.stringify(e));
|
|
633
633
|
}
|
|
634
634
|
_insertLinks(e, t, s) {
|
|
635
|
-
const
|
|
636
|
-
|
|
635
|
+
const o = e[t];
|
|
636
|
+
o && o.fieldtype === "multilink" && o.linktype === "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
|
|
637
637
|
}
|
|
638
638
|
/**
|
|
639
639
|
*
|
|
@@ -646,85 +646,85 @@ class de {
|
|
|
646
646
|
this.relations[e][t]
|
|
647
647
|
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
|
648
648
|
}
|
|
649
|
-
_insertRelations(e, t, s,
|
|
650
|
-
s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(
|
|
649
|
+
_insertRelations(e, t, s, o) {
|
|
650
|
+
s.includes(`${e.component}.${t}`) && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
|
|
651
651
|
}
|
|
652
652
|
iterateTree(e, t, s) {
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
if (
|
|
656
|
-
for (let
|
|
657
|
-
|
|
658
|
-
else if (
|
|
659
|
-
if (
|
|
653
|
+
const o = (n) => {
|
|
654
|
+
if (n != null) {
|
|
655
|
+
if (n.constructor === Array)
|
|
656
|
+
for (let i = 0; i < n.length; i++)
|
|
657
|
+
o(n[i]);
|
|
658
|
+
else if (n.constructor === Object) {
|
|
659
|
+
if (n._stopResolving)
|
|
660
660
|
return;
|
|
661
|
-
for (const
|
|
662
|
-
(
|
|
663
|
-
i,
|
|
661
|
+
for (const i in n)
|
|
662
|
+
(n.component && n._uid || n.type === "link") && (this._insertRelations(
|
|
664
663
|
n,
|
|
664
|
+
i,
|
|
665
665
|
t,
|
|
666
666
|
s
|
|
667
667
|
), this._insertLinks(
|
|
668
|
-
i,
|
|
669
668
|
n,
|
|
669
|
+
i,
|
|
670
670
|
s
|
|
671
|
-
)),
|
|
671
|
+
)), o(n[i]);
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
|
-
|
|
675
|
+
o(e.content);
|
|
676
676
|
}
|
|
677
677
|
async resolveLinks(e, t, s) {
|
|
678
|
-
let
|
|
678
|
+
let o = [];
|
|
679
679
|
if (e.link_uuids) {
|
|
680
|
-
const
|
|
681
|
-
for (let
|
|
682
|
-
const h = Math.min(
|
|
683
|
-
|
|
680
|
+
const n = e.link_uuids.length, i = [], l = 50;
|
|
681
|
+
for (let a = 0; a < n; a += l) {
|
|
682
|
+
const h = Math.min(n, a + l);
|
|
683
|
+
i.push(e.link_uuids.slice(a, h));
|
|
684
684
|
}
|
|
685
|
-
for (let
|
|
685
|
+
for (let a = 0; a < i.length; a++)
|
|
686
686
|
(await this.getStories({
|
|
687
|
-
per_page:
|
|
687
|
+
per_page: l,
|
|
688
688
|
language: t.language,
|
|
689
689
|
version: t.version,
|
|
690
|
-
by_uuids:
|
|
690
|
+
by_uuids: i[a].join(",")
|
|
691
691
|
})).data.stories.forEach(
|
|
692
692
|
(h) => {
|
|
693
|
-
|
|
693
|
+
o.push(h);
|
|
694
694
|
}
|
|
695
695
|
);
|
|
696
696
|
} else
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
this.links[s][
|
|
700
|
-
...
|
|
697
|
+
o = e.links;
|
|
698
|
+
o.forEach((n) => {
|
|
699
|
+
this.links[s][n.uuid] = {
|
|
700
|
+
...n,
|
|
701
701
|
_stopResolving: !0
|
|
702
702
|
};
|
|
703
703
|
});
|
|
704
704
|
}
|
|
705
705
|
async resolveRelations(e, t, s) {
|
|
706
|
-
let
|
|
706
|
+
let o = [];
|
|
707
707
|
if (e.rel_uuids) {
|
|
708
|
-
const
|
|
709
|
-
for (let
|
|
710
|
-
const h = Math.min(
|
|
711
|
-
|
|
708
|
+
const n = e.rel_uuids.length, i = [], l = 50;
|
|
709
|
+
for (let a = 0; a < n; a += l) {
|
|
710
|
+
const h = Math.min(n, a + l);
|
|
711
|
+
i.push(e.rel_uuids.slice(a, h));
|
|
712
712
|
}
|
|
713
|
-
for (let
|
|
713
|
+
for (let a = 0; a < i.length; a++)
|
|
714
714
|
(await this.getStories({
|
|
715
|
-
per_page:
|
|
715
|
+
per_page: l,
|
|
716
716
|
language: t.language,
|
|
717
717
|
version: t.version,
|
|
718
|
-
by_uuids:
|
|
718
|
+
by_uuids: i[a].join(","),
|
|
719
719
|
excluding_fields: t.excluding_fields
|
|
720
720
|
})).data.stories.forEach((h) => {
|
|
721
|
-
|
|
721
|
+
o.push(h);
|
|
722
722
|
});
|
|
723
723
|
} else
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
this.relations[s][
|
|
727
|
-
...
|
|
724
|
+
o = e.rels;
|
|
725
|
+
o && o.length > 0 && o.forEach((n) => {
|
|
726
|
+
this.relations[s][n.uuid] = {
|
|
727
|
+
...n,
|
|
728
728
|
_stopResolving: !0
|
|
729
729
|
};
|
|
730
730
|
});
|
|
@@ -739,85 +739,85 @@ class de {
|
|
|
739
739
|
*
|
|
740
740
|
*/
|
|
741
741
|
async resolveStories(e, t, s) {
|
|
742
|
-
var
|
|
743
|
-
let
|
|
744
|
-
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (
|
|
745
|
-
for (const
|
|
742
|
+
var o, n;
|
|
743
|
+
let i = [];
|
|
744
|
+
if (this.links[s] = {}, this.relations[s] = {}, 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, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
745
|
+
for (const l in this.relations[s])
|
|
746
746
|
this.iterateTree(
|
|
747
|
-
this.relations[s][
|
|
748
|
-
|
|
747
|
+
this.relations[s][l],
|
|
748
|
+
i,
|
|
749
749
|
s
|
|
750
750
|
);
|
|
751
|
-
e.story ? this.iterateTree(e.story,
|
|
752
|
-
this.iterateTree(
|
|
751
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
|
|
752
|
+
this.iterateTree(l, i, s);
|
|
753
753
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
754
754
|
}
|
|
755
|
-
async cacheResponse(e, t, s,
|
|
756
|
-
const
|
|
755
|
+
async cacheResponse(e, t, s, o) {
|
|
756
|
+
const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
757
757
|
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e !== "/cdn/spaces/me") {
|
|
758
|
-
const
|
|
759
|
-
if (
|
|
760
|
-
return Promise.resolve(
|
|
758
|
+
const l = await i.get(n);
|
|
759
|
+
if (l)
|
|
760
|
+
return Promise.resolve(l);
|
|
761
761
|
}
|
|
762
|
-
return new Promise(async (
|
|
762
|
+
return new Promise(async (l, a) => {
|
|
763
763
|
var h;
|
|
764
764
|
try {
|
|
765
765
|
const u = await this.throttle(
|
|
766
766
|
"get",
|
|
767
767
|
e,
|
|
768
768
|
t,
|
|
769
|
-
|
|
769
|
+
o
|
|
770
770
|
);
|
|
771
771
|
if (u.status !== 200)
|
|
772
|
-
return
|
|
772
|
+
return a(u);
|
|
773
773
|
let d = { data: u.data, headers: u.headers };
|
|
774
774
|
if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
|
|
775
775
|
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
|
776
776
|
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
|
777
777
|
})), d.data.story || d.data.stories) {
|
|
778
|
-
const
|
|
779
|
-
await this.resolveStories(d.data, t, `${
|
|
778
|
+
const g = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
779
|
+
await this.resolveStories(d.data, t, `${g}`);
|
|
780
780
|
}
|
|
781
|
-
return t.version === "published" && e !== "/cdn/spaces/me" && await
|
|
781
|
+
return t.version === "published" && e !== "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] !== d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), l(d);
|
|
782
782
|
} catch (u) {
|
|
783
783
|
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
784
784
|
return console.log(
|
|
785
785
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
786
|
-
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(
|
|
787
|
-
|
|
786
|
+
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
|
|
787
|
+
a(u);
|
|
788
788
|
}
|
|
789
789
|
});
|
|
790
790
|
}
|
|
791
|
-
throttledRequest(e, t, s,
|
|
792
|
-
return this.client.setFetchOptions(
|
|
791
|
+
throttledRequest(e, t, s, o) {
|
|
792
|
+
return this.client.setFetchOptions(o), this.client[e](t, s);
|
|
793
793
|
}
|
|
794
794
|
cacheVersions() {
|
|
795
|
-
return
|
|
795
|
+
return E;
|
|
796
796
|
}
|
|
797
797
|
cacheVersion() {
|
|
798
|
-
return
|
|
798
|
+
return E[this.accessToken];
|
|
799
799
|
}
|
|
800
800
|
setCacheVersion(e) {
|
|
801
|
-
this.accessToken && (
|
|
801
|
+
this.accessToken && (E[this.accessToken] = e);
|
|
802
802
|
}
|
|
803
803
|
clearCacheVersion() {
|
|
804
|
-
this.accessToken && (
|
|
804
|
+
this.accessToken && (E[this.accessToken] = 0);
|
|
805
805
|
}
|
|
806
806
|
cacheProvider() {
|
|
807
807
|
switch (this.cache.type) {
|
|
808
808
|
case "memory":
|
|
809
809
|
return {
|
|
810
810
|
get(e) {
|
|
811
|
-
return Promise.resolve(
|
|
811
|
+
return Promise.resolve(x[e]);
|
|
812
812
|
},
|
|
813
813
|
getAll() {
|
|
814
|
-
return Promise.resolve(
|
|
814
|
+
return Promise.resolve(x);
|
|
815
815
|
},
|
|
816
816
|
set(e, t) {
|
|
817
|
-
return
|
|
817
|
+
return x[e] = t, Promise.resolve(void 0);
|
|
818
818
|
},
|
|
819
819
|
flush() {
|
|
820
|
-
return
|
|
820
|
+
return x = {}, Promise.resolve(void 0);
|
|
821
821
|
}
|
|
822
822
|
};
|
|
823
823
|
case "custom":
|
|
@@ -844,21 +844,21 @@ class de {
|
|
|
844
844
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
|
-
const
|
|
848
|
-
const { apiOptions: e } =
|
|
847
|
+
const Ue = (r = {}) => {
|
|
848
|
+
const { apiOptions: e } = r;
|
|
849
849
|
if (!e.accessToken) {
|
|
850
850
|
console.error(
|
|
851
851
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
852
852
|
);
|
|
853
853
|
return;
|
|
854
854
|
}
|
|
855
|
-
return { storyblokApi: new
|
|
856
|
-
},
|
|
857
|
-
if (typeof
|
|
855
|
+
return { storyblokApi: new Oe(e) };
|
|
856
|
+
}, ze = (r) => {
|
|
857
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
858
858
|
return {};
|
|
859
859
|
try {
|
|
860
860
|
const e = JSON.parse(
|
|
861
|
-
|
|
861
|
+
r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
862
862
|
);
|
|
863
863
|
return e ? {
|
|
864
864
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -868,69 +868,271 @@ const ge = (o = {}) => {
|
|
|
868
868
|
return {};
|
|
869
869
|
}
|
|
870
870
|
};
|
|
871
|
-
|
|
872
|
-
|
|
871
|
+
function Ae(r, e) {
|
|
872
|
+
if (!e)
|
|
873
|
+
return { src: r, attrs: {} };
|
|
874
|
+
let t = 0, s = 0;
|
|
875
|
+
const o = {}, n = [];
|
|
876
|
+
function i(a, h, u, d, g) {
|
|
877
|
+
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)`) : g.push(`${d}(${a})`);
|
|
878
|
+
}
|
|
879
|
+
if (typeof e == "object") {
|
|
880
|
+
if (typeof e.width == "number" && e.width > 0 ? (o.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 ? (o.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
|
|
881
|
+
const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: R, quality: y, rotate: w } = a || {};
|
|
882
|
+
h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), R && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
|
|
883
|
+
}
|
|
884
|
+
e.srcset && (o.srcset = e.srcset.map((a) => {
|
|
885
|
+
if (typeof a == "number")
|
|
886
|
+
return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
|
|
887
|
+
if (Array.isArray(a) && a.length === 2) {
|
|
888
|
+
const [h, u] = a;
|
|
889
|
+
return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
890
|
+
} else {
|
|
891
|
+
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
895
|
+
}
|
|
896
|
+
let l = `${r}/m/`;
|
|
897
|
+
return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
898
|
+
src: l,
|
|
899
|
+
attrs: o
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), G = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(G || {}), j = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(j || {});
|
|
903
|
+
const Ce = [
|
|
904
|
+
"area",
|
|
905
|
+
"base",
|
|
906
|
+
"br",
|
|
907
|
+
"col",
|
|
908
|
+
"embed",
|
|
909
|
+
"hr",
|
|
910
|
+
"img",
|
|
911
|
+
"input",
|
|
912
|
+
"link",
|
|
913
|
+
"meta",
|
|
914
|
+
"param",
|
|
915
|
+
"source",
|
|
916
|
+
"track",
|
|
917
|
+
"wbr"
|
|
918
|
+
], Le = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), Pe = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
|
|
919
|
+
function Ne(r) {
|
|
920
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
921
|
+
}
|
|
922
|
+
const B = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
|
|
923
|
+
function Me(r, e = {}, t) {
|
|
924
|
+
const s = Le(e), o = s ? `${r} ${s}` : r;
|
|
925
|
+
return Ce.includes(r) ? `<${o}>` : `<${o}>${Array.isArray(t) ? t.join("") : t || ""}</${r}>`;
|
|
926
|
+
}
|
|
927
|
+
function De(r = {}) {
|
|
928
|
+
let e = 0;
|
|
929
|
+
const {
|
|
930
|
+
renderFn: t = Me,
|
|
931
|
+
textFn: s = Ne,
|
|
932
|
+
resolvers: o = {},
|
|
933
|
+
optimizeImages: n = !1,
|
|
934
|
+
keyedResolvers: i = !1
|
|
935
|
+
} = r, l = (c) => (m) => {
|
|
936
|
+
const f = m.attrs || {};
|
|
937
|
+
return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
|
|
938
|
+
}, a = (c) => {
|
|
939
|
+
const { src: m, alt: f, title: b, srcset: T, sizes: $ } = c.attrs || {};
|
|
940
|
+
let S = m, _ = {};
|
|
941
|
+
if (n) {
|
|
942
|
+
const { src: K, attrs: Y } = Ae(m, n);
|
|
943
|
+
S = K, _ = Y;
|
|
944
|
+
}
|
|
945
|
+
i && (_ = {
|
|
946
|
+
..._,
|
|
947
|
+
key: `img-${e}`
|
|
948
|
+
});
|
|
949
|
+
const J = {
|
|
950
|
+
src: S,
|
|
951
|
+
alt: f,
|
|
952
|
+
title: b,
|
|
953
|
+
srcset: T,
|
|
954
|
+
sizes: $,
|
|
955
|
+
..._
|
|
956
|
+
};
|
|
957
|
+
return t("img", B(J));
|
|
958
|
+
}, h = (c) => {
|
|
959
|
+
const { level: m, ...f } = c.attrs || {}, b = {
|
|
960
|
+
...f
|
|
961
|
+
};
|
|
962
|
+
return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
|
|
963
|
+
}, u = (c) => {
|
|
964
|
+
var m, f, b, T;
|
|
965
|
+
const $ = t("img", {
|
|
966
|
+
src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
|
|
967
|
+
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
968
|
+
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
969
|
+
draggable: "false",
|
|
970
|
+
loading: "lazy"
|
|
971
|
+
}), S = {
|
|
972
|
+
"data-type": "emoji",
|
|
973
|
+
"data-name": (b = c.attrs) == null ? void 0 : b.name,
|
|
974
|
+
"data-emoji": (T = c.attrs) == null ? void 0 : T.emoji
|
|
975
|
+
};
|
|
976
|
+
return i && (S.key = `emoji-${e}`), t("span", S, $);
|
|
977
|
+
}, d = (c) => t("pre", {
|
|
978
|
+
...c.attrs,
|
|
979
|
+
key: `code-${e}`
|
|
980
|
+
}, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
|
|
981
|
+
const { class: T, id: $, ...S } = b || {}, _ = m ? {
|
|
982
|
+
class: T,
|
|
983
|
+
id: $,
|
|
984
|
+
style: Pe(S) || void 0
|
|
985
|
+
} : b || {};
|
|
986
|
+
return i && (_.key = `${c}-${e}`), t(c, B(_), f);
|
|
987
|
+
}, R = (c) => C(c), y = (c) => {
|
|
988
|
+
const { marks: m, ...f } = c;
|
|
989
|
+
return "text" in c ? m ? m.reduce(
|
|
990
|
+
(b, T) => R({ ...T, text: b }),
|
|
991
|
+
// Fix: Ensure render function returns a string
|
|
992
|
+
R({ ...f, children: f.children })
|
|
993
|
+
// Fix: Cast children to string
|
|
994
|
+
) : s(f.text) : "";
|
|
995
|
+
}, w = (c) => {
|
|
996
|
+
const { linktype: m, href: f, anchor: b, ...T } = c.attrs || {};
|
|
997
|
+
let $ = "";
|
|
998
|
+
switch (m) {
|
|
999
|
+
case j.ASSET:
|
|
1000
|
+
case j.URL:
|
|
1001
|
+
$ = f;
|
|
1002
|
+
break;
|
|
1003
|
+
case j.EMAIL:
|
|
1004
|
+
$ = `mailto:${f}`;
|
|
1005
|
+
break;
|
|
1006
|
+
case j.STORY:
|
|
1007
|
+
$ = f;
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
return b && ($ = `${$}#${b}`), t("a", { ...T, href: $, key: `a-${e}` }, c.text);
|
|
1011
|
+
}, I = (c) => {
|
|
1012
|
+
var m, f;
|
|
1013
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
1014
|
+
blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
|
|
1015
|
+
id: (f = c.attrs) == null ? void 0 : f.id,
|
|
1016
|
+
key: `component-${e}`,
|
|
1017
|
+
style: "display: none"
|
|
1018
|
+
});
|
|
1019
|
+
}, F = new Map([
|
|
1020
|
+
[k.DOCUMENT, l("div")],
|
|
1021
|
+
[k.HEADING, h],
|
|
1022
|
+
[k.PARAGRAPH, l("p")],
|
|
1023
|
+
[k.UL_LIST, l("ul")],
|
|
1024
|
+
[k.OL_LIST, l("ol")],
|
|
1025
|
+
[k.LIST_ITEM, l("li")],
|
|
1026
|
+
[k.IMAGE, a],
|
|
1027
|
+
[k.EMOJI, u],
|
|
1028
|
+
[k.CODE_BLOCK, d],
|
|
1029
|
+
[k.HR, l("hr")],
|
|
1030
|
+
[k.BR, l("br")],
|
|
1031
|
+
[k.QUOTE, l("blockquote")],
|
|
1032
|
+
[k.COMPONENT, I],
|
|
1033
|
+
[G.TEXT, y],
|
|
1034
|
+
[v.LINK, w],
|
|
1035
|
+
[v.ANCHOR, w],
|
|
1036
|
+
[v.STYLED, g("span", !0)],
|
|
1037
|
+
[v.BOLD, g("strong")],
|
|
1038
|
+
[v.TEXT_STYLE, g("span", !0)],
|
|
1039
|
+
[v.ITALIC, g("em")],
|
|
1040
|
+
[v.UNDERLINE, g("u")],
|
|
1041
|
+
[v.STRIKE, g("s")],
|
|
1042
|
+
[v.CODE, g("code")],
|
|
1043
|
+
[v.SUPERSCRIPT, g("sup")],
|
|
1044
|
+
[v.SUBSCRIPT, g("sub")],
|
|
1045
|
+
[v.HIGHLIGHT, g("mark")],
|
|
1046
|
+
...Object.entries(o).map(([c, m]) => [c, m])
|
|
1047
|
+
]);
|
|
1048
|
+
function M(c) {
|
|
1049
|
+
e += 1;
|
|
1050
|
+
const m = F.get(c.type);
|
|
1051
|
+
if (!m)
|
|
1052
|
+
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
1053
|
+
if (c.type === "text")
|
|
1054
|
+
return m(c);
|
|
1055
|
+
const f = c.content ? c.content.map(C) : void 0;
|
|
1056
|
+
return m({
|
|
1057
|
+
...c,
|
|
1058
|
+
children: f
|
|
1059
|
+
// Fix: Update the type of 'children' to Node[]
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function C(c) {
|
|
1063
|
+
return Array.isArray(c) ? c.map(M) : M(c);
|
|
1064
|
+
}
|
|
1065
|
+
return {
|
|
1066
|
+
render: C
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
let P, N = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1070
|
+
const Be = (r, e, t = {}) => {
|
|
873
1071
|
var s;
|
|
874
|
-
const
|
|
1072
|
+
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
875
1073
|
"_storyblok"
|
|
876
|
-
) ===
|
|
877
|
-
if (!(!
|
|
878
|
-
if (!
|
|
1074
|
+
) === r;
|
|
1075
|
+
if (!(!o || !n)) {
|
|
1076
|
+
if (!r) {
|
|
879
1077
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
880
1078
|
return;
|
|
881
1079
|
}
|
|
882
1080
|
window.storyblokRegisterEvent(() => {
|
|
883
|
-
new window.StoryblokBridge(t).on(["input", "published", "change"], (
|
|
884
|
-
|
|
1081
|
+
new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
|
|
1082
|
+
i.action === "input" && i.story.id === r ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === r && window.location.reload();
|
|
885
1083
|
});
|
|
886
1084
|
});
|
|
887
1085
|
}
|
|
888
|
-
},
|
|
1086
|
+
}, qe = (r = {}) => {
|
|
889
1087
|
var e, t;
|
|
890
1088
|
const {
|
|
891
1089
|
bridge: s,
|
|
892
|
-
accessToken:
|
|
893
|
-
use:
|
|
894
|
-
apiOptions:
|
|
895
|
-
richText:
|
|
896
|
-
bridgeUrl:
|
|
897
|
-
} =
|
|
898
|
-
|
|
899
|
-
const h = { bridge: s, apiOptions:
|
|
1090
|
+
accessToken: o,
|
|
1091
|
+
use: n = [],
|
|
1092
|
+
apiOptions: i = {},
|
|
1093
|
+
richText: l = {},
|
|
1094
|
+
bridgeUrl: a
|
|
1095
|
+
} = r;
|
|
1096
|
+
i.accessToken = i.accessToken || o;
|
|
1097
|
+
const h = { bridge: s, apiOptions: i };
|
|
900
1098
|
let u = {};
|
|
901
|
-
|
|
902
|
-
u = { ...u, ...
|
|
903
|
-
}),
|
|
1099
|
+
n.forEach((g) => {
|
|
1100
|
+
u = { ...u, ...g(h) };
|
|
1101
|
+
}), a && (N = a);
|
|
904
1102
|
const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
905
|
-
return s !== !1 && d &&
|
|
906
|
-
},
|
|
907
|
-
|
|
1103
|
+
return s !== !1 && d && q(N), P = new A(l.schema), l.resolver && V(P, l.resolver), u;
|
|
1104
|
+
}, V = (r, e) => {
|
|
1105
|
+
r.addNode("blok", (t) => {
|
|
908
1106
|
let s = "";
|
|
909
|
-
return t.attrs.body.forEach((
|
|
910
|
-
s += e(
|
|
1107
|
+
return t.attrs.body.forEach((o) => {
|
|
1108
|
+
s += e(o.component, o);
|
|
911
1109
|
}), {
|
|
912
1110
|
html: s
|
|
913
1111
|
};
|
|
914
1112
|
});
|
|
915
|
-
},
|
|
916
|
-
let s = t ||
|
|
1113
|
+
}, He = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Ge = (r, e, t) => {
|
|
1114
|
+
let s = t || P;
|
|
917
1115
|
if (!s) {
|
|
918
1116
|
console.error(
|
|
919
1117
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
920
1118
|
);
|
|
921
1119
|
return;
|
|
922
1120
|
}
|
|
923
|
-
return
|
|
924
|
-
},
|
|
1121
|
+
return He(r) ? "" : (e && (s = new A(e.schema), e.resolver && V(s, e.resolver)), s.render(r, {}, !1));
|
|
1122
|
+
}, Ve = () => q(N);
|
|
925
1123
|
export {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1124
|
+
k as BlockTypes,
|
|
1125
|
+
v as MarkTypes,
|
|
1126
|
+
A as RichTextResolver,
|
|
1127
|
+
_e as RichTextSchema,
|
|
1128
|
+
G as TextTypes,
|
|
1129
|
+
Ue as apiPlugin,
|
|
1130
|
+
He as isRichTextEmpty,
|
|
1131
|
+
Ve as loadStoryblokBridge,
|
|
1132
|
+
Be as registerStoryblokBridge,
|
|
1133
|
+
Ge as renderRichText,
|
|
1134
|
+
De as richTextResolver,
|
|
1135
|
+
ze as storyblokEditable,
|
|
1136
|
+
qe as storyblokInit,
|
|
1137
|
+
Be as useStoryblokBridge
|
|
936
1138
|
};
|