Hello,
I try to build my first project with CodeMirror and at the moment it works on the first steps well. But I would like to add an undo function. In my structure CodeMirror save the data via Ajax call if the focus on the CM instance is lost. This works well, but the Ajax call can be failed so on this case CodeMirror should undo all changes after the last saved call.
In short
- CM is openend with source code (first undo checkpoint)
- user does some changes
- focus of the window is lost, CM data is saved by Ajax call, Ajax call success (second undo checkpoint)
- user add some new changes
- focus is lost, CM data will be saved with Ajax call, Ajax failes - undo changes until step 3
How can I create the CM undo calls? I need only to jump back to the previous checkpoint.
Also on this structure I would like to add also a Ajax call, which saves the data every line or every 5 seconds. How can I do this with CM and use also the undo checkpoint structure?
Thanks
Phil