Ticket #6662: 6662_2.patch
File 6662_2.patch, 5.1 KB (added by , 15 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 else if ( CKEDITOR.env.gecko && element.parent.attributes && 191 /\b(ListParagraph(CxSp\w+)?|MsoNormal\b)/i.test( element.parent.attributes[ 'class' ] ) && 192 element.children && element.children.length == 1 && element.children[ 0 ].name == 'span' && 193 element.children[ 0 ].children && element.children[ 0 ].children.length == 1 && 194 element.children[ 0 ].children[ 0 ].type == 3 195 ) 196 return true; 189 197 }, 190 198 191 199 isContainingOnlySpaces : function( element ) … … 214 222 // Text-indent is not representing list item level any more. 215 223 [ 'text-indent' ], 216 224 [ 'line-height' ], 225 226 [ 'list-style-type' ], 217 227 // Resolve indent level from 'margin-left' value. 218 228 [ ( /^margin(:?-left)?$/ ), null, function( margin ) 219 229 { … … 370 380 listItemIndent, // Indent level of current list item. 371 381 lastListItem, // The previous one just been added to the list. 372 382 list, parentList, // Current staging list and it's parent list if any. 373 indent ;383 indent, diff; 374 384 375 385 for ( var i = 0; i < children.length; i++ ) 376 386 { … … 399 409 ] )( listItemAttrs.style ) 400 410 || '' ); 401 411 402 if ( !list )412 if ( !list || ( list && list.name != listType ) ) 403 413 { 404 414 list = new CKEDITOR.htmlParser.element( listType ); 405 415 list.add( listItem ); 416 list._indent = listItemIndent; 406 417 children[ i ] = list; 418 419 if ( listItemIndent > indent ) 420 lastListItem.add( list ); 407 421 } 408 422 else 409 423 { 410 424 if ( listItemIndent > indent ) 411 425 { 412 list = new CKEDITOR.htmlParser.element( listType ); 413 list.add( listItem ); 414 lastListItem.add( list ); 415 } 426 diff = listItemIndent - indent; 427 428 while ( diff-- ) 429 { 430 list = new CKEDITOR.htmlParser.element( listType ); 431 lastListItem.add( list ); 432 list._indent = listItemIndent - diff; 433 434 if ( diff > 0 ) 435 { 436 list.add( new CKEDITOR.htmlParser.element( 'li' ) ); 437 lastListItem = list.children[ 0 ]; 438 } 439 else 440 list.add( listItem ); 441 } 442 } 443 // TODO support a list type change here 416 444 else if ( listItemIndent < indent ) 417 445 { 418 446 // 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; 447 parentList = list.parent && list.parent.parent, 448 diff = ( parentList && listItemIndent == parentList._indent ) ? 1 : indent - listItemIndent; 423 449 450 while ( diff-- && list.parent && ( parentList = list.parent.parent ) ) 451 { 452 list = parentList; 453 } 454 424 455 list.add( listItem ); 425 456 } 426 457 else … … 867 898 868 899 // For IE/Safari: List item bullet type is supposed to be indicated by 869 900 // the text of a span with style 'mso-list : Ignore' or an image. 870 if ( !CKEDITOR.env.gecko && isListBulletIndicator( element ) ) 901 // For Gecko, list bullet is a child of `p.ListParagraphCxSp*` element. 902 if ( ( !CKEDITOR.env.gecko && isListBulletIndicator( element ) ) || 903 ( CKEDITOR.env.gecko && isListBulletIndicator( element ) ) ) 871 904 { 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]+?)([.)]?)$/ ); 905 var listSymbol, listType; 906 if ( CKEDITOR.env.gecko ) 907 { 908 listType = element.children[ 0 ].children[ 0 ].value; 909 listType = /^(?: [ \n]?)*([\w\u00B7]*)(\.?)/.exec( listType ); 910 } 911 else 912 { 913 var listSymbolNode = element.firstChild( function( node ) 914 { 915 return node.value || node.name == 'img'; 916 }); 917 918 listSymbol = listSymbolNode && ( listSymbolNode.value || 'l.' ), 919 listType = listSymbol.match( /^([^\s]+?)([.)]?)$/ ); 920 } 879 921 return createListBulletMarker( listType, listSymbol ); 880 922 } 881 923 … … 971 1013 // Preserve clear float style. 972 1014 [ ( /^clear$/ ) ], 973 1015 1016 [ ( /^list-style-type/ ) ], 1017 974 1018 [ ( /^border.*|margin.*|vertical-align|float$/ ), null, 975 1019 function( value, element ) 976 1020 {