Very Basic Custom Input Rule

Hey there,

im getting into prosemirror right now and im having a hard time since my js-knowledge is a bit rusty… Im got the Dino-Example (Link) running yesterday (yay :smiley: ) and currently im trying to implement a very basic input-rule.

Therefore i used this code:

let plugins = exampleSetup({schema: this.dinoSchema, menuContent: menu.fullMenu}); 
let dinoInput = new InputRule(/---$/, "test");
window.view = new EditorView(document.querySelector("#editor"), {
  state: EditorState.create({
    doc: startDoc,
    // Pass exampleSetup our schema and the menu we created
    plugins: plugins

When i run this im getting an error whenever i type something in the editor:

Uncaught TypeError: Cannot read property 'length' of undefined
at run (
at Plugin.handleTextInput (
at eval (
at EditorView.someProp (
at readDOMChange (
at DOMObserver.eval [as handleDOMChange] (
at DOMObserver.flush (
at (

Does anyone know what is going on here or what i can do to implement it the right way?

Sorry if im doing rookie-mistakes here :frowning:

I think you are using inputRules() incorrectly, please double check the API docs at .

Probably. My understanding so far is that i create an InputRule and use inputRule() to create a Plugin out of it. Is there anything wrong with that process? Are you aware of what exactly im doing wrong?

Thanks for the reply :slight_smile:

The docs ask for the argument to be an object with an array of rules in its rules property, so something like {rules: [dinoInput]}. Reading docs closely will save you a lot of time.

Im ashamed now :frowning:

Thank you for the quick response. I try to improve in the doc-reading department!