@storyblok/vue 8.1.4 → 8.1.5
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-vue.js +3 -3
- package/dist/storyblok-vue.mjs +523 -475
- package/package.json +11 -11
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as K, ref as C, resolveDynamicComponent as N, inject as ne, openBlock as J, createBlock as Y, mergeProps as ie, h as X, createTextVNode as ae, watch as le, onMounted as ce, defineAsyncComponent as he } from "vue";
|
|
2
|
+
let D = !1;
|
|
3
|
+
const z = [], ue = (r) => new Promise((e, t) => {
|
|
4
4
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (o) => {
|
|
5
5
|
if (window.location === window.parent.location) {
|
|
6
6
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
D ? o() : z.push(o);
|
|
10
10
|
}, document.getElementById("storyblok-javascript-bridge"))) return;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
11
|
+
const s = document.createElement("script");
|
|
12
|
+
s.async = !0, s.src = r, s.id = "storyblok-javascript-bridge", s.onerror = (o) => t(o), s.onload = (o) => {
|
|
13
|
+
z.forEach((n) => n()), D = !0, e(o);
|
|
14
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
15
15
|
});
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
return !(
|
|
16
|
+
var pe = Object.defineProperty, de = (r, e, t) => e in r ? pe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e, t) => de(r, typeof e != "symbol" ? e + "" : e, t);
|
|
17
|
+
function B(r) {
|
|
18
|
+
return !(r !== r || r === 1 / 0 || r === -1 / 0);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
if (!
|
|
20
|
+
function ge(r, e, t) {
|
|
21
|
+
if (!B(e))
|
|
22
22
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
-
if (!
|
|
23
|
+
if (!B(t))
|
|
24
24
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
|
-
const
|
|
25
|
+
const s = [];
|
|
26
26
|
let o = [], n = 0;
|
|
27
27
|
const i = function() {
|
|
28
28
|
n++;
|
|
29
29
|
const a = setTimeout(function() {
|
|
30
|
-
n--,
|
|
31
|
-
return
|
|
30
|
+
n--, s.length > 0 && i(), o = o.filter(function(u) {
|
|
31
|
+
return u !== a;
|
|
32
32
|
});
|
|
33
33
|
}, t);
|
|
34
34
|
o.indexOf(a) < 0 && o.push(a);
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const h = s.shift();
|
|
36
|
+
h.resolve(r.apply(h.self, h.args));
|
|
37
37
|
}, l = function(...a) {
|
|
38
|
-
const
|
|
39
|
-
return new Promise(function(
|
|
40
|
-
|
|
41
|
-
resolve:
|
|
42
|
-
reject:
|
|
38
|
+
const h = this;
|
|
39
|
+
return new Promise(function(u, d) {
|
|
40
|
+
s.push({
|
|
41
|
+
resolve: u,
|
|
42
|
+
reject: d,
|
|
43
43
|
args: a,
|
|
44
|
-
self:
|
|
44
|
+
self: h
|
|
45
45
|
}), n < e && i();
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
return l.abort = function() {
|
|
49
|
-
o.forEach(clearTimeout), o = [],
|
|
49
|
+
o.forEach(clearTimeout), o = [], 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
|
}, l;
|
|
55
55
|
}
|
|
56
|
-
class
|
|
56
|
+
let A = class {
|
|
57
57
|
constructor() {
|
|
58
|
-
|
|
59
|
-
...
|
|
60
|
-
per_page:
|
|
61
|
-
page:
|
|
62
|
-
})),
|
|
63
|
-
const
|
|
64
|
-
return this.arrayFrom(
|
|
65
|
-
}),
|
|
66
|
-
const
|
|
58
|
+
p(this, "isCDNUrl", (r = "") => r.indexOf("/cdn/") > -1), p(this, "getOptionsPage", (r, e = 25, t = 1) => ({
|
|
59
|
+
...r,
|
|
60
|
+
per_page: e,
|
|
61
|
+
page: t
|
|
62
|
+
})), p(this, "delay", (r) => new Promise((e) => setTimeout(e, r))), p(this, "arrayFrom", (r = 0, e) => [...Array(r)].map(e)), p(this, "range", (r = 0, e = r) => {
|
|
63
|
+
const t = Math.abs(e - r) || 0, s = r < e ? 1 : -1;
|
|
64
|
+
return this.arrayFrom(t, (o, n) => n * s + r);
|
|
65
|
+
}), p(this, "asyncMap", async (r, e) => Promise.all(r.map(e))), p(this, "flatMap", (r = [], e) => r.map(e).reduce((t, s) => [...t, ...s], [])), p(this, "escapeHTML", function(r) {
|
|
66
|
+
const e = {
|
|
67
67
|
"&": "&",
|
|
68
68
|
"<": "<",
|
|
69
69
|
">": ">",
|
|
70
70
|
'"': """,
|
|
71
71
|
"'": "'"
|
|
72
|
-
},
|
|
73
|
-
return
|
|
72
|
+
}, t = /[&<>"']/g, s = RegExp(t.source);
|
|
73
|
+
return r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -80,110 +80,110 @@ class j {
|
|
|
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(
|
|
83
|
+
stringify(r, e, t) {
|
|
84
|
+
const s = [];
|
|
85
|
+
for (const o in r) {
|
|
86
|
+
if (!Object.prototype.hasOwnProperty.call(r, o))
|
|
87
87
|
continue;
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
typeof
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Array.isArray(
|
|
94
|
-
) :
|
|
88
|
+
const n = r[o], i = t ? "" : encodeURIComponent(o);
|
|
89
|
+
let l;
|
|
90
|
+
typeof n == "object" ? l = this.stringify(
|
|
91
|
+
n,
|
|
92
|
+
e ? e + encodeURIComponent("[" + i + "]") : i,
|
|
93
|
+
Array.isArray(n)
|
|
94
|
+
) : l = (e ? e + encodeURIComponent("[" + i + "]") : i) + "=" + encodeURIComponent(n), s.push(l);
|
|
95
95
|
}
|
|
96
|
-
return
|
|
96
|
+
return s.join("&");
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* @method getRegionURL
|
|
100
100
|
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
101
101
|
* @return {String} The base URL of the region
|
|
102
102
|
*/
|
|
103
|
-
getRegionURL(
|
|
104
|
-
const
|
|
105
|
-
switch (
|
|
103
|
+
getRegionURL(r) {
|
|
104
|
+
const e = "api.storyblok.com", t = "api-us.storyblok.com", s = "app.storyblokchina.cn", o = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
105
|
+
switch (r) {
|
|
106
106
|
case "us":
|
|
107
|
-
return
|
|
107
|
+
return t;
|
|
108
108
|
case "cn":
|
|
109
|
-
return
|
|
109
|
+
return s;
|
|
110
110
|
case "ap":
|
|
111
|
-
return
|
|
111
|
+
return o;
|
|
112
112
|
case "ca":
|
|
113
|
-
return
|
|
113
|
+
return n;
|
|
114
114
|
default:
|
|
115
|
-
return
|
|
115
|
+
return e;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
}
|
|
119
|
-
const
|
|
118
|
+
};
|
|
119
|
+
const me = function(r, e) {
|
|
120
120
|
const t = {};
|
|
121
|
-
for (const
|
|
122
|
-
const o = s
|
|
123
|
-
e.indexOf(
|
|
121
|
+
for (const s in r) {
|
|
122
|
+
const o = r[s];
|
|
123
|
+
e.indexOf(s) > -1 && o !== null && (t[s] = o);
|
|
124
124
|
}
|
|
125
125
|
return t;
|
|
126
|
-
},
|
|
126
|
+
}, fe = (r) => r === "email", ye = () => ({
|
|
127
127
|
singleTag: "hr"
|
|
128
|
-
}),
|
|
128
|
+
}), be = () => ({
|
|
129
129
|
tag: "blockquote"
|
|
130
|
-
}),
|
|
130
|
+
}), ke = () => ({
|
|
131
131
|
tag: "ul"
|
|
132
|
-
}),
|
|
132
|
+
}), ve = (r) => ({
|
|
133
133
|
tag: [
|
|
134
134
|
"pre",
|
|
135
135
|
{
|
|
136
136
|
tag: "code",
|
|
137
|
-
attrs:
|
|
137
|
+
attrs: r.attrs
|
|
138
138
|
}
|
|
139
139
|
]
|
|
140
|
-
}),
|
|
140
|
+
}), $e = () => ({
|
|
141
141
|
singleTag: "br"
|
|
142
|
-
}),
|
|
143
|
-
tag: `h${
|
|
144
|
-
}),
|
|
142
|
+
}), Te = (r) => ({
|
|
143
|
+
tag: `h${r.attrs.level}`
|
|
144
|
+
}), Re = (r) => ({
|
|
145
145
|
singleTag: [
|
|
146
146
|
{
|
|
147
147
|
tag: "img",
|
|
148
|
-
attrs:
|
|
148
|
+
attrs: me(r.attrs, ["src", "alt", "title"])
|
|
149
149
|
}
|
|
150
150
|
]
|
|
151
|
-
}),
|
|
151
|
+
}), we = () => ({
|
|
152
152
|
tag: "li"
|
|
153
|
-
}),
|
|
153
|
+
}), Se = () => ({
|
|
154
154
|
tag: "ol"
|
|
155
|
-
}),
|
|
155
|
+
}), _e = () => ({
|
|
156
156
|
tag: "p"
|
|
157
|
-
}),
|
|
157
|
+
}), Ee = (r) => ({
|
|
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": r.attrs.name,
|
|
164
|
+
emoji: r.attrs.emoji
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
]
|
|
168
|
-
}),
|
|
168
|
+
}), xe = () => ({
|
|
169
169
|
tag: "b"
|
|
170
|
-
}),
|
|
170
|
+
}), je = () => ({
|
|
171
171
|
tag: "s"
|
|
172
|
-
}),
|
|
172
|
+
}), Ie = () => ({
|
|
173
173
|
tag: "u"
|
|
174
|
-
}),
|
|
174
|
+
}), Oe = () => ({
|
|
175
175
|
tag: "strong"
|
|
176
|
-
}),
|
|
176
|
+
}), Ce = () => ({
|
|
177
177
|
tag: "code"
|
|
178
|
-
}),
|
|
178
|
+
}), Ae = () => ({
|
|
179
179
|
tag: "i"
|
|
180
|
-
}),
|
|
181
|
-
if (!
|
|
180
|
+
}), Le = (r) => {
|
|
181
|
+
if (!r.attrs)
|
|
182
182
|
return {
|
|
183
183
|
tag: ""
|
|
184
184
|
};
|
|
185
|
-
const e = new
|
|
186
|
-
if (delete t.linktype, t.href && (t.href = e(
|
|
185
|
+
const e = new A().escapeHTML, t = { ...r.attrs }, { linktype: s = "url" } = r.attrs;
|
|
186
|
+
if (delete t.linktype, t.href && (t.href = e(r.attrs.href || "")), fe(s) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), t.custom) {
|
|
187
187
|
for (const o in t.custom)
|
|
188
188
|
t[o] = t.custom[o];
|
|
189
189
|
delete t.custom;
|
|
@@ -196,95 +196,95 @@ const he = function(s, e) {
|
|
|
196
196
|
}
|
|
197
197
|
]
|
|
198
198
|
};
|
|
199
|
-
},
|
|
199
|
+
}, Pe = (r) => ({
|
|
200
200
|
tag: [
|
|
201
201
|
{
|
|
202
202
|
tag: "span",
|
|
203
|
-
attrs:
|
|
203
|
+
attrs: r.attrs
|
|
204
204
|
}
|
|
205
205
|
]
|
|
206
|
-
}),
|
|
206
|
+
}), Ne = () => ({
|
|
207
207
|
tag: "sub"
|
|
208
|
-
}),
|
|
208
|
+
}), Me = () => ({
|
|
209
209
|
tag: "sup"
|
|
210
|
-
}),
|
|
210
|
+
}), He = (r) => ({
|
|
211
211
|
tag: [
|
|
212
212
|
{
|
|
213
213
|
tag: "span",
|
|
214
|
-
attrs:
|
|
214
|
+
attrs: r.attrs
|
|
215
215
|
}
|
|
216
216
|
]
|
|
217
|
-
}),
|
|
217
|
+
}), Ue = (r) => {
|
|
218
218
|
var e;
|
|
219
|
-
return (e =
|
|
219
|
+
return (e = r.attrs) != null && e.color ? {
|
|
220
220
|
tag: [
|
|
221
221
|
{
|
|
222
222
|
tag: "span",
|
|
223
223
|
attrs: {
|
|
224
|
-
style: `background-color:${
|
|
224
|
+
style: `background-color:${r.attrs.color};`
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
]
|
|
228
228
|
} : {
|
|
229
229
|
tag: ""
|
|
230
230
|
};
|
|
231
|
-
},
|
|
231
|
+
}, De = (r) => {
|
|
232
232
|
var e;
|
|
233
|
-
return (e =
|
|
233
|
+
return (e = r.attrs) != null && e.color ? {
|
|
234
234
|
tag: [
|
|
235
235
|
{
|
|
236
236
|
tag: "span",
|
|
237
237
|
attrs: {
|
|
238
|
-
style: `color:${
|
|
238
|
+
style: `color:${r.attrs.color}`
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
]
|
|
242
242
|
} : {
|
|
243
243
|
tag: ""
|
|
244
244
|
};
|
|
245
|
-
},
|
|
245
|
+
}, ze = {
|
|
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: ye,
|
|
248
|
+
blockquote: be,
|
|
249
|
+
bullet_list: ke,
|
|
250
|
+
code_block: ve,
|
|
251
|
+
hard_break: $e,
|
|
252
|
+
heading: Te,
|
|
253
|
+
image: Re,
|
|
254
|
+
list_item: we,
|
|
255
|
+
ordered_list: Se,
|
|
256
|
+
paragraph: _e,
|
|
257
|
+
emoji: Ee
|
|
258
258
|
},
|
|
259
259
|
marks: {
|
|
260
|
-
bold:
|
|
261
|
-
strike:
|
|
262
|
-
underline:
|
|
263
|
-
strong:
|
|
264
|
-
code:
|
|
265
|
-
italic:
|
|
266
|
-
link:
|
|
267
|
-
styled:
|
|
268
|
-
subscript:
|
|
269
|
-
superscript:
|
|
270
|
-
anchor:
|
|
271
|
-
highlight:
|
|
272
|
-
textStyle:
|
|
273
|
-
}
|
|
274
|
-
},
|
|
260
|
+
bold: xe,
|
|
261
|
+
strike: je,
|
|
262
|
+
underline: Ie,
|
|
263
|
+
strong: Oe,
|
|
264
|
+
code: Ce,
|
|
265
|
+
italic: Ae,
|
|
266
|
+
link: Le,
|
|
267
|
+
styled: Pe,
|
|
268
|
+
subscript: Ne,
|
|
269
|
+
superscript: Me,
|
|
270
|
+
anchor: He,
|
|
271
|
+
highlight: Ue,
|
|
272
|
+
textStyle: De
|
|
273
|
+
}
|
|
274
|
+
}, Be = function(r) {
|
|
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 r && s.test(r) ? r.replace(t, (o) => e[o]) : r;
|
|
283
283
|
};
|
|
284
|
-
let
|
|
285
|
-
class
|
|
284
|
+
let q = !1;
|
|
285
|
+
class qe {
|
|
286
286
|
constructor(e) {
|
|
287
|
-
|
|
287
|
+
p(this, "marks"), p(this, "nodes"), e || (e = ze), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
288
288
|
}
|
|
289
289
|
addNode(e, t) {
|
|
290
290
|
this.nodes[e] = t;
|
|
@@ -292,10 +292,10 @@ class He {
|
|
|
292
292
|
addMark(e, t) {
|
|
293
293
|
this.marks[e] = t;
|
|
294
294
|
}
|
|
295
|
-
render(e, t = { optimizeImages: !1 },
|
|
296
|
-
if (!
|
|
295
|
+
render(e, t = { optimizeImages: !1 }, s = !0) {
|
|
296
|
+
if (!q && s && (console.warn(
|
|
297
297
|
"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/"
|
|
298
|
-
),
|
|
298
|
+
), q = !0), e && e.content && Array.isArray(e.content)) {
|
|
299
299
|
let o = "";
|
|
300
300
|
return e.content.forEach((n) => {
|
|
301
301
|
o += this.renderNode(n);
|
|
@@ -329,31 +329,31 @@ class He {
|
|
|
329
329
|
), "";
|
|
330
330
|
}
|
|
331
331
|
optimizeImages(e, t) {
|
|
332
|
-
let
|
|
333
|
-
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `,
|
|
334
|
-
const l =
|
|
332
|
+
let s = 0, o = 0, n = "", i = "";
|
|
333
|
+
typeof t != "boolean" && (typeof t.width == "number" && t.width > 0 && (n += `width="${t.width}" `, s = t.width), typeof t.height == "number" && t.height > 0 && (n += `height="${t.height}" `, o = t.height), (t.loading === "lazy" || t.loading === "eager") && (n += `loading="${t.loading}" `), typeof t.class == "string" && t.class.length > 0 && (n += `class="${t.class}" `), t.filters && (typeof t.filters.blur == "number" && t.filters.blur >= 0 && t.filters.blur <= 100 && (i += `:blur(${t.filters.blur})`), typeof t.filters.brightness == "number" && t.filters.brightness >= -100 && t.filters.brightness <= 100 && (i += `:brightness(${t.filters.brightness})`), t.filters.fill && (t.filters.fill.match(/[0-9A-Fa-f]{6}/g) || t.filters.fill === "transparent") && (i += `:fill(${t.filters.fill})`), t.filters.format && ["webp", "png", "jpeg"].includes(t.filters.format) && (i += `:format(${t.filters.format})`), typeof t.filters.grayscale == "boolean" && t.filters.grayscale && (i += ":grayscale()"), typeof t.filters.quality == "number" && t.filters.quality >= 0 && t.filters.quality <= 100 && (i += `:quality(${t.filters.quality})`), t.filters.rotate && [90, 180, 270].includes(t.filters.rotate) && (i += `:rotate(${t.filters.rotate})`), i.length > 0 && (i = "/filters" + i))), n.length > 0 && (e = e.replace(/<img/g, `<img ${n.trim()}`));
|
|
334
|
+
const l = s > 0 || o > 0 || i.length > 0 ? `${s}x${o}${i}` : "";
|
|
335
335
|
return e = e.replace(
|
|
336
336
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
337
337
|
`a.storyblok.com/f/$1/$2.$3/m/${l}`
|
|
338
338
|
), typeof t != "boolean" && (t.sizes || t.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (a) => {
|
|
339
|
-
var
|
|
340
|
-
const
|
|
339
|
+
var h, u;
|
|
340
|
+
const d = a.match(
|
|
341
341
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
342
342
|
);
|
|
343
|
-
if (
|
|
344
|
-
const
|
|
345
|
-
srcset: (
|
|
343
|
+
if (d && d.length > 0) {
|
|
344
|
+
const g = {
|
|
345
|
+
srcset: (h = t.srcset) == null ? void 0 : h.map((y) => {
|
|
346
346
|
if (typeof y == "number")
|
|
347
|
-
return `//${
|
|
347
|
+
return `//${d}/m/${y}x0${i} ${y}w`;
|
|
348
348
|
if (typeof y == "object" && y.length === 2) {
|
|
349
|
-
let w = 0,
|
|
350
|
-
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (
|
|
349
|
+
let w = 0, I = 0;
|
|
350
|
+
return typeof y[0] == "number" && (w = y[0]), typeof y[1] == "number" && (I = y[1]), `//${d}/m/${w}x${I}${i} ${w}w`;
|
|
351
351
|
}
|
|
352
352
|
}).join(", "),
|
|
353
|
-
sizes: (
|
|
353
|
+
sizes: (u = t.sizes) == null ? void 0 : u.map((y) => y).join(", ")
|
|
354
354
|
};
|
|
355
355
|
let $ = "";
|
|
356
|
-
return
|
|
356
|
+
return g.srcset && ($ += `srcset="${g.srcset}" `), g.sizes && ($ += `sizes="${g.sizes}" `), a.replace(/<img/g, `<img ${$.trim()}`);
|
|
357
357
|
}
|
|
358
358
|
return a;
|
|
359
359
|
})), e;
|
|
@@ -364,24 +364,24 @@ class He {
|
|
|
364
364
|
const n = this.getMatchingMark(o);
|
|
365
365
|
n && n.tag !== "" && t.push(this.renderOpeningTag(n.tag));
|
|
366
366
|
});
|
|
367
|
-
const
|
|
368
|
-
return
|
|
367
|
+
const s = this.getMatchingNode(e);
|
|
368
|
+
return s && s.tag && t.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((o) => {
|
|
369
369
|
t.push(this.renderNode(o));
|
|
370
|
-
}) : e.text ? t.push(
|
|
370
|
+
}) : e.text ? t.push(Be(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((o) => {
|
|
371
371
|
const n = this.getMatchingMark(o);
|
|
372
372
|
n && n.tag !== "" && t.push(this.renderClosingTag(n.tag));
|
|
373
373
|
}), t.join("");
|
|
374
374
|
}
|
|
375
375
|
renderTag(e, t) {
|
|
376
|
-
return e.constructor === String ? `<${e}${t}>` : e.map((
|
|
377
|
-
if (
|
|
378
|
-
return `<${
|
|
376
|
+
return e.constructor === String ? `<${e}${t}>` : e.map((s) => {
|
|
377
|
+
if (s.constructor === String)
|
|
378
|
+
return `<${s}${t}>`;
|
|
379
379
|
{
|
|
380
|
-
let o = `<${
|
|
381
|
-
if (
|
|
382
|
-
for (const n in
|
|
383
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
384
|
-
const i =
|
|
380
|
+
let o = `<${s.tag}`;
|
|
381
|
+
if (s.attrs) {
|
|
382
|
+
for (const n in s.attrs)
|
|
383
|
+
if (Object.prototype.hasOwnProperty.call(s.attrs, n)) {
|
|
384
|
+
const i = s.attrs[n];
|
|
385
385
|
i !== null && (o += ` ${n}="${i}"`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
@@ -422,10 +422,10 @@ class He {
|
|
|
422
422
|
return this.renderTag(t, " /");
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
const
|
|
426
|
-
class
|
|
425
|
+
const L = qe;
|
|
426
|
+
class Ve {
|
|
427
427
|
constructor(e) {
|
|
428
|
-
|
|
428
|
+
p(this, "baseURL"), p(this, "timeout"), p(this, "headers"), p(this, "responseInterceptor"), p(this, "fetch"), p(this, "ejectInterceptor"), p(this, "url"), p(this, "parameters"), p(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 = {};
|
|
429
429
|
}
|
|
430
430
|
/**
|
|
431
431
|
*
|
|
@@ -446,28 +446,28 @@ class Ue {
|
|
|
446
446
|
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
447
447
|
}
|
|
448
448
|
async _responseHandler(e) {
|
|
449
|
-
const t = [],
|
|
449
|
+
const t = [], s = {
|
|
450
450
|
data: {},
|
|
451
451
|
headers: {},
|
|
452
452
|
status: 0,
|
|
453
453
|
statusText: ""
|
|
454
454
|
};
|
|
455
455
|
e.status !== 204 && await e.json().then((o) => {
|
|
456
|
-
|
|
456
|
+
s.data = o;
|
|
457
457
|
});
|
|
458
458
|
for (const o of e.headers.entries())
|
|
459
459
|
t[o[0]] = o[1];
|
|
460
|
-
return
|
|
460
|
+
return s.headers = { ...t }, s.status = e.status, s.statusText = e.statusText, s;
|
|
461
461
|
}
|
|
462
462
|
async _methodHandler(e) {
|
|
463
|
-
let t = `${this.baseURL}${this.url}`,
|
|
463
|
+
let t = `${this.baseURL}${this.url}`, s = null;
|
|
464
464
|
if (e === "get") {
|
|
465
|
-
const a = new
|
|
465
|
+
const a = new A();
|
|
466
466
|
t = `${this.baseURL}${this.url}?${a.stringify(
|
|
467
467
|
this.parameters
|
|
468
468
|
)}`;
|
|
469
469
|
} else
|
|
470
|
-
|
|
470
|
+
s = JSON.stringify(this.parameters);
|
|
471
471
|
const o = new URL(t), n = new AbortController(), { signal: i } = n;
|
|
472
472
|
let l;
|
|
473
473
|
this.timeout && (l = setTimeout(() => n.abort(), this.timeout));
|
|
@@ -475,15 +475,15 @@ class Ue {
|
|
|
475
475
|
const a = await this.fetch(`${o}`, {
|
|
476
476
|
method: e,
|
|
477
477
|
headers: this.headers,
|
|
478
|
-
body:
|
|
478
|
+
body: s,
|
|
479
479
|
signal: i,
|
|
480
480
|
...this.fetchOptions
|
|
481
481
|
});
|
|
482
482
|
this.timeout && clearTimeout(l);
|
|
483
|
-
const
|
|
483
|
+
const h = await this._responseHandler(
|
|
484
484
|
a
|
|
485
485
|
);
|
|
486
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(
|
|
486
|
+
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(h)) : this._statusHandler(h);
|
|
487
487
|
} catch (a) {
|
|
488
488
|
return {
|
|
489
489
|
message: a
|
|
@@ -498,9 +498,9 @@ class Ue {
|
|
|
498
498
|
}
|
|
499
499
|
_statusHandler(e) {
|
|
500
500
|
const t = /20[0-6]/g;
|
|
501
|
-
return new Promise((
|
|
501
|
+
return new Promise((s, o) => {
|
|
502
502
|
if (t.test(`${e.status}`))
|
|
503
|
-
return
|
|
503
|
+
return s(e);
|
|
504
504
|
const n = {
|
|
505
505
|
message: e.statusText,
|
|
506
506
|
status: e.status,
|
|
@@ -510,36 +510,36 @@ class Ue {
|
|
|
510
510
|
});
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
const
|
|
513
|
+
const Fe = Ve, V = "SB-Agent", M = {
|
|
514
514
|
defaultAgentName: "SB-JS-CLIENT",
|
|
515
515
|
defaultAgentVersion: "SB-Agent-Version",
|
|
516
516
|
packageVersion: "6.0.0"
|
|
517
517
|
};
|
|
518
|
-
let
|
|
519
|
-
const
|
|
520
|
-
class
|
|
518
|
+
let O = {};
|
|
519
|
+
const E = {};
|
|
520
|
+
class Ge {
|
|
521
521
|
/**
|
|
522
522
|
*
|
|
523
523
|
* @param config ISbConfig interface
|
|
524
524
|
* @param endpoint string, optional
|
|
525
525
|
*/
|
|
526
526
|
constructor(e, t) {
|
|
527
|
-
|
|
528
|
-
let
|
|
529
|
-
if (!
|
|
530
|
-
const i = new
|
|
531
|
-
e.oauthToken ?
|
|
527
|
+
p(this, "client"), p(this, "maxRetries"), p(this, "retriesDelay"), p(this, "throttle"), p(this, "accessToken"), p(this, "cache"), p(this, "helpers"), p(this, "resolveCounter"), p(this, "relations"), p(this, "links"), p(this, "richTextResolver"), p(this, "resolveNestedRelations"), p(this, "stringifiedStoriesCache");
|
|
528
|
+
let s = e.endpoint || t;
|
|
529
|
+
if (!s) {
|
|
530
|
+
const i = new A().getRegionURL, l = e.https === !1 ? "http" : "https";
|
|
531
|
+
e.oauthToken ? s = `${l}://${i(e.region)}/v1` : s = `${l}://${i(e.region)}/v2`;
|
|
532
532
|
}
|
|
533
533
|
const o = new Headers();
|
|
534
534
|
o.set("Content-Type", "application/json"), o.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([i, l]) => {
|
|
535
535
|
o.set(i, l);
|
|
536
|
-
}), o.has(
|
|
537
|
-
|
|
538
|
-
|
|
536
|
+
}), o.has(V) || (o.set(V, M.defaultAgentName), o.set(
|
|
537
|
+
M.defaultAgentVersion,
|
|
538
|
+
M.packageVersion
|
|
539
539
|
));
|
|
540
540
|
let n = 5;
|
|
541
|
-
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new
|
|
542
|
-
baseURL:
|
|
541
|
+
e.oauthToken && (o.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new L(e.richTextSchema) : this.richTextResolver = new L(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries || 10, this.retriesDelay = 300, this.throttle = ge(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new A(), this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.client = new Fe({
|
|
542
|
+
baseURL: s,
|
|
543
543
|
timeout: e.timeout || 0,
|
|
544
544
|
headers: o,
|
|
545
545
|
responseInterceptor: e.responseInterceptor,
|
|
@@ -548,65 +548,65 @@ class ze {
|
|
|
548
548
|
}
|
|
549
549
|
setComponentResolver(e) {
|
|
550
550
|
this.richTextResolver.addNode("blok", (t) => {
|
|
551
|
-
let
|
|
551
|
+
let s = "";
|
|
552
552
|
return t.attrs.body && t.attrs.body.forEach((o) => {
|
|
553
|
-
|
|
553
|
+
s += e(o.component, o);
|
|
554
554
|
}), {
|
|
555
|
-
html:
|
|
555
|
+
html: s
|
|
556
556
|
};
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
559
|
parseParams(e) {
|
|
560
|
-
return e.token || (e.token = this.getToken()), e.cv || (e.cv =
|
|
560
|
+
return e.token || (e.token = this.getToken()), e.cv || (e.cv = E[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), typeof e.resolve_relations < "u" && (e.resolve_level = 2), e;
|
|
561
561
|
}
|
|
562
562
|
factoryParamOptions(e, t) {
|
|
563
563
|
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
564
564
|
}
|
|
565
|
-
makeRequest(e, t,
|
|
565
|
+
makeRequest(e, t, s, o, n) {
|
|
566
566
|
const i = this.factoryParamOptions(
|
|
567
567
|
e,
|
|
568
|
-
this.helpers.getOptionsPage(t,
|
|
568
|
+
this.helpers.getOptionsPage(t, s, o)
|
|
569
569
|
);
|
|
570
570
|
return this.cacheResponse(e, i, void 0, n);
|
|
571
571
|
}
|
|
572
|
-
get(e, t,
|
|
572
|
+
get(e, t, s) {
|
|
573
573
|
t || (t = {});
|
|
574
574
|
const o = `/${e}`, n = this.factoryParamOptions(o, t);
|
|
575
|
-
return this.cacheResponse(o, n, void 0,
|
|
575
|
+
return this.cacheResponse(o, n, void 0, s);
|
|
576
576
|
}
|
|
577
|
-
async getAll(e, t,
|
|
578
|
-
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, l = i.split("/"), a =
|
|
577
|
+
async getAll(e, t, s, o) {
|
|
578
|
+
const n = (t == null ? void 0 : t.per_page) || 25, i = `/${e}`, l = i.split("/"), a = s || l[l.length - 1], h = 1, u = await this.makeRequest(
|
|
579
579
|
i,
|
|
580
580
|
t,
|
|
581
581
|
n,
|
|
582
|
-
|
|
582
|
+
h,
|
|
583
583
|
o
|
|
584
|
-
),
|
|
585
|
-
this.helpers.range(
|
|
584
|
+
), d = u.total ? Math.ceil(u.total / n) : 1, g = await this.helpers.asyncMap(
|
|
585
|
+
this.helpers.range(h, d),
|
|
586
586
|
($) => this.makeRequest(i, t, n, $ + 1, o)
|
|
587
587
|
);
|
|
588
588
|
return this.helpers.flatMap(
|
|
589
|
-
[
|
|
589
|
+
[u, ...g],
|
|
590
590
|
($) => Object.values($.data[a])
|
|
591
591
|
);
|
|
592
592
|
}
|
|
593
|
-
post(e, t,
|
|
593
|
+
post(e, t, s) {
|
|
594
594
|
const o = `/${e}`;
|
|
595
|
-
return Promise.resolve(this.throttle("post", o, t,
|
|
595
|
+
return Promise.resolve(this.throttle("post", o, t, s));
|
|
596
596
|
}
|
|
597
|
-
put(e, t,
|
|
597
|
+
put(e, t, s) {
|
|
598
598
|
const o = `/${e}`;
|
|
599
|
-
return Promise.resolve(this.throttle("put", o, t,
|
|
599
|
+
return Promise.resolve(this.throttle("put", o, t, s));
|
|
600
600
|
}
|
|
601
|
-
delete(e, t,
|
|
601
|
+
delete(e, t, s) {
|
|
602
602
|
const o = `/${e}`;
|
|
603
|
-
return Promise.resolve(this.throttle("delete", o, t,
|
|
603
|
+
return Promise.resolve(this.throttle("delete", o, t, s));
|
|
604
604
|
}
|
|
605
605
|
getStories(e, t) {
|
|
606
606
|
return this._addResolveLevel(e), this.get("cdn/stories", e, t);
|
|
607
607
|
}
|
|
608
|
-
getStory(e, t,
|
|
609
|
-
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t,
|
|
608
|
+
getStory(e, t, s) {
|
|
609
|
+
return this._addResolveLevel(t), this.get(`cdn/stories/${e}`, t, s);
|
|
610
610
|
}
|
|
611
611
|
getToken() {
|
|
612
612
|
return this.accessToken;
|
|
@@ -620,9 +620,9 @@ class ze {
|
|
|
620
620
|
_cleanCopy(e) {
|
|
621
621
|
return JSON.parse(JSON.stringify(e));
|
|
622
622
|
}
|
|
623
|
-
_insertLinks(e, t,
|
|
623
|
+
_insertLinks(e, t, s) {
|
|
624
624
|
const o = e[t];
|
|
625
|
-
o && o.fieldtype == "multilink" && o.linktype == "story" && typeof o.id == "string" && this.links[
|
|
625
|
+
o && o.fieldtype == "multilink" && o.linktype == "story" && typeof o.id == "string" && this.links[s][o.id] ? o.story = this._cleanCopy(this.links[s][o.id]) : o && o.linktype === "story" && typeof o.uuid == "string" && this.links[s][o.uuid] && (o.story = this._cleanCopy(this.links[s][o.uuid]));
|
|
626
626
|
}
|
|
627
627
|
/**
|
|
628
628
|
*
|
|
@@ -635,10 +635,10 @@ class ze {
|
|
|
635
635
|
this.relations[e][t]
|
|
636
636
|
)), JSON.parse(this.stringifiedStoriesCache[t])) : t;
|
|
637
637
|
}
|
|
638
|
-
_insertRelations(e, t,
|
|
639
|
-
|
|
638
|
+
_insertRelations(e, t, s, o) {
|
|
639
|
+
s.indexOf(`${e.component}.${t}`) > -1 && (typeof e[t] == "string" ? e[t] = this.getStoryReference(o, e[t]) : Array.isArray(e[t]) && (e[t] = e[t].map((n) => this.getStoryReference(o, n)).filter(Boolean)));
|
|
640
640
|
}
|
|
641
|
-
iterateTree(e, t,
|
|
641
|
+
iterateTree(e, t, s) {
|
|
642
642
|
const o = (n) => {
|
|
643
643
|
if (n != null) {
|
|
644
644
|
if (n.constructor === Array)
|
|
@@ -652,24 +652,24 @@ class ze {
|
|
|
652
652
|
n,
|
|
653
653
|
i,
|
|
654
654
|
t,
|
|
655
|
-
|
|
655
|
+
s
|
|
656
656
|
), this._insertLinks(
|
|
657
657
|
n,
|
|
658
658
|
i,
|
|
659
|
-
|
|
659
|
+
s
|
|
660
660
|
)), o(n[i]);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
663
|
};
|
|
664
664
|
o(e.content);
|
|
665
665
|
}
|
|
666
|
-
async resolveLinks(e, t,
|
|
666
|
+
async resolveLinks(e, t, s) {
|
|
667
667
|
let o = [];
|
|
668
668
|
if (e.link_uuids) {
|
|
669
669
|
const n = e.link_uuids.length, i = [], l = 50;
|
|
670
670
|
for (let a = 0; a < n; a += l) {
|
|
671
|
-
const
|
|
672
|
-
i.push(e.link_uuids.slice(a,
|
|
671
|
+
const h = Math.min(n, a + l);
|
|
672
|
+
i.push(e.link_uuids.slice(a, h));
|
|
673
673
|
}
|
|
674
674
|
for (let a = 0; a < i.length; a++)
|
|
675
675
|
(await this.getStories({
|
|
@@ -678,26 +678,26 @@ class ze {
|
|
|
678
678
|
version: t.version,
|
|
679
679
|
by_uuids: i[a].join(",")
|
|
680
680
|
})).data.stories.forEach(
|
|
681
|
-
(
|
|
682
|
-
o.push(
|
|
681
|
+
(h) => {
|
|
682
|
+
o.push(h);
|
|
683
683
|
}
|
|
684
684
|
);
|
|
685
685
|
} else
|
|
686
686
|
o = e.links;
|
|
687
687
|
o.forEach((n) => {
|
|
688
|
-
this.links[
|
|
688
|
+
this.links[s][n.uuid] = {
|
|
689
689
|
...n,
|
|
690
690
|
_stopResolving: !0
|
|
691
691
|
};
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
|
-
async resolveRelations(e, t,
|
|
694
|
+
async resolveRelations(e, t, s) {
|
|
695
695
|
let o = [];
|
|
696
696
|
if (e.rel_uuids) {
|
|
697
697
|
const n = e.rel_uuids.length, i = [], l = 50;
|
|
698
698
|
for (let a = 0; a < n; a += l) {
|
|
699
|
-
const
|
|
700
|
-
i.push(e.rel_uuids.slice(a,
|
|
699
|
+
const h = Math.min(n, a + l);
|
|
700
|
+
i.push(e.rel_uuids.slice(a, h));
|
|
701
701
|
}
|
|
702
702
|
for (let a = 0; a < i.length; a++)
|
|
703
703
|
(await this.getStories({
|
|
@@ -706,13 +706,13 @@ class ze {
|
|
|
706
706
|
version: t.version,
|
|
707
707
|
by_uuids: i[a].join(","),
|
|
708
708
|
excluding_fields: t.excluding_fields
|
|
709
|
-
})).data.stories.forEach((
|
|
710
|
-
o.push(
|
|
709
|
+
})).data.stories.forEach((h) => {
|
|
710
|
+
o.push(h);
|
|
711
711
|
});
|
|
712
712
|
} else
|
|
713
713
|
o = e.rels;
|
|
714
714
|
o && o.length > 0 && o.forEach((n) => {
|
|
715
|
-
this.relations[
|
|
715
|
+
this.relations[s][n.uuid] = {
|
|
716
716
|
...n,
|
|
717
717
|
_stopResolving: !0
|
|
718
718
|
};
|
|
@@ -727,21 +727,21 @@ class ze {
|
|
|
727
727
|
* @returns Promise<void>
|
|
728
728
|
*
|
|
729
729
|
*/
|
|
730
|
-
async resolveStories(e, t,
|
|
730
|
+
async resolveStories(e, t, s) {
|
|
731
731
|
var o, n;
|
|
732
732
|
let i = [];
|
|
733
|
-
if (this.links[
|
|
734
|
-
for (const l in this.relations[
|
|
733
|
+
if (this.links[s] = {}, this.relations[s] = {}, typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (i = t.resolve_relations.split(",")), await this.resolveRelations(e, t, s)), t.resolve_links && ["1", "story", "url", "link"].indexOf(t.resolve_links) > -1 && ((o = e.links) != null && o.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t, s), this.resolveNestedRelations)
|
|
734
|
+
for (const l in this.relations[s])
|
|
735
735
|
this.iterateTree(
|
|
736
|
-
this.relations[
|
|
736
|
+
this.relations[s][l],
|
|
737
737
|
i,
|
|
738
|
-
|
|
738
|
+
s
|
|
739
739
|
);
|
|
740
|
-
e.story ? this.iterateTree(e.story, i,
|
|
741
|
-
this.iterateTree(l, i,
|
|
742
|
-
}), this.stringifiedStoriesCache = {}, delete this.links[
|
|
740
|
+
e.story ? this.iterateTree(e.story, i, s) : e.stories.forEach((l) => {
|
|
741
|
+
this.iterateTree(l, i, s);
|
|
742
|
+
}), this.stringifiedStoriesCache = {}, delete this.links[s], delete this.relations[s];
|
|
743
743
|
}
|
|
744
|
-
async cacheResponse(e, t,
|
|
744
|
+
async cacheResponse(e, t, s, o) {
|
|
745
745
|
const n = this.helpers.stringify({ url: e, params: t }), i = this.cacheProvider();
|
|
746
746
|
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
747
747
|
const l = await i.get(n);
|
|
@@ -749,59 +749,59 @@ class ze {
|
|
|
749
749
|
return Promise.resolve(l);
|
|
750
750
|
}
|
|
751
751
|
return new Promise(async (l, a) => {
|
|
752
|
-
var
|
|
752
|
+
var h;
|
|
753
753
|
try {
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
return a(
|
|
757
|
-
let
|
|
758
|
-
if ((
|
|
759
|
-
perPage:
|
|
760
|
-
total:
|
|
761
|
-
})),
|
|
762
|
-
const
|
|
763
|
-
await this.resolveStories(
|
|
754
|
+
const u = await this.throttle("get", e, t, o);
|
|
755
|
+
if (u.status !== 200)
|
|
756
|
+
return a(u);
|
|
757
|
+
let d = { data: u.data, headers: u.headers };
|
|
758
|
+
if ((h = u.headers) != null && h["per-page"] && (d = Object.assign({}, d, {
|
|
759
|
+
perPage: u.headers["per-page"] ? parseInt(u.headers["per-page"]) : 0,
|
|
760
|
+
total: u.headers["per-page"] ? parseInt(u.headers.total) : 0
|
|
761
|
+
})), d.data.story || d.data.stories) {
|
|
762
|
+
const g = this.resolveCounter = ++this.resolveCounter % 1e3;
|
|
763
|
+
await this.resolveStories(d.data, t, `${g}`);
|
|
764
764
|
}
|
|
765
|
-
return t.version === "published" && e != "/cdn/spaces/me" && await i.set(n,
|
|
766
|
-
} catch (
|
|
767
|
-
if (
|
|
765
|
+
return t.version === "published" && e != "/cdn/spaces/me" && await i.set(n, d), d.data.cv && t.token && E[t.token] != d.data.cv && (await this.flushCache(), E[t.token] = d.data.cv), l(d);
|
|
766
|
+
} catch (u) {
|
|
767
|
+
if (u.response && u.status === 429 && (s = typeof s > "u" ? 0 : s + 1, s < this.maxRetries))
|
|
768
768
|
return console.log(
|
|
769
769
|
`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`
|
|
770
|
-
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t,
|
|
771
|
-
a(
|
|
770
|
+
), await this.helpers.delay(this.retriesDelay), this.cacheResponse(e, t, s).then(l).catch(a);
|
|
771
|
+
a(u);
|
|
772
772
|
}
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
|
-
throttledRequest(e, t,
|
|
776
|
-
return this.client.setFetchOptions(o), this.client[e](t,
|
|
775
|
+
throttledRequest(e, t, s, o) {
|
|
776
|
+
return this.client.setFetchOptions(o), this.client[e](t, s);
|
|
777
777
|
}
|
|
778
778
|
cacheVersions() {
|
|
779
|
-
return
|
|
779
|
+
return E;
|
|
780
780
|
}
|
|
781
781
|
cacheVersion() {
|
|
782
|
-
return
|
|
782
|
+
return E[this.accessToken];
|
|
783
783
|
}
|
|
784
784
|
setCacheVersion(e) {
|
|
785
|
-
this.accessToken && (
|
|
785
|
+
this.accessToken && (E[this.accessToken] = e);
|
|
786
786
|
}
|
|
787
787
|
clearCacheVersion() {
|
|
788
|
-
this.accessToken && (
|
|
788
|
+
this.accessToken && (E[this.accessToken] = 0);
|
|
789
789
|
}
|
|
790
790
|
cacheProvider() {
|
|
791
791
|
switch (this.cache.type) {
|
|
792
792
|
case "memory":
|
|
793
793
|
return {
|
|
794
794
|
get(e) {
|
|
795
|
-
return Promise.resolve(
|
|
795
|
+
return Promise.resolve(O[e]);
|
|
796
796
|
},
|
|
797
797
|
getAll() {
|
|
798
|
-
return Promise.resolve(
|
|
798
|
+
return Promise.resolve(O);
|
|
799
799
|
},
|
|
800
800
|
set(e, t) {
|
|
801
|
-
return
|
|
801
|
+
return O[e] = t, Promise.resolve(void 0);
|
|
802
802
|
},
|
|
803
803
|
flush() {
|
|
804
|
-
return
|
|
804
|
+
return O = {}, Promise.resolve(void 0);
|
|
805
805
|
}
|
|
806
806
|
};
|
|
807
807
|
case "custom":
|
|
@@ -827,21 +827,21 @@ class ze {
|
|
|
827
827
|
return await this.cacheProvider().flush(), this.clearCacheVersion(), this;
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
|
-
const
|
|
831
|
-
const { apiOptions: e } =
|
|
830
|
+
const ct = (r = {}) => {
|
|
831
|
+
const { apiOptions: e } = r;
|
|
832
832
|
if (!e.accessToken) {
|
|
833
833
|
console.error(
|
|
834
834
|
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
835
835
|
);
|
|
836
836
|
return;
|
|
837
837
|
}
|
|
838
|
-
return { storyblokApi: new
|
|
839
|
-
},
|
|
840
|
-
if (typeof
|
|
838
|
+
return { storyblokApi: new Ge(e) };
|
|
839
|
+
}, Ke = (r) => {
|
|
840
|
+
if (typeof r != "object" || typeof r._editable > "u")
|
|
841
841
|
return {};
|
|
842
842
|
try {
|
|
843
843
|
const e = JSON.parse(
|
|
844
|
-
|
|
844
|
+
r._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
845
845
|
);
|
|
846
846
|
return e ? {
|
|
847
847
|
"data-blok-c": JSON.stringify(e),
|
|
@@ -851,325 +851,373 @@ const st = (s = {}) => {
|
|
|
851
851
|
return {};
|
|
852
852
|
}
|
|
853
853
|
};
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
let t = 0,
|
|
854
|
+
function Je(r, e) {
|
|
855
|
+
if (!e)
|
|
856
|
+
return { src: r, attrs: {} };
|
|
857
|
+
let t = 0, s = 0;
|
|
858
858
|
const o = {}, n = [];
|
|
859
|
-
function i(a,
|
|
860
|
-
typeof a != "number" || a <=
|
|
859
|
+
function i(a, h, u, d, g) {
|
|
860
|
+
typeof a != "number" || a <= h || a >= u ? console.warn(`[StoryblokRichText] - ${d.charAt(0).toUpperCase() + d.slice(1)} value must be a number between ${h} and ${u} (inclusive)`) : g.push(`${d}(${a})`);
|
|
861
861
|
}
|
|
862
862
|
if (typeof e == "object") {
|
|
863
|
-
if (typeof e.width == "number" && e.width > 0 ? (o.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 ? (o.height = e.height,
|
|
864
|
-
const { filters: a } = e || {}, { blur:
|
|
865
|
-
|
|
863
|
+
if (typeof e.width == "number" && e.width > 0 ? (o.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 ? (o.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) && (o.loading = e.loading), e.class && (o.class = e.class), e.filters) {
|
|
864
|
+
const { filters: a } = e || {}, { blur: h, brightness: u, fill: d, format: g, grayscale: $, quality: y, rotate: w } = a || {};
|
|
865
|
+
h && i(h, 0, 100, "blur", n), y && i(y, 0, 100, "quality", n), u && i(u, 0, 100, "brightness", n), d && n.push(`fill(${d})`), $ && n.push("grayscale()"), w && [0, 90, 180, 270].includes(e.filters.rotate || 0) && n.push(`rotate(${w})`), g && ["webp", "png", "jpeg"].includes(g) && n.push(`format(${g})`);
|
|
866
866
|
}
|
|
867
867
|
e.srcset && (o.srcset = e.srcset.map((a) => {
|
|
868
868
|
if (typeof a == "number")
|
|
869
|
-
return `${
|
|
869
|
+
return `${r}/m/${a}x0/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${a}w`;
|
|
870
870
|
if (Array.isArray(a) && a.length === 2) {
|
|
871
|
-
const [
|
|
872
|
-
return `${
|
|
871
|
+
const [h, u] = a;
|
|
872
|
+
return `${r}/m/${h}x${u}/${n.length > 0 ? `filters:${n.join(":")}` : ""} ${h}w`;
|
|
873
|
+
} else {
|
|
874
|
+
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
875
|
+
return;
|
|
873
876
|
}
|
|
874
877
|
}).join(", ")), e.sizes && (o.sizes = e.sizes.join(", "));
|
|
875
878
|
}
|
|
876
|
-
let l = `${
|
|
877
|
-
return t > 0 &&
|
|
879
|
+
let l = `${r}/m/`;
|
|
880
|
+
return t > 0 && s > 0 && (l = `${l}${t}x${s}/`), n.length > 0 && (l = `${l}filters:${n.join(":")}`), {
|
|
878
881
|
src: l,
|
|
879
882
|
attrs: o
|
|
880
883
|
};
|
|
881
884
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
+
var k = /* @__PURE__ */ ((r) => (r.DOCUMENT = "doc", r.HEADING = "heading", r.PARAGRAPH = "paragraph", r.QUOTE = "blockquote", r.OL_LIST = "ordered_list", r.UL_LIST = "bullet_list", r.LIST_ITEM = "list_item", r.CODE_BLOCK = "code_block", r.HR = "horizontal_rule", r.BR = "hard_break", r.IMAGE = "image", r.EMOJI = "emoji", r.COMPONENT = "blok", r))(k || {}), v = /* @__PURE__ */ ((r) => (r.BOLD = "bold", r.STRONG = "strong", r.STRIKE = "strike", r.UNDERLINE = "underline", r.ITALIC = "italic", r.CODE = "code", r.LINK = "link", r.ANCHOR = "anchor", r.STYLED = "styled", r.SUPERSCRIPT = "superscript", r.SUBSCRIPT = "subscript", r.TEXT_STYLE = "textStyle", r.HIGHLIGHT = "highlight", r))(v || {}), W = /* @__PURE__ */ ((r) => (r.TEXT = "text", r))(W || {}), x = /* @__PURE__ */ ((r) => (r.URL = "url", r.STORY = "story", r.ASSET = "asset", r.EMAIL = "email", r))(x || {});
|
|
886
|
+
const Ye = [
|
|
887
|
+
"area",
|
|
888
|
+
"base",
|
|
889
|
+
"br",
|
|
890
|
+
"col",
|
|
891
|
+
"embed",
|
|
892
|
+
"hr",
|
|
893
|
+
"img",
|
|
894
|
+
"input",
|
|
895
|
+
"link",
|
|
896
|
+
"meta",
|
|
897
|
+
"param",
|
|
898
|
+
"source",
|
|
899
|
+
"track",
|
|
900
|
+
"wbr"
|
|
901
|
+
], Xe = (r = {}) => Object.keys(r).map((e) => `${e}="${r[e]}"`).join(" "), We = (r = {}) => Object.keys(r).map((e) => `${e}: ${r[e]}`).join("; ");
|
|
902
|
+
function Qe(r) {
|
|
903
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
885
904
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
905
|
+
const F = (r) => Object.fromEntries(Object.entries(r).filter(([e, t]) => t !== void 0));
|
|
906
|
+
function Ze(r, e = {}, t) {
|
|
907
|
+
const s = Xe(e), o = s ? `${r} ${s}` : r;
|
|
908
|
+
return Ye.includes(r) ? `<${o}>` : `<${o}>${Array.isArray(t) ? t.join("") : t || ""}</${r}>`;
|
|
889
909
|
}
|
|
890
|
-
function
|
|
910
|
+
function et(r = {}) {
|
|
891
911
|
let e = 0;
|
|
892
912
|
const {
|
|
893
|
-
renderFn: t =
|
|
894
|
-
textFn:
|
|
913
|
+
renderFn: t = Ze,
|
|
914
|
+
textFn: s = Qe,
|
|
895
915
|
resolvers: o = {},
|
|
896
|
-
optimizeImages: n = !1
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
916
|
+
optimizeImages: n = !1,
|
|
917
|
+
keyedResolvers: i = !1
|
|
918
|
+
} = r, l = (c) => (m) => {
|
|
919
|
+
const f = m.attrs || {};
|
|
920
|
+
return i && (f.key = `${c}-${e}`), t(c, f, m.children || null);
|
|
921
|
+
}, a = (c) => {
|
|
922
|
+
const { src: m, alt: f, title: b, srcset: R, sizes: T } = c.attrs || {};
|
|
923
|
+
let S = m, _ = {};
|
|
900
924
|
if (n) {
|
|
901
|
-
const { src:
|
|
902
|
-
|
|
925
|
+
const { src: se, attrs: oe } = Je(m, n);
|
|
926
|
+
S = se, _ = oe;
|
|
903
927
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
928
|
+
i && (_ = {
|
|
929
|
+
..._,
|
|
930
|
+
key: `img-${e}`
|
|
931
|
+
});
|
|
932
|
+
const re = {
|
|
933
|
+
src: S,
|
|
934
|
+
alt: f,
|
|
935
|
+
title: b,
|
|
936
|
+
srcset: R,
|
|
937
|
+
sizes: T,
|
|
938
|
+
..._
|
|
910
939
|
};
|
|
911
|
-
return t("img",
|
|
912
|
-
},
|
|
913
|
-
const { level:
|
|
914
|
-
|
|
940
|
+
return t("img", F(re));
|
|
941
|
+
}, h = (c) => {
|
|
942
|
+
const { level: m, ...f } = c.attrs || {}, b = {
|
|
943
|
+
...f
|
|
944
|
+
};
|
|
945
|
+
return i && (b.key = `h${m}-${e}`), t(`h${m}`, b, c.children);
|
|
915
946
|
}, u = (c) => {
|
|
916
|
-
var
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
emoji: (f = c.attrs) == null ? void 0 : f.emoji,
|
|
921
|
-
key: `emoji-${e}`
|
|
922
|
-
}, t("img", {
|
|
923
|
-
src: (v = c.attrs) == null ? void 0 : v.fallbackImage,
|
|
924
|
-
alt: (T = c.attrs) == null ? void 0 : T.alt,
|
|
947
|
+
var m, f, b, R;
|
|
948
|
+
const T = t("img", {
|
|
949
|
+
src: (m = c.attrs) == null ? void 0 : m.fallbackImage,
|
|
950
|
+
alt: (f = c.attrs) == null ? void 0 : f.alt,
|
|
925
951
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
926
952
|
draggable: "false",
|
|
927
953
|
loading: "lazy"
|
|
928
|
-
},
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
954
|
+
}), S = {
|
|
955
|
+
"data-type": "emoji",
|
|
956
|
+
"data-name": (b = c.attrs) == null ? void 0 : b.name,
|
|
957
|
+
"data-emoji": (R = c.attrs) == null ? void 0 : R.emoji
|
|
958
|
+
};
|
|
959
|
+
return i && (S.key = `emoji-${e}`), t("span", S, T);
|
|
960
|
+
}, d = (c) => t("pre", {
|
|
961
|
+
...c.attrs,
|
|
962
|
+
key: `code-${e}`
|
|
963
|
+
}, t("code", { key: `code-${e}` }, c.children || "")), g = (c, m = !1) => ({ text: f, attrs: b }) => {
|
|
964
|
+
const { class: R, id: T, ...S } = b || {}, _ = m ? {
|
|
965
|
+
class: R,
|
|
966
|
+
id: T,
|
|
967
|
+
style: We(S) || void 0
|
|
968
|
+
} : b || {};
|
|
969
|
+
return i && (_.key = `${c}-${e}`), t(c, F(_), f);
|
|
970
|
+
}, $ = (c) => P(c), y = (c) => {
|
|
971
|
+
const { marks: m, ...f } = c;
|
|
972
|
+
return "text" in c ? m ? m.reduce(
|
|
973
|
+
(b, R) => $({ ...R, text: b }),
|
|
936
974
|
// Fix: Ensure render function returns a string
|
|
937
|
-
|
|
975
|
+
$({ ...f, children: f.children })
|
|
938
976
|
// Fix: Cast children to string
|
|
939
|
-
) :
|
|
940
|
-
},
|
|
941
|
-
const { linktype:
|
|
942
|
-
let
|
|
943
|
-
switch (
|
|
944
|
-
case
|
|
945
|
-
case
|
|
946
|
-
|
|
977
|
+
) : s(f.text) : "";
|
|
978
|
+
}, w = (c) => {
|
|
979
|
+
const { linktype: m, href: f, anchor: b, ...R } = c.attrs || {};
|
|
980
|
+
let T = "";
|
|
981
|
+
switch (m) {
|
|
982
|
+
case x.ASSET:
|
|
983
|
+
case x.URL:
|
|
984
|
+
T = f;
|
|
947
985
|
break;
|
|
948
|
-
case
|
|
949
|
-
|
|
986
|
+
case x.EMAIL:
|
|
987
|
+
T = `mailto:${f}`;
|
|
950
988
|
break;
|
|
951
|
-
case
|
|
952
|
-
|
|
989
|
+
case x.STORY:
|
|
990
|
+
T = f;
|
|
953
991
|
break;
|
|
954
992
|
}
|
|
955
|
-
return
|
|
956
|
-
},
|
|
957
|
-
var
|
|
993
|
+
return b && (T = `${T}#${b}`), t("a", { ...R, href: T, key: `a-${e}` }, c.text);
|
|
994
|
+
}, I = (c) => {
|
|
995
|
+
var m, f;
|
|
958
996
|
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), t("span", {
|
|
959
|
-
blok: (
|
|
997
|
+
blok: (m = c == null ? void 0 : c.attrs) == null ? void 0 : m.body[0],
|
|
960
998
|
id: (f = c.attrs) == null ? void 0 : f.id,
|
|
961
999
|
key: `component-${e}`,
|
|
962
1000
|
style: "display: none"
|
|
963
|
-
}
|
|
964
|
-
},
|
|
965
|
-
[
|
|
966
|
-
[
|
|
967
|
-
[
|
|
968
|
-
[
|
|
969
|
-
[
|
|
970
|
-
[
|
|
971
|
-
[
|
|
972
|
-
[
|
|
973
|
-
[
|
|
974
|
-
[
|
|
975
|
-
[
|
|
976
|
-
[
|
|
977
|
-
[
|
|
978
|
-
[
|
|
979
|
-
[
|
|
980
|
-
[
|
|
981
|
-
[
|
|
982
|
-
[
|
|
983
|
-
[
|
|
984
|
-
[
|
|
985
|
-
[
|
|
986
|
-
[
|
|
987
|
-
[
|
|
988
|
-
[
|
|
989
|
-
[
|
|
990
|
-
[
|
|
991
|
-
...Object.entries(o).map(([c,
|
|
1001
|
+
});
|
|
1002
|
+
}, te = new Map([
|
|
1003
|
+
[k.DOCUMENT, l("div")],
|
|
1004
|
+
[k.HEADING, h],
|
|
1005
|
+
[k.PARAGRAPH, l("p")],
|
|
1006
|
+
[k.UL_LIST, l("ul")],
|
|
1007
|
+
[k.OL_LIST, l("ol")],
|
|
1008
|
+
[k.LIST_ITEM, l("li")],
|
|
1009
|
+
[k.IMAGE, a],
|
|
1010
|
+
[k.EMOJI, u],
|
|
1011
|
+
[k.CODE_BLOCK, d],
|
|
1012
|
+
[k.HR, l("hr")],
|
|
1013
|
+
[k.BR, l("br")],
|
|
1014
|
+
[k.QUOTE, l("blockquote")],
|
|
1015
|
+
[k.COMPONENT, I],
|
|
1016
|
+
[W.TEXT, y],
|
|
1017
|
+
[v.LINK, w],
|
|
1018
|
+
[v.ANCHOR, w],
|
|
1019
|
+
[v.STYLED, g("span", !0)],
|
|
1020
|
+
[v.BOLD, g("strong")],
|
|
1021
|
+
[v.TEXT_STYLE, g("span", !0)],
|
|
1022
|
+
[v.ITALIC, g("em")],
|
|
1023
|
+
[v.UNDERLINE, g("u")],
|
|
1024
|
+
[v.STRIKE, g("s")],
|
|
1025
|
+
[v.CODE, g("code")],
|
|
1026
|
+
[v.SUPERSCRIPT, g("sup")],
|
|
1027
|
+
[v.SUBSCRIPT, g("sub")],
|
|
1028
|
+
[v.HIGHLIGHT, g("mark")],
|
|
1029
|
+
...Object.entries(o).map(([c, m]) => [c, m])
|
|
992
1030
|
]);
|
|
993
|
-
function
|
|
1031
|
+
function U(c) {
|
|
994
1032
|
e += 1;
|
|
995
|
-
const
|
|
996
|
-
if (!
|
|
1033
|
+
const m = te.get(c.type);
|
|
1034
|
+
if (!m)
|
|
997
1035
|
return console.error("<Storyblok>", `No resolver found for node type ${c.type}`), "";
|
|
998
1036
|
if (c.type === "text")
|
|
999
|
-
return
|
|
1000
|
-
const f = c.content ? c.content.map(
|
|
1001
|
-
return
|
|
1037
|
+
return m(c);
|
|
1038
|
+
const f = c.content ? c.content.map(P) : void 0;
|
|
1039
|
+
return m({
|
|
1002
1040
|
...c,
|
|
1003
1041
|
children: f
|
|
1004
1042
|
// Fix: Update the type of 'children' to Node[]
|
|
1005
1043
|
});
|
|
1006
1044
|
}
|
|
1007
|
-
function
|
|
1008
|
-
return Array.isArray(c) ? c.map(
|
|
1045
|
+
function P(c) {
|
|
1046
|
+
return Array.isArray(c) ? c.map(U) : U(c);
|
|
1009
1047
|
}
|
|
1010
1048
|
return {
|
|
1011
|
-
render:
|
|
1049
|
+
render: P
|
|
1012
1050
|
};
|
|
1013
1051
|
}
|
|
1014
|
-
let
|
|
1015
|
-
const
|
|
1016
|
-
var
|
|
1017
|
-
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((
|
|
1052
|
+
let H, G = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1053
|
+
const tt = (r, e, t = {}) => {
|
|
1054
|
+
var s;
|
|
1055
|
+
const o = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", n = +new URL((s = window.location) == null ? void 0 : s.href).searchParams.get(
|
|
1018
1056
|
"_storyblok"
|
|
1019
|
-
) ===
|
|
1057
|
+
) === r;
|
|
1020
1058
|
if (!(!o || !n)) {
|
|
1021
|
-
if (!
|
|
1059
|
+
if (!r) {
|
|
1022
1060
|
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
1023
1061
|
return;
|
|
1024
1062
|
}
|
|
1025
1063
|
window.storyblokRegisterEvent(() => {
|
|
1026
1064
|
new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
|
|
1027
|
-
i.action === "input" && i.story.id ===
|
|
1065
|
+
i.action === "input" && i.story.id === r ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === r && window.location.reload();
|
|
1028
1066
|
});
|
|
1029
1067
|
});
|
|
1030
1068
|
}
|
|
1031
|
-
},
|
|
1069
|
+
}, rt = (r = {}) => {
|
|
1032
1070
|
var e, t;
|
|
1033
1071
|
const {
|
|
1034
|
-
bridge:
|
|
1072
|
+
bridge: s,
|
|
1035
1073
|
accessToken: o,
|
|
1036
1074
|
use: n = [],
|
|
1037
1075
|
apiOptions: i = {},
|
|
1038
1076
|
richText: l = {},
|
|
1039
1077
|
bridgeUrl: a
|
|
1040
|
-
} =
|
|
1078
|
+
} = r;
|
|
1041
1079
|
i.accessToken = i.accessToken || o;
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
n.forEach((
|
|
1045
|
-
|
|
1046
|
-
}), a && (
|
|
1047
|
-
const
|
|
1048
|
-
return
|
|
1049
|
-
},
|
|
1050
|
-
|
|
1051
|
-
let
|
|
1080
|
+
const h = { bridge: s, apiOptions: i };
|
|
1081
|
+
let u = {};
|
|
1082
|
+
n.forEach((g) => {
|
|
1083
|
+
u = { ...u, ...g(h) };
|
|
1084
|
+
}), a && (G = a);
|
|
1085
|
+
const d = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
1086
|
+
return s !== !1 && d && ue(G), H = new L(l.schema), l.resolver && Q(H, l.resolver), u;
|
|
1087
|
+
}, Q = (r, e) => {
|
|
1088
|
+
r.addNode("blok", (t) => {
|
|
1089
|
+
let s = "";
|
|
1052
1090
|
return t.attrs.body.forEach((o) => {
|
|
1053
|
-
|
|
1091
|
+
s += e(o.component, o);
|
|
1054
1092
|
}), {
|
|
1055
|
-
html:
|
|
1093
|
+
html: s
|
|
1056
1094
|
};
|
|
1057
1095
|
});
|
|
1058
|
-
},
|
|
1059
|
-
let
|
|
1060
|
-
if (!
|
|
1096
|
+
}, st = (r) => !r || !(r != null && r.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), ht = (r, e, t) => {
|
|
1097
|
+
let s = t || H;
|
|
1098
|
+
if (!s) {
|
|
1061
1099
|
console.error(
|
|
1062
1100
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
1063
1101
|
);
|
|
1064
1102
|
return;
|
|
1065
1103
|
}
|
|
1066
|
-
return
|
|
1067
|
-
},
|
|
1104
|
+
return st(r) ? "" : (e && (s = new L(e.schema), e.resolver && Q(s, e.resolver)), s.render(r, {}, !1));
|
|
1105
|
+
}, Z = /* @__PURE__ */ K({
|
|
1068
1106
|
__name: "StoryblokComponent",
|
|
1069
1107
|
props: {
|
|
1070
1108
|
blok: {}
|
|
1071
1109
|
},
|
|
1072
|
-
setup(
|
|
1073
|
-
const t =
|
|
1110
|
+
setup(r, { expose: e }) {
|
|
1111
|
+
const t = r, s = C();
|
|
1074
1112
|
e({
|
|
1075
|
-
value:
|
|
1113
|
+
value: s
|
|
1076
1114
|
});
|
|
1077
|
-
const o = typeof
|
|
1078
|
-
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof
|
|
1115
|
+
const o = typeof N(t.blok.component) != "string", n = ne("VueSDKOptions"), i = C(t.blok.component);
|
|
1116
|
+
return o || (n.enableFallbackComponent ? (i.value = n.customFallbackComponent ?? "FallbackComponent", typeof N(i.value) == "string" && console.error(
|
|
1079
1117
|
`Is the Fallback component "${i.value}" registered properly?`
|
|
1080
1118
|
)) : console.error(
|
|
1081
1119
|
`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`
|
|
1082
|
-
)), (l, a) => (
|
|
1120
|
+
)), (l, a) => (J(), Y(N(i.value), ie({
|
|
1083
1121
|
ref_key: "blokRef",
|
|
1084
|
-
ref:
|
|
1122
|
+
ref: s
|
|
1085
1123
|
}, { ...l.$props, ...l.$attrs }), null, 16));
|
|
1086
1124
|
}
|
|
1087
|
-
}),
|
|
1125
|
+
}), ot = (r) => {
|
|
1088
1126
|
var e, t;
|
|
1089
|
-
return
|
|
1090
|
-
|
|
1127
|
+
return X(
|
|
1128
|
+
Z,
|
|
1091
1129
|
{
|
|
1092
|
-
blok: (e =
|
|
1093
|
-
id: (t =
|
|
1130
|
+
blok: (e = r == null ? void 0 : r.attrs) == null ? void 0 : e.body[0],
|
|
1131
|
+
id: (t = r.attrs) == null ? void 0 : t.id
|
|
1094
1132
|
},
|
|
1095
|
-
|
|
1133
|
+
r.children
|
|
1096
1134
|
);
|
|
1097
1135
|
};
|
|
1098
|
-
function
|
|
1136
|
+
function nt(r) {
|
|
1099
1137
|
const e = {
|
|
1100
|
-
renderFn:
|
|
1101
|
-
textFn:
|
|
1138
|
+
renderFn: X,
|
|
1139
|
+
textFn: ae,
|
|
1140
|
+
keyedResolvers: !0,
|
|
1102
1141
|
resolvers: {
|
|
1103
|
-
[
|
|
1104
|
-
...
|
|
1142
|
+
[k.COMPONENT]: ot,
|
|
1143
|
+
...r.resolvers
|
|
1105
1144
|
}
|
|
1106
1145
|
};
|
|
1107
|
-
return
|
|
1146
|
+
return et(e);
|
|
1108
1147
|
}
|
|
1109
|
-
const
|
|
1148
|
+
const it = /* @__PURE__ */ K({
|
|
1110
1149
|
__name: "StoryblokRichText",
|
|
1111
1150
|
props: {
|
|
1112
1151
|
doc: {},
|
|
1113
1152
|
resolvers: {}
|
|
1114
1153
|
},
|
|
1115
|
-
setup(
|
|
1116
|
-
const e =
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1154
|
+
setup(r) {
|
|
1155
|
+
const e = r, t = C(), s = () => t.value;
|
|
1156
|
+
return le(
|
|
1157
|
+
[e.doc, e.resolvers],
|
|
1158
|
+
([o, n]) => {
|
|
1159
|
+
const { render: i } = nt({
|
|
1160
|
+
resolvers: n ?? {}
|
|
1161
|
+
});
|
|
1162
|
+
t.value = i(o);
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
immediate: !0
|
|
1166
|
+
}
|
|
1167
|
+
), (o, n) => (J(), Y(s));
|
|
1168
|
+
}
|
|
1169
|
+
}), at = {
|
|
1170
|
+
beforeMount(r, e) {
|
|
1123
1171
|
if (e.value) {
|
|
1124
|
-
const t =
|
|
1125
|
-
Object.keys(t).length > 0 && (
|
|
1172
|
+
const t = Ke(e.value);
|
|
1173
|
+
Object.keys(t).length > 0 && (r.setAttribute("data-blok-c", t["data-blok-c"]), r.setAttribute("data-blok-uid", t["data-blok-uid"]), r.classList.add("storyblok__outline"));
|
|
1126
1174
|
}
|
|
1127
1175
|
}
|
|
1128
|
-
},
|
|
1129
|
-
console.error(`You can't use ${
|
|
1176
|
+
}, ee = (r) => {
|
|
1177
|
+
console.error(`You can't use ${r} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
1130
1178
|
`);
|
|
1131
1179
|
};
|
|
1132
|
-
let
|
|
1133
|
-
const
|
|
1134
|
-
const
|
|
1135
|
-
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links,
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
(o) =>
|
|
1180
|
+
let j = null;
|
|
1181
|
+
const ut = () => (j || ee("useStoryblokApi"), j), pt = async (r, e = {}, t = {}) => {
|
|
1182
|
+
const s = C(null);
|
|
1183
|
+
if (t.resolveRelations = t.resolveRelations ?? e.resolve_relations, t.resolveLinks = t.resolveLinks ?? e.resolve_links, ce(() => {
|
|
1184
|
+
s.value && s.value.id && tt(
|
|
1185
|
+
s.value.id,
|
|
1186
|
+
(o) => s.value = o,
|
|
1139
1187
|
t
|
|
1140
1188
|
);
|
|
1141
|
-
}),
|
|
1142
|
-
const { data: o } = await
|
|
1143
|
-
`cdn/stories/${
|
|
1189
|
+
}), j) {
|
|
1190
|
+
const { data: o } = await j.get(
|
|
1191
|
+
`cdn/stories/${r}`,
|
|
1144
1192
|
e
|
|
1145
1193
|
);
|
|
1146
|
-
|
|
1147
|
-
} else
|
|
1148
|
-
return
|
|
1149
|
-
},
|
|
1150
|
-
install(
|
|
1151
|
-
|
|
1194
|
+
s.value = o.story;
|
|
1195
|
+
} else ee("useStoryblok");
|
|
1196
|
+
return s;
|
|
1197
|
+
}, dt = {
|
|
1198
|
+
install(r, e = {}) {
|
|
1199
|
+
r.directive("editable", at), r.component("StoryblokComponent", Z), r.component("StoryblokRichText", it), e.enableFallbackComponent && !e.customFallbackComponent && r.component(
|
|
1152
1200
|
"FallbackComponent",
|
|
1153
|
-
|
|
1201
|
+
he(() => import("./FallbackComponent-C2j8Ky5h.mjs"))
|
|
1154
1202
|
);
|
|
1155
|
-
const { storyblokApi: t } =
|
|
1156
|
-
|
|
1203
|
+
const { storyblokApi: t } = rt(e);
|
|
1204
|
+
j = t, r.provide("VueSDKOptions", e);
|
|
1157
1205
|
}
|
|
1158
1206
|
};
|
|
1159
1207
|
export {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1208
|
+
k as BlockTypes,
|
|
1209
|
+
v as MarkTypes,
|
|
1210
|
+
L as RichTextResolver,
|
|
1211
|
+
ze as RichTextSchema,
|
|
1212
|
+
Z as StoryblokComponent,
|
|
1213
|
+
it as StoryblokRichText,
|
|
1214
|
+
dt as StoryblokVue,
|
|
1215
|
+
W as TextTypes,
|
|
1216
|
+
ct as apiPlugin,
|
|
1217
|
+
ht as renderRichText,
|
|
1218
|
+
et as richTextResolver,
|
|
1219
|
+
pt as useStoryblok,
|
|
1220
|
+
ut as useStoryblokApi,
|
|
1221
|
+
tt as useStoryblokBridge,
|
|
1222
|
+
nt as useStoryblokRichText
|
|
1175
1223
|
};
|