Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-prosemirror: RangeError: Adding different instances of a keyed plugin (plugin$) caused by adding an inputRules plugin #2216

Open
marekdedic opened this issue Nov 29, 2023 · 0 comments
Labels
type: bug 🪲 Something isn't working

Comments

@marekdedic
Copy link

marekdedic commented Nov 29, 2023

Summary

Hi, I am getting the error RangeError: Adding different instances of a keyed plugin (plugin$) when trying to use jest-prosemirror. I am aware of #1811 and I think this is a different issue.

Steps to reproduce

import { inputRules } from "prosemirror-inputrules";

createEditor(proseMirrorRoot, {
  plugins: [inputRules({ rules: [...] })],
})

Expected results

No error

Actual results

RangeError: Adding different instances of a keyed plugin (plugin$)

Possible Solution

The bug is caused because there are 2 plugins with the same key plugin$. One is the one passed by me, the second one is constructed here:

const state = createState(taggedDocument, [...plugins, inputRules({ rules })]);

Because inputRules() always produces the same key for the plugin, the 2 instances clash with each other.

I think the proper solution would be to remove the rules option from createEditor() altoghether and let the user create inputRules() themselves. In my case, I am actually getting the input rules plugin from another package, so I can't just pass the rules to jest-prosemirror directly easily...

@marekdedic marekdedic added the type: bug 🪲 Something isn't working label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant