Callback on delete specific node

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?

No. You’ll have to look at transactions and check the area covered by their changes.

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-utils findChildrenByType

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