2014-06-23 41 views
0

如果我輸入類似下面的行:CK編輯器預成形調整到源代碼

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

之後切換回WYSIWYG模式,有一個& NBSP插入像這樣:

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

我試圖編輯配置後,看到在另一個Stackoverflow線程但以同樣的問題爲準。任何幫助?

//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; 

回答

1

CKEditor的正確填補空<div>&nbsp;。您嘗試錯誤地使用CKEditor。當您將空塊加載到CKEditor時,CKEditor會看到它,並知道它不會被插入符號,除非它被展開。因此,編輯在那裏插入一些東西(我說了一些東西,因爲它取決於大小寫)。

請記住,CKEditor is a document editor, not web page builder

這就是說,有一個選項可以防止這種自然的CKEditor行爲 - config.fillEmptyBlocks

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

這將使所有塊都爲空。

PS。文檔中存在一個錯誤 - 該選項不接受回調。