firebasecodemirrorfirepad

Real time collaboration with CodeMirror


I started this little project where I would do real time collaboration on code using CodeMirror.

I have a msgs system setup such its easy to pass objects from one user to another. My problem is getting it integrated with CodeMirror. I found out that it have events for onchange and a replaceRange(string, from, to).

I pass the onchange objects to the other users and uses the replaceRange to update the view. Problem is then when using replaceRange, it triggers an new onchange and it sends msgs back and forward. Anyone know if there are some way of updating the local view without it triggering an onchange. Or suggestings for other paths to take. (the msgs system is already set up and its easy to pass javascript objects to other clients).


Solution

  • To get this to work properly, you'll have to merge changes as well. See http://ot.substance.io/ for a demo of an open-source solution (also using CodeMirror).