2017-06-27 295 views
0

我正在使用ckeditor。我想讓用戶使用他們想要的所有內聯樣式。CKEDITOR.config.allowedContent true不起作用

但是,當我使用CKEDITOR.config.allowedContent = true;,沒有任何變化和ckeditor更改style名稱與[removed]

這裏就是我試圖做的事:

config.js

CKEDITOR.editorConfig = function(config) { }; 
CKEDITOR.config.allowedContent = true; 

我也試過:

CKEDITOR.editorConfig = function(config) {  
    CKEDITOR.config.allowedContent = true; 
}; 

我清除每次更改後的緩存,但不運氣。當我進入

<p style="text-align: center;"><span style="color:#ff0000">this is for test</span></p> 

結果變成:

<p [removed]="color:#ff0000">this is for test</span></p> 

我看了很多文章,但仍沒有運氣。有什麼建議麼?

回答

0

關於如何啓用額外的標記中的CKEditor這裏

CKEDITOR.replace('editor1', { 
    extraAllowedContent: 'style;*[id,rel](*){*}' 
}); 

extraAllowedContent使元件一個簡單的示例,允許所有兩個附加屬性(方括號中)(*是一個通配符)已經允許的元素,使任何類名(*)對他們的使用,並允許任何內嵌樣式{*}使用

要允許風格標籤(style type="text/css">...</style>)

config.extraAllowedContent = 'style'; 

允許任何類和任何內聯樣式。

config.extraAllowedContent = '*(*);*{*}'; 

我希望它能適合你!

+0

TNX的回答,但沒有任何變化。我使用ckeditor工具欄添加內嵌css,如方向和字體顏色 – msDead

0

使用CKEditor的配置文件config.jsallowedContent屬性設置爲true(因此禁用數據完全濾除):

CKEDITOR.editorConfig = function(config) {  
    config.allowedContent = true; 
}; 
+0

請儘量避免將代碼轉儲爲答案,並嘗試解釋它的作用和原因。對於那些沒有相關編碼經驗的人來說,你的代碼可能並不明顯。請編輯你的答案,包括[澄清,上下文,並嘗試在你的答案中提到任何限制,假設或簡化。](https://stackoverflow.com/help/how-to-answer) – Frits

+0

感謝您的回答,我嘗試那,沒有變化。仍然是同樣的問題 – msDead

+0

你是否像我寫過的那樣完全按照'config.allowedContent = true;'的方式來嘗試它?沒有'CKEDITOR.'在前面? – Wizard

相關問題