Log in or register to post comments
Last post
Prevent CKEditor from "tampering" with the source
If I enter the following in the source-view of an empty editor:

<div><a href="javascript:void(0);">test</a></div>

go out of source-view and then go back into source-view - the above has become

<div>
   <a href="javascript:void(0);">test</a></div>


Is there any way to prevent this from happening? I would prefer to have the source exactly as I wrote it, without being reformatted.
Re: Prevent CKEditor from &quot;tampering&quot; with the source
Add this code to your config.js file.

CKEDITOR.on('instanceReady', function( ev ) {
  var blockTags = ['div','h1','h2','h3','h4','h5','h6','p','pre','li','blockquote','ul','ol',
  'table','thead','tbody','tfoot','td','th',];

  for (var i = 0; i < blockTags.length; i++)
  {
     ev.editor.dataProcessor.writer.setRules( blockTags[i], {
        indent : false,
        breakBeforeOpen : true,
        breakAfterOpen : false,
        breakBeforeClose : false,
        breakAfterClose : true
     });
  }
});