shrey vijayvargiya
1 min readJun 3, 2022

--

Sure, but for the time being I am giving you the approach. Editor js return a data array in the same order as written in the editor and every object of the data array has keys - type and data.

All you have to do it render the correct HTML type using the key and pass the data into it.

for example, if this is the one object of the output array {

"type": "header",

"data": {

"text": "test",

"level": 2

}

}

than the output html will be

outputHTML = `<h1>{data.text}</h1>` for type header....

If you are using react them you jsut have to map the data array and render the element based on the key type. If you are using vanilla javascript here is the stackoverflow solution.

https://stackoverflow.com/questions/61916688/what-is-the-best-way-to-convert-editorjs-text-editor-json-to-html-elements

I hope its clear if not would be love to help more in detail.

--

--

shrey vijayvargiya
shrey vijayvargiya

Responses (1)