Ticket #7839: 7839.patch
File 7839.patch, 5.5 KB (added by , 14 years ago) |
---|
-
_source/plugins/pastefromword/filter/default.js
279 279 var listId = Number( val[ 0 ].match( /\d+/ ) ), 280 280 indent = Number( val[ 1 ].match( /\d+/ ) ); 281 281 282 listId !== previousListId && ( attrs[ 'cke:reset' ] = 1 ); 283 previousListId = listId; 282 if ( indent == 1 ) 283 { 284 listId !== previousListId && ( attrs[ 'cke:reset' ] = 1 ); 285 previousListId = listId; 286 } 284 287 attrs[ 'cke:indent' ] = indent; 285 288 } ] 286 289 ] )( attrs.style, element ) || ''; … … 357 360 // E.g. <ul><li>level1<ol><li>level2</li></ol></li> => 358 361 // <cke:li cke:listtype="ul" cke:indent="1">level1</cke:li> 359 362 // <cke:li cke:listtype="ol" cke:indent="2">level2</cke:li> 360 flattenList : function( element )363 flattenList : function( element, level ) 361 364 { 365 level = typeof level == 'number' ? level : 1; 366 362 367 var attrs = element.attributes, 363 parent = element.parent;368 listStyleType; 364 369 365 var listStyleType,366 indentLevel = 1;367 368 // Resolve how many level nested.369 while ( parent )370 {371 parent.attributes && parent.attributes[ 'cke:list' ] && indentLevel++;372 parent = parent.parent;373 }374 375 370 // All list items are of the same type. 376 371 switch ( attrs.type ) 377 372 { 378 373 case 'a' : 379 374 listStyleType = 'lower-alpha'; 380 375 break; 376 case '1' : 377 listStyleType = 'decimal'; 378 break; 381 379 // TODO: Support more list style type from MS-Word. 382 380 } 383 381 384 382 var children = element.children, 385 child; 383 child, 384 index; 386 385 387 386 for ( var i = 0; i < children.length; i++ ) 388 387 { 389 388 child = children[ i ]; 390 var attributes = child.attributes; 389 if ( child.name == 'li' ) 390 { 391 var attributes = child.attributes; 391 392 392 if ( child.name in CKEDITOR.dtd.$listItem )393 {394 var listItemChildren = child.children,395 count = listItemChildren.length,396 last = listItemChildren[ count - 1 ];393 if ( child.name in CKEDITOR.dtd.$listItem ) 394 { 395 var listItemChildren = child.children, 396 count = listItemChildren.length, 397 last = listItemChildren[ count - 1 ]; 397 398 398 // Move out nested list.399 if ( last.name in CKEDITOR.dtd.$list )400 {401 children.splice( i + 1, 0, last );402 last.parent = element;399 // Move out nested list. 400 if ( last.name in CKEDITOR.dtd.$list ) 401 { 402 children.splice( i + 1, 0, last ); 403 last.parent = element; 403 404 404 // Remove the parent list item if it's just a holder. 405 if ( !--listItemChildren.length ) 406 children.splice( i, 1 ); 407 } 405 // Remove the parent list item if it's just a holder. 406 if ( !--listItemChildren.length ) 407 children.splice( i, 1 ); 408 409 // Flatten sub list. 410 arguments.callee.apply( this, [ last, level + 1 ] ); 411 var index = children.indexOf( last ); 412 // Absorb sub list children. 413 children = children.splice( 0, index ).concat( last.children ).concat( children.splice( index + 1 ) ); 414 element.children = children; 415 } 408 416 409 child.name = 'cke:li';417 child.name = 'cke:li'; 410 418 411 // Inherit numbering from list root on the first list item.412 attrs.start && !i && ( attributes.value = attrs.start );419 // Inherit numbering from list root on the first list item. 420 attrs.start && !i && ( attributes.value = attrs.start ); 413 421 414 plugin.filters.stylesFilter(415 [416 417 {418 var margin = val.split( ' ' )[ 1 ].match( cssLengthRelativeUnit );419 margin && ( previousListItemMargin = parseInt( plugin.utils.convertToPx( margin[ 0 ] ), 10 ) );420 } ],421 [ 'mso-list', null, function( val )422 {423 val = val.split( ' ' );424 var listId = Number( val[ 0 ].match( /\d+/ ) );425 listId !== previousListId && ( attributes[ 'cke:reset' ] = 1 );426 previousListId = listId;427 } ]428 ] )( attributes.style );422 plugin.filters.stylesFilter( 423 [ 424 [ 'tab-stops', null, function( val ) 425 { 426 var margin = val.split( ' ' )[ 1 ].match( cssLengthRelativeUnit ); 427 margin && ( previousListItemMargin = parseInt( plugin.utils.convertToPx( margin[ 0 ] ), 10 ) ); 428 } ], 429 ( level == 1 ? [ 'mso-list', null, function( val ) 430 { 431 val = val.split( ' ' ); 432 var listId = Number( val[ 0 ].match( /\d+/ ) ); 433 listId !== previousListId && ( attributes[ 'cke:reset' ] = 1 ); 434 previousListId = listId; 435 } ] : null ) 436 ] )( attributes.style ); 429 437 430 attributes[ 'cke:indent' ] = indentLevel; 431 attributes[ 'cke:listtype' ] = element.name; 432 attributes[ 'cke:list-style-type' ] = listStyleType; 433 } 434 } 438 attributes[ 'cke:indent' ] = level; 439 attributes[ 'cke:listtype' ] = element.name; 440 attributes[ 'cke:list-style-type' ] = listStyleType; 441 } 442 } 443 } 435 444 436 445 delete element.name; 437 446