-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from storyblok/feature/replace-sb-types-naming…
…-to-storyblok feat(types)!: replace sb types naming to storyblok
- Loading branch information
Showing
23 changed files
with
205 additions
and
205 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react' | ||
|
||
import { forwardRef } from 'react' | ||
import { convertAttributesInElement } from './utils' | ||
import { useStoryblokRichTextResolver } from '.' | ||
import { StoryblokRichTextNode, StoryblokRichTextResolvers } from '@storyblok/richtext' | ||
|
||
interface StoryblokRichTextProps { | ||
doc: StoryblokRichTextNode<React.ReactElement> // Try to avoid 'any' by specifying a more accurate type | ||
resolvers?: StoryblokRichTextResolvers<React.ReactElement> // Same here for resolvers | ||
} | ||
|
||
// If you're forwarding a ref to StoryblokRichText | ||
const StoryblokRichText = forwardRef<HTMLDivElement, StoryblokRichTextProps>(({ doc, resolvers }, ref) => { | ||
// Assuming useStoryblokRichTextResolver is a hook you've created | ||
const { render } = useStoryblokRichTextResolver({ | ||
resolvers, | ||
}) | ||
|
||
/* const Root = () => render(doc) */ | ||
const html = render(doc) | ||
const formattedHtml = convertAttributesInElement(html) | ||
|
||
// If you're forwarding a ref, make sure to attach the ref to a DOM element. | ||
// For example, wrapping <Root /> in a div and attaching the ref to it: | ||
return <div ref={ref}>{formattedHtml}</div> | ||
}) | ||
|
||
export default StoryblokRichText |
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script setup lang="ts"> | ||
import { VNode } from 'vue'; | ||
import { useStoryblokRichTextResolver } from '..' | ||
import { StoryblokRichTextNode } from '@storyblok/richtext'; | ||
import { StoryblokRichTextProps } from '../types' | ||
const props = defineProps<StoryblokRichTextProps>() | ||
const { render } = useStoryblokRichTextResolver({ | ||
resolvers: props.resolvers, | ||
}) | ||
const root = () => render(props.doc as StoryblokRichTextNode<VNode>) | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { VNode } from 'vue'; | ||
import { SbRichTextDocumentNode, SbRichTextResolvers } from '@storyblok/richtext'; | ||
import { StoryblokRichTextDocumentNode, StoryblokRichTextResolvers } from '@storyblok/richtext'; | ||
|
||
export interface SbRichTextProps { | ||
doc: SbRichTextDocumentNode; | ||
resolvers: SbRichTextResolvers<VNode> | ||
export interface StoryblokRichTextProps { | ||
doc: StoryblokRichTextDocumentNode; | ||
resolvers: StoryblokRichTextResolvers<VNode> | ||
} |
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
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.