var CodeMirror = require('codemirror'); var ShareDBCodeMirror = require('sharedb-codemirror'); // ... var codeMirror = CodeMirror.fromTextArea(elem); ShareDBCodeMirror.attachDocToCodeMirror(shareDBDoc, codeMirror);
That's it. You now have two-way sync between ShareDB and CodeMirror. A full example is available in examples/.
Install with NPM
npm install sharedb-codemirror
Try it out
npm install npm start # in a couple of browsers... open http://localhost:7007
Try clicking the infinite monkeys button. Do it in both browsers. Wait for poetry to appear.
npm install npm test
With test coverage:
npm run test-cover open coverage/lcov-report/index.html