Closed chb1828 closed 4 years ago
The reason you have encountered this error, is because the parser is not able to initialise with data you provided. The possible solutions are
blocks
variable inside an object.blocks = [{"data":{"text":"내용<br>"},"type":"paragraph"},{"data":{"text":"헤더1","level":2},"type":"header"},{"data":{"style":"ordered","items":["리스트1","리스트2"]},"type":"list"}]
//contents is string
const edjsParser = edjsHTML();
let html = edjsParser.parse({blocks});
blocks
key of the object.contents = [{"data":{"text":"내용<br>"},"type":"paragraph"},{"data":{"text":"헤더1","level":2},"type":"header"},{"data":{"style":"ordered","items":["리스트1","리스트2"]},"type":"list"}]
//contents is string
const edjsParser = edjsHTML();
let html = edjsParser.parse({blocks: contents});
const block = {"data":{"text":"내용<br>"},"type":"paragraph"};
const html = edjsParser.parseBlock(block);
editorjs keeps all its data under the blocks
property. So, you must pass it under the same name. You can use any of the provided approaches above. If you encounter any other issues, let me know.
Thanks to your answer I solved it.
how to solve this problem in html?