Ticket #7896: 7896.patch

File 7896.patch, 3.2 KB (added by Garry Yao, 13 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    288288                        this.getSelection().lock();
    289289        }
    290290
    291         // DOM modification here should not bother dirty flag.(#4385)
    292         function restoreDirty( editor )
    293         {
    294                 if ( !editor.checkDirty() )
    295                         setTimeout( function(){ editor.resetDirty(); }, 0 );
    296         }
    297 
    298291        var isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true ),
    299292                isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true );
    300293
     
    309302                           && CKEDITOR.tools.trim( node.getText() ).match( /^(?: |\xa0)$/ );
    310303        }
    311304
    312         function restoreSelection( selection )
    313         {
    314                 if ( selection.isLocked )
    315                 {
    316                         selection.unlock();
    317                         setTimeout( function() { selection.lock(); }, 0 );
    318                 }
    319         }
    320 
    321305        function isBlankParagraph( block )
    322306        {
    323307                return block.getOuterHtml().match( emptyParagraphRegexp );
     
    366350                }
    367351        }
    368352
     353        /*
     354         *      Revert various editor status which should get affected by the changes brought by the executed function: (#4385,#5221)
     355         *      1. dirty flag;
     356         *      2. selection lock;
     357         *      3. undo stack;
     358         */
     359        function keepEditorStatus( editor, func )
     360        {
     361                return function()
     362                {
     363                        var wasClean = !editor.checkDirty();
     364                        var sel = editor.getSelection();
     365                        if ( !sel || sel.isLocked )
     366                                return;
     367                        editor.fire( 'updateSnapshot' );
     368
     369                        func.apply( this, arguments );
     370
     371                        wasClean && editor.resetDirty();
     372                };
     373        }
     374
    369375        /**
    370376         *  Auto-fixing block-less content by wrapping paragraph (#3190), prevent
    371377         *  non-exitable-block by padding extra br.(#3189)
     
    398404                                        && !pathBlock.is( 'pre' )
    399405                                        && !pathBlock.getBogus() )
    400406                        {
    401                                 editor.fire( 'updateSnapshot' );
    402                                 restoreDirty( editor );
    403407                                pathBlock.appendBogus();
    404408                        }
    405409                }
     
    412416                                && blockLimit.getName() == 'body'
    413417                                && !path.block )
    414418                {
    415                         editor.fire( 'updateSnapshot' );
    416                         restoreDirty( editor );
    417                         CKEDITOR.env.ie && restoreSelection( selection );
    418 
    419419                        var fixedBlock = range.fixBlock( true,
    420420                                        editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p'  );
    421421
     
    464464                var testPath = new CKEDITOR.dom.elementPath( testRange.startContainer );
    465465                if ( !testPath.blockLimit.is( 'body') )
    466466                {
    467                         editor.fire( 'updateSnapshot' );
    468                         restoreDirty( editor );
    469                         CKEDITOR.env.ie && restoreSelection( selection );
    470 
    471467                        var paddingBlock;
    472468                        if ( enterMode != CKEDITOR.ENTER_BR )
    473469                                paddingBlock = body.append( editor.document.createElement( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) );
     
    11251121                                        editor.on( 'insertElement', onInsert( doInsertElement ), null, null, 20 );
    11261122                                        editor.on( 'insertText', onInsert( doInsertText ), null, null, 20 );
    11271123                                        // Auto fixing on some document structure weakness to enhance usabilities. (#3190 and #3189)
    1128                                         editor.on( 'selectionChange', onSelectionChangeFixBody, null, null, 1 );
     1124                                        editor.on( 'selectionChange', keepEditorStatus( editor, onSelectionChangeFixBody ), null, null, 1 );
    11291125                                });
    11301126
    11311127                        var titleBackup;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy