Prevent a particular mark to be deleted

I know that there is a filterTransaction method, where I can return false on some conditions to decline transaction (for example if a selected area has a particular mark). But if a selection has some text, nodes and marks and the user deletes selection, then everything except the specific mark should be deleted. How can I do it?

That’s not really possible, except by handling individual actions that might cause the deletion (handleTextInput, key bindings for delete/backspace/etc).

Key binding is not suitable because user can edit selection by many different methods, e.g. select and paste copied text from outside.

This question is similar to others:

  1. How can I disable the option to delete a custom node from prosesmirror?
  2. How to prevent node deletion?
  3. The content of non-editable node is still editable
  4. ProseMirror and Uneditable content in the document
  5. Whats an example of the minimal code required to undo a transformation?

This would be a quite handy feature to take control over transactions and to be able to allow/disallow action for each part (Node, TextNode, Mark, etc.) inside filterTransaction.