diff --git a/CHANGES.md b/CHANGES.md index 5c079cfca58..00b259198f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ CKEditor 4 Changelog Fixed Issues: +* [#11677](http://dev.ckeditor.com/ticket/11677): Fixed: undo/redo keystrokes are blocked in source mode. * [#11717](http://dev.ckeditor.com/ticket/11717): [Docprops](http://ckeditor.com/addon/docprops) plugin requires the [Colordialog](http://ckeditor.com/addon/colordialog) plugin to work. ## CKEditor 4.3.4 diff --git a/core/config.js b/core/config.js index dbdcaf1df08..221a1eeeb14 100644 --- a/core/config.js +++ b/core/config.js @@ -333,10 +333,7 @@ CKEDITOR.config = { * config.blockedKeystrokes = [ * CKEDITOR.CTRL + 66, // CTRL+B * CKEDITOR.CTRL + 73, // CTRL+I - * CKEDITOR.CTRL + 85, // CTRL+U - * CKEDITOR.CTRL + 89, // CTRL+Y - * CKEDITOR.CTRL + 90, // CTRL+Z - * CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 // CTRL+SHIFT+Z + * CKEDITOR.CTRL + 85 // CTRL+U * ]; * * @cfg {Array} [blockedKeystrokes=see example] @@ -344,11 +341,7 @@ CKEDITOR.config = { blockedKeystrokes: [ CKEDITOR.CTRL + 66, // CTRL+B CKEDITOR.CTRL + 73, // CTRL+I - CKEDITOR.CTRL + 85, // CTRL+U - - CKEDITOR.CTRL + 89, // CTRL+Y - CKEDITOR.CTRL + 90, // CTRL+Z - CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 // CTRL+SHIFT+Z + CKEDITOR.CTRL + 85 // CTRL+U ] }; diff --git a/plugins/undo/plugin.js b/plugins/undo/plugin.js index baa6f9cf35a..828b4acd11a 100644 --- a/plugins/undo/plugin.js +++ b/plugins/undo/plugin.js @@ -38,12 +38,23 @@ canUndo: false } ); + var keystrokes = [ CKEDITOR.CTRL + 90 /*Z*/, CKEDITOR.CTRL + 89 /*Y*/, CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/ ]; + editor.setKeystroke( [ - [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], - [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], - [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ] + [ keystrokes[ 0 ], 'undo' ], + [ keystrokes[ 1 ], 'redo' ], + [ keystrokes[ 2 ], 'redo' ] ] ); + // Block undo/redo keystrokes when at the bottom/top of the undo stack (#11126 and #11677). + editor.on( 'contentDom', function() { + var editable = editor.editable(); + editable.attachListener( editable, 'keydown', function( evt ) { + if ( CKEDITOR.tools.indexOf( keystrokes, evt.data.getKeystroke() ) > -1 ) + evt.data.preventDefault(); + } ); + } ); + undoManager.onChange = function() { undoCommand.setState( undoManager.undoable() ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); redoCommand.setState( undoManager.redoable() ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );