Hi,
I am not able to find any api or function in the docs which can be used to update the data.
Suppose I have updated data, and want to update the editorjs instance, I suppose something like this should be present.
editorJsInstance.setData(newData);
Can you please help in the same?
Glad to give more insight if required
Hi @vsvanshi
You can use render() and clear() methods to manipulate the data
@gohabereg
I call the render() with a very simple new set of data.
[{"type":"header","data":{"text":"Register now!","level":2}}]
I get the following error (I tried both the api.blocks.render() as well as the api.render(), but both give the stated error.):
Unhandled Rejection (TypeError): Cannot read property 'map' of undefined
The clear()' does empty the entire content. But iterating over the array of new data, and using theinsert()` gives a different error message.
Unhandled Rejection (TypeError): Cannot read property 'config' of undefined
To elaborate a bit more, I use it as a editor for a website configuration. Their is a possibility of multilanguage, so when you switch the language in the configuration, I want to replace the entire content, based on language.
I wrapped everything myself to use it in React. I now solved the issue by building in a 10ms delay. So after i change the language, I start a 'refresh' hidding the entire editor, and after 10ms the new editor for a different language is shown. This solves my issue, for now.
render() expects to full structure object to be passed, not only blocks array.
{
"time" : 1550476186479,
"blocks" : [ {...}, {...}, {...}],
"version" : "2.8.1"
}
Its not clear from docs) You can only pass {blocks[ your_blocks ]}, it works.
Resolved
Most helpful comment
render() expects to full structure object to be passed, not only blocks array.
{
"time" : 1550476186479,
"blocks" : [ {...}, {...}, {...}],
"version" : "2.8.1"
}
Its not clear from docs) You can only pass
{blocks[ your_blocks ]}, it works.