Skip to content

Commit

Permalink
Merge pull request #853 from storyblok/bugfix/add-option-to-supress-d…
Browse files Browse the repository at this point in the history
…eprecation-warning-richtext

fix: add option to supress deprecation warning
  • Loading branch information
alvarosabu authored Sep 4, 2024
2 parents c1c4e72 + 5c7f6e5 commit 94f4692
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 2 additions & 3 deletions playground/vanilla/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ try {
],
}

const html = resolver.render(paragraph)

console.log(Storyblok.cacheVersions())
const html = resolver.render(paragraph, {}, false)


document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
<pre>
Expand Down
14 changes: 10 additions & 4 deletions src/richTextResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ interface ISbFunction<T extends any[], R> {
(...args: T): R
}

let hasWarnedAboutDeprecation = false;

class RichTextResolver {
private marks: ISbNode
private nodes: ISbNode
Expand All @@ -81,11 +83,15 @@ class RichTextResolver {

public render(
data?: ISbRichtext,
options: RenderOptions = { optimizeImages: false }
options: RenderOptions = { optimizeImages: false },
deprecationWarning = true
) {
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(!hasWarnedAboutDeprecation && deprecationWarning) {
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/"
);
hasWarnedAboutDeprecation = true
}
if (data && data.content && Array.isArray(data.content)) {
let html = ''

Expand Down

0 comments on commit 94f4692

Please sign in to comment.