akg akg - 3 years ago 81
Javascript Question

How to format the HTML output of CKEDITOR?

I want to format the html output of CKEDITOR. I am using this code to set the rules for


editor_new = CKEDITOR.appendTo( 'editorSpace',{
instanceReady: function(ev){
this.dataProcessor.writer.lineBreakChars = '';
this.dataProcessor.writer.setRules( 'p', {
indent: false,
breakBeforeOpen: false,
breakAfterOpen: false,
breakBeforeClose: false,
breakAfterClose: false

It has changed the output format from






But the problem with this is when I use
on the editor, it adds one
after every line as it is a normal string. I want to eliminate that
on the backend side.

I want to configure the html of editor as this


without any spaces and breaks so that the backend does not need to care about the data coming from frontend and stores it in database as-is. Is there any way I can achieve this?

PS: I have just shown example for
tags. I want to achieve this for every tag. In short, I want to generate html in the same way a minified js file stores javascript content.

Answer Source

Just get rid of HTML Output Writer plugin, i.e. with config.removePlugins:

CKEDITOR.replace( 'editor', {
    removePlugins: 'htmlwriter'
} );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download