I’m embedding the prosemirror-search code into my editor.
I noticed that the decorations of another plugin of mine get deleted by the replaceCommand, when they fall in the replaced text.
I suspect this is inevitable, because the matching text is first deleted and then the replacing text is inserted, even when the two are almost the same.
Prosemirror-search is good at saving leaf nodes in the (regexp-)replaced text, but the decorations that were created as a consequence of those leaf nodes are deleted.
The general solution would be detecting the presence of those leaf nodes in the replaced ranges in the oldState
of apply() in my Plugin, and then rebuild their decorations when they are still there in the replaced portions in newState
.
Would it make sense adding a tr.setMeta(REPLACED_TEXT, {from, to})
to the replaceCommand
as a shortcut to notify all other plugins that a text replacement by prosemirror-search happened in the range from
… to
?
Every time I have to check for some changes in the document in state.apply() or appendTransaction() I’m afraid of dampening the performance and so the responsiveness of the editor. That’s the reason behind the question about a shortcut.