xeivo
xeivo

Reputation: 11

ckeditor - Pure HTML source mode without ANY alterations of the code

I know this question has been asked 1000 times, but after 6 hours of research I still couldn't find any solution.

Unfortunately, I am bound to a CMS that's using ckeditor. I don't like WYSIWYG editors at all, but I have to deal with it. I want the editor to not touch ANY of my code, doesn't matter if it's wrong or not, if I place block elements into inline elements, etc.

This is the config I am using atm:

CKEDITOR.editorConfig = function( config ) {
config.language = 'en';
config.allowedContent = true;
config.height = 600;
config.startupMode = 'source';

// Prevent CK from removing empty HTML-tags
$.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
    CKEDITOR.dtd.$removeEmpty[i] = false;
});};

Well, with these settings the editor still seems to alter the code. For instance, it realigns <a> or <span> tags and just adds new code. This is so incredible annoying. I know it's not the purpose of the editor to behave like a pure webdev editor, but there must be a way to configure it somehow to just leave the code completely alone, right? Can anyone tell me what settings I need to add in order to achieve this?

Upvotes: 0

Views: 719

Answers (1)

Quentin
Quentin

Reputation: 943150

there must be a way to configure it somehow to just leave the code completely alone, right?

Wrong.

Libraries like this make use of the contentEditable feature provided by browsers.

The browser will take the HTML, parse it into a DOM, and then provide an API to manipulate it. Later, that DOM can be serialised back to HTML, but this is entirely disconnected from the original HTML. Everything will have been normalised.

Upvotes: 1

Related Questions