Ticket #5782: 5782_2.patch

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

     
    492492                                                domWindow.on( 'focus', function()
    493493                                                        {
    494494                                                                var doc = editor.document;
    495                                                                 if ( CKEDITOR.env.gecko || CKEDITOR.env.opera )
     495
     496                                                                if ( CKEDITOR.env.gecko )
     497                                                                        blinkCursor();
     498                                                                else if ( CKEDITOR.env.opera )
    496499                                                                        doc.getBody().focus();
    497500                                                                else if ( CKEDITOR.env.webkit )
    498501                                                                {
     
    819822                                editor.addCss( 'html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}' );
    820823
    821824                        // Switch on design mode for a short while and close it after then.
    822                         function blinkCursor()
     825                        function blinkCursor( retry )
    823826                        {
    824                                 editor.document.$.designMode = 'on';
    825                                 setTimeout( function ()
    826                                 {
    827                                         editor.document.$.designMode = 'off';
    828                                 }, 50 );
     827                                CKEDITOR.tools.tryThese( function ()
     828                                {
     829                                        editor.document.$.designMode = 'on';
     830                                        setTimeout( function ()
     831                                        {
     832                                                editor.document.$.designMode = 'off';
     833                                                editor.document.getBody().focus();
     834                                        }, 50 );
     835                                }, function ()
     836                                {
     837                                        // The above call is known to fail when parent DOM
     838                                        // tree layout changes may break design mode. (#5782)
     839                                        // Refresh the 'contentEditable' is a cue to this.
     840                                        editor.document.$.designMode = 'off';
     841                                        var body = editor.document.getBody();
     842                                        body.setAttribute( 'contentEditable', false );
     843                                        body.setAttribute( 'contentEditable', true );
     844                                        // Try it again once..
     845                                        !retry && blinkCursor( 1 );
     846                                })
    829847                        }
    830848
    831849                        // Create an invisible element to grab focus.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy