X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fundo%2Fplugin.js;h=fcdd2a4e4803d853e79fc8963cb9f6542208cc81;hp=e013a9ddb42af6b9cb8dfc0baf743ba6cac7355a;hb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d diff --git a/_source/plugins/undo/plugin.js b/_source/plugins/undo/plugin.js index e013a9d..fcdd2a4 100644 --- a/_source/plugins/undo/plugin.js +++ b/_source/plugins/undo/plugin.js @@ -130,11 +130,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.contents = this.contents.replace( /\s+_cke_expando=".*?"/g, '' ); } + // Attributes that browser may changing them when setting via innerHTML. + var protectedAttrs = /\b(?:href|src|name)="[^"]*?"/gi; + Image.prototype = { equals : function( otherImage, contentOnly ) { - if ( this.contents != otherImage.contents ) + var thisContents = this.contents, + otherContents = otherImage.contents; + + // For IE6/7 : Comparing only the protected attribute values but not the original ones.(#4522) + if( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ) + { + thisContents = thisContents.replace( protectedAttrs, '' ); + otherContents = otherContents.replace( protectedAttrs, '' ); + } + + if( thisContents != otherContents ) return false; if ( contentOnly ) @@ -179,6 +192,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.reset(); } + + var editingKeyCodes = { /*Backspace*/ 8:1, /*Delete*/ 46:1 }, + modifierKeyCodes = { /*Shift*/ 16:1, /*Ctrl*/ 17:1, /*Alt*/ 18:1 }, + navigationKeyCodes = { 37:1, 38:1, 39:1, 40:1 }; // Arrows: L, T, R, B + UndoManager.prototype = { /** @@ -187,32 +205,26 @@ For licensing, see LICENSE.html or http://ckeditor.com/license */ type : function( event ) { - var keystroke = event && event.data.getKeystroke(), - - // Backspace, Delete - modifierCodes = { 8:1, 46:1 }, - // Keystrokes which will modify the contents. - isModifier = keystroke in modifierCodes, - wasModifier = this.lastKeystroke in modifierCodes, - lastWasSameModifier = isModifier && keystroke == this.lastKeystroke, - - // Arrows: L, T, R, B - resetTypingCodes = { 37:1, 38:1, 39:1, 40:1 }, + var keystroke = event && event.data.getKey(), + isModifierKey = keystroke in modifierKeyCodes, + isEditingKey = keystroke in editingKeyCodes, + wasEditingKey = this.lastKeystroke in editingKeyCodes, + sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke, // Keystrokes which navigation through contents. - isReset = keystroke in resetTypingCodes, - wasReset = this.lastKeystroke in resetTypingCodes, + isReset = keystroke in navigationKeyCodes, + wasReset = this.lastKeystroke in navigationKeyCodes, // Keystrokes which just introduce new contents. - isContent = ( !isModifier && !isReset ), + isContent = ( !isEditingKey && !isReset ), // Create undo snap for every different modifier key. - modifierSnapshot = ( isModifier && !lastWasSameModifier ), + modifierSnapshot = ( isEditingKey && !sameAsLastEditingKey ), // Create undo snap on the following cases: - // 1. Just start to type. + // 1. Just start to type . // 2. Typing some content after a modifier. // 3. Typing some content after make a visible selection. - startedTyping = !this.typing - || ( isContent && ( wasModifier || wasReset ) ); + startedTyping = !( isModifierKey || this.typing ) + || ( isContent && ( wasEditingKey || wasReset ) ); if ( startedTyping || modifierSnapshot ) { @@ -250,8 +262,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } this.lastKeystroke = keystroke; + + // Ignore modifier keys. (#4673) + if( isModifierKey ) + return; // Create undo snap after typed too much (over 25 times). - if ( isModifier ) + if ( isEditingKey ) { this.typesCount = 0; this.modifiersCount++;