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

Commit

Permalink
Changes according to changes in CKE5-core.
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed May 4, 2016
1 parent 3c348a6 commit 4420f98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/undocommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
17 changes: 14 additions & 3 deletions src/undofeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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.
Expand Down

0 comments on commit 4420f98

Please sign in to comment.