Ticket #5404: 5404_2.patch

File 5404_2.patch, 3.7 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/htmldataprocessor/plugin.js

     
    3838                }
    3939        }
    4040
    41         function blockNeedsExtension( block )
     41        function blockNeedsExtension( block, extendEmptyBlock )
    4242        {
    4343                var lastChild = lastNoneSpaceChild( block );
    4444
    45                 return !lastChild
    46                         || lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'
    47                         // Some of the controls in form needs extension too,
    48                         // to move cursor at the end of the form. (#4791)
    49                         || block.name == 'form' && lastChild.name == 'input';
     45                if( !extendEmptyBlock ||
     46                        typeof extendEmptyBlock == 'function' && ( extendEmptyBlock( block ) == false ) )
     47                        return false;
     48
     49                return !lastChild || lastChild &&
     50                                ( lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'
     51                                // Some of the controls in form needs extension too,
     52                                // to move cursor at the end of the form. (#4791)
     53                                || block.name == 'form' && lastChild.name == 'input' );
    5054        }
    5155
    52         function extendBlockForDisplay( block )
     56        function getBlockExtension( isOutput, emptyBlockFiller )
    5357        {
    54                 trimFillers( block, true );
    55 
    56                 if ( blockNeedsExtension( block ) )
     58                return function( node )
    5759                {
    58                         if ( CKEDITOR.env.ie )
    59                                 block.add( new CKEDITOR.htmlParser.text( '\xa0' ) );
    60                         else
    61                                 block.add( new CKEDITOR.htmlParser.element( 'br', {} ) );
    62                 }
    63         }
    64 
    65         function extendBlockForOutput( block )
    66         {
    67                 trimFillers( block );
    68 
    69                 if ( blockNeedsExtension( block ) )
    70                         block.add( new CKEDITOR.htmlParser.text( '\xa0' ) );
     60                        trimFillers( node, !isOutput );
     61                        if ( blockNeedsExtension( node, !isOutput || emptyBlockFiller ) )
     62                        {
     63                                if ( isOutput || CKEDITOR.env.ie )
     64                                        node.add( new CKEDITOR.htmlParser.text( '\xa0' ) );
     65                                else
     66                                        node.add( new CKEDITOR.htmlParser.element( 'br', {} ) );
     67                        }
     68                }
    7169        }
    7270
    7371        var dtd = CKEDITOR.dtd;
     
    9694        var defaultDataBlockFilterRules = { elements : {} };
    9795
    9896        for ( i in blockLikeTags )
    99                 defaultDataBlockFilterRules.elements[ i ] = extendBlockForDisplay;
     97                defaultDataBlockFilterRules.elements[ i ] = getBlockExtension();
    10098
    10199        var defaultHtmlFilterRules =
    102100                {
     
    233231                        }
    234232                };
    235233
    236         var defaultHtmlBlockFilterRules = { elements : {} };
    237 
    238         for ( i in blockLikeTags )
    239                 defaultHtmlBlockFilterRules.elements[ i ] = extendBlockForOutput;
    240 
    241234        if ( CKEDITOR.env.ie )
    242235        {
    243236                // IE outputs style attribute in capital letters. We should convert
     
    398391                        dataProcessor.dataFilter.addRules( defaultDataFilterRules );
    399392                        dataProcessor.dataFilter.addRules( defaultDataBlockFilterRules );
    400393                        dataProcessor.htmlFilter.addRules( defaultHtmlFilterRules );
     394
     395                        var defaultHtmlBlockFilterRules = { elements : {} };
     396                        for ( i in blockLikeTags )
     397                                defaultHtmlBlockFilterRules.elements[ i ] = getBlockExtension( true, editor.config.fillEmptyBlocks );
     398
    401399                        dataProcessor.htmlFilter.addRules( defaultHtmlBlockFilterRules );
    402400                }
    403401        });
     
    492490 * config.forceSimpleAmpersand = false;
    493491 */
    494492CKEDITOR.config.forceSimpleAmpersand = false;
     493
     494/**
     495 * Whether in the HTML output editor will insert a filler text (non-breaking space entity -  ) into empty block
     496 * elements, in order to render such block element at an empty line height.
     497 * @name CKEDITOR.config.fillEmptyBlocks;
     498 * @type Boolean|Function a judging bool or a mediation function.
     499 * @default true
     500 * @example
     501 * config.fillEmptyBlocks = false;      // Prevent filler nodes in all empty blocks.
     502 *
     503 * // Prevent filler node only in float cleaners.
     504 * config.fillEmptyBlocks = function( element )
     505 * {
     506 *      if ( element.attributes[ 'class' ].indexOf ( 'clear-both' ) != -1 )
     507 *              return false;
     508 * }
     509 */
     510
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy