Skip to content

Commit

Permalink
Merge branch 't/12321'
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewand committed Aug 19, 2014
2 parents 26dd8f0 + 47fef4e commit 67f620b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
14 changes: 11 additions & 3 deletions plugins/undo/plugin.js
Expand Up @@ -897,9 +897,17 @@
editor = undoManager.editor,
ieFunctionKeysWorkaround = CKEDITOR.env.ie && keyCode in backspaceOrDelete;

// IE: backspace/del would still call keypress event, even if nothing was removed.
if ( ieFunctionKeysWorkaround && this.lastKeydownImage.equalsContent( new Image( editor, true ) ) ) {
return;
// IE: doesn't call keypress for backspace/del keys so we need to handle it manually
// with a workaround.
if ( ieFunctionKeysWorkaround ) {
if ( this.lastKeydownImage.equalsContent( new Image( editor, true ) ) ) {
// Content was not changed, we don't need to do anything.
return;
} else {
// Content was changed. And since no keypress event was fired, we have
// inputFired = 0, so undoManager.type method will not be called.
inputFired += 1;
}
}

if ( inputFired > 0 ) {
Expand Down
17 changes: 16 additions & 1 deletion tests/plugins/undo/change.js
Expand Up @@ -39,6 +39,13 @@
}
},

_should: {
ignore: {
'test backspace': CKEDITOR.env.ie,
'test IE backspace': !CKEDITOR.env.ie
}
},

'test setData': function() {
bender.editor.focus();

Expand Down Expand Up @@ -124,10 +131,18 @@

'test backspace': function() {
// IE: In case of backspace and delete we need to make real change to DOM content.
var that = this;
this.checkChange( function( editor ) {
that.keyTools.keyEvent( 8 /* backspace */ );
} );
},

'test IE backspace': function() {
// IE doesn't send keypress event, which is used as a `input` event.
var that = this,
textNode = this.editor.editable().getFirst().getFirst();
this.checkChange( function( editor ) {
that.keyTools.keyEvent( 8 /* backspace */, null, null, function( e ) {
that.keyTools.keyEvent( 8 /* backspace */, null, true, function( e ) {
textNode.setText( 'fo' );
} );
textNode.setText( 'foo' );
Expand Down

0 comments on commit 67f620b

Please sign in to comment.