I’m loading plugins dynamically using ES6 dynamic imports. My API entry is through tiptap v2. What I’m now noticing that whenever I add the extension-gapcursor (which effectively is a thin layer over PMs gapcursor module) to be dynamically imported - I get an error.
This is the error:
Uncaught (in promise) RangeError: Adding different instances of a keyed plugin (plugin$)
Configuration2 state.js:50
Configuration2 state.js:48
reconfigure state.js:204
createView Editor.ts:273
Editor Editor.ts:85
<anonymous> main.ts:47
promise callback* main.ts:27
promise callback* main.ts:18
state.js:50:14
As a n00b this to me seems like some synthesized key somewhere (plugin$) that is somehow generated twice (is this like a pluginKey?). I tracked the origin of the plugins to:
prosemirror-keymap and
prosemirror-gapcursor
I do not have a clue what I can do about this. Could this be a issue in/with PM?
You’re somehow adding the same plugin (or two plugins with the same explicitly given key value) twice in your configuration. Shouldn’t be too hard to diagnose.
Okay - sorry this might sound like a stupid question, but given that I don’t knowingly load anything that I don’t specify how can I find out if prosemirror-state is loaded twice and what it is that is loading it twice?
npm ls prosemirror-state will show you whether you have multiple instances installed. But even if there’s only one there, whatever loading strategy you’re using might still end up loading it twice. You could add console.log statements to the top of node_modules/prosemirror-state/dist/*.js and see how many of them come by in your browser console.
Thank you for all your insights and help, in the mean time I think I spotted some suspicious looking code in tiptap v2, which I think introduces the duplicatie plugin$. I don’t have a clue how to prevent this from happening and/but I’ll direct my question to them.
For the record the code is in tiptap’s ExtensionManager on a getter of Plugin[] ~ which actually augments the plugins based on the property for addKeyboardShortcuts
Hey @pojo, don’t confuse the ProseMirror forum with all the Tiptap support channels (GitHub issues, GitHub discussions, Discord, Email). I feel bad if Tiptap users ask Marijn for help. On the one hand it’s hard for him to help with packages he doesn’t even know, and on the other hand it’s unlikely you’ll find solutions here. Please open an issue in the Tiptap repository and we’ll make sure to look into it:
In case someone is interested in the outcome of this specific issue. For my dev environment I managed to resolve it through configuring vitejs appropriately (I think).
install prosemirror-model, prosemirror-state, prosemirror-view and prosemirror-transform