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