@storyblok/js 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/storyblok-js.js +2 -2
- package/dist/storyblok-js.mjs +325 -325
- package/package.json +2 -2
package/dist/storyblok-js.mjs
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
let
|
2
|
-
const
|
3
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (
|
1
|
+
let _ = !1;
|
2
|
+
const S = [], O = (o) => new Promise((e, t) => {
|
3
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (r) => {
|
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
|
+
_ ? r() : S.push(r);
|
9
9
|
}, document.getElementById("storyblok-javascript-bridge")))
|
10
10
|
return;
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
11
|
+
const s = document.createElement("script");
|
12
|
+
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (r) => t(r), s.onload = (r) => {
|
13
|
+
S.forEach((i) => i()), _ = !0, e(r);
|
14
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
15
15
|
});
|
16
|
-
var
|
17
|
-
function
|
18
|
-
return !(
|
16
|
+
var I = Object.defineProperty, P = (o, e, t) => e in o ? I(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, h = (o, e, t) => (P(o, typeof e != "symbol" ? e + "" : e, t), t);
|
17
|
+
function j(o) {
|
18
|
+
return !(o !== o || o === 1 / 0 || o === -1 / 0);
|
19
19
|
}
|
20
|
-
function
|
21
|
-
if (!
|
20
|
+
function C(o, e, t) {
|
21
|
+
if (!j(e))
|
22
22
|
throw new TypeError("Expected `limit` to be a finite number");
|
23
|
-
if (!
|
23
|
+
if (!j(t))
|
24
24
|
throw new TypeError("Expected `interval` to be a finite number");
|
25
|
-
const
|
26
|
-
let
|
25
|
+
const s = [];
|
26
|
+
let r = [], i = 0;
|
27
27
|
const n = function() {
|
28
|
-
|
28
|
+
i++;
|
29
29
|
const a = setTimeout(function() {
|
30
|
-
|
30
|
+
i--, s.length > 0 && n(), r = r.filter(function(u) {
|
31
31
|
return u !== a;
|
32
32
|
});
|
33
33
|
}, t);
|
34
|
-
|
35
|
-
const l =
|
36
|
-
l.resolve(
|
34
|
+
r.indexOf(a) < 0 && r.push(a);
|
35
|
+
const l = s.shift();
|
36
|
+
l.resolve(o.apply(l.self, l.args));
|
37
37
|
}, c = function(...a) {
|
38
38
|
const l = this;
|
39
|
-
return new Promise(function(u,
|
40
|
-
|
39
|
+
return new Promise(function(u, p) {
|
40
|
+
s.push({
|
41
41
|
resolve: u,
|
42
|
-
reject:
|
42
|
+
reject: p,
|
43
43
|
args: a,
|
44
44
|
self: l
|
45
|
-
}),
|
45
|
+
}), i < e && n();
|
46
46
|
});
|
47
47
|
};
|
48
48
|
return c.abort = function() {
|
49
|
-
|
49
|
+
r.forEach(clearTimeout), r = [], s.forEach(function(a) {
|
50
50
|
a.reject(function() {
|
51
51
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
52
52
|
});
|
53
|
-
}),
|
53
|
+
}), s.length = 0;
|
54
54
|
}, c;
|
55
55
|
}
|
56
56
|
class b {
|
57
57
|
constructor() {
|
58
|
-
h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25,
|
58
|
+
h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, s = 1) => ({
|
59
59
|
...e,
|
60
60
|
per_page: t,
|
61
|
-
page:
|
61
|
+
page: s
|
62
62
|
})), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
|
63
|
-
const
|
64
|
-
return this.arrayFrom(
|
65
|
-
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((
|
63
|
+
const s = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
64
|
+
return this.arrayFrom(s, (i, n) => n * r + e);
|
65
|
+
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((s, r) => [...s, ...r], [])), h(this, "escapeHTML", function(e) {
|
66
66
|
const t = {
|
67
67
|
"&": "&",
|
68
68
|
"<": "<",
|
69
69
|
">": ">",
|
70
70
|
'"': """,
|
71
71
|
"'": "'"
|
72
|
-
},
|
73
|
-
return e &&
|
72
|
+
}, s = /[&<>"']/g, r = RegExp(s.source);
|
73
|
+
return e && r.test(e) ? e.replace(s, (i) => t[i]) : e;
|
74
74
|
});
|
75
75
|
}
|
76
76
|
/**
|
@@ -80,20 +80,20 @@ class b {
|
|
80
80
|
* @param {Boolean} isArray
|
81
81
|
* @return {String} Stringified object
|
82
82
|
*/
|
83
|
-
stringify(e, t,
|
84
|
-
const
|
85
|
-
for (const
|
86
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
83
|
+
stringify(e, t, s) {
|
84
|
+
const r = [];
|
85
|
+
for (const i in e) {
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(e, i))
|
87
87
|
continue;
|
88
|
-
const n = e[
|
88
|
+
const n = e[i], c = s ? "" : encodeURIComponent(i);
|
89
89
|
let a;
|
90
90
|
typeof n == "object" ? a = this.stringify(
|
91
91
|
n,
|
92
92
|
t ? t + encodeURIComponent("[" + c + "]") : c,
|
93
93
|
Array.isArray(n)
|
94
|
-
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n),
|
94
|
+
) : a = (t ? t + encodeURIComponent("[" + c + "]") : c) + "=" + encodeURIComponent(n), r.push(a);
|
95
95
|
}
|
96
|
-
return
|
96
|
+
return r.join("&");
|
97
97
|
}
|
98
98
|
/**
|
99
99
|
* @method getRegionURL
|
@@ -101,14 +101,14 @@ class b {
|
|
101
101
|
* @return {String} The base URL of the region
|
102
102
|
*/
|
103
103
|
getRegionURL(e) {
|
104
|
-
const t = "api.storyblok.com",
|
104
|
+
const t = "api.storyblok.com", s = "api-us.storyblok.com", r = "app.storyblokchina.cn", i = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
105
105
|
switch (e) {
|
106
106
|
case "us":
|
107
|
-
return r;
|
108
|
-
case "cn":
|
109
107
|
return s;
|
108
|
+
case "cn":
|
109
|
+
return r;
|
110
110
|
case "ap":
|
111
|
-
return
|
111
|
+
return i;
|
112
112
|
case "ca":
|
113
113
|
return n;
|
114
114
|
default:
|
@@ -116,76 +116,76 @@ class b {
|
|
116
116
|
}
|
117
117
|
}
|
118
118
|
}
|
119
|
-
const
|
119
|
+
const A = function(o, e) {
|
120
120
|
const t = {};
|
121
|
-
for (const
|
122
|
-
const
|
123
|
-
e.indexOf(
|
121
|
+
for (const s in o) {
|
122
|
+
const r = o[s];
|
123
|
+
e.indexOf(s) > -1 && r !== null && (t[s] = r);
|
124
124
|
}
|
125
125
|
return t;
|
126
|
-
},
|
126
|
+
}, N = (o) => o === "email", L = () => ({
|
127
127
|
singleTag: "hr"
|
128
|
-
}),
|
128
|
+
}), M = () => ({
|
129
129
|
tag: "blockquote"
|
130
|
-
}),
|
130
|
+
}), z = () => ({
|
131
131
|
tag: "ul"
|
132
|
-
}),
|
132
|
+
}), U = (o) => ({
|
133
133
|
tag: [
|
134
134
|
"pre",
|
135
135
|
{
|
136
136
|
tag: "code",
|
137
|
-
attrs:
|
137
|
+
attrs: o.attrs
|
138
138
|
}
|
139
139
|
]
|
140
|
-
}),
|
140
|
+
}), H = () => ({
|
141
141
|
singleTag: "br"
|
142
|
-
}),
|
143
|
-
tag: `h${
|
144
|
-
}),
|
142
|
+
}), q = (o) => ({
|
143
|
+
tag: `h${o.attrs.level}`
|
144
|
+
}), B = (o) => ({
|
145
145
|
singleTag: [
|
146
146
|
{
|
147
147
|
tag: "img",
|
148
|
-
attrs:
|
148
|
+
attrs: A(o.attrs, ["src", "alt", "title"])
|
149
149
|
}
|
150
150
|
]
|
151
|
-
}), V = () => ({
|
152
|
-
tag: "li"
|
153
151
|
}), F = () => ({
|
152
|
+
tag: "li"
|
153
|
+
}), V = () => ({
|
154
154
|
tag: "ol"
|
155
|
-
}),
|
155
|
+
}), J = () => ({
|
156
156
|
tag: "p"
|
157
|
-
}),
|
157
|
+
}), D = (o) => ({
|
158
158
|
tag: [
|
159
159
|
{
|
160
160
|
tag: "span",
|
161
161
|
attrs: {
|
162
162
|
"data-type": "emoji",
|
163
|
-
"data-name":
|
164
|
-
emoji:
|
163
|
+
"data-name": o.attrs.name,
|
164
|
+
emoji: o.attrs.emoji
|
165
165
|
}
|
166
166
|
}
|
167
167
|
]
|
168
|
-
}),
|
168
|
+
}), Y = () => ({
|
169
169
|
tag: "b"
|
170
|
-
}),
|
170
|
+
}), K = () => ({
|
171
171
|
tag: "s"
|
172
|
-
}),
|
172
|
+
}), W = () => ({
|
173
173
|
tag: "u"
|
174
|
-
}),
|
174
|
+
}), G = () => ({
|
175
175
|
tag: "strong"
|
176
|
-
}), q = () => ({
|
177
|
-
tag: "code"
|
178
176
|
}), Q = () => ({
|
177
|
+
tag: "code"
|
178
|
+
}), X = () => ({
|
179
179
|
tag: "i"
|
180
|
-
}), Z = (
|
181
|
-
if (!
|
180
|
+
}), Z = (o) => {
|
181
|
+
if (!o.attrs)
|
182
182
|
return {
|
183
183
|
tag: ""
|
184
184
|
};
|
185
|
-
const e = new b().escapeHTML, t = { ...
|
186
|
-
if (delete t.linktype, t.href && (t.href = e(
|
187
|
-
for (const
|
188
|
-
t[
|
185
|
+
const e = new b().escapeHTML, t = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
|
186
|
+
if (delete t.linktype, t.href && (t.href = e(o.attrs.href || "")), N(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
187
|
+
for (const r in t.custom)
|
188
|
+
t[r] = t.custom[r];
|
189
189
|
delete t.custom;
|
190
190
|
}
|
191
191
|
return {
|
@@ -196,94 +196,94 @@ const P = function(i, e) {
|
|
196
196
|
}
|
197
197
|
]
|
198
198
|
};
|
199
|
-
}, ee = (
|
199
|
+
}, ee = (o) => ({
|
200
200
|
tag: [
|
201
201
|
{
|
202
202
|
tag: "span",
|
203
|
-
attrs:
|
203
|
+
attrs: o.attrs
|
204
204
|
}
|
205
205
|
]
|
206
206
|
}), te = () => ({
|
207
207
|
tag: "sub"
|
208
|
-
}),
|
208
|
+
}), se = () => ({
|
209
209
|
tag: "sup"
|
210
|
-
}),
|
210
|
+
}), re = (o) => ({
|
211
211
|
tag: [
|
212
212
|
{
|
213
213
|
tag: "span",
|
214
|
-
attrs:
|
214
|
+
attrs: o.attrs
|
215
215
|
}
|
216
216
|
]
|
217
|
-
}),
|
217
|
+
}), ie = (o) => {
|
218
218
|
var e;
|
219
|
-
return (e =
|
219
|
+
return (e = o.attrs) != null && e.color ? {
|
220
220
|
tag: [
|
221
221
|
{
|
222
222
|
tag: "span",
|
223
223
|
attrs: {
|
224
|
-
style: `background-color:${
|
224
|
+
style: `background-color:${o.attrs.color};`
|
225
225
|
}
|
226
226
|
}
|
227
227
|
]
|
228
228
|
} : {
|
229
229
|
tag: ""
|
230
230
|
};
|
231
|
-
}, ne = (
|
231
|
+
}, ne = (o) => {
|
232
232
|
var e;
|
233
|
-
return (e =
|
233
|
+
return (e = o.attrs) != null && e.color ? {
|
234
234
|
tag: [
|
235
235
|
{
|
236
236
|
tag: "span",
|
237
237
|
attrs: {
|
238
|
-
style: `color:${
|
238
|
+
style: `color:${o.attrs.color}`
|
239
239
|
}
|
240
240
|
}
|
241
241
|
]
|
242
242
|
} : {
|
243
243
|
tag: ""
|
244
244
|
};
|
245
|
-
},
|
245
|
+
}, oe = {
|
246
246
|
nodes: {
|
247
|
-
horizontal_rule:
|
248
|
-
blockquote:
|
249
|
-
bullet_list:
|
250
|
-
code_block:
|
251
|
-
hard_break:
|
252
|
-
heading:
|
253
|
-
image:
|
254
|
-
list_item:
|
255
|
-
ordered_list:
|
256
|
-
paragraph:
|
257
|
-
emoji:
|
247
|
+
horizontal_rule: L,
|
248
|
+
blockquote: M,
|
249
|
+
bullet_list: z,
|
250
|
+
code_block: U,
|
251
|
+
hard_break: H,
|
252
|
+
heading: q,
|
253
|
+
image: B,
|
254
|
+
list_item: F,
|
255
|
+
ordered_list: V,
|
256
|
+
paragraph: J,
|
257
|
+
emoji: D
|
258
258
|
},
|
259
259
|
marks: {
|
260
|
-
bold:
|
261
|
-
strike:
|
262
|
-
underline:
|
263
|
-
strong:
|
264
|
-
code:
|
265
|
-
italic:
|
260
|
+
bold: Y,
|
261
|
+
strike: K,
|
262
|
+
underline: W,
|
263
|
+
strong: G,
|
264
|
+
code: Q,
|
265
|
+
italic: X,
|
266
266
|
link: Z,
|
267
267
|
styled: ee,
|
268
268
|
subscript: te,
|
269
|
-
superscript:
|
270
|
-
anchor:
|
271
|
-
highlight:
|
269
|
+
superscript: se,
|
270
|
+
anchor: re,
|
271
|
+
highlight: ie,
|
272
272
|
textStyle: ne
|
273
273
|
}
|
274
|
-
}, ae = function(
|
274
|
+
}, ae = function(o) {
|
275
275
|
const e = {
|
276
276
|
"&": "&",
|
277
277
|
"<": "<",
|
278
278
|
">": ">",
|
279
279
|
'"': """,
|
280
280
|
"'": "'"
|
281
|
-
}, t = /[&<>"']/g,
|
282
|
-
return
|
281
|
+
}, t = /[&<>"']/g, s = RegExp(t.source);
|
282
|
+
return o && s.test(o) ? o.replace(t, (r) => e[r]) : o;
|
283
283
|
};
|
284
|
-
class
|
284
|
+
class k {
|
285
285
|
constructor(e) {
|
286
|
-
h(this, "marks"), h(this, "nodes"), e || (e =
|
286
|
+
h(this, "marks"), h(this, "nodes"), e || (e = oe), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
287
287
|
}
|
288
288
|
addNode(e, t) {
|
289
289
|
this.nodes[e] = t;
|
@@ -293,10 +293,10 @@ class T {
|
|
293
293
|
}
|
294
294
|
render(e, t = { optimizeImages: !1 }) {
|
295
295
|
if (e && e.content && Array.isArray(e.content)) {
|
296
|
-
let
|
297
|
-
return e.content.forEach((
|
298
|
-
|
299
|
-
}), t.optimizeImages ? this.optimizeImages(
|
296
|
+
let s = "";
|
297
|
+
return e.content.forEach((r) => {
|
298
|
+
s += this.renderNode(r);
|
299
|
+
}), t.optimizeImages ? this.optimizeImages(s, t.optimizeImages) : s;
|
300
300
|
}
|
301
301
|
return console.warn(
|
302
302
|
`The render method must receive an Object with a "content" field.
|
@@ -326,61 +326,61 @@ class T {
|
|
326
326
|
), "";
|
327
327
|
}
|
328
328
|
optimizeImages(e, t) {
|
329
|
-
let
|
330
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (
|
331
|
-
const c =
|
329
|
+
let s = 0, r = 0, i = "", n = "";
|
330
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (i += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (i += `height="${t.height}" `, r = t.height), (t.loading === "lazy" || t.loading === "eager") && (i += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (i += `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-Fa-f]{6}/g) || 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))), i.length > 0 && (e = e.replace(/<img/g, `<img ${i.trim()}`));
|
331
|
+
const c = s > 0 || r > 0 || n.length > 0 ? `${s}x${r}${n}` : "";
|
332
332
|
return e = e.replace(
|
333
333
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
334
334
|
`a.storyblok.com/f/$1/$2.$3/m/${c}`
|
335
335
|
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
336
336
|
var l, u;
|
337
|
-
const
|
337
|
+
const p = a.match(
|
338
338
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
339
339
|
);
|
340
|
-
if (
|
341
|
-
const
|
342
|
-
srcset: (l = t.srcset) == null ? void 0 : l.map((
|
343
|
-
if (typeof
|
344
|
-
return `//${
|
345
|
-
if (typeof
|
346
|
-
let
|
347
|
-
return typeof
|
340
|
+
if (p && p.length > 0) {
|
341
|
+
const g = {
|
342
|
+
srcset: (l = t.srcset) == null ? void 0 : l.map((d) => {
|
343
|
+
if (typeof d == "number")
|
344
|
+
return `//${p}/m/${d}x0${n} ${d}w`;
|
345
|
+
if (typeof d == "object" && d.length === 2) {
|
346
|
+
let v = 0, T = 0;
|
347
|
+
return typeof d[0] == "number" && (v = d[0]), typeof d[1] == "number" && (T = d[1]), `//${p}/m/${v}x${T}${n} ${v}w`;
|
348
348
|
}
|
349
349
|
}).join(", "),
|
350
|
-
sizes: (u = t.sizes) == null ? void 0 : u.map((
|
350
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((d) => d).join(", ")
|
351
351
|
};
|
352
|
-
let
|
353
|
-
return
|
352
|
+
let f = "";
|
353
|
+
return g.srcset && (f += `srcset="${g.srcset}" `), g.sizes && (f += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${f.trim()}`);
|
354
354
|
}
|
355
355
|
return a;
|
356
356
|
})), e;
|
357
357
|
}
|
358
358
|
renderNode(e) {
|
359
359
|
const t = [];
|
360
|
-
e.marks && e.marks.forEach((
|
361
|
-
const
|
362
|
-
|
360
|
+
e.marks && e.marks.forEach((r) => {
|
361
|
+
const i = this.getMatchingMark(r);
|
362
|
+
i && i.tag !== "" && t.push(this.renderOpeningTag(i.tag));
|
363
363
|
});
|
364
|
-
const
|
365
|
-
return
|
366
|
-
t.push(this.renderNode(
|
367
|
-
}) : e.text ? t.push(ae(e.text)) :
|
368
|
-
const
|
369
|
-
|
364
|
+
const s = this.getMatchingNode(e);
|
365
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((r) => {
|
366
|
+
t.push(this.renderNode(r));
|
367
|
+
}) : e.text ? t.push(ae(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) => {
|
368
|
+
const i = this.getMatchingMark(r);
|
369
|
+
i && i.tag !== "" && t.push(this.renderClosingTag(i.tag));
|
370
370
|
}), t.join("");
|
371
371
|
}
|
372
372
|
renderTag(e, t) {
|
373
|
-
return e.constructor === String ? `<${e}${t}>` : e.map((
|
374
|
-
if (
|
375
|
-
return `<${
|
373
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
|
374
|
+
if (s.constructor === String)
|
375
|
+
return `<${s}${t}>`;
|
376
376
|
{
|
377
|
-
let
|
378
|
-
if (
|
379
|
-
for (const
|
380
|
-
const n =
|
381
|
-
n !== null && (
|
377
|
+
let r = `<${s.tag}`;
|
378
|
+
if (s.attrs)
|
379
|
+
for (const i in s.attrs) {
|
380
|
+
const n = s.attrs[i];
|
381
|
+
n !== null && (r += ` ${i}="${n}"`);
|
382
382
|
}
|
383
|
-
return `${
|
383
|
+
return `${r}${t}>`;
|
384
384
|
}
|
385
385
|
}).join("");
|
386
386
|
}
|
@@ -440,36 +440,36 @@ class le {
|
|
440
440
|
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
441
441
|
}
|
442
442
|
async _responseHandler(e) {
|
443
|
-
const t = [],
|
443
|
+
const t = [], s = {
|
444
444
|
data: {},
|
445
445
|
headers: {},
|
446
446
|
status: 0,
|
447
447
|
statusText: ""
|
448
448
|
};
|
449
|
-
e.status !== 204 && await e.json().then((
|
450
|
-
|
449
|
+
e.status !== 204 && await e.json().then((r) => {
|
450
|
+
s.data = r;
|
451
451
|
});
|
452
|
-
for (const
|
453
|
-
t[
|
454
|
-
return
|
452
|
+
for (const r of e.headers.entries())
|
453
|
+
t[r[0]] = r[1];
|
454
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
455
455
|
}
|
456
456
|
async _methodHandler(e) {
|
457
|
-
let t = `${this.baseURL}${this.url}`,
|
457
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
458
458
|
if (e === "get") {
|
459
459
|
const a = new b();
|
460
460
|
t = `${this.baseURL}${this.url}?${a.stringify(
|
461
461
|
this.parameters
|
462
462
|
)}`;
|
463
463
|
} else
|
464
|
-
|
465
|
-
const
|
464
|
+
s = JSON.stringify(this.parameters);
|
465
|
+
const r = new URL(t), i = new AbortController(), { signal: n } = i;
|
466
466
|
let c;
|
467
|
-
this.timeout && (c = setTimeout(() =>
|
467
|
+
this.timeout && (c = setTimeout(() => i.abort(), this.timeout));
|
468
468
|
try {
|
469
|
-
const a = await fetch(`${
|
469
|
+
const a = await fetch(`${r}`, {
|
470
470
|
method: e,
|
471
471
|
headers: this.headers,
|
472
|
-
body:
|
472
|
+
body: s,
|
473
473
|
signal: n,
|
474
474
|
...this.fetchOptions
|
475
475
|
});
|
@@ -492,26 +492,26 @@ class le {
|
|
492
492
|
}
|
493
493
|
_statusHandler(e) {
|
494
494
|
const t = /20[0-6]/g;
|
495
|
-
return new Promise((
|
495
|
+
return new Promise((s, r) => {
|
496
496
|
if (t.test(`${e.status}`))
|
497
|
-
return
|
498
|
-
const
|
497
|
+
return s(e);
|
498
|
+
const i = {
|
499
499
|
message: e.statusText,
|
500
500
|
status: e.status,
|
501
501
|
response: Array.isArray(e.data) ? e.data[0] : e.data.error || e.data.slug
|
502
502
|
};
|
503
|
-
|
503
|
+
r(i);
|
504
504
|
});
|
505
505
|
}
|
506
506
|
}
|
507
|
-
var ce = {
|
508
|
-
const
|
507
|
+
var ce = { npm_package_version: "6.6.1" };
|
508
|
+
const x = "SB-Agent", w = {
|
509
509
|
defaultAgentName: "SB-JS-CLIENT",
|
510
510
|
defaultAgentVersion: "SB-Agent-Version",
|
511
511
|
packageVersion: ce.npm_package_version
|
512
512
|
};
|
513
|
-
let
|
514
|
-
const
|
513
|
+
let y = {};
|
514
|
+
const m = {};
|
515
515
|
class he {
|
516
516
|
/**
|
517
517
|
*
|
@@ -520,20 +520,20 @@ class he {
|
|
520
520
|
*/
|
521
521
|
constructor(e, t) {
|
522
522
|
h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "resolveCounter"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), h(this, "stringifiedStoriesCache");
|
523
|
-
let
|
524
|
-
const
|
525
|
-
e.oauthToken ?
|
523
|
+
let s = e.endpoint || t;
|
524
|
+
const r = new b().getRegionURL, i = e.https === !1 ? "http" : "https";
|
525
|
+
e.oauthToken ? s = `${i}://${r(e.region)}/v1` : s = `${i}://${r(e.region)}/v2`;
|
526
526
|
const n = new Headers();
|
527
527
|
if (n.set("Content-Type", "application/json"), n.set("Accept", "application/json"), e.headers)
|
528
528
|
for (const a in e.headers)
|
529
529
|
n.set(a, e.headers[a]);
|
530
|
-
n.has(
|
531
|
-
|
532
|
-
|
530
|
+
n.has(x) || (n.set(x, w.defaultAgentName), n.set(
|
531
|
+
w.defaultAgentVersion,
|
532
|
+
w.packageVersion
|
533
533
|
));
|
534
534
|
let c = 5;
|
535
|
-
e.oauthToken && (n.set("Authorization", e.oauthToken), c = 3), e.rateLimit && (c = e.rateLimit), e.richTextSchema ? this.richTextResolver = new
|
536
|
-
baseURL:
|
535
|
+
e.oauthToken && (n.set("Authorization", e.oauthToken), c = 3), e.rateLimit && (c = e.rateLimit), e.richTextSchema ? this.richTextResolver = new k(e.richTextSchema) : this.richTextResolver = new k(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 5, this.throttle = C(this.throttledRequest, c, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new b(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new le({
|
536
|
+
baseURL: s,
|
537
537
|
timeout: e.timeout || 0,
|
538
538
|
headers: n,
|
539
539
|
responseInterceptor: e.responseInterceptor,
|
@@ -542,61 +542,61 @@ class he {
|
|
542
542
|
}
|
543
543
|
setComponentResolver(e) {
|
544
544
|
this.richTextResolver.addNode("blok", (t) => {
|
545
|
-
let
|
546
|
-
return t.attrs.body && t.attrs.body.forEach((
|
547
|
-
|
545
|
+
let s = "";
|
546
|
+
return t.attrs.body && t.attrs.body.forEach((r) => {
|
547
|
+
s += e(r.component, r);
|
548
548
|
}), {
|
549
|
-
html:
|
549
|
+
html: s
|
550
550
|
};
|
551
551
|
});
|
552
552
|
}
|
553
553
|
parseParams(e) {
|
554
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
554
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = m[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
|
555
555
|
}
|
556
556
|
factoryParamOptions(e, t) {
|
557
557
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
558
558
|
}
|
559
|
-
makeRequest(e, t,
|
560
|
-
const
|
559
|
+
makeRequest(e, t, s, r) {
|
560
|
+
const i = this.factoryParamOptions(
|
561
561
|
e,
|
562
|
-
this.helpers.getOptionsPage(t,
|
562
|
+
this.helpers.getOptionsPage(t, s, r)
|
563
563
|
);
|
564
|
-
return this.cacheResponse(e,
|
564
|
+
return this.cacheResponse(e, i);
|
565
565
|
}
|
566
|
-
get(e, t,
|
566
|
+
get(e, t, s) {
|
567
567
|
t || (t = {});
|
568
|
-
const
|
569
|
-
return this.client.setFetchOptions(
|
570
|
-
}
|
571
|
-
async getAll(e, t,
|
572
|
-
const
|
573
|
-
this.client.setFetchOptions(
|
574
|
-
const
|
575
|
-
this.helpers.range(l,
|
576
|
-
(
|
568
|
+
const r = `/${e}`, i = this.factoryParamOptions(r, t);
|
569
|
+
return this.client.setFetchOptions(s), this.cacheResponse(r, i);
|
570
|
+
}
|
571
|
+
async getAll(e, t, s, r) {
|
572
|
+
const i = (t == null ? void 0 : t.per_page) || 25, n = `/${e}`, c = n.split("/"), a = s || c[c.length - 1], l = 1, u = await this.makeRequest(n, t, i, l), p = u.total ? Math.ceil(u.total / i) : 1;
|
573
|
+
this.client.setFetchOptions(r);
|
574
|
+
const g = await this.helpers.asyncMap(
|
575
|
+
this.helpers.range(l, p),
|
576
|
+
(f) => this.makeRequest(n, t, i, f + 1)
|
577
577
|
);
|
578
578
|
return this.helpers.flatMap(
|
579
|
-
[u, ...
|
580
|
-
(
|
579
|
+
[u, ...g],
|
580
|
+
(f) => Object.values(f.data[a])
|
581
581
|
);
|
582
582
|
}
|
583
|
-
post(e, t,
|
584
|
-
const
|
585
|
-
return this.client.setFetchOptions(
|
583
|
+
post(e, t, s) {
|
584
|
+
const r = `/${e}`;
|
585
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("post", r, t));
|
586
586
|
}
|
587
|
-
put(e, t,
|
588
|
-
const
|
589
|
-
return this.client.setFetchOptions(
|
587
|
+
put(e, t, s) {
|
588
|
+
const r = `/${e}`;
|
589
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("put", r, t));
|
590
590
|
}
|
591
|
-
delete(e, t,
|
592
|
-
const
|
593
|
-
return this.client.setFetchOptions(
|
591
|
+
delete(e, t, s) {
|
592
|
+
const r = `/${e}`;
|
593
|
+
return this.client.setFetchOptions(s), Promise.resolve(this.throttle("delete", r, t));
|
594
594
|
}
|
595
595
|
getStories(e, t) {
|
596
596
|
return this.client.setFetchOptions(t), this.get("cdn/stories", e);
|
597
597
|
}
|
598
|
-
getStory(e, t,
|
599
|
-
return this.client.setFetchOptions(
|
598
|
+
getStory(e, t, s) {
|
599
|
+
return this.client.setFetchOptions(s), this.get(`cdn/stories/${e}`, t);
|
600
600
|
}
|
601
601
|
getToken() {
|
602
602
|
return this.accessToken;
|
@@ -607,9 +607,9 @@ class he {
|
|
607
607
|
_cleanCopy(e) {
|
608
608
|
return JSON.parse(JSON.stringify(e));
|
609
609
|
}
|
610
|
-
_insertLinks(e, t,
|
611
|
-
const
|
612
|
-
|
610
|
+
_insertLinks(e, t, s) {
|
611
|
+
const r = e[t];
|
612
|
+
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[s][r.id] ? r.story = this._cleanCopy(this.links[s][r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[s][r.uuid] && (r.story = this._cleanCopy(this.links[s][r.uuid]));
|
613
613
|
}
|
614
614
|
/**
|
615
615
|
*
|
@@ -622,40 +622,40 @@ class he {
|
|
622
622
|
this.relations[e][t]
|
623
623
|
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
624
624
|
}
|
625
|
-
_insertRelations(e, t,
|
626
|
-
|
627
|
-
}
|
628
|
-
iterateTree(e, t,
|
629
|
-
const
|
630
|
-
if (
|
631
|
-
if (
|
632
|
-
for (let n = 0; n <
|
633
|
-
|
634
|
-
else if (
|
635
|
-
if (
|
625
|
+
_insertRelations(e, t, s, r) {
|
626
|
+
s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(r, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((i) => this.getStoryReference(r, i)).filter(Boolean)));
|
627
|
+
}
|
628
|
+
iterateTree(e, t, s) {
|
629
|
+
const r = (i) => {
|
630
|
+
if (i != null) {
|
631
|
+
if (i.constructor === Array)
|
632
|
+
for (let n = 0; n < i.length; n++)
|
633
|
+
r(i[n]);
|
634
|
+
else if (i.constructor === Object) {
|
635
|
+
if (i._stopResolving)
|
636
636
|
return;
|
637
|
-
for (const n in
|
638
|
-
(
|
639
|
-
|
637
|
+
for (const n in i)
|
638
|
+
(i.component && i._uid || i.type === "link") && (this._insertRelations(
|
639
|
+
i,
|
640
640
|
n,
|
641
641
|
t,
|
642
|
-
|
642
|
+
s
|
643
643
|
), this._insertLinks(
|
644
|
-
|
644
|
+
i,
|
645
645
|
n,
|
646
|
-
|
647
|
-
)),
|
646
|
+
s
|
647
|
+
)), r(i[n]);
|
648
648
|
}
|
649
649
|
}
|
650
650
|
};
|
651
|
-
|
651
|
+
r(e.content);
|
652
652
|
}
|
653
|
-
async resolveLinks(e, t,
|
654
|
-
let
|
653
|
+
async resolveLinks(e, t, s) {
|
654
|
+
let r = [];
|
655
655
|
if (e.link_uuids) {
|
656
|
-
const
|
657
|
-
for (let a = 0; a <
|
658
|
-
const l = Math.min(
|
656
|
+
const i = e.link_uuids.length, n = [], c = 50;
|
657
|
+
for (let a = 0; a < i; a += c) {
|
658
|
+
const l = Math.min(i, a + c);
|
659
659
|
n.push(e.link_uuids.slice(a, l));
|
660
660
|
}
|
661
661
|
for (let a = 0; a < n.length; a++)
|
@@ -666,24 +666,24 @@ class he {
|
|
666
666
|
by_uuids: n[a].join(",")
|
667
667
|
})).data.stories.forEach(
|
668
668
|
(l) => {
|
669
|
-
|
669
|
+
r.push(l);
|
670
670
|
}
|
671
671
|
);
|
672
672
|
} else
|
673
|
-
|
674
|
-
|
675
|
-
this.links[
|
676
|
-
...
|
673
|
+
r = e.links;
|
674
|
+
r.forEach((i) => {
|
675
|
+
this.links[s][i.uuid] = {
|
676
|
+
...i,
|
677
677
|
_stopResolving: !0
|
678
678
|
};
|
679
679
|
});
|
680
680
|
}
|
681
|
-
async resolveRelations(e, t,
|
682
|
-
let
|
681
|
+
async resolveRelations(e, t, s) {
|
682
|
+
let r = [];
|
683
683
|
if (e.rel_uuids) {
|
684
|
-
const
|
685
|
-
for (let a = 0; a <
|
686
|
-
const l = Math.min(
|
684
|
+
const i = e.rel_uuids.length, n = [], c = 50;
|
685
|
+
for (let a = 0; a < i; a += c) {
|
686
|
+
const l = Math.min(i, a + c);
|
687
687
|
n.push(e.rel_uuids.slice(a, l));
|
688
688
|
}
|
689
689
|
for (let a = 0; a < n.length; a++)
|
@@ -694,13 +694,13 @@ class he {
|
|
694
694
|
by_uuids: n[a].join(","),
|
695
695
|
excluding_fields: t.excluding_fields
|
696
696
|
})).data.stories.forEach((l) => {
|
697
|
-
|
697
|
+
r.push(l);
|
698
698
|
});
|
699
699
|
} else
|
700
|
-
|
701
|
-
|
702
|
-
this.relations[
|
703
|
-
...
|
700
|
+
r = e.rels;
|
701
|
+
r && r.length > 0 && r.forEach((i) => {
|
702
|
+
this.relations[s][i.uuid] = {
|
703
|
+
...i,
|
704
704
|
_stopResolving: !0
|
705
705
|
};
|
706
706
|
});
|
@@ -714,25 +714,25 @@ class he {
|
|
714
714
|
* @returns Promise<void>
|
715
715
|
*
|
716
716
|
*/
|
717
|
-
async resolveStories(e, t,
|
718
|
-
var
|
717
|
+
async resolveStories(e, t, s) {
|
718
|
+
var r, i;
|
719
719
|
let n = [];
|
720
|
-
if (this.links[
|
721
|
-
for (const c in this.relations[
|
720
|
+
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"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (i = e.link_uuids) != null && i.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
721
|
+
for (const c in this.relations[s])
|
722
722
|
this.iterateTree(
|
723
|
-
this.relations[
|
723
|
+
this.relations[s][c],
|
724
724
|
n,
|
725
|
-
|
725
|
+
s
|
726
726
|
);
|
727
|
-
e.story ? this.iterateTree(e.story, n,
|
728
|
-
this.iterateTree(c, n,
|
729
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
727
|
+
e.story ? this.iterateTree(e.story, n, s) : e.stories.forEach((c) => {
|
728
|
+
this.iterateTree(c, n, s);
|
729
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
730
730
|
}
|
731
|
-
async cacheResponse(e, t,
|
732
|
-
(typeof
|
733
|
-
const
|
731
|
+
async cacheResponse(e, t, s) {
|
732
|
+
(typeof s > "u" || !s) && (s = 0);
|
733
|
+
const r = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
734
734
|
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
735
|
-
const n = await
|
735
|
+
const n = await i.get(r);
|
736
736
|
if (n)
|
737
737
|
return Promise.resolve(n);
|
738
738
|
}
|
@@ -740,8 +740,8 @@ class he {
|
|
740
740
|
var a;
|
741
741
|
try {
|
742
742
|
const l = await this.throttle("get", e, t);
|
743
|
-
if (l.status === 429 && (
|
744
|
-
return console.log(`Hit rate limit. Retrying in ${
|
743
|
+
if (l.status === 429 && (s = s ? s + 1 : 0, s < this.maxRetries))
|
744
|
+
return console.log(`Hit rate limit. Retrying in ${s} seconds.`), await this.helpers.delay(1e3 * s), this.cacheResponse(e, t, s).then(n).catch(c);
|
745
745
|
if (l.status !== 200)
|
746
746
|
return c(l);
|
747
747
|
let u = { data: l.data, headers: l.headers };
|
@@ -749,42 +749,42 @@ class he {
|
|
749
749
|
perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
|
750
750
|
total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
|
751
751
|
})), u.data.story || u.data.stories) {
|
752
|
-
const
|
753
|
-
await this.resolveStories(u.data, t, `${
|
752
|
+
const p = this.resolveCounter = ++this.resolveCounter % 1e3;
|
753
|
+
await this.resolveStories(u.data, t, `${p}`);
|
754
754
|
}
|
755
|
-
return t.version === "published" && e != "/cdn/spaces/me" && await
|
755
|
+
return t.version === "published" && e != "/cdn/spaces/me" && await i.set(r, u), u.data.cv && t.token && (t.version === "draft" && m[t.token] != u.data.cv && await this.flushCache(), m[t.token] = t.cv ? t.cv : u.data.cv), n(u);
|
756
756
|
} catch (l) {
|
757
757
|
c(l);
|
758
758
|
}
|
759
759
|
});
|
760
760
|
}
|
761
|
-
throttledRequest(e, t,
|
762
|
-
return this.client[e](t,
|
761
|
+
throttledRequest(e, t, s) {
|
762
|
+
return this.client[e](t, s);
|
763
763
|
}
|
764
764
|
cacheVersions() {
|
765
|
-
return
|
765
|
+
return m;
|
766
766
|
}
|
767
767
|
cacheVersion() {
|
768
|
-
return
|
768
|
+
return m[this.accessToken];
|
769
769
|
}
|
770
770
|
setCacheVersion(e) {
|
771
|
-
this.accessToken && (
|
771
|
+
this.accessToken && (m[this.accessToken] = e);
|
772
772
|
}
|
773
773
|
cacheProvider() {
|
774
774
|
switch (this.cache.type) {
|
775
775
|
case "memory":
|
776
776
|
return {
|
777
777
|
get(e) {
|
778
|
-
return Promise.resolve(
|
778
|
+
return Promise.resolve(y[e]);
|
779
779
|
},
|
780
780
|
getAll() {
|
781
|
-
return Promise.resolve(
|
781
|
+
return Promise.resolve(y);
|
782
782
|
},
|
783
783
|
set(e, t) {
|
784
|
-
return
|
784
|
+
return y[e] = t, Promise.resolve(void 0);
|
785
785
|
},
|
786
786
|
flush() {
|
787
|
-
return
|
787
|
+
return y = {}, Promise.resolve(void 0);
|
788
788
|
}
|
789
789
|
};
|
790
790
|
case "custom":
|
@@ -811,8 +811,8 @@ class he {
|
|
811
811
|
return await this.cacheProvider().flush(), this;
|
812
812
|
}
|
813
813
|
}
|
814
|
-
const
|
815
|
-
const { apiOptions: e } =
|
814
|
+
const pe = (o = {}) => {
|
815
|
+
const { apiOptions: e } = o;
|
816
816
|
if (!e.accessToken) {
|
817
817
|
console.error(
|
818
818
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
@@ -820,12 +820,12 @@ const de = (i = {}) => {
|
|
820
820
|
return;
|
821
821
|
}
|
822
822
|
return { storyblokApi: new he(e) };
|
823
|
-
},
|
824
|
-
if (typeof
|
823
|
+
}, de = (o) => {
|
824
|
+
if (typeof o != "object" || typeof o._editable > "u")
|
825
825
|
return {};
|
826
826
|
try {
|
827
827
|
const e = JSON.parse(
|
828
|
-
|
828
|
+
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
829
829
|
);
|
830
830
|
return e ? {
|
831
831
|
"data-blok-c": JSON.stringify(e),
|
@@ -835,69 +835,69 @@ const de = (i = {}) => {
|
|
835
835
|
return {};
|
836
836
|
}
|
837
837
|
};
|
838
|
-
let
|
839
|
-
const
|
838
|
+
let R, $ = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
839
|
+
const ge = (o, e, t = {}) => {
|
840
840
|
var c;
|
841
|
-
const
|
841
|
+
const r = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((c = window.location) == null ? void 0 : c.href).searchParams.get(
|
842
842
|
"_storyblok"
|
843
|
-
) ===
|
844
|
-
if (!(!
|
845
|
-
if (!
|
843
|
+
) === o;
|
844
|
+
if (!(!r || !n)) {
|
845
|
+
if (!o) {
|
846
846
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
847
847
|
return;
|
848
848
|
}
|
849
849
|
window.storyblokRegisterEvent(() => {
|
850
850
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (l) => {
|
851
|
-
l.action === "input" && l.story.id ===
|
851
|
+
l.action === "input" && l.story.id === o ? e(l.story) : (l.action === "change" || l.action === "published") && l.storyId === o && window.location.reload();
|
852
852
|
});
|
853
853
|
});
|
854
854
|
}
|
855
|
-
},
|
856
|
-
var
|
855
|
+
}, fe = (o = {}) => {
|
856
|
+
var p, g;
|
857
857
|
const {
|
858
858
|
bridge: e,
|
859
859
|
accessToken: t,
|
860
|
-
use:
|
861
|
-
apiOptions:
|
862
|
-
richText:
|
860
|
+
use: s = [],
|
861
|
+
apiOptions: r = {},
|
862
|
+
richText: i = {},
|
863
863
|
bridgeUrl: n
|
864
|
-
} =
|
865
|
-
|
866
|
-
const c = { bridge: e, apiOptions:
|
864
|
+
} = o;
|
865
|
+
r.accessToken = r.accessToken || t;
|
866
|
+
const c = { bridge: e, apiOptions: r };
|
867
867
|
let a = {};
|
868
|
-
|
869
|
-
a = { ...a, ...
|
870
|
-
}), n && (
|
871
|
-
const u = !(typeof window > "u") && ((
|
872
|
-
return e !== !1 && u &&
|
873
|
-
},
|
874
|
-
|
875
|
-
let
|
876
|
-
return t.attrs.body.forEach((
|
877
|
-
|
868
|
+
s.forEach((f) => {
|
869
|
+
a = { ...a, ...f(c) };
|
870
|
+
}), n && ($ = n);
|
871
|
+
const u = !(typeof window > "u") && ((g = (p = window.location) == null ? void 0 : p.search) == null ? void 0 : g.includes("_storyblok_tk"));
|
872
|
+
return e !== !1 && u && O($), R = new k(i.schema), i.resolver && E(R, i.resolver), a;
|
873
|
+
}, E = (o, e) => {
|
874
|
+
o.addNode("blok", (t) => {
|
875
|
+
let s = "";
|
876
|
+
return t.attrs.body.forEach((r) => {
|
877
|
+
s += e(r.component, r);
|
878
878
|
}), {
|
879
|
-
html:
|
879
|
+
html: s
|
880
880
|
};
|
881
881
|
});
|
882
|
-
}, ue = (
|
883
|
-
let
|
884
|
-
if (!
|
882
|
+
}, ue = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), me = (o, e, t) => {
|
883
|
+
let s = t || R;
|
884
|
+
if (!s) {
|
885
885
|
console.error(
|
886
886
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
887
887
|
);
|
888
888
|
return;
|
889
889
|
}
|
890
|
-
return ue(
|
891
|
-
},
|
890
|
+
return ue(o) ? "" : (e && (s = new k(e.schema), e.resolver && E(s, e.resolver)), s.render(o));
|
891
|
+
}, ye = () => O($);
|
892
892
|
export {
|
893
|
-
|
894
|
-
|
895
|
-
|
893
|
+
k as RichTextResolver,
|
894
|
+
oe as RichTextSchema,
|
895
|
+
pe as apiPlugin,
|
896
896
|
ue as isRichTextEmpty,
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
897
|
+
ye as loadStoryblokBridge,
|
898
|
+
ge as registerStoryblokBridge,
|
899
|
+
me as renderRichText,
|
900
|
+
de as storyblokEditable,
|
901
|
+
fe as storyblokInit,
|
902
|
+
ge as useStoryblokBridge
|
903
903
|
};
|