Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Customising the Rich Text Editor via a feature

  Asked By: Bhavani    Date: Jan 11    Category: Sharepoint    Views: 1581

I want to modify the Rich Text Editor used by Sharepoint on my publishing page. I've created my Javascript files and image files, and created a modified version of RTE2ToolbarExtension.xml - I'm ready to go.



If I add the files to my Layouts folder manually, and then customise the RTE2ToolbarExtension.xml within the catalog/masterpage/Editing Menu folder, it all works a treat - my buttons appear and work as desired. However, this manual approach is obviously not the ideal way of doing it, so instead I created a feature to make the changes instead.



The first problem is that I can't overwrite a file within the catalog masterpages via a feature, so my workaround is to rename the existing file first. At the moment I'm doing that manually but ultimately this will be done via a feature activation event. Now when I activate my feature, I get my updated version of RTE2ToolbarExtension.xml added to the catalog. However, when I try to edit my publishing page, Sharepoint throws the following XML Exception:



"Data at the root level is invalid. Line 1, position 1



So it's unable to read my new version of the XML file, even though the contents are *exactly* the same as they were after I manually updated it.



Any suggestions why that might be? My ElementManifest file contains the following:


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="EditingMenu"
Url="_catalogs/masterpage/Editing Menu"
Path="EditingMenu"
RootWebOnly="TRUE">
<File Url="RTE2ToolbarExtension.xml" Type="Ghostable" IgnoreIfAlreadyExists="TRUE"/>
</Module>
</Elements>

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Silvia Wilkinson     Answered On: Jan 11

I finally solved this, btw.

For once, the error-message in SharePoint was 100% correct but if it's because of a design-issue or not... who knows.

It's impossible to customize RichTextEditor with an xml  of your own. You have to make use of the one residing in the Master page  library and edit  through either Notepad(before uploading it again) or SharePoint Designer.

The reason for this is that the one that is shipped with SharePoint is filled with some kind of characters that I didn't have the encoding for or just a certain amount of space before the root-node in the xml. If these "characters" are not included in the file  with the additions you want to have in the RTE then you will get an error saying "Data at the root  level is invalid. Line 1, position  1" everytime you try to edit a page where this control is available.

If you edit the xml in Visual Studio the encoded characters will be removed automaticly and the XML will be useless.

So, make sure you make a copy of the original file before you try to customize the RTE without making use of SharePoint Designer.

 
Didn't find what you were looking for? Find more on Customising the Rich Text Editor via a feature Or get search suggestion and latest updates.




Tagged: