I hope there can be a callback when a certain type of node is removed/added into a doc
Right now, I can do this using the
dispatchTransaction callback, but for adding, I need to scan all the steps’ fragments to find out the node types. For deleting, I will see no fragments, then I will have to scan the document to discover the removed nodes.
use a customized node view, since a nodeview has a constructor and a destroy function. But I have to implement the content-updating behavior myself.
I think adding this callback is useful when we want to count or manage nodes globally. Two usecases I have in mind:
auto label equaitions/pics with a number and update them automatically as new equations and images are inserted. We can also refer to them in text using Fig 2. or Eq 3. The references can be updated automatically also.
This is something you’ll have to do yourself based on the information in the transaction. The way the editor works it just sees a new document, and there’s no concept of individual nodes being added or removed.