Formular una preguntaFormular una pregunta
 

RespondidaCustomising the Rich Text Editor via a feature

  • viernes, 06 de junio de 2008 9:12Gerry Crowe Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     

    Morning all

     

    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>

     

    Many thanks

    Gerry

Respuestas

  • viernes, 03 de julio de 2009 11:32rollspelosofen Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    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.

Todas las respuestas

  • miércoles, 10 de junio de 2009 13:51rollspelosofen Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     
    I'm having a similar issue. The only difference is that I have deployed the files manually.

    Did you find a solution for this?

    /Benjamin
  • viernes, 03 de julio de 2009 11:32rollspelosofen Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Respondida
    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.
  • jueves, 01 de octubre de 2009 1:40akiam Medallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuarioMedallas del usuario
     Tiene código
    Hi All

    You can still modify the original file and then encode it and save it back using the following code:

    	   byte[] bitesEncode = RTE2ToolbarExtensionsFile.OpenBinary();
           	   Encoding asciiEncoding = Encoding.GetEncoding("ISO646-US", new EncoderReplacementFallback(""), new DecoderReplacementFallback());
                Encoding utf8Encoding = Encoding.UTF8;
                bitesEncode = Encoding.Convert(utf8Encoding, asciiEncoding, bitesEncode);
                RTE2ToolbarExtensionsFile.SaveBinary(bitesEncode);