supercharged-rte-serializer v1.0.535
JSON RTE SERIALIZER
Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. Read More.
This package helps the user to convert to JSON of the json_rte field to HTML and vice versa.
Installation
To get started with JavaScript, you will need the following:
- Node.js 10 or later
Install json-rte-serializer with npm
npm install json-rte-serializer
Usage/Examples
Convert value of json_rte field into html
import Component from 'my-project'
import { jsonToHtml } from "json-rte-serializer"
function App() {
const htmlValue = jsonToHtml({ JSON Value})
return <Component />
}
Convert html value into JSON to support json_rte field
import Component from 'my-project'
import { htmlToJson } from "json-rte-serializer"
function App() {
const htmlDomBody = new DOMParser().parseFromString("<p>This is Html Value</p>", 'text/html').body
const jsonValue = htmlToJson(htmlDomBody)
return <Component />
}
Example of conversion
[{
"uid":"767a479c6882471d9725852f042b67ce",
"type": "p",
"attrs":{},
"children" : [{"text": "hello world"}]
}]
<p>hello world</p>
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago