-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0621b4
commit d131b1d
Showing
5 changed files
with
675 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
<script setup lang="ts"> | ||
import type { VNode } from "vue"; | ||
import type { StoryblokRichTextNode } from "@storyblok/js"; | ||
import { ref, watch, type VNode } from "vue"; | ||
import type { | ||
StoryblokRichTextNode, | ||
StoryblokRichTextResolvers, | ||
} from "@storyblok/js"; | ||
import { useStoryblokRichText } from "../composables/useStoryblokRichText"; | ||
import type { StoryblokRichTextProps } from "../types"; | ||
const props = defineProps<StoryblokRichTextProps>(); | ||
const { render } = useStoryblokRichText({ | ||
resolvers: props.resolvers ?? {}, | ||
}); | ||
const renderedDoc = ref(); | ||
const root = () => renderedDoc.value; | ||
const root = () => render(props.doc as StoryblokRichTextNode<VNode>); | ||
watch( | ||
[props.doc, props.resolvers], | ||
([doc, resolvers]) => { | ||
const { render } = useStoryblokRichText({ | ||
resolvers: (resolvers as StoryblokRichTextResolvers<VNode>) ?? {}, | ||
}); | ||
renderedDoc.value = render(doc as StoryblokRichTextNode<VNode>); | ||
}, | ||
{ | ||
immediate: true, | ||
} | ||
); | ||
</script> | ||
|
||
<template> | ||
<root /> | ||
</template> | ||
ß |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.