Changeset 799

Show
Ignore:
Timestamp:
2007-09-12 05:16:14 (3 years ago)
Author:
martinkou
Message:

Merged Fred's proposed patch for FCKDomRange.GetParagraphs() with changes for supporting list-style paragraph separations.
Fix for #1178 : Fixed the problem where list removal does not work when the caret is at the end of a list item in IE.

Location:
FCKeditor/trunk/editor/_source
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckdomrange.js

    r776 r799  
    5252                        if ( eStart != eEnd ) 
    5353                                oElementPath = new FCKElementPath( eEnd ) ; 
    54                         this.EndNode                    = eEnd.nodeType == 3 ? eEnd : eEnd.childNodes[ innerRange.endOffset ] ; 
     54 
     55                        // The innerRange.endContainer[ innerRange.endOffset ] is not 
     56                        // usually part of the range, but the marker for the range end. So, 
     57                        // let's get the previous available node as the real end. 
     58                        var eEndNode = eEnd ; 
     59                        if ( innerRange.endOffset == 0 ) 
     60                        { 
     61                                while ( eEndNode && !eEndNode.previousSibling ) 
     62                                        eEndNode = eEndNode.parentNode ; 
     63                                 
     64                                eEndNode = eEndNode.previousSibling ; 
     65                        } 
     66                        else if ( eEndNode.nodeType == 1 ) 
     67                                eEndNode = eEndNode.childNodes[ innerRange.endOffset - 1 ] ; 
     68 
     69                        this.EndNode                    = eEndNode ; 
    5570                        this.EndContainer               = eEnd ; 
    5671                        this.EndBlock                   = oElementPath.Block ; 
     
    394409         *                      4 = After End           <target>contents</target>^ 
    395410         */ 
    396         SetStart : function( targetElement, position ) 
     411        SetStart : function( targetElement, position, noInfoUpdate ) 
    397412        { 
    398413                var oRange = this._Range ; 
     
    417432                                oRange.setStartAfter( targetElement ) ; 
    418433                } 
    419                 this._UpdateElementInfo() ; 
     434                 
     435                if ( !noInfoUpdate ) 
     436                        this._UpdateElementInfo() ; 
    420437        }, 
    421438 
     
    429446         *                      4 = After End           <target>contents</target>^ 
    430447         */ 
    431         SetEnd : function( targetElement, position ) 
     448        SetEnd : function( targetElement, position, noInfoUpdate ) 
    432449        { 
    433450                var oRange = this._Range ; 
     
    452469                                oRange.setEndAfter( targetElement ) ; 
    453470                } 
    454                 this._UpdateElementInfo() ; 
     471 
     472                if ( !noInfoUpdate ) 
     473                        this._UpdateElementInfo() ; 
    455474        }, 
    456475 
     
    509528 
    510529                        case 'block_contents' : 
    511                                 if ( this.StartBlock ) 
     530                                if ( this.StartBlock && FCKConfig.EnterMode != 'br' ) 
    512531                                        this.SetStart( this.StartBlock, 1 ) ; 
    513532                                else 
     
    519538                                        // If the offset node is not available, the the first one. 
    520539                                        if ( oNode.nodeType == 1 ) 
    521                                         { 
    522                                                 if ( !( oNode = oNode.childNodes[ this._Range.startOffset ] ) ) 
    523                                                         oNode = oNode.firstChild ; 
    524                                         } 
    525  
    526                                         // Not able to defined the current position. 
    527                                         if ( !oNode ) 
    528                                                 return ; 
     540                                                oNode = oNode.childNodes[ this._Range.startOffset ] || oNode.firstChild ; 
    529541 
    530542                                        // We must look for the left boundary, relative to the range 
    531543                                        // start, which is limited by a block element. 
    532                                         while ( true ) 
     544                                        while ( oNode  
     545                                                        && ( oNode.nodeType != 1  
     546                                                                || ( oNode != this.StartBlockLimit 
     547                                                                        && !FCKListsLib.BlockBoundaries[ oNode.nodeName.toLowerCase() ] ) ) ) 
    533548                                        { 
    534                                                 oSibling = oNode.previousSibling ; 
    535  
    536                                                 if ( !oSibling ) 
    537                                                 { 
    538                                                         // Continue if we are not yet in the block limit (inside a <b>, for example). 
    539                                                         if ( oNode.parentNode != this.StartBlockLimit ) 
    540                                                                 oNode = oNode.parentNode ; 
    541                                                         else 
    542                                                                 break ; 
    543                                                 } 
    544                                                 else if ( oSibling.nodeType != 1 || !(/^(?:P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|DT|DE)$/).test( oSibling.nodeName.toUpperCase() ) ) 
    545                                                 { 
    546                                                         // Continue if the sibling is not a block tag. 
    547                                                         oNode = oSibling ; 
    548                                                 } 
    549                                                 else 
     549                                                this._Range.setStartBefore( oNode ) ; 
     550                                                 
     551                                                if ( oNode == oNode.parentNode.firstChild && FCKListsLib.BlockBoundaries[ oNode.parentNode.nodeName.toLowerCase() ] ) 
    550552                                                        break ; 
     553 
     554                                                oNode = FCKDomTools.GetPreviousSourceNode( oNode, true ) ; 
    551555                                        } 
    552  
    553                                         this._Range.setStartBefore( oNode ) ; 
    554                                 } 
    555  
    556                                 if ( this.EndBlock ) 
     556                                } 
     557 
     558                                if ( this.EndBlock && FCKConfig.EnterMode != 'br'  ) 
    557559                                        this.SetEnd( this.EndBlock, 2 ) ; 
    558560                                else 
     
    562564                                                oNode = oNode.childNodes[ this._Range.endOffset ] || oNode.lastChild ; 
    563565 
    564                                         if ( !oNode ) 
    565                                                 return ; 
    566  
    567566                                        // We must look for the right boundary, relative to the range 
    568567                                        // end, which is limited by a block element. 
    569                                         while ( true ) 
     568                                        while ( oNode  
     569                                                        && ( oNode.nodeType != 1  
     570                                                                || ( oNode != this.StartBlockLimit  
     571                                                                        && !FCKListsLib.BlockBoundaries[ oNode.nodeName.toLowerCase() ] ) ) ) 
    570572                                        { 
    571                                                 oSibling = oNode.nextSibling ; 
    572  
    573                                                 if ( !oSibling ) 
    574                                                 { 
    575                                                         // Continue if we are not yet in the block limit (inside a <b>, for example). 
    576                                                         if ( oNode.parentNode != this.EndBlockLimit ) 
    577                                                                 oNode = oNode.parentNode ; 
    578                                                         else 
    579                                                                 break ; 
    580                                                 } 
    581                                                 else if ( oSibling.nodeType != 1 || !(/^(?:P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|DT|DE)$/).test( oSibling.nodeName.toUpperCase() ) ) 
    582                                                 { 
    583                                                         // Continue if the sibling is not a block tag. 
    584                                                         oNode = oSibling ; 
    585                                                 } 
    586                                                 else 
     573                                                this._Range.setEndAfter( oNode ) ; 
     574 
     575                                                if ( oNode == oNode.parentNode.lastChild && FCKListsLib.BlockBoundaries[ oNode.parentNode.nodeName.toLowerCase() ] ) 
    587576                                                        break ; 
     577 
     578                                                oNode = FCKDomTools.GetNextSourceNode( oNode, true ) ; 
    588579                                        } 
    589  
     580                                         
     581                                        // In EnterMode='br', the end <br> boundary element must 
     582                                        // be included in the expanded range. 
     583                                        if ( oNode && oNode.nodeName.toLowerCase() == 'br' )  
     584                                                this._Range.setEndAfter( oNode ) ; 
     585                                } 
     586 
     587                                this._UpdateElementInfo() ; 
     588                                break ;                                                                                 // @Packager.Remove.Start 
     589 
     590                        case 'list_contents' : 
     591                                // Get the start node for the current range. 
     592                                oNode = this._Range.startContainer ; 
     593 
     594                                // If it is an element, get the current child node for the range (in the offset). 
     595                                // If the offset node is not available, the the first one. 
     596                                if ( oNode.nodeType == 1 ) 
     597                                        oNode = oNode.childNodes[ this._Range.startOffset ] || oNode.firstChild ; 
     598 
     599                                // We must look for the left boundary, relative to the range 
     600                                // start, which is limited by a block element. 
     601                                while ( oNode  
     602                                                && ( oNode.nodeType != 1  
     603                                                        || ( oNode != this.StartBlockLimit 
     604                                                                && !FCKListsLib.ListBoundaries[ oNode.nodeName.toLowerCase() ] ) ) ) 
     605                                { 
     606                                        this._Range.setStartBefore( oNode ) ; 
     607 
     608                                        if ( oNode == oNode.parentNode.firstChild && FCKListsLib.ListBoundaries[ oNode.parentNode.nodeName.toLowerCase() ] ) 
     609                                                break ; 
     610 
     611                                        oNode = FCKDomTools.GetPreviousSourceNode( oNode, true ) ; 
     612                                } 
     613 
     614                                oNode = this._Range.endContainer ; 
     615                                if ( oNode.nodeType == 1 ) 
     616                                        oNode = oNode.childNodes[ this._Range.endOffset ] || oNode.lastChild ; 
     617 
     618                                // We must look for the right boundary, relative to the range 
     619                                // end, which is limited by a block element. 
     620                                while ( oNode  
     621                                                && ( oNode.nodeType != 1  
     622                                                        || ( oNode != this.StartBlockLimit  
     623                                                                && !FCKListsLib.ListBoundaries[ oNode.nodeName.toLowerCase() ] ) ) ) 
     624                                { 
    590625                                        this._Range.setEndAfter( oNode ) ; 
    591                                 } 
     626 
     627                                        if ( oNode == oNode.parentNode.lastChild && FCKListsLib.ListBoundaries[ oNode.parentNode.nodeName.toLowerCase() ] ) 
     628                                                break ; 
     629 
     630                                        oNode = FCKDomTools.GetNextSourceNode( oNode, true ) ; 
     631                                } 
     632 
     633                                // In EnterMode='br', the end <br> boundary element must 
     634                                // be included in the expanded range. 
     635                                if ( oNode && oNode.nodeName.toLowerCase() == 'br' )  
     636                                        this._Range.setEndAfter( oNode ) ; 
    592637 
    593638                                this._UpdateElementInfo() ; 
    594                         break ;                                                                                 // @Packager.Remove.Start 
     639                                break ;                                                                                 // @Packager.Remove.Start 
    595640 
    596641                        default : 
     
    725770        CheckHasRange : function() 
    726771        { 
    727                 return ( this._Range && true ) ; 
    728         }, 
    729  
    730         _CheckIsParagraphBoundary : function( node ) 
    731         { 
    732                 if ( node.nodeType == 1 ) 
    733                 { 
    734                         var tagName = node.tagName.toLowerCase() ; 
    735                         return ! ( FCKListsLib.InlineNonEmptyElements[tagName] || tagName == 'img' ) ; 
    736                 } 
    737                 return false ; 
    738         }, 
    739  
    740         _GenerateParagraphRange : function( paragraphList, targetWindow, startNode, endNode ) 
    741         { 
    742                 if ( ! startNode || ! endNode ) 
    743                         return ; 
    744                 var range = new FCKDomRange( targetWindow ) ; 
    745                 range._Range = new FCKW3CRange( targetWindow.document ) ; 
    746                 if ( startNode.nodeName.toLowerCase() == 'br' ) 
    747                         range._Range.setStartBefore( startNode ) ; 
     772                return !!this._Range ; 
     773        }, 
     774 
     775        GetParagraphs : function( forceBreakBr ) 
     776        { 
     777                var retval = [] ; 
     778 
     779                // Get and "expanded" clone of this range. 
     780                var range = this.Clone() ; 
     781                if ( forceBreakBr ) 
     782                        range.Expand( 'list_contents' ) ; 
    748783                else 
    749                         range._Range.setStart( startNode, 0 ) ; 
    750                 if ( endNode.nodeName.toLowerCase() == 'br' ) 
    751                         range._Range.setEndBefore( endNode ) ; 
    752                 else 
    753                         range._Range.setEnd( endNode, endNode.nodeType == 1 ? endNode.childNodes.length : endNode.nodeValue.length ) ; 
    754                 range._UpdateElementInfo() ; 
    755                 paragraphList.push( range ) ; 
    756         }, 
    757  
    758         GetSelectedParagraphs : function() 
    759         { 
    760                 this.MoveToSelection() ; 
    761  
    762                 var startNode = this._Range.startContainer ; 
    763                 var endNode = this._Range.endContainer ; 
    764                 var startOffset = this._Range.startOffset ; 
    765                 var endOffset = this._Range.endOffset ; 
    766                 if ( startNode.childNodes && startNode.childNodes[startOffset] ) 
    767                         startNode = startNode.childNodes[startOffset] ; 
    768                 if ( endNode.childNodes && endNode.childNodes[endOffset] ) 
    769                         endNode = endNode.childNodes[endOffset] ; 
    770  
    771                 // Get the starting point of the selection's paragraph. 
    772                 var paragraphStartNode = startNode ; 
    773                 while ( paragraphStartNode && ! this._CheckIsParagraphBoundary( paragraphStartNode ) ) 
    774                 { 
    775                         var candidate = null ; 
    776                         if ( paragraphStartNode.previousSibling ) 
    777                         { 
    778                                 if ( ! this._CheckIsParagraphBoundary( paragraphStartNode.previousSibling ) ) 
    779                                         candidate = paragraphStartNode.previousSibling ; 
    780                                 while ( candidate && candidate.lastChild && ! this._CheckIsParagraphBoundary( candidate.lastChild ) ) 
    781                                         candidate = candidate.lastChild ; 
    782                         } 
    783                         else 
    784                         { 
    785                                 if ( ! this._CheckIsParagraphBoundary( paragraphStartNode.parentNode ) ) 
    786                                         candidate = paragraphStartNode.parentNode ; 
    787                         } 
    788  
    789                         if ( candidate ) 
    790                                 paragraphStartNode = candidate ; 
    791                         else 
    792                                 break ; 
    793                 } 
    794  
    795                 // Get the ending point of the selection's paragraph. 
    796                 var paragraphEndNode = endNode ; 
    797                 while ( paragraphEndNode && ! this._CheckIsParagraphBoundary( paragraphEndNode ) ) 
    798                 { 
    799                         var candidate = null ; 
    800                         if ( paragraphEndNode.firstChild ) 
    801                         { 
    802                                 if ( ! this._CheckIsParagraphBoundary( paragraphEndNode.firstChild ) ) 
    803                                         candidate = paragraphEndNode.firstChild ; 
    804                         } 
    805                         else if ( paragraphEndNode.nextSibling ) 
    806                         { 
    807                                 if ( ! this._CheckIsParagraphBoundary( paragraphEndNode.nextSibling ) ) 
    808                                         candidate = paragraphEndNode.nextSibling ; 
    809                         } 
    810                         else 
    811                         { 
    812                                 var ancestor = paragraphEndNode.parentNode ; 
    813                                 while ( ancestor ) 
    814                                 { 
    815                                         if ( this._CheckIsParagraphBoundary( ancestor ) ) 
    816                                                 break ; 
    817                                         if ( ancestor.nextSibling ) 
     784                        range.Expand( 'block_contents' ) ; 
     785         
     786                var currentNode = range.StartNode || range.StartContainer ; 
     787                var lastNode    = range.EndNode || range.EndContainer.lastChild || range.EndContainer ; 
     788 
     789                var boundarySet = FCKListsLib.BlockBoundaries ; 
     790                if ( forceBreakBr ) 
     791                        boundarySet = FCKListsLib.ListBoundaries ; 
     792                 
     793                // Let's reuse this range  
     794                range = null ; 
     795 
     796                while ( currentNode ) 
     797                { 
     798                        // closeRange indicates that a paragraph boundary has been found, 
     799                        // so the range must be appended to the list. 
     800                        var closeRange = false ; 
     801                         
     802                        var continueFromSibling = false ; 
     803                         
     804                        // includeNode indicates that the current node is good to be part 
     805                        // of the range. 
     806                        var includeNode = ( currentNode.nodeType != 1 ) ; 
     807                         
     808                        // If it is an element node, let's check if it can be part of the 
     809                        // range. 
     810                        if ( !includeNode ) 
     811                        { 
     812                                var nodeName = currentNode.nodeName.toLowerCase() ; 
     813                                 
     814                                if ( boundarySet[ nodeName ] ) 
     815                                { 
     816                                        // <br> boundaries must be part of the range. It will 
     817                                        // happen only if EnterMode='br'. 
     818                                        if ( nodeName == 'br' ) 
     819                                                includeNode = true ; 
     820                                 
     821                                        closeRange = true ; 
     822                                } 
     823                                else 
     824                                { 
     825                                        // If we have child nodes, let's check them. 
     826                                        if ( currentNode.firstChild ) 
    818827                                        { 
    819                                                 if ( this._CheckIsParagraphBoundary( ancestor.nextSibling ) ) 
    820                                                         break ; 
    821                                                 candidate = ancestor.nextSibling ; 
     828                                                currentNode = currentNode.firstChild ; 
     829                                                continue ; 
     830                                        } 
     831                                        includeNode = true ; 
     832                                } 
     833                        } 
     834                        else if ( currentNode.nodeType == 3 ) 
     835                        { 
     836                                // Ignore normal whitespaces (i.e. not including &nbsp; or 
     837                                // other unicode whitespaces) before/after a block node. 
     838                                if ( /^[\r\n\t ]+$/.test( currentNode.nodeValue ) ) 
     839                                        includeNode = false ; 
     840                        } 
     841                         
     842                        // The current node is good to be part of the range and we are 
     843                        // starting a new range, initialize it first. 
     844                        if ( includeNode && !range ) 
     845                        { 
     846                                range = new FCKDomRange( this.Window ) ; 
     847                                range.SetStart( currentNode, 3, true ) ; 
     848                        } 
     849                                 
     850                        // If we are in an element boundary, let's check if it is time 
     851                        // to close the range, otherwise we include the parent within it. 
     852                        if ( range && !closeRange ) 
     853                        { 
     854                                var parentNode = currentNode.parentNode ; 
     855                                while ( currentNode == parentNode.lastChild && currentNode != lastNode ) 
     856                                { 
     857                                        if ( boundarySet[ parentNode.nodeName.toLowerCase() ] ) 
     858                                        { 
     859                                                closeRange = true ;              
    822860                                                break ; 
    823861                                        } 
    824                                         else 
    825                                                 ancestor = ancestor.parentNode ; 
    826                                 } 
    827                         } 
    828  
    829                         if ( candidate ) 
    830                                 paragraphEndNode = candidate ; 
    831                         else 
     862                                         
     863                                        currentNode = parentNode ; 
     864                                        continueFromSibling = true ; 
     865                                } 
     866                        } 
     867                         
     868                        // Now finally include the node. 
     869                        if ( includeNode ) 
     870                                range.SetEnd( currentNode, 4, true ) ; 
     871                         
     872                        // We have found a block boundary. Let's add the range to the list, 
     873                        // and prepare it for the next one. 
     874                        if ( ( closeRange || currentNode == lastNode ) && range ) 
     875                        { 
     876                                range._UpdateElementInfo() ; 
     877                                retval.push( range ) ; 
     878                                range = null ; 
     879                        } 
     880                         
     881                        // Stop processing if this is the last one. 
     882                        if ( currentNode == lastNode ) 
    832883                                break ; 
    833                 } 
    834  
    835                 // Break up the range between paragraphStartNode and paragraphEndNode into paragraphs represented by ranges. 
    836                 var retval = [] ; 
    837                 var currentStart = paragraphStartNode ; 
    838                 var currentEnd = currentStart ; 
    839  
    840                 // Each iteration advances the position by one node in a DFS tree walk. 
    841                 while ( currentEnd != paragraphEndNode ) 
    842                 { 
    843                         // 1. if we come across a <br> node, save a new paragraph 
    844                         // 2. if we come across a block element boundary, save a new paragraph 
    845                         // 3. set currentStart to null after saving a new paragraph 
    846                         // 4. set currentStart to currentEnd if currentStart is null and currentEnd is not boundary node 
    847                         if ( currentStart == null && currentEnd.nodeType == 3 ) 
    848                         { 
    849                                 // Ignore normal whitespaces (i.e. not including &nbsp; or other unicode whitespaces) after a block node. 
    850                                 if ( currentEnd.nodeValue.search( /^[\r\n\t ]+$/ ) == 0 ) 
    851                                 { 
    852                                         var prevNode = currentEnd.previousSibling ; 
    853                                         if ( prevNode ) 
    854                                         { 
    855                                                 var prevTag = String( prevNode.tagName ).toLowerCase() ; 
    856                                                 if ( ! ( FCKListsLib.BlockElements[prevTag] || FCKListsLib.NonEmptyBlockElements[prevTag] ) ) 
    857                                                         currentStart = currentEnd ; 
    858                                         } 
    859                                 } 
    860                                 else if ( currentEnd.nodeValue.length > 0 ) 
    861                                         currentStart = currentEnd ; 
    862                         } 
    863  
    864                         if ( currentEnd.firstChild ) 
    865                         { 
    866                                 if ( this._CheckIsParagraphBoundary( currentEnd.firstChild ) ) 
    867                                 { 
    868                                         this._GenerateParagraphRange( retval, this.Window, currentStart, currentEnd ) ; 
    869                                         currentStart = null ; 
    870                                 } 
    871                                 currentEnd = currentEnd.firstChild ; 
    872                         } 
    873                         else if ( currentEnd.nextSibling ) 
    874                         { 
    875                                 if ( this._CheckIsParagraphBoundary( currentEnd.nextSibling ) ) 
    876                                 { 
    877                                         this._GenerateParagraphRange( retval, this.Window, currentStart, currentEnd ) ; 
    878                                         currentStart = null ; 
    879                                 } 
    880                                 currentEnd = currentEnd.nextSibling ; 
    881                         } 
    882                         else 
    883                         { 
    884                                 var ancestor = currentEnd.parentNode ; 
    885                                 while ( ancestor ) 
    886                                 { 
    887                                         if ( this._CheckIsParagraphBoundary( ancestor ) ) 
    888                                         { 
    889                                                 this._GenerateParagraphRange( retval, this.Window, currentStart, currentEnd ) ; 
    890                                                 currentStart = null ; 
    891                                         } 
    892                                         if ( ancestor.nextSibling ) 
    893                                         { 
    894                                                 if ( this._CheckIsParagraphBoundary( ancestor.nextSibling ) ) 
    895                                                 { 
    896                                                         this._GenerateParagraphRange( retval, this.Window, currentStart, currentEnd ) ; 
    897                                                         currentStart = null ; 
    898                                                 } 
    899                                                 currentEnd = ancestor.nextSibling ; 
    900                                                 break ; 
    901                                         } 
    902                                         else 
    903                                                 ancestor = ancestor.parentNode ; 
    904                                 } 
    905                         } 
    906                 } 
    907                 // Record the final range as well. 
    908                 if ( currentStart == null && currentEnd.nodeType == 3 ) 
    909                         currentStart = currentEnd ; 
    910                 this._GenerateParagraphRange( retval, this.Window, currentStart, currentEnd ) ; 
     884                         
     885                        currentNode = FCKDomTools.GetNextSourceNode( currentNode, continueFromSibling ) ; 
     886                } 
    911887 
    912888                return retval ; 
    913889        } 
    914  
    915890} ; 
  • FCKeditor/trunk/editor/_source/classes/fckeditingarea.js

    r781 r799  
    303303        // Kludge for #141... yet more code to workaround IE bugs 
    304304        var range = this.Document.selection.createRange() ; 
     305 
     306        // Only apply the fix when in a block and the block is empty. 
     307        var parentNode = range.parentElement() ; 
     308 
     309        if ( ! ( parentNode.childNodes.length == 0 && (  
     310                                        FCKListsLib.BlockElements[parentNode.nodeName.toLowerCase()] ||  
     311                                        FCKListsLib.NonEmptyBlockElements[parentNode.nodeName.toLowerCase()] ) ) ) 
     312                return ; 
     313 
    305314        var oldLength = range.text.length ; 
    306315        range.moveEnd( "character", 1 ) ; 
  • FCKeditor/trunk/editor/_source/internals/fckdomtools.js

    r774 r799  
    270270                        return null ; 
    271271 
    272                 var nextNode ; 
     272                var node ; 
    273273                 
    274274                if ( !startFromSibling && currentNode.firstChild ) 
    275                         nextNode = currentNode.firstChild ; 
    276                 else 
    277                         nextNode = ( currentNode.nextSibling || this.GetNextSourceNode( currentNode.parentNode, true, nodeType ) ) ; 
    278                  
    279                 if ( nodeType && nextNode && nextNode.nodeType != nodeType ) 
    280                         return this.GetNextSourceNode( nextNode, false, nodeType ) ; 
    281                  
    282                 return nextNode ; 
     275                        node = currentNode.firstChild ; 
     276                else 
     277                        node = ( currentNode.nextSibling || this.GetNextSourceNode( currentNode.parentNode, true, nodeType ) ) ; 
     278                 
     279                if ( nodeType && node && node.nodeType != nodeType ) 
     280                        return this.GetNextSourceNode( node, false, nodeType ) ; 
     281                 
     282                return node ; 
     283        }, 
     284 
     285        /* 
     286         * Get the next DOM node available in source order. 
     287         */ 
     288        GetPreviousSourceNode : function( currentNode, startFromSibling, nodeType ) 
     289        { 
     290                if ( !currentNode ) 
     291                        return null ; 
     292 
     293                var node ; 
     294                 
     295                if ( !startFromSibling && currentNode.lastChild ) 
     296                        node = currentNode.lastChild ; 
     297                else 
     298                        node = ( currentNode.previousSibling || this.GetPreviousSourceNode( currentNode.parentNode, true, nodeType ) ) ; 
     299                 
     300                if ( nodeType && node && node.nodeType != nodeType ) 
     301                        return this.GetPreviousSourceNode( node, false, nodeType ) ; 
     302                 
     303                return node ; 
    283304        }, 
    284305 
  • FCKeditor/trunk/editor/_source/internals/fcklistslib.js

    r774 r799  
    5454        // Object elements for the Styles System. 
    5555        StyleObjectElements : { img:1,hr:1,li:1,table:1,tr:1,td:1,embed:1,object:1,ol:1,ul:1 }, 
     56         
     57        // Elements used to separate block contents. 
     58        BlockBoundaries : { p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,address:1,pre:1,ol:1,ul:1,li:1,dt:1,de:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,blockquote:1 }, 
     59        ListBoundaries : { p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,address:1,pre:1,ol:1,ul:1,li:1,dt:1,de:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,blockquote:1,br:1 }, 
    5660 
    5761        // Final setup of FCKListsLib once the editor is loaded (at FCK.StartEditor). 
     
    6973                else 
    7074                        this.PathBlockLimitElements.div = 1 ; 
     75                 
     76                if ( FCKConfig.EnterMode == 'br' ) 
     77                        this.BlockBoundaries.br = 1 ; 
    7178        } 
    7279} ;