Skip to content

Latest commit

 

History

History
267 lines (159 loc) · 3.38 KB

undo_manager.md

File metadata and controls

267 lines (159 loc) · 3.38 KB

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 configuration object

Returns 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

isRegistered

Check if the entity (Model/Collection) to tracked Note: New Components and CSSRules will be added automatically

Parameters

  • obj any
  • entity (Model | Collection) Entity to track

Returns Boolean

getStack

Get stack of changes

Examples

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

Returns Collection

skip

Execute the provided callback temporarily stopping tracking changes

Parameters

  • clb Function The callback to execute with changes tracking stopped

Examples

um.skip(() => {
 // Do stuff without tracking
});

clear

Clear the stack

Examples

um.clear();

Returns this