-
-
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
Define new "block-updated" event. #2221
Comments
I think this is because the Therefore, there are two final actions:
This is why an update causes the This is the definition of the update function: editor.js/src/components/modules/api/blocks.ts Lines 291 to 311 in 870e265
This is the definition of the insert function: editor.js/src/components/modules/blockManager.ts Lines 266 to 322 in 870e265
It seems that the simple way is:
|
Why does it need to support a single eventRecently, I tried to make a binding between the YJS and EditorJS. This is to realize an idea. Please refer to here. FirstSince the synchronization EditorJS changes to the data model (YJS doc) is triggered by It is necessary to minimize unnecessary events and avoid performance waste. SecondIn the scenario of multi-person collaborative editing, directly removing and replacing the DOM of the entire block will cause the collaborator to lose the input focus, which will cause experience problems. Therefore, it is a good way to delegate the work of updating a specific block content to a specific plug-in. |
Good job! @neSpecc This issue has been resolved. So my work can be continue. |
Thank you for the fix @neSpecc . Marking as resolved. |
The question.
Why and how the question has come up.
When block is updated using
block.update(id, BlockToolData)
- EditorJSonChange
api gets called twice. once withblocked-removed
and later withblock-added
events.block-removed
andblock-added
events are also fired when the blocks are deleted / added to the EditorJS instance.Hence, from the onChange response, it is not possible to differentiate if block's content is updated or a new block is added / existing block is removed.
The text was updated successfully, but these errors were encountered: