@storyblok/astro 8.2.0 → 9.0.1
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 +1 -1
- package/dist/lib/client.d.ts +1 -0
- package/dist/lib/client.ts +3 -0
- package/dist/lib/richTextToHTML.ts +94 -0
- package/dist/public.d.ts +9 -3
- package/dist/storyblok-astro.es.js +58 -60
- package/dist/storyblok-astro.umd.js +14 -14
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">@storyblok/astro</h1>
|
|
6
6
|
<p>
|
|
7
|
-
The Astro SDK to interact with <a href="
|
|
7
|
+
The Astro SDK to interact with <a href="https://www.storyblok.com/docs/api/content-delivery/v2" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guides/astro/visual-preview#enable-live-preview-in-the-visual-editor" target="_blank">Real-time Visual Editing Experience</a>.
|
|
8
8
|
</p>
|
|
9
9
|
<br />
|
|
10
10
|
</div>
|
package/dist/lib/client.d.ts
CHANGED
package/dist/lib/client.ts
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentBlok,
|
|
3
|
+
richTextResolver,
|
|
4
|
+
type StoryblokRichTextNode,
|
|
5
|
+
type StoryblokRichTextOptions,
|
|
6
|
+
} from '@storyblok/js';
|
|
7
|
+
import { experimental_AstroContainer } from 'astro/container';
|
|
8
|
+
import StoryblokComponent from '@storyblok/astro/StoryblokComponent.astro';
|
|
9
|
+
|
|
10
|
+
// Lazily initialized Astro container (for rendering blok components)
|
|
11
|
+
let container: null | experimental_AstroContainer = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @experimental Converts a Storyblok RichText field into an HTML string.
|
|
15
|
+
*
|
|
16
|
+
* This API is still under development and may change in future releases.
|
|
17
|
+
* It also relies on Astro's experimental
|
|
18
|
+
* [experimental_AstroContainer](https://docs.astro.build/en/reference/container-reference/) feature.
|
|
19
|
+
*
|
|
20
|
+
* @async
|
|
21
|
+
* @param {StoryblokRichTextNode} richTextField - The root RichText node to convert.
|
|
22
|
+
* @param {StoryblokRichTextOptions['tiptapExtensions']} [tiptapExtensions] - Optional custom
|
|
23
|
+
* tiptap extensions for customizing how specific nodes or marks are rendered.
|
|
24
|
+
* @returns {Promise<string>} A promise that resolves to the HTML string representation
|
|
25
|
+
* of the provided RichText content.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```astro
|
|
29
|
+
* ---
|
|
30
|
+
* import { richTextToHTML } from '@storyblok/astro/client';
|
|
31
|
+
* const { blok } = Astro.props;
|
|
32
|
+
* const renderedRichText = await richTextToHTML(blok.text);
|
|
33
|
+
* ---
|
|
34
|
+
*
|
|
35
|
+
* <div set:html={renderedRichText} />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const richTextToHTML = async (
|
|
39
|
+
richTextField: StoryblokRichTextNode,
|
|
40
|
+
tiptapExtensions?: StoryblokRichTextOptions['tiptapExtensions'],
|
|
41
|
+
): Promise<string> => {
|
|
42
|
+
// Create Astro container only once
|
|
43
|
+
if (!container) {
|
|
44
|
+
container = await experimental_AstroContainer.create();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Collect async render results keyed by placeholder ID
|
|
48
|
+
const asyncReplacements: Promise<{ id: string; result: string }>[] = [];
|
|
49
|
+
|
|
50
|
+
const resolver = richTextResolver<string>({
|
|
51
|
+
tiptapExtensions: {
|
|
52
|
+
blok: ComponentBlok.configure({
|
|
53
|
+
renderComponent: (blok: Record<string, unknown>, _id?: string) => {
|
|
54
|
+
if (!blok || typeof blok !== 'object' || !container) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Generate unique placeholder ID
|
|
59
|
+
const id = crypto.randomUUID();
|
|
60
|
+
const placeholder = `<!--ASYNC-${id}-->`;
|
|
61
|
+
|
|
62
|
+
// Queue async render
|
|
63
|
+
const promise = container
|
|
64
|
+
.renderToString(StoryblokComponent, {
|
|
65
|
+
props: { blok },
|
|
66
|
+
})
|
|
67
|
+
.then(result => ({ id, result }))
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
console.error('Component rendering failed:', err);
|
|
70
|
+
return { id, result: '<!-- Component render error -->' };
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
asyncReplacements.push(promise);
|
|
74
|
+
return placeholder;
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
77
|
+
...tiptapExtensions,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
let html = resolver.render(richTextField);
|
|
82
|
+
// Wait for all async renders
|
|
83
|
+
const results = await Promise.all(asyncReplacements);
|
|
84
|
+
const replacements = new Map(
|
|
85
|
+
results.map(({ id, result }) => [id, result ?? '']),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Single-pass replacement using regex
|
|
89
|
+
html = html.replace(/<!--ASYNC-([\w-]+)-->/g, (_, id: string) => {
|
|
90
|
+
return replacements.get(id) ?? '';
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return html;
|
|
94
|
+
};
|
package/dist/public.d.ts
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* Provides IntelliSense, JSDoc, and type safety for SDK consumers.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
declare module 'virtual:storyblok-init' {
|
|
7
|
+
import type { StoryblokClient } from '@storyblok/astro';
|
|
8
|
+
|
|
9
|
+
export const storyblokApiInstance: StoryblokClient;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
declare module '@storyblok/astro/StoryblokComponent.astro' {
|
|
7
13
|
import type { SbBlokData } from '@storyblok/astro';
|
|
8
14
|
|
|
@@ -28,7 +34,7 @@ declare module '@storyblok/astro/client' {
|
|
|
28
34
|
import type {
|
|
29
35
|
StoryblokClient,
|
|
30
36
|
StoryblokRichTextNode,
|
|
31
|
-
|
|
37
|
+
StoryblokRichTextOptions,
|
|
32
38
|
} from '@storyblok/astro';
|
|
33
39
|
/**
|
|
34
40
|
* @experimental Converts a Storyblok RichText field into an HTML string.
|
|
@@ -39,7 +45,7 @@ declare module '@storyblok/astro/client' {
|
|
|
39
45
|
*
|
|
40
46
|
* @async
|
|
41
47
|
* @param {StoryblokRichTextNode} richTextField - The root RichText node to convert.
|
|
42
|
-
* @param {
|
|
48
|
+
* @param {StoryblokRichTextOptions['tiptapExtensions']} [tiptapExtensions] - Optional custom resolvers
|
|
43
49
|
* for customizing how specific nodes or marks are transformed into HTML.
|
|
44
50
|
* @returns {Promise<string>} A promise that resolves to the HTML string representation
|
|
45
51
|
* of the provided RichText content.
|
|
@@ -57,7 +63,7 @@ declare module '@storyblok/astro/client' {
|
|
|
57
63
|
*/
|
|
58
64
|
export function richTextToHTML(
|
|
59
65
|
richTextField: StoryblokRichTextNode,
|
|
60
|
-
|
|
66
|
+
tiptapExtensions?: StoryblokRichTextOptions['tiptapExtensions'],
|
|
61
67
|
): Promise<string>;
|
|
62
68
|
|
|
63
69
|
/**
|
|
@@ -41,7 +41,7 @@ function Xp(t) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function Qj() {
|
|
44
|
-
if (!
|
|
44
|
+
if (!globalThis?.storyblokApiInstance)
|
|
45
45
|
throw new Error("storyblokApiInstance has not been initialized correctly");
|
|
46
46
|
return globalThis.storyblokApiInstance;
|
|
47
47
|
}
|
|
@@ -154,8 +154,7 @@ function lc(t, e, o) {
|
|
|
154
154
|
|
|
155
155
|
// Manual imports (overwrite auto if same key exists)
|
|
156
156
|
${o.map((s) => {
|
|
157
|
-
|
|
158
|
-
const r = (i = s.match(/import\s+(\w+)\s+from/)) == null ? void 0 : i[1];
|
|
157
|
+
const r = s.match(/import\s+(\w+)\s+from/)?.[1];
|
|
159
158
|
return `storyblokComponents['${r}'] = ${r};`;
|
|
160
159
|
}).join(`
|
|
161
160
|
`)}
|
|
@@ -242,7 +241,7 @@ function ov(t) {
|
|
|
242
241
|
Xp(e)
|
|
243
242
|
]
|
|
244
243
|
}
|
|
245
|
-
}), c &&
|
|
244
|
+
}), c && h?.output !== "server")
|
|
246
245
|
throw new Error(
|
|
247
246
|
"To utilize the Astro Storyblok Live feature, Astro must be configured to run in SSR mode. Please disable this feature or switch Astro to SSR mode."
|
|
248
247
|
);
|
|
@@ -528,7 +527,7 @@ function Ec() {
|
|
|
528
527
|
const t = document.querySelector(
|
|
529
528
|
`meta[name="${Fc}"]`
|
|
530
529
|
);
|
|
531
|
-
return
|
|
530
|
+
return t?.content === "disabled" || t?.content === "false";
|
|
532
531
|
}
|
|
533
532
|
async function nv(t) {
|
|
534
533
|
const { action: e, story: o } = t || {};
|
|
@@ -566,13 +565,12 @@ async function Ac(t) {
|
|
|
566
565
|
Mc(o, n, s), Ga(or, { story: t });
|
|
567
566
|
}
|
|
568
567
|
function Sc(t, e) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (r.name === Kt)
|
|
568
|
+
const o = t.attributes.getNamedItem(Kt)?.value, a = e.attributes.getNamedItem(Kt)?.value;
|
|
569
|
+
o === a && Array.from(t.attributes).forEach((n) => {
|
|
570
|
+
if (n.name === Kt)
|
|
573
571
|
return;
|
|
574
|
-
const
|
|
575
|
-
(!e.hasAttribute(
|
|
572
|
+
const s = n.value, r = e.getAttribute(n.name);
|
|
573
|
+
(!e.hasAttribute(n.name) || r !== s) && e.setAttribute(n.name, s);
|
|
576
574
|
});
|
|
577
575
|
}
|
|
578
576
|
function Mc(t, e, o) {
|
|
@@ -633,7 +631,7 @@ function Ga(t, e, o = !1) {
|
|
|
633
631
|
}
|
|
634
632
|
function $c(t) {
|
|
635
633
|
const e = t.querySelector(`#${Ic}`);
|
|
636
|
-
if (!
|
|
634
|
+
if (!e?.textContent)
|
|
637
635
|
return null;
|
|
638
636
|
try {
|
|
639
637
|
return JSON.parse(e.textContent || "{}");
|
|
@@ -644,7 +642,7 @@ function $c(t) {
|
|
|
644
642
|
const zc = ["_storyblok", "_storyblok_c", "_storyblok_tk[space_id]"];
|
|
645
643
|
function sv(t, e) {
|
|
646
644
|
const o = t.searchParams;
|
|
647
|
-
return !(!zc.every((n) => o.has(n)) || e
|
|
645
|
+
return !(!zc.every((n) => o.has(n)) || e?.spaceId && o.get("_storyblok_tk[space_id]") !== e.spaceId);
|
|
648
646
|
}
|
|
649
647
|
var Nc = Object.defineProperty, Oc = (t, e, o) => e in t ? Nc(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, W = (t, e, o) => Oc(t, typeof e != "symbol" ? e + "" : e, o);
|
|
650
648
|
function pe(t) {
|
|
@@ -7691,7 +7689,7 @@ _s(ql, {
|
|
|
7691
7689
|
});
|
|
7692
7690
|
var Xd = () => ({ editor: t, view: e }) => (requestAnimationFrame(() => {
|
|
7693
7691
|
var o;
|
|
7694
|
-
t.isDestroyed || (e.dom.blur(), (o = window
|
|
7692
|
+
t.isDestroyed || (e.dom.blur(), (o = window?.getSelection()) == null || o.removeAllRanges());
|
|
7695
7693
|
}), !0), Yd = (t = !0) => ({ commands: e }) => e.setContent("", { emitUpdate: t }), Zd = () => ({ state: t, tr: e, dispatch: o }) => {
|
|
7696
7694
|
const { selection: a } = e, { ranges: n } = a;
|
|
7697
7695
|
return o && n.forEach(({ $from: s, $to: r }) => {
|
|
@@ -8054,7 +8052,7 @@ var xg = (t) => ({ editor: e, view: o, tr: a, dispatch: n }) => {
|
|
|
8054
8052
|
}), l = e.captureTransaction(() => {
|
|
8055
8053
|
o.someProp("handleKeyDown", (p) => p(o, i));
|
|
8056
8054
|
});
|
|
8057
|
-
return l
|
|
8055
|
+
return l?.steps.forEach((p) => {
|
|
8058
8056
|
const c = p.map(a.mapping);
|
|
8059
8057
|
c && n && a.maybeStep(c);
|
|
8060
8058
|
}), !0;
|
|
@@ -8247,7 +8245,7 @@ function Wg(t, e, o) {
|
|
|
8247
8245
|
return t.nodesBetween(a, n, (l, p, c, m) => {
|
|
8248
8246
|
var d;
|
|
8249
8247
|
l.isBlock && p > a && (i += s);
|
|
8250
|
-
const g = r
|
|
8248
|
+
const g = r?.[l.type.name];
|
|
8251
8249
|
if (g)
|
|
8252
8250
|
return c && (i += g({
|
|
8253
8251
|
node: l,
|
|
@@ -8256,7 +8254,7 @@ function Wg(t, e, o) {
|
|
|
8256
8254
|
index: m,
|
|
8257
8255
|
range: e
|
|
8258
8256
|
})), !1;
|
|
8259
|
-
l.isText && (i += (d = l
|
|
8257
|
+
l.isText && (i += (d = l?.text) == null ? void 0 : d.slice(Math.max(a, p) - p, n - p));
|
|
8260
8258
|
}), i;
|
|
8261
8259
|
}
|
|
8262
8260
|
function Ug(t) {
|
|
@@ -8328,7 +8326,7 @@ function Fs(t, e, o) {
|
|
|
8328
8326
|
...r
|
|
8329
8327
|
});
|
|
8330
8328
|
}) : o.nodesBetween(t, e, (n, s) => {
|
|
8331
|
-
!n ||
|
|
8329
|
+
!n || n?.nodeSize === void 0 || a.push(
|
|
8332
8330
|
...n.marks.map((r) => ({
|
|
8333
8331
|
from: s,
|
|
8334
8332
|
to: s + n.nodeSize,
|
|
@@ -8342,7 +8340,7 @@ var Yg = (t, e, o, a = 20) => {
|
|
|
8342
8340
|
let s = a, r = null;
|
|
8343
8341
|
for (; s > 0 && r === null; ) {
|
|
8344
8342
|
const i = n.node(s);
|
|
8345
|
-
|
|
8343
|
+
i?.type.name === e ? r = i : s -= 1;
|
|
8346
8344
|
}
|
|
8347
8345
|
return [r, s];
|
|
8348
8346
|
};
|
|
@@ -8523,7 +8521,7 @@ var au = (t, e = {}) => ({ tr: o, state: a, dispatch: n }) => {
|
|
|
8523
8521
|
function Br(t, e) {
|
|
8524
8522
|
const o = t.storedMarks || t.selection.$to.parentOffset && t.selection.$from.marks();
|
|
8525
8523
|
if (o) {
|
|
8526
|
-
const a = o.filter((n) => e
|
|
8524
|
+
const a = o.filter((n) => e?.includes(n.type.name));
|
|
8527
8525
|
t.tr.ensureMarks(a);
|
|
8528
8526
|
}
|
|
8529
8527
|
}
|
|
@@ -8619,7 +8617,7 @@ var cu = ({ keepMarks: t = !0 } = {}) => ({ tr: e, state: o, dispatch: a, editor
|
|
|
8619
8617
|
if (a === void 0)
|
|
8620
8618
|
return !0;
|
|
8621
8619
|
const n = t.doc.nodeAt(a);
|
|
8622
|
-
return o.node.type ===
|
|
8620
|
+
return o.node.type === n?.type && it(t.doc, o.pos) && t.join(o.pos), !0;
|
|
8623
8621
|
}, pn = (t, e) => {
|
|
8624
8622
|
const o = Ct((s) => s.type === e)(t.selection);
|
|
8625
8623
|
if (!o)
|
|
@@ -8628,7 +8626,7 @@ var cu = ({ keepMarks: t = !0 } = {}) => ({ tr: e, state: o, dispatch: a, editor
|
|
|
8628
8626
|
if (a === void 0)
|
|
8629
8627
|
return !0;
|
|
8630
8628
|
const n = t.doc.nodeAt(a);
|
|
8631
|
-
return o.node.type ===
|
|
8629
|
+
return o.node.type === n?.type && it(t.doc, a) && t.join(a), !0;
|
|
8632
8630
|
}, du = (t, e, o, a = {}) => ({ editor: n, tr: s, state: r, dispatch: i, chain: l, commands: p, can: c }) => {
|
|
8633
8631
|
const { extensions: m, splittableMarks: d } = n.extensionManager, g = oe(t, r.schema), u = oe(e, r.schema), { selection: f, storedMarks: h } = r, { $from: b, $to: j } = f, y = b.blockRange(j), I = h || f.$to.parentOffset && f.$from.marks();
|
|
8634
8632
|
if (!y)
|
|
@@ -8827,9 +8825,9 @@ var xs = class {
|
|
|
8827
8825
|
const { tr: a } = e.state, n = e.state.selection.$from;
|
|
8828
8826
|
if (n.pos === n.end()) {
|
|
8829
8827
|
const s = n.marks();
|
|
8830
|
-
if (!s.find((i) =>
|
|
8828
|
+
if (!s.find((i) => i?.type.name === o.name))
|
|
8831
8829
|
return !1;
|
|
8832
|
-
const r = s.find((i) =>
|
|
8830
|
+
const r = s.find((i) => i?.type.name === o.name);
|
|
8833
8831
|
return r && a.removeStoredMark(r), a.insertText(" ", n.pos), e.view.dispatch(a), !0;
|
|
8834
8832
|
}
|
|
8835
8833
|
return !1;
|
|
@@ -9295,7 +9293,7 @@ var Ru = (t) => "touches" in t, $u = class {
|
|
|
9295
9293
|
this.node = t.node, this.editor = t.editor, this.element = t.element, this.contentElement = t.contentElement, this.getPos = t.getPos, this.onResize = t.onResize, this.onCommit = t.onCommit, this.onUpdate = t.onUpdate, (e = t.options) != null && e.min && (this.minSize = {
|
|
9296
9294
|
...this.minSize,
|
|
9297
9295
|
...t.options.min
|
|
9298
|
-
}), (o = t.options) != null && o.max && (this.maxSize = t.options.max), (a = t
|
|
9296
|
+
}), (o = t.options) != null && o.max && (this.maxSize = t.options.max), (a = t?.options) != null && a.directions && (this.directions = t.options.directions), (n = t.options) != null && n.preserveAspectRatio && (this.preserveAspectRatio = t.options.preserveAspectRatio), (s = t.options) != null && s.className && (this.classNames = {
|
|
9299
9297
|
container: t.options.className.container || "",
|
|
9300
9298
|
wrapper: t.options.className.wrapper || "",
|
|
9301
9299
|
handle: t.options.className.handle || "",
|
|
@@ -9769,7 +9767,7 @@ function Pu(t) {
|
|
|
9769
9767
|
name: e,
|
|
9770
9768
|
level: "inline",
|
|
9771
9769
|
start(d) {
|
|
9772
|
-
const g = i ? new RegExp(`\\[${m}\\s*[^\\]]*\\]`) : new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`), u = d.match(g), f = u
|
|
9770
|
+
const g = i ? new RegExp(`\\[${m}\\s*[^\\]]*\\]`) : new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`), u = d.match(g), f = u?.index;
|
|
9773
9771
|
return f !== void 0 ? f : -1;
|
|
9774
9772
|
},
|
|
9775
9773
|
tokenize(d, g, u) {
|
|
@@ -10320,7 +10318,7 @@ var Zu = "listItem", Vr = "textStyle", Wr = /^(\d+)\.\s$/, up = X.create({
|
|
|
10320
10318
|
name: "orderedList",
|
|
10321
10319
|
level: "block",
|
|
10322
10320
|
start: (t) => {
|
|
10323
|
-
const e = t.match(/^(\s*)(\d+)\.\s+/), o = e
|
|
10321
|
+
const e = t.match(/^(\s*)(\d+)\.\s+/), o = e?.index;
|
|
10324
10322
|
return o !== void 0 ? o : -1;
|
|
10325
10323
|
},
|
|
10326
10324
|
tokenize: (t, e, o) => {
|
|
@@ -10468,7 +10466,7 @@ var Zu = "listItem", Vr = "textStyle", Wr = /^(\d+)\.\s$/, up = X.create({
|
|
|
10468
10466
|
return !1;
|
|
10469
10467
|
const f = g.doc.nodeAt(u);
|
|
10470
10468
|
return g.setNodeMarkup(u, void 0, {
|
|
10471
|
-
...f
|
|
10469
|
+
...f?.attrs,
|
|
10472
10470
|
checked: d
|
|
10473
10471
|
}), !0;
|
|
10474
10472
|
}).run(), !a.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (i.checked = !i.checked));
|
|
@@ -10870,7 +10868,7 @@ var ra = (t, e) => e.view.domAtPos(t).node.offsetParent !== null, nf = (t, e, o)
|
|
|
10870
10868
|
else
|
|
10871
10869
|
n.classList.toggle(this.options.openClassName);
|
|
10872
10870
|
const c = new Event("toggleDetailsContent"), m = i.querySelector(':scope > div[data-type="detailsContent"]');
|
|
10873
|
-
m
|
|
10871
|
+
m?.dispatchEvent(c);
|
|
10874
10872
|
};
|
|
10875
10873
|
return o.attrs.open && setTimeout(() => l()), r.addEventListener("click", () => {
|
|
10876
10874
|
if (l(), !this.options.persist) {
|
|
@@ -10884,7 +10882,7 @@ var ra = (t, e) => e.view.domAtPos(t).node.offsetParent !== null, nf = (t, e, o)
|
|
|
10884
10882
|
if (!d)
|
|
10885
10883
|
return !1;
|
|
10886
10884
|
const g = m.doc.nodeAt(d);
|
|
10887
|
-
return
|
|
10885
|
+
return g?.type !== this.type ? !1 : (m.setNodeMarkup(d, void 0, {
|
|
10888
10886
|
open: !g.attrs.open
|
|
10889
10887
|
}), !0);
|
|
10890
10888
|
}).setTextSelection({
|
|
@@ -10936,7 +10934,7 @@ var ra = (t, e) => e.view.domAtPos(t).node.offsetParent !== null, nf = (t, e, o)
|
|
|
10936
10934
|
const s = Oo(n.node, (h) => h.type === a.nodes.detailsSummary), r = Oo(n.node, (h) => h.type === a.nodes.detailsContent);
|
|
10937
10935
|
if (!s.length || !r.length)
|
|
10938
10936
|
return !1;
|
|
10939
|
-
const i = s[0], l = r[0], p = n.pos, c = t.doc.resolve(p), m = p + n.node.nodeSize, d = { from: p, to: m }, g = l.node.content.toJSON() || [], u = c.parent.type.contentMatch.defaultType, f = [u
|
|
10937
|
+
const i = s[0], l = r[0], p = n.pos, c = t.doc.resolve(p), m = p + n.node.nodeSize, d = { from: p, to: m }, g = l.node.content.toJSON() || [], u = c.parent.type.contentMatch.defaultType, f = [u?.create(null, i.node.content).toJSON(), ...g];
|
|
10940
10938
|
return e().insertContentAt(d, f).setTextSelection(p + 1).run();
|
|
10941
10939
|
}
|
|
10942
10940
|
};
|
|
@@ -11050,7 +11048,7 @@ var ra = (t, e) => e.view.domAtPos(t).node.offsetParent !== null, nf = (t, e, o)
|
|
|
11050
11048
|
const i = n.index(r.depth), { childCount: l } = r.node;
|
|
11051
11049
|
if (l !== i + 1)
|
|
11052
11050
|
return !1;
|
|
11053
|
-
const p = r.node.type.contentMatch.defaultType, c = p
|
|
11051
|
+
const p = r.node.type.contentMatch.defaultType, c = p?.createAndFill();
|
|
11054
11052
|
if (!c)
|
|
11055
11053
|
return !1;
|
|
11056
11054
|
const m = e.doc.resolve(r.pos + 1), d = l - 1, g = r.node.child(d), u = m.posAtIndex(d, r.depth);
|
|
@@ -11687,7 +11685,7 @@ function _p(t, { map: e, tableStart: o, table: a }, n) {
|
|
|
11687
11685
|
}), p += d.colspan - 1;
|
|
11688
11686
|
} else {
|
|
11689
11687
|
var l;
|
|
11690
|
-
const m = i == null ? ge(a.type.schema).cell : (l = a.nodeAt(e.map[c + i * e.width])) === null || l === void 0 ? void 0 : l.type, d = m
|
|
11688
|
+
const m = i == null ? ge(a.type.schema).cell : (l = a.nodeAt(e.map[c + i * e.width])) === null || l === void 0 ? void 0 : l.type, d = m?.createAndFill();
|
|
11691
11689
|
d && r.push(d);
|
|
11692
11690
|
}
|
|
11693
11691
|
return t.insert(s, ge(a.type.schema).row.create(null, r)), t;
|
|
@@ -12678,7 +12676,7 @@ var Eo = ({ editor: t }) => {
|
|
|
12678
12676
|
return !1;
|
|
12679
12677
|
let o = 0;
|
|
12680
12678
|
const a = Xl(e.ranges[0].$from, (n) => n.type.name === "table");
|
|
12681
|
-
return a
|
|
12679
|
+
return a?.node.descendants((n) => {
|
|
12682
12680
|
if (n.type.name === "table")
|
|
12683
12681
|
return !1;
|
|
12684
12682
|
["tableCell", "tableHeader"].includes(n.type.name) && (o += 1);
|
|
@@ -13112,7 +13110,7 @@ ${o}
|
|
|
13112
13110
|
handlePaste: (t, e) => {
|
|
13113
13111
|
if (!e.clipboardData || this.editor.isActive(this.type.name))
|
|
13114
13112
|
return !1;
|
|
13115
|
-
const o = e.clipboardData.getData("text/plain"), a = e.clipboardData.getData("vscode-editor-data"), n = a ? JSON.parse(a) : void 0, s = n
|
|
13113
|
+
const o = e.clipboardData.getData("text/plain"), a = e.clipboardData.getData("vscode-editor-data"), n = a ? JSON.parse(a) : void 0, s = n?.mode;
|
|
13116
13114
|
if (!o || !s)
|
|
13117
13115
|
return !1;
|
|
13118
13116
|
const { tr: r, schema: i } = t.state, l = i.text(o.replace(/\r\n?/g, `
|
|
@@ -13139,7 +13137,7 @@ function Dh(t) {
|
|
|
13139
13137
|
const f = i.pos - u.length, h = Array.from(u.matchAll(g)).pop();
|
|
13140
13138
|
if (!h || h.input === void 0 || h.index === void 0)
|
|
13141
13139
|
return null;
|
|
13142
|
-
const b = h.input.slice(Math.max(0, h.index - 1), h.index), j = new RegExp(`^[${s
|
|
13140
|
+
const b = h.input.slice(Math.max(0, h.index - 1), h.index), j = new RegExp(`^[${s?.join("")}\0]?$`).test(b);
|
|
13143
13141
|
if (s !== null && !j)
|
|
13144
13142
|
return null;
|
|
13145
13143
|
const y = f + h.index;
|
|
@@ -13174,7 +13172,7 @@ function Ch({
|
|
|
13174
13172
|
shouldShow: h
|
|
13175
13173
|
}) {
|
|
13176
13174
|
let b;
|
|
13177
|
-
const j = g
|
|
13175
|
+
const j = g?.(), y = () => {
|
|
13178
13176
|
const D = e.state.selection.$anchor.pos, C = e.view.coordsAtPos(D), { top: $, right: P, bottom: T, left: q } = C;
|
|
13179
13177
|
try {
|
|
13180
13178
|
return new DOMRect(q, $, P - q, T - $);
|
|
@@ -13182,8 +13180,8 @@ function Ch({
|
|
|
13182
13180
|
return null;
|
|
13183
13181
|
}
|
|
13184
13182
|
}, I = (D, C) => C ? () => {
|
|
13185
|
-
const $ = t.getState(e.state), P =
|
|
13186
|
-
return
|
|
13183
|
+
const $ = t.getState(e.state), P = $?.decorationId, T = D.dom.querySelector(`[data-decoration-id="${P}"]`);
|
|
13184
|
+
return T?.getBoundingClientRect() || null;
|
|
13187
13185
|
} : y;
|
|
13188
13186
|
function w(D, C) {
|
|
13189
13187
|
var $;
|
|
@@ -13191,15 +13189,15 @@ function Ch({
|
|
|
13191
13189
|
const T = t.getState(D.state), q = T != null && T.decorationId ? D.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`) : null, L = {
|
|
13192
13190
|
// @ts-ignore editor is available in closure
|
|
13193
13191
|
editor: e,
|
|
13194
|
-
range:
|
|
13195
|
-
query:
|
|
13196
|
-
text:
|
|
13192
|
+
range: T?.range || { from: 0, to: 0 },
|
|
13193
|
+
query: T?.query || null,
|
|
13194
|
+
text: T?.text || null,
|
|
13197
13195
|
items: [],
|
|
13198
|
-
command: (V) => m({ editor: e, range:
|
|
13196
|
+
command: (V) => m({ editor: e, range: T?.range || { from: 0, to: 0 }, props: V }),
|
|
13199
13197
|
decorationNode: q,
|
|
13200
13198
|
clientRect: I(D, q)
|
|
13201
13199
|
};
|
|
13202
|
-
($ = j
|
|
13200
|
+
($ = j?.onExit) == null || $.call(j, L);
|
|
13203
13201
|
} catch {
|
|
13204
13202
|
}
|
|
13205
13203
|
const P = D.state.tr.setMeta(C, { exit: !0 });
|
|
@@ -13228,14 +13226,14 @@ function Ch({
|
|
|
13228
13226
|
}),
|
|
13229
13227
|
decorationNode: $e,
|
|
13230
13228
|
clientRect: I(D, $e)
|
|
13231
|
-
}, N && ((T = j
|
|
13229
|
+
}, N && ((T = j?.onBeforeStart) == null || T.call(j, b)), H && ((q = j?.onBeforeUpdate) == null || q.call(j, b)), (H || N) && (b.items = await d({
|
|
13232
13230
|
editor: e,
|
|
13233
13231
|
query: de.query
|
|
13234
|
-
})), Ae && ((L = j
|
|
13232
|
+
})), Ae && ((L = j?.onExit) == null || L.call(j, b)), H && ((V = j?.onUpdate) == null || V.call(j, b)), N && ((B = j?.onStart) == null || B.call(j, b));
|
|
13235
13233
|
},
|
|
13236
13234
|
destroy: () => {
|
|
13237
13235
|
var D;
|
|
13238
|
-
b && ((D = j
|
|
13236
|
+
b && ((D = j?.onExit) == null || D.call(j, b));
|
|
13239
13237
|
}
|
|
13240
13238
|
};
|
|
13241
13239
|
},
|
|
@@ -13293,8 +13291,8 @@ function Ch({
|
|
|
13293
13291
|
if (!L)
|
|
13294
13292
|
return !1;
|
|
13295
13293
|
if (C.key === "Escape" || C.key === "Esc") {
|
|
13296
|
-
const B = F.getState(D.state), R = ($ = b
|
|
13297
|
-
if ((P = j
|
|
13294
|
+
const B = F.getState(D.state), R = ($ = b?.decorationNode) != null ? $ : null, Q = R ?? (B != null && B.decorationId ? D.dom.querySelector(`[data-decoration-id="${B.decorationId}"]`) : null);
|
|
13295
|
+
if ((P = j?.onKeyDown) != null && P.call(j, { view: D, event: C, range: B.range }))
|
|
13298
13296
|
return !0;
|
|
13299
13297
|
const se = {
|
|
13300
13298
|
editor: e,
|
|
@@ -13309,9 +13307,9 @@ function Ch({
|
|
|
13309
13307
|
// let consumer decide if they want to query.
|
|
13310
13308
|
clientRect: Q ? () => Q.getBoundingClientRect() || null : null
|
|
13311
13309
|
};
|
|
13312
|
-
return (T = j
|
|
13310
|
+
return (T = j?.onExit) == null || T.call(j, se), w(D, t), !0;
|
|
13313
13311
|
}
|
|
13314
|
-
return ((q = j
|
|
13312
|
+
return ((q = j?.onKeyDown) == null ? void 0 : q.call(j, { view: D, event: C, range: V })) || !1;
|
|
13315
13313
|
},
|
|
13316
13314
|
// Setup decorator on the currently active suggestion.
|
|
13317
13315
|
decorations(D) {
|
|
@@ -32743,7 +32741,7 @@ var Rh = new ae("emojiSuggestion"), $h = /:([a-zA-Z0-9_+-]+):$/, zh = /(^|\s):([
|
|
|
32743
32741
|
command: ({ editor: t, range: e, props: o }) => {
|
|
32744
32742
|
var a;
|
|
32745
32743
|
const n = t.view.state.selection.$to.nodeAfter;
|
|
32746
|
-
(a = n
|
|
32744
|
+
(a = n?.text) != null && a.startsWith(" ") && (e.to += 1), t.chain().focus().insertContentAt(e, [
|
|
32747
32745
|
{
|
|
32748
32746
|
type: this.name,
|
|
32749
32747
|
attrs: o
|
|
@@ -32814,7 +32812,7 @@ var Rh = new ae("emojiSuggestion"), $h = /:([a-zA-Z0-9_+-]+):$/, zh = /(^|\s):([
|
|
|
32814
32812
|
},
|
|
32815
32813
|
renderText({ node: t }) {
|
|
32816
32814
|
const e = Ht(t.attrs.name, this.options.emojis);
|
|
32817
|
-
return
|
|
32815
|
+
return e?.emoji || `:${t.attrs.name}:`;
|
|
32818
32816
|
},
|
|
32819
32817
|
renderMarkdown: (t) => {
|
|
32820
32818
|
var e;
|
|
@@ -33087,7 +33085,7 @@ var Rh = new ae("emojiSuggestion"), $h = /:([a-zA-Z0-9_+-]+):$/, zh = /(^|\s):([
|
|
|
33087
33085
|
if (l.nodeAfter)
|
|
33088
33086
|
l.nodeAfter.isTextblock ? r.setSelection(E.create(r.doc, l.pos + 1)) : l.nodeAfter.isBlock ? r.setSelection(x.create(r.doc, l.pos)) : r.setSelection(E.create(r.doc, l.pos));
|
|
33089
33087
|
else {
|
|
33090
|
-
const c = s.schema.nodes[this.options.nextNodeType] || l.parent.type.contentMatch.defaultType, m = c
|
|
33088
|
+
const c = s.schema.nodes[this.options.nextNodeType] || l.parent.type.contentMatch.defaultType, m = c?.create();
|
|
33091
33089
|
m && (r.insert(p, m), r.setSelection(E.create(r.doc, p + 1)));
|
|
33092
33090
|
}
|
|
33093
33091
|
r.scrollIntoView();
|
|
@@ -35252,8 +35250,8 @@ const fj = bh.extend({ renderHTML({ HTMLAttributes: t }) {
|
|
|
35252
35250
|
renderHTML({ HTMLAttributes: t }) {
|
|
35253
35251
|
var e;
|
|
35254
35252
|
return console.warn("[StoryblokRichText] - BLOK resolver is not available for vanilla usage. Configure `renderComponent` option on the blok tiptapExtension."), ["span", Ft({
|
|
35255
|
-
"data-blok": JSON.stringify(((e = t
|
|
35256
|
-
"data-blok-id": t
|
|
35253
|
+
"data-blok": JSON.stringify(((e = t?.body) == null ? void 0 : e[0]) ?? null),
|
|
35254
|
+
"data-blok-id": t?.id,
|
|
35257
35255
|
style: "display: none"
|
|
35258
35256
|
})];
|
|
35259
35257
|
}
|
|
@@ -35488,7 +35486,7 @@ function Up(t = {}) {
|
|
|
35488
35486
|
if (b.type === "text") return f(b);
|
|
35489
35487
|
if (b.type === "doc") return h(b);
|
|
35490
35488
|
const C = m.get(b.type);
|
|
35491
|
-
if (!((j = C
|
|
35489
|
+
if (!((j = C?.config) != null && j.renderHTML))
|
|
35492
35490
|
return console.error("<Storyblok>", `No extension found for node type ${b.type}`), "";
|
|
35493
35491
|
if ((y = C.options) != null && y.renderComponent) {
|
|
35494
35492
|
const P = (I = b.attrs) == null ? void 0 : I.body, T = (w = b.attrs) == null ? void 0 : w.id;
|
|
@@ -35519,7 +35517,7 @@ function Up(t = {}) {
|
|
|
35519
35517
|
return j.reduce((F, D) => {
|
|
35520
35518
|
var C;
|
|
35521
35519
|
const $ = d.get(D.type);
|
|
35522
|
-
return (C =
|
|
35520
|
+
return (C = $?.config) != null && C.renderHTML ? Vo(vn($, "mark", D.attrs || {}), g, F) : (console.error("<Storyblok>", `No extension found for node type ${D.type}`), F);
|
|
35523
35521
|
}, w);
|
|
35524
35522
|
}
|
|
35525
35523
|
const I = b.attrs || {};
|
|
@@ -35860,7 +35858,7 @@ var Zj = class {
|
|
|
35860
35858
|
return this.cacheResponse(a, n, void 0, o);
|
|
35861
35859
|
}
|
|
35862
35860
|
async getAll(t, e = {}, o, a) {
|
|
35863
|
-
const n =
|
|
35861
|
+
const n = e?.per_page || 25, s = `/${t}`.replace(/\/$/, ""), r = o ?? s.substring(s.lastIndexOf("/") + 1);
|
|
35864
35862
|
e.version = e.version || this.version;
|
|
35865
35863
|
const i = 1, l = await this.makeRequest(s, e, n, i, a);
|
|
35866
35864
|
return Hj([l, ...await Bj(Oj(i, l.total ? Math.ceil(l.total / (l.perPage || n)) : 1), (p) => this.makeRequest(s, e, n, p + 1, a))], (p) => Object.values(p.data[r]));
|
|
@@ -36060,7 +36058,7 @@ var Zj = class {
|
|
|
36060
36058
|
headers: m.headers
|
|
36061
36059
|
};
|
|
36062
36060
|
const g = Kj(m.headers);
|
|
36063
|
-
if (
|
|
36061
|
+
if (g?.max !== void 0 && (this.rateLimitConfig.serverHeadersRateLimit = g.max), (c = m.headers) != null && c["per-page"] && (d = Object.assign({}, d, {
|
|
36064
36062
|
perPage: m.headers["per-page"] ? Number.parseInt(m.headers["per-page"]) : 0,
|
|
36065
36063
|
total: m.headers["per-page"] ? Number.parseInt(m.headers.total) : 0
|
|
36066
36064
|
})), d.data.story || d.data.stories) {
|