Node selection on backspace

I’m trying to add a special mark on a text node which will add a semi transparent background and a border around the text node after detecting a match to ‘@xx’ pattern (as in )

But while editing the text , everytime i tap the backspace key, i get a node selection and the previous selection is lost (the cursor vanish) (demo). Actually it’s the paragraph node wrapping the mark which get selected.

I make sure that it’s not any piece of the code i wrote causes it, (in the begining i thought some tr.setSelection(TextSelection.create(doc, from, to)) have caused it, i thought maybe a text selection was converted to a node selection) but then after i set a debugger after all those calls i found that none of them runs when the backspace is tapped)

I also haven’t any plugin attached to the backspace , except the one i got from prosemirror example module code bind(“Backspace”, undoInputRule); )

What could trigger the node selection on backspace ?

I tried to set selectable = false to the paragraph node in my schema but then when i hit backspace it’s the whole paragraph that is removed

There is functionality for creating a node selection on backspace (the selectNodeBefore command), but that should select a node before the cursor, not one around it. And in this case it shouldn’t apply. I can’t reproduce the issue in your demo—when I try to do what you’re doing in the screencast, backspace works as expected, and I’m not getting any node selections.