Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Tests, docs: undo.UndoFeature minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed May 4, 2016
1 parent 9eff507 commit f89097a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/undocommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/undofeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 7 additions & 4 deletions tests/undofeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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( () => {
Expand Down

0 comments on commit f89097a

Please sign in to comment.