# tinymce.UndoManager

Namespace | tinymce
Class | UndoManager

This class handles the undo/redo history levels for the editor. Since the build in undo/redo has major drawbacks a custom one was needed.

## Public Methods

Method | Defined By
--- | ---
add(l:Object):Object Adds a new undo level/snapshot to the undo list. | UndoManager
beforeChange():void Stores away a bookmark to be used when performing an undo action so that the selection is before the change has been mad... | UndoManager
clear():void Removes all undo levels. | UndoManager
hasRedo():Boolean Returns true/false if the undo manager has any redo levels. | UndoManager
hasUndo():Boolean Returns true/false if the undo manager has any undo levels. | UndoManager
redo():Object Redoes the last action. | UndoManager
undo():Object Undoes the last action. | UndoManager

## Public Events

Event | Defined By
--- | ---
onAdd(sender:UndoManager, level:Object) This event will fire each time a new undo level is added to the undo manager. | UndoManager
onBeforeAdd(sender:UndoManager, level:Object) This event will fire before a new undo level is added to the undo manager | UndoManager
onRedo(sender:UndoManager, level:Object) This event will fire when the user make an redo of a change. | UndoManager
onUndo(sender:UndoManager, level:Object) This event will fire when the user make an undo of a change. | UndoManager

## Method details

### addmethod

`public function add(l:Object):Object`
Adds a new undo level/snapshot to the undo list.

#### Parameters

l:Object | Optional undo level object to add.

#### Returns

Object - Undo level that got added or null it a level wasn't needed.

### beforeChangemethod

`public function beforeChange():void`
Stores away a bookmark to be used when performing an undo action so that the selection is before the change has been made.

### clearmethod

`public function clear():void`
Removes all undo levels.

### hasRedomethod

`public function hasRedo():Boolean`
Returns true/false if the undo manager has any redo levels.

#### Returns

Boolean - true/false if the undo manager has any redo levels.

### hasUndomethod

`public function hasUndo():Boolean`
Returns true/false if the undo manager has any undo levels.

#### Returns

Boolean - true/false if the undo manager has any undo levels.

### redomethod

`public function redo():Object`
Redoes the last action.

#### Returns

Object - Redo level or null if no redo was performed.

### undomethod

`public function undo():Object`
Undoes the last action.

#### Returns

Object - Undo level or null if no undo was performed.

## Event details

### onAddevent

`public event onAdd(sender:UndoManager, level:Object)`
This event will fire each time a new undo level is added to the undo manager.

#### Parameters

sender:UndoManager | UndoManager instance that got the new level.
level:Object | The new level object containing a bookmark and contents.

### onBeforeAddevent

`public event onBeforeAdd(sender:UndoManager, level:Object)`
This event will fire before a new undo level is added to the undo manager

#### Parameters

sender:UndoManager | UndoManager instance that is going to add the new level
level:Object | The new level object containing a bookmark and contents

### onRedoevent

`public event onRedo(sender:UndoManager, level:Object)`
This event will fire when the user make an redo of a change.

#### Parameters

sender:UndoManager | UndoManager instance that got the new level.
level:Object | The old level object containing a bookmark and contents.

### onUndoevent

`public event onUndo(sender:UndoManager, level:Object)`
This event will fire when the user make an undo of a change.

#### Parameters

sender:UndoManager | UndoManager instance that got the new level.
level:Object | The old level object containing a bookmark and contents.