Skip to content

Commit

Permalink
Merge pull request #849 from storyblok/next
Browse files Browse the repository at this point in the history
feat: deprecation warning for Richtext
  • Loading branch information
alvarosabu authored Aug 26, 2024
2 parents c8a3a45 + 5732541 commit 578f2c5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
17 changes: 16 additions & 1 deletion playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import StoryblokClient from 'storyblok-js-client'
import RichTextResolver from 'storyblok-js-client/richTextResolver'
import './style.css'

const headers = new Headers()
Expand All @@ -16,6 +17,20 @@ try {
version: 'draft',
resolve_relations: 'root.author',
})
const resolver = new RichTextResolver()

const paragraph = {
type: 'paragraph',
content: [
{
text: 'Bold and italic',
type: 'text',
marks: [{ type: 'bold' }, { type: 'italic' }],
},
],
}

const html = resolver.render(paragraph)

console.log(Storyblok.cacheVersions())

Expand All @@ -30,4 +45,4 @@ try {
console.error(error)
}

console.log(Storyblok)

6 changes: 3 additions & 3 deletions playground/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'vite'

import { resolve } from 'pathe'
/* import { resolve } from 'pathe' */

import { qrcode } from 'vite-plugin-qrcode'

Expand All @@ -9,9 +9,9 @@ export default defineConfig({
plugins: [
qrcode(), // only applies in dev mode
],
resolve: {
/* resolve: {
alias: {
'storyblok-js-client': resolve(__dirname, '../../src/index.ts'),
},
},
}, */
})
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Storyblok {
private resolveCounter: number
public relations: RelationsType
public links: LinksType
// TODO: Remove on v7.x.x
public richTextResolver: RichTextResolver
public resolveNestedRelations: boolean
private stringifiedStoriesCache: Record<string, string>
Expand Down
3 changes: 3 additions & 0 deletions src/richTextResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class RichTextResolver {
data?: ISbRichtext,
options: RenderOptions = { optimizeImages: false }
) {
console.warn(
"Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"
);
if (data && data.content && Array.isArray(data.content)) {
let html = ''

Expand Down

0 comments on commit 578f2c5

Please sign in to comment.