Opened 5 years ago

Closed 4 years ago

#10422 closed Bug (fixed)

fillEmptyBlocks not working properly if a function is specified

Reported by: raz_atoth Owned by: Piotrek Koszuliński
Priority: Normal Milestone: CKEditor 4.4.3
Component: General Version: 4.0 Beta
Keywords: HasPatch Cc: shane@…

Description (last modified by Jakub Ś)

The function never fires,if config.fillEmptyBlocks is a function,although there are empty elements and a &nbsp; is placed instead just as if config.fillEmptyBlocks was true [<div class="block">&nbsp;</div>] If config.fillEmptyBlocks=false it works as expected [<div class="block"></div>]

config.fillEmptyBlocks = function( element )
	{
		alert('fillEmptyBlocks!');
		if ( element.attributes[ 'class' ].indexOf ( 'clear-both' ) != -1 )
			return false;
	}

Attachments (1)

config.js (1.7 KB) - added by raz_atoth 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by raz_atoth

Attachment: config.js added

comment:1 Changed 5 years ago by Jakub Ś

Description: modified (diff)
Status: newconfirmed
Version: 4.1.14.0 Beta

Problem can be reproduced from CKEditor 4 beta. In 3.x branch when you switched to source you could see alert being called. Nothing like this is happening in CKE 4.x.

comment:2 Changed 5 years ago by casupport

Cc: shane@… added
Keywords: HasPatch added

For CKEditor 4.3.1 in htmldataprocessor.js, it appears the fillEmptyBlock argument for blockFilter() will always be passed as a boolean true when config.fillEmptyBlocks is a function. So when building the list of text blocks, blockFilter() will never receive a function for the fillEmptyBlock argument. Propose changes:

From

for ( i in textBlockTags )
rules.elements[ i ] = blockFilter( isOutput, editor.config.fillEmptyBlocks !== false );

To

for ( i in textBlockTags )
rules.elements[ i ] = blockFilter( isOutput, editor.config.fillEmptyBlocks );

And From

( typeof fillEmptyBlock == 'function' ? fillEmptyBlock( block ) !== false : fillEmptyBlock ) ) 

To

( typeof fillEmptyBlock == 'function' ? fillEmptyBlock( block ) !== false : fillEmptyBlock !== false ) ) 

comment:3 Changed 4 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.4.3
Owner: set to Piotrek Koszuliński
Status: confirmedassigned

A duplicate was reported in #12129.

comment:4 Changed 4 years ago by Piotrek Koszuliński

Status: assignedreview

comment:5 Changed 4 years ago by Marek Lewandowski

Resolution: fixed
Status: reviewclosed

I've updated one comment and joined var statement. Fixed with git:ab195efbe1 (merged to master).

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy