Ticket #6662: 6662_3.patch
File 6662_3.patch, 5.1 KB (added by , 13 years ago) |
---|
-
_source/plugins/pastefromword/filter/default.js
184 184 isListBulletIndicator : function( element ) 185 185 { 186 186 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 ) ) 188 188 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; 189 198 }, 190 199 191 200 isContainingOnlySpaces : function( element ) … … 214 223 // Text-indent is not representing list item level any more. 215 224 [ 'text-indent' ], 216 225 [ 'line-height' ], 226 227 [ 'list-style-type' ], 217 228 // Resolve indent level from 'margin-left' value. 218 229 [ ( /^margin(:?-left)?$/ ), null, function( margin ) 219 230 { … … 370 381 listItemIndent, // Indent level of current list item. 371 382 lastListItem, // The previous one just been added to the list. 372 383 list, parentList, // Current staging list and it's parent list if any. 373 indent ;384 indent, diff; 374 385 375 386 for ( var i = 0; i < children.length; i++ ) 376 387 { … … 399 410 ] )( listItemAttrs.style ) 400 411 || '' ); 401 412 402 if ( !list )413 if ( !list || ( list && list.name != listType ) ) 403 414 { 404 415 list = new CKEDITOR.htmlParser.element( listType ); 405 416 list.add( listItem ); 417 list._indent = listItemIndent; 406 418 children[ i ] = list; 419 420 if ( listItemIndent > indent ) 421 lastListItem.add( list ); 407 422 } 408 423 else 409 424 { 410 425 if ( listItemIndent > indent ) 411 426 { 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 416 445 else if ( listItemIndent < indent ) 417 446 { 418 447 // 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; 423 450 451 while ( diff-- && list.parent && ( parentList = list.parent.parent ) ) 452 { 453 list = parentList; 454 } 455 424 456 list.add( listItem ); 425 457 } 426 458 else … … 867 899 868 900 // For IE/Safari: List item bullet type is supposed to be indicated by 869 901 // 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 ) ) ) 871 905 { 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 = /^(?: [ \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 } 879 922 return createListBulletMarker( listType, listSymbol ); 880 923 } 881 924 … … 971 1014 // Preserve clear float style. 972 1015 [ ( /^clear$/ ) ], 973 1016 1017 [ ( /^list-style-type/ ) ], 1018 974 1019 [ ( /^border.*|margin.*|vertical-align|float$/ ), null, 975 1020 function( value, element ) 976 1021 {