Ticket #7907: 7907_2.patch

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

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    161161                        {
    162162                                iterator = ranges[ i ].createIterator();
    163163                                iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
     164                                iterator.enforceRealBlocks = 1;
    164165
    165166                                while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
    166167                                {
  • _source/plugins/list/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    102102                                indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ),
    103103                                currentListItem = null,
    104104                                orgDir,
     105                                newBlock,
    105106                                paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' );
    106107                        while ( 1 )
    107108                        {
     
    146147                                        if ( listNodeNames[ item.grandparent.getName() ] )
    147148                                                currentListItem = item.element.clone( false, true );
    148149                                        else
     150                                                currentListItem = new CKEDITOR.dom.documentFragment( doc );
     151
     152                                        // Migrate all children to the new container,
     153                                        // apply the proper text direction.
     154                                        var 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 )
     
    190198                                                }
    191199                                        }
    192200
    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;
    204                                                 }
    205                                         }
    206 
    207201                                        var currentListItemName = currentListItem.$.nodeName.toLowerCase();
    208202                                        if ( !CKEDITOR.env.ie && ( currentListItemName == 'div' || currentListItemName == 'p' ) )
    209203                                                currentListItem.appendBogus();
     
    214208                                else
    215209                                        return null;
    216210
     211                                newBlock = null;
     212
     213
    217214                                if ( listArray.length <= currentIndex || Math.max( listArray[ currentIndex ].indent, 0 ) < indentLevel )
    218215                                        break;
    219216                        }
     
    378375
    379376                listsCreated.push( listNode );
    380377
    381                 var contentBlock, listItem;
     378                var contentBlock, blockDir, listItem;
    382379
    383380                while ( listContents.length )
    384381                {
    385382                        contentBlock = listContents.shift();
    386383                        listItem = doc.createElement( 'li' );
    387384
    388                         // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
    389                         if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
     385                        // Take it off the tree to void bothering
     386                        // the direction change event.
     387                        contentBlock.remove();
     388
     389                        if ( blockDir = contentBlock.getDirection() )
     390                        {
     391                                contentBlock.removeStyle( 'direction' );
     392                                contentBlock.removeAttribute( 'dir' );
     393                        }
     394
     395                        // Preserve the block when converting to list item if:
     396                        // 1. In preformat; (#5335)
     397                        // 2. In heading structure; (#5271)
     398                        // 3. Styled or attributed. (#6461)
     399                        if ( contentBlock.is( 'pre' )
     400                                 || headerTagRegex.test( contentBlock.getName() )
     401                                 || contentBlock.hasAttributes() )
    390402                                contentBlock.appendTo( listItem );
    391403                        else
    392404                        {
    393                                 contentBlock.copyAttributes( listItem );
    394                                 // Remove direction attribute after it was merged into list root. (#7657)
    395                                 if ( listDir && contentBlock.getDirection() )
    396                                 {
    397                                         listItem.removeStyle( 'direction' );
    398                                         listItem.removeAttribute( 'dir' );
    399                                 }
    400405                                contentBlock.moveChildren( listItem );
    401406                                contentBlock.remove();
    402407                        }
     408
     409                        // Apply text direction on list item unless it's already applied on root. (#7657)
     410                        if ( blockDir && !listDir )
     411                                listItem.setAttribute( 'dir', blockDir );
    403412
    404413                        listItem.appendTo( listNode );
    405414                }
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy