Ticket #4883: 4883.patch
File 4883.patch, 3.2 KB (added by , 15 years ago) |
---|
-
_source/plugins/pastefromword/filter/default.js
258 258 }; 259 259 } )(), 260 260 261 // Providing a shorthand style then retrieve one or more style component values. 262 getStyleComponents : ( function() 263 { 264 var calculator = CKEDITOR.dom.element.createFromHtml( 265 '<div style="position:absolute;left:-9999px;top:-9999px;"></div>', 266 CKEDITOR.document ); 267 CKEDITOR.document.getBody().append( calculator ); 268 269 return function( name, styleValue, fetchList ) 270 { 271 calculator.setStyle( name, styleValue ); 272 var styles = {}, 273 count = fetchList.length; 274 for ( var i = 0; i < count; i++ ) 275 styles[ fetchList[ i ] ] = calculator.getStyle( fetchList[ i ] ); 276 277 return styles; 278 }; 279 } )(), 280 261 281 listDtdParents : CKEDITOR.dtd.parentOf( 'ol' ) 262 282 }, 263 283 … … 453 473 whitelist && ( newValue = newValue || value ); 454 474 455 475 if( typeof newValue == 'function' ) 456 newValue = newValue( value, element ); 476 newValue = newValue( value, element, name ); 477 478 // Return an couple indicate both name and value 479 // changed. 480 if( newValue && newValue.push ) 481 name = newValue[ 0 ], newValue = newValue[ 1 ]; 482 457 483 if( typeof newValue == 'string' ) 458 484 rules.push( [ name, newValue ] ); 459 485 return; … … 551 577 containsNothingButSpaces = this.utils.isContainingOnlySpaces, 552 578 resolveListItem = this.utils.resolveList, 553 579 convertToPx = this.utils.convertToPx, 580 getStyleComponents = this.utils.getStyleComponents, 554 581 listDtdParents = this.utils.listDtdParents, 555 582 removeFontStyles = config.pasteFromWordRemoveFontStyles !== false, 556 583 removeStyles = config.pasteFromWordRemoveStyles !== false; … … 887 914 // Provide a white-list of styles that we preserve, those should 888 915 // be the ones that could later be altered with editor tools. 889 916 [ 890 [ ( /^margin$|^margin-(?!bottom|top)/ ), null, function( value, element ) 917 // Preserve margin-left/right which used as default indent style in the editor. 918 [ ( /^margin$|^margin-(?!bottom|top)/ ), null, function( value, element, name ) 891 919 { 892 if( element.name in { p : 1, div : 1 } 893 && !emptyMarginRegex.test( value ) ) 894 return value; 920 if( element.name in { p : 1, div : 1 } ) 921 { 922 var indentStyleName = config.contentsLangDirection == 'ltr' ? 923 'margin-left' : 'margin-right'; 924 925 // Extract component value from 'margin' shorthand. 926 if ( name == 'margin' ) 927 { 928 value = getStyleComponents( name, value, 929 [ indentStyleName ] )[ indentStyleName ]; 930 } 931 else if ( name != indentStyleName ) 932 return; 933 934 if ( value && !emptyMarginRegex.test( value ) ) 935 return [ indentStyleName, value ]; 936 } 895 937 } ], 896 938 897 939 [ ( /^border.*|margin.*|vertical-align|float$/ ), null,