I am trying to maintain a list of mentions. When user add a mention node, I can insert some data like
{
userId: '1234',
username: 'test user name',
key: '@test user name'
}
I am trying to figure out how to delete the data when user delete the mention in the editor. Is there a callback api when user delete specific kind of node?
You could set up a plugin which compares oldState.doc to newState.doc to see mention nodes were removed. I did something like this using prosemirror-utilsfindChildrenByType
const mentionNodesBefore = findChildrenByType(oldState.doc, schema.nodes.mention);
const mentionNodesAfter = findChildrenByType(newState.doc, schema.nodes.mention);
// compare lists to figure out which ones were removed