mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-11 05:56:11 +00:00
babaa4118d
Introduction of fake selection for single focused nodes. This change specifically makes the selection much nicer in appearance for Chrome users selecting floated FocusableNodes (block images) for example. Added ve-ce-surface-highlights DOM element to contain styled highlight elements. Made adjustments to getSelectionRect to return fake selection bounds if necessary. Replaced old uses of showSelection with model.change(). Change-Id: I96e66567cdce6455ef3eb77568e72f23140448ff
64 lines
1.2 KiB
JavaScript
64 lines
1.2 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 */
|
|
|
|
ve.inheritClass( ve.ui.HistoryAction, ve.ui.Action );
|
|
|
|
/* Static Properties */
|
|
|
|
/**
|
|
* 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 () {
|
|
var range = this.surface.getModel().undo();
|
|
if ( range ) {
|
|
this.surface.getModel().change( null, range );
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Step forwards in time.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.HistoryAction.prototype.redo = function () {
|
|
var range = this.surface.getModel().redo();
|
|
if ( range ) {
|
|
this.surface.getModel().change( null, range );
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.actionFactory.register( 'history', ve.ui.HistoryAction );
|