Ticket #7422: 7422_3.patch

File 7422_3.patch, 2.1 KB (added by Alfonso Martínez de Lizarrondo, 14 years ago)

Updated patch

  • _source/plugins/undo/plugin.js

     
    7272                        // Registering keydown on every document recreation.(#3844)
    7373                        editor.on( 'contentDom', function()
    7474                                {
    75                                         editor.document.on( 'keydown', function( event )
     75                                        var innerDrag,
     76                                                doc = editor.document,
     77                                                target = doc.getBody();
     78
     79                                        doc.on( 'keydown', function( event )
    7680                                                {
    7781                                                        // Do not capture CTRL hotkeys.
    7882                                                        if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
    7983                                                                undoManager.type( event );
    8084                                                });
     85
     86                                        // Event "dragstart" fires only when dragging
     87                                        // from inside the own document.
     88                                        target.on( 'dragstart', function( evt )
     89                                                {
     90                                                        innerDrag = 1;
     91                                                        editor.fire( 'saveSnapshot' );
     92
     93                                                        // There's always a "dragend" in accompany with "dragstart".
     94                                                        ( CKEDITOR.env.ie ? target : new CKEDITOR.dom.element( evt.data.$.target ) ).
     95                                                                on( 'dragend', function( evt )
     96                                                                {
     97                                                                        evt.removeListener();
     98                                                                        innerDrag = 0;
     99                                                                        setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 );
     100                                                                });
     101                                                });
     102
     103                                        CKEDITOR.env.gecko && doc.on( 'dragenter', function(e)
     104                                                {
     105                                                        // Start of drag from outside the document
     106                                                        if ( doc.$.documentElement == e.data.$.target )
     107                                                                editor.fire( 'saveSnapshot' );
     108                                                });
     109
     110                                        // Event "drop" only works for IE and FF right now
     111                                        // to catch droppers from outside of the document.
     112                                        ( CKEDITOR.env.ie ? target : doc ).on( 'drop', function()
     113                                                {
     114                                                        if ( !innerDrag )
     115                                                        {
     116                                                                if ( CKEDITOR.env.ie )
     117                                                                {
     118                                                                        var savedRange = editor.getSelection().getNative().createRange();
     119                                                                        editor.fire( 'saveSnapshot' );
     120                                                                        savedRange.select();
     121                                                                }
     122                                                                setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 );
     123                                                        }
     124                                                });
    81125                                });
    82126
    83127                        // Always save an undo snapshot - the previous mode might have
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy