Sha256: 9e319b83796449a4b8931c89e35107d143cc146f36a299e9808c3dabf9084edd
Contents?: true
Size: 1.21 KB
Versions: 4
Compression:
Stored size: 1.21 KB
Contents
class Trix.UndoManager extends Trix.BasicObject constructor: (@composition) -> @undoEntries = [] @redoEntries = [] recordUndoEntry: (description, {context, consolidatable} = {}) -> previousEntry = @undoEntries[-1..][0] unless consolidatable and entryHasDescriptionAndContext(previousEntry, description, context) undoEntry = @createEntry({description, context}) @undoEntries.push(undoEntry) @redoEntries = [] undo: -> if undoEntry = @undoEntries.pop() redoEntry = @createEntry(undoEntry) @redoEntries.push(redoEntry) @composition.loadSnapshot(undoEntry.snapshot) redo: -> if redoEntry = @redoEntries.pop() undoEntry = @createEntry(redoEntry) @undoEntries.push(undoEntry) @composition.loadSnapshot(redoEntry.snapshot) canUndo: -> @undoEntries.length > 0 canRedo: -> @redoEntries.length > 0 # Private createEntry: ({description, context} = {}) -> description: description?.toString() context: JSON.stringify(context) snapshot: @composition.getSnapshot() entryHasDescriptionAndContext = (entry, description, context) -> entry?.description is description?.toString() and entry?.context is JSON.stringify(context)
Version data entries
4 entries across 4 versions & 1 rubygems