Ticket #7380: 7380.patch
File 7380.patch, 2.7 KB (added by , 13 years ago) |
---|
-
_source/plugins/list/plugin.js
633 633 }; 634 634 635 635 var dtd = CKEDITOR.dtd; 636 var tailNbspRegex = / [\t\r\n ]*(?: |\xa0)$/;636 var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/; 637 637 638 638 function indexOfFirstChildElement( element, tagNameList ) 639 639 { … … 653 653 654 654 function getExtendNestedListFilter( isHtmlFilter ) 655 655 { 656 // An element filter function that corrects nested list start in an empty 657 // list item for better displaying/outputting. (#3165) 656 function createFillerNode() 657 { 658 return ( isHtmlFilter || CKEDITOR.env.ie ) ? 659 new CKEDITOR.htmlParser.text( '\xa0' ) : 660 new CKEDITOR.htmlParser.element( 'br', {} ); 661 } 662 663 // Handle BRs before nested list element (pseudo list item). (#3165) (#7380) 658 664 return function( listItem ) 659 665 { 660 666 var children = listItem.children, 661 667 firstNestedListIndex = indexOfFirstChildElement( listItem, dtd.$list ), 662 668 firstNestedList = children[ firstNestedListIndex ], 663 669 nodeBefore = firstNestedList && firstNestedList.previous, 670 nodeIndex = firstNestedListIndex - 1, 664 671 tailNbspmatch; 665 672 666 if ( nodeBefore667 && ( nodeBefore.name && nodeBefore.name == 'br'668 || nodeBefore.value && ( tailNbspmatch = nodeBefore.value.match( tailNbspRegex ) ) ))673 // BR at the end of a pseudo block is required only if it's the first child 674 // or it's proceeded by other brs. 675 if ( nodeBefore && nodeBefore.name && nodeBefore.name == 'br' ) 669 676 { 670 677 var fillerNode = nodeBefore; 671 672 // Always use 'nbsp' as filler node if we found a nested list appear 673 // in front of a list item. 674 if ( !( tailNbspmatch && tailNbspmatch.index ) && fillerNode == children[ 0 ] ) 675 children[ 0 ] = ( isHtmlFilter || CKEDITOR.env.ie ) ? 676 new CKEDITOR.htmlParser.text( '\xa0' ) : 677 new CKEDITOR.htmlParser.element( 'br', {} ); 678 679 // Otherwise the filler is not needed anymore. 680 else if ( fillerNode.name == 'br' ) 681 children.splice( firstNestedListIndex - 1, 1 ); 678 nodeBefore = fillerNode.previous; 679 if ( !nodeBefore || nodeBefore.type == CKEDITOR.NODE_ELEMENT && nodeBefore.name == 'br' ) 680 children.splice( nodeIndex, 1, createFillerNode() ); 682 681 else 683 fillerNode.value = fillerNode.value.replace( tailNbspRegex, '');682 children.splice( nodeIndex, 1 ); 684 683 } 685 684 685 if ( nodeBefore && nodeBefore.type == CKEDITOR.NODE_TEXT && tailNbspRegex.test( nodeBefore.value ) ) 686 children.splice( nodeIndex, 1, createFillerNode() ); 686 687 }; 687 688 } 688 689