@storyblok/js 3.3.1 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +340 -334
- package/package.json +4 -4
package/dist/storyblok-js.mjs
CHANGED
@@ -4,35 +4,35 @@
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
5
5
|
* author: undefined
|
6
6
|
*/
|
7
|
-
let
|
8
|
-
const
|
7
|
+
let z = !1;
|
8
|
+
const D = [], J = (i) => new Promise((e, t) => {
|
9
9
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
10
10
|
if (window.location === window.parent.location) {
|
11
11
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
12
12
|
return;
|
13
13
|
}
|
14
|
-
|
14
|
+
z ? r() : D.push(r);
|
15
15
|
}, document.getElementById("storyblok-javascript-bridge")))
|
16
16
|
return;
|
17
17
|
const s = document.createElement("script");
|
18
18
|
s.async = !0, s.src = i, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
19
|
-
|
19
|
+
D.forEach((o) => o()), z = !0, e(r);
|
20
20
|
}, document.getElementsByTagName("head")[0].appendChild(s);
|
21
21
|
});
|
22
|
-
var
|
23
|
-
class
|
22
|
+
var ie = Object.defineProperty, oe = (i, e, t) => e in i ? ie(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e, t) => oe(i, typeof e != "symbol" ? e + "" : e, t);
|
23
|
+
class ne extends Error {
|
24
24
|
constructor(e) {
|
25
25
|
super(e), this.name = "AbortError";
|
26
26
|
}
|
27
27
|
}
|
28
|
-
function
|
28
|
+
function ae(i, e, t) {
|
29
29
|
if (!Number.isFinite(e))
|
30
30
|
throw new TypeError("Expected `limit` to be a finite number");
|
31
31
|
if (!Number.isFinite(t))
|
32
32
|
throw new TypeError("Expected `interval` to be a finite number");
|
33
33
|
const s = [];
|
34
34
|
let r = [], o = 0, n = !1;
|
35
|
-
const
|
35
|
+
const c = async () => {
|
36
36
|
o++;
|
37
37
|
const h = s.shift();
|
38
38
|
if (h)
|
@@ -43,7 +43,7 @@ function oe(i, e, t) {
|
|
43
43
|
h.reject(p);
|
44
44
|
}
|
45
45
|
const u = setTimeout(() => {
|
46
|
-
o--, s.length > 0 &&
|
46
|
+
o--, s.length > 0 && c(), r = r.filter((p) => p !== u);
|
47
47
|
}, t);
|
48
48
|
r.includes(u) || r.push(u);
|
49
49
|
}, a = (...h) => n ? Promise.reject(
|
@@ -55,24 +55,24 @@ function oe(i, e, t) {
|
|
55
55
|
resolve: u,
|
56
56
|
reject: p,
|
57
57
|
args: h
|
58
|
-
}), o < e &&
|
58
|
+
}), o < e && c();
|
59
59
|
});
|
60
60
|
return a.abort = () => {
|
61
61
|
n = !0, r.forEach(clearTimeout), r = [], s.forEach(
|
62
|
-
(h) => h.reject(() => new
|
62
|
+
(h) => h.reject(() => new ne("Throttle function aborted"))
|
63
63
|
), s.length = 0;
|
64
64
|
}, a;
|
65
65
|
}
|
66
|
-
class
|
66
|
+
class C {
|
67
67
|
constructor() {
|
68
|
-
|
68
|
+
m(this, "isCDNUrl", (e = "") => e.includes("/cdn/")), m(this, "getOptionsPage", (e, t = 25, s = 1) => ({
|
69
69
|
...e,
|
70
70
|
per_page: t,
|
71
71
|
page: s
|
72
|
-
})),
|
72
|
+
})), 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) => {
|
73
73
|
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
74
74
|
return this.arrayFrom(s, (o, n) => n * r + e);
|
75
|
-
}),
|
75
|
+
}), m(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), m(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), m(this, "escapeHTML", function(e) {
|
76
76
|
const t = {
|
77
77
|
"&": "&",
|
78
78
|
"<": "<",
|
@@ -98,13 +98,13 @@ class L {
|
|
98
98
|
const n = e[o];
|
99
99
|
if (n == null)
|
100
100
|
continue;
|
101
|
-
const
|
101
|
+
const c = s ? "" : encodeURIComponent(o);
|
102
102
|
let a;
|
103
103
|
typeof n == "object" ? a = this.stringify(
|
104
104
|
n,
|
105
|
-
t ? t + encodeURIComponent(`[${
|
105
|
+
t ? t + encodeURIComponent(`[${c}]`) : c,
|
106
106
|
Array.isArray(n)
|
107
|
-
) : a = `${t ? t + encodeURIComponent(`[${
|
107
|
+
) : a = `${t ? t + encodeURIComponent(`[${c}]`) : c}=${encodeURIComponent(n)}`, r.push(a);
|
108
108
|
}
|
109
109
|
return r.join("&");
|
110
110
|
}
|
@@ -129,20 +129,20 @@ class L {
|
|
129
129
|
}
|
130
130
|
}
|
131
131
|
}
|
132
|
-
const
|
132
|
+
const le = function(i, e) {
|
133
133
|
const t = {};
|
134
134
|
for (const s in i) {
|
135
135
|
const r = i[s];
|
136
136
|
e.includes(s) && r !== null && (t[s] = r);
|
137
137
|
}
|
138
138
|
return t;
|
139
|
-
},
|
139
|
+
}, ce = (i) => i === "email", he = () => ({
|
140
140
|
singleTag: "hr"
|
141
|
-
}),
|
141
|
+
}), ue = () => ({
|
142
142
|
tag: "blockquote"
|
143
|
-
}),
|
143
|
+
}), de = () => ({
|
144
144
|
tag: "ul"
|
145
|
-
}),
|
145
|
+
}), pe = (i) => ({
|
146
146
|
tag: [
|
147
147
|
"pre",
|
148
148
|
{
|
@@ -150,24 +150,24 @@ const ne = function(i, e) {
|
|
150
150
|
attrs: i.attrs
|
151
151
|
}
|
152
152
|
]
|
153
|
-
}),
|
153
|
+
}), ge = () => ({
|
154
154
|
singleTag: "br"
|
155
|
-
}),
|
155
|
+
}), fe = (i) => ({
|
156
156
|
tag: `h${i.attrs.level}`
|
157
|
-
}),
|
157
|
+
}), me = (i) => ({
|
158
158
|
singleTag: [
|
159
159
|
{
|
160
160
|
tag: "img",
|
161
|
-
attrs:
|
161
|
+
attrs: le(i.attrs, ["src", "alt", "title"])
|
162
162
|
}
|
163
163
|
]
|
164
|
-
}),
|
164
|
+
}), ye = () => ({
|
165
165
|
tag: "li"
|
166
|
-
}),
|
166
|
+
}), be = () => ({
|
167
167
|
tag: "ol"
|
168
|
-
}),
|
168
|
+
}), ke = () => ({
|
169
169
|
tag: "p"
|
170
|
-
}),
|
170
|
+
}), ve = (i) => ({
|
171
171
|
tag: [
|
172
172
|
{
|
173
173
|
tag: "span",
|
@@ -178,25 +178,25 @@ const ne = function(i, e) {
|
|
178
178
|
}
|
179
179
|
}
|
180
180
|
]
|
181
|
-
}), ke = () => ({
|
182
|
-
tag: "b"
|
183
181
|
}), $e = () => ({
|
182
|
+
tag: "b"
|
183
|
+
}), Te = () => ({
|
184
184
|
tag: "s"
|
185
|
-
}),
|
185
|
+
}), we = () => ({
|
186
186
|
tag: "u"
|
187
|
-
}),
|
187
|
+
}), Re = () => ({
|
188
188
|
tag: "strong"
|
189
|
-
}),
|
189
|
+
}), Ee = () => ({
|
190
190
|
tag: "code"
|
191
|
-
}),
|
191
|
+
}), _e = () => ({
|
192
192
|
tag: "i"
|
193
|
-
}),
|
193
|
+
}), Se = (i) => {
|
194
194
|
if (!i.attrs)
|
195
195
|
return {
|
196
196
|
tag: ""
|
197
197
|
};
|
198
|
-
const e = new
|
199
|
-
if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")),
|
198
|
+
const e = new C().escapeHTML, t = { ...i.attrs }, { linktype: s = "url" } = i.attrs;
|
199
|
+
if (delete t.linktype, t.href && (t.href = e(i.attrs.href || "")), ce(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
200
200
|
for (const r in t.custom)
|
201
201
|
t[r] = t.custom[r];
|
202
202
|
delete t.custom;
|
@@ -209,25 +209,25 @@ const ne = function(i, e) {
|
|
209
209
|
}
|
210
210
|
]
|
211
211
|
};
|
212
|
-
},
|
212
|
+
}, je = (i) => ({
|
213
213
|
tag: [
|
214
214
|
{
|
215
215
|
tag: "span",
|
216
216
|
attrs: i.attrs
|
217
217
|
}
|
218
218
|
]
|
219
|
-
}),
|
219
|
+
}), Ie = () => ({
|
220
220
|
tag: "sub"
|
221
|
-
}),
|
221
|
+
}), xe = () => ({
|
222
222
|
tag: "sup"
|
223
|
-
}),
|
223
|
+
}), Ae = (i) => ({
|
224
224
|
tag: [
|
225
225
|
{
|
226
226
|
tag: "span",
|
227
227
|
attrs: i.attrs
|
228
228
|
}
|
229
229
|
]
|
230
|
-
}),
|
230
|
+
}), Oe = (i) => {
|
231
231
|
var e;
|
232
232
|
return (e = i.attrs) != null && e.color ? {
|
233
233
|
tag: [
|
@@ -241,7 +241,7 @@ const ne = function(i, e) {
|
|
241
241
|
} : {
|
242
242
|
tag: ""
|
243
243
|
};
|
244
|
-
},
|
244
|
+
}, Le = (i) => {
|
245
245
|
var e;
|
246
246
|
return (e = i.attrs) != null && e.color ? {
|
247
247
|
tag: [
|
@@ -255,36 +255,36 @@ const ne = function(i, e) {
|
|
255
255
|
} : {
|
256
256
|
tag: ""
|
257
257
|
};
|
258
|
-
},
|
258
|
+
}, Ce = {
|
259
259
|
nodes: {
|
260
|
-
horizontal_rule:
|
261
|
-
blockquote:
|
262
|
-
bullet_list:
|
263
|
-
code_block:
|
264
|
-
hard_break:
|
265
|
-
heading:
|
266
|
-
image:
|
267
|
-
list_item:
|
268
|
-
ordered_list:
|
269
|
-
paragraph:
|
270
|
-
emoji:
|
260
|
+
horizontal_rule: he,
|
261
|
+
blockquote: ue,
|
262
|
+
bullet_list: de,
|
263
|
+
code_block: pe,
|
264
|
+
hard_break: ge,
|
265
|
+
heading: fe,
|
266
|
+
image: me,
|
267
|
+
list_item: ye,
|
268
|
+
ordered_list: be,
|
269
|
+
paragraph: ke,
|
270
|
+
emoji: ve
|
271
271
|
},
|
272
272
|
marks: {
|
273
|
-
bold:
|
274
|
-
strike:
|
275
|
-
underline:
|
276
|
-
strong:
|
277
|
-
code:
|
278
|
-
italic:
|
279
|
-
link:
|
280
|
-
styled:
|
281
|
-
subscript:
|
282
|
-
superscript:
|
283
|
-
anchor:
|
284
|
-
highlight:
|
285
|
-
textStyle:
|
286
|
-
}
|
287
|
-
},
|
273
|
+
bold: $e,
|
274
|
+
strike: Te,
|
275
|
+
underline: we,
|
276
|
+
strong: Re,
|
277
|
+
code: Ee,
|
278
|
+
italic: _e,
|
279
|
+
link: Se,
|
280
|
+
styled: je,
|
281
|
+
subscript: Ie,
|
282
|
+
superscript: xe,
|
283
|
+
anchor: Ae,
|
284
|
+
highlight: Oe,
|
285
|
+
textStyle: Le
|
286
|
+
}
|
287
|
+
}, Pe = function(i) {
|
288
288
|
const e = {
|
289
289
|
"&": "&",
|
290
290
|
"<": "<",
|
@@ -294,10 +294,10 @@ const ne = function(i, e) {
|
|
294
294
|
}, t = /[&<>"']/g, s = new RegExp(t.source);
|
295
295
|
return i && s.test(i) ? i.replace(t, (r) => e[r]) : i;
|
296
296
|
};
|
297
|
-
let
|
298
|
-
class
|
297
|
+
let q = !1;
|
298
|
+
class P {
|
299
299
|
constructor(e) {
|
300
|
-
|
300
|
+
m(this, "marks"), m(this, "nodes"), e || (e = Ce), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
301
301
|
}
|
302
302
|
addNode(e, t) {
|
303
303
|
this.nodes[e] = t;
|
@@ -306,9 +306,9 @@ class C {
|
|
306
306
|
this.marks[e] = t;
|
307
307
|
}
|
308
308
|
render(e, t = { optimizeImages: !1 }, s = !0) {
|
309
|
-
if (!
|
309
|
+
if (!q && s && (console.warn(
|
310
310
|
"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/"
|
311
|
-
),
|
311
|
+
), q = !0), e && e.content && Array.isArray(e.content)) {
|
312
312
|
let r = "";
|
313
313
|
return e.content.forEach((o) => {
|
314
314
|
r += this.renderNode(o);
|
@@ -344,30 +344,30 @@ class C {
|
|
344
344
|
optimizeImages(e, t) {
|
345
345
|
let s = 0, r = 0, o = "", n = "";
|
346
346
|
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (o += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (o += `height="${t.height}" `, r = 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 && (n += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (n += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-F]{6}/gi) || t.filters.fill === "transparent") && (n += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (n += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (n += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (n += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (n += `:rotate(${t.filters.rotate})`), n.length > 0 && (n = `/filters${n}`))), o.length > 0 && (e = e.replace(/<img/g, `<img ${o.trim()}`));
|
347
|
-
const
|
347
|
+
const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
|
348
348
|
return e = e.replace(
|
349
349
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g,
|
350
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
350
|
+
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
351
351
|
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
352
352
|
var h, u;
|
353
353
|
const p = a.match(
|
354
354
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|bmp)/g
|
355
355
|
);
|
356
356
|
if (p && p.length > 0) {
|
357
|
-
const
|
358
|
-
srcset: (h = t.srcset) == null ? void 0 : h.map((
|
359
|
-
if (typeof
|
360
|
-
return `//${p}/m/${
|
361
|
-
if (typeof
|
362
|
-
let
|
363
|
-
return typeof
|
357
|
+
const b = {
|
358
|
+
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
359
|
+
if (typeof y == "number")
|
360
|
+
return `//${p}/m/${y}x0${n} ${y}w`;
|
361
|
+
if (typeof y == "object" && y.length === 2) {
|
362
|
+
let S = 0, x = 0;
|
363
|
+
return typeof y[0] == "number" && (S = y[0]), typeof y[1] == "number" && (x = y[1]), `//${p}/m/${S}x${x}${n} ${S}w`;
|
364
364
|
}
|
365
365
|
return "";
|
366
366
|
}).join(", "),
|
367
|
-
sizes: (u = t.sizes) == null ? void 0 : u.map((
|
367
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
368
368
|
};
|
369
|
-
let
|
370
|
-
return
|
369
|
+
let _ = "";
|
370
|
+
return b.srcset && (_ += `srcset="${b.srcset}" `), b.sizes && (_ += `sizes="${b.sizes}" `), a.replace(/<img/g, `<img ${_.trim()}`);
|
371
371
|
}
|
372
372
|
return a;
|
373
373
|
})), e;
|
@@ -381,7 +381,7 @@ class C {
|
|
381
381
|
const s = this.getMatchingNode(e);
|
382
382
|
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
383
383
|
t.push(this.renderNode(r));
|
384
|
-
}) : e.text ? t.push(
|
384
|
+
}) : e.text ? t.push(Pe(e.text)) : s && s.singleTag ? t.push(this.renderTag(s.singleTag, " /")) : s && s.html ? t.push(s.html) : e.type === "emoji" && t.push(this.renderEmoji(e)), s && s.tag && t.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((r) => {
|
385
385
|
const o = this.getMatchingMark(r);
|
386
386
|
o && o.tag !== "" && t.push(this.renderClosingTag(o.tag));
|
387
387
|
}), t.join("");
|
@@ -436,9 +436,9 @@ class C {
|
|
436
436
|
return this.renderTag(t, " /");
|
437
437
|
}
|
438
438
|
}
|
439
|
-
class
|
439
|
+
class Ne {
|
440
440
|
constructor(e) {
|
441
|
-
|
441
|
+
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 = {};
|
442
442
|
}
|
443
443
|
/**
|
444
444
|
*
|
@@ -475,15 +475,15 @@ class Ce {
|
|
475
475
|
async _methodHandler(e) {
|
476
476
|
let t = `${this.baseURL}${this.url}`, s = null;
|
477
477
|
if (e === "get") {
|
478
|
-
const a = new
|
478
|
+
const a = new C();
|
479
479
|
t = `${this.baseURL}${this.url}?${a.stringify(
|
480
480
|
this.parameters
|
481
481
|
)}`;
|
482
482
|
} else
|
483
483
|
s = JSON.stringify(this.parameters);
|
484
484
|
const r = new URL(t), o = new AbortController(), { signal: n } = o;
|
485
|
-
let
|
486
|
-
this.timeout && (
|
485
|
+
let c;
|
486
|
+
this.timeout && (c = setTimeout(() => o.abort(), this.timeout));
|
487
487
|
try {
|
488
488
|
const a = await this.fetch(`${r}`, {
|
489
489
|
method: e,
|
@@ -492,7 +492,7 @@ class Ce {
|
|
492
492
|
signal: n,
|
493
493
|
...this.fetchOptions
|
494
494
|
});
|
495
|
-
this.timeout && clearTimeout(
|
495
|
+
this.timeout && clearTimeout(c);
|
496
496
|
const h = await this._responseHandler(
|
497
497
|
a
|
498
498
|
);
|
@@ -523,39 +523,39 @@ class Ce {
|
|
523
523
|
});
|
524
524
|
}
|
525
525
|
}
|
526
|
-
const
|
526
|
+
const F = "SB-Agent", H = {
|
527
527
|
defaultAgentName: "SB-JS-CLIENT",
|
528
528
|
defaultAgentVersion: "SB-Agent-Version",
|
529
529
|
packageVersion: "6.0.0"
|
530
530
|
};
|
531
|
-
let
|
532
|
-
const
|
533
|
-
class
|
531
|
+
let O = {};
|
532
|
+
const j = {};
|
533
|
+
class He {
|
534
534
|
/**
|
535
535
|
*
|
536
536
|
* @param config ISbConfig interface
|
537
537
|
* @param pEndpoint string, optional
|
538
538
|
*/
|
539
539
|
constructor(e, t) {
|
540
|
-
|
540
|
+
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");
|
541
541
|
let s = e.endpoint || t;
|
542
542
|
if (!s) {
|
543
|
-
const n = new
|
544
|
-
e.oauthToken ? s = `${
|
543
|
+
const n = new C().getRegionURL, c = e.https === !1 ? "http" : "https";
|
544
|
+
e.oauthToken ? s = `${c}://${n(e.region)}/v1` : s = `${c}://${n(e.region)}/v2`;
|
545
545
|
}
|
546
546
|
const r = new Headers();
|
547
|
-
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n,
|
548
|
-
r.set(n,
|
549
|
-
}), r.has(
|
550
|
-
|
551
|
-
|
547
|
+
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([n, c]) => {
|
548
|
+
r.set(n, c);
|
549
|
+
}), r.has(F) || (r.set(F, H.defaultAgentName), r.set(
|
550
|
+
H.defaultAgentVersion,
|
551
|
+
H.packageVersion
|
552
552
|
));
|
553
553
|
let o = 5;
|
554
|
-
e.oauthToken && (r.set("Authorization", e.oauthToken), o = 3), e.rateLimit && (o = e.rateLimit), e.richTextSchema ? this.richTextResolver = new
|
554
|
+
e.oauthToken && (r.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 = ae(
|
555
555
|
this.throttledRequest.bind(this),
|
556
556
|
o,
|
557
557
|
1e3
|
558
|
-
), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new
|
558
|
+
), 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({
|
559
559
|
baseURL: s,
|
560
560
|
timeout: e.timeout || 0,
|
561
561
|
headers: r,
|
@@ -574,7 +574,7 @@ class Pe {
|
|
574
574
|
});
|
575
575
|
}
|
576
576
|
parseParams(e) {
|
577
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
577
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = j[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
578
578
|
}
|
579
579
|
factoryParamOptions(e, t) {
|
580
580
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
@@ -592,7 +592,7 @@ class Pe {
|
|
592
592
|
return this.cacheResponse(r, o, void 0, s);
|
593
593
|
}
|
594
594
|
async getAll(e, t, s, r) {
|
595
|
-
const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""),
|
595
|
+
const o = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`.replace(/\/$/, ""), c = s ?? n.substring(n.lastIndexOf("/") + 1), a = 1, h = await this.makeRequest(
|
596
596
|
n,
|
597
597
|
t,
|
598
598
|
o,
|
@@ -600,9 +600,9 @@ class Pe {
|
|
600
600
|
r
|
601
601
|
), u = h.total ? Math.ceil(h.total / o) : 1, p = await this.helpers.asyncMap(
|
602
602
|
this.helpers.range(a, u),
|
603
|
-
(
|
603
|
+
(b) => this.makeRequest(n, t, o, b + 1, r)
|
604
604
|
);
|
605
|
-
return this.helpers.flatMap([h, ...p], (
|
605
|
+
return this.helpers.flatMap([h, ...p], (b) => Object.values(b.data[c]));
|
606
606
|
}
|
607
607
|
post(e, t, s) {
|
608
608
|
const r = `/${e}`;
|
@@ -705,11 +705,11 @@ class Pe {
|
|
705
705
|
const r = (o, n = "") => {
|
706
706
|
if (!(!o || o._stopResolving)) {
|
707
707
|
if (Array.isArray(o))
|
708
|
-
o.forEach((
|
708
|
+
o.forEach((c, a) => r(c, `${n}[${a}]`));
|
709
709
|
else if (typeof o == "object")
|
710
|
-
for (const
|
711
|
-
const a = n ? `${n}.${
|
712
|
-
(o.component && o._uid || o.type === "link") && (this._insertRelations(o,
|
710
|
+
for (const c in o) {
|
711
|
+
const a = n ? `${n}.${c}` : c;
|
712
|
+
(o.component && o._uid || o.type === "link") && (this._insertRelations(o, c, t, s), this._insertLinks(o, c, s)), r(o[c], a);
|
713
713
|
}
|
714
714
|
}
|
715
715
|
};
|
@@ -718,14 +718,14 @@ class Pe {
|
|
718
718
|
async resolveLinks(e, t, s) {
|
719
719
|
let r = [];
|
720
720
|
if (e.link_uuids) {
|
721
|
-
const o = e.link_uuids.length, n = [],
|
722
|
-
for (let a = 0; a < o; a +=
|
723
|
-
const h = Math.min(o, a +
|
721
|
+
const o = e.link_uuids.length, n = [], c = 50;
|
722
|
+
for (let a = 0; a < o; a += c) {
|
723
|
+
const h = Math.min(o, a + c);
|
724
724
|
n.push(e.link_uuids.slice(a, h));
|
725
725
|
}
|
726
726
|
for (let a = 0; a < n.length; a++)
|
727
727
|
(await this.getStories({
|
728
|
-
per_page:
|
728
|
+
per_page: c,
|
729
729
|
language: t.language,
|
730
730
|
version: t.version,
|
731
731
|
starts_with: t.starts_with,
|
@@ -747,14 +747,14 @@ class Pe {
|
|
747
747
|
async resolveRelations(e, t, s) {
|
748
748
|
let r = [];
|
749
749
|
if (e.rel_uuids) {
|
750
|
-
const o = e.rel_uuids.length, n = [],
|
751
|
-
for (let a = 0; a < o; a +=
|
752
|
-
const h = Math.min(o, a +
|
750
|
+
const o = e.rel_uuids.length, n = [], c = 50;
|
751
|
+
for (let a = 0; a < o; a += c) {
|
752
|
+
const h = Math.min(o, a + c);
|
753
753
|
n.push(e.rel_uuids.slice(a, h));
|
754
754
|
}
|
755
755
|
for (let a = 0; a < n.length; a++)
|
756
756
|
(await this.getStories({
|
757
|
-
per_page:
|
757
|
+
per_page: c,
|
758
758
|
language: t.language,
|
759
759
|
version: t.version,
|
760
760
|
starts_with: t.starts_with,
|
@@ -763,6 +763,7 @@ class Pe {
|
|
763
763
|
})).data.stories.forEach((h) => {
|
764
764
|
r.push(h);
|
765
765
|
});
|
766
|
+
r.length > 0 && (e.rels = r, delete e.rel_uuids);
|
766
767
|
} else
|
767
768
|
r = e.rels;
|
768
769
|
r && r.length > 0 && r.forEach((o) => {
|
@@ -785,24 +786,24 @@ class Pe {
|
|
785
786
|
var r, o;
|
786
787
|
let n = [];
|
787
788
|
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (n = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].includes(t.resolve_links) && ((r = e.links) != null && r.length || (o = e.link_uuids) != null && o.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
788
|
-
for (const
|
789
|
+
for (const c in this.relations[s])
|
789
790
|
this.iterateTree(
|
790
|
-
this.relations[s][
|
791
|
+
this.relations[s][c],
|
791
792
|
n,
|
792
793
|
s
|
793
794
|
);
|
794
|
-
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((
|
795
|
-
this.iterateTree(
|
795
|
+
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
|
796
|
+
this.iterateTree(c, n, s);
|
796
797
|
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
797
798
|
}
|
798
799
|
async cacheResponse(e, t, s, r) {
|
799
800
|
const o = this.helpers.stringify({ url: e, params: t }), n = this.cacheProvider();
|
800
801
|
if (t.version === "published" && e !== "/cdn/spaces/me") {
|
801
|
-
const
|
802
|
-
if (
|
803
|
-
return Promise.resolve(
|
802
|
+
const c = await n.get(o);
|
803
|
+
if (c)
|
804
|
+
return Promise.resolve(c);
|
804
805
|
}
|
805
|
-
return new Promise(async (
|
806
|
+
return new Promise(async (c, a) => {
|
806
807
|
var h;
|
807
808
|
try {
|
808
809
|
const u = await this.throttle(
|
@@ -818,17 +819,17 @@ class Pe {
|
|
818
819
|
perPage: u.headers["per-page"] ? Number.parseInt(u.headers["per-page"]) : 0,
|
819
820
|
total: u.headers["per-page"] ? Number.parseInt(u.headers.total) : 0
|
820
821
|
})), p.data.story || p.data.stories) {
|
821
|
-
const
|
822
|
-
await this.resolveStories(p.data, t, `${
|
822
|
+
const _ = this.resolveCounter = ++this.resolveCounter % 1e3;
|
823
|
+
await this.resolveStories(p.data, t, `${_}`);
|
823
824
|
}
|
824
825
|
t.version === "published" && e !== "/cdn/spaces/me" && await n.set(o, p);
|
825
|
-
const
|
826
|
-
return t.token && p.data.cv && (
|
826
|
+
const b = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
827
|
+
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), c(p);
|
827
828
|
} catch (u) {
|
828
829
|
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
829
830
|
return console.log(
|
830
831
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
831
|
-
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(
|
832
|
+
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(c).catch(a);
|
832
833
|
a(u);
|
833
834
|
}
|
834
835
|
});
|
@@ -837,38 +838,37 @@ class Pe {
|
|
837
838
|
return this.client.setFetchOptions(r), this.client[e](t, s);
|
838
839
|
}
|
839
840
|
cacheVersions() {
|
840
|
-
return
|
841
|
+
return j;
|
841
842
|
}
|
842
843
|
cacheVersion() {
|
843
|
-
return
|
844
|
+
return j[this.accessToken];
|
844
845
|
}
|
845
846
|
setCacheVersion(e) {
|
846
|
-
this.accessToken && (
|
847
|
+
this.accessToken && (j[this.accessToken] = e);
|
847
848
|
}
|
848
849
|
clearCacheVersion() {
|
849
|
-
this.accessToken && (
|
850
|
+
this.accessToken && (j[this.accessToken] = 0);
|
850
851
|
}
|
851
852
|
cacheProvider() {
|
852
853
|
switch (this.cache.type) {
|
853
854
|
case "memory":
|
854
855
|
return {
|
855
856
|
get(e) {
|
856
|
-
return Promise.resolve(
|
857
|
+
return Promise.resolve(O[e]);
|
857
858
|
},
|
858
859
|
getAll() {
|
859
|
-
return Promise.resolve(
|
860
|
+
return Promise.resolve(O);
|
860
861
|
},
|
861
862
|
set(e, t) {
|
862
|
-
return
|
863
|
+
return O[e] = t, Promise.resolve(void 0);
|
863
864
|
},
|
864
865
|
flush() {
|
865
|
-
return
|
866
|
+
return O = {}, Promise.resolve(void 0);
|
866
867
|
}
|
867
868
|
};
|
868
869
|
case "custom":
|
869
870
|
if (this.cache.custom)
|
870
871
|
return this.cache.custom;
|
871
|
-
// eslint-disable-next-line no-fallthrough
|
872
872
|
default:
|
873
873
|
return {
|
874
874
|
get() {
|
@@ -890,7 +890,7 @@ class Pe {
|
|
890
890
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
891
891
|
}
|
892
892
|
}
|
893
|
-
const
|
893
|
+
const Fe = (i = {}) => {
|
894
894
|
const { apiOptions: e } = i;
|
895
895
|
if (!e || !e.accessToken) {
|
896
896
|
console.error(
|
@@ -898,8 +898,8 @@ const De = (i = {}) => {
|
|
898
898
|
);
|
899
899
|
return;
|
900
900
|
}
|
901
|
-
return { storyblokApi: new
|
902
|
-
},
|
901
|
+
return { storyblokApi: new He(e) };
|
902
|
+
}, Ge = (i) => {
|
903
903
|
if (typeof i != "object" || typeof i._editable > "u")
|
904
904
|
return {};
|
905
905
|
try {
|
@@ -914,18 +914,18 @@ const De = (i = {}) => {
|
|
914
914
|
return {};
|
915
915
|
}
|
916
916
|
};
|
917
|
-
function
|
917
|
+
function Me(i, e) {
|
918
918
|
if (!e)
|
919
919
|
return { src: i, attrs: {} };
|
920
920
|
let t = 0, s = 0;
|
921
921
|
const r = {}, o = [];
|
922
|
-
function n(a, h, u, p,
|
923
|
-
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) :
|
922
|
+
function n(a, h, u, p, b) {
|
923
|
+
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${p.charAt(0).toUpperCase() + p.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : b.push(`${p}(${a})`);
|
924
924
|
}
|
925
925
|
if (typeof e == "object") {
|
926
926
|
if (typeof e.width == "number" && e.width > 0 ? (r.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 ? (r.height = e.height, s = e.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), e.loading && ["lazy", "eager"].includes(e.loading) && (r.loading = e.loading), e.class && (r.class = e.class), e.filters) {
|
927
|
-
const { filters: a } = e || {}, { blur: h, brightness: u, fill: p, format:
|
928
|
-
h && n(h, 0, 100, "blur", o),
|
927
|
+
const { filters: a } = e || {}, { blur: h, brightness: u, fill: p, format: b, grayscale: _, quality: y, rotate: S } = a || {};
|
928
|
+
h && n(h, 0, 100, "blur", o), y && n(y, 0, 100, "quality", o), u && n(u, 0, 100, "brightness", o), p && o.push(`fill(${p})`), _ && 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})`);
|
929
929
|
}
|
930
930
|
e.srcset && (r.srcset = e.srcset.map((a) => {
|
931
931
|
if (typeof a == "number")
|
@@ -939,14 +939,14 @@ function Ne(i, e) {
|
|
939
939
|
}
|
940
940
|
}).join(", ")), e.sizes && (r.sizes = e.sizes.join(", "));
|
941
941
|
}
|
942
|
-
let
|
943
|
-
return t > 0 && s > 0 && (
|
944
|
-
src:
|
942
|
+
let c = `${i}/m/`;
|
943
|
+
return t > 0 && s > 0 && (c = `${c}${t}x${s}/`), o.length > 0 && (c = `${c}filters:${o.join(":")}`), {
|
944
|
+
src: c,
|
945
945
|
attrs: r
|
946
946
|
};
|
947
947
|
}
|
948
|
-
var
|
949
|
-
const
|
948
|
+
var $ = /* @__PURE__ */ ((i) => (i.DOCUMENT = "doc", i.HEADING = "heading", i.PARAGRAPH = "paragraph", i.QUOTE = "blockquote", i.OL_LIST = "ordered_list", i.UL_LIST = "bullet_list", i.LIST_ITEM = "list_item", i.CODE_BLOCK = "code_block", i.HR = "horizontal_rule", i.BR = "hard_break", i.IMAGE = "image", i.EMOJI = "emoji", i.COMPONENT = "blok", i.TABLE = "table", i.TABLE_ROW = "tableRow", i.TABLE_CELL = "tableCell", i.TABLE_HEADER = "tableHeader", i))($ || {}), E = /* @__PURE__ */ ((i) => (i.BOLD = "bold", i.STRONG = "strong", i.STRIKE = "strike", i.UNDERLINE = "underline", i.ITALIC = "italic", i.CODE = "code", i.LINK = "link", i.ANCHOR = "anchor", i.STYLED = "styled", i.SUPERSCRIPT = "superscript", i.SUBSCRIPT = "subscript", i.TEXT_STYLE = "textStyle", i.HIGHLIGHT = "highlight", i))(E || {}), V = /* @__PURE__ */ ((i) => (i.TEXT = "text", i))(V || {}), I = /* @__PURE__ */ ((i) => (i.URL = "url", i.STORY = "story", i.ASSET = "asset", i.EMAIL = "email", i))(I || {});
|
949
|
+
const Be = [
|
950
950
|
"area",
|
951
951
|
"base",
|
952
952
|
"br",
|
@@ -961,193 +961,199 @@ const He = [
|
|
961
961
|
"source",
|
962
962
|
"track",
|
963
963
|
"wbr"
|
964
|
-
],
|
965
|
-
function
|
964
|
+
], Ue = (i = {}) => Object.keys(i).map((e) => `${e}="${i[e]}"`).join(" "), ze = (i = {}) => Object.keys(i).map((e) => `${e}: ${i[e]}`).join("; ");
|
965
|
+
function De(i) {
|
966
966
|
return i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
967
967
|
}
|
968
|
-
const
|
969
|
-
function
|
970
|
-
const s =
|
968
|
+
const L = (i) => Object.fromEntries(Object.entries(i).filter(([e, t]) => t !== void 0));
|
969
|
+
function G(i, e = {}, t) {
|
970
|
+
const s = Ue(e), r = s ? `${i} ${s}` : i, o = Array.isArray(t) ? t.join("") : t || "";
|
971
971
|
if (i) {
|
972
|
-
if (
|
972
|
+
if (Be.includes(i))
|
973
973
|
return `<${r}>`;
|
974
974
|
} else return o;
|
975
975
|
return `<${r}>${o}</${i}>`;
|
976
976
|
}
|
977
|
-
function
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
textFn: s = Ue,
|
977
|
+
function Je(i = {}) {
|
978
|
+
const e = /* @__PURE__ */ new Map(), {
|
979
|
+
renderFn: t = G,
|
980
|
+
textFn: s = De,
|
982
981
|
resolvers: r = {},
|
983
982
|
optimizeImages: o = !1,
|
984
983
|
keyedResolvers: n = !1
|
985
|
-
} = i,
|
984
|
+
} = i, c = t !== G, a = () => ({ render: (l, d = {}, g) => {
|
985
|
+
if (n && l) {
|
986
|
+
const f = e.get(l) || 0;
|
987
|
+
e.set(l, f + 1), d.key = `${l}-${f}`;
|
988
|
+
}
|
989
|
+
return t(l, d, g);
|
990
|
+
} }), h = (l) => (d, g) => {
|
986
991
|
const f = d.attrs || {};
|
987
|
-
return
|
988
|
-
},
|
989
|
-
const { src:
|
990
|
-
let
|
992
|
+
return g.render(l, f, d.children || null);
|
993
|
+
}, u = (l, d) => {
|
994
|
+
const { src: g, alt: f, title: k, srcset: w, sizes: v } = l.attrs || {};
|
995
|
+
let T = g, R = {};
|
991
996
|
if (o) {
|
992
|
-
const { src:
|
993
|
-
|
997
|
+
const { src: se, attrs: re } = Me(g, o);
|
998
|
+
T = se, R = re;
|
994
999
|
}
|
995
|
-
|
996
|
-
|
997
|
-
key: `img-${e}`
|
998
|
-
});
|
999
|
-
const Z = {
|
1000
|
-
src: m,
|
1000
|
+
const te = {
|
1001
|
+
src: T,
|
1001
1002
|
alt: f,
|
1002
|
-
title:
|
1003
|
-
srcset:
|
1004
|
-
sizes:
|
1005
|
-
...
|
1006
|
-
};
|
1007
|
-
return t("img", O(Z));
|
1008
|
-
}, u = (c) => {
|
1009
|
-
const { level: d, ...f } = c.attrs || {}, b = {
|
1010
|
-
...f
|
1003
|
+
title: k,
|
1004
|
+
srcset: w,
|
1005
|
+
sizes: v,
|
1006
|
+
...R
|
1011
1007
|
};
|
1012
|
-
return
|
1013
|
-
}, p = (
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1008
|
+
return d.render("img", L(te));
|
1009
|
+
}, p = (l, d) => {
|
1010
|
+
const { level: g, ...f } = l.attrs || {};
|
1011
|
+
return d.render(`h${g}`, f, l.children);
|
1012
|
+
}, b = (l, d) => {
|
1013
|
+
var g, f, k, w;
|
1014
|
+
const v = d.render("img", {
|
1015
|
+
src: (g = l.attrs) == null ? void 0 : g.fallbackImage,
|
1016
|
+
alt: (f = l.attrs) == null ? void 0 : f.alt,
|
1018
1017
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
1019
1018
|
draggable: "false",
|
1020
1019
|
loading: "lazy"
|
1021
|
-
})
|
1020
|
+
});
|
1021
|
+
return d.render("span", {
|
1022
1022
|
"data-type": "emoji",
|
1023
|
-
"data-name": (
|
1024
|
-
"data-emoji": (
|
1025
|
-
};
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
const { class:
|
1032
|
-
class:
|
1033
|
-
id:
|
1034
|
-
style:
|
1035
|
-
} :
|
1036
|
-
return
|
1037
|
-
},
|
1038
|
-
const { marks: d, ...
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1023
|
+
"data-name": (k = l.attrs) == null ? void 0 : k.name,
|
1024
|
+
"data-emoji": (w = l.attrs) == null ? void 0 : w.emoji
|
1025
|
+
}, v);
|
1026
|
+
}, _ = (l, d) => d.render(
|
1027
|
+
"pre",
|
1028
|
+
l.attrs || {},
|
1029
|
+
d.render("code", {}, l.children || "")
|
1030
|
+
), y = (l, d = !1) => ({ text: g, attrs: f }, k) => {
|
1031
|
+
const { class: w, id: v, ...T } = f || {}, R = d ? {
|
1032
|
+
class: w,
|
1033
|
+
id: v,
|
1034
|
+
style: ze(T) || void 0
|
1035
|
+
} : f || {};
|
1036
|
+
return k.render(l, L(R), g);
|
1037
|
+
}, S = (l) => N(l), x = (l) => {
|
1038
|
+
const { marks: d, ...g } = l;
|
1039
|
+
if ("text" in l) {
|
1040
|
+
if (d)
|
1041
|
+
return d.reduce(
|
1042
|
+
(k, w) => S({ ...w, text: k }),
|
1043
|
+
S({ ...g, children: g.children })
|
1044
|
+
);
|
1045
|
+
const f = l.attrs || {};
|
1046
|
+
if (n) {
|
1047
|
+
const k = e.get("txt") || 0;
|
1048
|
+
e.set("txt", k + 1), f.key = `txt-${k}`;
|
1049
|
+
}
|
1050
|
+
return s(g.text, f);
|
1051
|
+
}
|
1052
|
+
return "";
|
1053
|
+
}, U = (l, d) => {
|
1054
|
+
const { linktype: g, href: f, anchor: k, ...w } = l.attrs || {};
|
1055
|
+
let v = "";
|
1056
|
+
switch (g) {
|
1049
1057
|
case I.ASSET:
|
1050
1058
|
case I.URL:
|
1051
|
-
|
1059
|
+
v = f;
|
1052
1060
|
break;
|
1053
1061
|
case I.EMAIL:
|
1054
|
-
|
1062
|
+
v = `mailto:${f}`;
|
1055
1063
|
break;
|
1056
1064
|
case I.STORY:
|
1057
|
-
|
1065
|
+
v = f, k && (v = `${v}#${k}`);
|
1058
1066
|
break;
|
1059
1067
|
default:
|
1060
|
-
|
1068
|
+
v = f;
|
1061
1069
|
break;
|
1062
1070
|
}
|
1063
|
-
const
|
1064
|
-
return
|
1065
|
-
},
|
1066
|
-
var
|
1067
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
1068
|
-
blok: (
|
1069
|
-
id: (f =
|
1070
|
-
key: `component-${e}`,
|
1071
|
+
const T = { ...w };
|
1072
|
+
return v && (T.href = v), d.render("a", T, l.text);
|
1073
|
+
}, Y = (l, d) => {
|
1074
|
+
var g, f;
|
1075
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), d.render("span", {
|
1076
|
+
blok: (g = l == null ? void 0 : l.attrs) == null ? void 0 : g.body[0],
|
1077
|
+
id: (f = l.attrs) == null ? void 0 : f.id,
|
1071
1078
|
style: "display: none"
|
1072
1079
|
});
|
1073
|
-
},
|
1074
|
-
const
|
1075
|
-
return
|
1076
|
-
},
|
1077
|
-
const
|
1078
|
-
return
|
1079
|
-
},
|
1080
|
-
const { colspan:
|
1081
|
-
|
1080
|
+
}, W = (l, d) => {
|
1081
|
+
const g = {}, f = d.render("tbody", {}, l.children);
|
1082
|
+
return d.render("table", g, f);
|
1083
|
+
}, X = (l, d) => {
|
1084
|
+
const g = {};
|
1085
|
+
return d.render("tr", g, l.children);
|
1086
|
+
}, Q = (l, d) => {
|
1087
|
+
const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
|
1088
|
+
...v
|
1082
1089
|
};
|
1083
|
-
|
1084
|
-
const
|
1085
|
-
return
|
1086
|
-
},
|
1087
|
-
const { colspan:
|
1088
|
-
|
1090
|
+
g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
|
1091
|
+
const R = [];
|
1092
|
+
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), d.render("td", L(T), l.children);
|
1093
|
+
}, Z = (l, d) => {
|
1094
|
+
const { colspan: g, rowspan: f, colwidth: k, backgroundColor: w, ...v } = l.attrs || {}, T = {
|
1095
|
+
...v
|
1089
1096
|
};
|
1090
|
-
|
1091
|
-
const
|
1092
|
-
return
|
1093
|
-
},
|
1094
|
-
[
|
1095
|
-
[
|
1096
|
-
[
|
1097
|
-
[
|
1098
|
-
[
|
1099
|
-
[
|
1100
|
-
[
|
1101
|
-
[
|
1102
|
-
[
|
1103
|
-
[
|
1104
|
-
[
|
1105
|
-
[
|
1106
|
-
[
|
1107
|
-
[
|
1108
|
-
[E.LINK,
|
1109
|
-
[E.ANCHOR,
|
1110
|
-
[E.STYLED,
|
1111
|
-
[E.BOLD,
|
1112
|
-
[E.TEXT_STYLE,
|
1113
|
-
[E.ITALIC,
|
1114
|
-
[E.UNDERLINE,
|
1115
|
-
[E.STRIKE,
|
1116
|
-
[E.CODE,
|
1117
|
-
[E.SUPERSCRIPT,
|
1118
|
-
[E.SUBSCRIPT,
|
1119
|
-
[E.HIGHLIGHT,
|
1120
|
-
[
|
1121
|
-
[
|
1122
|
-
[
|
1123
|
-
[
|
1124
|
-
...Object.entries(r).map(([
|
1097
|
+
g > 1 && (T.colspan = g), f > 1 && (T.rowspan = f);
|
1098
|
+
const R = [];
|
1099
|
+
return k && R.push(`width: ${k}px;`), w && R.push(`background-color: ${w};`), R.length > 0 && (T.style = R.join(" ")), d.render("th", L(T), l.children);
|
1100
|
+
}, ee = new Map([
|
1101
|
+
[$.DOCUMENT, h("")],
|
1102
|
+
[$.HEADING, p],
|
1103
|
+
[$.PARAGRAPH, h("p")],
|
1104
|
+
[$.UL_LIST, h("ul")],
|
1105
|
+
[$.OL_LIST, h("ol")],
|
1106
|
+
[$.LIST_ITEM, h("li")],
|
1107
|
+
[$.IMAGE, u],
|
1108
|
+
[$.EMOJI, b],
|
1109
|
+
[$.CODE_BLOCK, _],
|
1110
|
+
[$.HR, h("hr")],
|
1111
|
+
[$.BR, h("br")],
|
1112
|
+
[$.QUOTE, h("blockquote")],
|
1113
|
+
[$.COMPONENT, Y],
|
1114
|
+
[V.TEXT, x],
|
1115
|
+
[E.LINK, U],
|
1116
|
+
[E.ANCHOR, U],
|
1117
|
+
[E.STYLED, y("span", !0)],
|
1118
|
+
[E.BOLD, y("strong")],
|
1119
|
+
[E.TEXT_STYLE, y("span", !0)],
|
1120
|
+
[E.ITALIC, y("em")],
|
1121
|
+
[E.UNDERLINE, y("u")],
|
1122
|
+
[E.STRIKE, y("s")],
|
1123
|
+
[E.CODE, y("code")],
|
1124
|
+
[E.SUPERSCRIPT, y("sup")],
|
1125
|
+
[E.SUBSCRIPT, y("sub")],
|
1126
|
+
[E.HIGHLIGHT, y("mark")],
|
1127
|
+
[$.TABLE, W],
|
1128
|
+
[$.TABLE_ROW, X],
|
1129
|
+
[$.TABLE_CELL, Q],
|
1130
|
+
[$.TABLE_HEADER, Z],
|
1131
|
+
...Object.entries(r).map(([l, d]) => [l, d])
|
1125
1132
|
]);
|
1126
|
-
function A(
|
1127
|
-
|
1128
|
-
const d = Q.get(c.type);
|
1133
|
+
function A(l) {
|
1134
|
+
const d = ee.get(l.type);
|
1129
1135
|
if (!d)
|
1130
|
-
return console.error("<Storyblok>", `No resolver found for node type ${
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1136
|
+
return console.error("<Storyblok>", `No resolver found for node type ${l.type}`), "";
|
1137
|
+
const g = a();
|
1138
|
+
if (l.type === "text")
|
1139
|
+
return d(l, g);
|
1140
|
+
const f = l.content ? l.content.map(N) : void 0;
|
1134
1141
|
return d({
|
1135
|
-
...
|
1142
|
+
...l,
|
1136
1143
|
children: f
|
1137
|
-
|
1138
|
-
});
|
1144
|
+
}, g);
|
1139
1145
|
}
|
1140
|
-
function
|
1141
|
-
return
|
1146
|
+
function N(l) {
|
1147
|
+
return l.type === "doc" ? c ? l.content.map(A) : l.content.map(A).join("") : Array.isArray(l) ? l.map(A) : A(l);
|
1142
1148
|
}
|
1143
1149
|
return {
|
1144
|
-
render:
|
1150
|
+
render: N
|
1145
1151
|
};
|
1146
1152
|
}
|
1147
|
-
let
|
1148
|
-
const
|
1149
|
-
var
|
1150
|
-
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((
|
1153
|
+
let M, B = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
1154
|
+
const Ve = (i, e, t = {}) => {
|
1155
|
+
var c;
|
1156
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
|
1151
1157
|
"_storyblok"
|
1152
1158
|
), n = o !== null && +o === i;
|
1153
1159
|
if (!(!r || !n)) {
|
@@ -1162,7 +1168,7 @@ const Ge = (i, e, t = {}) => {
|
|
1162
1168
|
});
|
1163
1169
|
});
|
1164
1170
|
}
|
1165
|
-
},
|
1171
|
+
}, K = (i, e) => {
|
1166
1172
|
i.addNode("blok", (t) => {
|
1167
1173
|
let s = "";
|
1168
1174
|
return t.attrs.body.forEach((r) => {
|
@@ -1171,8 +1177,8 @@ const Ge = (i, e, t = {}) => {
|
|
1171
1177
|
html: s
|
1172
1178
|
};
|
1173
1179
|
});
|
1174
|
-
},
|
1175
|
-
var p,
|
1180
|
+
}, Ke = (i = {}) => {
|
1181
|
+
var p, b;
|
1176
1182
|
const {
|
1177
1183
|
bridge: e,
|
1178
1184
|
accessToken: t,
|
@@ -1182,39 +1188,39 @@ const Ge = (i, e, t = {}) => {
|
|
1182
1188
|
bridgeUrl: n
|
1183
1189
|
} = i;
|
1184
1190
|
r.accessToken = r.accessToken || t;
|
1185
|
-
const
|
1191
|
+
const c = { bridge: e, apiOptions: r };
|
1186
1192
|
let a = {};
|
1187
|
-
s.forEach((
|
1188
|
-
a = { ...a, ...
|
1189
|
-
}), n && (
|
1190
|
-
const u = !(typeof window > "u") && ((
|
1191
|
-
return e !== !1 && u &&
|
1192
|
-
},
|
1193
|
+
s.forEach((_) => {
|
1194
|
+
a = { ...a, ..._(c) };
|
1195
|
+
}), n && (B = n);
|
1196
|
+
const u = !(typeof window > "u") && ((b = (p = window.location) == null ? void 0 : p.search) == null ? void 0 : b.includes("_storyblok_tk"));
|
1197
|
+
return e !== !1 && u && J(B), M = new P(o.schema), o.resolver && K(M, o.resolver), a;
|
1198
|
+
}, qe = (i) => {
|
1193
1199
|
var e;
|
1194
1200
|
return !i || !((e = i == null ? void 0 : i.content) != null && e.some((t) => t.content || t.type === "blok" || t.type === "horizontal_rule"));
|
1195
|
-
},
|
1196
|
-
let s = t ||
|
1201
|
+
}, Ye = (i, e, t) => {
|
1202
|
+
let s = t || M;
|
1197
1203
|
if (!s) {
|
1198
1204
|
console.error(
|
1199
1205
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
1200
1206
|
);
|
1201
1207
|
return;
|
1202
1208
|
}
|
1203
|
-
return
|
1204
|
-
},
|
1209
|
+
return qe(i) ? "" : (e && (s = new P(e.schema), e.resolver && K(s, e.resolver)), s.render(i, {}, !1));
|
1210
|
+
}, We = () => J(B);
|
1205
1211
|
export {
|
1206
|
-
|
1212
|
+
$ as BlockTypes,
|
1207
1213
|
E as MarkTypes,
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1214
|
+
P as RichTextResolver,
|
1215
|
+
Ce as RichTextSchema,
|
1216
|
+
V as TextTypes,
|
1217
|
+
Fe as apiPlugin,
|
1218
|
+
qe as isRichTextEmpty,
|
1219
|
+
We as loadStoryblokBridge,
|
1220
|
+
Ve as registerStoryblokBridge,
|
1221
|
+
Ye as renderRichText,
|
1222
|
+
Je as richTextResolver,
|
1223
|
+
Ge as storyblokEditable,
|
1224
|
+
Ke as storyblokInit,
|
1225
|
+
Ve as useStoryblokBridge
|
1220
1226
|
};
|