# UndoManager

This module allows to manage the stack of changes applied in canvas. Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance

const um = editor.UndoManager;

# getConfig

Get module configurations

# Examples

const config = um.getConfig();
// { ... }

Returns Object Configuration object

# add

Add an entity (Model/Collection) to track Note: New Components and CSSRules will be added automatically

# Parameters

  • entity (Model | Collection) Entity to track

# Examples

um.add(someModelOrCollection);

Returns this

# remove

Remove and stop tracking the entity (Model/Collection)

# Parameters

  • entity (Model | Collection) Entity to remove

# Examples

um.remove(someModelOrCollection);

Returns this

# removeAll

Remove all entities

# Examples

um.removeAll();

Returns this

# start

Start/resume tracking changes

# Examples

um.start();

Returns this

# stop

Stop tracking changes

# Examples

um.stop();

Returns this

# undo

Undo last change

# Parameters

  • all (optional, default true)

# Examples

um.undo();

Returns this

# undoAll

Undo all changes

# Examples

um.undoAll();

Returns this

# redo

Redo last change

# Parameters

  • all (optional, default true)

# Examples

um.redo();

Returns this

# redoAll

Redo all changes

# Examples

um.redoAll();

Returns this

# hasUndo

Checks if exists an available undo

# Examples

um.hasUndo();

Returns Boolean

# hasRedo

Checks if exists an available redo

# Examples

um.hasRedo();

Returns Boolean

# getStack

Get stack of changes

# Examples

const stack = um.getStack();
stack.each(item => ...);

Returns Collection

# getStackGroup

Get grouped undo manager stack. The difference between getStack is when you do multiple operations at a time, like appending multiple components: editor.getWrapper().append(

C1
C2
); getStack will return a collection length of 2. getStackGroup instead will group them as a single operation (the first inserted component will be returned in the list) by returning an array length of 1.

Returns Array

# clear

Clear the stack

# Examples

um.clear();

Returns this