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

Tests, docs: undo.UndoFeature minor tweaks.

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

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

@@ -132,7 +132,7 @@ export default class UndoCommand extends Command {
 							case 'move':
 							case 'remove':
 							case 'reinsert':
-								result = transformed[ t ].getTransformedByMove( operation.sourcePosition, operation.movedRangeStart, operation.howMany, true );
+								result = transformed[ t ].getTransformedByMove( operation.sourcePosition, operation.targetPosition, operation.howMany, true );
 								break;
 						}
 

+ 3 - 3
packages/ckeditor5-undo/src/undofeature.js

@@ -18,7 +18,7 @@ export default class UndoFeature extends Feature {
 		super( editor );
 
 		/**
-		 * Undo command which manages undo {@link core.treeModel.Batch batches} stack (history).
+		 * Undo command which manages undo {@link engine.treeModel.Batch batches} stack (history).
 		 * Created and registered during {@link undo.UndoFeature#init feature initialization}.
 		 *
 		 * @private
@@ -27,7 +27,7 @@ export default class UndoFeature extends Feature {
 		this._undoCommand = null;
 
 		/**
-		 * Undo command which manages redo {@link core.treeModel.Batch batches} stack (history).
+		 * Undo command which manages redo {@link engine.treeModel.Batch batches} stack (history).
 		 * Created and registered during {@link undo.UndoFeature#init feature initialization}.
 		 *
 		 * @private
@@ -56,9 +56,9 @@ export default class UndoFeature extends Feature {
 		this.editor.commands.set( 'redo', this._redoCommand );
 		this.editor.commands.set( 'undo', this._undoCommand );
 
-		// Whenever new batch is created add it to undo history and clear redo history.
 		this.listenTo( this.editor.document, 'change', ( evt, type, changes, batch ) => {
 			if ( batch && !this._batchRegistry.has( batch ) ) {
+				// Whenever new batch is created add it to undo history and clear redo history.
 				this._batchRegistry.add( batch );
 				this._undoCommand.addBatch( batch );
 				this._redoCommand.clearStack();

+ 7 - 4
packages/ckeditor5-undo/tests/undofeature.js

@@ -6,7 +6,8 @@
 'use strict';
 
 import Editor from '/ckeditor5/editor.js';
-import Position from '/ckeditor5/core/treemodel/position.js';
+import ModelDocument from '/ckeditor5/engine/treemodel/document.js';
+import Position from '/ckeditor5/engine/treemodel/position.js';
 import UndoFeature from '/ckeditor5/undo/undofeature.js';
 
 let element, editor, undo, batch, doc, root;
@@ -16,12 +17,14 @@ beforeEach( () => {
 	document.body.appendChild( element );
 
 	editor = new Editor( element );
-	undo = new UndoFeature( editor );
-	undo.init();
 
-	doc = editor.document;
+	doc = new ModelDocument();
+	editor.document = doc;
 	batch = doc.batch();
 	root = doc.createRoot( 'root' );
+
+	undo = new UndoFeature( editor );
+	undo.init();
 } );
 
 afterEach( () => {