Changeset 597

Show
Ignore:
Timestamp:
2007-07-31 08:33:50 (3 years ago)
Author:
martinkou
Message:

Fix for #393 : Fixed the issue where the caret would sometimes jump between lines in the previous patch.
Fix for #393 : Limited the tag extension prevention logic to <a> tags only under normal situations, to better resemble the behavior in Internet Explorer and MS Word.
Fix for #393 : Defined the <End> key as a way for users to force inline tag discontinuation at the end of a line.

Files:
1 modified

Legend:

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

    r596 r597  
    6565 
    6666                var keyCode = evt.keyCode ; 
    67                 var modKeys = { 34 : 1, 35 : 1, 39 : 1, 40 : 1 } ; 
    68                 if ( ! modKeys[keyCode] ) 
     67                // ignore if positioning key is not pressed. 
     68                // left or up arrow keys need to be processed as well, since <a> links can be expanded in Gecko's editor 
     69                // when the caret moved left or up from another block element below. 
     70                if ( keyCode < 33 || keyCode > 40 ) 
    6971                        return ; 
    7072 
     
    7880                        var node = range.endContainer ; 
    7981                         
     82                        // only perform the patched behavior if we're at the end of a text node. 
    8083                        if ( node.nodeType != 3 ) 
    8184                                return ; 
     
    8487                                return ; 
    8588 
    86                         // we've moved to just after the last character of a text node under an unknown tag, how to proceed? 
     89                        // only perform the patched behavior if we're in an <a> tag, or the End key is pressed. 
     90                        var parentTag = node.parentNode.tagName.toLowerCase() ; 
     91                        if ( ! (  parentTag == 'a' || ( ! FCKListsLib.BlockElements[parentTag] && keyCode == 35 ) ) ) 
     92                                return ; 
     93 
     94                        // our caret has moved to just after the last character of a text node under an unknown tag, how to proceed? 
    8795                        // first, see if there are other text nodes by DFS walking from this text node. 
    8896                        //      - if the DFS has scanned all nodes under my parent, then go the next step. 
     
    108116                                // no suitable next siblings under our grandparent! what to do next? 
    109117                                node = node.parentNode ; 
    110                                 if ( FCKListsLib.BlockElements[ node.tagName.toLowerCase() ] || node == FCK.EditorDocument.body ) 
     118                                if ( FCKListsLib.BlockElements[ parentTag ]  
     119                                                || FCKListsLib.EmptyElements[ parentTag ] 
     120                                                || node == FCK.EditorDocument.body ) 
    111121                                { 
    112122                                        // if our parent is a block node, move to the end of our parent. 
     
    116126                                else 
    117127                                { 
    118                                         // if our parent is not a block node, move to the end of our grandparent. 
     128                                        // things are a little bit more interesting if our parent is not a block node 
     129                                        // due to the weired ways how Gecko's caret acts... 
     130 
     131                                        var stopNode = node.nextSibling ; 
     132 
     133                                        // find out the next block/empty element at our grandparent, we'll  
     134                                        // move the caret just before it. 
     135                                        while ( stopNode ) 
     136                                        { 
     137                                                if ( stopNode.nodeType != 1 ) 
     138                                                { 
     139                                                        stopNode = stopNode.nextSibling ; 
     140                                                        continue ; 
     141                                                } 
     142                                                 
     143                                                var stopTag = stopNode.tagName.toLowerCase() ; 
     144                                                if ( FCKListsLib.BlockElements[stopTag] || FCKListsLib.EmptyElements[stopTag] ) 
     145                                                        break ; 
     146                                                stopNode = stopNode.nextSibling ; 
     147                                        } 
     148 
    119149                                        // note that the dummy marker below is NEEDED, otherwise the caret's behavior will  
    120150                                        // be broken in Gecko. 
    121151                                        var marker = FCK.EditorDocument.createTextNode( "" ) ; 
    122                                         node.parentNode.appendChild( marker ) ; 
     152                                        if ( stopNode ) 
     153                                                node.parentNode.insertBefore( marker, stopNode ) ; 
     154                                        else 
     155                                                node.parentNode.appendChild( marker ) ; 
    123156                                        range.setStart( marker, 0 ) ; 
    124157                                        range.setEnd( marker, 0 ) ;