@storyblok/vue 10.1.9 → 11.0.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.
@@ -0,0 +1,57 @@
1
+ import { PropType } from 'vue';
2
+ import { SbRichTextMark, SbRichTextNode } from '@storyblok/richtext';
3
+ import { SbVueRichTextProps, SbVueRichTextRenderContext } from '../rich-text-renderer.ts';
4
+ declare const BlokRenderer: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
+ type: {
6
+ type: PropType<"blok">;
7
+ required: true;
8
+ };
9
+ attrs: {
10
+ type: PropType<SbVueRichTextProps["blok"]["attrs"]>;
11
+ required: false;
12
+ };
13
+ content: {
14
+ type: PropType<SbRichTextNode[]>;
15
+ required: false;
16
+ };
17
+ marks: {
18
+ type: PropType<SbRichTextMark[]>;
19
+ required: false;
20
+ };
21
+ _key: {
22
+ type: StringConstructor;
23
+ required: false;
24
+ };
25
+ context: {
26
+ type: PropType<SbVueRichTextRenderContext>;
27
+ required: false;
28
+ };
29
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
30
+ [key: string]: any;
31
+ }>[] | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
32
+ type: {
33
+ type: PropType<"blok">;
34
+ required: true;
35
+ };
36
+ attrs: {
37
+ type: PropType<SbVueRichTextProps["blok"]["attrs"]>;
38
+ required: false;
39
+ };
40
+ content: {
41
+ type: PropType<SbRichTextNode[]>;
42
+ required: false;
43
+ };
44
+ marks: {
45
+ type: PropType<SbRichTextMark[]>;
46
+ required: false;
47
+ };
48
+ _key: {
49
+ type: StringConstructor;
50
+ required: false;
51
+ };
52
+ context: {
53
+ type: PropType<SbVueRichTextRenderContext>;
54
+ required: false;
55
+ };
56
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
57
+ export default BlokRenderer;
@@ -1,16 +1,19 @@
1
- import { SbComponentProps } from '../types';
1
+ import { SbBlokData } from '../types.ts';
2
+ type __VLS_Props = {
3
+ blok: SbBlokData;
4
+ };
2
5
  declare function __VLS_template(): {
3
6
  attrs: Partial<{}>;
4
- slots: any;
7
+ slots: Partial<Record<string, (_: any) => any>>;
5
8
  refs: {
6
9
  blokRef: unknown;
7
10
  };
8
11
  rootEl: any;
9
12
  };
10
13
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
11
- declare const __VLS_component: import('vue').DefineComponent<SbComponentProps, {
14
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {
12
15
  value: import('vue').Ref<any, any>;
13
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SbComponentProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
16
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
14
17
  blokRef: unknown;
15
18
  }, any>;
16
19
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
@@ -1,3 +1,35 @@
1
- import { StoryblokRichTextProps } from '../types';
2
- declare const _default: import('vue').DefineComponent<StoryblokRichTextProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<StoryblokRichTextProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
1
+ import { PropType } from 'vue';
2
+ import { SbRichTextImageOptions, SbRichTextInput } from '@storyblok/richtext';
3
+ import { SbVueRichTextComponentMap } from '../rich-text-renderer';
4
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
+ document: {
6
+ type: PropType<SbRichTextInput>;
7
+ required: false;
8
+ };
9
+ optimizeImage: {
10
+ type: PropType<boolean | SbRichTextImageOptions>;
11
+ required: false;
12
+ };
13
+ components: {
14
+ type: PropType<SbVueRichTextComponentMap>;
15
+ required: false;
16
+ };
17
+ }>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
18
+ [key: string]: any;
19
+ }> | import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
20
+ [key: string]: any;
21
+ }>[] | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
22
+ document: {
23
+ type: PropType<SbRichTextInput>;
24
+ required: false;
25
+ };
26
+ optimizeImage: {
27
+ type: PropType<boolean | SbRichTextImageOptions>;
28
+ required: false;
29
+ };
30
+ components: {
31
+ type: PropType<SbVueRichTextComponentMap>;
32
+ required: false;
33
+ };
34
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
3
35
  export default _default;
@@ -0,0 +1,34 @@
1
+ import { SbVueRichTextRenderContext } from '../rich-text-renderer';
2
+ /**
3
+ * Creates a Storyblok Rich Text renderer.
4
+ *
5
+ * The returned render function can be used to transform Storyblok Rich Text
6
+ * documents into Vue VNodes using the provided configuration.
7
+ *
8
+ * Useful for configuring image optimization and custom node resolvers once
9
+ * and reusing the renderer across multiple rich text documents.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const render = useStoryblokRichText({
14
+ * optimizeImage: true,
15
+ * components: {
16
+ * heading: CustomHeading,
17
+ * },
18
+ * });
19
+ *
20
+ * const content = computed(() => render(story.content.richtext));
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```vue
25
+ * <script setup>
26
+ * const render = useStoryblokRichText();
27
+ * </script>
28
+ *
29
+ * <template>
30
+ * <component :is="render(blok.articleContent)" />
31
+ * </template>
32
+ * ```
33
+ */
34
+ export declare function useStoryblokRichText(props: SbVueRichTextRenderContext): (document: import('@storyblok/richtext').SbRichTextInput) => import('vue').VNode | import('vue').VNode[] | null;
@@ -0,0 +1,7 @@
1
+ import { Directive, GlobalDirectives } from 'vue';
2
+ /**
3
+ * Compile-time regression test for https://github.com/storyblok/monoblok/issues/620
4
+ * `v-editable` must be declared in Vue's `GlobalDirectives` so that
5
+ * vue-tsc/Volar recognize it in templates under `strictTemplates`.
6
+ */
7
+ export type VEditableIsGloballyDeclared = GlobalDirectives['vEditable'] extends Directive<HTMLElement> ? true : never;
package/dist/index.d.ts CHANGED
@@ -2,9 +2,10 @@ import { Plugin, Ref } from 'vue';
2
2
  import { ISbStoriesParams, ISbStoryData, StoryblokBridgeConfigV2, StoryblokClient } from './types';
3
3
  export { default as StoryblokComponent } from './components/StoryblokComponent.vue';
4
4
  export { default as StoryblokRichText } from './components/StoryblokRichText.vue';
5
- export * from './composables/useStoryblokRichText';
5
+ export { useStoryblokRichText } from './composables/use-storyblok-rich-text';
6
+ export type { SbVueRichTextComponentMap, SbVueRichTextProps, SbVueRichTextRenderContext } from './rich-text-renderer';
6
7
  export * from './types';
7
- export { apiPlugin, asTag, BlockTypes, ComponentBlok, LinkTypes, MarkTypes, renderRichText, richTextResolver, StoryblokClient, type StoryblokRichTextDocumentNode, type StoryblokRichTextImageOptimizationOptions, type StoryblokRichTextNode, type StoryblokRichTextNodeTypes, type StoryblokRichTextOptions, TextTypes, useStoryblokBridge, } from '@storyblok/js';
8
+ export { apiPlugin, StoryblokClient, useStoryblokBridge, } from '@storyblok/js';
8
9
  export declare const useStoryblokApi: () => StoryblokClient;
9
10
  export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams, bridgeOptions?: StoryblokBridgeConfigV2) => Promise<Ref<ISbStoryData<import('storyblok-js-client').ISbComponentType<string> & {
10
11
  [index: string]: any;
@@ -12,3 +13,5 @@ export declare const useStoryblok: (url: string, apiOptions?: ISbStoriesParams,
12
13
  [index: string]: any;
13
14
  }> | null>>;
14
15
  export declare const StoryblokVue: Plugin;
16
+ export { buildStoryblokImage, renderRichText, splitTableRows } from '@storyblok/richtext';
17
+ export type { SbRichTextDoc, SbRichTextImageOptions, SbRichTextMark, SbRichTextNode, SbRichTextProps, SbRichTextRenderContext, } from '@storyblok/richtext';
@@ -0,0 +1,24 @@
1
+ import { Component, VNode } from 'vue';
2
+ import { SbRichTextElement, SbRichTextElementByType, SbRichTextImageOptions, SbRichTextInput } from '@storyblok/richtext';
3
+ export type SbVueRichTextProps = SbRichTextElementByType<SbVueRichTextRenderContext>;
4
+ export type SbVueRichTextComponentMap = {
5
+ [K in SbRichTextElement]?: Component<SbVueRichTextProps[K]>;
6
+ };
7
+ export interface SbVueRichTextRenderContext {
8
+ optimizeImage?: boolean | Partial<SbRichTextImageOptions>;
9
+ components?: SbVueRichTextComponentMap;
10
+ }
11
+ /**
12
+ * Creates a Vue-compatible render function for Storyblok Rich Text documents.
13
+ *
14
+ * This is a factory that binds render-time configuration (such as image
15
+ * optimization and component overrides) and returns a reusable renderer
16
+ * function.
17
+ *
18
+ * The returned function is designed to be used directly inside Vue render
19
+ * functions or setup return functions, and will convert a normalized
20
+ * Storyblok rich text document into Vue VNodes.
21
+ *
22
+ * If the input is null or empty, it returns null.
23
+ */
24
+ export declare function createRichTextRenderer(options: SbVueRichTextRenderContext): (document: SbRichTextInput) => VNode | VNode[] | null;