Ticket #7907: 7907.patch

File 7907.patch, 3.3 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/list/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    146146                                        if ( listNodeNames[ item.grandparent.getName() ] )
    147147                                                currentListItem = item.element.clone( false, true );
    148148                                        else
     149                                                currentListItem = new CKEDITOR.dom.documentFragment( doc );
     150
     151                                        // Migrate all children to the new container,
     152                                        // apply the proper text direction.
     153                                        var newBlock,
     154                                                dirLoose = item.grandparent.getDirection( 1 ) != orgDir,
     155                                                enterBr = paragraphMode == CKEDITOR.ENTER_BR;
     156
     157                                        for ( var i = 0, child, count = item.contents.length; i < count; i++ )
    149158                                        {
    150                                                 // Create completely new blocks here.
    151                                                 if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR )
     159                                                child = item.contents[ i ];
     160                                                if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() )
    152161                                                {
    153                                                         currentListItem = doc.createElement( paragraphName );
    154                                                         item.element.copyAttributes( currentListItem, { type:1, value:1 } );
     162                                                        // Apply direction on content blocks.
     163                                                        if ( dirLoose && !child.getDirection() )
     164                                                                child.setAttribute( 'dir', orgDir );
    155165
    156                                                         // There might be a case where there are no attributes in the element after all
    157                                                         // (i.e. when "type" or "value" are the only attributes set). In this case, if enterMode = BR,
    158                                                         // the current item should be a fragment.
    159                                                         if ( !dir && paragraphMode == CKEDITOR.ENTER_BR && !currentListItem.hasAttributes() )
    160                                                                 currentListItem = new CKEDITOR.dom.documentFragment( doc );
     166                                                        newBlock = null;
    161167                                                }
    162                                                 else
    163                                                         currentListItem = new CKEDITOR.dom.documentFragment( doc );
    164                                         }
     168                                                else if ( dirLoose || !enterBr )
     169                                                {
     170                                                        // Wrap inline contents with new block, just to remain item direction.
     171                                                        if ( !newBlock )
     172                                                        {
     173                                                                newBlock = doc.createElement( paragraphName );
     174                                                                dirLoose && newBlock.setAttribute( 'dir', orgDir );
     175                                                        }
    165176
    166                                         if ( currentListItem.type == CKEDITOR.NODE_ELEMENT )
    167                                         {
    168                                                 if ( item.grandparent.getDirection( 1 ) != orgDir )
    169                                                         currentListItem.setAttribute( 'dir', orgDir );
    170                                         }
     177                                                        newBlock.append( child.clone( 1, 1 ) );
     178                                                }
    171179
    172                                         for ( i = 0 ; i < item.contents.length ; i++ )
    173                                                 currentListItem.append( item.contents[i].clone( 1, 1 ) );
     180                                                currentListItem.append( newBlock || child.clone( 1, 1 ) );
     181                                        }
    174182
    175183                                        if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT
    176184                                                 && currentIndex != listArray.length - 1 )
     
    187195                                                        && last.getName() in CKEDITOR.dtd.$block ) )
    188196                                                {
    189197                                                        currentListItem.append( doc.createElement( 'br' ) );
    190                                                 }
    191                                         }
    192 
    193                                         if ( currentListItem.type == CKEDITOR.NODE_ELEMENT &&
    194                                                         currentListItem.getName() == paragraphName &&
    195                                                         currentListItem.$.firstChild )
    196                                         {
    197                                                 currentListItem.trim();
    198                                                 var firstChild = currentListItem.getFirst();
    199                                                 if ( firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.isBlockBoundary() )
    200                                                 {
    201                                                         var tmp = new CKEDITOR.dom.documentFragment( doc );
    202                                                         currentListItem.moveChildren( tmp );
    203                                                         currentListItem = tmp;
    204198                                                }
    205199                                        }
    206200
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy