Ticket #3372: 3372.patch

File 3372.patch, 1.4 KB (added by Tobiasz Cudnik, 15 years ago)
  • _source/plugins/undo/plugin.js

     
    8282                                                                {
    8383                                                                        // Do not capture CTRL hotkeys.
    8484                                                                        if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
    85                                                                                 undoManager.type();
     85                                                                                undoManager.type( event );
    8686                                                                });
    8787
    8888                                                        // Being this the first call, let's get an undo snapshot.
     
    182182                this.index = -1;
    183183
    184184                this.limit = editor.config.undoStackSize;
     185
     186                /**
     187                 * Remember last pressed key.
     188                 */
     189                this.lastKeystroke = 0;
    185190        }
    186191
    187192        UndoManager.prototype =
    188193        {
    189                 type : function()
     194                /**
     195                 *
     196                 * @param {CKEDITOR.dom.event} [event]
     197                 */
     198                type : function( event )
    190199                {
    191                         if ( !this.typing )
     200                        var keystroke = event && event.data.getKeystroke(),
     201                                /**
     202                                 * Backspace not preceeded by backspace.
     203                                 */
     204                                safeBackspace = keystroke == 8 && !( this.lastKeystroke == 8 );
     205                       
     206                        if ( !this.typing || safeBackspace )
    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 ( !safeBackspace )
     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