Rich text editing still blows

Wow do I hate dealing with rich text editing. The funny thing is, way back when POP Forums was a product I actually sold, I think I may have been the first to use some very basic bold/italic functionality in a forum. Now there are some nice controls out there, free even, but trying to get them to work as you'd like in both IE and Mozilla/Firefox is hopeless.

The latest version of FreeTextBox has one problem: By default it renders bold and italics with span/style tags/attributes. That's bad because what I need for parsing is <b>/<strong> or <i>/<em> tags. To Firefox's credit, it's smart enough to combine them into the same tag, but again, not really what I need. I did find this little gem buried in the Mozilla documentation and tried to work it into a derived class:

public class FTB : FreeTextBox
{
  protected override void OnPreRender(EventArgs e)
  {
    base.OnPreRender (e);
    this.Page.RegisterStartupScript("cssfix",
      "<script language=\"javascript\">if (navigator.userAgent.toLowerCase().indexOf(\"gecko\") != -1) document.getElementById(\""
      + this.UniqueID.Replace(":", "_").Remove(0, 1)
      + "_designEditor\").contentDocument
.execCommand(\"useCSS\",false,null);</script>");
  }
}


Unfortunately, while the relative client-side script works great when I plug it into a static HTML representation of an editor (the useCSS command), it works great, but causes some kind of component error in Firefox's Javascript engine when I try to use it in a live FreeTextBox.

My next attempt was to try and upgrade my own little control, however ugly it might be, to work in Firefox. Works great, except for the part about copying the HTML from the iframe to the hidden text field. In my version, I use the iframe's onblur event to copy, so if you hit anything else on the page, it'll copy it over before a form submit (by postback or otherwise). Firefox doesn't seem to listen for onblur from an iframe, so that doesn't work. Despite a lot of searching through the FreeTextBox script, I can't see how it does the copy.

So here I am, back at zero.

There really should be a good Flash-based editor, though that of course would cause you to lose text if you accidentally moved back or forward. I've seen a few out there, but they rely on Flash's built-in functionality, which, believe it or not, throws in more junk than IE ever did.

2 Comments

  • I agree completely. There are no decent web-based rich text editors which produce good markup.



    I want something that will clean up Word documents and spurt out valid, semantic XHTML. I don't want excess &quot;style&quot; attributes and I do want it to work in all the browsers I try.

  • http://xstandard.com/page.asp?p=A4372B00-8D7F-4166-977C-64E5C4E3708E



    XStandard has a free version with a pretty good feature-set. It's implemented as a browser plugin, and it does *perfect* xhtml. Try it out... It really seems to be first class. There's a Pro version that has a bunch of good features as well. The downside is that you have to do a bit of fiddling to grab the text from ASP.NET. If someone wrapped the free version as a .NET control I'd be an extremely happy camper.

Comments have been disabled for this content.