3

Why does SharePoint add the following to text entered into rich text fields of list items?

<div class="ExternalClass85AC900AB26A481DBDC8ADAE7A02F039"><p>....</p></div>

We've seen instances where we have two of these ExternalClass DIV tags wrapping content, even though we didn't add them. They cause the text to have weird, extra spacing on top and bottom, with the only solution for us being to go in and remove them from the HTML of the rich text field. We don't mind the P tags; but the unneeded DIVs are too much. And removing them doesn't affect the content in any way.

Anyone have a solution for this? Thanks.

2
  • Use JQuery to remove the div/remove spacing from the div?
    – Rawling
    Commented Jan 30, 2012 at 13:36
  • Thanks, Rawling. But that doesn't address the issue of why SP2010 adds the DIVs in the first place.
    – Alex C
    Commented Jan 31, 2012 at 6:13

3 Answers 3

1

Perhaps switching to alternate Rich Text Editor might be best option to get rid of these. At least RadEditor is one relatively common replacement. (I have no affiliation with RadEditor whatsoever).

1

This thread is quite old but there is a solution for it explained in this forum post: http://www.telerik.com/forums/table-formatting-lost-after-saving-a-list-item

Here are the two steps:
In order to workaround this issue you can create a custom content filter, which will strip .ExternalClassxxxxxxxxxxxxxxxxxxxxxxxxxxx class.

  1. Modify the respective ListConfigFile.xml, which is located in the /Program Files/Common Files/Microsoft Shared/web server extensions/wpresources/RadEditorSharePoint/5.x.x.0__1f131a624888eeed/Resources/ folder.
    Add the following element:
<property name="OnClientLoad">OnClientLoad</property>
  1. Add the following JavaScript to the MOSSEditorTools.js, which is located in the mentioned above folder:
function OnClientLoad(editor, args)
{
    editor.get_filtersManager().add(new MyFilter());
}
MyFilter = function()
{
    MyFilter.initializeBase(this);
    this.set_isDom(false);
    this.set_enabled(true);
    this.set_name("RadEditor filter");
    this.set_description("RadEditor filter description");
}
MyFilter.prototype =
{
    getHtmlContent: function(content)
    {
        var newContent = content;
        //Make changes to the content and return it
        newContent = newContent.replace(/\.ExternalClass[^ ]* /ig, "");
        return newContent;
    }
}
MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter);
1
  • Please add a brief explanation of the steps outlined in the link you provided. If the link breaks at a later date, your answer will no longer be valuable.
    – Phil Greer
    Commented Jul 11, 2014 at 15:28
1
    public static string ListFieldTextMultileFilter(string val)
    {
        var tmp30 = val;
        var tmp31 = XDocument.Parse(@"<tmp>" + tmp30 + @"</tmp>");
        XElement tmp32 = null;
        while (true)
        {
            tmp32 = tmp31.Descendants().Where(it3 =>
               it3.Name.LocalName == @"div" &&
               it3.Attributes().Where(it5 =>
                   it5.Name == @"class" &&
                   it5.Value.StartsWith(@"External")).Count() > 0
               ).FirstOrDefault();
            if (tmp32 == null) { break; }
            tmp32.AddBeforeSelf(tmp32.Nodes().ToArray());
            tmp32.Remove();
        }
        var ret = tmp31.FirstNode.ToString();
        ret = ret.Substring(@"<tmp>".Length, ret.Length - @"<tmp>".Length - @"</tmp>".Length);
        return ret;        
    }
1
  • Thanks, @ivanivanov. Can you explain what the above method does and where it should be used?
    – Alex C
    Commented Aug 3, 2015 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.