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

Changes according to changes in CKE5-core.

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

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

@@ -75,7 +75,7 @@ export default class UndoCommand extends Command {
 
 		for ( let undoDelta of undoDeltas ) {
 			const undoDeltaReversed = undoDelta.getReversed();
-			const updatedDeltas = this.editor.document.history.updateDelta( undoDeltaReversed );
+			const updatedDeltas = this.editor.document.history.getTransformedDelta( undoDeltaReversed );
 
 			for ( let delta of updatedDeltas ) {
 				for ( let operation of delta.operations ) {

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

@@ -34,6 +34,14 @@ export default class UndoFeature extends Feature {
 		 * @member {undo.UndoCommand} undo.UndoFeature#_redoCommand
 		 */
 		this._redoCommand = null;
+
+		/**
+		 * Keeps track of which batch has already been added to undo manager.
+		 *
+		 * @private
+		 * @member {Set} undo.UndoFeature#_batchRegistry
+		 */
+		this._batchRegistry = new Set();
 	}
 
 	/**
@@ -49,9 +57,12 @@ export default class UndoFeature extends Feature {
 		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, 'batch', ( evt, batch ) => {
-			this._undoCommand.addBatch( batch );
-			this._redoCommand.clearStack();
+		this.listenTo( this.editor.document, 'change', ( evt, type, changes, batch ) => {
+			if ( batch && !this._batchRegistry.has( batch ) ) {
+				this._batchRegistry.add( batch );
+				this._undoCommand.addBatch( batch );
+				this._redoCommand.clearStack();
+			}
 		} );
 
 		// Whenever batch is reverted by undo command, add it to redo history.