mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-26 15:21:51 +00:00
1bf58252ce
...or really changeInternal(), so we can avoid adding undo transactions to the undo stack. Also get rid of the pattern where undo() and redo() return a selection which the caller then has to restore, and instead just restore the selection. Bug: 53224 Change-Id: If5a3b4d4162e9f0713ee9cd26e79a66efe52770f
60 lines
1.1 KiB
JavaScript
60 lines
1.1 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface HistoryAction class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* History action.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.Action
|
|
* @constructor
|
|
* @param {ve.ui.Surface} surface Surface to act on
|
|
*/
|
|
ve.ui.HistoryAction = function VeUiHistoryAction( surface ) {
|
|
// Parent constructor
|
|
ve.ui.Action.call( this, surface );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.HistoryAction, ve.ui.Action );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.HistoryAction.static.name = 'history';
|
|
|
|
/**
|
|
* List of allowed methods for the action.
|
|
*
|
|
* @static
|
|
* @property
|
|
*/
|
|
ve.ui.HistoryAction.static.methods = [ 'undo', 'redo' ];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Step backwards in time.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.HistoryAction.prototype.undo = function () {
|
|
this.surface.getModel().undo();
|
|
};
|
|
|
|
/**
|
|
* Step forwards in time.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.HistoryAction.prototype.redo = function () {
|
|
this.surface.getModel().redo();
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.actionFactory.register( ve.ui.HistoryAction );
|