2017-05-26 63 views
5

在我的Ckeditor配置我有一個自定義allowedContent。我不使用allowedContent:true,因爲我不想讓在span標籤的style屬性Ckeditor:stylesSet不工作,當我設置一個自定義allowedContent

所以這是我allowedContent

allowedContent : 'span[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;' 

利用這種結構,樣式屬性不再被允許的跨度標籤

問題是與我stylesSets:

stylesSet: 
     - { name: "style 1", element: ['div', 'p', 'a', 'span'], attributes: { class:"display_only_in_popup" } } 
     - { name: "style 2", element: ['div', 'p', 'a', 'span'], attributes: { class:"blockquote" } } 
     - { name: "style 3", element: ['div', 'p', 'a', 'span'], attributes: { class:"note" } } 
     - { name: "style 4", element: ['p', 'span'], attributes: { class:"highlight" } } 
     - { name: "style 5", element: 'span', attributes: { class:"visuallyhidden" } } 

之前,當我有allowedContent:true,我能夠看到和使用我所有的5個樣式集,但現在,由於某種原因,我只看到樣式字段中的「樣式5」

是否可以保留我的5個樣式集而不使用allowedContent:true

非常感謝

+0

我將'allowedContent'設置爲其默認值,並將其改爲'extraAllowedContent' – Wizard

回答

0

看來你的5個stylesets全部使用class屬性,但你allowedContent規則只允許span元素class屬性。

我建議改變allowedContent規則:

allowedContent : '*[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;' 

,或者如果你想更明確的:

allowedContent : 'div[class]; p[class]; a[class]; span[class]; a[!href](*); caption; div; em; h1; h2; h3; h4; h5; h6; hr; i; img; li; ol; p[*]{*}; pre; strong; sub; sup; table; thead; tbody; tfoot; td; th; tr; tt; u; ul; dl; dt; dd; iframe;' 

請參閱documentation here

注:我無法測試此代碼,請在評論中告知我是否執行此項工作。

相關問題