2013-10-24 73 views
0

online CMS(現在正在使用CKEditor的v4.2.2)不支持<font face="Symbol">,所以在線編輯工具必須保留的UTF-8的在線版本的「純潔」。CKeditor-4,如何禁用字體符號?

就會出現問題,當用戶複製/粘貼從外部文本到CKEDITOR箱,

<p><font face="Symbol">&bull; </font>blabla 
    <font face="Symbol">S</font> blabla;</p> 

燦CKEditor的把這些<font face="Symbol">爲 「無UTF-8」?也就是說,可以節省的CKEditor

<p>&#8226; blabla &#931; blabla;</p> 

有一些配置來執行僅UTF8字符,沒有字體符號?


編輯:我的配置測試的情境,

CKEDITOR.on('instanceCreated', function(event) { // contenteditable 
     var editor = event.editor; 
     // ... 
     editor.on('configLoaded', function() { 
      editor.config.skin   = '...'; 
      // ... 
     }); 
    }); 

回答

1

首先,如果要解決這個問題,你需要找到這些字符的字典,這將讓你翻譯原始字符到他們的UTF-8表示。

要將此轉換應用於所有font元素,請使用dataProcessordataFilter適用於加載或插入編輯器的所有數據。

editor.dataProcessor.dataFilter.addRules({ 
    elements: { 
     font: function(el) { 
      // el will be an instance of CKEDITOR.htmlParser.element 
      // el.children[ 0 ] will be an instance of CKEDITOR.htmlParser.text 
      // You'll need to read a value of that text, replace 
      // all characters with their UTF-8 representatives 
      // and return: 
      return new CKEDITOR.htmlParser.text(text); 
      // That will replace font tags with returned text nodes. 
     } 
    } 
}); 

在這裏你可以找到數據處理器使用的更復雜的所示例:http://ckeditor.com/forums/CKEditor/Create-new-dom-elements-using-dataProcessor.htmlFilter

+0

感謝@Reinmar,你是CKEDITOR-的人,所以我敢肯定,你的答案是正確的! [官方字典在這裏](http://www.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/symbol.txt)...但我需要一點點的幫助來複制/粘貼你的代碼(使用'返回CKEDITOR.htmlParser.text('HelloWorld');')到CKedtitor實現中,請參閱我編輯過的附錄中的問題文本 - 無法正常工作,我需要複製/粘貼代碼? –

+0

最佳位置將放在'editor#pluginsLoaded'偵聽器中。數據處理器實例將在那時準備就緒。你也可以將它添加到'editor#instanceReady'監聽器中,但是這是在數據被過濾之後,所以你的過濾器將會錯過啓動時加載的數據。 – Reinmar

相關問題