Skip to content

Commit

Permalink
Code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Jul 5, 2013
1 parent d2c306d commit 0b15e93
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions plugins/undo/plugin.js
Expand Up @@ -24,7 +24,7 @@
},
state: CKEDITOR.TRISTATE_DISABLED,
canUndo: false
});
} );

var redoCommand = editor.addCommand( 'redo', {
exec: function() {
Expand All @@ -35,7 +35,7 @@
},
state: CKEDITOR.TRISTATE_DISABLED,
canUndo: false
});
} );

editor.setKeystroke( [
[ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
Expand All @@ -61,28 +61,27 @@
// Save snapshots before doing custom changes.
editor.on( 'saveSnapshot', function( evt ) {
undoManager.save( evt.data && evt.data.contentOnly );
});
} );

// Registering keydown on every document recreation.(#3844)
editor.on( 'contentDom', function() {
editor.editable().on( 'keydown', function( event ) {
var keystroke = event.data.getKey();

if ( keystroke == 8 /*Backspace*/ || keystroke == 46 /*Delete*/ ) {
if ( keystroke == 8 /*Backspace*/ || keystroke == 46 /*Delete*/ )
undoManager.type( keystroke, 0 );
}
});
} );

editor.editable().on( 'keypress', function( event ) {
undoManager.type( event.data.getKey(), 1 );
});
});
} );
} );

// Always save an undo snapshot - the previous mode might have
// changed editor contents.
editor.on( 'beforeModeUnload', function() {
editor.mode == 'wysiwyg' && undoManager.save( true );
});
} );

function toggleUndoManager() {
undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg';
Expand All @@ -100,13 +99,13 @@
label: editor.lang.undo.undo,
command: 'undo',
toolbar: 'undo,10'
});
} );

editor.ui.addButton( 'Redo', {
label: editor.lang.undo.redo,
command: 'redo',
toolbar: 'undo,20'
});
} );
}

/**
Expand Down Expand Up @@ -140,7 +139,7 @@
editor.on( 'updateSnapshot', function() {
if ( undoManager.currentImage )
undoManager.update();
});
} );

/**
* Lock manager to prevent any save/update operations.
Expand Down Expand Up @@ -170,7 +169,7 @@
*/
editor.on( 'unlockSnapshot', undoManager.unlock, undoManager );
}
});
} );

CKEDITOR.plugins.undo = {};

Expand Down

0 comments on commit 0b15e93

Please sign in to comment.