Ticket #3165: 3165_2.patch
File 3165_2.patch, 5.7 KB (added by , 15 years ago) |
---|
-
_source/plugins/enterkey/plugin.js
101 101 if ( !isStartOfBlock && !isEndOfBlock ) 102 102 { 103 103 // If the next block is an <li> with another list tree as the first 104 // child, we'll need to append a placeholderor the list item104 // child, we'll need to append a filler (<br>/NBSP) or the list item 105 105 // wouldn't be editable. (#1420) 106 if ( nextBlock.is( 'li' ) && ( node = nextBlock.getFirst() ) 107 && node.is && node.is( 'ul', 'ol') ) 108 nextBlock.insertBefore( doc.createText( '\xa0' ), node ); 106 if ( nextBlock.is( 'li' ) 107 && ( node = nextBlock.getFirst( CKEDITOR.dom.walker.invisible( true ) ) ) 108 && node.is && node.is( 'ul', 'ol' ) ) 109 ( CKEDITOR.env.ie ? doc.createText( '\xa0') : doc.createElement( 'br' ) ).insertBefore( node ); 109 110 110 111 // Move the selection to the end block. 111 112 if ( nextBlock ) -
_source/core/dom/element.js
627 627 628 628 /** 629 629 * Gets the first child node of this element. 630 * @param {Function} evaluator Filtering the result node. 630 631 * @returns {CKEDITOR.dom.node} The first child node or null if not 631 632 * available. 632 633 * @example … … 634 635 * var first = <b>element.getFirst()</b>; 635 636 * alert( first.getName() ); // "b" 636 637 */ 637 getFirst : function( )638 getFirst : function( evaluator ) 638 639 { 639 var $ = this.$.firstChild; 640 return $ ? new CKEDITOR.dom.node( $ ) : null; 640 var first = this.$.firstChild, 641 retval = first && new CKEDITOR.dom.node( first ); 642 if ( retval && evaluator && !evaluator( retval ) ) 643 retval = retval.getNext( evaluator ); 644 645 return retval; 641 646 }, 642 647 643 648 /** -
_source/core/dom/walker.js
408 408 return isReject ^ isWhitespace; 409 409 }; 410 410 }; 411 412 /** 413 * Whether the node is invisible in wysiwyg mode. 414 * @param isReject 415 */ 416 CKEDITOR.dom.walker.invisible = function( isReject ) 417 { 418 var whitespace = CKEDITOR.dom.walker.whitespaces(); 419 return function( node ) 420 { 421 // Nodes that take no spaces in wysiwyg: 422 // 1. White-spaces but not including NBSP; 423 // 2. Empty inline elements, e.g. <b></b> we're checking here 'offsetHeight' 424 // instead of width for properly excluding all sorts of empty paragraph, e.g. <br />. 425 var isInvisible = whitespace( node ) 426 || !node.$.offsetHeight; 427 return isReject ^ isInvisible; 428 }; 429 }; 430 411 431 })(); -
_source/plugins/htmldataprocessor/plugin.js
45 45 return !lastChild || lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'; 46 46 } 47 47 48 function extendNestedListForDisplay( list ) 49 { 50 var children = list.children, 51 firstChild = children && children[ 0 ], 52 secondChild = children && children[ 1 ]; 53 54 if( firstChild && 55 firstChild.type == CKEDITOR.NODE_TEXT 56 && tailNbspRegex.test( firstChild.value ) 57 && secondChild && secondChild.type == CKEDITOR.NODE_ELEMENT 58 && secondChild.name in CKEDITOR.dtd.$list ) 59 children[ 0 ] = new CKEDITOR.htmlParser.element( 'br', {} ); 60 } 61 48 62 function extendBlockForDisplay( block ) 49 63 { 50 64 trimFillers( block, true ); … … 66 80 block.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); 67 81 } 68 82 83 function extendNestedListForOutput( list ) 84 { 85 var children = list.children, 86 firstChild = children && children[ 0 ], 87 secondChild = children && children[ 1 ]; 88 89 if( firstChild && firstChild.type == CKEDITOR.NODE_ELEMENT 90 && firstChild.name == 'br' 91 && secondChild && secondChild.type == CKEDITOR.NODE_ELEMENT 92 && secondChild.name in CKEDITOR.dtd.$list ) 93 children[ 0 ] = new CKEDITOR.htmlParser.text( '\xa0' ); 94 } 95 69 96 var dtd = CKEDITOR.dtd; 70 97 71 98 // Find out the list of block-like tags that can contain <br>. … … 93 120 for ( i in blockLikeTags ) 94 121 defaultDataBlockFilterRules.elements[ i ] = extendBlockForDisplay; 95 122 123 var defaultListDataFilterRules = { elements : {} }; 124 if( !CKEDITOR.env.ie ) 125 { 126 for( i in dtd.$listItem ) 127 defaultListDataFilterRules.elements[ i ] = extendNestedListForDisplay; 128 } 129 96 130 var defaultHtmlFilterRules = 97 131 { 98 132 elementNames : … … 189 223 for ( i in blockLikeTags ) 190 224 defaultHtmlBlockFilterRules.elements[ i ] = extendBlockForOutput; 191 225 226 var defaultListHtmlFilterRules = { elements : {} }; 227 if( !CKEDITOR.env.ie ) 228 { 229 for( i in dtd.$listItem ) 230 defaultListHtmlFilterRules.elements[ i ] = extendNestedListForOutput; 231 } 232 192 233 if ( CKEDITOR.env.ie ) 193 234 { 194 235 // IE outputs style attribute in capital letters. We should convert … … 293 334 294 335 dataProcessor.dataFilter.addRules( defaultDataFilterRules ); 295 336 dataProcessor.dataFilter.addRules( defaultDataBlockFilterRules ); 337 dataProcessor.dataFilter.addRules( defaultListDataFilterRules ); 296 338 dataProcessor.htmlFilter.addRules( defaultHtmlFilterRules ); 297 339 dataProcessor.htmlFilter.addRules( defaultHtmlBlockFilterRules ); 340 dataProcessor.htmlFilter.addRules( defaultListHtmlFilterRules ); 298 341 } 299 342 }); 300 343