How does the Sharepoint Text Editor work?

By jpsmit
May 30, 2005
0


For things like the content editor webpart and the add listing functionality, Sharepoint has a Text Editor. As you might have noticed, the text editor isn’t the same everywhere. It looks more or less the same but it is supplying different functionality at every different location.


To change the default Text Editor, it is necessary to first understand how the current is working. This post tries to explain this.


First of all the Text Editor is a plain DHTML editor. It uses a TextArea and an IFrame, just like the well known DHTML editor.


The Text Editor is wrapped in a user control:



When the page is rendered, the Text Editor is converted into a TextArea:


<TEXTAREA id=TextEditor style=”WIDTH: 600px; HEIGHT: 800px” name=TextEditor>….</TEXTAREA>


Also at the bottom of the page the following Javascript is added:


RTE_ConvertTextAreaToRichEdit (“TextEditor”, …)


This function is located in the ows.js and does exactly what it looks like it does. It looks up the TextArea and converts it into the DHTML control. It leaves the TextArea alone but adds an IFrame and toolbars for the editor.


The function RTE_GiveEditorFirstFocus(“TextEditor”) moves the focus to the just created editor. Also an event is attached to the IFrame which makes sure that the content in the editor is moved to the text area after the user presses the submit button. It uses the following function for that:


RTE_TransferIFrameContentsToTextArea(“TextEditor”)

 

All Javascript is located in the ows.js file.

 

To change the default implementation of the text editor, the best approach is to make sure the content of the adjusted editor ends up in the text editor text area afterwards. For the add listing version it is also necessary to leave the SPSWC:TextEditor in place because the button calling ‘ShowTextEditor’ counts on it. If that is removed, it is much more difficult to display the editor and save the content using default available functionality. I was not able to determine the implementation of ‘ShowTextEditor’, so if someone can explain it to me……..

Comments: 0

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta