1.0.535 • Published 3 years ago

supercharged-rte-serializer v1.0.535

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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>
1.0.530

3 years ago

1.0.535

3 years ago

1.0.532

3 years ago

1.0.531

3 years ago

1.0.534

3 years ago

1.0.533

3 years ago

1.0.529

3 years ago

1.0.528

3 years ago

1.0.525

3 years ago

1.0.524

3 years ago

1.0.527

3 years ago

1.0.526

3 years ago

1.0.521

3 years ago

1.0.520

3 years ago

1.0.523

3 years ago

1.0.522

3 years ago

1.0.519

3 years ago

1.0.518

3 years ago

1.0.517

3 years ago

1.0.514

3 years ago

1.0.513

3 years ago

1.0.516

3 years ago

1.0.515

3 years ago

1.0.510

3 years ago

1.0.512

3 years ago

1.0.511

3 years ago

1.0.509

3 years ago

1.0.508

3 years ago

1.0.507

3 years ago

1.0.506

3 years ago

1.0.505

3 years ago

1.0.504

3 years ago

1.0.503

3 years ago

1.0.502

3 years ago

1.0.501

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.41

3 years ago

1.0.4

3 years ago

1.0.31

3 years ago

1.0.3

3 years ago

1.0.21

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago