Ticket #1682: 1682.patch

File 1682.patch, 2.3 KB (added by Martin Kou, 12 years ago)
  • _whatsnew.html

     
    7575                        are now properly sized in Opera.</li>
    7676                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1782">#1782</a>] Clicking on radio
    7777                        buttons or checkboxes in the editor in IE will no longer cause lockups in IE.</li>
     78                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1682">#1682</a>] Editing control elements
     79                        in Firefox, Opera and Safari now works properly.</li>
    7880        </ul>
    7981        <p>
    8082                <a href="_whatsnew_history.html">See previous versions history</a>
  • editor/_source/internals/fckselection_gecko.js

     
    5151// element (object like and image or a table) is selected.
    5252FCKSelection.GetSelectedElement = function()
    5353{
    54         var selectedElement = null ;
    55 
    5654        var selection = !!FCK.EditorWindow && FCK.EditorWindow.getSelection() ;
     55        if ( !selection || selection.rangeCount < 1 )
     56                return null ;
    5757
    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 ] ;
     58        var range = selection.getRangeAt( 0 ) ;
     59        if ( range.startContainer != range.endContainer || range.startContainer.nodeType != 1 || range.startOffset != range.endOffset - 1 )
     60                return null ;
    6461
    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         }
     62        var node = range.startContainer.childNodes[ range.startOffset ] ;
     63        if ( node.nodeType != 1 )
     64                return null ;
    7665
    77         return selectedElement ;
     66        return node ;
    7867}
    7968
    8069FCKSelection.GetParentElement = function()
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy