Ticket #5781: 5781_2.patch

File 5781_2.patch, 3.5 KB (added by Sa'ar Zac Elias, 14 years ago)
  • _source/plugins/wysiwygarea/plugin.js

     
    1 /*
     1/*
    22Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    187187
    188188        isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );
    189189
     190        // Gecko need a key event to 'wake up' the editing
     191        // ability when document is empty.(#3864, #5781)
     192        function activateEditing( editor )
     193        {
     194                var win = editor.window,
     195                        doc = editor.document,
     196                        body = editor.document.getBody(),
     197                        bodyChildsNum = body.getChildren().count();
     198
     199                if ( !bodyChildsNum || ( bodyChildsNum == 1&& body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) )
     200                {
     201                        restoreDirty( editor );
     202
     203                        // Simulating keyboard character input by dispatching a keydown of white-space text.
     204                        var keyEventSimulate = doc.$.createEvent( "KeyEvents" );
     205                        keyEventSimulate.initKeyEvent( 'keypress', true, true, win.$, false,
     206                                false, false, false, 0, 32 );
     207                        doc.$.dispatchEvent( keyEventSimulate );
     208
     209                        // Restore the original document status by placing the cursor before a bogus br created (#5021).
     210                        bodyChildsNum && body.getFirst().remove();
     211                        doc.getBody().appendBogus();
     212                        var nativeRange = new CKEDITOR.dom.range( doc );
     213                        nativeRange.setStartAt( body , CKEDITOR.POSITION_AFTER_START );
     214                        nativeRange.select();
     215                }
     216        }
     217
    190218        /**
    191219         *  Auto-fixing block-less content by wrapping paragraph (#3190), prevent
    192220         *  non-exitable-block by padding extra br.(#3189)
     
    201229                        body = editor.document.getBody(),
    202230                        enterMode = editor.config.enterMode;
    203231
     232                CKEDITOR.env.gecko && activateEditing( editor );
     233
    204234                // When enterMode set to block, we'll establing new paragraph only if we're
    205235                // selecting inline contents right under body. (#3657)
    206236                if ( enterMode != CKEDITOR.ENTER_BR
     
    405435                                                        }, 0 );
    406436                                                }
    407437
    408                                                 // Gecko need a key event to 'wake up' the editing
    409                                                 // ability when document is empty.(#3864)
    410                                                 if ( CKEDITOR.env.gecko && !body.childNodes.length )
    411                                                 {
    412                                                         setTimeout( function()
    413                                                         {
    414                                                                 restoreDirty( editor );
     438                                                CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor );
    415439
    416                                                                 // Simulating keyboard character input by dispatching a keydown of white-space text.
    417                                                                 var keyEventSimulate = domDocument.$.createEvent( "KeyEvents" );
    418                                                                 keyEventSimulate.initKeyEvent( 'keypress', true, true, domWindow.$, false,
    419                                                                         false, false, false, 0, 32 );
    420                                                                 domDocument.$.dispatchEvent( keyEventSimulate );
    421 
    422                                                                 // Restore the original document status by placing the cursor before a bogus br created (#5021).
    423                                                                 domDocument.createElement( 'br', { attributes: { '_moz_editor_bogus_node' : 'TRUE', '_moz_dirty' : "" } } )
    424                                                                         .replace( domDocument.getBody().getFirst() );
    425                                                                 var nativeRange = new CKEDITOR.dom.range( domDocument );
    426                                                                 nativeRange.setStartAt( new CKEDITOR.dom.element( body ) , CKEDITOR.POSITION_AFTER_START );
    427                                                                 nativeRange.select();
    428                                                         }, 0 );
    429                                                 }
    430 
    431440                                                // IE, Opera and Safari may not support it and throw
    432441                                                // errors.
    433442                                                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