Stop CKEDITOR from copying the class of the previous element to every new element on the page

By default, any element that your cursor is inside when you press enter will be duplicated with all the same attributes. If you set "forceEnterMode: true" in the CKEDITOR config file, you can force ckeditor not to duplicate the element and instead use the default element every time you press enter ( http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR .config.html # .forceEnterMode ), but unfortunately the classes are still copied to this new element.

In other words, if the code inside ckeditor:

<div class="text">{{cursor here}}</div>

      

And press the enter key twice. You'll get:

<div class="text"></div>
<div class="text">{{cursor here}}</div>

      

Then you set forceEnterMode: true and press enter key, you get:

<div class="text"></div>
<div class="text"></div>
<p class="text">{{cursor here}}</p>

      

I'm not sure what kind of situation you would like your previous element class to be copied to every future element on page explosion, but I definitely don't want this feature. I want the result to be like this:

<div class="text"></div>
<p></p>

      

How do I make CKEDITOR stop copying the attributes of the previous element to every new page element every time I press the enter key?

Here's a jsfiddle: http://jsfiddle.net/B4yGJ/158/

+3


source to share


1 answer


Short answer: you cannot force CKEDITOR to stop copying previous attributes of an element.

If you read the enterkey code plugin on github carefully , you will see the previous node cloned with all attributes, inline styles and classes (only the id is removed) and then the parent or below is pasted into it . The exceptions are blockquote , li and pre tags .



This makes sense because we usually want to keep typing with the selected styles when a new paragraph is created (just like in any other editor).

If this behavior is still annoying, you can manually use the magicline plugin , which forces line breaks between blocks, or remove text formatting from the selected block.

+1


source







All Articles