Ticket #3372: 3372_3.patch

File 3372_3.patch, 1.7 KB (added by Tobiasz Cudnik, 15 years ago)

Version without use of indexOf (for IE).

  • _source/plugins/undo/plugin.js

     
    1010
    1111(function()
    1212{
     13        var modifierCodes = { 8:1, 46:1/*, 39:1, 40:1, 38:1, 37:1*/ };
    1314        CKEDITOR.plugins.add( 'undo',
    1415        {
    1516                requires : [ 'selection', 'wysiwygarea' ],
     
    8283                                                                {
    8384                                                                        // Do not capture CTRL hotkeys.
    8485                                                                        if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
    85                                                                                 undoManager.type();
     86                                                                                undoManager.type( event );
    8687                                                                });
    8788
    8889                                                        // Being this the first call, let's get an undo snapshot.
     
    182183                this.index = -1;
    183184
    184185                this.limit = editor.config.undoStackSize;
     186
     187                /**
     188                 * Remember last pressed key.
     189                 */
     190                this.lastKeystroke = 0;
    185191        }
    186192
    187193        UndoManager.prototype =
    188194        {
    189                 type : function()
     195                /**
     196                 *
     197                 * @param {CKEDITOR.dom.event} [event]
     198                 */
     199                type : function( event )
    190200                {
    191                         if ( !this.typing )
     201                        var keystroke = event && event.data.getKeystroke(),
     202                                isModifier = keystroke in modifierCodes,
     203                                lastWasSameModifier = isModifier && keystroke == this.lastKeystroke,
     204                                modifierSnapshot = isModifier  && !lastWasSameModifier;
     205                       
     206                        if ( !this.typing || modifierSnapshot )
    192207                        {
    193208                                var beforeTypeImage = new Image( this.editor );
    194209
     
    219234                                                        this.onChange();
    220235                                                }
    221236                                        },
    222                                         0, this );
     237                                        0, this
     238                                );
    223239
    224                                 return;
     240                                if ( !modifierSnapshot )
     241                                        return;
    225242                        }
    226243
    227244                        this.typesCount++;
     
    233250                        }
    234251
    235252                        this.typing = true;
     253                        this.lastKeystroke = keystroke;
    236254                },
    237255
    238256                fireChange : function()
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy