Ticket #2407: 2407.patch

File 2407.patch, 6.3 KB (added by Martin Kou, 16 years ago)
  • _whatsnew.html

     
    4242        <p>
    4343                Fixed Bugs:</p>
    4444        <ul>
    45                 <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2407">#2407</a>] Fixed the issue
     45                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2412">#2412</a>] Fixed the issue
    4646                        where FCK.InsertHtml() is no longer removing selected contents after content insertion
    4747                        in Firefox.</li>
     48                <li>[<a target="_blank" href="http://dev.fckeditor.net/ticket/2407">#2407</a>] Fixed the issue
     49                        where the Div container command and the blockquote command would break lists.</li>
    4850        </ul>
    4951        <h3>
    5052                Version 2.6.3 Beta</h3>
  • editor/_source/commandclasses/fckblockquotecommand.js

     
    8383
    8484                if ( state == FCK_TRISTATE_OFF )
    8585                {
    86                         iterator.EnforceRealBlocks = true ;
    8786                        var paragraphs = [] ;
    8887                        while ( ( block = iterator.GetNextParagraph() ) )
    8988                                paragraphs.push( block ) ;
     
    109108                                block = paragraphs[i] ;
    110109                                commonParent = FCKDomTools.GetCommonParents( block.parentNode, commonParent ).pop() ;
    111110                        }
     111
     112                        // The common parent must not be the following tags: table, tbody, tr, ol, ul.
     113                        while ( commonParent.nodeName.IEquals( 'table', 'tbody', 'tr', 'ol', 'ul' ) )
     114                                commonParent = commonParent.parentNode ;
     115
     116                        // Reconstruct the block list to be processed such that all resulting blocks
     117                        // satisfy parentNode == commonParent.
    112118                        var lastBlock = null ;
    113119                        while ( paragraphs.length > 0 )
    114120                        {
     
    150156                else if ( state == FCK_TRISTATE_ON )
    151157                {
    152158                        var moveOutNodes = [] ;
     159                        var elementMarkers = {} ;
    153160                        while ( ( block = iterator.GetNextParagraph() ) )
    154161                        {
    155162                                var bqParent = null ;
     
    165172                                        block = block.parentNode ;
    166173                                }
    167174
    168                                 if ( bqParent && bqChild )
     175                                // Remember the blocks that were recorded down in the moveOutNodes array
     176                                // to prevent duplicates.
     177                                if ( bqParent && bqChild && !bqChild._fckblockquotemoveout )
     178                                {
    169179                                        moveOutNodes.push( bqChild ) ;
     180                                        FCKDomTools.SetElementMarker( elementMarkers, bqChild, '_fckblockquotemoveout', true ) ;
     181                                }
    170182                        }
     183                        FCKDomTools.ClearAllMarkers( elementMarkers ) ;
    171184
    172185                        var movedNodes = [] ;
     186                        var processedBlockquoteBlocks = [], elementMarkers = {} ;
     187                        var noBlockLeft = function( bqBlock )
     188                        {
     189                                for ( var i = 0 ; i < bqBlock.childNodes.length ; i++ )
     190                                {
     191                                        if ( FCKListsLib.BlockElements[ bqBlock.childNodes[i].nodeName.toLowerCase() ] )
     192                                                return false ;
     193                                }
     194                                return true ;
     195                        }
    173196                        while ( moveOutNodes.length > 0 )
    174197                        {
    175198                                var node = moveOutNodes.shift() ;
     
    178201                                // If the node is located at the beginning or the end, just take it out without splitting.
    179202                                // Otherwise, split the blockquote node and move the paragraph in between the two blockquote nodes.
    180203                                if ( node == node.parentNode.firstChild )
    181                                 {
    182204                                        bqBlock.parentNode.insertBefore( bqBlock.removeChild( node ), bqBlock ) ;
    183                                         if ( ! bqBlock.firstChild )
    184                                                 bqBlock.parentNode.removeChild( bqBlock ) ;
    185                                 }
    186205                                else if ( node == node.parentNode.lastChild )
    187                                 {
    188206                                        bqBlock.parentNode.insertBefore( bqBlock.removeChild( node ), bqBlock.nextSibling ) ;
    189                                         if ( ! bqBlock.firstChild )
    190                                                 bqBlock.parentNode.removeChild( bqBlock ) ;
    191                                 }
    192207                                else
    193208                                        FCKDomTools.BreakParent( node, node.parentNode, range ) ;
    194209
     210                                // Remember the blockquote node so we can clear it later (if it becomes empty).
     211                                if ( !bqBlock._fckbqprocessed )
     212                                {
     213                                        processedBlockquoteBlocks.push( bqBlock ) ;
     214                                        FCKDomTools.SetElementMarker( elementMarkers, bqBlock, '_fckbqprocessed', true );
     215                                }
     216
    195217                                movedNodes.push( node ) ;
    196218                        }
    197219
     220                        // Clear blockquote nodes that have become empty.
     221                        for ( var i = processedBlockquoteBlocks.length - 1 ; i >= 0 ; i-- )
     222                        {
     223                                var bqBlock = processedBlockquoteBlocks[i] ;
     224                                if ( noBlockLeft( bqBlock ) )
     225                                        FCKDomTools.RemoveNode( bqBlock ) ;
     226                        }
     227                        FCKDomTools.ClearAllMarkers( elementMarkers ) ;
     228
    198229                        if ( FCKConfig.EnterMode.IEquals( 'br' ) )
    199230                        {
    200231                                while ( movedNodes.length )
  • editor/dialog/fck_div.html

     
    203203        var iterator = new FCKDomRangeIterator( range ) ;
    204204        var block ;
    205205
    206         iterator.EnforceRealBlocks = true ;
    207206        var paragraphs = [] ;
     207        while ( ( block = iterator.GetNextParagraph() ) )
     208                paragraphs.push( block ) ;
     209
     210        // Make sure all paragraphs have the same parent.
     211        var commonParent = paragraphs[0].parentNode ;
     212        var tmp = [] ;
     213        for ( var i = 0 ; i < paragraphs.length ; i++ )
     214        {
     215                block = paragraphs[i] ;
     216                commonParent = FCKDomTools.GetCommonParents( block.parentNode, commonParent ).pop() ;
     217        }
     218
     219        // The common parent must not be the following tags: table, tbody, tr, ol, ul.
     220        while ( commonParent.nodeName.IEquals( 'table', 'tbody', 'tr', 'ol', 'ul' ) )
     221                commonParent = commonParent.parentNode ;
     222
     223        // Reconstruct the block list to be processed such that all resulting blocks
     224        // satisfy parentNode == commonParent.
     225        var lastBlock = null ;
     226        while ( paragraphs.length > 0 )
     227        {
     228                block = paragraphs.shift() ;
     229                while ( block.parentNode != commonParent )
     230                        block = block.parentNode ;
     231                if ( block != lastBlock )
     232                        tmp.push( block ) ;
     233                lastBlock = block ;
     234        }
     235        paragraphs = tmp ;
     236
     237        // Split the paragraphs into groups depending on their BlockLimit element.
    208238        var groups = [] ;
    209239        var lastBlockLimit = null ;
    210         while ( ( block = iterator.GetNextParagraph() ) )
     240        for ( var i = 0 ; i < paragraphs.length ; i++ )
    211241        {
     242                block = paragraphs[i] ;
    212243                var elementPath = new FCKElementPath( block ) ;
    213244                if ( elementPath.BlockLimit != lastBlockLimit )
    214245                {
     
    218249                groups[groups.length - 1].push( block ) ;
    219250        }
    220251
     252        // Create a DIV container for each group.
    221253        for ( var i = 0 ; i < groups.length ; i++ )
    222254        {
    223255                var divNode = FCK.EditorDocument.createElement( 'div' ) ;
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy