Ticket #5404: 5404_5.patch
File 5404_5.patch, 4.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/htmldataprocessor/plugin.js
38 38 } 39 39 } 40 40 41 function blockNeedsExtension( block, fromSource )41 function blockNeedsExtension( block, fromSource, extendEmptyBlock ) 42 42 { 43 if( !extendEmptyBlock || 44 typeof extendEmptyBlock == 'function' && ( extendEmptyBlock( block ) == false ) ) 45 return false; 46 43 47 // 1. For IE version >=8, empty blocks are displayed correctly themself in wysiwiyg; 44 48 // 2. For the rest, at least table cell and list item need no filler space. 45 49 // (#6248) … … 51 55 52 56 var lastChild = lastNoneSpaceChild( block ); 53 57 54 return !lastChild 55 ||lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'56 // Some of the controls in form needs extension too,57 // to move cursor at the end of the form. (#4791)58 || block.name == 'form' && lastChild.name == 'input';58 return !lastChild || lastChild && 59 ( lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br' 60 // Some of the controls in form needs extension too, 61 // to move cursor at the end of the form. (#4791) 62 || block.name == 'form' && lastChild.name == 'input' ); 59 63 } 60 64 61 function extendBlockForDisplay( block)65 function getBlockExtension( isOutput, emptyBlockFiller ) 62 66 { 63 trimFillers( block, true ); 67 return function( node ) 68 { 69 trimFillers( node, !isOutput ); 64 70 65 if ( blockNeedsExtension( block, true ) ) 66 { 67 if ( CKEDITOR.env.ie ) 68 block.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); 69 else 70 block.add( new CKEDITOR.htmlParser.element( 'br', {} ) ); 71 } 72 } 73 74 function extendBlockForOutput( block ) 75 { 76 trimFillers( block ); 77 78 if ( blockNeedsExtension( block ) ) 79 block.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); 71 if ( blockNeedsExtension( node, !isOutput, emptyBlockFiller ) ) 72 { 73 if ( isOutput || CKEDITOR.env.ie ) 74 node.add( new CKEDITOR.htmlParser.text( '\xa0' ) ); 75 else 76 node.add( new CKEDITOR.htmlParser.element( 'br', {} ) ); 77 } 78 } 80 79 } 81 80 82 81 var dtd = CKEDITOR.dtd; … … 105 104 var defaultDataBlockFilterRules = { elements : {} }; 106 105 107 106 for ( i in blockLikeTags ) 108 defaultDataBlockFilterRules.elements[ i ] = extendBlockForDisplay;107 defaultDataBlockFilterRules.elements[ i ] = getBlockExtension( false, true ); 109 108 110 109 var defaultHtmlFilterRules = 111 110 { … … 242 241 } 243 242 }; 244 243 245 var defaultHtmlBlockFilterRules = { elements : {} };246 247 for ( i in blockLikeTags )248 defaultHtmlBlockFilterRules.elements[ i ] = extendBlockForOutput;249 250 244 if ( CKEDITOR.env.ie ) 251 245 { 252 246 // IE outputs style attribute in capital letters. We should convert … … 412 406 dataProcessor.dataFilter.addRules( defaultDataFilterRules ); 413 407 dataProcessor.dataFilter.addRules( defaultDataBlockFilterRules ); 414 408 dataProcessor.htmlFilter.addRules( defaultHtmlFilterRules ); 409 410 var defaultHtmlBlockFilterRules = { elements : {} }; 411 for ( i in blockLikeTags ) 412 defaultHtmlBlockFilterRules.elements[ i ] = getBlockExtension( true, editor.config.fillEmptyBlocks ); 413 415 414 dataProcessor.htmlFilter.addRules( defaultHtmlBlockFilterRules ); 415 }, 416 417 onLoad : function() 418 { 419 ! ( 'fillEmptyBlocks' in CKEDITOR.config ) && ( CKEDITOR.config.fillEmptyBlocks = 1 ); 416 420 } 417 421 }); 418 422 … … 510 514 * @example 511 515 * config.forceSimpleAmpersand = false; 512 516 */ 517 518 /** 519 * Whether a filler text (non-breaking space entity - ) will be inserted into empty block elements in HTML output, 520 * this is used to render block elements properly with line-height; When a function is instead specified, 521 * it'll be passed a {@link CKEDITOR.htmlParser.element} to decide whether adding the filler text 522 * by expecting a boolean return value. 523 * @name CKEDITOR.config.fillEmptyBlocks; 524 * @type Boolean|Function 525 * @default true 526 * @example 527 * config.fillEmptyBlocks = false; // Prevent filler nodes in all empty blocks. 528 * 529 * // Prevent filler node only in float cleaners. 530 * config.fillEmptyBlocks = function( element ) 531 * { 532 * if ( element.attributes[ 'class' ].indexOf ( 'clear-both' ) != -1 ) 533 * return false; 534 * } 535 */ 536