Ticket #4896: 4896.patch

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

     
    123123        var cssLengthRelativeUnit = /^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i;
    124124        var emptyMarginRegex = /^(?:\b0[^\s]*\s*){1,4}$/;
    125125
     126        var listBaseIndent;
     127
    126128        CKEDITOR.plugins.pastefromword =
    127129        {
    128130                utils :
     
    210212                                        if ( attrs.style )
    211213                                        {
    212214                                                attrs.style = CKEDITOR.plugins.pastefromword.filters.stylesFilter(
    213                                                         [
    214                                                                 // Text-indent is not representing list item level any more.
    215                                                                 [ 'text-indent' ],
    216                                                                 [ 'line-height' ],
    217                                                                 // Resolve indent level from 'margin-left' value.
    218                                                                 [ ( /^margin(:?-left)?$/ ), null, function( value )
    219                                                                 {
    220                                                                         // Be able to deal with component/short-hand form style.
    221                                                                         var values = value.split( ' ' );
    222                                                                         value = values[ 3 ] || values[ 1 ] || values [ 0 ];
    223                                                                         attrs[ 'cke:indent' ] =
    224                                                                                 // Indent margin unit by 36pt.
    225                                                                                 Math.floor( parseInt( value, 10 ) / 36 );
    226                                                                 } ]
     215                                                                [
     216                                                                        // Text-indent is not representing list item level any more.
     217                                                                        [ 'text-indent' ],
     218                                                                        [ 'line-height' ],
     219                                                                        // Resolve indent level from 'margin-left' value.
     220                                                                        [ ( /^margin(:?-left)?$/ ), null, function( value )
     221                                                                        {
     222                                                                                // Be able to deal with component/short-hand form style.
     223                                                                                var values = value.split( ' ' );
     224                                                                                value = values[ 3 ] || values[ 1 ] || values [ 0 ];
     225                                                                                value = parseInt( value, 10 );
     226
     227                                                                                // Figure out the indent unit by looking at the first list item.
     228                                                                                !listBaseIndent && ( listBaseIndent = value );
     229
     230                                                                                // Indent level start with one.
     231                                                                                attrs[ 'cke:indent' ] = Math.floor( value / listBaseIndent ) + 1;
     232                                                                        } ]
    227233                                                        ] )( attrs.style, element ) || '' ;
    228234                                        }
    229235
     
    235241                                        CKEDITOR.tools.extend( attrs, listBulletAttrs );
    236242                                        return true;
    237243                                }
     244                                // Indicate a list has ended.
     245                                else
     246                                        listBaseIndent = 0;
    238247                        },
    239248
    240249                        // Convert various length units to 'px' in ignorance of DPI.
     
    10951104                // Remove the dummy spans ( having no inline style ).
    10961105                data = data.replace( /<span>/g, '' );
    10971106
     1107                // Clean up certain stateful session variables.
     1108                listBaseIndent = 0;
    10981109                return data;
    10991110        };
    11001111})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy