I am trying to combine Quill Rich text editor and socket.io. I would like to have an editor similar to Google docs where people can edit at the same time.
I'm struggling to send and apply "text change" events on a wire using code similar to this:
fullEditor.on('text-change', function(delta, source) {
if (source === 'user') {
socket.emit('text change', {'who': my_id, 'delta': JSON.stringify(delta)});
}
});
socket.on('text change', function(msg){
if(msg.who != my_id) {
var del = JSON.parse(msg.delta);
var Delta = fullEditor.getContents().constructor;
var delta = new Delta(del.startLength,del.endLength,del.ops);
fullEditor.updateContents( delta );
}
});
This does not work with
Uncaught TypeError: undefined is not a function | quill.js: 8020
since I have a simple hash on the other end, and quill expects objects of a certain type (InsertOp, http://quilljs.com/docs/editor/deltas/ , etc.).
Any ideas how to make it work?
source
share