-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Is there any library convert html to block of editorjs, or convert block to html #1232
Comments
Maybe I am wrong, but I think if you start editorjs with html as initial payload it will convert for blocks for you. Block to html you can find samples of code online. |
@gabrielmoterani Thank you for your reply. I have gotten some html pages with python spider from public website. Now I want to parse them to blocks of editorjs in backend, and then save these blocks to database. |
@qqqays Yeah, I need to convert HTML for EditorJs blocks too... What I am doing is using a nodejs lib to convert HTML to json and then iterating each item of this json, converting to blocks. But I dont think this is such a good ideia. HTML is very nested... It would be better if EditorJs provide us that api. If anyone knows a better way to do that, please share with us :) |
@gabrielmoterani Hello, bro! How is the work of parsing html into editor.js blocks? |
Well I am still struggling to make a good solution for my application. @qqqays can u share more details of your implementation? Can u share the code that converts jsdom to blocks? I tried to use a lib that named Hymalaya that converts html to JSON, but HTML object became so nested, thats impossible to iterate over it. Does anyone nows how Editorjs convert pasted content to blocks? |
@gabrielmoterani I put the project to https://github.com/qqqays/server4parseEditorJs. You can try it ; ) |
How did you do it? Please show me |
@proflinksgh I was able to take a clue from @qqqays's library and I used the following code block to convert an HTML string to EditorJS blocks: const editor = new EditorJS({
...
onReady: async () => {
if (dataIsHtml) {
await editor.blocks.renderFromHTML(data);
}
},
...
}); |
@Alchez Hello, I came across your reply as I am facing the same issue, did you change anything else except adding above code to the editorjs instance? Where can you get the outputted html string from?Also, if possible can I have a look at the code file? |
Hey @sushant-78, unfortunately the code is private on Github so I can't share it. We were receiving an HTML string from our backend server that we wanted to output as EditorJS blocks, that was our source. By just adding that Hope that helps. |
@Alchez Thanks, for quick reply, didn't need to try it out, worked out a solution,needed to migrate data, so wrote patch script for it |
@qqqays You are the savior. The solution works well with [email protected] but not the latest. Yet, you are the legend
|
i want to convert html to block (json structure of editorjs )
The text was updated successfully, but these errors were encountered: