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