Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@storyblok/richtext
Advanced tools
A custom resolver for the Storyblok Richtext field.
If you are first-time user of the Storyblok, read the Getting Started guide to get a project ready in less than 5 minutes.
npm install @storyblok/richtext
or yarn
:
yarn add @storyblok/richtext
or pnpm
:
pnpm add @storyblok/richtext
import { richTextResolver } from '@storyblok/richtext'
const { render } = richTextResolver()
const html = render(doc)
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
<div>
${html}
</div>
`
To overwrite an existing resolver, you can pass a property called resolvers available on the richTextResolver
options.
import { MarkTypes, richTextResolver } from '@storyblok/richtext'
const html = richTextResolver({
resolvers: {
[MarkTypes.LINK]: (node) => {
return `<button href="${node.attrs?.href}" target="${node.attrs?.target}">${node.children}</button>`
},
},
}).render(doc)
It is possible to ensure correct typing support in a framework-agnostic way by using Typescript Generics
string
VNode
React.ReactElement
This way the @storyblok/richtext
is ignorant of framework specific types, avoiding having to import them and having vue
react
etc as dependencies.
// Vanilla
const options: SbRichtextOptions<string> = {
resolvers: {
[MarkTypes.LINK]: (node: Node<string>) => {
return `<button href="${node.attrs?.href}" target="${node.attrs?.target}">${node.children}</button>`
},
},
}
const html = richTextResolver<string>(options).render(doc)
// Vue
const options: SbRichtextOptions<VNode> = {
renderFn: h,
}
const root = () => richTextResolver<VNode>(options).render(doc)
pnpm install
This command will install the dependencies for the workspace, including the dependencies for the playgrounds under /playground
and different framework wrappers /packages
To run the vanilla Typescript playground:
pnpm run playground
Vue playground:
pnpm run playground:vue
React playground:
pnpm run playground:react
Alternatively you can run the following command to run all the playgrounds:
pnpm run playground:all
To build the core package:
pnpm run build
To build the wrappers under /packages
:
pnpm run build:packages
To lint the core package:
pnpm run lint
To lint the wrappers under /packages
:
pnpm run lint:packages
Alternatively, you can run the following command to fix the linting issues:
pnpm run lint:fix
To run the tests for the core package:
pnpm run test
Please see our contributing guidelines and our code of conduct. This project use semantic-release for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check this question about it in semantic-release FAQ
FAQs
Storyblok RichText Resolver
The npm package @storyblok/richtext receives a total of 24,124 weekly downloads. As such, @storyblok/richtext popularity was classified as popular.
We found that @storyblok/richtext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.