2013-07-07 38 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 });