i tried dispatchTransaction, but i have no idea how to judge whether there is a ‘[’ ‘]’ or not
and after preventing ‘[’ text from being deleted ,the cursor must go 1 character forward and leaving ']'after it . i guess setSelection can help .but …
A plugin with a filterTransaction hook is probably the best way to do this. But in order to figure out whether a given transaction deletes such a node, you’ll need to read a bit more of the docs—this really isn’t a library where you can just poke at the objects you’re given to figure out what to do. You’ll probably want to use nodesBetween with the ranges from the step maps on the transaction to scan whether one of the nodes you want to preserve is in the replaced ranges, and cancel the transaction when that’s the case.