Prosemirror Composer (WIP)

Hello all.

Over the last few years, we have been working on a relatively complex Prosemirror project. As this project developed we ended up thinking about how we structured our code. For the most part our document handlers.

I am sure others are doing similar things. Just wanted to share our approach so far.


We decided to use the terms Modifier and Handler

  • Modifier - A modifier function takes a transaction and returns a transaction.
  • Handler - A handler function takes the editorView and composes the modifier functions and dispatches them.

The NPM Library (WIP)

Link - prosemirror-composer - npm

We have created a typed npm module that exports some wrapped functions to get you started. I am still working on the


This approach comes into its own once you start writing your own modifiers as you can write tests for those independently. Ill write some examples sometime soon.

Either way - just wanted to start some communication around the package on npm if people saw it… Keen to hear if people think this is worthwhile once the README is fleshed out a bit more.

1 Like

Interesting. How are you handling positions from multiple changes? Should positions for subsequent changes refer to the document created by the changes before them (in the argument list to composeModifiers), or can they all refer to the initial document?

It looks like the code does not handle mapping positions from the initial document, but that was what I was hoping for!