Ticket #2024: fckdialog_ie_selection_source_view.patch

File fckdialog_ie_selection_source_view.patch, 2.2 kB (added by letssurf, 4 months ago)
  • fckdialog.js

     
    104104                        // be restored in the dialog code. 
    105105                        if ( FCKBrowserInfo.IsIE && !topDialog ) 
    106106                        { 
    107                                 // Ensures the editor has the selection focus. (#1801) 
    108                                 currentInstance.Focus() ; 
     107                         
     108        if (currentInstance.EditMode == FCK_EDITMODE_WYSIWYG) { 
     109            // Ensures the editor has the selection focus. (#1801) 
     110            currentInstance.Focus() ; 
     111            var editorDocument = currentInstance.EditorDocument ; 
     112            var selection = editorDocument.selection ; 
     113            var range ; 
    109114 
    110                                 var editorDocument = currentInstance.EditorDocument ; 
    111                                 var selection = editorDocument.selection ; 
    112                                 var range ; 
     115            if ( selection ) 
     116            { 
     117                range = selection.createRange() ; 
    113118 
    114                                 if ( selection ) 
    115                                 { 
    116                                         range = selection.createRange() ; 
     119                // Ensure that the range comes from the editor document. 
     120                if ( range ) 
     121                { 
     122                    if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument ) 
     123                        range = null ; 
     124                    else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument ) 
     125                        range = null ; 
     126                } 
     127            } 
     128        } else { 
     129            currentInstance.EditingArea.Textarea.focus(); 
     130            var editorDocument = currentInstance.EditingArea.Textarea ; 
     131            var selection = editorDocument.document.selection ; 
     132            var range ; 
    117133 
    118                                         // Ensure that the range comes from the editor document. 
    119                                         if ( range ) 
    120                                         { 
    121                                                 if ( range.parentElement && FCKTools.GetElementDocument( range.parentElement() ) != editorDocument ) 
    122                                                         range = null ; 
    123                                                 else if ( range.item && FCKTools.GetElementDocument( range.item(0) )!= editorDocument ) 
    124                                                         range = null ; 
    125                                         } 
    126                                 } 
    127  
     134            if ( selection ) { 
     135                range = selection.createRange() ; 
     136            } 
     137        } 
     138                         
    128139                                this.SelectionData = range ; 
    129140                        } 
    130141