This PR solves the issue #254. The changes made were:
Implemented the jsondiffpatch library.
Implemented the undoStack and redoStack stacks, to store the done and undone changes.
Implemented the basicData attribute to store a copy of the editor state.
Updated the initialize method for initializing the basicData attribute.
Updated the clear method to clean the content of the undoStack and redoStack stacks.
Updated the editorDidUpdate method in terms of basicData.
Updated the save method to make use of the diff method from jsondiffpatch library and get the difference (delta) between the current basicData value and the entry changes, in order to add that delta in the undoStack and update the basicData with the entry changes.
Updated the undo method to make usage of the jsonpatchFormatter format from jsondiffpatch library, in order to get clear info about the delta stored in the top of the undoStack, and save it in the redoStack, in addition, make usage of the unpatch method from jsondiffpatch library to build the previous state of basicData, removing the changes specified in lastState(delta). In this point, we are deleting the element from the undoStack and saving it into redoStack.
Updated the redo method to make usage of the patch method from jsondiffpatch library to build the next state of basicData applying the changes contained in lastRedoState(delta). In this point, we are deleting the element from the redoStack.
Replaced in the other methods stack with undoStack.
Description
This PR solves the issue #254. The changes made were:
jsondiffpatch
library.undoStack
andredoStack
stacks, to store the done and undone changes.basicData
attribute to store a copy of the editor state.initialize
method for initializing thebasicData
attribute.clear
method to clean the content of theundoStack
andredoStack
stacks.editorDidUpdate
method in terms ofbasicData
.save
method to make use of thediff
method fromjsondiffpatch
library and get the difference (delta) between the currentbasicData
value and the entry changes, in order to add thatdelta
in theundoStack
and update thebasicData
with the entry changes.undo
method to make usage of thejsonpatchFormatter
format fromjsondiffpatch
library, in order to get clear info about thedelta
stored in thetop
of theundoStack
, and save it in theredoStack
, in addition, make usage of theunpatch
method fromjsondiffpatch
library to build the previous state ofbasicData
, removing the changes specified inlastState
(delta). In this point, we are deleting the element from theundoStack
and saving it intoredoStack
.redo
method to make usage of thepatch
method fromjsondiffpatch
library to build the next state ofbasicData
applying the changes contained inlastRedoState
(delta). In this point, we are deleting the element from theredoStack
.stack
withundoStack
.