Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 360
Poul K. Sørensen Avatar asked Dec 01 '12 05:12

Poul K. Sørensen


2 Answers

You Can Use Firepad

FirePad is an open-source (on GitHub) realtime collaborative plug-in to codemirror. You can get it setup with codemirror in 4 extra lines of code and a few minutes. It's uses Firebase for the backend.

like image 57
DrFriedParts Avatar answered Sep 28 '22 14:09

DrFriedParts


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).

like image 44
Marijn Avatar answered Sep 28 '22 12:09

Marijn