浏览代码

Changed: Changes after model events refactor in ckeditor5-engine.

Szymon Cofalik 8 年之前
父节点
当前提交
a5aad9fb0f
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 4 1
      packages/ckeditor5-undo/src/undoengine.js
  2. 4 1
      packages/ckeditor5-undo/tests/undoengine-integration.js

+ 4 - 1
packages/ckeditor5-undo/src/undoengine.js

@@ -63,7 +63,10 @@ export default class UndoEngine extends Plugin {
 		this.editor.commands.add( 'undo', this._undoCommand );
 		this.editor.commands.add( 'redo', this._redoCommand );
 
-		this.listenTo( this.editor.model.document, 'change', ( evt, type, changes, batch ) => {
+		this.listenTo( this.editor.model, 'applyOperation', ( evt, args ) => {
+			const operation = args[ 0 ];
+			const batch = operation.delta.batch;
+
 			// If changes are not a part of a batch or this is not a new batch, omit those changes.
 			if ( this._batchRegistry.has( batch ) || batch.type == 'transparent' ) {
 				return;

+ 4 - 1
packages/ckeditor5-undo/tests/undoengine-integration.js

@@ -227,14 +227,17 @@ describe( 'UndoEngine integration', () => {
 
 		it( 'undo insert first content', () => {
 			input( '' );
+			output( '<paragraph>[]</paragraph>' ); // All hail our king and savior, autoparagraphing!
 
 			model.change( writer => {
+				writer.remove( Range.createIn( root ) );
 				writer.insertElement( 'heading1', doc.selection.getFirstPosition() );
 			} );
+
 			output( '<heading1>[]</heading1>' );
 
 			editor.execute( 'undo' );
-			output( '<paragraph>[]</paragraph>' ); // All hail our king and savior, autoparagraphing!
+			output( '<paragraph>[]</paragraph>' );
 
 			undoDisabled();
 		} );