Question

How to disable the Redactor editor auto remove &nbsp ; ? Please help.

Was it helpful?

Solution 3

to fix clean  

  1. open redactor.js
  2. find
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. comment replacing string

profit! :)

OTHER TIPS

In new version U may set "cleanSpaces" option to "false" for disabling of   auto remove.

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

The text and code you are seeing will be different between all the browsers and it's how contenteditable fields work. For example, some browsers insert UTF-8 characters for spaces some &nbsp.

RedactorJS don't gives methods to normalize the text, so you can parse the text manually. Check this:

var html = $('#redactor').redactor('get');
var sanitizeHtml = html.replace(/\u00a0/g, ' ').replace(/ /g, ' ');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top