onChange shouldn't be fired when programmatically setting the editor's content #1907
-
Question Is there a way to prevent Context The editor emits The problem is that if the Furthermore, even setting a previously saved content object will mutate the
Furthermore:
Only way I found to make it work is as follows, which is not very elegant: //...
onChange: () => {
(async () => {
const content = await editorJS.save();
if (JSON.stringify(content.blocks) !== JSON.stringify(model.content.blocks)) {
model.content = content;
}
})();
},
//... |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
I have the same problem, using JSON.stringify is the worse solution, it will taken a lot of time |
Beta Was this translation helpful? Give feedback.
-
Same problem for us, there should be an option when inserting or updating a block where we can specify whether the onChange callback will be executed. Another option would be to configure our onChange callback when we register it to specify which type of change we want to listen to. |
Beta Was this translation helpful? Give feedback.
-
Spent hours trying to make editorjs collaborative and add auto save feature. In part of that, onChange event shouldn't be fired everytime the editor instance changes, best (but not good) solution I ever had was to artificially slow down the editorjs component. |
Beta Was this translation helpful? Give feedback.
-
When I use render to replace the old data, it trigger the onChange event, I was confused , I just want to replace the old data. what should I do ? |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
The
blocks.render()
should not leadonChange
call. Give more information: editor.js version, browser.