Changeset 4872
- Timestamp:
- 01/05/10 11:08:43 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/_source/plugins/pastefromword/filter/default.js
r4870 r4872 124 124 var emptyMarginRegex = /^(?:\b0[^\s]*\s*){1,4}$/; 125 125 126 var listBaseIndent; 126 var listBaseIndent = 0, 127 previousListItemMargin; 127 128 128 129 CKEDITOR.plugins.pastefromword = … … 218 219 [ 'line-height' ], 219 220 // Resolve indent level from 'margin-left' value. 220 [ ( /^margin(:?-left)?$/ ), null, function( value)221 [ ( /^margin(:?-left)?$/ ), null, function( margin ) 221 222 { 222 223 // 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;224 var values = margin.split( ' ' ); 225 margin = values[ 3 ] || values[ 1 ] || values [ 0 ]; 226 margin = parseInt( margin, 10 ); 227 228 // Figure out the indent unit by looking at the first increament. 229 if ( !listBaseIndent && previousListItemMargin && margin > previousListItemMargin ) 230 listBaseIndent = margin - previousListItemMargin; 231 232 attrs[ 'cke:margin' ] = previousListItemMargin = margin; 232 233 } ] 233 234 ] )( attrs.style, element ) || '' ; … … 242 243 return true; 243 244 } 244 // Indicate a list has ended.245 else246 listBaseIndent = 0;247 245 248 246 return false; … … 350 348 child.name = 'cke:li'; 351 349 attributes[ 'cke:indent' ] = indentLevel; 350 previousListItemMargin = 0; 352 351 attributes[ 'cke:listtype' ] = element.name; 353 352 listStyleType && child.addStyle( 'list-style-type', listStyleType, true ); … … 387 386 listItemAttrs = listItem.attributes; 388 387 listType = listItem.attributes[ 'cke:listtype' ]; 389 // The indent attribute might not present. 390 listItemIndent = parseInt( listItemAttrs[ 'cke:indent' ], 10 ) || 0; 388 389 // List item indent level might come from a real list indentation or 390 // been resolved from a pseudo list item's margin value, even get 391 // no indentation at all. 392 listItemIndent = parseInt( listItemAttrs[ 'cke:indent' ], 10 ) 393 || listBaseIndent && ( Math.ceil( listItemAttrs[ 'cke:margin' ] / listBaseIndent ) ) 394 || 1; 391 395 392 396 // Ignore the 'list-style-type' attribute if it's matched with … … 401 405 if ( !list ) 402 406 { 403 parentList =list = new CKEDITOR.htmlParser.element( listType );407 list = new CKEDITOR.htmlParser.element( listType ); 404 408 list.add( listItem ); 405 409 children[ i ] = list; … … 409 413 if ( listItemIndent > indent ) 410 414 { 411 parentList = list;412 415 list = new CKEDITOR.htmlParser.element( listType ); 413 416 list.add( listItem ); … … 416 419 else if ( listItemIndent < indent ) 417 420 { 418 list = parentList; 419 parentList = list.parent ? list.parent.parent : list; 421 // There might be a negative gap between two list levels. (#4944) 422 var diff = indent - listItemIndent, 423 parent = list.parent; 424 while( diff-- && parent ) 425 list = parent.parent; 426 420 427 list.add( listItem ); 421 428 } … … 432 439 list = null; 433 440 } 441 442 listBaseIndent = 0; 434 443 }, 435 444 … … 1131 1140 data = data.replace( /<span>/g, '' ); 1132 1141 1133 // Clean up certain stateful session variables.1134 listBaseIndent = 0;1135 1142 return data; 1136 1143 };
Note: See TracChangeset
for help on using the changeset viewer.
