@storyblok/svelte 7.1.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
document: SbRichTextInput;
|
|
8
8
|
} & Record<string, unknown>;
|
|
9
9
|
|
|
10
|
-
const { document, components = {}, optimizeImage }: Props = $props();
|
|
10
|
+
const { document, components = {}, optimizeImage, data }: Props = $props();
|
|
11
11
|
const nodes = $derived.by(() => normalizeNodes(document, true));
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
|
-
<RenderChildren {nodes} options={{ components, optimizeImage }} />
|
|
14
|
+
<RenderChildren {nodes} options={{ components, optimizeImage, data }} />
|
|
@@ -16,18 +16,26 @@
|
|
|
16
16
|
|
|
17
17
|
const { node, options }: Props = $props();
|
|
18
18
|
const CustomComponent = $derived(
|
|
19
|
-
options.components
|
|
19
|
+
options.components ? options.components[node.type] : undefined,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// When passing context to a custom component, exclude that component type
|
|
23
|
+
// to prevent infinite loops if the custom component uses StoryblokRichText internally
|
|
24
|
+
const contextForCustom = $derived(
|
|
25
|
+
CustomComponent
|
|
26
|
+
? { ...options, components: { ...options.components, [node.type]: undefined } }
|
|
27
|
+
: options,
|
|
20
28
|
);
|
|
21
29
|
</script>
|
|
22
30
|
|
|
23
|
-
{#if
|
|
24
|
-
<
|
|
25
|
-
{
|
|
26
|
-
<CustomComponent {...node} context={options}>
|
|
27
|
-
{#if node.content}
|
|
31
|
+
{#if CustomComponent}
|
|
32
|
+
<CustomComponent {...node} context={contextForCustom}>
|
|
33
|
+
{#if node.type !== 'text' && node.content}
|
|
28
34
|
<RenderChildren nodes={node.content} {options} />
|
|
29
35
|
{/if}
|
|
30
36
|
</CustomComponent>
|
|
37
|
+
{:else if node.type === 'text'}
|
|
38
|
+
<RenderTextNodeWithMarks {node} marks={node.marks} {options} />
|
|
31
39
|
{:else if node.type === 'image'}
|
|
32
40
|
<RenderImage {node} {options} />
|
|
33
41
|
{:else if node.type === 'blok'}
|
|
@@ -3,6 +3,7 @@ import type { Component, Snippet } from 'svelte';
|
|
|
3
3
|
export interface SbSvelteRichTextRenderContext {
|
|
4
4
|
optimizeImage?: boolean | SbRichTextImageOptions;
|
|
5
5
|
components?: SbSvelteRichTextComponentMap;
|
|
6
|
+
data?: unknown;
|
|
6
7
|
}
|
|
7
8
|
type AnyComponent = Component<any>;
|
|
8
9
|
export type SbSvelteRichTextComponentMap = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "SDK to integrate Storyblok into your project using Svelte.",
|
|
7
7
|
"author": "Storyblok",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"svelte": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@storyblok/
|
|
43
|
-
"@storyblok/
|
|
42
|
+
"@storyblok/richtext": "5.2.0",
|
|
43
|
+
"@storyblok/js": "6.2.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@cypress/svelte": "^3.0.0",
|