Essential Fix Needed When Using TinyMCE With Domino

Back in April '06 I talked about the bug in Domino whereby it inserts "random paragraph breaks". When using one of the many WYSIWYG HTML editors to edit documents there was a potential problem in that Domino could insert its own carriage returns at any point in your HTML. If this happens to be inside an HTML tag then you're likely to get some garbled, badly-formatted output.

The solution at the time seemed to be an upgrade to 6.5.5. It worked for me and I've not suffered the same problem since. Until yesterday that is. This time the server was 7.0.2 and the same "regression bug" appears to be back. Although I'm not 100% certain it's the exact same bug it's still a problem and so a solution is needed regardless of what the actual cause is.

In my case the editor in question was TinyMCE and the problem was Domino breaking the HTML in the wrong place. The trouble seems to be that TinyMCE sends the whole of the HTML you've written to the server as one long unbroken string. Domino doesn't like this and so breaks it in to chunks after every 16,000th character or so.

To stop this happening we need to stop TinyMCE sending one long line of text and break it up in a sensible manner before Domino gets the chance to.

The solution was suggested in the comments to that original post by, amongst others, Patrick Niland. His idea was to use the save_callback method of the editor to alter the HTML before it gets posted. The solution is worthy of its own posting instead of being hidden in the comments back there.

Here's an example of the JavaScript needed on a form that uses the editor and demonstrates how you can use regular expressions to split the HTML:

        mode: "exact",
        elements: "Body",
        //Lots of other options here
        save_callback: "addNewLinesForDomino"

function addNewLinesForDomino(element_id, html, body){
        return html.replace(/(\<\/(div|h[1-6]{1}|p|ol|ul|pre)\>)/gi, "$1\n");

What this does is tell the TinyMCE editor to call the function "addNewLinesForDomino" before the form is submitted to the server. When the function runs it adds a new line after all the common block-level elements that might appear in the HTML. Not only does this prevent problems at the server it also lends itself to much tidier looking code in the source.

If nothing else it's a nice example of the power of Regular Expressions. Does that part make sense? Hands up if not and I'll explain.

If you use TinyMCE with Domino add this fix now.


  1. Nice. One thing I enable by default in my Tiny MCE implementation in Struturo is the apply_source_formatting : true.

    Makes the HTML look really nice when you view it from the Notes client after someone uses the web editor.

    It works kind of like the old formula editor back in the day.

  2. According to the documentation:

    Option: apply_source_formatting

    This option enables you to tell TinyMCE to apply some source formatting to the output HTML code. With source formatting, the output HTML code is indented and formatted. Without source formatting, the output HTML is more compact.

    This option is enabled by default as of version 3.0.

    So if you're using 3.0 or greater this is not needed unless you set apply_source_formatting to false.

    • avatar
    • Jake Howlett
    • Thu 24 Jul 2008 03:09 PM

    I'm guessing the addition of this setting (or an upgrade to v3) would negate the need for the fix I mentioned then...

  3. Unless you set apply_source_formatting to false. Then TinyMCE would send the HTML as one unbroken string.

  4. Hi Jake, in connection with the insurance claim for the laptop, I have the same prob.

    Chassis on mine is broken. I paid £15 to have the laptop looked over and they said it is not cost effective to repair.

    Contacted the insurance and I do have a valid claim however after the £100 excess I will lose my no claims discount for the next 4years so my premiums will be 40% higher until 2012.

    Therefore the insurance company will get their money back and some more on top.

    I can think of a few choice words I could say on the matter but I won't because I'm a laydeee!!!

    • avatar
    • Fredrik
    • Mon 1 Sep 2008 06:35 AM

    Have anybody had problems with attachments and TINY MCE.

    I have a form that I have implemented Tiny MCE in and it works great but below this field I have an upload control that you counld upload files to the document. And the problem seams to be that Domino is attaching the files to the Richtext field that I have the text in now.

    Any Ideas how to get the attachments just to be uploaded into the document and not too my richtext field ?

Your Comments


About This Page

Written by Jake Howlett on Thu 24 Jul 2008

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content