I have a web page with a CKEditor on it and my issue is that when I view source or post to the server, I am getting extra spaces and line breaks before the initial text that I type in the textarea.
Here is what I type
and when I click on source, here is what I see:
When I post this to the server, before the initial text I see:
<p>\r\n\tWe do deli . . .
Does anyone know how I can change the settings so it doesn't add all of this extra paragraph and line breaks when I don't want them. Is this a setting on CKEditor or is this something that I need to deal with on the client? I notice that there is also a </p>
at the end of the data.
I Fixed my problem by adding this code n my config.js (just replace br
for p
)
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.dataProcessor.writer.setRules('br',
{
indent: false,
breakBeforeOpen: false,
breakAfterOpen: false,
breakBeforeClose: false,
breakAfterClose: false
});
});
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
It applies to all ckeditors avoiding the need of code being replicated ( ctrl + c + ctrl + v )