Automerge integration

I am trying to build a text editor that uses an Automerge document, mainly because Automerge has a permanent history and merging which I can use as a basic version control system.

What would be the best way of using Automerge with codemirror? I found this repo from 3 years ago which keeps the two states separate and they update each other using a mutex lock, I wondered if it would be better to replace the codemirror-state module with a shim around an automerge document.