1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 206× 206× 206× 2× 1× 157× 157× | class ChangeHistory { constructor() { // undo list this.doneChanges = [] // redo list this.undoneChanges = [] // last change for accumlation this.lastChange = null } canUndo() { return this.doneChanges.length > 0 } canRedo() { return this.undoneChanges.length > 0 } push(change) { this.doneChanges.push(change) this.undoneChanges = [] } } export default ChangeHistory |