UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing systems.

28 lines (21 loc) 430 B
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