I am working on a note-taking app that uses ProseMirror as the editor. I want to achieve the feature that when the user searches, the editor will automatically scroll to the most relevant position calculated by other functions. Meanwhile, the search bar should NOT lose the input focus so the user can modify the search content. Therefore, the straightforward way of
editor.chain().focus().setTextSelection().run()
would not work.
I have found a way to set the editor selection without focus. But the view is not scrolled. I need it to scroll to the new selection.
Here is an illustration of the scenario
I tried
editor.commands.scrollIntoView()
It does not work. But
editor.commands.setTextSelection()
does change the selection of editor.view.
You can use ProseMirror directly (instead of TipTap objects), or finding the DOM node worked for me too:
Copied from SilentNotes