javascript - Codemirror autocomplete and auto closing brackets doesnt trigger change event -


i have following problem. i've written server , client scripts node js work live collaboration code editing. 2 or more people can code in same instance of codemirror editor. until have enabled autocomplete feature , auto closing brackets working perfect, after did messed work. when use autocomplete list or when bracket or tag closed module not manually not recognized change. have inspected object codemirror instance returning , doesnt contain change have been done automatically. not strictly problem node js beacuse if want lets say, send changes server via ajax , save in file, wont happen beacuse not present in change object. had similiar problem , can help?

client code:

    var appcm = codemirror.fromtextarea(document.getelementbyid('app-cm'), {         mode: 'text/html',         theme: "monokai",         styleactiveline: true,         linenumbers: true,         matchbrackets: true,         indentunit: 4,         indentwithtabs: true,         autoclosetags: true,         autoclosebrackets: true,         matchtags: false,         extrakeys: {             "ctrl-space": "autocomplete",             "ctrl-q": function(appcm) {                 appcm.foldcode(appcm.getcursor());             }         },         foldgutter: true,         gutters: ["codemirror-linenumbers", "codemirror-foldgutter"],         readonly: access     });          appcm.on('change', function(i, op) {             socket.emit('change', op);         });          socket.on('change', function(data) {             appcm.replacerange(data.text, data.from, data.to);         }); 

server code:

socket.on('change', function(op) {     if(op.origin === '+input' || op.origin === 'paste' || op.origin === '+delete') {         clients.foreach(function(client) {             if(client !== socket)                 client.emit('change', op);         });     }; }); 

you explicitly filtering out changes origin isn't 1 of input/paste/delete. why doing that? you'll need propagate changes if want peers stay in sync.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -