How can I get / apply a delta change in the Ace editor?

I am also trying to synchronize two instances of the Ace editor. Therefore, when the user enters one, the other is updated.

Looking at my documents, I see that the EditSession change event says that it returns the change delta, and Document has the applyDeltas method.

So, I connected to this change event, and when it is fired, I call another document.applyDeltas and pass it, but it does not work.

I provoked their documents (and Google for an hour), but I don’t see how to synchronize them. Does anyone know how I can do this?

+4
source share
1 answer

Ok, I figured it out. Nothing beats src :)

The applyDeltas method in the document requires an array, and you need to capture data from the change event.

 //on editor1.change this.handleEditor1Changed = function (e) { var deltas = new Array(); deltas[0] = e.data; this.editor2.getSession().getDocument().applyDeltas(deltas); }; 
+4
source

All Articles