ApplyDeltas in ACE Editor

I am trying to save changes in the Ace editor and then replay them. There's some kind of pseudo-code there - the bottom line is that the applyDeltas API doesn't seem to do anything for my editor. I am attached to the editor change event, click the delta conversion to array and try to play it later - I do not see any errors when running the code below, but I also do not see the changes in my editor.

thanks
Mustafa

shouldRecord = true; myStoredArray = new Array(); editor.on('change', function(e) { if(shouldRecord) { myStoredArray.push(e.data); } }); //on a button click shouldRecord = false; editor.getSession().setValue(''); //clear for(var currentDelta in myStoredArray) { editor.getSession().getDocument().applyDeltas(currentDelta); } 
+4
source share
1 answer

Of course I found the answer -

The applyDeltas(Object deltas) API accepts an array of deltas. Changing the correct example code above editor.getSession().getDocument().applyDeltas([currentDelta]) .

Hope this helps someone.

Mustafa

+4
source

Source: https://habr.com/ru/post/1495249/


All Articles