mxUndoableEdit

Implements a composite undoable edit.  Here is an example for a custom change which gets executed via the model:

function CustomChange(model, name)
{
  this.model = model;
  this.name = name;
  this.previous = name;
};

CustomChange.prototype.execute = function()
{
  let tmp = this.model.name;
  this.model.name = this.previous;
  this.previous = tmp;
};

let name = prompt('Enter name');
graph.model.execute(new CustomChange(graph.model, name));
Summary
mxUndoableEditImplements a composite undoable edit.
Events
mxEvent.EXECUTEDFires between START_EDIT and END_EDIT after an atomic change was executed.
mxEvent.START_EDITFires before a set of changes will be executed in undo or redo.
mxEvent.END_EDITFires after a set of changeswas executed in undo or redo.
Functions
mxUndoableEditConstructs a new undoable edit for the given source.
Variables
sourceSpecifies the source of the edit.
changesArray that contains the changes that make up this edit.
significantSpecifies if the undoable change is significant.
undoneSpecifies if this edit has been undone.
redoneSpecifies if this edit has been redone.
Functions
isEmptyReturns true if the this edit contains no changes.
isSignificantReturns significant.
addAdds the specified change to this edit.
notifyHook to notify any listeners of the changes after an undo or redo has been carried out.
dieHook to free resources after the edit has been removed from the command history.
undoUndoes all changes in this edit.
redoRedoes all changes in this edit.

Events

mxEvent.EXECUTED

Fires between START_EDIT and END_EDIT after an atomic change was executed.  The <code>change</code> property contains the change that was executed.

mxEvent.START_EDIT

Fires before a set of changes will be executed in undo or redo.  This event contains no properties.

mxEvent.END_EDIT

Fires after a set of changeswas executed in undo or redo.  This event contains no properties.

Functions

mxUndoableEdit

function mxUndoableEdit(source,
significant)

Constructs a new undoable edit for the given source.

Variables

source

mxUndoableEdit.prototype.source

Specifies the source of the edit.

changes

mxUndoableEdit.prototype.changes

Array that contains the changes that make up this edit.  The changes are expected to either have an undo and redo function, or an execute function.  Default is an empty array.

significant

mxUndoableEdit.prototype.significant

Specifies if the undoable change is significant.  Default is true.

undone

mxUndoableEdit.prototype.undone

Specifies if this edit has been undone.  Default is false.

redone

mxUndoableEdit.prototype.redone

Specifies if this edit has been redone.  Default is false.

Functions

isEmpty

mxUndoableEdit.prototype.isEmpty = function()

Returns true if the this edit contains no changes.

isSignificant

mxUndoableEdit.prototype.isSignificant = function()

Returns significant.

add

mxUndoableEdit.prototype.add = function(change)

Adds the specified change to this edit.  The change is an object that is expected to either have an undo and redo, or an execute function.

notify

mxUndoableEdit.prototype.notify = function()

Hook to notify any listeners of the changes after an undo or redo has been carried out.  This implementation is empty.

die

mxUndoableEdit.prototype.die = function()

Hook to free resources after the edit has been removed from the command history.  This implementation is empty.

undo

mxUndoableEdit.prototype.undo = function()

Undoes all changes in this edit.

redo

mxUndoableEdit.prototype.redo = function()

Redoes all changes in this edit.

mxUndoableEdit.prototype.undo = function()
Undoes all changes in this edit.
mxUndoableEdit.prototype.redo = function()
Redoes all changes in this edit.
function mxUndoableEdit(source,
significant)
Constructs a new undoable edit for the given source.
mxUndoableEdit.prototype.source
Specifies the source of the edit.
mxUndoableEdit.prototype.changes
Array that contains the changes that make up this edit.
mxUndoableEdit.prototype.significant
Specifies if the undoable change is significant.
mxUndoableEdit.prototype.undone
Specifies if this edit has been undone.
mxUndoableEdit.prototype.redone
Specifies if this edit has been redone.
mxUndoableEdit.prototype.isEmpty = function()
Returns true if the this edit contains no changes.
mxUndoableEdit.prototype.isSignificant = function()
Returns significant.
mxUndoableEdit.prototype.add = function(change)
Adds the specified change to this edit.
mxUndoableEdit.prototype.notify = function()
Hook to notify any listeners of the changes after an undo or redo has been carried out.
mxUndoableEdit.prototype.die = function()
Hook to free resources after the edit has been removed from the command history.
Close