-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json to html on frontend... #860
Comments
Duplicate of #676 A read-only init option is also in the Roadmap #837 It also depends on your needs. You can use a templating engine such as ejs or pug if you want server side rendering benefits. Since you said "on the frontend", you can also just write a function in client side javascript that renders elements as you need, iterating over function renderHTML(data) {
let result = ``;
for (let block of JSON.parse(data).blocks) {
switch (block.type) {
case 'paragraph':
result += `<p>${block.data.text}</p>`;
break;
case 'header':
result += `<h${block.data.level}>${block.data.text}</h${block.data.level}>`;
break;
case 'list':
...
}
}
return result;
} |
https://medium.com/@sumitvekariya7/editor-js-read-only-mode-in-angular-4f73192ed860 I have created readOnly view mode for angular using switchcase statement based on block type and I have used css classes given in editor.js iteslf, so It creates 100% same user interface. |
This seems like the best approach. Seems like you will need a rendering class for each custom block. |
If you want an extendable framework-free approach: https://github.com/pavittarx/editorjs-html. Use it in the browser, or node, extend it to suit your needs.
|
I've created a package for this purpose. editorjs-parser
It also is configurable. |
read-only mode is released with v2.19 |
Json string render HTML on frontend, how can it works?
The text was updated successfully, but these errors were encountered: