Ticket #4945: 4945_2.patch

File 4945_2.patch, 2.9 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/pastefromword/filter/default.js

     
    226226                                                                                if ( !listBaseIndent && previousListItemMargin && margin > previousListItemMargin )
    227227                                                                                        listBaseIndent = margin - previousListItemMargin;
    228228
    229                                                                                 attrs[ 'cke:margin' ] = previousListItemMargin = margin;
     229                                                                                previousListItemMargin = margin;
     230                                                                                attrs[ 'cke:indent' ] = listBaseIndent && Math.ceil( margin / listBaseIndent ) || 1;
    230231                                                                        } ]
    231232                                                        ] )( attrs.style, element ) || '' ;
    232233                                        }
     
    323324                                        for ( var i = 0; i < children.length; i++ )
    324325                                        {
    325326                                                child = children[ i ];
    326                                                 var attributes = child.attributes;
    327327
    328328                                                if ( child.name in CKEDITOR.dtd.$listItem )
    329329                                                {
    330330                                                        var listItemChildren = child.children,
     331                                                                attributes = child.attributes,
    331332                                                                count = listItemChildren.length,
    332333                                                                last = listItemChildren[ count - 1 ];
    333334
     
    342343                                                                        children.splice( i, 1 );
    343344                                                        }
    344345
     346                                                        // #4945: list presentation might be mixed with <li> and <p>, also analysis the
     347                                                        // the 'tab-stops' to figure out base indent unit.
     348                                                        attributes.style = CKEDITOR.plugins.pastefromword.filters.stylesFilter(
     349                                                                [
     350                                                                        // Resolve indent level from 'tab-stops' value.
     351                                                                        [ ( /^tab-stops$/ ), null, function( margin )
     352                                                                        {
     353                                                                                // Be able to deal with component/short-hand form style.
     354                                                                                var values = margin.split( ' ' );
     355                                                                                margin = values[ 3 ] || values[ 1 ] || values [ 0 ];
     356                                                                                margin = parseInt( margin, 10 );
     357
     358                                                                                // Figure out the
     359                                                                                if ( !listBaseIndent && previousListItemMargin && margin > previousListItemMargin )
     360                                                                                        listBaseIndent = margin - previousListItemMargin;
     361
     362                                                                                previousListItemMargin = margin;
     363                                                                        } ]
     364                                                        ] )( attributes.style, element ) || '' ;
     365
    345366                                                        child.name = 'cke:li';
    346367                                                        attributes[ 'cke:indent' ] = indentLevel;
    347                                                         previousListItemMargin = 0;
    348368                                                        attributes[ 'cke:listtype' ] = element.name;
    349369                                                        listStyleType && child.addStyle( 'list-style-type', listStyleType, true );
    350370                                                }
     
    386406                                                        // List item indent level might come from a real list indentation or
    387407                                                        // been resolved from a pseudo list item's margin value, even get
    388408                                                        // no indentation at all.
    389                                                         listItemIndent = parseInt( listItemAttrs[ 'cke:indent' ], 10 )
    390                                                                                                         || listBaseIndent && ( Math.ceil( listItemAttrs[ 'cke:margin' ] / listBaseIndent ) )
    391                                                                                                         || 1;
     409                                                        listItemIndent = parseInt( listItemAttrs[ 'cke:indent' ], 10 );
    392410
    393411                                                        // Ignore the 'list-style-type' attribute if it's matched with
    394412                                                        // the list root element's default style type.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy