Ticket #1519: 1519_2.patch

File 1519_2.patch, 4.2 KB (added by Martin Kou, 16 years ago)
  • _whatsnew.html

     
    4242        <p>
    4343                Fixed Bugs:</p>
    4444        <ul>
    45                 <li></li>
     45                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/1519">#1519</a>] Fixed the issue where
     46                        the list command might convert one non-selected line if the lines to be converted are
     47                        selected by keyboard.</li>
    4648        </ul>
    4749        <h3>
    4850                Version 2.6 (SVN)</h3>
  • editor/_source/classes/fckdomrange.js

     
    919919                        return container ;
    920920
    921921                return container.childNodes[ range.endOffset - 1 ] || container ;
     922        },
     923
     924        /*
     925         * This is a pretty funny function. This is needed because of the way
     926         * block selections are handled in MS Word. For example, if you try to
     927         * convert the following into a list (^ delimits selection):
     928         * <p>^Line 1<br>Line 2<br>^Line 3</p>
     929         * Then it should become:
     930         * <ul><li>Line 1</li><li>Line 2</li></ul><p>Line 3</p>
     931         *
     932         * Or this:
     933         * <p>^Line 1</p><p>Line 2</p><p>^Line 3</p>
     934         * Should become:
     935         * <ul><li>Line 1</li></li>Line 2</li></ul><p>Line 3</p>
     936         *
     937         * However, we need to be careful when there are multiple <br>s:
     938         * <p>^Line 1<br>Line 2<br><br><br>^<br>Line 3</p>
     939         * Should become:
     940         * <ul><li>Line 1</li><li>Line 2</li><li></li><li></li></ul>
     941         * <p><br>Line 3</p>
     942         *
     943         * Other cases to be careful:
     944         * <p>^Line 1<br>Lin<b>e 2<br><i><u>^Lin</u></i></b>e 3</p>
     945         * <p>^Line 1<br>Line 2<br>^<img>Line 3</p>
     946         * <p>Line 1^<br>Line 2<br>Line 3^</p>
     947         */
     948        Trim : function()
     949        {
     950                if ( this.CheckIsCollapsed() )
     951                        return ;
     952
     953                var endContainer = this._Range.endContainer ;
     954                var endOffset = this._Range.endOffset ;
     955                var startNode = this.StartNode ;
     956
     957                if ( endContainer.nodeType == 3 )
     958                {
     959                        if ( endOffset > 0 )
     960                                return ;
     961
     962                        var currentNode = endContainer ;
     963                        var commonParent = FCKDomTools.GetCommonParents( endContainer, startNode ).pop() ;
     964                        while ( FCKDomTools.CheckIsEditable( currentNode.parentNode )
     965                                       && currentNode == currentNode.parentNode.childNodes[0]
     966                                       && currentNode.parentNode != commonParent )
     967                                currentNode = currentNode.parentNode ;
     968
     969                        if ( currentNode.previousSibling && currentNode.previousSibling.nodeName.IEquals( 'br' ) )
     970                                this.SetEnd( currentNode.previousSibling, 3 ) ;
     971
     972                        if ( FCKListsLib.BlockElements[ currentNode.nodeName.toLowerCase() ] )
     973                                this.SetEnd( currentNode, 3 ) ;
     974                }
     975                else if ( endContainer.nodeType == 1 )
     976                {
     977                        var currentNode = endContainer.childNodes[ endOffset ] || endContainer.childNodes[ endOffset - 1 ] ;
     978                        var commonParent = FCKDomTools.GetCommonParents( currentNode, startNode ).pop() ;
     979                        while ( FCKDomTools.CheckIsEditable( currentNode.parentNode )
     980                                       && currentNode == currentNode.parentNode.childNodes[0]
     981                                       && currentNode.parentNode != commonParent )
     982                                currentNode = currentNode.parentNode ;
     983
     984                        var prevNode = ( endOffset >= endContainer.length ? currentNode : currentNode.previousSibling ) ;
     985                       
     986                        if ( prevNode && prevNode.nodeName.IEquals( 'br' ) )
     987                                this.SetEnd( prevNode, 3 ) ;
     988
     989                        if ( FCKListsLib.BlockElements[ currentNode ] )
     990                                this.SetEnd( currentNode, 3 ) ;
     991                }
    922992        }
    923993} ;
  • editor/_source/commandclasses/fcklistcommands.js

     
    5858                var doc = FCK.EditorDocument ;
    5959                var range = new FCKDomRange( FCK.EditorWindow ) ;
    6060                range.MoveToSelection() ;
     61                range.Trim() ;
    6162                var state = this.GetState() ;
    6263
    6364                // Midas lists rule #1 says we can create a list even in an empty document.
     
    142143                                nextRangeExists = false ;
    143144                        else
    144145                        {
     146                                // Firefox allows a selection to contain multiple range objects.
     147                                // Handle them as well.
    145148                                if ( rangeQueue == null )
    146149                                {
    147150                                        rangeQueue = [] ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy