Changeset 1501

Show
Ignore:
Timestamp:
2008-02-11 03:46:25 (6 months ago)
Author:
martinkou
Message:

Fixed #1682 : Fixed the issue where control elements could not be edited in Firefox, Safari and Opera.

Location:
FCKeditor/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/internals/fckselection_gecko.js

    r1061 r1501  
    5252FCKSelection.GetSelectedElement = function() 
    5353{ 
    54         var selectedElement = null ; 
    55  
    5654        var selection = !!FCK.EditorWindow && FCK.EditorWindow.getSelection() ; 
    57  
    58         if ( selection && selection.anchorNode && selection.anchorNode.nodeType == 1 ) 
    59         { 
    60                 if ( this.GetType() == 'Control' ) 
    61                 { 
    62                         // This one is good for all browsers, expect Safari Mac. 
    63                         selectedElement = selection.anchorNode.childNodes[ selection.anchorOffset ] ; 
    64  
    65                         // For Safari (Mac only), the anchor node for a control selection is 
    66                         // the control itself, which seams logic. FF and Opera use the parent 
    67                         // as the anchor node, pointing to the control with the offset. 
    68                         // As FF created the selection "standard", Safari would do better by 
    69                         // following their steps. 
    70                         if ( !selectedElement ) 
    71                                 selectedElement = selection.anchorNode ; 
    72                         else if ( selectedElement.nodeType != 1 ) 
    73                                 return null ; 
    74                 } 
    75         } 
    76  
    77         return selectedElement ; 
     55        if ( !selection || selection.rangeCount < 1 ) 
     56                return null ; 
     57 
     58        var range = selection.getRangeAt( 0 ) ; 
     59        if ( range.startContainer != range.endContainer || range.startContainer.nodeType != 1 || range.startOffset != range.endOffset - 1 ) 
     60                return null ; 
     61 
     62        var node = range.startContainer.childNodes[ range.startOffset ] ; 
     63        if ( node.nodeType != 1 ) 
     64                return null ; 
     65 
     66        return node ; 
    7867} 
    7968 
  • FCKeditor/trunk/_whatsnew.html

    r1480 r1501  
    8181                        to empty the box in the "Paste from Word" has been removed as it lead to confusion for some  
    8282                        users.</li> 
     83                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1682">#1682</a>] Editing control elements 
     84                        in Firefox, Opera and Safari now works properly.</li> 
    8385        </ul> 
    8486        <p>