Ticket #5781: 5781.patch

File 5781.patch, 3.4 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    177177
    178178        isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );
    179179
     180        // Gecko need a key event to 'wake up' the editing
     181        // ability when document is empty.(#3864, #5781)
     182        function activateEditing( editor )
     183        {
     184                var win = editor.window,
     185                        doc = editor.document,
     186                        body = editor.document.getBody(),
     187                        bodyChildsNum = body.getChildren().count();
     188
     189                if ( ( !bodyChildsNum
     190                                || bodyChildsNum == 1
     191                                        && body.getFirst().hasAttribute( '_moz_editor_bogus_node') ) )
     192                {
     193                        restoreDirty( editor );
     194
     195                        // Simulating keyboard character input by dispatching a keydown of white-space text.
     196                        var keyEventSimulate = doc.$.createEvent( "KeyEvents" );
     197                        keyEventSimulate.initKeyEvent( 'keypress', true, true, win.$, false,
     198                                false, false, false, 0, 32 );
     199                        doc.$.dispatchEvent( keyEventSimulate );
     200
     201                        // Restore the original document status by placing the cursor before a bogus br created (#5021).
     202                        doc.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } )
     203                                .replace( doc.getBody().getFirst() );
     204                        var nativeRange = new CKEDITOR.dom.range( doc );
     205                        nativeRange.setStartAt( body , CKEDITOR.POSITION_AFTER_START );
     206                        nativeRange.select();
     207                        console.log( 'fix' );
     208                }
     209        }
     210
    180211        /**
    181212         *  Auto-fixing block-less content by wrapping paragraph (#3190), prevent
    182213         *  non-exitable-block by padding extra br.(#3189)
     
    191222                        body = editor.document.getBody(),
    192223                        enterMode = editor.config.enterMode;
    193224
     225                CKEDITOR.env.gecko && activateEditing( editor );
     226
    194227                // When enterMode set to block, we'll establing new paragraph only if we're
    195228                // selecting inline contents right under body. (#3657)
    196229                if ( enterMode != CKEDITOR.ENTER_BR
     
    395428                                                        }, 0 );
    396429                                                }
    397430
    398                                                 // Gecko need a key event to 'wake up' the editing
    399                                                 // ability when document is empty.(#3864)
    400                                                 if ( CKEDITOR.env.gecko && !body.childNodes.length )
    401                                                 {
    402                                                         setTimeout( function()
    403                                                         {
    404                                                                 restoreDirty( editor );
     431                                                CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor );
    405432
    406                                                                 // Simulating keyboard character input by dispatching a keydown of white-space text.
    407                                                                 var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" );
    408                                                                 keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false,
    409                                                                         false, false, false, 0, 32 );
    410                                                                 domDocument.$.dispatchEvent( keyEventSimulate );
    411 
    412                                                                 // Restore the original document status by placing the cursor before a bogus br created (#5021).
    413                                                                 domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } )
    414                                                                         .replace( domDocument.getBody().getFirst() );
    415                                                                 var nativeRange = new CKEDITOR.dom.range( domDocument );
    416                                                                 nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START );
    417                                                                 nativeRange.select();
    418                                                         }, 0 );
    419                                                 }
    420 
    421433                                                // IE, Opera and Safari may not support it and throw
    422434                                                // errors.
    423435                                                try { domDocument.execCommand( 'enableObjectResizing', false, !editor.config.disableObjectResizing ) ; } catch(e) {}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy