Collaboration with non-js backend

Hey there,

I am implementing a simple collaborative editor with CodeMirror 6 for company internal purposes. The client side seems to be done, websocket connections have been set up for user presence and language changes (updating the editor language for all peers when changed).

Now it’s time for the big one: Merging the documents of all peers. I have read the examples and looked at example code but all examples expect a JS backend (Well at least the examples use functions and structures from @codemirror/collab, which is a node package).

I understand that CodeMirror may not have the time to create backend-collaboration-sdks for every language, but is there some kind of list of community packages for that? Every example I find always requires a node backend, since everyone is using @codemirror/collab because they can work with the ChangeSet-class for example.

So when using a Rust, Python, PHP, Go or whatever backend, the logic from the @codemirror/collab package (which is used in the backend examples) needs to be implemented by ourselves, correct?

Just asking in case we start to implement it and then find a “codemirror-collab-adaptors” repository for different languages after we built it :smiley:

Thanks in advance

I’m not aware of any implementations in languages other than JS, so far. But the model is pretty simple and such an implementation, especially if you use a simplified form of the document data structure (such as a big string or an array of lines), could be pretty straightforward.

So essentially, we just port collab.ts to our target backend (Python, in my case), and then create simplified versions of the imports from @codemirror/state? I had avoided doing so previously because I was concerned that the imports would make this considerably harder (there’s a lot of files in that module), but you make it sound much easier if I’m willing to do a more trivial data representation.

For those of us thinking about different backend ports, is there a place we should think about contributing these back to the community? I’m only modestly aware of the modern CodeMirror ecosystem, having been stuck in v5 for almost a decade now.

A bunch of that is client-side code you don’t need. But you will want a way to verify and possibly apply and rebase the change sets (as in rebaseUpdates).