javascript - How to combine Quill Rich Text Editor and socket.io to exchange Deltas -


i trying combine quill rich text editor , socket.io. have editor similar google docs, people can edit simultaneously.

i struggling send , apply 'text-change' events across wire, using code similar 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 failing with

uncaught typeerror: undefined not function | quill.js:8020

as on other end have simple hash, , quill expects objects of specific type (insertop, http://quilljs.com/docs/editor/deltas/ etc.).

any ideas how make work?

the problem updatecontents expecting delta object , while create one, delta constructor expected array of operations objects.

the newest version (v0.14.0) updates updatecontents take plain javascript object should able do:

socket.on('text change', function(msg){   if(msg.who != my_id) {     var del = json.parse(msg.delta);     fulleditor.updatecontents( del );   } }); 

note implement realtime collaboration google docs need sort of conflict resolution. simplest platformized solution goinstant's ot api or can roll own library sharejs.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

ios - Change Storyboard View using Seague -

verilog - Systemverilog dynamic casting issues -