@storyblok/astro 10.2.0 → 10.2.2
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/index-CtMAhUF--DxA2RtMY.js +720 -0
- package/dist/index.js +97 -106
- package/package.json +2 -2
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
//#region ../js/dist/index-CtMAhUF-.js
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
for (; e && e.nodeType === 1;) {
|
|
4
|
+
if (e.hasAttribute(t)) return e;
|
|
5
|
+
e = e.parentNode;
|
|
6
|
+
}
|
|
7
|
+
return null;
|
|
8
|
+
}, t = (t) => {
|
|
9
|
+
let n = e(t, "data-blok-c");
|
|
10
|
+
if (!n) return null;
|
|
11
|
+
let r = n.getAttribute("data-blok-c");
|
|
12
|
+
return JSON.parse(r);
|
|
13
|
+
}, n = (e, t) => e.contains(t), r = (e) => document.querySelector(`[data-blok-uid="${e}"]`), i = (e) => {
|
|
14
|
+
let t = e.getBoundingClientRect();
|
|
15
|
+
return t.top < 0 && t.top + t.height >= 0 || t.top >= 0 && t.top <= (window.innerHeight || document.documentElement.clientHeight);
|
|
16
|
+
}, a = (e) => {
|
|
17
|
+
let t = {};
|
|
18
|
+
try {
|
|
19
|
+
let n = e.replace(/\\/g, "");
|
|
20
|
+
t = JSON.parse(n);
|
|
21
|
+
} catch {
|
|
22
|
+
console.error("Error parsing json", e);
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
}, o = (e) => {
|
|
26
|
+
let t = [], n = document.createNodeIterator(e, NodeFilter.SHOW_COMMENT, () => NodeFilter.FILTER_ACCEPT, !1), r = {};
|
|
27
|
+
for (; r = n.nextNode();) if (r.nodeValue.indexOf("#storyblok#") > -1) {
|
|
28
|
+
let e = r.nodeValue.replace("#storyblok#", ""), n = r.nextElementSibling || r.nextSibling, i = a(e);
|
|
29
|
+
i && t.push({
|
|
30
|
+
options: i,
|
|
31
|
+
el: n
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}, s = (e) => {
|
|
36
|
+
let t = "";
|
|
37
|
+
return location.search.substr(1).split("&").forEach((n) => {
|
|
38
|
+
let r = n.split("=");
|
|
39
|
+
r[0] === e && (t = decodeURIComponent(r[1]));
|
|
40
|
+
}), t;
|
|
41
|
+
}, c = (e, t, n) => typeof e == "string" ? e.toString().replace(/([A-Z])/g, " $1").trim().toLowerCase().replace(/[_-]/g, " ").replace(/(?:^|\s)\S/g, function(e, t) {
|
|
42
|
+
return e.toUpperCase();
|
|
43
|
+
}) : "", l = (e) => e && e.display_name ? e.display_name : c(e.name), u = (e) => {
|
|
44
|
+
let t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
45
|
+
t.setAttribute("viewBox", e.viewBox), t.setAttribute("class", e.svgClass);
|
|
46
|
+
let n = document.createElementNS(t.namespaceURI, "path");
|
|
47
|
+
return n.setAttribute("d", e.path), n.setAttribute("fill", e.pathFill), n.setAttribute("transform", e.pathTransform ? e.pathTransform : "translate(0 0)"), t.appendChild(n), t;
|
|
48
|
+
}, d = ((e) => e)`
|
|
49
|
+
@keyframes smoke {
|
|
50
|
+
from {
|
|
51
|
+
background-color: rgba(89, 197, 198, 0);
|
|
52
|
+
}
|
|
53
|
+
to {
|
|
54
|
+
background-color: rgba(89, 197, 198, 0.5);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.storyblok--outlined .storyblok__outline,
|
|
59
|
+
.storyblok--outlined [data-blok-c] {
|
|
60
|
+
outline: 1px dashed rgba(182, 186, 191, 0.5);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.storyblok--outlined .storyblok__outline[data-blok-focused='true'],
|
|
64
|
+
.storyblok--outlined [data-blok-c][data-blok-focused='true'] {
|
|
65
|
+
outline: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.storyblok__hint {
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
outline: 1px solid #05807f;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
position: absolute;
|
|
73
|
+
transition: opacity 0.2s ease;
|
|
74
|
+
z-index: 16777272;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.storyblok__highlight {
|
|
78
|
+
background: rgba(89, 197, 198, 0.2);
|
|
79
|
+
outline: 1px solid #05807f;
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
position: absolute;
|
|
82
|
+
transition: opacity 0.2s ease;
|
|
83
|
+
z-index: 16777270;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.storyblok__overlay {
|
|
87
|
+
box-shadow: 0 0 8px 2px rgba(34, 42, 69, 0.07);
|
|
88
|
+
box-sizing: border-box;
|
|
89
|
+
outline: 1px solid #05807f;
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
position: absolute;
|
|
92
|
+
z-index: 16777273;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.storyblok__overlay-menu {
|
|
96
|
+
background-color: #05807f;
|
|
97
|
+
border-radius: 5px;
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
font-family:
|
|
100
|
+
-apple-system, blinkmacsystemfont, 'Segoe UI', roboto, helvetica, arial,
|
|
101
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
102
|
+
height: 30px;
|
|
103
|
+
left: -1px;
|
|
104
|
+
pointer-events: auto;
|
|
105
|
+
position: absolute;
|
|
106
|
+
top: -40px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.storyblok__overlay-menu--simple .storyblok__overlay-menu-btn {
|
|
110
|
+
border-bottom-right-radius: 5px;
|
|
111
|
+
border-top-right-radius: 5px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.storyblok__overlay-menu-label {
|
|
115
|
+
color: #fff;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
line-height: 30px;
|
|
118
|
+
margin-right: 20px;
|
|
119
|
+
max-width: 200px;
|
|
120
|
+
overflow-x: hidden;
|
|
121
|
+
text-overflow: ellipsis;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.storyblok__overlay-menu-label:first-child {
|
|
126
|
+
margin-left: 20px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.storyblok__overlay-menu-btn {
|
|
130
|
+
align-items: center;
|
|
131
|
+
background-color: transparent;
|
|
132
|
+
border: 0;
|
|
133
|
+
display: flex;
|
|
134
|
+
justify-content: center;
|
|
135
|
+
outline: none;
|
|
136
|
+
padding: 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.storyblok__overlay-menu-btn:hover {
|
|
140
|
+
background-color: #0d5454;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.storyblok__overlay-menu-btn-action {
|
|
144
|
+
border-bottom-right-radius: 5px;
|
|
145
|
+
border-left: 1px solid #fff;
|
|
146
|
+
border-top-right-radius: 5px;
|
|
147
|
+
height: inherit;
|
|
148
|
+
margin: auto;
|
|
149
|
+
margin-right: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.storyblok__overlay-menu-btn-parent {
|
|
153
|
+
border-bottom-left-radius: 5px;
|
|
154
|
+
border-top-left-radius: 5px;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
margin: 0;
|
|
157
|
+
width: auto;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.storyblok__overlay-menu-svg {
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
height: 24px;
|
|
164
|
+
margin: 0 3px;
|
|
165
|
+
width: 24px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.storyblok__overlay--bottom .storyblok__overlay-menu {
|
|
169
|
+
bottom: -40px;
|
|
170
|
+
top: auto;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.storyblok__overlay--clicked {
|
|
174
|
+
animation-duration: 0.2s;
|
|
175
|
+
animation-iteration-count: 1;
|
|
176
|
+
animation-name: smoke;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.storyblok__actions-menu,
|
|
180
|
+
.storyblok__breadcrumbs-menu {
|
|
181
|
+
background-color: #fff;
|
|
182
|
+
border: 1px solid #dfe3e8;
|
|
183
|
+
border-radius: 5px;
|
|
184
|
+
box-shadow: 0 2px 17px 3px rgba(34, 42, 69, 0.07);
|
|
185
|
+
box-sizing: content-box;
|
|
186
|
+
display: none;
|
|
187
|
+
height: fit-content;
|
|
188
|
+
min-width: 156px;
|
|
189
|
+
overflow: hidden;
|
|
190
|
+
padding: 11px 0;
|
|
191
|
+
position: absolute;
|
|
192
|
+
top: 25px;
|
|
193
|
+
z-index: 2;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.storyblok__actions-menu hr,
|
|
197
|
+
.storyblok__breadcrumbs-menu hr {
|
|
198
|
+
background-color: #dfe3e8;
|
|
199
|
+
border: 0;
|
|
200
|
+
height: 1px;
|
|
201
|
+
margin: 11px 0 11px 20px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.storyblok__actions-menu__menu-item,
|
|
205
|
+
.storyblok__breadcrumbs-menu__menu-item {
|
|
206
|
+
align-items: center;
|
|
207
|
+
appearance: none;
|
|
208
|
+
background: #fff;
|
|
209
|
+
border: 0;
|
|
210
|
+
color: #1b243f;
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
display: flex;
|
|
213
|
+
font-family:
|
|
214
|
+
-apple-system, blinkmacsystemfont, 'Segoe UI', roboto, helvetica, arial,
|
|
215
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
216
|
+
font-size: 14px;
|
|
217
|
+
padding: 8px 20px;
|
|
218
|
+
text-align: left;
|
|
219
|
+
width: 100%;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.storyblok__actions-menu__menu-item--delete,
|
|
223
|
+
.storyblok__breadcrumbs-menu__menu-item--delete {
|
|
224
|
+
color: #c11c14;
|
|
225
|
+
margin-bottom: 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.storyblok__actions-menu__menu-item--selected,
|
|
229
|
+
.storyblok__breadcrumbs-menu__menu-item--selected {
|
|
230
|
+
color: #05807f;
|
|
231
|
+
cursor: default;
|
|
232
|
+
margin-bottom: 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.storyblok__actions-menu__menu-item--selected:hover,
|
|
236
|
+
.storyblok__breadcrumbs-menu__menu-item--selected:hover {
|
|
237
|
+
background: transparent;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.storyblok__actions-menu__menu-item:hover,
|
|
241
|
+
.storyblok__breadcrumbs-menu__menu-item:hover {
|
|
242
|
+
background: #eff1f3;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.storyblok__actions-menu__menu-item:focus,
|
|
246
|
+
.storyblok__breadcrumbs-menu__menu-item:focus {
|
|
247
|
+
outline: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.storyblok__actions-menu {
|
|
251
|
+
left: calc(100% - 20px);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.storyblok__breadcrumbs-menu {
|
|
255
|
+
left: -10px;
|
|
256
|
+
}
|
|
257
|
+
`, f = {
|
|
258
|
+
OUTLINE: "storyblok--outlined",
|
|
259
|
+
STYLESHEET: "storyblok-bridge-stylesheet",
|
|
260
|
+
HINT: "storyblok__hint",
|
|
261
|
+
HIGHLIGHTER: "storyblok__highlight",
|
|
262
|
+
OVERLAY: "storyblok__overlay",
|
|
263
|
+
COMPONENT_BASE: "storyblok__overlay-menu",
|
|
264
|
+
ACTIONS_MENU: "storyblok__actions-menu",
|
|
265
|
+
BREADCRUMBS_MENU: "storyblok__breadcrumbs-menu"
|
|
266
|
+
}, p = class {
|
|
267
|
+
constructor(e) {
|
|
268
|
+
this.appVersion = "v1", this.inEditor = !0, this.initialized = !1, this.currentUid = null, this.storyId = "", this.componentNames = {}, this.outlineOnMoveInterval = null, this.calcInterval = null, this.canAddBlocks = !1, this.canMoveForward = !1, this.canMoveBackward = !1, this.canDeleteBlocks = !1, this.navigationBreadcrumbs = [], this.focusState = !1, this.actionsEnabled = !1, this.hinter = null, this.highlighter = null, this.overlay = null, this.componentBase = null, this.componentLabel = null, this.breadcrumbsButtonMenu = null, this.breadcrumbsMenu = null, this.actionsMenu = null, this.actionsMenuButton = null, this.actionsMenuItems = null, this.events = {
|
|
269
|
+
input: [],
|
|
270
|
+
change: [],
|
|
271
|
+
published: [],
|
|
272
|
+
unpublished: [],
|
|
273
|
+
viewLiveVersion: [],
|
|
274
|
+
enterEditmode: [],
|
|
275
|
+
enterComponent: [],
|
|
276
|
+
hoverComponent: [],
|
|
277
|
+
highlightComponent: [],
|
|
278
|
+
customEvent: [],
|
|
279
|
+
pingBack: [],
|
|
280
|
+
sessionReceived: [],
|
|
281
|
+
editedBlok: [],
|
|
282
|
+
deselectBlok: [],
|
|
283
|
+
addedBlock: [],
|
|
284
|
+
deletedBlock: [],
|
|
285
|
+
movedBlock: [],
|
|
286
|
+
duplicatedBlock: []
|
|
287
|
+
};
|
|
288
|
+
let t = {
|
|
289
|
+
customParent: null,
|
|
290
|
+
resolveRelations: null,
|
|
291
|
+
resolveLinks: null,
|
|
292
|
+
preventClicks: !1,
|
|
293
|
+
initOnlyOnce: !0,
|
|
294
|
+
fallbackLang: null
|
|
295
|
+
};
|
|
296
|
+
this.config = {
|
|
297
|
+
...t,
|
|
298
|
+
...e
|
|
299
|
+
}, this.init();
|
|
300
|
+
}
|
|
301
|
+
get isInIframe() {
|
|
302
|
+
return window.top !== window.self;
|
|
303
|
+
}
|
|
304
|
+
get csProtocol() {
|
|
305
|
+
let e = location.protocol.replace(":", "");
|
|
306
|
+
return e !== "http" && e !== "https" && (e = "https"), e;
|
|
307
|
+
}
|
|
308
|
+
get targetOrigin() {
|
|
309
|
+
return this.config.customParent ? this.config.customParent : s("_storyblok_env") === "stage" ? `${this.csProtocol}://app-beta.storyblok.com` : `${this.csProtocol}://app.storyblok.com`;
|
|
310
|
+
}
|
|
311
|
+
get lastBreadcrumbItem() {
|
|
312
|
+
return this.navigationBreadcrumbs[this.navigationBreadcrumbs.length - 1] || {};
|
|
313
|
+
}
|
|
314
|
+
isInEditor() {
|
|
315
|
+
return this.inEditor;
|
|
316
|
+
}
|
|
317
|
+
init() {
|
|
318
|
+
if (document.body === null) {
|
|
319
|
+
console.error("Body tag not found. Please install the Storyblok bridge script inside the body tag");
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.config.initOnlyOnce && document.querySelectorAll(`.${f.HINT}`).length > 0 || this.isInIframe && (this.resetAllEvents(), this.addMessageListener(), this.outlineOnMove(), this.buildBridgeStyles(), this.on("enterEditmode", this.enterEditmode), this.isInIframe && this.sendDataToEditor({
|
|
323
|
+
action: "initialized",
|
|
324
|
+
config: this.config
|
|
325
|
+
}), this.initialized = !0);
|
|
326
|
+
}
|
|
327
|
+
keyPress(e, t) {
|
|
328
|
+
(t.key === "z" && t.metaKey || t.key === "z" && t.ctrlKey) && (t.preventDefault(), t.stopImmediatePropagation(), e.sendDataToEditor({ action: "undo" })), (t.key === "y" && t.metaKey || t.key === "y" && t.ctrlKey) && (t.preventDefault(), t.stopImmediatePropagation(), e.sendDataToEditor({ action: "redo" }));
|
|
329
|
+
}
|
|
330
|
+
sendDataToEditor(e) {
|
|
331
|
+
window.parent.postMessage(e, this.targetOrigin);
|
|
332
|
+
}
|
|
333
|
+
buildBridgeStyles() {
|
|
334
|
+
document.getElementById(f.STYLESHEET) ? (this.hinter = document.querySelector(`.${f.HINT}`), this.highlighter = document.querySelector(`.${f.HIGHLIGHTER}`), this.overlay = document.querySelector(`.${f.OVERLAY}`), this.componentBase = document.querySelector(`.${f.COMPONENT_BASE}`), this.breadcrumbsButtonMenu = document.querySelector(`.${f.COMPONENT_BASE}-btn-parent`), this.breadcrumbsMenu = document.querySelector(`.${f.BREADCRUMBS_MENU}`), this.actionsMenuButton = document.querySelector(`.${f.COMPONENT_BASE}-btn-action`), this.actionsMenu = document.querySelector(`.${f.ACTIONS_MENU}`), this.componentLabel = document.querySelector(`.${f.COMPONENT_BASE} > .${f.COMPONENT_BASE}-label`), this.createActionsMenuItems()) : (this.createBridgeStylesheet(), this.createHinter(), this.createHighlighter(), this.createOverlay(), this.createComponentContext());
|
|
335
|
+
}
|
|
336
|
+
createBridgeStylesheet() {
|
|
337
|
+
let e = document.createElement("style");
|
|
338
|
+
e.setAttribute("type", "text/css"), e.id = f.STYLESHEET, "textContent" in e ? e.textContent = d : e.styleSheet.cssText = d, document.getElementsByTagName("head")[0].appendChild(e);
|
|
339
|
+
}
|
|
340
|
+
createHinter() {
|
|
341
|
+
this.hinter = document.createElement("div"), this.hinter.className = f.HINT, this.hideElement(this.hinter), document.body.appendChild(this.hinter);
|
|
342
|
+
}
|
|
343
|
+
createHighlighter() {
|
|
344
|
+
this.highlighter = document.createElement("div"), this.highlighter.style.opacity = 0, this.hideElement(this.highlighter), document.body.appendChild(this.highlighter);
|
|
345
|
+
}
|
|
346
|
+
createOverlay() {
|
|
347
|
+
this.overlay = document.createElement("div"), this.overlay.setAttribute("class", f.OVERLAY), this.overlay.setAttribute("id", f.OVERLAY), this.hideElement(this.overlay), document.body.appendChild(this.overlay);
|
|
348
|
+
}
|
|
349
|
+
calculateElementPosition(e, t) {
|
|
350
|
+
if (!t) {
|
|
351
|
+
this.hideElement(e);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let n = r(t);
|
|
355
|
+
if (n) {
|
|
356
|
+
let { left: t, top: r } = this.getElementOffset(n);
|
|
357
|
+
r <= 30 ? this.overlay.classList.add(`${f.OVERLAY}--bottom`) : this.overlay.classList.remove(`${f.OVERLAY}--bottom`), e.style.top = `${r}px`, e.style.left = `${t}px`, e.style.width = `${n.offsetWidth}px`, e.style.height = `${n.offsetHeight}px`, e.style.minHeight = "5px";
|
|
358
|
+
} else this.hideElement(e);
|
|
359
|
+
}
|
|
360
|
+
getElementOffset(e) {
|
|
361
|
+
let t = e.getBoundingClientRect(), n = window.pageXOffset || document.documentElement.scrollLeft, r = window.pageYOffset || document.documentElement.scrollTop;
|
|
362
|
+
return {
|
|
363
|
+
top: t.top + r,
|
|
364
|
+
left: t.left + n
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
resetAllEvents() {
|
|
368
|
+
for (let e in this.events) this.events[e] = [];
|
|
369
|
+
}
|
|
370
|
+
addMessageListener() {
|
|
371
|
+
window.addEventListener && addEventListener("message", this.receiveMessageFromApp.bind(this), !1);
|
|
372
|
+
}
|
|
373
|
+
receiveMessageFromApp(e) {
|
|
374
|
+
e && e.data && e.data.action && this.emit(e.data.action, e.data);
|
|
375
|
+
}
|
|
376
|
+
emit(e, ...t) {
|
|
377
|
+
let n = this.events[e];
|
|
378
|
+
if (!(!e || !n || !n.length)) for (let e = 0; e < n.length; e++) n[e].apply(this, t);
|
|
379
|
+
}
|
|
380
|
+
outlineOnMoveHandler() {
|
|
381
|
+
document.body.classList.add(f.OUTLINE);
|
|
382
|
+
let e = () => {
|
|
383
|
+
document.body.classList.remove(f.OUTLINE), this.hinter && (this.hinter.style.opacity = 0);
|
|
384
|
+
};
|
|
385
|
+
this.outlineOnMoveInterval && clearTimeout(this.outlineOnMoveInterval), this.outlineOnMoveInterval = setTimeout(e, 800);
|
|
386
|
+
}
|
|
387
|
+
outlineOnMove() {
|
|
388
|
+
document.addEventListener("mousemove", this.outlineOnMoveHandler.bind(this), !1);
|
|
389
|
+
}
|
|
390
|
+
on(e, t) {
|
|
391
|
+
if (e.constructor === Array) {
|
|
392
|
+
for (let n of e) this.subscribeEvent(n, t);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
this.subscribeEvent(e, t);
|
|
396
|
+
}
|
|
397
|
+
subscribeEvent(e, t) {
|
|
398
|
+
e === "input" && (this.actionsEnabled = !0), this.events[e].indexOf(t) === -1 && this.events[e].push(t);
|
|
399
|
+
}
|
|
400
|
+
pingEditor(e) {
|
|
401
|
+
this.isInIframe ? this.sendDataToEditor({ action: "ping" }) : (this.inEditor = !1, e(this)), this.on("pingBack", this.handlePingBack(e));
|
|
402
|
+
}
|
|
403
|
+
handlePingBack(e) {
|
|
404
|
+
return () => {
|
|
405
|
+
this.inEditor = !0, e(this);
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
handleEditedBlok(e) {
|
|
409
|
+
this.navigationBreadcrumbs = e.breadcrumbs, this.canAddBlocks = e.canAddBlocks || !1, this.canMoveForward = e.canMoveForward || !1, this.canMoveBackward = e.canMoveBackward || !1, this.canDeleteBlocks = e.canDeleteBlocks || !1, this.updateComponentBase(e.blok);
|
|
410
|
+
}
|
|
411
|
+
handleAddMoveBlok(e) {
|
|
412
|
+
let t = r(`${this.storyId}-${e.blockId}`);
|
|
413
|
+
t && this.handleOpenBlok(t);
|
|
414
|
+
}
|
|
415
|
+
handleDeselectBlock() {
|
|
416
|
+
document.querySelectorAll("[data-blok-focused]").forEach((e) => e.removeAttribute("data-blok-focused")), this.hideElement(this.overlay);
|
|
417
|
+
}
|
|
418
|
+
handleDuplicatedBlok(e) {
|
|
419
|
+
this.handleDeselectBlock(), setTimeout(() => {
|
|
420
|
+
let t = r(`${this.storyId}-${e.blockId}`);
|
|
421
|
+
this.handleOpenBlok(t);
|
|
422
|
+
}, 500);
|
|
423
|
+
}
|
|
424
|
+
handleWindowClick(e) {
|
|
425
|
+
this.config.preventClicks && (e.preventDefault(), e.stopPropagation()), this.handleOpenBlok(e.target, e);
|
|
426
|
+
}
|
|
427
|
+
handleOpenBlok(e, n) {
|
|
428
|
+
let r = t(e);
|
|
429
|
+
if (r) {
|
|
430
|
+
n && r.uid !== this.currentUid && (n.preventDefault(), n.stopPropagation()), this.currentUid = r.uid, this.storyId = r.id, this.openBlok(r);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
n && this.toggleFocusElement(e, !0);
|
|
434
|
+
}
|
|
435
|
+
enterEditmode(e) {
|
|
436
|
+
let t = o(document.body);
|
|
437
|
+
e && e.appVersion && (this.appVersion = e.appVersion), e && e.componentNames && (this.componentNames = e.componentNames);
|
|
438
|
+
for (let e = 0; e < t.length; e++) {
|
|
439
|
+
let n = t[e].el, r = t[e].options;
|
|
440
|
+
!n || n.nodeType !== Node.ELEMENT_NODE || (r.name = this.componentNames[r.name] || r.name, n.setAttribute("data-blok-c", JSON.stringify(r)), n.setAttribute("data-blok-uid", `${r.id}-${r.uid}`), n.offsetHeight < 5 && (n.style["min-height"] = "5px"), n.classList.add("storyblok__outline"));
|
|
441
|
+
}
|
|
442
|
+
if (this.on("addedBlock", this.handleAddMoveBlok), this.on("duplicatedBlock", this.handleDuplicatedBlok), this.on("movedBlock", this.handleAddMoveBlok), this.on("enterComponent", this.enterComponent), this.on("highlightComponent", this.highlightComponent), this.on("hoverComponent", this.hoverComponent), this.on("editedBlok", this.handleEditedBlok), this.on("deselectBlok", this.handleDeselectBlock), e && e.blockId && this.config.setActiveBlock) {
|
|
443
|
+
let t = r(`${e.storyId}-${e.blockId}`);
|
|
444
|
+
this.handleOpenBlok(t);
|
|
445
|
+
}
|
|
446
|
+
window.addEventListener("click", this.handleWindowClick.bind(this)), this.calcInterval !== null && window.clearInterval(this.calcInterval), this.calcInterval = window.setInterval(() => {
|
|
447
|
+
this.calculateElementPosition(this.overlay, `${this.storyId}-${this.currentUid}`);
|
|
448
|
+
}, 300);
|
|
449
|
+
}
|
|
450
|
+
highlightComponent(e) {
|
|
451
|
+
this.highlighter.innerHTML = "", e.componentIds.length > 0 ? (this.highlighter.style.display = "block", this.highlighter.style.opacity = 1) : (this.highlighter.style.display = "none", this.highlighter.style.opacity = 0);
|
|
452
|
+
for (let t = 0; t < e.componentIds.length; t++) {
|
|
453
|
+
let n = `${e.storyId}-${e.componentIds[t]}`, a = r(n);
|
|
454
|
+
if (a) {
|
|
455
|
+
let r = document.createElement("div");
|
|
456
|
+
r.setAttribute("class", f.HIGHLIGHTER), this.highlighter.appendChild(r), this.calculateElementPosition(r, n), e.componentId === e.componentIds[t] && !i(a) && typeof a.scrollIntoView < "u" && a.scrollIntoView();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
hoverComponent(e) {
|
|
461
|
+
this.calculateElementPosition(this.hinter, `${e.storyId}-${e.componentId}`), this.hinter.style.opacity = 1, this.hinter.style.display = "block";
|
|
462
|
+
}
|
|
463
|
+
toggleFocusElement(e, t = !1) {
|
|
464
|
+
if (!n(this.overlay, e)) {
|
|
465
|
+
if (this.handleDeselectBlock(), !t && this.storyId === s("_storyblok")) {
|
|
466
|
+
e.setAttribute("data-blok-focused", !0), this.showFocusedElement(this.overlay), this.focusState = !1;
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
this.focusState || this.sendDataToEditor({ action: "noFocus" });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
showFocusedElement(e) {
|
|
473
|
+
if (!this.currentUid) {
|
|
474
|
+
this.hideElement(e);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
this.showElement(e), this.calculateElementPosition(e, `${this.storyId}-${this.currentUid}`);
|
|
478
|
+
}
|
|
479
|
+
handleBlokActions(e) {
|
|
480
|
+
this.sendDataToEditor({
|
|
481
|
+
action: e,
|
|
482
|
+
blok: this.lastBreadcrumbItem
|
|
483
|
+
}), e === "addBlockBefore" || e === "addBlockAfter" || e === "copy" ? this.hideElement(this.actionsMenu) : this.hideElement(this.overlay), (e === "moveForward" || e === "moveBackward") && (this.focusState = !0);
|
|
484
|
+
}
|
|
485
|
+
hideElement(e) {
|
|
486
|
+
e.style.display = "none";
|
|
487
|
+
}
|
|
488
|
+
showElement(e) {
|
|
489
|
+
e.style.display = "block";
|
|
490
|
+
}
|
|
491
|
+
toggleElement(e) {
|
|
492
|
+
if (e.style.display === "block") {
|
|
493
|
+
this.hideElement(e);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
this.showElement(e);
|
|
497
|
+
}
|
|
498
|
+
enterComponent(e) {
|
|
499
|
+
let n = r(`${e.storyId}-${e.componentId}`), i = t(n);
|
|
500
|
+
i && (this.hinter.style.opacity = 0, this.hinter.style.display = "none", this.currentUid = i.uid, this.storyId = i.id, this.scrollIntoView(n), this.handleEditedBlok(e));
|
|
501
|
+
}
|
|
502
|
+
scrollIntoView(e) {
|
|
503
|
+
e && !i(e) && typeof e.scrollIntoView < "u" && setTimeout(() => {
|
|
504
|
+
e.scrollIntoView({
|
|
505
|
+
behavior: "smooth",
|
|
506
|
+
block: "start"
|
|
507
|
+
});
|
|
508
|
+
}, 100);
|
|
509
|
+
}
|
|
510
|
+
openBlok(e) {
|
|
511
|
+
this.sendDataToEditor({
|
|
512
|
+
action: "edit",
|
|
513
|
+
dataC: e,
|
|
514
|
+
config: this.config
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
createComponentContext() {
|
|
518
|
+
this.createComponentBase(), this.createActionsMenu(), this.createActionsMenuItems(), this.createBreadcrumbsMenu(), this.createActionsMenuButton(), this.createBreadcrumbsMenuButton(), this.createComponentLabel(), this.createComponentButtonLabel();
|
|
519
|
+
}
|
|
520
|
+
createComponentBase() {
|
|
521
|
+
this.componentBase = document.createElement("div"), this.componentBase.setAttribute("class", f.COMPONENT_BASE), this.componentBase.setAttribute("id", f.COMPONENT_BASE), this.overlay.append(this.componentBase);
|
|
522
|
+
}
|
|
523
|
+
createComponentLabel() {
|
|
524
|
+
this.componentLabel = document.createElement("span"), this.componentLabel.setAttribute("class", `${f.COMPONENT_BASE}-label`), this.componentBase.prepend(this.componentLabel);
|
|
525
|
+
}
|
|
526
|
+
createComponentButtonLabel() {
|
|
527
|
+
let e = document.createElement("span");
|
|
528
|
+
e.setAttribute("class", `${f.COMPONENT_BASE}-label`), this.breadcrumbsButtonMenu.appendChild(e);
|
|
529
|
+
}
|
|
530
|
+
updateComponentLabel(e) {
|
|
531
|
+
document.querySelectorAll(`.${f.COMPONENT_BASE}-label`).forEach((t) => t.innerText = this.componentNames[e.name] || l(e));
|
|
532
|
+
}
|
|
533
|
+
updateComponentBase(e) {
|
|
534
|
+
this.hideElement(this.actionsMenu), this.hideElement(this.breadcrumbsMenu), this.overlay.classList.add(`${f.OVERLAY}--clicked`), setTimeout(() => {
|
|
535
|
+
this.overlay.classList.remove(`${f.OVERLAY}--clicked`);
|
|
536
|
+
}, 400), this.navigationBreadcrumbs.length > 1 ? (this.updateBreadcrumbsMenu(this.navigationBreadcrumbs), this.actionsEnabled ? this.updateActionsMenu() : (this.componentBase.setAttribute("class", `${f.COMPONENT_BASE} ${f.COMPONENT_BASE}--simple`), this.hideElement(this.actionsMenuButton)), this.hideElement(this.componentLabel)) : (this.hideElement(this.breadcrumbsButtonMenu), this.hideElement(this.actionsMenuButton), this.showElement(this.componentLabel)), this.updateComponentLabel(e);
|
|
537
|
+
let t = r(`${this.storyId}-${e.uid}`);
|
|
538
|
+
t && this.toggleFocusElement(t);
|
|
539
|
+
}
|
|
540
|
+
createBreadcrumbsMenuButton() {
|
|
541
|
+
this.breadcrumbsButtonMenu = document.createElement("button"), this.breadcrumbsButtonMenu.setAttribute("class", `${f.COMPONENT_BASE}-btn ${f.COMPONENT_BASE}-btn-parent`), this.breadcrumbsButtonMenu.prepend(u({
|
|
542
|
+
viewBox: "0 0 24 24",
|
|
543
|
+
svgClass: `${f.COMPONENT_BASE}-svg`,
|
|
544
|
+
path: "M13.73 14.284l-2.197-2.216 2.197-2.217a1.051 1.051 0 000-1.477 1.03 1.03 0 00-1.465 0l-2.93 2.955a1.043 1.043 0 00-.287.554l-.014.123v.123c.014.247.115.489.301.677l2.93 2.956a1.03 1.03 0 001.465 0 1.051 1.051 0 000-1.478z",
|
|
545
|
+
pathFill: "#ffffff"
|
|
546
|
+
})), this.breadcrumbsButtonMenu.addEventListener("click", () => {
|
|
547
|
+
this.toggleElement(this.breadcrumbsMenu), this.hideElement(this.actionsMenu);
|
|
548
|
+
}), this.componentBase.prepend(this.breadcrumbsButtonMenu);
|
|
549
|
+
}
|
|
550
|
+
createBreadcrumbsMenu() {
|
|
551
|
+
this.breadcrumbsMenu = document.createElement("div"), this.breadcrumbsMenu.setAttribute("class", f.BREADCRUMBS_MENU), this.breadcrumbsMenu.setAttribute("id", f.BREADCRUMBS_MENU), this.componentBase.append(this.breadcrumbsMenu);
|
|
552
|
+
}
|
|
553
|
+
updateBreadcrumbsMenu(e) {
|
|
554
|
+
this.breadcrumbsMenu.innerHTML = "";
|
|
555
|
+
let t = [];
|
|
556
|
+
for (let n = 0; n < e.length; n++) {
|
|
557
|
+
t[n] = document.createElement("button"), t[n].innerHTML = l({
|
|
558
|
+
display_name: this.componentNames[e[n].component],
|
|
559
|
+
name: e[n].component
|
|
560
|
+
});
|
|
561
|
+
let r = e[n];
|
|
562
|
+
t[n].addEventListener("click", (e) => {
|
|
563
|
+
e.stopPropagation(), this.currentUid = r._uid, this.openBlok({
|
|
564
|
+
id: this.storyId,
|
|
565
|
+
uid: r._uid,
|
|
566
|
+
name: r.component
|
|
567
|
+
});
|
|
568
|
+
}), t[n].classList.add(`${f.BREADCRUMBS_MENU}__menu-item`), e[n]._uid === this.currentUid && (t[n].classList.add(`${f.BREADCRUMBS_MENU}__menu-item--selected`), t[n].setAttribute("disabled", !0)), this.breadcrumbsMenu.appendChild(t[n]), this.breadcrumbsButtonMenu.style.display = "flex";
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
createActionsMenuButton() {
|
|
572
|
+
this.actionsMenuButton = document.createElement("button"), this.actionsMenuButton.setAttribute("class", `${f.COMPONENT_BASE}-btn ${f.COMPONENT_BASE}-btn-action`), this.actionsMenuButton.prepend(u({
|
|
573
|
+
viewBox: "0 0 24 24",
|
|
574
|
+
svgClass: `${f.COMPONENT_BASE}-svg`,
|
|
575
|
+
path: "M7.5 11a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm10 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3zm-5 0a1.5 1.5 0 110 3 1.5 1.5 0 010-3z",
|
|
576
|
+
pathFill: "#ffffff"
|
|
577
|
+
})), this.actionsMenuButton.addEventListener("click", () => {
|
|
578
|
+
this.toggleElement(this.actionsMenu), this.breadcrumbsMenu && this.hideElement(this.breadcrumbsMenu);
|
|
579
|
+
}), this.componentBase.append(this.actionsMenuButton);
|
|
580
|
+
}
|
|
581
|
+
createActionsMenuItems() {
|
|
582
|
+
this.actionsMenuItems = [
|
|
583
|
+
{
|
|
584
|
+
eventFunction: () => this.handleBlokActions.bind(this, "addBlockBefore"),
|
|
585
|
+
innerHTML: "Add Block Before",
|
|
586
|
+
order: 0,
|
|
587
|
+
show: () => this.canAddBlocks
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
eventFunction: () => this.handleBlokActions.bind(this, "addBlockAfter"),
|
|
591
|
+
innerHTML: "Add Block After",
|
|
592
|
+
order: 1,
|
|
593
|
+
show: () => this.canAddBlocks
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
eventFunction: () => this.handleBlokActions.bind(this, "duplicateBlock"),
|
|
597
|
+
innerHTML: "Duplicate",
|
|
598
|
+
order: 2,
|
|
599
|
+
show: () => this.canAddBlocks
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
eventFunction: () => this.handleBlokActions.bind(this, "copy"),
|
|
603
|
+
innerHTML: "Copy",
|
|
604
|
+
order: 3,
|
|
605
|
+
show: () => this.appVersion === "v2"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
separator: !0,
|
|
609
|
+
order: 4,
|
|
610
|
+
show: () => this.canAddBlocks && this.canMoveForward || !!(this.canMoveBackward && this.lastBreadcrumbItem._parentindex)
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
eventFunction: () => this.handleBlokActions.bind(this, "moveForward"),
|
|
614
|
+
innerHTML: "Move Forward",
|
|
615
|
+
order: 5,
|
|
616
|
+
show: () => this.canMoveForward
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
eventFunction: () => this.handleBlokActions.bind(this, "moveBackward"),
|
|
620
|
+
innerHTML: "Move Backward",
|
|
621
|
+
order: 6,
|
|
622
|
+
show: () => this.canMoveBackward && this.lastBreadcrumbItem._parentindex
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
separator: !0,
|
|
626
|
+
order: 7,
|
|
627
|
+
show: () => this.canAddBlocks && this.canDeleteBlocks
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
eventFunction: () => this.handleBlokActions.bind(this, "deleteBlock"),
|
|
631
|
+
className: `${f.ACTIONS_MENU}__menu-item--delete`,
|
|
632
|
+
innerHTML: "Delete",
|
|
633
|
+
order: 8,
|
|
634
|
+
show: () => this.canDeleteBlocks
|
|
635
|
+
}
|
|
636
|
+
];
|
|
637
|
+
}
|
|
638
|
+
createActionsMenu() {
|
|
639
|
+
this.actionsMenu = document.createElement("div"), this.actionsMenu.setAttribute("class", f.ACTIONS_MENU), this.actionsMenu.setAttribute("id", f.ACTIONS_MENU), this.componentBase.append(this.actionsMenu);
|
|
640
|
+
}
|
|
641
|
+
updateActionsMenu() {
|
|
642
|
+
this.actionsMenu.innerHTML = "";
|
|
643
|
+
let e = `${f.ACTIONS_MENU}__menu-item`;
|
|
644
|
+
this.actionsMenuItems.sort((e, t) => e.order > t.order ? 1 : t.order > e.order ? -1 : 0).forEach((t) => {
|
|
645
|
+
if (t.separator && t.show()) {
|
|
646
|
+
this.actionsMenu.appendChild(document.createElement("hr"));
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
let n = document.createElement(t.element ? t.element : "button");
|
|
650
|
+
n.classList.add(e), t.className && n.classList.add(t.className), n.innerHTML = t.innerHTML, t.eventFunction && n.addEventListener(t.event ? t.event : "click", t.eventFunction()), t.show() && this.actionsMenu.appendChild(n);
|
|
651
|
+
}), this.actionsMenuButton.style.display = "flex";
|
|
652
|
+
}
|
|
653
|
+
}, m = Object.defineProperty, h = (e, t, n) => t in e ? m(e, t, {
|
|
654
|
+
enumerable: !0,
|
|
655
|
+
configurable: !0,
|
|
656
|
+
writable: !0,
|
|
657
|
+
value: n
|
|
658
|
+
}) : e[t] = n, g = (e, t, n) => h(e, typeof t == "symbol" ? t : t + "", n), _ = class {
|
|
659
|
+
constructor(e) {
|
|
660
|
+
g(this, "isInEditor"), g(this, "enterEditmode"), g(this, "pingEditor"), g(this, "on");
|
|
661
|
+
let t = new p(e);
|
|
662
|
+
this.isInEditor = () => t.isInEditor(), this.enterEditmode = (e) => {
|
|
663
|
+
t.enterEditmode(e);
|
|
664
|
+
}, this.pingEditor = (e) => {
|
|
665
|
+
t.pingEditor(e);
|
|
666
|
+
}, this.on = (e, n) => {
|
|
667
|
+
t.on(e, n);
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
}, v = (e) => ({
|
|
671
|
+
tag: "success",
|
|
672
|
+
value: e
|
|
673
|
+
}), y = (e) => ({
|
|
674
|
+
tag: "failure",
|
|
675
|
+
error: e,
|
|
676
|
+
path: []
|
|
677
|
+
}), b = (e, t) => ({
|
|
678
|
+
tag: "failure",
|
|
679
|
+
error: e.error,
|
|
680
|
+
path: [t, ...e.path]
|
|
681
|
+
}), x = (e) => typeof e > "u", S = (e) => typeof e == "string", C = (e) => typeof e == "object" && !!e, w = Symbol("propertyAbsent"), T = Symbol("omitProperty"), E = "Not an object", D = (e) => b(y("Property is missing"), {
|
|
682
|
+
tag: "object",
|
|
683
|
+
key: e
|
|
684
|
+
}), O = (e) => {
|
|
685
|
+
let t = Object.entries(e);
|
|
686
|
+
return (e) => {
|
|
687
|
+
if (!C(e)) return y(E);
|
|
688
|
+
let n = {};
|
|
689
|
+
for (let r = 0; r < t.length; r++) {
|
|
690
|
+
let [i, a] = t[r], o = e[i];
|
|
691
|
+
if (o === void 0 && !e.hasOwnProperty(i)) {
|
|
692
|
+
let e = a(w);
|
|
693
|
+
if (e.tag === "failure" || e.value === w) return D(i);
|
|
694
|
+
e.value !== T && (n[i] = e.value);
|
|
695
|
+
} else {
|
|
696
|
+
let e = a(o);
|
|
697
|
+
if (e.tag === "failure") return b(e, {
|
|
698
|
+
tag: "object",
|
|
699
|
+
key: i
|
|
700
|
+
});
|
|
701
|
+
n[i] = e.value;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return v(n);
|
|
705
|
+
};
|
|
706
|
+
}, k = (e) => x(e) ? v(e) : y("Not undefined"), A = (e) => S(e) ? v(e) : y("Not a string"), j = (...e) => (t) => {
|
|
707
|
+
for (let n of e) {
|
|
708
|
+
let e = n(t);
|
|
709
|
+
if (e.tag === "success") return v(e.value);
|
|
710
|
+
}
|
|
711
|
+
return y("No parser in the union matched");
|
|
712
|
+
}, M = (e) => j(N, k, e), N = (e) => e === w ? v(T) : y("not optional");
|
|
713
|
+
O({
|
|
714
|
+
name: A,
|
|
715
|
+
space: M(A),
|
|
716
|
+
uid: A,
|
|
717
|
+
id: A
|
|
718
|
+
});
|
|
719
|
+
//#endregion
|
|
720
|
+
export { _ as default };
|
package/dist/index.js
CHANGED
|
@@ -949,10 +949,10 @@ function ut(e) {
|
|
|
949
949
|
}
|
|
950
950
|
function dt(e, t) {
|
|
951
951
|
let n = st(e);
|
|
952
|
-
return n?.length ?
|
|
952
|
+
return n?.length ? mt(n, t) : "";
|
|
953
953
|
}
|
|
954
|
-
function
|
|
955
|
-
let n = e.type !== "text" && e.content ?
|
|
954
|
+
function ft(e, t) {
|
|
955
|
+
let n = e.type !== "text" && e.content ? mt(e.content, t) : "", r = t?.renderers?.[e.type];
|
|
956
956
|
if (r) {
|
|
957
957
|
let i = t?.renderers?.[e.type] ? {
|
|
958
958
|
...t,
|
|
@@ -967,18 +967,18 @@ function q(e, t) {
|
|
|
967
967
|
context: i
|
|
968
968
|
});
|
|
969
969
|
}
|
|
970
|
-
if (e.type === "text") return
|
|
970
|
+
if (e.type === "text") return ht(e, e.marks, t);
|
|
971
971
|
if (e.type === "blok") return console.warn("\"blok\" nodes require a custom renderer in renderRichText."), "";
|
|
972
972
|
let i = G(e);
|
|
973
973
|
if (!i) return n;
|
|
974
|
-
if (e.type === "image" && t?.optimizeImage) return
|
|
975
|
-
let a =
|
|
974
|
+
if (e.type === "image" && t?.optimizeImage) return pt(e, t);
|
|
975
|
+
let a = q(e.type, e.attrs);
|
|
976
976
|
if (K(i)) return `<${i}${a}>`;
|
|
977
|
-
if (e.type === "table") return `<${i}${a}>${
|
|
977
|
+
if (e.type === "table") return `<${i}${a}>${vt(e.content, t)}</${i}>`;
|
|
978
978
|
let o = lt(e);
|
|
979
|
-
return o ? `<${i}>${
|
|
979
|
+
return o ? `<${i}>${yt(e.type, o, e.attrs, n)}</${i}>` : `<${i}${a}>${n}</${i}>`;
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function pt(e, t) {
|
|
982
982
|
let n = e.attrs, r = n?.src, i = n;
|
|
983
983
|
if (r) {
|
|
984
984
|
let { src: e, attrs: a } = ze(r, t.optimizeImage);
|
|
@@ -988,28 +988,28 @@ function ft(e, t) {
|
|
|
988
988
|
...a
|
|
989
989
|
};
|
|
990
990
|
}
|
|
991
|
-
let a =
|
|
991
|
+
let a = q("image", i);
|
|
992
992
|
return a ? `<img${a}>` : "<img>";
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function mt(e, t) {
|
|
995
995
|
let n = "", r = 0, i = e.length;
|
|
996
996
|
for (; r < i;) {
|
|
997
997
|
let a = e[r], o = W(a);
|
|
998
998
|
if (o) {
|
|
999
999
|
let a = r + 1;
|
|
1000
1000
|
for (; a < i && nt(o, W(e[a]));) a++;
|
|
1001
|
-
n +=
|
|
1002
|
-
} else n +=
|
|
1001
|
+
n += _t(e, r, a, o, t), r = a;
|
|
1002
|
+
} else n += ft(a, t), r++;
|
|
1003
1003
|
}
|
|
1004
1004
|
return n;
|
|
1005
1005
|
}
|
|
1006
|
-
function
|
|
1006
|
+
function ht(e, t, n) {
|
|
1007
1007
|
let r = Ve(e.text);
|
|
1008
1008
|
if (!t?.length) return r;
|
|
1009
|
-
for (let e of t) r =
|
|
1009
|
+
for (let e of t) r = gt(r, e, n);
|
|
1010
1010
|
return r;
|
|
1011
1011
|
}
|
|
1012
|
-
function
|
|
1012
|
+
function gt(e, t, n) {
|
|
1013
1013
|
let r = n?.renderers?.[t.type];
|
|
1014
1014
|
if (r) return r({
|
|
1015
1015
|
...t,
|
|
@@ -1017,13 +1017,13 @@ function ht(e, t, n) {
|
|
|
1017
1017
|
context: n
|
|
1018
1018
|
});
|
|
1019
1019
|
let i = G(t);
|
|
1020
|
-
return i ? `<${i}${
|
|
1020
|
+
return i ? `<${i}${q(t.type, t.attrs)}>${e}</${i}>` : e;
|
|
1021
1021
|
}
|
|
1022
|
-
function
|
|
1022
|
+
function _t(e, t, n, r, i) {
|
|
1023
1023
|
let a = "";
|
|
1024
1024
|
for (let r = t; r < n; r++) {
|
|
1025
1025
|
let t = e[r], n = t.marks?.filter((e) => e.type !== "link");
|
|
1026
|
-
a +=
|
|
1026
|
+
a += ht(t, n, i);
|
|
1027
1027
|
}
|
|
1028
1028
|
let o = i?.renderers?.[r.type];
|
|
1029
1029
|
if (o) return o({
|
|
@@ -1032,41 +1032,41 @@ function gt(e, t, n, r, i) {
|
|
|
1032
1032
|
context: i
|
|
1033
1033
|
});
|
|
1034
1034
|
let s = G(r);
|
|
1035
|
-
return s ? `<${s}${
|
|
1035
|
+
return s ? `<${s}${q(r.type, r.attrs)}>${a}</${s}>` : a;
|
|
1036
1036
|
}
|
|
1037
|
-
function
|
|
1037
|
+
function vt(e, t) {
|
|
1038
1038
|
if (!e?.length) return "";
|
|
1039
1039
|
let n = 0;
|
|
1040
1040
|
for (; n < e.length && at(e[n]);) n++;
|
|
1041
1041
|
let r = "";
|
|
1042
1042
|
if (n > 0) {
|
|
1043
1043
|
r += "<thead>";
|
|
1044
|
-
for (let i = 0; i < n; i++) r +=
|
|
1044
|
+
for (let i = 0; i < n; i++) r += ft(e[i], t);
|
|
1045
1045
|
r += "</thead>";
|
|
1046
1046
|
}
|
|
1047
1047
|
if (n < e.length) {
|
|
1048
1048
|
r += "<tbody>";
|
|
1049
|
-
for (let i = n; i < e.length; i++) r +=
|
|
1049
|
+
for (let i = n; i < e.length; i++) r += ft(e[i], t);
|
|
1050
1050
|
r += "</tbody>";
|
|
1051
1051
|
}
|
|
1052
1052
|
return r;
|
|
1053
1053
|
}
|
|
1054
|
-
function
|
|
1054
|
+
function yt(e, t, n, r) {
|
|
1055
1055
|
let i = "";
|
|
1056
1056
|
for (let a of t) {
|
|
1057
|
-
let { tag: t, children: o, attrs: s } = a, c =
|
|
1057
|
+
let { tag: t, children: o, attrs: s } = a, c = q(e, {
|
|
1058
1058
|
...s,
|
|
1059
1059
|
...n
|
|
1060
1060
|
});
|
|
1061
1061
|
if (K(t)) i += `<${t}${c}>`;
|
|
1062
1062
|
else {
|
|
1063
|
-
let a = o ?
|
|
1063
|
+
let a = o ? yt(e, o, n, r) : r;
|
|
1064
1064
|
i += `<${t}${c}>${a}</${t}>`;
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
return i;
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function q(e, t) {
|
|
1070
1070
|
let n = U(e, t, {
|
|
1071
1071
|
colspan: "colspan",
|
|
1072
1072
|
rowspan: "rowspan"
|
|
@@ -1075,10 +1075,10 @@ function J(e, t) {
|
|
|
1075
1075
|
}
|
|
1076
1076
|
//#endregion
|
|
1077
1077
|
//#region src/utils/richtext-helpers.ts
|
|
1078
|
-
function
|
|
1078
|
+
function bt(e) {
|
|
1079
1079
|
return typeof e == "function" || typeof e == "object" && !!e && "isAstroComponentFactory" in e;
|
|
1080
1080
|
}
|
|
1081
|
-
function
|
|
1081
|
+
function xt(e, t) {
|
|
1082
1082
|
let n = U(e, t, {
|
|
1083
1083
|
colspan: "colspan",
|
|
1084
1084
|
rowspan: "rowspan"
|
|
@@ -1087,31 +1087,31 @@ function bt(e, t) {
|
|
|
1087
1087
|
}
|
|
1088
1088
|
//#endregion
|
|
1089
1089
|
//#region ../js-client/dist/index.mjs
|
|
1090
|
-
var
|
|
1090
|
+
var St = (e = "") => e.includes("/cdn/"), Ct = (e, t = 25, n = 1) => ({
|
|
1091
1091
|
...e,
|
|
1092
1092
|
per_page: t,
|
|
1093
1093
|
page: n
|
|
1094
|
-
}),
|
|
1094
|
+
}), wt = (e) => new Promise((t) => setTimeout(t, e)), Tt = (e = 0, t) => Array.from({ length: e }, t), Et = (e = 0, t = e) => {
|
|
1095
1095
|
let n = Math.abs(t - e) || 0, r = e < t ? 1 : -1;
|
|
1096
|
-
return
|
|
1097
|
-
},
|
|
1096
|
+
return Tt(n, (t, n) => n * r + e);
|
|
1097
|
+
}, Dt = async (e, t) => Promise.all(e.map(t)), Ot = (e = [], t) => e.map(t).reduce((e, t) => [...e, ...t], []), kt = (e) => {
|
|
1098
1098
|
if (/%[0-9A-F]{2}/i.test(e)) try {
|
|
1099
1099
|
return decodeURIComponent(e);
|
|
1100
1100
|
} catch {
|
|
1101
1101
|
return e;
|
|
1102
1102
|
}
|
|
1103
1103
|
return e;
|
|
1104
|
-
},
|
|
1104
|
+
}, At = (e, t, n) => {
|
|
1105
1105
|
let r = [];
|
|
1106
1106
|
for (let i in e) {
|
|
1107
1107
|
if (!Object.prototype.hasOwnProperty.call(e, i)) continue;
|
|
1108
1108
|
let a = e[i];
|
|
1109
1109
|
if (a == null) continue;
|
|
1110
1110
|
let o = n ? "" : encodeURIComponent(i), s;
|
|
1111
|
-
s = typeof a == "object" ?
|
|
1111
|
+
s = typeof a == "object" ? At(a, t ? t + encodeURIComponent(`[${o}]`) : o, Array.isArray(a)) : `${t ? t + encodeURIComponent(`[${o}]`) : o}=${encodeURIComponent(a)}`, r.push(s);
|
|
1112
1112
|
}
|
|
1113
1113
|
return r.join("&");
|
|
1114
|
-
},
|
|
1114
|
+
}, jt = (e) => {
|
|
1115
1115
|
let t = {
|
|
1116
1116
|
eu: "api.storyblok.com",
|
|
1117
1117
|
us: "api-us.storyblok.com",
|
|
@@ -1120,7 +1120,7 @@ var xt = (e = "") => e.includes("/cdn/"), St = (e, t = 25, n = 1) => ({
|
|
|
1120
1120
|
ca: "api-ca.storyblok.com"
|
|
1121
1121
|
};
|
|
1122
1122
|
return t[e] ?? t.eu;
|
|
1123
|
-
},
|
|
1123
|
+
}, Mt = class {
|
|
1124
1124
|
baseURL;
|
|
1125
1125
|
timeout;
|
|
1126
1126
|
headers;
|
|
@@ -1163,7 +1163,7 @@ var xt = (e = "") => e.includes("/cdn/"), St = (e, t = 25, n = 1) => ({
|
|
|
1163
1163
|
}
|
|
1164
1164
|
async _methodHandler(e) {
|
|
1165
1165
|
let t = `${this.baseURL}${this.url}`, n = null;
|
|
1166
|
-
e === "get" ? t = `${this.baseURL}${this.url}?${
|
|
1166
|
+
e === "get" ? t = `${this.baseURL}${this.url}?${At(this.parameters)}` : n = JSON.stringify(this.parameters);
|
|
1167
1167
|
let r = new URL(t), i = new AbortController(), { signal: a } = i, o = null;
|
|
1168
1168
|
this.timeout && (o = setTimeout(() => i.abort(), this.timeout));
|
|
1169
1169
|
try {
|
|
@@ -1210,32 +1210,32 @@ var xt = (e = "") => e.includes("/cdn/"), St = (e, t = 25, n = 1) => ({
|
|
|
1210
1210
|
});
|
|
1211
1211
|
});
|
|
1212
1212
|
}
|
|
1213
|
-
},
|
|
1213
|
+
}, Nt = {
|
|
1214
1214
|
DRAFT: "draft",
|
|
1215
1215
|
PUBLISHED: "published"
|
|
1216
1216
|
};
|
|
1217
|
-
Object.values(
|
|
1218
|
-
var
|
|
1217
|
+
Object.values(Nt);
|
|
1218
|
+
var Pt = 25, Ft = {
|
|
1219
1219
|
SMALL: 25,
|
|
1220
1220
|
MEDIUM: 50,
|
|
1221
1221
|
LARGE: 75
|
|
1222
|
-
},
|
|
1222
|
+
}, J = {
|
|
1223
1223
|
SINGLE_OR_SMALL: 50,
|
|
1224
1224
|
MEDIUM: 15,
|
|
1225
1225
|
LARGE: 10,
|
|
1226
1226
|
VERY_LARGE: 6
|
|
1227
|
-
},
|
|
1228
|
-
function
|
|
1227
|
+
}, It = 1e3, Y = 3;
|
|
1228
|
+
function Lt(e, t) {
|
|
1229
1229
|
let n = e.includes("/cdn/stories/"), r = e.split("/").length > 3 && !e.endsWith("/cdn/stories"), i = "find_by" in t;
|
|
1230
1230
|
return n && r || i;
|
|
1231
1231
|
}
|
|
1232
|
-
function
|
|
1233
|
-
return e <=
|
|
1232
|
+
function Rt(e) {
|
|
1233
|
+
return e <= Ft.SMALL ? J.SINGLE_OR_SMALL : e <= Ft.MEDIUM ? J.MEDIUM : e <= Ft.LARGE ? J.LARGE : J.VERY_LARGE;
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1236
|
-
return n.userRateLimit === void 0 ? n.serverHeadersRateLimit === void 0 ? r === void 0 ? !e || !t ||
|
|
1235
|
+
function X(e, t, n = {}, r) {
|
|
1236
|
+
return n.userRateLimit === void 0 ? n.serverHeadersRateLimit === void 0 ? r === void 0 ? !e || !t || Lt(e, t) ? J.SINGLE_OR_SMALL : Rt(t.per_page || Pt) : r : Math.min(n.serverHeadersRateLimit, It) : Math.min(n.userRateLimit, It);
|
|
1237
1237
|
}
|
|
1238
|
-
function
|
|
1238
|
+
function zt(e) {
|
|
1239
1239
|
if (!e) return null;
|
|
1240
1240
|
let t = e["x-ratelimit"] || e["X-RateLimit"], n = e["x-ratelimit-policy"] || e["X-RateLimit-Policy"];
|
|
1241
1241
|
if (!t && !n) return null;
|
|
@@ -1250,19 +1250,19 @@ function Rt(e) {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
return Object.keys(r).length > 0 ? r : null;
|
|
1252
1252
|
}
|
|
1253
|
-
function
|
|
1253
|
+
function Bt(e, t = !1) {
|
|
1254
1254
|
return {
|
|
1255
1255
|
userRateLimit: e,
|
|
1256
1256
|
serverHeadersRateLimit: void 0,
|
|
1257
1257
|
isManagementApi: t
|
|
1258
1258
|
};
|
|
1259
1259
|
}
|
|
1260
|
-
var
|
|
1260
|
+
var Vt = class extends Error {
|
|
1261
1261
|
constructor(e) {
|
|
1262
1262
|
super(e), this.name = "AbortError";
|
|
1263
1263
|
}
|
|
1264
1264
|
};
|
|
1265
|
-
function
|
|
1265
|
+
function Ht(e, t, n) {
|
|
1266
1266
|
if (!Number.isFinite(t)) throw TypeError("Expected `limit` to be a finite number");
|
|
1267
1267
|
if (!Number.isFinite(n)) throw TypeError("Expected `interval` to be a finite number");
|
|
1268
1268
|
let r = [], i = [], a = 0, o = !1, s = async () => {
|
|
@@ -1286,10 +1286,10 @@ function Vt(e, t, n) {
|
|
|
1286
1286
|
}), a < t && s();
|
|
1287
1287
|
});
|
|
1288
1288
|
return c.abort = () => {
|
|
1289
|
-
o = !0, i.forEach(clearTimeout), i = [], r.forEach((e) => e.reject(() => new
|
|
1289
|
+
o = !0, i.forEach(clearTimeout), i = [], r.forEach((e) => e.reject(() => new Vt("Throttle function aborted"))), r.length = 0;
|
|
1290
1290
|
}, c;
|
|
1291
1291
|
}
|
|
1292
|
-
var
|
|
1292
|
+
var Ut = class {
|
|
1293
1293
|
queues;
|
|
1294
1294
|
interval;
|
|
1295
1295
|
throttledRequestFn;
|
|
@@ -1298,7 +1298,7 @@ var Ht = class {
|
|
|
1298
1298
|
}
|
|
1299
1299
|
getQueue(e) {
|
|
1300
1300
|
let t = this.queues.get(e);
|
|
1301
|
-
return t || (t =
|
|
1301
|
+
return t || (t = Ht(this.throttledRequestFn, e, this.interval), this.queues.set(e, t)), t;
|
|
1302
1302
|
}
|
|
1303
1303
|
execute(e, ...t) {
|
|
1304
1304
|
return this.getQueue(e)(...t);
|
|
@@ -1311,7 +1311,7 @@ var Ht = class {
|
|
|
1311
1311
|
getQueueCount() {
|
|
1312
1312
|
return this.queues.size;
|
|
1313
1313
|
}
|
|
1314
|
-
},
|
|
1314
|
+
}, Z = {}, Q = {}, Wt = class {
|
|
1315
1315
|
client;
|
|
1316
1316
|
maxRetries;
|
|
1317
1317
|
retriesDelay;
|
|
@@ -1332,12 +1332,12 @@ var Ht = class {
|
|
|
1332
1332
|
let n = e.endpoint || t;
|
|
1333
1333
|
if (!n) {
|
|
1334
1334
|
let t = e.https === !1 ? "http" : "https";
|
|
1335
|
-
n = e.oauthToken ? `${t}://${
|
|
1335
|
+
n = e.oauthToken ? `${t}://${jt(e.region)}/v1` : `${t}://${jt(e.region)}/v2`;
|
|
1336
1336
|
}
|
|
1337
1337
|
let r = new Headers();
|
|
1338
1338
|
!e.oauthToken && typeof window < "u" || r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), e.headers && (e.headers.constructor.name === "Headers" ? e.headers.entries().toArray() : Object.entries(e.headers)).forEach(([e, t]) => {
|
|
1339
1339
|
r.set(e, t);
|
|
1340
|
-
}), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig =
|
|
1340
|
+
}), e.oauthToken && r.set("Authorization", e.oauthToken), this.rateLimitConfig = Bt(e.rateLimit, !!e.oauthToken), this.maxRetries = e.maxRetries || 10, this.retriesDelay = e.retriesDelay ?? 300, this.throttleManager = new Ut(this.throttledRequest.bind(this), 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.cvMode = e.cache?.cv ?? "auto", this.resolveCounter = 0, this.resolveNestedRelations = e.resolveNestedRelations || !0, this.stringifiedStoriesCache = {}, this.version = e.version || Nt.PUBLISHED, this.inlineAssets = e.inlineAssets || !1, this.client = new Mt({
|
|
1341
1341
|
baseURL: n,
|
|
1342
1342
|
timeout: e.timeout || 0,
|
|
1343
1343
|
headers: r,
|
|
@@ -1346,19 +1346,19 @@ var Ht = class {
|
|
|
1346
1346
|
});
|
|
1347
1347
|
}
|
|
1348
1348
|
parseParams(e) {
|
|
1349
|
-
return e.token ||= this.getToken(), !e.cv && this.cvMode === "auto" && (e.cv =
|
|
1349
|
+
return e.token ||= this.getToken(), !e.cv && this.cvMode === "auto" && (e.cv = Q[e.token]), Array.isArray(e.resolve_relations) ? e.resolve_relations = e.resolve_relations.map(kt).join(",") : typeof e.resolve_relations == "string" && (e.resolve_relations = kt(e.resolve_relations)), e.resolve_relations !== void 0 && (e.resolve_level = 2), e;
|
|
1350
1350
|
}
|
|
1351
1351
|
factoryParamOptions(e, t) {
|
|
1352
|
-
return
|
|
1352
|
+
return St(e) ? this.parseParams(t) : t;
|
|
1353
1353
|
}
|
|
1354
1354
|
makeRequest(e, t, n, r, i) {
|
|
1355
|
-
let a = this.factoryParamOptions(e,
|
|
1355
|
+
let a = this.factoryParamOptions(e, Ct(t, n, r));
|
|
1356
1356
|
return this.cacheResponse(e, a, void 0, i);
|
|
1357
1357
|
}
|
|
1358
1358
|
get(e, t = {}, n) {
|
|
1359
1359
|
t ||= {};
|
|
1360
1360
|
let r = `/${e}`;
|
|
1361
|
-
|
|
1361
|
+
St(r) && (t.version = t.version || this.version);
|
|
1362
1362
|
let i = this.factoryParamOptions(r, t);
|
|
1363
1363
|
return this.cacheResponse(r, i, void 0, n);
|
|
1364
1364
|
}
|
|
@@ -1366,23 +1366,23 @@ var Ht = class {
|
|
|
1366
1366
|
let i = t?.per_page || 25, a = `/${e}`.replace(/\/$/, ""), o = n ?? a.substring(a.lastIndexOf("/") + 1);
|
|
1367
1367
|
t.version = t.version || this.version;
|
|
1368
1368
|
let s = await this.makeRequest(a, t, i, 1, r);
|
|
1369
|
-
return
|
|
1369
|
+
return Ot([s, ...await Dt(Et(1, s.total ? Math.ceil(s.total / (s.perPage || i)) : 1), (e) => this.makeRequest(a, t, i, e + 1, r))], (e) => Object.values(e.data[o]));
|
|
1370
1370
|
}
|
|
1371
1371
|
post(e, t = {}, n) {
|
|
1372
|
-
let r = `/${e}`, i =
|
|
1372
|
+
let r = `/${e}`, i = X(void 0, void 0, this.rateLimitConfig, Y);
|
|
1373
1373
|
return this.throttleManager.execute(i, "post", r, t, n);
|
|
1374
1374
|
}
|
|
1375
1375
|
put(e, t = {}, n) {
|
|
1376
|
-
let r = `/${e}`, i =
|
|
1376
|
+
let r = `/${e}`, i = X(void 0, void 0, this.rateLimitConfig, Y);
|
|
1377
1377
|
return this.throttleManager.execute(i, "put", r, t, n);
|
|
1378
1378
|
}
|
|
1379
1379
|
patch(e, t = {}, n) {
|
|
1380
|
-
let r = `/${e}`, i =
|
|
1380
|
+
let r = `/${e}`, i = X(void 0, void 0, this.rateLimitConfig, Y);
|
|
1381
1381
|
return this.throttleManager.execute(i, "patch", r, t, n);
|
|
1382
1382
|
}
|
|
1383
1383
|
delete(e, t = {}, n) {
|
|
1384
1384
|
t ||= {};
|
|
1385
|
-
let r = `/${e}`, i =
|
|
1385
|
+
let r = `/${e}`, i = X(void 0, void 0, this.rateLimitConfig, Y);
|
|
1386
1386
|
return this.throttleManager.execute(i, "delete", r, t, n);
|
|
1387
1387
|
}
|
|
1388
1388
|
getStories(e = {}, t) {
|
|
@@ -1499,7 +1499,7 @@ var Ht = class {
|
|
|
1499
1499
|
}), this.stringifiedStoriesCache = {}, delete this.links[n], delete this.relations[n];
|
|
1500
1500
|
}
|
|
1501
1501
|
async cacheResponse(e, t, n, r) {
|
|
1502
|
-
let i =
|
|
1502
|
+
let i = At({
|
|
1503
1503
|
url: e,
|
|
1504
1504
|
params: t
|
|
1505
1505
|
}), a = this.cacheProvider();
|
|
@@ -1507,7 +1507,7 @@ var Ht = class {
|
|
|
1507
1507
|
let e = await a.get(i);
|
|
1508
1508
|
if (e) return Promise.resolve(e);
|
|
1509
1509
|
}
|
|
1510
|
-
let o = !
|
|
1510
|
+
let o = !St(e) && this.rateLimitConfig.isManagementApi ? Y : void 0, s = X(e, t, this.rateLimitConfig, o);
|
|
1511
1511
|
return new Promise(async (o, c) => {
|
|
1512
1512
|
try {
|
|
1513
1513
|
let n = await this.throttleManager.execute(s, "get", e, t, r);
|
|
@@ -1515,7 +1515,7 @@ var Ht = class {
|
|
|
1515
1515
|
let l = {
|
|
1516
1516
|
data: n.data,
|
|
1517
1517
|
headers: n.headers
|
|
1518
|
-
}, u =
|
|
1518
|
+
}, u = zt(n.headers);
|
|
1519
1519
|
if (u?.max !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = u.max), n.headers?.["per-page"] && (l = Object.assign({}, l, {
|
|
1520
1520
|
perPage: n.headers["per-page"] ? Number.parseInt(n.headers["per-page"]) : 0,
|
|
1521
1521
|
total: n.headers["per-page"] ? Number.parseInt(n.headers.total) : 0
|
|
@@ -1525,9 +1525,9 @@ var Ht = class {
|
|
|
1525
1525
|
}
|
|
1526
1526
|
t.version === "published" && e !== "/cdn/spaces/me" && await a.set(i, l);
|
|
1527
1527
|
let d = this.cache.clear === "onpreview" && t.version === "draft" || this.cache.clear === "auto";
|
|
1528
|
-
return t.token && l.data.cv && (d &&
|
|
1528
|
+
return t.token && l.data.cv && (d && Q[t.token] && Q[t.token] !== l.data.cv && await this.flushCache(), Q[t.token] = l.data.cv), o(l);
|
|
1529
1529
|
} catch (r) {
|
|
1530
|
-
if (r.response && r.status === 429 && (n = n === void 0 ? 0 : n + 1, n < this.maxRetries)) return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await
|
|
1530
|
+
if (r.response && r.status === 429 && (n = n === void 0 ? 0 : n + 1, n < this.maxRetries)) return console.log(`Hit rate limit. Retrying in ${this.retriesDelay / 1e3} seconds.`), await wt(this.retriesDelay), this.cacheResponse(e, t, n).then(o).catch(c);
|
|
1531
1531
|
c(r);
|
|
1532
1532
|
}
|
|
1533
1533
|
});
|
|
@@ -1536,31 +1536,31 @@ var Ht = class {
|
|
|
1536
1536
|
return this.client.setFetchOptions(r), this.client[e](t, n);
|
|
1537
1537
|
}
|
|
1538
1538
|
cacheVersions() {
|
|
1539
|
-
return
|
|
1539
|
+
return Q;
|
|
1540
1540
|
}
|
|
1541
1541
|
cacheVersion() {
|
|
1542
|
-
return
|
|
1542
|
+
return Q[this.accessToken];
|
|
1543
1543
|
}
|
|
1544
1544
|
setCacheVersion(e) {
|
|
1545
|
-
this.accessToken && (
|
|
1545
|
+
this.accessToken && (Q[this.accessToken] = e);
|
|
1546
1546
|
}
|
|
1547
1547
|
clearCacheVersion() {
|
|
1548
|
-
this.accessToken && (
|
|
1548
|
+
this.accessToken && (Q[this.accessToken] = 0);
|
|
1549
1549
|
}
|
|
1550
1550
|
cacheProvider() {
|
|
1551
1551
|
switch (this.cache.type) {
|
|
1552
1552
|
case "memory": return {
|
|
1553
1553
|
get(e) {
|
|
1554
|
-
return Promise.resolve(
|
|
1554
|
+
return Promise.resolve(Z[e]);
|
|
1555
1555
|
},
|
|
1556
1556
|
getAll() {
|
|
1557
|
-
return Promise.resolve(
|
|
1557
|
+
return Promise.resolve(Z);
|
|
1558
1558
|
},
|
|
1559
1559
|
set(e, t) {
|
|
1560
|
-
return
|
|
1560
|
+
return Z[e] = t, Promise.resolve(void 0);
|
|
1561
1561
|
},
|
|
1562
1562
|
flush() {
|
|
1563
|
-
return
|
|
1563
|
+
return Z = {}, Promise.resolve(void 0);
|
|
1564
1564
|
}
|
|
1565
1565
|
};
|
|
1566
1566
|
case "custom": if (this.cache.custom) return this.cache.custom;
|
|
@@ -1598,33 +1598,24 @@ var Ht = class {
|
|
|
1598
1598
|
};
|
|
1599
1599
|
return e.data.story && (e.data.story.content = t(e.data.story.content)), e.data.stories && (e.data.stories = e.data.stories.map((e) => (e.content = t(e.content), e))), e;
|
|
1600
1600
|
}
|
|
1601
|
-
},
|
|
1602
|
-
if (
|
|
1603
|
-
|
|
1601
|
+
}, Gt = !1, $, Kt = [], qt = () => typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Cannot load Storyblok bridge: window is undefined (server-side environment)")) : (window.storyblokRegisterEvent = (e) => {
|
|
1602
|
+
if (!window.location.search.includes("_storyblok")) {
|
|
1603
|
+
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
1604
1604
|
return;
|
|
1605
1605
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
}, document.getElementById("storyblok-javascript-bridge")) {
|
|
1613
|
-
t(void 0);
|
|
1614
|
-
return;
|
|
1615
|
-
}
|
|
1616
|
-
let r = document.createElement("script");
|
|
1617
|
-
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (e) => n(e), r.onload = (e) => {
|
|
1618
|
-
Gt.forEach((e) => e()), Wt = !0, t(e);
|
|
1619
|
-
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
1620
|
-
}), qt = (e = {}) => {
|
|
1606
|
+
Gt ? e() : Kt.push(e);
|
|
1607
|
+
}, Gt ? Promise.resolve() : $ || ($ = import("./index-CtMAhUF--DxA2RtMY.js").then(({ default: e }) => {
|
|
1608
|
+
window.StoryblokBridge = e, Kt.forEach((e) => e()), Gt = !0;
|
|
1609
|
+
}).catch((e) => {
|
|
1610
|
+
throw $ = void 0, e;
|
|
1611
|
+
}), $)), Jt = (e = {}) => {
|
|
1621
1612
|
let { apiOptions: t } = e;
|
|
1622
1613
|
if (!t || !t.accessToken) {
|
|
1623
1614
|
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");
|
|
1624
1615
|
return;
|
|
1625
1616
|
}
|
|
1626
|
-
return { storyblokApi: new
|
|
1627
|
-
},
|
|
1617
|
+
return { storyblokApi: new Wt(t) };
|
|
1618
|
+
}, Yt = (e) => {
|
|
1628
1619
|
if (typeof e != "object" || typeof e._editable != "string") return {};
|
|
1629
1620
|
try {
|
|
1630
1621
|
let t = JSON.parse(e._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
|
|
@@ -1635,9 +1626,9 @@ var Ht = class {
|
|
|
1635
1626
|
} catch {
|
|
1636
1627
|
return {};
|
|
1637
1628
|
}
|
|
1638
|
-
},
|
|
1629
|
+
}, Xt = (e = {}) => {
|
|
1639
1630
|
let { bridge: t, accessToken: n, use: r = [], apiOptions: i = {}, bridgeUrl: a } = e;
|
|
1640
|
-
i.accessToken = i.accessToken || n;
|
|
1631
|
+
a && console.warn("[Storyblok] The `bridgeUrl` option is deprecated and will be removed in a future major version. The Storyblok bridge is now bundled and is no longer loaded from a CDN URL."), i.accessToken = i.accessToken || n;
|
|
1641
1632
|
let o = {
|
|
1642
1633
|
bridge: t,
|
|
1643
1634
|
apiOptions: i
|
|
@@ -1647,9 +1638,9 @@ var Ht = class {
|
|
|
1647
1638
|
...s,
|
|
1648
1639
|
...e(o)
|
|
1649
1640
|
};
|
|
1650
|
-
})
|
|
1641
|
+
});
|
|
1651
1642
|
let c = !(typeof window > "u") && (window.location?.search)?.includes("_storyblok_tk");
|
|
1652
|
-
return t !== !1 && c &&
|
|
1653
|
-
}, Zt = () =>
|
|
1643
|
+
return t !== !1 && c && qt(), s;
|
|
1644
|
+
}, Zt = () => qt();
|
|
1654
1645
|
//#endregion
|
|
1655
|
-
export {
|
|
1646
|
+
export { Jt as apiPlugin, ut as attrsToHtmlString, xt as buildAstroAttrs, ze as buildStoryblokImage, rt as getInnerMarks, r as getLiveStory, i as getPayload, lt as getStaticChildren, it as groupLinkNodes, Oe as handleStoryblokMessage, Re as isEditorRequest, K as isSelfClosing, bt as isValidAstroComponent, Zt as loadStoryblokBridge, st as normalizeNodes, U as processAttrs, dt as renderRichText, G as resolveTag, te as sanitizeJSON, ot as splitTableRows, O as storyblok, Yt as storyblokEditable, Xt as storyblokInit, V as styleToString, b as toCamelCase, n as useStoryblokApi };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.2.
|
|
4
|
+
"version": "10.2.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"camelcase": "^8.0.0",
|
|
53
53
|
"morphdom": "^2.7.8",
|
|
54
|
-
"@storyblok/js": "6.
|
|
54
|
+
"@storyblok/js": "6.3.0",
|
|
55
55
|
"@storyblok/richtext": "5.2.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|