Ticket #5404: 5404.patch

File 5404.patch, 3.4 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                return extendEmptyBlock && !lastChild
     46                        || lastChild &&
     47                                ( lastChild.type == CKEDITOR.NODE_ELEMENT && lastChild.name == 'br'
     48                                // Some of the controls in form needs extension too,
     49                                // to move cursor at the end of the form. (#4791)
     50                                || block.name == 'form' && lastChild.name == 'input' );
    5051        }
    5152
    52         function extendBlockForDisplay( block )
     53        function getBlockExtension( isOutput, emptyBlockFiller )
    5354        {
    54                 trimFillers( block, true );
    55 
    56                 if ( blockNeedsExtension( block ) )
     55                return function( node )
    5756                {
    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' ) );
     57                        trimFillers( node, !isOutput );
     58                        if ( blockNeedsExtension( node, !isOutput || emptyBlockFiller ) )
     59                        {
     60                                if ( isOutput || CKEDITOR.env.ie )
     61                                        node.add( new CKEDITOR.htmlParser.text( '\xa0' ) );
     62                                else
     63                                        node.add( new CKEDITOR.htmlParser.element( 'br', {} ) );
     64                        }
     65                }
    7166        }
    7267
    7368        var dtd = CKEDITOR.dtd;
     
    9590        var defaultDataBlockFilterRules = { elements : {} };
    9691
    9792        for ( i in blockLikeTags )
    98                 defaultDataBlockFilterRules.elements[ i ] = extendBlockForDisplay;
     93                defaultDataBlockFilterRules.elements[ i ] = getBlockExtension();
    9994
    10095        var defaultHtmlFilterRules =
    10196                {
     
    225220                        }
    226221                };
    227222
    228         var defaultHtmlBlockFilterRules = { elements : {} };
    229 
    230         for ( i in blockLikeTags )
    231                 defaultHtmlBlockFilterRules.elements[ i ] = extendBlockForOutput;
    232 
    233223        if ( CKEDITOR.env.ie )
    234224        {
    235225                // IE outputs style attribute in capital letters. We should convert
     
    367357                        dataProcessor.dataFilter.addRules( defaultDataFilterRules );
    368358                        dataProcessor.dataFilter.addRules( defaultDataBlockFilterRules );
    369359                        dataProcessor.htmlFilter.addRules( defaultHtmlFilterRules );
     360
     361                        var defaultHtmlBlockFilterRules = { elements : {} };
     362                        for ( i in blockLikeTags )
     363                                defaultHtmlBlockFilterRules.elements[ i ] = getBlockExtension( true, editor.config.fillEmptyBlocks !== false );
     364
    370365                        dataProcessor.htmlFilter.addRules( defaultHtmlBlockFilterRules );
    371366                }
    372367        });
     
    461459 * config.forceSimpleAmpersand = false;
    462460 */
    463461CKEDITOR.config.forceSimpleAmpersand = false;
     462
     463/**
     464 * Whether editor output will insert the non-breaking space entity ( ) into empty block elements.
     465 * @name CKEDITOR.config.fillEmptyBlocks;
     466 * @type Boolean
     467 * @default true
     468 * @example
     469 * config.fillEmptyBlocks = false;
     470 */
     471
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy