Binds a Codemirror editor and peer-crdt.
$ npm install peer-crdt-bind-codemirrorconst Codemirror = require('codemirror')
const bind = require('peer-crdt-bind-codemirror')
const crdt = ...
const cursorCrdt = ...
const editor = Codemirror.fromTextArea(document.getElementById('codemirror'))
// bind editor to an array CRDT
const unbind = bind.editor(crdt, editor)
// bind cursors to a register CRDT
const unbindCursors = bind.cursors(cursorCrdt, editor)
// some time later ...
unbind()
unbindCursors()Returns an unbind function.
Arguments:
crdt: must be a CRDT of typetreedoceditor: 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.
Returns an unbind function.
Arguments:
ipfs: IPFS nodecrdt: must be a CRDT of typemv-registereditor: an instance of Codemirroroptions: optional object with the following shape:debounceMS: how long (in miliseconds) after the cursor position changed should the CRDT be updated. Default is2000.
See example.
MIT