0

我的在线CMS(现在使用CKEditor v4.2.2)不支持<font face="Symbol">,所以在线编辑工具必须保留在线版本的UTF-8的“纯度”。

当用户从外部文本复制/粘贴到 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           = '...';
           // ...
      });
  });
4

1 回答 1

1

首先,如果你想解决这个问题,你需要找到一个包含这些字符的字典,它可以让你将原始字符转换为它们的 UTF-8 表示。

要将此转换应用于所有font元素,请使用dataProcessor. dataFilter应用于所有加载或插入编辑器的数据。

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.
        }
    }
} );

在这里您可以找到更复杂的 dataProcessor 用法示例:http ://ckeditor.com/forums/CKEditor/Create-new-dom-elements-using-dataProcessor.htmlFilter

于 2013-10-26T13:55:59.223 回答