CKEditor adding far too many BR tags

Viewed 1206

I'm developing a web application using ASP.NET WebForms and have added CKEditor for more user-friendly text editing. Now the issue is, the amount of whitespace is far too big.

Apparently, it creates a div element for every block of text (treats an empty line as another block) and then surrounds each block with an additional BR element.

There's been plenty of times this issue has been mentioned both on SO and on the official forums, although the solutions did not seem to work for me.

Eventually, after spending way longer than expect on the issue, I just went for a trial and error approach, and added this to my

editor.config.enterMode = CKEditor.NET.EnterMode.P;
editor.config.autoParagraph = false;
editor.config.shiftEnterMode = CKEditor.NET.EnterMode.P;
editor.config.fillEmptyBlocks = false;
editor.config.forceEnterMode = false;

It does seem to react to the code (fillEmptyBlocks worked just fine), although it seems to completely ignore the EnterMode settings.

Has anyone had the exact same issue and found an effective way of fixing this? I've literally spent hours of trial and error/internet research and I'm starting to get fairly desperate (The biggest problem is not just the BRs, it's the fact that an empty div also contains a BR and two BRs outside of it)

EDIT.: It finally reacts to EnterMode changes (started working after I added editor.config.forcePasteAsPlainText = true;)

Now the interesting thing is - when the EnterMode is set to BR, it dishes out BR elements for each line break (including an empty line) - that means that if you have an empty line in between two blocks of text, there will be a total of 4 BRs separating them. Is there a way around this ?

0 Answers
Related