peer-crdt-bind-codemirror
v0.1.1
Published
Binds a Codemirror editor and peer-crdt
Downloads
9
Readme
peer-crdt-bind-codemirror
Binds a Codemirror editor and peer-crdt.
Install
$ npm install peer-crdt-bind-codemirror
Example
const Codemirror = require('codemirror')
const bind = require('peer-crdt-bind-codemirror')
const crdt = ...
const editor = Codemirror.fromTextArea(document.getElementById('codemirror'))
// bind editor to a CRDT
const unbind = bind(crdt, editor)
// some time later ...
unbind()
API
bind (crdt, editor [, options])
Returns an unbind function.
Arguments:
crdt
: must be a CRDT of typetreedoc
editor
: an instance of Codemirroroptions
: optional object with the following shape:debounceMS
: how long (in miliseconds) after the last edit should the CRDT be updated. Default is2000
.
See example.
License
MIT