@storyblok/vue 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/StoryblokComponent.vue.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/storyblok-vue.js +5 -3
- package/dist/storyblok-vue.mjs +570 -403
- package/package.json +9 -9
package/dist/storyblok-vue.mjs
CHANGED
|
@@ -1,407 +1,561 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { defineComponent as P, openBlock as j, createBlock as x, resolveDynamicComponent as A, normalizeProps as C, guardReactiveProps as M, ref as N, onMounted as I } from "vue";
|
|
2
|
+
import q from "axios";
|
|
3
|
+
var L = Object.defineProperty, z = Object.defineProperties, B = Object.getOwnPropertyDescriptors, v = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable, b = (n, t, e) => t in n ? L(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, h = (n, t) => {
|
|
4
|
+
for (var e in t || (t = {}))
|
|
5
|
+
D.call(t, e) && b(n, e, t[e]);
|
|
6
|
+
if (v)
|
|
7
|
+
for (var e of v(t))
|
|
8
|
+
U.call(t, e) && b(n, e, t[e]);
|
|
9
|
+
return n;
|
|
10
|
+
}, y = (n, t) => z(n, B(t));
|
|
11
|
+
let _ = !1;
|
|
12
|
+
const T = [], V = (n) => new Promise((t, e) => {
|
|
13
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
14
|
+
if (window.location === window.parent.location) {
|
|
15
|
+
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
16
|
+
return;
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
_ ? s() : T.push(s);
|
|
19
|
+
}, document.getElementById("storyblok-javascript-bridge")))
|
|
20
|
+
return;
|
|
21
|
+
const r = document.createElement("script");
|
|
22
|
+
r.async = !0, r.src = n, r.id = "storyblok-javascript-bridge", r.onerror = (s) => e(s), r.onload = (s) => {
|
|
23
|
+
T.forEach((o) => o()), _ = !0, t(s);
|
|
24
|
+
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
25
|
+
}), H = function(n, t) {
|
|
26
|
+
if (!n)
|
|
27
|
+
return null;
|
|
28
|
+
let e = {};
|
|
29
|
+
for (let r in n) {
|
|
30
|
+
let s = n[r];
|
|
31
|
+
t.indexOf(r) > -1 && s !== null && (e[r] = s);
|
|
32
|
+
}
|
|
33
|
+
return e;
|
|
34
|
+
}, J = (n) => n === "email";
|
|
35
|
+
var Y = {
|
|
36
|
+
nodes: {
|
|
37
|
+
horizontal_rule() {
|
|
38
|
+
return {
|
|
39
|
+
singleTag: "hr"
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
blockquote() {
|
|
43
|
+
return {
|
|
44
|
+
tag: "blockquote"
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
bullet_list() {
|
|
48
|
+
return {
|
|
49
|
+
tag: "ul"
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
code_block(n) {
|
|
53
|
+
return {
|
|
54
|
+
tag: [
|
|
55
|
+
"pre",
|
|
56
|
+
{
|
|
57
|
+
tag: "code",
|
|
58
|
+
attrs: n.attrs
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
hard_break() {
|
|
64
|
+
return {
|
|
65
|
+
singleTag: "br"
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
heading(n) {
|
|
69
|
+
return {
|
|
70
|
+
tag: `h${n.attrs.level}`
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
image(n) {
|
|
74
|
+
return {
|
|
75
|
+
singleTag: [
|
|
76
|
+
{
|
|
77
|
+
tag: "img",
|
|
78
|
+
attrs: H(n.attrs, ["src", "alt", "title"])
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
list_item() {
|
|
84
|
+
return {
|
|
85
|
+
tag: "li"
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
ordered_list() {
|
|
89
|
+
return {
|
|
90
|
+
tag: "ol"
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
paragraph() {
|
|
94
|
+
return {
|
|
95
|
+
tag: "p"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
marks: {
|
|
100
|
+
bold() {
|
|
101
|
+
return {
|
|
102
|
+
tag: "b"
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
strike() {
|
|
106
|
+
return {
|
|
107
|
+
tag: "strike"
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
underline() {
|
|
111
|
+
return {
|
|
112
|
+
tag: "u"
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
strong() {
|
|
116
|
+
return {
|
|
117
|
+
tag: "strong"
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
code() {
|
|
121
|
+
return {
|
|
122
|
+
tag: "code"
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
italic() {
|
|
126
|
+
return {
|
|
127
|
+
tag: "i"
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
link(n) {
|
|
131
|
+
const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
|
|
132
|
+
return J(e) && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), {
|
|
133
|
+
tag: [
|
|
134
|
+
{
|
|
135
|
+
tag: "a",
|
|
136
|
+
attrs: t
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
styled(n) {
|
|
142
|
+
return {
|
|
143
|
+
tag: [
|
|
144
|
+
{
|
|
145
|
+
tag: "span",
|
|
146
|
+
attrs: n.attrs
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
};
|
|
34
150
|
}
|
|
35
|
-
|
|
151
|
+
}
|
|
36
152
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (!loaded)
|
|
50
|
-
callbacks.push(cb);
|
|
51
|
-
else
|
|
52
|
-
cb();
|
|
53
|
-
};
|
|
54
|
-
if (document.getElementById("storyblok-javascript-bridge"))
|
|
55
|
-
return;
|
|
56
|
-
const script = document.createElement("script");
|
|
57
|
-
script.async = true;
|
|
58
|
-
script.src = src;
|
|
59
|
-
script.id = "storyblok-javascript-bridge";
|
|
60
|
-
script.onerror = (error) => reject(error);
|
|
61
|
-
script.onload = (ev) => {
|
|
62
|
-
callbacks.forEach((cb) => cb());
|
|
63
|
-
loaded = true;
|
|
64
|
-
resolve(ev);
|
|
65
|
-
};
|
|
66
|
-
document.getElementsByTagName("head")[0].appendChild(script);
|
|
67
|
-
});
|
|
153
|
+
const F = function(n) {
|
|
154
|
+
const t = {
|
|
155
|
+
"&": "&",
|
|
156
|
+
"<": "<",
|
|
157
|
+
">": ">",
|
|
158
|
+
'"': """,
|
|
159
|
+
"'": "'"
|
|
160
|
+
}, e = /[&<>"']/g, r = RegExp(e.source);
|
|
161
|
+
return n && r.test(n) ? n.replace(e, (s) => t[s]) : n;
|
|
68
162
|
};
|
|
163
|
+
class R {
|
|
164
|
+
constructor(t) {
|
|
165
|
+
t || (t = Y), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
166
|
+
}
|
|
167
|
+
addNode(t, e) {
|
|
168
|
+
this.nodes[t] = e;
|
|
169
|
+
}
|
|
170
|
+
addMark(t, e) {
|
|
171
|
+
this.marks[t] = e;
|
|
172
|
+
}
|
|
173
|
+
render(t = {}) {
|
|
174
|
+
if (t.content && Array.isArray(t.content)) {
|
|
175
|
+
let e = "";
|
|
176
|
+
return t.content.forEach((r) => {
|
|
177
|
+
e += this.renderNode(r);
|
|
178
|
+
}), e;
|
|
179
|
+
}
|
|
180
|
+
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
181
|
+
}
|
|
182
|
+
renderNode(t) {
|
|
183
|
+
let e = [];
|
|
184
|
+
t.marks && t.marks.forEach((s) => {
|
|
185
|
+
const o = this.getMatchingMark(s);
|
|
186
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
187
|
+
});
|
|
188
|
+
const r = this.getMatchingNode(t);
|
|
189
|
+
return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
|
|
190
|
+
e.push(this.renderNode(s));
|
|
191
|
+
}) : t.text ? e.push(F(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
192
|
+
const o = this.getMatchingMark(s);
|
|
193
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
194
|
+
}), e.join("");
|
|
195
|
+
}
|
|
196
|
+
renderTag(t, e) {
|
|
197
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((s) => {
|
|
198
|
+
if (s.constructor === String)
|
|
199
|
+
return `<${s}${e}>`;
|
|
200
|
+
{
|
|
201
|
+
let o = `<${s.tag}`;
|
|
202
|
+
if (s.attrs)
|
|
203
|
+
for (let a in s.attrs) {
|
|
204
|
+
let i = s.attrs[a];
|
|
205
|
+
i !== null && (o += ` ${a}="${i}"`);
|
|
206
|
+
}
|
|
207
|
+
return `${o}${e}>`;
|
|
208
|
+
}
|
|
209
|
+
}).join("");
|
|
210
|
+
}
|
|
211
|
+
renderOpeningTag(t) {
|
|
212
|
+
return this.renderTag(t, "");
|
|
213
|
+
}
|
|
214
|
+
renderClosingTag(t) {
|
|
215
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
|
|
216
|
+
}
|
|
217
|
+
getMatchingNode(t) {
|
|
218
|
+
if (typeof this.nodes[t.type] == "function")
|
|
219
|
+
return this.nodes[t.type](t);
|
|
220
|
+
}
|
|
221
|
+
getMatchingMark(t) {
|
|
222
|
+
if (typeof this.marks[t.type] == "function")
|
|
223
|
+
return this.marks[t.type](t);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
69
226
|
/*!
|
|
70
227
|
* storyblok-js-client v4.5.2
|
|
71
228
|
* Universal JavaScript SDK for Storyblok's API
|
|
72
229
|
* (c) 2020-2022 Stobylok Team
|
|
73
230
|
*/
|
|
74
|
-
function
|
|
75
|
-
return typeof
|
|
231
|
+
function w(n) {
|
|
232
|
+
return typeof n == "number" && n == n && n !== 1 / 0 && n !== -1 / 0;
|
|
76
233
|
}
|
|
77
|
-
function
|
|
78
|
-
if (!t
|
|
234
|
+
function $(n, t, e) {
|
|
235
|
+
if (!w(t))
|
|
79
236
|
throw new TypeError("Expected `limit` to be a finite number");
|
|
80
|
-
if (!
|
|
237
|
+
if (!w(e))
|
|
81
238
|
throw new TypeError("Expected `interval` to be a finite number");
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
return
|
|
239
|
+
var r = [], s = [], o = 0, a = function() {
|
|
240
|
+
o++;
|
|
241
|
+
var c = setTimeout(function() {
|
|
242
|
+
o--, r.length > 0 && a(), s = s.filter(function(u) {
|
|
243
|
+
return u !== c;
|
|
87
244
|
});
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
var
|
|
94
|
-
return new Promise(function(
|
|
95
|
-
|
|
245
|
+
}, e);
|
|
246
|
+
s.indexOf(c) < 0 && s.push(c);
|
|
247
|
+
var l = r.shift();
|
|
248
|
+
l.resolve(n.apply(l.self, l.args));
|
|
249
|
+
}, i = function() {
|
|
250
|
+
var c = arguments, l = this;
|
|
251
|
+
return new Promise(function(u, p) {
|
|
252
|
+
r.push({ resolve: u, reject: p, args: c, self: l }), o < t && a();
|
|
96
253
|
});
|
|
97
254
|
};
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
},
|
|
255
|
+
return i.abort = function() {
|
|
256
|
+
s.forEach(clearTimeout), s = [], r.forEach(function(c) {
|
|
257
|
+
c.reject(new throttle.AbortError());
|
|
258
|
+
}), r.length = 0;
|
|
259
|
+
}, i;
|
|
103
260
|
}
|
|
104
|
-
|
|
261
|
+
$.AbortError = function() {
|
|
105
262
|
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
106
263
|
};
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
264
|
+
const K = function(n, t) {
|
|
265
|
+
if (!n)
|
|
109
266
|
return null;
|
|
110
|
-
let
|
|
111
|
-
for (let
|
|
112
|
-
let
|
|
113
|
-
|
|
267
|
+
let e = {};
|
|
268
|
+
for (let r in n) {
|
|
269
|
+
let s = n[r];
|
|
270
|
+
t.indexOf(r) > -1 && s !== null && (e[r] = s);
|
|
114
271
|
}
|
|
115
|
-
return
|
|
272
|
+
return e;
|
|
116
273
|
};
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
}, styled: (
|
|
121
|
-
class
|
|
122
|
-
constructor(
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
addNode(
|
|
126
|
-
this.nodes[
|
|
127
|
-
}
|
|
128
|
-
addMark(
|
|
129
|
-
this.marks[
|
|
130
|
-
}
|
|
131
|
-
render(
|
|
132
|
-
if (
|
|
133
|
-
let
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
}),
|
|
274
|
+
var G = { nodes: { horizontal_rule: () => ({ singleTag: "hr" }), blockquote: () => ({ tag: "blockquote" }), bullet_list: () => ({ tag: "ul" }), code_block: (n) => ({ tag: ["pre", { tag: "code", attrs: n.attrs }] }), hard_break: () => ({ singleTag: "br" }), heading: (n) => ({ tag: `h${n.attrs.level}` }), image: (n) => ({ singleTag: [{ tag: "img", attrs: K(n.attrs, ["src", "alt", "title"]) }] }), list_item: () => ({ tag: "li" }), ordered_list: () => ({ tag: "ol" }), paragraph: () => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(n) {
|
|
275
|
+
const t = h({}, n.attrs), { linktype: e = "url" } = n.attrs;
|
|
276
|
+
return e === "email" && (t.href = `mailto:${t.href}`), t.anchor && (t.href = `${t.href}#${t.anchor}`, delete t.anchor), { tag: [{ tag: "a", attrs: t }] };
|
|
277
|
+
}, styled: (n) => ({ tag: [{ tag: "span", attrs: n.attrs }] }) } };
|
|
278
|
+
class Q {
|
|
279
|
+
constructor(t) {
|
|
280
|
+
t || (t = G), this.marks = t.marks || [], this.nodes = t.nodes || [];
|
|
281
|
+
}
|
|
282
|
+
addNode(t, e) {
|
|
283
|
+
this.nodes[t] = e;
|
|
284
|
+
}
|
|
285
|
+
addMark(t, e) {
|
|
286
|
+
this.marks[t] = e;
|
|
287
|
+
}
|
|
288
|
+
render(t = {}) {
|
|
289
|
+
if (t.content && Array.isArray(t.content)) {
|
|
290
|
+
let e = "";
|
|
291
|
+
return t.content.forEach((r) => {
|
|
292
|
+
e += this.renderNode(r);
|
|
293
|
+
}), e;
|
|
137
294
|
}
|
|
138
295
|
return console.warn("The render method must receive an object with a content field, which is an array"), "";
|
|
139
296
|
}
|
|
140
|
-
renderNode(
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
297
|
+
renderNode(t) {
|
|
298
|
+
let e = [];
|
|
299
|
+
t.marks && t.marks.forEach((s) => {
|
|
300
|
+
const o = this.getMatchingMark(s);
|
|
301
|
+
o && e.push(this.renderOpeningTag(o.tag));
|
|
145
302
|
});
|
|
146
|
-
const
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
}) :
|
|
150
|
-
const
|
|
151
|
-
return
|
|
152
|
-
}(
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
}
|
|
157
|
-
renderTag(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (e3.constructor === String)
|
|
162
|
-
return `<${e3}${t2}>`;
|
|
303
|
+
const r = this.getMatchingNode(t);
|
|
304
|
+
return r && r.tag && e.push(this.renderOpeningTag(r.tag)), t.content ? t.content.forEach((s) => {
|
|
305
|
+
e.push(this.renderNode(s));
|
|
306
|
+
}) : t.text ? e.push(function(s) {
|
|
307
|
+
const o = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, a = /[&<>"']/g, i = RegExp(a.source);
|
|
308
|
+
return s && i.test(s) ? s.replace(a, (c) => o[c]) : s;
|
|
309
|
+
}(t.text)) : r && r.singleTag ? e.push(this.renderTag(r.singleTag, " /")) : r && r.html && e.push(r.html), r && r.tag && e.push(this.renderClosingTag(r.tag)), t.marks && t.marks.slice(0).reverse().forEach((s) => {
|
|
310
|
+
const o = this.getMatchingMark(s);
|
|
311
|
+
o && e.push(this.renderClosingTag(o.tag));
|
|
312
|
+
}), e.join("");
|
|
313
|
+
}
|
|
314
|
+
renderTag(t, e) {
|
|
315
|
+
return t.constructor === String ? `<${t}${e}>` : t.map((r) => {
|
|
316
|
+
if (r.constructor === String)
|
|
317
|
+
return `<${r}${e}>`;
|
|
163
318
|
{
|
|
164
|
-
let
|
|
165
|
-
if (
|
|
166
|
-
for (let
|
|
167
|
-
let
|
|
168
|
-
|
|
319
|
+
let s = `<${r.tag}`;
|
|
320
|
+
if (r.attrs)
|
|
321
|
+
for (let o in r.attrs) {
|
|
322
|
+
let a = r.attrs[o];
|
|
323
|
+
a !== null && (s += ` ${o}="${a}"`);
|
|
169
324
|
}
|
|
170
|
-
return `${
|
|
325
|
+
return `${s}${e}>`;
|
|
171
326
|
}
|
|
172
327
|
}).join("");
|
|
173
328
|
}
|
|
174
|
-
renderOpeningTag(
|
|
175
|
-
return this.renderTag(
|
|
329
|
+
renderOpeningTag(t) {
|
|
330
|
+
return this.renderTag(t, "");
|
|
176
331
|
}
|
|
177
|
-
renderClosingTag(
|
|
178
|
-
|
|
179
|
-
return `</${e2}>`;
|
|
180
|
-
return e2.slice(0).reverse().map((e3) => e3.constructor === String ? `</${e3}>` : `</${e3.tag}>`).join("");
|
|
332
|
+
renderClosingTag(t) {
|
|
333
|
+
return t.constructor === String ? `</${t}>` : t.slice(0).reverse().map((e) => e.constructor === String ? `</${e}>` : `</${e.tag}>`).join("");
|
|
181
334
|
}
|
|
182
|
-
getMatchingNode(
|
|
183
|
-
if (typeof this.nodes[
|
|
184
|
-
return this.nodes[
|
|
335
|
+
getMatchingNode(t) {
|
|
336
|
+
if (typeof this.nodes[t.type] == "function")
|
|
337
|
+
return this.nodes[t.type](t);
|
|
185
338
|
}
|
|
186
|
-
getMatchingMark(
|
|
187
|
-
if (typeof this.marks[
|
|
188
|
-
return this.marks[
|
|
339
|
+
getMatchingMark(t) {
|
|
340
|
+
if (typeof this.marks[t.type] == "function")
|
|
341
|
+
return this.marks[t.type](t);
|
|
189
342
|
}
|
|
190
343
|
}
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
return ((
|
|
194
|
-
},
|
|
195
|
-
const
|
|
196
|
-
for (const
|
|
197
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
344
|
+
const W = (n = 0, t = n) => {
|
|
345
|
+
const e = Math.abs(t - n) || 0, r = n < t ? 1 : -1;
|
|
346
|
+
return ((s = 0, o) => [...Array(s)].map(o))(e, (s, o) => o * r + n);
|
|
347
|
+
}, k = (n, t, e) => {
|
|
348
|
+
const r = [];
|
|
349
|
+
for (const s in n) {
|
|
350
|
+
if (!Object.prototype.hasOwnProperty.call(n, s))
|
|
198
351
|
continue;
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
|
|
352
|
+
const o = n[s], a = e ? "" : encodeURIComponent(s);
|
|
353
|
+
let i;
|
|
354
|
+
i = typeof o == "object" ? k(o, t ? t + encodeURIComponent("[" + a + "]") : a, Array.isArray(o)) : (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(o), r.push(i);
|
|
202
355
|
}
|
|
203
|
-
return
|
|
356
|
+
return r.join("&");
|
|
204
357
|
};
|
|
205
|
-
let
|
|
206
|
-
class
|
|
207
|
-
constructor(
|
|
208
|
-
if (!
|
|
209
|
-
let
|
|
210
|
-
|
|
358
|
+
let f = {}, d = {};
|
|
359
|
+
class X {
|
|
360
|
+
constructor(t, e) {
|
|
361
|
+
if (!e) {
|
|
362
|
+
let o = t.region ? `-${t.region}` : "", a = t.https === !1 ? "http" : "https";
|
|
363
|
+
e = t.oauthToken === void 0 ? `${a}://api${o}.storyblok.com/v2` : `${a}://api${o}.storyblok.com/v1`;
|
|
211
364
|
}
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
setComponentResolver(
|
|
216
|
-
this.richTextResolver.addNode("blok", (
|
|
217
|
-
let
|
|
218
|
-
return
|
|
219
|
-
|
|
220
|
-
}), { html:
|
|
365
|
+
let r = Object.assign({}, t.headers), s = 5;
|
|
366
|
+
t.oauthToken !== void 0 && (r.Authorization = t.oauthToken, s = 3), t.rateLimit !== void 0 && (s = t.rateLimit), this.richTextResolver = new Q(t.richTextSchema), typeof t.componentResolver == "function" && this.setComponentResolver(t.componentResolver), this.maxRetries = t.maxRetries || 5, this.throttle = $(this.throttledRequest, s, 1e3), this.accessToken = t.accessToken, this.relations = {}, this.links = {}, this.cache = t.cache || { clear: "manual" }, this.client = q.create({ baseURL: e, timeout: t.timeout || 0, headers: r, proxy: t.proxy || !1 }), t.responseInterceptor && this.client.interceptors.response.use((o) => t.responseInterceptor(o)), this.resolveNestedRelations = t.resolveNestedRelations || !0;
|
|
367
|
+
}
|
|
368
|
+
setComponentResolver(t) {
|
|
369
|
+
this.richTextResolver.addNode("blok", (e) => {
|
|
370
|
+
let r = "";
|
|
371
|
+
return e.attrs.body.forEach((s) => {
|
|
372
|
+
r += t(s.component, s);
|
|
373
|
+
}), { html: r };
|
|
221
374
|
});
|
|
222
375
|
}
|
|
223
|
-
parseParams(
|
|
224
|
-
return
|
|
376
|
+
parseParams(t = {}) {
|
|
377
|
+
return t.version || (t.version = "published"), t.token || (t.token = this.getToken()), t.cv || (t.cv = d[t.token]), Array.isArray(t.resolve_relations) && (t.resolve_relations = t.resolve_relations.join(",")), t;
|
|
225
378
|
}
|
|
226
|
-
factoryParamOptions(
|
|
227
|
-
return ((
|
|
379
|
+
factoryParamOptions(t, e = {}) {
|
|
380
|
+
return ((r = "") => r.indexOf("/cdn/") > -1)(t) ? this.parseParams(e) : e;
|
|
228
381
|
}
|
|
229
|
-
makeRequest(
|
|
230
|
-
const
|
|
231
|
-
return this.cacheResponse(
|
|
382
|
+
makeRequest(t, e, r, s) {
|
|
383
|
+
const o = this.factoryParamOptions(t, ((a = {}, i = 25, c = 1) => y(h({}, a), { per_page: i, page: c }))(e, r, s));
|
|
384
|
+
return this.cacheResponse(t, o);
|
|
232
385
|
}
|
|
233
|
-
get(
|
|
234
|
-
let
|
|
235
|
-
const
|
|
236
|
-
return this.cacheResponse(
|
|
386
|
+
get(t, e) {
|
|
387
|
+
let r = `/${t}`;
|
|
388
|
+
const s = this.factoryParamOptions(r, e);
|
|
389
|
+
return this.cacheResponse(r, s);
|
|
237
390
|
}
|
|
238
|
-
async getAll(
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
return ((
|
|
391
|
+
async getAll(t, e = {}, r) {
|
|
392
|
+
const s = e.per_page || 25, o = `/${t}`, a = o.split("/");
|
|
393
|
+
r = r || a[a.length - 1];
|
|
394
|
+
const i = await this.makeRequest(o, e, s, 1), c = Math.ceil(i.total / s);
|
|
395
|
+
return ((l = [], u) => l.map(u).reduce((p, S) => [...p, ...S], []))([i, ...await (async (l = [], u) => Promise.all(l.map(u)))(W(1, c), async (l) => this.makeRequest(o, e, s, l + 1))], (l) => Object.values(l.data[r]));
|
|
243
396
|
}
|
|
244
|
-
post(
|
|
245
|
-
let
|
|
246
|
-
return this.throttle("post",
|
|
397
|
+
post(t, e) {
|
|
398
|
+
let r = `/${t}`;
|
|
399
|
+
return this.throttle("post", r, e);
|
|
247
400
|
}
|
|
248
|
-
put(
|
|
249
|
-
let
|
|
250
|
-
return this.throttle("put",
|
|
401
|
+
put(t, e) {
|
|
402
|
+
let r = `/${t}`;
|
|
403
|
+
return this.throttle("put", r, e);
|
|
251
404
|
}
|
|
252
|
-
delete(
|
|
253
|
-
let
|
|
254
|
-
return this.throttle("delete",
|
|
405
|
+
delete(t, e) {
|
|
406
|
+
let r = `/${t}`;
|
|
407
|
+
return this.throttle("delete", r, e);
|
|
255
408
|
}
|
|
256
|
-
getStories(
|
|
257
|
-
return this.get("cdn/stories",
|
|
409
|
+
getStories(t) {
|
|
410
|
+
return this.get("cdn/stories", t);
|
|
258
411
|
}
|
|
259
|
-
getStory(
|
|
260
|
-
return this.get(`cdn/stories/${
|
|
412
|
+
getStory(t, e) {
|
|
413
|
+
return this.get(`cdn/stories/${t}`, e);
|
|
261
414
|
}
|
|
262
|
-
setToken(
|
|
263
|
-
this.accessToken =
|
|
415
|
+
setToken(t) {
|
|
416
|
+
this.accessToken = t;
|
|
264
417
|
}
|
|
265
418
|
getToken() {
|
|
266
419
|
return this.accessToken;
|
|
267
420
|
}
|
|
268
|
-
_cleanCopy(
|
|
269
|
-
return JSON.parse(JSON.stringify(
|
|
270
|
-
}
|
|
271
|
-
_insertLinks(
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
_insertRelations(
|
|
276
|
-
if (
|
|
277
|
-
if (typeof
|
|
278
|
-
this.relations[
|
|
279
|
-
else if (
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
this.relations[
|
|
283
|
-
}),
|
|
421
|
+
_cleanCopy(t) {
|
|
422
|
+
return JSON.parse(JSON.stringify(t));
|
|
423
|
+
}
|
|
424
|
+
_insertLinks(t, e) {
|
|
425
|
+
const r = t[e];
|
|
426
|
+
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
|
|
427
|
+
}
|
|
428
|
+
_insertRelations(t, e, r) {
|
|
429
|
+
if (r.indexOf(t.component + "." + e) > -1) {
|
|
430
|
+
if (typeof t[e] == "string")
|
|
431
|
+
this.relations[t[e]] && (t[e] = this._cleanCopy(this.relations[t[e]]));
|
|
432
|
+
else if (t[e].constructor === Array) {
|
|
433
|
+
let s = [];
|
|
434
|
+
t[e].forEach((o) => {
|
|
435
|
+
this.relations[o] && s.push(this._cleanCopy(this.relations[o]));
|
|
436
|
+
}), t[e] = s;
|
|
284
437
|
}
|
|
285
438
|
}
|
|
286
439
|
}
|
|
287
|
-
_insertAssetsRelations(
|
|
288
|
-
|
|
289
|
-
|
|
440
|
+
_insertAssetsRelations(t, e) {
|
|
441
|
+
e.forEach((r) => {
|
|
442
|
+
t.id === r.id && (t.original = r, t.original.filename = t.filename, t.original.filename = t.original.filename.includes("https://s3.amazonaws.com/") ? t.original.filename : t.original.filename.replace("https://", "https://s3.amazonaws.com/"), delete t.original.s3_filename);
|
|
290
443
|
});
|
|
291
444
|
}
|
|
292
|
-
iterateTree(
|
|
293
|
-
let
|
|
294
|
-
if (
|
|
295
|
-
if (
|
|
296
|
-
for (let
|
|
297
|
-
|
|
298
|
-
else if (
|
|
299
|
-
if (
|
|
445
|
+
iterateTree(t, e) {
|
|
446
|
+
let r = (s) => {
|
|
447
|
+
if (s != null) {
|
|
448
|
+
if (s.constructor === Array)
|
|
449
|
+
for (let o = 0; o < s.length; o++)
|
|
450
|
+
r(s[o]);
|
|
451
|
+
else if (s.constructor === Object) {
|
|
452
|
+
if (s._stopResolving)
|
|
300
453
|
return;
|
|
301
|
-
for (let
|
|
302
|
-
|
|
454
|
+
for (let o in s)
|
|
455
|
+
s.component && s._uid || s.type === "link" ? (this._insertRelations(s, o, e), this._insertLinks(s, o)) : "id" in s && s.fieldtype === "asset" && this._insertAssetsRelations(s, e), r(s[o]);
|
|
303
456
|
}
|
|
304
457
|
}
|
|
305
458
|
};
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
async resolveLinks(
|
|
309
|
-
let
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
312
|
-
let
|
|
313
|
-
const
|
|
314
|
-
for (let
|
|
315
|
-
const
|
|
316
|
-
|
|
459
|
+
r(t.content);
|
|
460
|
+
}
|
|
461
|
+
async resolveLinks(t, e) {
|
|
462
|
+
let r = [];
|
|
463
|
+
if (t.link_uuids) {
|
|
464
|
+
const s = t.link_uuids.length;
|
|
465
|
+
let o = [];
|
|
466
|
+
const a = 50;
|
|
467
|
+
for (let i = 0; i < s; i += a) {
|
|
468
|
+
const c = Math.min(s, i + a);
|
|
469
|
+
o.push(t.link_uuids.slice(i, c));
|
|
317
470
|
}
|
|
318
|
-
for (let
|
|
319
|
-
(await this.getStories({ per_page:
|
|
320
|
-
|
|
471
|
+
for (let i = 0; i < o.length; i++)
|
|
472
|
+
(await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
|
|
473
|
+
r.push(c);
|
|
321
474
|
});
|
|
322
|
-
}
|
|
323
475
|
} else
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
this.links[
|
|
476
|
+
r = t.links;
|
|
477
|
+
r.forEach((s) => {
|
|
478
|
+
this.links[s.uuid] = y(h({}, s), { _stopResolving: !0 });
|
|
327
479
|
});
|
|
328
480
|
}
|
|
329
|
-
async resolveRelations(
|
|
330
|
-
let
|
|
331
|
-
if (
|
|
332
|
-
const
|
|
333
|
-
let
|
|
334
|
-
const
|
|
335
|
-
for (let
|
|
336
|
-
const
|
|
337
|
-
|
|
481
|
+
async resolveRelations(t, e) {
|
|
482
|
+
let r = [];
|
|
483
|
+
if (t.rel_uuids) {
|
|
484
|
+
const s = t.rel_uuids.length;
|
|
485
|
+
let o = [];
|
|
486
|
+
const a = 50;
|
|
487
|
+
for (let i = 0; i < s; i += a) {
|
|
488
|
+
const c = Math.min(s, i + a);
|
|
489
|
+
o.push(t.rel_uuids.slice(i, c));
|
|
338
490
|
}
|
|
339
|
-
for (let
|
|
340
|
-
(await this.getStories({ per_page:
|
|
341
|
-
|
|
491
|
+
for (let i = 0; i < o.length; i++)
|
|
492
|
+
(await this.getStories({ per_page: a, language: e.language, version: e.version, by_uuids: o[i].join(",") })).data.stories.forEach((c) => {
|
|
493
|
+
r.push(c);
|
|
342
494
|
});
|
|
343
|
-
}
|
|
344
495
|
} else
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
this.relations[
|
|
496
|
+
r = t.rels;
|
|
497
|
+
r.forEach((s) => {
|
|
498
|
+
this.relations[s.uuid] = y(h({}, s), { _stopResolving: !0 });
|
|
348
499
|
});
|
|
349
500
|
}
|
|
350
|
-
async resolveStories(
|
|
351
|
-
let
|
|
352
|
-
if (
|
|
353
|
-
for (const
|
|
354
|
-
this.iterateTree(this.relations[
|
|
355
|
-
|
|
356
|
-
this.iterateTree(
|
|
501
|
+
async resolveStories(t, e) {
|
|
502
|
+
let r = [];
|
|
503
|
+
if (e.resolve_relations !== void 0 && e.resolve_relations.length > 0 && (t.rels || t.rel_uuids) && (r = e.resolve_relations.split(","), await this.resolveRelations(t, e)), ["1", "story", "url"].indexOf(e.resolve_links) > -1 && (t.links || t.link_uuids) && await this.resolveLinks(t, e), this.resolveNestedRelations)
|
|
504
|
+
for (const s in this.relations)
|
|
505
|
+
this.iterateTree(this.relations[s], r);
|
|
506
|
+
t.story ? this.iterateTree(t.story, r) : t.stories.forEach((s) => {
|
|
507
|
+
this.iterateTree(s, r);
|
|
357
508
|
});
|
|
358
509
|
}
|
|
359
|
-
resolveAssetsRelations(
|
|
360
|
-
const { assets:
|
|
361
|
-
if (
|
|
362
|
-
for (const
|
|
363
|
-
this.iterateTree(
|
|
364
|
-
else
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
510
|
+
resolveAssetsRelations(t) {
|
|
511
|
+
const { assets: e, stories: r, story: s } = t;
|
|
512
|
+
if (r)
|
|
513
|
+
for (const o of r)
|
|
514
|
+
this.iterateTree(o, e);
|
|
515
|
+
else {
|
|
516
|
+
if (!s)
|
|
517
|
+
return t;
|
|
518
|
+
this.iterateTree(s, e);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
cacheResponse(t, e, r) {
|
|
522
|
+
return r === void 0 && (r = 0), new Promise(async (s, o) => {
|
|
523
|
+
let a = k({ url: t, params: e }), i = this.cacheProvider();
|
|
524
|
+
if (this.cache.clear === "auto" && e.version === "draft" && await this.flushCache(), e.version === "published" && t != "/cdn/spaces/me") {
|
|
525
|
+
const l = await i.get(a);
|
|
526
|
+
if (l)
|
|
527
|
+
return s(l);
|
|
374
528
|
}
|
|
375
529
|
try {
|
|
376
|
-
let
|
|
377
|
-
if (
|
|
378
|
-
return
|
|
379
|
-
(
|
|
380
|
-
} catch (
|
|
381
|
-
if (
|
|
382
|
-
return console.log(`Hit rate limit. Retrying in ${
|
|
383
|
-
|
|
530
|
+
let l = await this.throttle("get", t, { params: e, paramsSerializer: (p) => k(p) }), u = { data: l.data, headers: l.headers };
|
|
531
|
+
if (u.data.assets && u.data.assets.length && this.resolveAssetsRelations(u.data), l.headers["per-page"] && (u = Object.assign({}, u, { perPage: parseInt(l.headers["per-page"]), total: parseInt(l.headers.total) })), l.status != 200)
|
|
532
|
+
return o(l);
|
|
533
|
+
(u.data.story || u.data.stories) && await this.resolveStories(u.data, e), e.version === "published" && t != "/cdn/spaces/me" && i.set(a, u), u.data.cv && (e.version == "draft" && d[e.token] != u.data.cv && this.flushCache(), d[e.token] = u.data.cv), s(u);
|
|
534
|
+
} catch (l) {
|
|
535
|
+
if (l.response && l.response.status === 429 && (r += 1) < this.maxRetries)
|
|
536
|
+
return console.log(`Hit rate limit. Retrying in ${r} seconds.`), await (c = 1e3 * r, new Promise((u) => setTimeout(u, c))), this.cacheResponse(t, e, r).then(s).catch(o);
|
|
537
|
+
o(l);
|
|
384
538
|
}
|
|
385
|
-
var
|
|
539
|
+
var c;
|
|
386
540
|
});
|
|
387
541
|
}
|
|
388
|
-
throttledRequest(
|
|
389
|
-
return this.client[
|
|
542
|
+
throttledRequest(t, e, r) {
|
|
543
|
+
return this.client[t](e, r);
|
|
390
544
|
}
|
|
391
545
|
cacheVersions() {
|
|
392
|
-
return
|
|
546
|
+
return d;
|
|
393
547
|
}
|
|
394
548
|
cacheVersion() {
|
|
395
|
-
return
|
|
549
|
+
return d[this.accessToken];
|
|
396
550
|
}
|
|
397
|
-
setCacheVersion(
|
|
398
|
-
this.accessToken && (
|
|
551
|
+
setCacheVersion(t) {
|
|
552
|
+
this.accessToken && (d[this.accessToken] = t);
|
|
399
553
|
}
|
|
400
554
|
cacheProvider() {
|
|
401
|
-
return this.cache.type === "memory" ? { get: (
|
|
402
|
-
|
|
555
|
+
return this.cache.type === "memory" ? { get: (t) => f[t], getAll: () => f, set(t, e) {
|
|
556
|
+
f[t] = e;
|
|
403
557
|
}, flush() {
|
|
404
|
-
|
|
558
|
+
f = {};
|
|
405
559
|
} } : { get() {
|
|
406
560
|
}, getAll() {
|
|
407
561
|
}, set() {
|
|
@@ -412,113 +566,126 @@ class h {
|
|
|
412
566
|
return await this.cacheProvider().flush(), this;
|
|
413
567
|
}
|
|
414
568
|
}
|
|
415
|
-
const
|
|
416
|
-
const { apiOptions } =
|
|
417
|
-
if (!
|
|
569
|
+
const at = (n = {}) => {
|
|
570
|
+
const { apiOptions: t } = n;
|
|
571
|
+
if (!t.accessToken) {
|
|
418
572
|
console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");
|
|
419
573
|
return;
|
|
420
574
|
}
|
|
421
|
-
|
|
422
|
-
return { storyblokApi };
|
|
575
|
+
return { storyblokApi: new X(t) };
|
|
423
576
|
};
|
|
424
|
-
var
|
|
425
|
-
if (typeof
|
|
577
|
+
var Z = (n) => {
|
|
578
|
+
if (typeof n != "object" || typeof n._editable > "u")
|
|
426
579
|
return {};
|
|
427
|
-
|
|
428
|
-
const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
580
|
+
const t = JSON.parse(n._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
429
581
|
return {
|
|
430
|
-
"data-blok-c": JSON.stringify(
|
|
431
|
-
"data-blok-uid":
|
|
582
|
+
"data-blok-c": JSON.stringify(t),
|
|
583
|
+
"data-blok-uid": t.id + "-" + t.uid
|
|
432
584
|
};
|
|
433
585
|
};
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
if (typeof window
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
sbBridge.on(["input", "published", "change"], (event) => {
|
|
450
|
-
if (event.action == "input" && event.story.id === id) {
|
|
451
|
-
cb(event.story);
|
|
452
|
-
} else {
|
|
453
|
-
window.location.reload();
|
|
454
|
-
}
|
|
586
|
+
let m;
|
|
587
|
+
const tt = "https://app.storyblok.com/f/storyblok-v2-latest.js", et = (n, t, e = {}) => {
|
|
588
|
+
if (!(typeof window > "u")) {
|
|
589
|
+
if (typeof window.storyblokRegisterEvent > "u") {
|
|
590
|
+
console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (!n) {
|
|
594
|
+
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
window.storyblokRegisterEvent(() => {
|
|
598
|
+
new window.StoryblokBridge(e).on(["input", "published", "change"], (s) => {
|
|
599
|
+
s.story.id === n && (s.action === "input" ? t(s.story) : window.location.reload());
|
|
600
|
+
});
|
|
455
601
|
});
|
|
602
|
+
}
|
|
603
|
+
}, rt = (n = {}) => {
|
|
604
|
+
const {
|
|
605
|
+
bridge: t,
|
|
606
|
+
accessToken: e,
|
|
607
|
+
use: r = [],
|
|
608
|
+
apiOptions: s = {},
|
|
609
|
+
richText: o = {}
|
|
610
|
+
} = n;
|
|
611
|
+
s.accessToken = s.accessToken || e;
|
|
612
|
+
const a = { bridge: t, apiOptions: s };
|
|
613
|
+
let i = {};
|
|
614
|
+
return r.forEach((c) => {
|
|
615
|
+
i = h(h({}, i), c(a));
|
|
616
|
+
}), t !== !1 && V(tt), m = new R(o.schema), o.resolver && E(m, o.resolver), i;
|
|
617
|
+
}, E = (n, t) => {
|
|
618
|
+
n.addNode("blok", (e) => {
|
|
619
|
+
let r = "";
|
|
620
|
+
return e.attrs.body.forEach((s) => {
|
|
621
|
+
r += t(s.component, s);
|
|
622
|
+
}), {
|
|
623
|
+
html: r
|
|
624
|
+
};
|
|
456
625
|
});
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const options = { bridge, apiOptions };
|
|
462
|
-
let result = {};
|
|
463
|
-
use.forEach((pluginFactory) => {
|
|
464
|
-
result = __spreadValues2(__spreadValues2({}, result), pluginFactory(options));
|
|
465
|
-
});
|
|
466
|
-
if (bridge !== false) {
|
|
467
|
-
loadBridge(bridgeLatest);
|
|
626
|
+
}, lt = (n, t) => {
|
|
627
|
+
if (!m) {
|
|
628
|
+
console.error("Please initialize the Storyblok SDK before calling the renderRichText function");
|
|
629
|
+
return;
|
|
468
630
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
631
|
+
if (n === "")
|
|
632
|
+
return "";
|
|
633
|
+
if (!n)
|
|
634
|
+
return console.warn(`${n} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
635
|
+
|
|
636
|
+
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "";
|
|
637
|
+
let e = m;
|
|
638
|
+
return t && (e = new R(t.schema), t.resolver && E(e, t.resolver)), e.render(n);
|
|
639
|
+
}, st = /* @__PURE__ */ P({
|
|
472
640
|
__name: "StoryblokComponent",
|
|
473
641
|
props: {
|
|
474
642
|
blok: null
|
|
475
643
|
},
|
|
476
|
-
setup(
|
|
477
|
-
return (
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
if (binding.value) {
|
|
485
|
-
const options = editable(binding.value);
|
|
486
|
-
el.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
487
|
-
el.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
488
|
-
el.classList.add("storyblok__outline");
|
|
644
|
+
setup(n) {
|
|
645
|
+
return (t, e) => (j(), x(A(n.blok.component), C(M({ ...t.$props, ...t.$attrs })), null, 16));
|
|
646
|
+
}
|
|
647
|
+
}), nt = {
|
|
648
|
+
beforeMount(n, t) {
|
|
649
|
+
if (t.value) {
|
|
650
|
+
const e = Z(t.value);
|
|
651
|
+
n.setAttribute("data-blok-c", e["data-blok-c"]), n.setAttribute("data-blok-uid", e["data-blok-uid"]), n.classList.add("storyblok__outline");
|
|
489
652
|
}
|
|
490
653
|
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
console.error(`You can't use ${fnName} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
654
|
+
}, O = (n) => {
|
|
655
|
+
console.error(`You can't use ${n} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
|
|
494
656
|
`);
|
|
495
657
|
};
|
|
496
|
-
let
|
|
497
|
-
const useStoryblokApi = () => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
story.value = data.story;
|
|
658
|
+
let g = null;
|
|
659
|
+
const ct = () => (g || O("useStoryblokApi"), g), ut = async (n, t = {}, e = {}) => {
|
|
660
|
+
const r = N(null);
|
|
661
|
+
if (I(() => {
|
|
662
|
+
r.value && r.value.id && et(
|
|
663
|
+
r.value.id,
|
|
664
|
+
(s) => r.value = s,
|
|
665
|
+
e
|
|
666
|
+
);
|
|
667
|
+
}), g) {
|
|
668
|
+
const { data: s } = await g.get(
|
|
669
|
+
`cdn/stories/${n}`,
|
|
670
|
+
t
|
|
671
|
+
);
|
|
672
|
+
r.value = s.story;
|
|
512
673
|
} else
|
|
513
|
-
|
|
514
|
-
return
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const { storyblokApi } = storyblokInit(pluginOptions);
|
|
521
|
-
storyblokApiInstance = storyblokApi;
|
|
674
|
+
O("useStoryblok");
|
|
675
|
+
return r;
|
|
676
|
+
}, ht = {
|
|
677
|
+
install(n, t = {}) {
|
|
678
|
+
n.directive("editable", nt), n.component("StoryblokComponent", st);
|
|
679
|
+
const { storyblokApi: e } = rt(t);
|
|
680
|
+
g = e;
|
|
522
681
|
}
|
|
523
682
|
};
|
|
524
|
-
export {
|
|
683
|
+
export {
|
|
684
|
+
st as StoryblokComponent,
|
|
685
|
+
ht as StoryblokVue,
|
|
686
|
+
at as apiPlugin,
|
|
687
|
+
lt as renderRichText,
|
|
688
|
+
ut as useStoryblok,
|
|
689
|
+
ct as useStoryblokApi,
|
|
690
|
+
et as useStoryblokBridge
|
|
691
|
+
};
|