Ticket #3372: 3372_4.patch
File 3372_4.patch, 2.0 KB (added by , 15 years ago) |
---|
-
_source/plugins/undo/plugin.js
82 82 { 83 83 // Do not capture CTRL hotkeys. 84 84 if ( !event.data.$.ctrlKey && !event.data.$.metaKey ) 85 undoManager.type( );85 undoManager.type( event ); 86 86 }); 87 87 88 88 // Being this the first call, let's get an undo snapshot. … … 182 182 this.index = -1; 183 183 184 184 this.limit = editor.config.undoStackSize; 185 186 /** 187 * Remember last pressed key. 188 */ 189 this.lastKeystroke = 0; 185 190 } 186 191 187 192 UndoManager.prototype = 188 193 { 189 type : function() 194 /** 195 * 196 * @param {CKEDITOR.dom.event} [event] 197 */ 198 type : function( event ) 190 199 { 191 if ( !this.typing ) 200 var keystroke = event && event.data.getKeystroke(), 201 // Backspace, Delete 202 modifierCodes = { 8:1, 46:1 }, 203 // Arrows: L, T, R, B 204 resetTypingCodes = { 37:1, 38:1, 39:1, 40:1 }, 205 isModifier = keystroke in modifierCodes, 206 lastWasSameModifier = isModifier && keystroke == this.lastKeystroke, 207 modifierSnapshot = isModifier && !lastWasSameModifier; 208 209 if ( !this.typing || modifierSnapshot ) 192 210 { 193 211 var beforeTypeImage = new Image( this.editor ); 194 212 … … 219 237 this.onChange(); 220 238 } 221 239 }, 222 0, this ); 240 0, this 241 ); 223 242 224 return; 243 if ( !modifierSnapshot ) 244 return; 225 245 } 246 this.lastKeystroke = keystroke; 226 247 227 this.typesCount++; 248 if ( keystroke in resetTypingCodes ) 249 this.typing = false; 250 else 251 { 252 this.typesCount++; 228 253 229 if ( this.typesCount > 25 )230 {231 this.save();232 this.typesCount = 1;233 }254 if ( this.typesCount > 25 ) 255 { 256 this.save(); 257 this.typesCount = 1; 258 } 234 259 235 this.typing = true; 260 this.typing = true; 261 } 236 262 }, 237 263 238 264 fireChange : function()