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