Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
I'm trying to set up CouchCMS for updating a static site which has relatively straightforward content, but a lot of content layout DIVs and scattered images. The WYSIWYG mode of CKEditor works well enough for basic text editing (it massacres the layout, but the text is clearly editable, which is good enough). I started with a static site and added CouchCMS as per the tutorial.

Unfortunately, CKEditor insists on modifying the HTML at the time it loads the content, even if I change nothing in the editor -- removing tags, changing tags to other tags, etc. If I paste HTML code into the source view of the editor, switch to WYSIWYG view and then switch back to source view, the code often changes significantly.

I am aware that CKEditor employs content filtering, which is highly configurable. I've poked around in the CKEditor documentation, and it appears you should be able to disable content filtering by adding
Code: Select all
CKEDITOR.config.allowedContent = true;
to the config file. I'm not certain if that alone would fix the problem, but at any rate, it isn't working.

Apologies if I'm missing something obvious, but has anyone else run into this issue and managed to configure CKEditor so it does not modify existing HTML tags at all? Thanks!
Hi and welcome :)

CKEditor, like invariably every other wysiwyg editor, seems to have a mind of its own.

There are actually several ways that the source can get modified e.g.
a. blank lines get converted into <p>&nbsp;</p>
b. source gets formatted with auto-indentation and a newline for each element etc.

You'll find many threads on CKeditor's forum with people complaining about this 'mangling' of source code. The official reply goes something like -
This is actually a feature in the editor regarding the output formatting for readability, and it's customizable.

So, theoretically, the formatting should be customizable.

From what i could gather, you can try the following -
Edit the 'couch/includes/ckeditor/config.js' file and place the following within the CKEDITOR.editorConfig
Code: Select all
config.autoParagraph = false;

Further, add the following new function to the file (i.e. below the existing CKEDITOR.editorConfig function
Code: Select all
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
     });
  }
});

I haven't really tried these out but the threads suggest these have helped people.
Please let us know if it is true for you too.

Thanks
2 posts Page 1 of 1
cron