@storyblok/astro 7.2.1 → 7.2.4
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 +39 -389
- package/dist/storyblok-astro.es.js +294 -259
- package/dist/storyblok-astro.umd.js +8 -8
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const te = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
2
2
|
<g id="storyblok-logo-kit" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
3
3
|
<g id="storyblok-partner-logo" transform="translate(-59.000000, -169.000000)" fill-rule="nonzero">
|
|
4
4
|
<g id="storyblok-symbol" transform="translate(59.000000, 169.000000)">
|
|
@@ -7,74 +7,74 @@ const ee = `<svg width="45px" height="53px" viewBox="0 0 45 53" version="1.1" xm
|
|
|
7
7
|
</g>
|
|
8
8
|
</g>
|
|
9
9
|
</g>
|
|
10
|
-
</svg>`,
|
|
11
|
-
let
|
|
10
|
+
</svg>`, re = /[\p{Lu}]/u, oe = /[\p{Ll}]/u, M = /^[\p{Lu}](?![\p{Lu}])/gu, G = /([\p{Alpha}\p{N}_]|$)/u, O = /[_.\- ]+/, se = new RegExp("^" + O.source), P = new RegExp(O.source + G.source, "gu"), j = new RegExp("\\d+" + G.source, "gu"), ne = (e, t, r, n) => {
|
|
11
|
+
let a = !1, s = !1, h = !1, p = !1;
|
|
12
12
|
for (let i = 0; i < e.length; i++) {
|
|
13
|
-
const
|
|
14
|
-
p = i > 2 ? e[i - 3] === "-" : !0,
|
|
13
|
+
const d = e[i];
|
|
14
|
+
p = i > 2 ? e[i - 3] === "-" : !0, a && re.test(d) ? (e = e.slice(0, i) + "-" + e.slice(i), a = !1, h = s, s = !0, i++) : s && h && oe.test(d) && (!p || n) ? (e = e.slice(0, i - 1) + "-" + e.slice(i - 1), h = s, s = !1, a = !0) : (a = t(d) === d && r(d) !== d, h = s, s = r(d) === d && t(d) !== d);
|
|
15
15
|
}
|
|
16
16
|
return e;
|
|
17
|
-
},
|
|
18
|
-
function
|
|
17
|
+
}, ae = (e, t) => (M.lastIndex = 0, e.replaceAll(M, (r) => t(r))), le = (e, t) => (P.lastIndex = 0, j.lastIndex = 0, e.replaceAll(j, (r, n, a) => ["_", "-"].includes(e.charAt(a + r.length)) ? r : t(r)).replaceAll(P, (r, n) => t(n)));
|
|
18
|
+
function ie(e, t) {
|
|
19
19
|
if (!(typeof e == "string" || Array.isArray(e)))
|
|
20
20
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
21
21
|
if (t = {
|
|
22
22
|
pascalCase: !1,
|
|
23
23
|
preserveConsecutiveUppercase: !1,
|
|
24
24
|
...t
|
|
25
|
-
}, Array.isArray(e) ? e = e.map((
|
|
25
|
+
}, Array.isArray(e) ? e = e.map((s) => s.trim()).filter((s) => s.length).join("-") : e = e.trim(), e.length === 0)
|
|
26
26
|
return "";
|
|
27
|
-
const
|
|
28
|
-
return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) :
|
|
27
|
+
const r = t.locale === !1 ? (s) => s.toLowerCase() : (s) => s.toLocaleLowerCase(t.locale), n = t.locale === !1 ? (s) => s.toUpperCase() : (s) => s.toLocaleUpperCase(t.locale);
|
|
28
|
+
return e.length === 1 ? O.test(e) ? "" : t.pascalCase ? n(e) : r(e) : (e !== r(e) && (e = ne(e, r, n, t.preserveConsecutiveUppercase)), e = e.replace(se, ""), e = t.preserveConsecutiveUppercase ? ae(e, r) : r(e), t.pascalCase && (e = n(e.charAt(0)) + e.slice(1)), le(e, n));
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
30
|
+
function D(e) {
|
|
31
|
+
return ie(e);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
33
|
+
function ce(e, t = {}, r, n) {
|
|
34
|
+
const a = "virtual:storyblok-components", s = `\0${a}`;
|
|
35
35
|
return {
|
|
36
36
|
name: "vite-plugin-storyblok-components",
|
|
37
|
-
async resolveId(
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
37
|
+
async resolveId(h) {
|
|
38
|
+
if (h === a)
|
|
39
|
+
return s;
|
|
40
40
|
},
|
|
41
|
-
async load(
|
|
42
|
-
if (
|
|
41
|
+
async load(h) {
|
|
42
|
+
if (h === s) {
|
|
43
43
|
const p = [], i = [];
|
|
44
|
-
for await (const [
|
|
45
|
-
const
|
|
44
|
+
for await (const [b, E] of Object.entries(t)) {
|
|
45
|
+
const A = await this.resolve(
|
|
46
46
|
`/${e}/${E}.astro`
|
|
47
47
|
);
|
|
48
|
-
if (
|
|
49
|
-
p.push(`import ${
|
|
50
|
-
else if (
|
|
51
|
-
i.push(
|
|
48
|
+
if (A)
|
|
49
|
+
p.push(`import ${D(b)} from "${A.id}"`);
|
|
50
|
+
else if (r)
|
|
51
|
+
i.push(b);
|
|
52
52
|
else
|
|
53
53
|
throw new Error(
|
|
54
|
-
`Component could not be found for blok "${
|
|
54
|
+
`Component could not be found for blok "${b}"! Does "${`/${e}/${E}`}.astro" exist?`
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
let
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
57
|
+
let d = "";
|
|
58
|
+
if (r)
|
|
59
|
+
if (d = ",FallbackComponent", n) {
|
|
60
|
+
const b = await this.resolve(
|
|
61
61
|
`/${e}/${n}.astro`
|
|
62
62
|
);
|
|
63
|
-
if (!
|
|
63
|
+
if (!b)
|
|
64
64
|
throw new Error(
|
|
65
65
|
`Custom fallback component could not be found. Does "${`/${e}/${n}`}.astro" exist?`
|
|
66
66
|
);
|
|
67
67
|
p.push(
|
|
68
|
-
`import FallbackComponent from "${
|
|
68
|
+
`import FallbackComponent from "${b.id}"`
|
|
69
69
|
);
|
|
70
70
|
} else
|
|
71
71
|
p.push(
|
|
72
72
|
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
73
73
|
);
|
|
74
74
|
if (Object.values(t).length)
|
|
75
|
-
return `${p.join(";")};export default {${Object.keys(t).filter((
|
|
76
|
-
if (
|
|
77
|
-
return `${p[0]}; export default {${
|
|
75
|
+
return `${p.join(";")};export default {${Object.keys(t).filter((b) => !i.includes(b)).map((b) => D(b)).join(",")}${d}}`;
|
|
76
|
+
if (r)
|
|
77
|
+
return `${p[0]}; export default {${d.replace(",", "")}}`;
|
|
78
78
|
throw new Error(
|
|
79
79
|
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
80
80
|
Please register your components or enable the fallback component.
|
|
@@ -84,22 +84,22 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const n = "virtual:storyblok-init",
|
|
87
|
+
function ue(e, t, r) {
|
|
88
|
+
const n = "virtual:storyblok-init", a = `\0${n}`;
|
|
89
89
|
return {
|
|
90
90
|
name: "vite-plugin-storyblok-init",
|
|
91
|
-
async resolveId(
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
91
|
+
async resolveId(s) {
|
|
92
|
+
if (s === n)
|
|
93
|
+
return a;
|
|
94
94
|
},
|
|
95
|
-
async load(
|
|
96
|
-
if (
|
|
95
|
+
async load(s) {
|
|
96
|
+
if (s === a)
|
|
97
97
|
return `
|
|
98
98
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
99
99
|
const { storyblokApi } = storyblokInit({
|
|
100
100
|
accessToken: "${e}",
|
|
101
101
|
use: ${t ? "[]" : "[apiPlugin]"},
|
|
102
|
-
apiOptions: ${JSON.stringify(
|
|
102
|
+
apiOptions: ${JSON.stringify(r)},
|
|
103
103
|
});
|
|
104
104
|
export const storyblokApiInstance = storyblokApi;
|
|
105
105
|
`;
|
|
@@ -107,32 +107,32 @@ function ce(e, t, s) {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
function de(e) {
|
|
110
|
-
const t = "virtual:storyblok-options",
|
|
110
|
+
const t = "virtual:storyblok-options", r = `\0${t}`;
|
|
111
111
|
return {
|
|
112
112
|
name: "vite-plugin-storyblok-options",
|
|
113
113
|
async resolveId(n) {
|
|
114
114
|
if (n === t)
|
|
115
|
-
return
|
|
115
|
+
return r;
|
|
116
116
|
},
|
|
117
117
|
async load(n) {
|
|
118
|
-
if (n ===
|
|
118
|
+
if (n === r)
|
|
119
119
|
return `export default ${JSON.stringify(e)}`;
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function _e() {
|
|
124
124
|
if (!(globalThis != null && globalThis.storyblokApiInstance))
|
|
125
125
|
throw new Error("storyblokApiInstance has not been initialized correctly");
|
|
126
126
|
return globalThis.storyblokApiInstance;
|
|
127
127
|
}
|
|
128
|
-
async function
|
|
128
|
+
async function Be(e) {
|
|
129
129
|
let t = null;
|
|
130
130
|
return e && e.locals._storyblok_preview_data && (t = e.locals._storyblok_preview_data), t;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function pe(e) {
|
|
133
133
|
return typeof e == "object" ? `const storyblokInstance = new StoryblokBridge(${JSON.stringify(e)});` : "const storyblokInstance = new StoryblokBridge();";
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function Ne(e) {
|
|
136
136
|
const t = {
|
|
137
137
|
useCustomApi: !1,
|
|
138
138
|
bridge: !0,
|
|
@@ -140,26 +140,26 @@ function Le(e) {
|
|
|
140
140
|
enableFallbackComponent: !1,
|
|
141
141
|
livePreview: !1,
|
|
142
142
|
...e
|
|
143
|
-
},
|
|
143
|
+
}, r = pe(t.bridge);
|
|
144
144
|
return {
|
|
145
145
|
name: "@storyblok/astro",
|
|
146
146
|
hooks: {
|
|
147
147
|
"astro:config:setup": ({
|
|
148
148
|
injectScript: n,
|
|
149
|
-
updateConfig:
|
|
150
|
-
addDevToolbarApp:
|
|
151
|
-
addMiddleware:
|
|
149
|
+
updateConfig: a,
|
|
150
|
+
addDevToolbarApp: s,
|
|
151
|
+
addMiddleware: h,
|
|
152
152
|
config: p
|
|
153
153
|
}) => {
|
|
154
|
-
if (
|
|
154
|
+
if (a({
|
|
155
155
|
vite: {
|
|
156
156
|
plugins: [
|
|
157
|
-
|
|
157
|
+
ue(
|
|
158
158
|
t.accessToken,
|
|
159
159
|
t.useCustomApi,
|
|
160
160
|
t.apiOptions
|
|
161
161
|
),
|
|
162
|
-
|
|
162
|
+
ce(
|
|
163
163
|
t.componentsDir,
|
|
164
164
|
t.components,
|
|
165
165
|
t.enableFallbackComponent,
|
|
@@ -183,7 +183,7 @@ function Le(e) {
|
|
|
183
183
|
`import { loadStoryblokBridge } from "@storyblok/astro";
|
|
184
184
|
loadStoryblokBridge().then(() => {
|
|
185
185
|
const { StoryblokBridge, location } = window;
|
|
186
|
-
${
|
|
186
|
+
${r}
|
|
187
187
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
188
188
|
if (!event.slugChanged) {
|
|
189
189
|
location.reload(true);
|
|
@@ -196,49 +196,49 @@ function Le(e) {
|
|
|
196
196
|
`import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
197
197
|
loadStoryblokBridge().then(() => {
|
|
198
198
|
const { StoryblokBridge, location } = window;
|
|
199
|
-
${
|
|
199
|
+
${r}
|
|
200
200
|
storyblokInstance.on(["published", "change", "input"], handleStoryblokMessage);
|
|
201
201
|
});
|
|
202
202
|
`
|
|
203
|
-
),
|
|
203
|
+
), h({
|
|
204
204
|
entrypoint: "@storyblok/astro/middleware.ts",
|
|
205
205
|
order: "pre"
|
|
206
|
-
})),
|
|
206
|
+
})), s({
|
|
207
207
|
id: "storyblok",
|
|
208
208
|
name: "Storyblok",
|
|
209
|
-
icon:
|
|
209
|
+
icon: te,
|
|
210
210
|
entrypoint: "@storyblok/astro/toolbarApp.ts"
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
let
|
|
217
|
-
async function
|
|
218
|
-
const { action: t, story:
|
|
219
|
-
if (t === "input" &&
|
|
216
|
+
let U;
|
|
217
|
+
async function Me(e) {
|
|
218
|
+
const { action: t, story: r } = e || {};
|
|
219
|
+
if (t === "input" && r) {
|
|
220
220
|
const n = async () => {
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
221
|
+
const s = await be(r), h = document.body;
|
|
222
|
+
if (s.outerHTML === h.outerHTML)
|
|
223
223
|
return;
|
|
224
224
|
const p = document.querySelector('[data-blok-focused="true"]');
|
|
225
|
-
|
|
225
|
+
he(h, s, p), document.dispatchEvent(new Event("storyblok-live-preview-updated"));
|
|
226
226
|
};
|
|
227
|
-
clearTimeout(
|
|
227
|
+
clearTimeout(U), U = setTimeout(n, 500);
|
|
228
228
|
}
|
|
229
229
|
["published", "change"].includes(e == null ? void 0 : e.action) && location.reload();
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
if (
|
|
233
|
-
const n =
|
|
231
|
+
function he(e, t, r) {
|
|
232
|
+
if (r) {
|
|
233
|
+
const n = r.getAttribute("data-blok-uid"), a = t.querySelector(
|
|
234
234
|
`[data-blok-uid="${n}"]`
|
|
235
235
|
);
|
|
236
|
-
|
|
236
|
+
a && (a.setAttribute("data-blok-focused", "true"), r.replaceWith(a));
|
|
237
237
|
} else
|
|
238
238
|
e.replaceWith(t);
|
|
239
239
|
}
|
|
240
240
|
async function be(e) {
|
|
241
|
-
const
|
|
241
|
+
const r = await (await fetch(location.href, {
|
|
242
242
|
method: "POST",
|
|
243
243
|
body: JSON.stringify({
|
|
244
244
|
...e,
|
|
@@ -248,41 +248,95 @@ async function be(e) {
|
|
|
248
248
|
"Content-Type": "application/json"
|
|
249
249
|
}
|
|
250
250
|
})).text();
|
|
251
|
-
return new DOMParser().parseFromString(
|
|
251
|
+
return new DOMParser().parseFromString(r, "text/html").body;
|
|
252
|
+
}
|
|
253
|
+
function I(e, t, r) {
|
|
254
|
+
this.type = e, this.tag = t, this.attrs = null, this.map = null, this.nesting = r, this.level = 0, this.children = null, this.content = "", this.markup = "", this.info = "", this.meta = null, this.block = !1, this.hidden = !1;
|
|
252
255
|
}
|
|
253
|
-
function
|
|
254
|
-
if (!
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
I.prototype.attrIndex = function(e) {
|
|
257
|
+
if (!this.attrs)
|
|
258
|
+
return -1;
|
|
259
|
+
const t = this.attrs;
|
|
260
|
+
for (let r = 0, n = t.length; r < n; r++)
|
|
261
|
+
if (t[r][0] === e)
|
|
262
|
+
return r;
|
|
263
|
+
return -1;
|
|
264
|
+
};
|
|
265
|
+
I.prototype.attrPush = function(e) {
|
|
266
|
+
this.attrs ? this.attrs.push(e) : this.attrs = [e];
|
|
267
|
+
};
|
|
268
|
+
I.prototype.attrSet = function(e, t) {
|
|
269
|
+
const r = this.attrIndex(e), n = [e, t];
|
|
270
|
+
r < 0 ? this.attrPush(n) : this.attrs[r] = n;
|
|
271
|
+
};
|
|
272
|
+
I.prototype.attrGet = function(e) {
|
|
273
|
+
const t = this.attrIndex(e);
|
|
274
|
+
let r = null;
|
|
275
|
+
return t >= 0 && (r = this.attrs[t][1]), r;
|
|
276
|
+
};
|
|
277
|
+
I.prototype.attrJoin = function(e, t) {
|
|
278
|
+
const r = this.attrIndex(e);
|
|
279
|
+
r < 0 ? this.attrPush([e, t]) : this.attrs[r][1] = this.attrs[r][1] + " " + t;
|
|
280
|
+
};
|
|
281
|
+
const ye = "[a-zA-Z_:][a-zA-Z0-9:._-]*", fe = "[^\"'=<>`\\x00-\\x20]+", ge = "'[^']*'", me = '"[^"]*"', ke = "(?:" + fe + "|" + ge + "|" + me + ")", we = "(?:\\s+" + ye + "(?:\\s*=\\s*" + ke + ")?)", Ce = "<[A-Za-z][A-Za-z0-9\\-]*" + we + "*\\s*\\/?>", ve = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>", Ee = new RegExp("^(?:" + Ce + "|" + ve + ")");
|
|
282
|
+
new RegExp(Ee.source + "\\s*$");
|
|
283
|
+
const K = [];
|
|
284
|
+
for (let e = 0; e < 256; e++)
|
|
285
|
+
K.push(0);
|
|
286
|
+
"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e) {
|
|
287
|
+
K[e.charCodeAt(0)] = 1;
|
|
288
|
+
});
|
|
289
|
+
let m = /* @__PURE__ */ function(e) {
|
|
290
|
+
return e.DOCUMENT = "doc", e.HEADING = "heading", e.PARAGRAPH = "paragraph", e.QUOTE = "blockquote", e.OL_LIST = "ordered_list", e.UL_LIST = "bullet_list", e.LIST_ITEM = "list_item", e.CODE_BLOCK = "code_block", e.HR = "horizontal_rule", e.BR = "hard_break", e.IMAGE = "image", e.EMOJI = "emoji", e.COMPONENT = "blok", e.TABLE = "table", e.TABLE_ROW = "tableRow", e.TABLE_CELL = "tableCell", e.TABLE_HEADER = "tableHeader", e;
|
|
291
|
+
}({}), v = /* @__PURE__ */ function(e) {
|
|
292
|
+
return e.BOLD = "bold", e.STRONG = "strong", e.STRIKE = "strike", e.UNDERLINE = "underline", e.ITALIC = "italic", e.CODE = "code", e.LINK = "link", e.ANCHOR = "anchor", e.STYLED = "styled", e.SUPERSCRIPT = "superscript", e.SUBSCRIPT = "subscript", e.TEXT_STYLE = "textStyle", e.HIGHLIGHT = "highlight", e;
|
|
293
|
+
}({}), Ae = /* @__PURE__ */ function(e) {
|
|
294
|
+
return e.TEXT = "text", e;
|
|
295
|
+
}({}), T = /* @__PURE__ */ function(e) {
|
|
296
|
+
return e.URL = "url", e.STORY = "story", e.ASSET = "asset", e.EMAIL = "email", e;
|
|
297
|
+
}({});
|
|
298
|
+
function Le(e, t) {
|
|
299
|
+
if (!t) return {
|
|
300
|
+
src: e,
|
|
301
|
+
attrs: {}
|
|
302
|
+
};
|
|
303
|
+
let r = 0, n = 0;
|
|
304
|
+
const a = {}, s = [];
|
|
305
|
+
function h(i, d, b, E, A) {
|
|
306
|
+
typeof i != "number" || i <= d || i >= b ? console.warn(`[StoryblokRichText] - ${E.charAt(0).toUpperCase() + E.slice(1)} value must be a number between ${d} and ${b} (inclusive)`) : A.push(`${E}(${i})`);
|
|
260
307
|
}
|
|
261
308
|
if (typeof t == "object") {
|
|
262
|
-
if (typeof t.width == "number" && t.width > 0 ? (
|
|
263
|
-
const { filters: i } = t || {}, { blur:
|
|
264
|
-
|
|
309
|
+
if (typeof t.width == "number" && t.width > 0 ? (a.width = t.width, r = t.width) : console.warn("[StoryblokRichText] - Width value must be a number greater than 0"), t.height && typeof t.height == "number" && t.height > 0 ? (a.height = t.height, n = t.height) : console.warn("[StoryblokRichText] - Height value must be a number greater than 0"), t.loading && ["lazy", "eager"].includes(t.loading) && (a.loading = t.loading), t.class && (a.class = t.class), t.filters) {
|
|
310
|
+
const { filters: i } = t || {}, { blur: d, brightness: b, fill: E, format: A, grayscale: C, quality: L, rotate: $ } = i || {};
|
|
311
|
+
d && h(d, 0, 100, "blur", s), L && h(L, 0, 100, "quality", s), b && h(b, 0, 100, "brightness", s), E && s.push(`fill(${E})`), C && s.push("grayscale()"), $ && [
|
|
312
|
+
0,
|
|
313
|
+
90,
|
|
314
|
+
180,
|
|
315
|
+
270
|
|
316
|
+
].includes(t.filters.rotate || 0) && s.push(`rotate(${$})`), A && [
|
|
317
|
+
"webp",
|
|
318
|
+
"png",
|
|
319
|
+
"jpeg"
|
|
320
|
+
].includes(A) && s.push(`format(${A})`);
|
|
265
321
|
}
|
|
266
|
-
t.srcset && (
|
|
267
|
-
if (typeof i == "number")
|
|
268
|
-
return `${e}/m/${i}x0/${r.length > 0 ? `filters:${r.join(":")}` : ""} ${i}w`;
|
|
322
|
+
t.srcset && (a.srcset = t.srcset.map((i) => {
|
|
323
|
+
if (typeof i == "number") return `${e}/m/${i}x0/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${i}w`;
|
|
269
324
|
if (Array.isArray(i) && i.length === 2) {
|
|
270
|
-
const [
|
|
271
|
-
return `${e}/m/${
|
|
325
|
+
const [d, b] = i;
|
|
326
|
+
return `${e}/m/${d}x${b}/${s.length > 0 ? `filters:${s.join(":")}` : ""} ${d}w`;
|
|
272
327
|
} else {
|
|
273
328
|
console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");
|
|
274
329
|
return;
|
|
275
330
|
}
|
|
276
|
-
}).join(", ")), t.sizes && (
|
|
331
|
+
}).join(", ")), t.sizes && (a.sizes = t.sizes.join(", "));
|
|
277
332
|
}
|
|
278
333
|
let p = `${e}/m/`;
|
|
279
|
-
return
|
|
334
|
+
return r > 0 && n > 0 && (p = `${p}${r}x${n}/`), s.length > 0 && (p = `${p}filters:${s.join(":")}`), {
|
|
280
335
|
src: p,
|
|
281
|
-
attrs:
|
|
336
|
+
attrs: a
|
|
282
337
|
};
|
|
283
338
|
}
|
|
284
|
-
|
|
285
|
-
const ye = [
|
|
339
|
+
const Ie = [
|
|
286
340
|
"area",
|
|
287
341
|
"base",
|
|
288
342
|
"br",
|
|
@@ -297,153 +351,140 @@ const ye = [
|
|
|
297
351
|
"source",
|
|
298
352
|
"track",
|
|
299
353
|
"wbr"
|
|
300
|
-
],
|
|
301
|
-
function
|
|
354
|
+
], $e = (e = {}) => Object.keys(e).map((t) => `${t}="${e[t]}"`).join(" "), Se = (e = {}) => Object.keys(e).map((t) => `${t}: ${e[t]}`).join("; ");
|
|
355
|
+
function Te(e) {
|
|
302
356
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
303
357
|
}
|
|
304
|
-
const
|
|
305
|
-
function
|
|
306
|
-
const n =
|
|
358
|
+
const R = (e) => Object.fromEntries(Object.entries(e).filter(([t, r]) => r !== void 0));
|
|
359
|
+
function F(e, t = {}, r) {
|
|
360
|
+
const n = $e(t), a = n ? `${e} ${n}` : e, s = Array.isArray(r) ? r.join("") : r || "";
|
|
307
361
|
if (e) {
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return `<${l}>${r}</${e}>`;
|
|
362
|
+
if (Ie.includes(e)) return `<${a}>`;
|
|
363
|
+
} else return s;
|
|
364
|
+
return `<${a}>${s}</${e}>`;
|
|
312
365
|
}
|
|
313
|
-
function
|
|
314
|
-
const t = /* @__PURE__ */ new Map(), {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}, u = (o, a) => {
|
|
324
|
-
const { src: c, alt: d, title: y, srcset: m, sizes: h } = o.attrs || {};
|
|
325
|
-
let k = c, w = {};
|
|
326
|
-
if (r) {
|
|
327
|
-
const { src: V, attrs: Q } = fe(c, r);
|
|
328
|
-
k = V, w = Q;
|
|
366
|
+
function Re(e = {}) {
|
|
367
|
+
const t = /* @__PURE__ */ new Map(), { renderFn: r = F, textFn: n = Te, resolvers: a = {}, optimizeImages: s = !1, keyedResolvers: h = !1 } = e, p = r !== F, i = (o) => (l, c) => {
|
|
368
|
+
const u = l.attrs || {};
|
|
369
|
+
return c.render(o, u, l.children || null);
|
|
370
|
+
}, d = (o, l) => {
|
|
371
|
+
const { src: c, alt: u, title: y, srcset: k, sizes: f } = o.attrs || {};
|
|
372
|
+
let g = c, w = {};
|
|
373
|
+
if (s) {
|
|
374
|
+
const { src: Q, attrs: ee } = Le(c, s);
|
|
375
|
+
g = Q, w = ee;
|
|
329
376
|
}
|
|
330
|
-
const
|
|
331
|
-
src:
|
|
332
|
-
alt:
|
|
377
|
+
const X = {
|
|
378
|
+
src: g,
|
|
379
|
+
alt: u,
|
|
333
380
|
title: y,
|
|
334
|
-
srcset:
|
|
335
|
-
sizes:
|
|
381
|
+
srcset: k,
|
|
382
|
+
sizes: f,
|
|
336
383
|
...w
|
|
337
384
|
};
|
|
338
|
-
return
|
|
339
|
-
},
|
|
340
|
-
const { level: c, ...
|
|
341
|
-
return
|
|
342
|
-
}, E = (o,
|
|
343
|
-
var c,
|
|
344
|
-
const
|
|
385
|
+
return l.render("img", R(X));
|
|
386
|
+
}, b = (o, l) => {
|
|
387
|
+
const { level: c, ...u } = o.attrs || {};
|
|
388
|
+
return l.render(`h${c}`, u, o.children);
|
|
389
|
+
}, E = (o, l) => {
|
|
390
|
+
var c, u, y, k;
|
|
391
|
+
const f = l.render("img", {
|
|
345
392
|
src: (c = o.attrs) == null ? void 0 : c.fallbackImage,
|
|
346
|
-
alt: (
|
|
393
|
+
alt: (u = o.attrs) == null ? void 0 : u.alt,
|
|
347
394
|
style: "width: 1.25em; height: 1.25em; vertical-align: text-top",
|
|
348
395
|
draggable: "false",
|
|
349
396
|
loading: "lazy"
|
|
350
397
|
});
|
|
351
|
-
return
|
|
398
|
+
return l.render("span", {
|
|
352
399
|
"data-type": "emoji",
|
|
353
400
|
"data-name": (y = o.attrs) == null ? void 0 : y.name,
|
|
354
|
-
"data-emoji": (
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
} : d || {};
|
|
366
|
-
return y.render(o, S(w), c);
|
|
367
|
-
}, $ = (o) => R(o), T = (o) => {
|
|
368
|
-
const { marks: a, ...c } = o;
|
|
401
|
+
"data-emoji": (k = o.attrs) == null ? void 0 : k.emoji
|
|
402
|
+
}, f);
|
|
403
|
+
}, A = (o, l) => l.render("pre", o.attrs || {}, l.render("code", {}, o.children || "")), C = (o, l = !1) => ({ text: c, attrs: u }, y) => {
|
|
404
|
+
const { class: k, id: f, ...g } = u || {}, w = l ? {
|
|
405
|
+
class: k,
|
|
406
|
+
id: f,
|
|
407
|
+
style: Se(g) || void 0
|
|
408
|
+
} : u || {};
|
|
409
|
+
return y.render(o, R(w), c);
|
|
410
|
+
}, L = (o) => x(o), $ = (o) => {
|
|
411
|
+
const { marks: l, ...c } = o;
|
|
369
412
|
if ("text" in o) {
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
413
|
+
if (l) return l.reduce((y, k) => L({
|
|
414
|
+
...k,
|
|
415
|
+
text: y
|
|
416
|
+
}), L({
|
|
417
|
+
...c,
|
|
418
|
+
children: c.children
|
|
419
|
+
}));
|
|
420
|
+
const u = o.attrs || {};
|
|
421
|
+
if (h) {
|
|
377
422
|
const y = t.get("txt") || 0;
|
|
378
|
-
t.set("txt", y + 1),
|
|
423
|
+
t.set("txt", y + 1), u.key = `txt-${y}`;
|
|
379
424
|
}
|
|
380
|
-
return n(c.text,
|
|
425
|
+
return n(c.text, u);
|
|
381
426
|
}
|
|
382
427
|
return "";
|
|
383
|
-
},
|
|
384
|
-
const { linktype: c, href:
|
|
385
|
-
let
|
|
428
|
+
}, _ = (o, l) => {
|
|
429
|
+
const { linktype: c, href: u, anchor: y, ...k } = o.attrs || {};
|
|
430
|
+
let f = "";
|
|
386
431
|
switch (c) {
|
|
387
|
-
case
|
|
388
|
-
case
|
|
389
|
-
|
|
432
|
+
case T.ASSET:
|
|
433
|
+
case T.URL:
|
|
434
|
+
f = u;
|
|
390
435
|
break;
|
|
391
|
-
case
|
|
392
|
-
|
|
436
|
+
case T.EMAIL:
|
|
437
|
+
f = `mailto:${u}`;
|
|
393
438
|
break;
|
|
394
|
-
case
|
|
395
|
-
|
|
439
|
+
case T.STORY:
|
|
440
|
+
f = u, y && (f = `${f}#${y}`);
|
|
396
441
|
break;
|
|
397
442
|
default:
|
|
398
|
-
|
|
443
|
+
f = u;
|
|
399
444
|
break;
|
|
400
445
|
}
|
|
401
|
-
const
|
|
402
|
-
return
|
|
403
|
-
},
|
|
404
|
-
var c,
|
|
405
|
-
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),
|
|
446
|
+
const g = { ...k };
|
|
447
|
+
return f && (g.href = f), l.render("a", g, o.text);
|
|
448
|
+
}, Z = (o, l) => {
|
|
449
|
+
var c, u;
|
|
450
|
+
return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"), l.render("span", {
|
|
406
451
|
blok: (c = o == null ? void 0 : o.attrs) == null ? void 0 : c.body[0],
|
|
407
|
-
id: (
|
|
452
|
+
id: (u = o.attrs) == null ? void 0 : u.id,
|
|
408
453
|
style: "display: none"
|
|
409
454
|
});
|
|
410
|
-
}, J = (o,
|
|
411
|
-
const c = {},
|
|
412
|
-
return
|
|
413
|
-
},
|
|
455
|
+
}, J = (o, l) => {
|
|
456
|
+
const c = {}, u = l.render("tbody", {}, o.children);
|
|
457
|
+
return l.render("table", c, u);
|
|
458
|
+
}, Y = (o, l) => {
|
|
414
459
|
const c = {};
|
|
415
|
-
return
|
|
416
|
-
},
|
|
417
|
-
const { colspan: c, rowspan:
|
|
418
|
-
|
|
419
|
-
};
|
|
420
|
-
c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
|
|
460
|
+
return l.render("tr", c, o.children);
|
|
461
|
+
}, q = (o, l) => {
|
|
462
|
+
const { colspan: c, rowspan: u, colwidth: y, backgroundColor: k, ...f } = o.attrs || {}, g = { ...f };
|
|
463
|
+
c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
|
|
421
464
|
const w = [];
|
|
422
|
-
return y && w.push(`width: ${y}px;`),
|
|
423
|
-
},
|
|
424
|
-
const { colspan: c, rowspan:
|
|
425
|
-
|
|
426
|
-
};
|
|
427
|
-
c > 1 && (k.colspan = c), d > 1 && (k.rowspan = d);
|
|
465
|
+
return y && w.push(`width: ${y}px;`), k && w.push(`background-color: ${k};`), w.length > 0 && (g.style = w.join(" ")), l.render("td", R(g), o.children);
|
|
466
|
+
}, W = (o, l) => {
|
|
467
|
+
const { colspan: c, rowspan: u, colwidth: y, backgroundColor: k, ...f } = o.attrs || {}, g = { ...f };
|
|
468
|
+
c > 1 && (g.colspan = c), u > 1 && (g.rowspan = u);
|
|
428
469
|
const w = [];
|
|
429
|
-
return y && w.push(`width: ${y}px;`),
|
|
430
|
-
},
|
|
431
|
-
[
|
|
432
|
-
[
|
|
433
|
-
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
[
|
|
438
|
-
[
|
|
439
|
-
[
|
|
440
|
-
[
|
|
441
|
-
[
|
|
442
|
-
[
|
|
443
|
-
[
|
|
444
|
-
[
|
|
445
|
-
[v.LINK,
|
|
446
|
-
[v.ANCHOR,
|
|
470
|
+
return y && w.push(`width: ${y}px;`), k && w.push(`background-color: ${k};`), w.length > 0 && (g.style = w.join(" ")), l.render("th", R(g), o.children);
|
|
471
|
+
}, B = /* @__PURE__ */ new Map([
|
|
472
|
+
[m.DOCUMENT, i("")],
|
|
473
|
+
[m.HEADING, b],
|
|
474
|
+
[m.PARAGRAPH, i("p")],
|
|
475
|
+
[m.UL_LIST, i("ul")],
|
|
476
|
+
[m.OL_LIST, i("ol")],
|
|
477
|
+
[m.LIST_ITEM, i("li")],
|
|
478
|
+
[m.IMAGE, d],
|
|
479
|
+
[m.EMOJI, E],
|
|
480
|
+
[m.CODE_BLOCK, A],
|
|
481
|
+
[m.HR, i("hr")],
|
|
482
|
+
[m.BR, i("br")],
|
|
483
|
+
[m.QUOTE, i("blockquote")],
|
|
484
|
+
[m.COMPONENT, Z],
|
|
485
|
+
[Ae.TEXT, $],
|
|
486
|
+
[v.LINK, _],
|
|
487
|
+
[v.ANCHOR, _],
|
|
447
488
|
[v.STYLED, C("span", !0)],
|
|
448
489
|
[v.BOLD, C("strong")],
|
|
449
490
|
[v.TEXT_STYLE, C("span", !0)],
|
|
@@ -454,65 +495,59 @@ function me(e = {}) {
|
|
|
454
495
|
[v.SUPERSCRIPT, C("sup")],
|
|
455
496
|
[v.SUBSCRIPT, C("sub")],
|
|
456
497
|
[v.HIGHLIGHT, C("mark")],
|
|
457
|
-
[
|
|
458
|
-
[
|
|
459
|
-
[
|
|
460
|
-
[
|
|
461
|
-
]),
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (b && o) {
|
|
467
|
-
const d = t.get(o) || 0;
|
|
468
|
-
t.set(o, d + 1), a.key = `${o}-${d}`;
|
|
498
|
+
[m.TABLE, J],
|
|
499
|
+
[m.TABLE_ROW, Y],
|
|
500
|
+
[m.TABLE_CELL, q],
|
|
501
|
+
[m.TABLE_HEADER, W]
|
|
502
|
+
]), N = new Map([...B, ...Object.entries(a).map(([o, l]) => [o, l])]), V = () => ({
|
|
503
|
+
render: (o, l = {}, c) => {
|
|
504
|
+
if (h && o) {
|
|
505
|
+
const u = t.get(o) || 0;
|
|
506
|
+
t.set(o, u + 1), l.key = `${o}-${u}`;
|
|
469
507
|
}
|
|
470
|
-
return
|
|
508
|
+
return r(o, l, c);
|
|
471
509
|
},
|
|
472
|
-
originalResolvers:
|
|
473
|
-
mergedResolvers:
|
|
510
|
+
originalResolvers: B,
|
|
511
|
+
mergedResolvers: N
|
|
474
512
|
});
|
|
475
|
-
function
|
|
476
|
-
const
|
|
477
|
-
if (!
|
|
513
|
+
function S(o) {
|
|
514
|
+
const l = N.get(o.type);
|
|
515
|
+
if (!l)
|
|
478
516
|
return console.error("<Storyblok>", `No resolver found for node type ${o.type}`), "";
|
|
479
|
-
const c =
|
|
480
|
-
if (o.type === "text")
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return a({
|
|
517
|
+
const c = V();
|
|
518
|
+
if (o.type === "text") return l(o, c);
|
|
519
|
+
const u = o.content ? o.content.map(x) : void 0;
|
|
520
|
+
return l({
|
|
484
521
|
...o,
|
|
485
|
-
children:
|
|
522
|
+
children: u
|
|
486
523
|
}, c);
|
|
487
524
|
}
|
|
488
|
-
function
|
|
489
|
-
return o.type === "doc" ? p ? o.content.map(
|
|
525
|
+
function x(o) {
|
|
526
|
+
return o.type === "doc" ? p ? o.content.map(S) : o.content.map(S).join("") : Array.isArray(o) ? o.map(S) : S(o);
|
|
490
527
|
}
|
|
491
|
-
return {
|
|
492
|
-
render: R
|
|
493
|
-
};
|
|
528
|
+
return { render: x };
|
|
494
529
|
}
|
|
495
530
|
let H = !1;
|
|
496
|
-
const
|
|
531
|
+
const z = [], xe = (e) => new Promise((t, r) => {
|
|
497
532
|
if (typeof window > "u") {
|
|
498
|
-
|
|
533
|
+
r(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
499
534
|
return;
|
|
500
535
|
}
|
|
501
|
-
if (window.storyblokRegisterEvent = (
|
|
536
|
+
if (window.storyblokRegisterEvent = (a) => {
|
|
502
537
|
if (!window.location.search.includes("_storyblok")) {
|
|
503
538
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
504
539
|
return;
|
|
505
540
|
}
|
|
506
|
-
H ?
|
|
541
|
+
H ? a() : z.push(a);
|
|
507
542
|
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
508
543
|
t(void 0);
|
|
509
544
|
return;
|
|
510
545
|
}
|
|
511
546
|
const n = document.createElement("script");
|
|
512
|
-
n.async = !0, n.src = e, n.id = "storyblok-javascript-bridge", n.onerror = (
|
|
513
|
-
|
|
547
|
+
n.async = !0, n.src = e, n.id = "storyblok-javascript-bridge", n.onerror = (a) => r(a), n.onload = (a) => {
|
|
548
|
+
z.forEach((s) => s()), H = !0, t(a);
|
|
514
549
|
}, document.getElementsByTagName("head")[0].appendChild(n);
|
|
515
|
-
}),
|
|
550
|
+
}), Pe = (e) => {
|
|
516
551
|
if (typeof e != "object" || typeof e._editable > "u")
|
|
517
552
|
return {};
|
|
518
553
|
try {
|
|
@@ -527,19 +562,19 @@ const F = [], we = (e) => new Promise((t, s) => {
|
|
|
527
562
|
return {};
|
|
528
563
|
}
|
|
529
564
|
};
|
|
530
|
-
let
|
|
531
|
-
function
|
|
532
|
-
return
|
|
565
|
+
let Oe = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
566
|
+
function je(e, t) {
|
|
567
|
+
return Re(t).render(e);
|
|
533
568
|
}
|
|
534
|
-
const
|
|
569
|
+
const De = () => xe(Oe);
|
|
535
570
|
export {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
571
|
+
Be as getLiveStory,
|
|
572
|
+
Me as handleStoryblokMessage,
|
|
573
|
+
De as loadStoryblokBridge,
|
|
574
|
+
je as renderRichText,
|
|
575
|
+
Re as richTextResolver,
|
|
576
|
+
Ne as storyblok,
|
|
577
|
+
Pe as storyblokEditable,
|
|
578
|
+
D as toCamelCase,
|
|
579
|
+
_e as useStoryblokApi
|
|
545
580
|
};
|