Rich text editing still blows
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.