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
transactionand returns a
Handler - A handler function takes the
editorViewand 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 README.md.
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.