Hi, I am using br tags with classes. Such as 'clear' and other classes for responsive sites. Like when to show or hide the BR tag. All other BR tags remain. But br class="clear", br class="clear mobile-show", br class="clear mobile-hide" is replaced with nbsp.
I tried the whole allowedContent, but I am not going to sit here and add every possible tag in order to not replace one tag. Thats is just a bit much, unneccessary and I should not have to do that.
Another alternative suggestions? Ideas?
Latest CKEditor version.
Even adding 'config
Even adding 'config.extraAllowedContent = 'br(*)';' does not work or even specifiying the class's.
I created editor like this:
I created editor like this:
And editor correctly preserved:
Are you sure that you cleared cache after changing config.js file?
Although, after a while I thought that you might want to use <br> at the end of block. Such <br>s have special meaning in contenteditable elements and you simply cannot use them. But first of all, you should not use CKEditor to edit a layout which needs clear fix hacks. Read more in CKEditor - basic concepts.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thanks.
Thanks.
See, I tried that and did not work.
As for the cache, Ya. I know about that one and how it is.
I even tried:
extraAllowedContent: {
br: {classes: 'clear'}
},
No go.
I will add or try both (not at same time). Clear cache, reload page. Code to source view. Type in the code, flip back and forth till back to source view and it is a nbsp; again.
This is interesting. Just tried it again. I will be in source code view. Type my br tag in the current code. Not go back to the other view and just hit submit. When I go back, the BR tag is still there, but... lots of rn (assuming \r\n). I go to source code view, remove those. Flip back and BR tag is replaced with NBSP;
The \r\n is somehting else
The \r\n is somehting else entirely.
The above does work, until you switch back and froth from code view. And BR tag is replaced.
I can add the tag in source code view, and submit it.
And it stays. But again, once you flip from source code view and back, it is replaced.
Sort of Fixed.
Not sure if you managed, it but I spent all night fixing this.
Very, very aggravating issue.
Syntactically it makes sense that some <br> are removed, but the ones with styles or classes applied should always be left alone.
To correct the issue - at least in part, some are still being removed despite the class, Download this file:
http://dev.ckeditor.com/browser/CKEditor/trunk/_source/plugins/htmldataprocessor/plugin.js
Create the plugin folder in the same path, then include the plugin in your configuration file:
config.extraPlugins = 'htmldataprocessor';
This is likely unrelated, but I also have the following in the settings:
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_P;
config.allowedContent = true; // don't filter my data
extraAllowedContent: 'br(*)';
And the phraser that sets the code formatting options to keep my sources somewhat readable:
CKEDITOR.on('instanceReady', function( ev ) {
//Set the write instance
var writer = ev.editor.dataProcessor.writer;
// The character sequence to use for every indentation step.
writer.indentationChars = '\t';
// The way to close self closing tags, like <br />.
writer.selfClosingEnd = ' />';
// The character sequence to be used for line breaks.
writer.lineBreakChars = '\n';
// The writing rules for <div> tag.
writer.setRules( 'div',
{
// Indicates that this tag causes indentation on line breaks inside of it.
indent : true,
// Inserts a line break before the <p> opening tag.
breakBeforeOpen : false,
// Inserts a line break after the <p> opening tag.
breakAfterOpen : true,
// Inserts a line break before the </p> closing tag.
breakBeforeClose : true,
// Inserts a line break after the </p> closing tag.
breakAfterClose : true
});
var blockTags = ['h1','h2','h3','h4','h5','h6','p','pre','ul','li'];
var rules = {
indent : true,
breakBeforeOpen : true,
breakAfterOpen : false,
breakBeforeClose : false,
breakAfterClose : true
};
for (var i=0; i<blockTags.length; i++) {
writer.setRules( blockTags[i], rules );
}
});
Again, it's not an actual "fix" that makes it work all the time, but at least it makes it stop replacing most of the breaks that are actually needed.