8
0
Просмотр исходного кода

Changed: BaseCommand#_items to #_stack, also made it protected instead of private.

Szymon Cofalik 9 лет назад
Родитель
Сommit
0dbe5a81da

+ 7 - 7
packages/ckeditor5-undo/src/basecommand.js

@@ -19,15 +19,15 @@ export default class BaseCommand extends Command {
 		super( editor );
 
 		/**
-		 * Items stored by the command. These are pairs of:
+		 * Stack of items stored by the command. These are pairs of:
 		 *
 		 * * {@link engine.model.Batch batch} saved by the command and,
 		 * * {@link engine.model.Selection selection} state at the moment of saving the batch.
 		 *
-		 * @private
-		 * @member {Array} undo.BaseCommand#_items
+		 * @protected
+		 * @member {Array} undo.BaseCommand#_stack
 		 */
-		this._items = [];
+		this._stack = [];
 
 		/**
 		 * Stores all batches that were created by this command.
@@ -53,7 +53,7 @@ export default class BaseCommand extends Command {
 			isBackward: this.editor.document.selection.isBackward
 		};
 
-		this._items.push( { batch, selection } );
+		this._stack.push( { batch, selection } );
 		this.refreshState();
 	}
 
@@ -61,7 +61,7 @@ export default class BaseCommand extends Command {
 	 * Removes all items from the stack.
 	 */
 	clearStack() {
-		this._items = [];
+		this._stack = [];
 		this.refreshState();
 	}
 
@@ -69,7 +69,7 @@ export default class BaseCommand extends Command {
 	 * @inheritDoc
 	 */
 	_checkEnabled() {
-		return this._items.length > 0;
+		return this._stack.length > 0;
 	}
 }
 

+ 1 - 1
packages/ckeditor5-undo/src/redocommand.js

@@ -28,7 +28,7 @@ export default class RedoCommand extends BaseCommand {
 	 * @protected
 	 */
 	_doExecute() {
-		const item = this._items.pop();
+		const item = this._stack.pop();
 
 		// All changes have to be done in one `enqueueChanges` callback so other listeners will not
 		// step between consecutive deltas, or won't do changes to the document before selection is properly restored.

+ 6 - 6
packages/ckeditor5-undo/src/undocommand.js

@@ -31,9 +31,9 @@ export default class UndoCommand extends BaseCommand {
 	 */
 	_doExecute( batch = null ) {
 		// If batch is not given, set `batchIndex` to the last index in command stack.
-		let batchIndex = batch ? this._items.findIndex( ( a ) => a.batch == batch ) : this._items.length - 1;
+		let batchIndex = batch ? this._stack.findIndex( ( a ) => a.batch == batch ) : this._stack.length - 1;
 
-		const item = this._items.splice( batchIndex, 1 )[ 0 ];
+		const item = this._stack.splice( batchIndex, 1 )[ 0 ];
 
 		// All changes has to be done in one `enqueueChanges` callback so other listeners will not
 		// step between consecutive deltas, or won't do changes to the document before selection is properly restored.
@@ -47,7 +47,7 @@ export default class UndoCommand extends BaseCommand {
 	}
 
 	/**
-	 * Returns index in {@link undo.BaseCommand#_items} pointing to the item that is storing a batch that has given
+	 * Returns index in {@link undo.BaseCommand#_stack} pointing to the item that is storing a batch that has given
 	 * {@link engine.model.Batch#baseVersion}.
 	 *
 	 * @private
@@ -55,8 +55,8 @@ export default class UndoCommand extends BaseCommand {
 	 * @returns {Number|null}
 	 */
 	_getItemIndexFromBaseVersion( baseVersion ) {
-		for ( let i = 0; i < this._items.length; i++ ) {
-			if ( this._items[ i ].batch.baseVersion == baseVersion ) {
+		for ( let i = 0; i < this._stack.length; i++ ) {
+			if ( this._stack[ i ].batch.baseVersion == baseVersion ) {
 				return i;
 			}
 		}
@@ -128,7 +128,7 @@ export default class UndoCommand extends BaseCommand {
 				// This is fine, because we want to transform each selection only once, before transforming reversed delta
 				// by the first delta of the batch connected with the ranges.
 				if ( itemIndex !== null ) {
-					this._items[ itemIndex ].selection.ranges = transformRangesByDeltas( this._items[ itemIndex ].selection.ranges, reversedDelta );
+					this._stack[ itemIndex ].selection.ranges = transformRangesByDeltas( this._stack[ itemIndex ].selection.ranges, reversedDelta );
 				}
 
 				// 3.2. Transform history delta by reversed delta. We need this to update document history.