CodeMirror bindings for ShareDB. Adapted from @ejones's sharedb-codemirror.
var ShareDB = require('sharedb/lib/client');
var CodeMirror = require('codemirror');
var ShareDBCodeMirror = require('sharedb-codemirror');
// ...
var shareDBCodeMirror = new ShareDBCodeMirror(codeMirror, {key: 'content'));
shareDBCodeMirror.attachDoc(shareDBDoc, (error) => {
if (error) {
console.error(error);
}
});
That's it. You now have two-way sync between ShareDB and CodeMirror. A full example is available at example.
npm install https://github.com/nickasd/sharedb-codemirror
npm install
npm start
// in a couple of browsers...
open http://localhost:8080
Try editing both documents: the changes will appear in real time in the other browser windows.