Ticket #6662: 6662_3.patch

File 6662_3.patch, 5.1 KB (added by Tobiasz Cudnik, 13 years ago)
  • _source/plugins/pastefromword/filter/default.js

     
    184184                        isListBulletIndicator : function( element )
    185185                        {
    186186                                var styleText = element.attributes && element.attributes.style;
    187                                 if ( /mso-list\s*:\s*Ignore/i.test( styleText ) )
     187                                if ( !CKEDITOR.env.gecko && /mso-list\s*:\s*Ignore/i.test( styleText ) )
    188188                                        return true;
     189                                // Search for following structure in Gecko `P.class > SPAN > SPAN > SPAN`.
     190                                // class="MsoListParagraph"
     191                                else if ( CKEDITOR.env.gecko && element.parent.attributes &&
     192                                        /\b((?:Mso)?ListParagraph(CxSp\w+)?|Normal\b)/i.test( element.parent.attributes[ 'class' ] ) &&
     193                                        element.children && element.children.length == 1 && element.children[ 0 ].name == 'span' &&
     194                                        element.children[ 0 ].children && element.children[ 0 ].children.length == 1 &&
     195                                        element.children[ 0 ].children[ 0 ].type == 3
     196                                )
     197                                        return true;
    189198                        },
    190199
    191200                        isContainingOnlySpaces : function( element )
     
    214223                                                                        // Text-indent is not representing list item level any more.
    215224                                                                        [ 'text-indent' ],
    216225                                                                        [ 'line-height' ],
     226
     227                                                                        [ 'list-style-type' ],
    217228                                                                        // Resolve indent level from 'margin-left' value.
    218229                                                                        [ ( /^margin(:?-left)?$/ ), null, function( margin )
    219230                                                                        {
     
    370381                                                        listItemIndent, // Indent level of current list item.
    371382                                                        lastListItem, // The previous one just been added to the list.
    372383                                                        list, parentList, // Current staging list and it's parent list if any.
    373                                                         indent;
     384                                                        indent, diff;
    374385
    375386                                        for ( var i = 0; i < children.length; i++ )
    376387                                        {
     
    399410                                                                        ] )( listItemAttrs.style )
    400411                                                                        || '' );
    401412
    402                                                         if ( !list )
     413                                                        if ( !list || ( list && list.name != listType ) )
    403414                                                        {
    404415                                                                list = new CKEDITOR.htmlParser.element( listType );
    405416                                                                list.add( listItem );
     417                                                                list._indent = listItemIndent;
    406418                                                                children[ i ] = list;
     419                                                               
     420                                                                if ( listItemIndent > indent )
     421                                                                        lastListItem.add( list );
    407422                                                        }
    408423                                                        else
    409424                                                        {
    410425                                                                if ( listItemIndent > indent )
    411426                                                                {
    412                                                                         list = new CKEDITOR.htmlParser.element( listType );
    413                                                                         list.add( listItem );
    414                                                                         lastListItem.add( list );
    415                                                                 }
     427                                                                        diff = listItemIndent - indent;
     428
     429                                                                        while ( diff-- )
     430                                                                        {
     431                                                                                list = new CKEDITOR.htmlParser.element( listType );
     432                                                                                lastListItem.add( list );
     433                                                                                list._indent = listItemIndent - diff;
     434                                                                               
     435                                                                                if ( diff > 0 )
     436                                                                                {
     437                                                                                        list.add( new CKEDITOR.htmlParser.element( 'li' ) );
     438                                                                                        lastListItem = list.children[ 0 ];
     439                                                                                }
     440                                                                                else
     441                                                                                        list.add( listItem );
     442                                                                        }
     443                                                                }
     444                                                                // TODO support a list type change here
    416445                                                                else if ( listItemIndent < indent )
    417446                                                                {
    418447                                                                        // There might be a negative gap between two list levels. (#4944)
    419                                                                         var diff = indent - listItemIndent,
    420                                                                                 parent;
    421                                                                         while ( diff-- && ( parent = list.parent ) )
    422                                                                                 list = parent.parent;
     448                                                                        parentList = list.parent && list.parent.parent,
     449                                                                                diff = ( parentList && listItemIndent == parentList._indent ) ? 1 : indent - listItemIndent;
    423450
     451                                                                        while ( diff-- && list.parent && ( parentList = list.parent.parent ) )
     452                                                                        {
     453                                                                                list = parentList;
     454                                                                        }
     455
    424456                                                                        list.add( listItem );
    425457                                                                }
    426458                                                                else
     
    867899
    868900                                                // For IE/Safari: List item bullet type is supposed to be indicated by
    869901                                                // the text of a span with style 'mso-list : Ignore' or an image.
    870                                                 if ( !CKEDITOR.env.gecko && isListBulletIndicator( element ) )
     902                                                // For Gecko, list bullet is a child of `p.ListParagraphCxSp*` element.
     903                                                if ( ( !CKEDITOR.env.gecko && isListBulletIndicator( element ) ) ||
     904                                                        ( CKEDITOR.env.gecko && isListBulletIndicator( element ) ) )
    871905                                                {
    872                                                         var listSymbolNode = element.firstChild( function( node )
    873                                                         {
    874                                                                 return node.value || node.name == 'img';
    875                                                         });
    876 
    877                                                         var listSymbol =  listSymbolNode && ( listSymbolNode.value || 'l.' ),
    878                                                                 listType = listSymbol.match( /^([^\s]+?)([.)]?)$/ );
     906                                                        var listSymbol, listType;
     907                                                        if ( CKEDITOR.env.gecko )
     908                                                        {
     909                                                                listType = element.children[ 0 ].children[ 0 ].value;
     910                                                                listType = /^(?:&nbsp;[ \n]?)*([\w\u00B7]*)(\.?)/.exec( listType );
     911                                                        }
     912                                                        else
     913                                                        {
     914                                                                var listSymbolNode = element.firstChild( function( node )
     915                                                                {
     916                                                                        return node.value || node.name == 'img';
     917                                                                });
     918                                                               
     919                                                                listSymbol =  listSymbolNode && ( listSymbolNode.value || 'l.' ),
     920                                                                        listType = listSymbol.match( /^([^\s]+?)([.)]?)$/ );
     921                                                        }
    879922                                                        return createListBulletMarker( listType, listSymbol );
    880923                                                }
    881924
     
    9711014                                                // Preserve clear float style.
    9721015                                                [ ( /^clear$/ ) ],
    9731016
     1017                                                [ ( /^list-style-type/ ) ],
     1018
    9741019                                                [ ( /^border.*|margin.*|vertical-align|float$/ ), null,
    9751020                                                        function( value, element )
    9761021                                                        {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy