Ucf_Falcon
Ucf_Falcon

Reputation: 39

CK Editor is preforming adjustments to the source code

If I input a line like the one below:

<div id="footer"></div>

After I switch back to WYSIWYG mode, there is an &nbsp inserted like so:

<div id="footer">&nbsp</div>

I've tried to edit the config as shown below after seeing that in another Stackoverflow thread but the same issue prevails. Any help?

//Whether to prompt the user about the clean up of content being pasted from MS Word.
config.pasteFromWordPromptCleanup = true;

config.enterMode = CKEDITOR.ENTER_DIV;
CKEDITOR.config.forcePasteAsPlainText = false; // default so content won't be manipulated on load
CKEDITOR.config.basicEntities = true;
CKEDITOR.config.entities = true;
CKEDITOR.config.entities_latin = false;
CKEDITOR.config.entities_greek = false;
CKEDITOR.config.entities_processNumerical = false;
CKEDITOR.config.fillEmptyBlocks = function (element) {
    return true; // DON'T DO ANYTHING!!!!!
};

CKEDITOR.config.allowedContent = true; // don't filter my data
config.shiftEnterMode = CKEDITOR.ENTER_BR;
config.language = 'en';

config.pasteFromWordRemoveFontStyles = false;
config.pasteFromWordRemoveStyles = false;

Upvotes: 0

Views: 133

Answers (1)

Reinmar
Reinmar

Reputation: 22023

CKEditor correctly fills empty <div> with an &nbsp;. You're trying to use CKEditor incorrectly. When you load that empty block into CKEditor, CKEditor sees it and knows that it won't be accessible by caret unless it's expanded. Therefore editor inserts there something (I say something, because it depends on case).

Remember that CKEditor is a document editor, not web page builder.

That's said, there's an option to prevent this natural CKEditor's behaviour - config.fillEmptyBlocks.

CKEDITOR.replace( 'editor1', {
    fillEmptyBlocks: false
} );

This will leave all blocks empty.

PS. There's a bug in the documentation - this option does not accept callback.

Upvotes: 0

Related Questions