Convert HTML to RichText

Hi all,

First, I’m new with domino so please be very verbose in your anwsers :slight_smile:

I’m using a (nice) javascript script to edit a RichText field through a webbrowser (ie … firefox … whatever). This script is generating HTML.

The problem is “how do I convert the generated HTML code into a Notes RichText field ?”

Thanks it advance !

Subject: Convert HTML to RichText

This is a good bit more complicated than you might think, depending on what your eventual goal is. If this is a completely web enabled database, so you never need to edit the rich text in Notes, it is more simple, but the exact format depends on the rich text editor (and there are a bunch - see Web Editors). I have seen several types, but your best bet is to go to the Sandbox and search for DHTML editor. You may not want to use the DHTML edit control, which doesn’t work in Firefox for example, but the basic approach will probably work for you.

Now, if you need to edit in Notes as well, you will either have to deal with a very minimalist approach, usually accomplished by fooling Domino into thinking you are using the Java rich text applet but actually using your web editor, then living with the loss of data in the MIME to CD translation, or you need to go outside the box and look at a third party product such as our CoexEdit product. See a longish description of what that looks like from our weblog today: Selling a 9 year old on CoexEdit.

One last possibility. If you just want to get the HTML into rich text, you can import it using NotesUIDocument.Import, but you would need a document open in the front end.

Subject: RE: Convert HTML to RichText

Actually, yes, it is a completely web enabled database.

I’m currently trying to use this cross-browser Rich Text editor : http://www.kevinroth.com/rte/demo.htm. Basically, it generates HTML code (even xhtml actually) in a regular field. The goal is to be able to insert back that HTML code in a Lotus RichText field.

On the other, I’m aware there is a java-based rich text editor with domino but here I can’t use it (some users don’t/can’t have java vm installed).

I’ve done some work on it and have achieved to use the editor to update the RichText field by hiding the notes RichText field and implicitely creating a field to substitute the actual field. But when viewing the form and showing the actual field, all I can see is the “raw-editor-generated” html code.

So any clue ?

btw, what’s the “sandbox” ?

Subject: Just to clarify

When you say " But when viewing the form and showing the actual field, all I can see is the “raw-editor-generated” html code." do you still mean from the web? If so, you may need to set the PassThruHTML attribute from a Web Query Save agent.

Subject: RE: Just to clarify

This would just sound perfect … if only I know how to do it in LotusScript ! :slight_smile:

Could you post few code lines ?

TIA !

Subject: RE: Just to clarify

Here’s something from a template I got from CodeStore (which uses TinyMCE as a rich-text editor for the web):

http://www.codestore.net/store.nsf/unid/BLOG-20050209/

Sub Initialize

Dim vWebSession As New notessession

Dim vThisDatabase As notesdatabase

Dim vThisDocument As notesdocument

Dim vRichStyle As NotesRichTextStyle

Dim vRTItem As Variant

Dim vHTMLCode As Variant



Set vThisDatabase = vWebSession.CurrentDatabase

Set vThisDocument = vWebSession.DocumentContext



Set vRichStyle = vWebSession.CreateRichTextStyle

vRichStyle.PassThruHTML=True



Set vRTItem = vThisDocument.GetFirstItem( "Body" )



If ( vRTItem.Type = RICHTEXT ) Then

	vHTMLCode= vRTItem.GetUnFormattedText()

	Call vThisDocument.RemoveItem("Body")

	

	Set vRTItem = vThisDocument.CreateRichTextItem( "Body" )

	Call vRTitem.AppendStyle( vRichStyle )

	Call vRTitem.AppendText(vHTMLCode)

	

End If

End Sub

Subject: RE: Convert HTML to RichText

This is the Sandbox:

http://www-10.lotus.com/ldd/sandbox.nsf

If the Rich Text field is set to store its content as HTML and MIME (advanced tab), then the Notes client will display the rendered (as opposed to raw) HTML.