2013-07-07 39 views

回答

0

修复干净& nbsp;

  1. 开放redactor.js
  2. 找到
syncClean: function(html) 
{ 
    if (!this.opts.fullpage) html = this.cleanStripTags(html); 

    html = $.trim(html); 

    // removeplaceholder 
    html = this.placeholderRemoveFromCode(html); 

    // remove space 
    html = html.replace(/​/gi, ''); 
    html = html.replace(/​/gi, ''); 
    // html = html.replace(/ /gi, ' '); // COMMENT THIS! 
    ... 
} 
  1. 评论替换字符串

利润! :)

+1

非常糟糕的方式修改源代码 - 你应该使用[回调](http://imperavi.com/redactor/docs/callbacks/)来代替,比如'pasteBeforeCallback'例如。 –

+0

在这种情况下修改源代码 - 最好的方法(尽管它通常不好)。 redactor.js的作者不想添加特殊设置。回调会破坏一切(在这种情况下)。 – hVostt

+0

你能否详细说明如何以及回调如何破坏? –

3

您所看到的文字和代码在所有浏览器中都会有所不同,这就是可信度字段的工作原理。例如,一些浏览器插入UTF-8字符的空格&nbsp

RedactorJS不提供标准化文本的方法,因此您可以手动解析文本。检查此:

var html = $('#redactor').redactor('get'); 
var sanitizeHtml = html.replace(/\u00a0/g, ' ').replace(/ /g, ' '); 
+0

10X求助)) – hVostt

2

在新版本中,U可能会将“cleanSpaces”选项设置为“false”,以禁用 自动删除。

$('#redactor').redactor({ cleanSpaces: false });