The question.
How to differentiate Block Update (vs) Block insert / delete.
Why and how the question has come up.
When block is updated using block.update(id, BlockToolData) - EditorJS onChange api gets called twice. once with blocked-removed and later with block-added events.
block-removed and block-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 question.
Why and how the question has come up.
When block is updated using
block.update(id, BlockToolData)- EditorJSonChangeapi gets called twice. once withblocked-removedand later withblock-addedevents.block-removedandblock-addedevents 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.