Ticket #3372: 3372_5.patch
File 3372_5.patch, 2.7 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. … … 167 167 function UndoManager( editor ) 168 168 { 169 169 this.typesCount = 0; 170 this.modifiersCount = 0; 170 171 171 172 this.editor = editor; 172 173 … … 182 183 this.index = -1; 183 184 184 185 this.limit = editor.config.undoStackSize; 186 187 /** 188 * Remember last pressed key. 189 */ 190 this.lastKeystroke = 0; 185 191 } 186 192 187 193 UndoManager.prototype = 188 194 { 189 type : function() 195 /** 196 * 197 * @param {CKEDITOR.dom.event} event 198 */ 199 type : function( event ) 190 200 { 191 if ( !this.typing ) 201 var keystroke = event && event.data.getKeystroke(), 202 isSelected = !this.editor.getSelection().getRanges()[0].collapsed, 203 204 // Backspace, Delete 205 modifierCodes = { 8:1, 46:1 }, 206 isModifier = keystroke in modifierCodes, 207 wasModifier = this.lastKeystroke in modifierCodes, 208 lastWasSameModifier = isModifier && keystroke == this.lastKeystroke, 209 210 // Arrows: L, T, R, B 211 resetTypingCodes = { 37:1, 38:1, 39:1, 40:1 }, 212 isReset = keystroke in resetTypingCodes, 213 wasReset = this.lastKeystroke in resetTypingCodes, 214 215 isTyping = !isModifier && !isReset, 216 217 modifierSnapshot = ( isModifier && !lastWasSameModifier ) || ( isTyping && isSelected ), 218 startedTyping = isTyping && ( wasModifier || wasReset ); 219 220 if ( startedTyping || modifierSnapshot ) 192 221 { 193 222 var beforeTypeImage = new Image( this.editor ); 194 223 … … 214 243 this.hasRedo = false; 215 244 216 245 this.typesCount = 1; 217 this. typing = true;246 this.modifiersCount = 1; 218 247 219 248 this.onChange(); 220 249 } 221 250 }, 222 0, this ); 223 224 return; 251 0, this 252 ); 225 253 } 254 this.lastKeystroke = keystroke; 226 255 227 this.typesCount++; 256 if ( isModifier ) 257 { 258 this.typesCount = 0; 259 this.modifiersCount++; 260 261 if ( this.modifiersCount > 25 ) 262 { 263 this.save(); 264 this.modifiersCount = 1; 265 } 266 } 267 else if ( !isReset ) 268 { 269 this.modifiersCount = 0; 270 this.typesCount++; 228 271 229 if ( this.typesCount > 25 ) 230 { 231 this.save(); 232 this.typesCount = 1; 233 } 234 235 this.typing = true; 272 if ( this.typesCount > 25 ) 273 { 274 this.save(); 275 this.typesCount = 1; 276 } 277 } 236 278 }, 237 279 238 280 fireChange : function()