The upgrade of @codemirror/view 6.3.0 to 6.3.1 introduced an error that I have been trying to figure out.
The following sequence of events throws an Uncaught RangeError: Trying to find position for a DOM position outside of the document
const view = new EditorView({
state: EditorState.create(),
parent: document.getElementById('editor')
})
Then, you click in the editor somewhere. Then, you call a function that does this:
view.setState(EditorState.create())
This will throw the RangeError. Crucially, if you don’t actually click in the editor, it won’t throw the error, so I’m wondering if it has something to do with selections.
The issue isn’t the empty state, I only am using that here to show that the error occurs even with no extensions at all. I bisected the various releases of codemirror to figure out where the bug started happening, so hopefully this is helpful. For now, I’ve downgraded to 6.3.0.
I’m not able to reproduce this in the Try CodeMirror, although I’m having to use setTimeout instead of triggering an action from a button like I’m doing in my application.
I’ll see if I can figure out exactly which commit broke it or otherwise provide more detail to help chase this down.
Confirmed. The same problem is on the latest version, 6.7.3.
(As an aside, our company contributes a modest monthly fee to your cause via GitHub subscriptions. I read somewhere that you asked folks to mention that when commenting here!)