Removing #8203 in RichTextHTML field Sharepoint

Subramaniyan Ganesan
 
SharePoint Developer
May 8, 2015
 
Rate this article
[Total: 0    Average: 0/5]
 
Views
13354

The Rich text editor in Sharepoint 2013 inserts “zero width spacing” characters when editing HTML. Unfortunately, these are not visible to the normal user and so it is difficult to remove, so much for WYSIWYG!

Below is a Javascript snippet that will remove all instances of the character in the HTML field’s editable region.

 //insert this script in the <head> after 
 
 <SharePoint:ScriptLink language="javascript" name="core.js" OnDemand="true" runat="server" Localizable="false"/>
 
 EnsureScript('SP.UI.RTE.js', typeof (RTE), function () {
 //Removes ​ZWSP characters
 if (RTE.Cursor.update == undefined)
 return;
 try {
 var update_orig = RTE.Cursor.update;
 RTE.Cursor.update = function () {
 update_orig();
 var range = RTE.Cursor.get_range();
 if (range.isValid()) {
 var editorElement = RTE.Canvas.getEditableRegion(range.parentElement());
 if (editorElement && editorElement.innerHTML) {
 editorElement.innerHTML = editorElement.innerHTML.replace(/\u200B/g, "");
 }
 }
 
 }
 } catch (e) {
 console.log (“RTE override error”, e);});
 
Category : SharePoint

Author Info

Subramaniyan Ganesan
 
SharePoint Developer
 
Rate this article
[Total: 0    Average: 0/5]
 
Around 6 years of IT experience in Microsoft technology like SharePoint 2013 / 2010, EPM (Project server 2010) & ASP.NET. Pursuing Master degree in Business Administration. Passionate in exploring SharePoint ...read more
 

Leave a comment