For those of you who don’t know, a Rich Text Editor, or RTE, is that really nice looking thing that you can enter text into that will automatically format it (such as bolding, italics, linking, aligning, etc.).
Today, my post is about choosing an implementing an RTE for your website form. Being as frugal as I am, I stuck to the open source selections.
First I was looking for something that was pretty, and when I typed in “free rich text editor”, I naturally got the Free Rich Text Editor website (http://www.freerichtexteditor.com). I took a look at a couple other options, but this one was the prettiest of them all, so I downloaded and started installing it. If you want to skip a nice and long story having to do with this editor, skip a few paragraphs until I talk about the next one.
The first thing I noticed was that it was not designed to be implemented in a page more than once . While it had configuration settings, they were all in a separate js (javascript) file that globally set the identity. I wanted 3 of these on one page, and I wanted unique identities for each one. Well, being the developer that I am, I decided I would fiddle with the code.
I found a way where I could include variables in the initialization function to specify the identity of the form name, it worked! Yay for me! I quickly found out, however, that my javascript form validation wouldn’t work with it. It took me some time to realize why, but I found out that it was in an iframe, meaning it was a separate window, and my validation tool couldn’t pick up iframes. Oh, and as a side note, the actual editor itself created iframes and all the functionality on one of the most confusing javascript pages I have ever seen. In addition, I found no support on the site.
I decided I would make a personal validation tool, I had done it before and I saw no reason why I couldn’t do it now, and I had already spent over an hour, maybe two, working on this and wasn’t about to give it up. Before I did that, I needed to find a way to give each iframe window a unique ID. I tried the same trick of adding it to the parameter list, which I thought worked. I then came to another error, it was in another function. I found where it called that function (in the initialization function) and added it to it’s parameters too. Got by another function, but got hung up on another one.
It had been 2-3 hours now and I was getting sick of it. I needed an RTE that didn’t use iframes, it was a simple as that. I trashed that project and started looking some more, and found that most RTEs use iframes, apparently it was the easier way to do it. Oh, I had also spent about an hour fiddling with some CSS to make it look right, as I found another design on the site had set some CSS properties, so I was thoroughly done having to do anything with it.
I finally decided I would handle it tomorrow (or today), as it was 3:30 AM and I had other work to do. Well, my friend who had heard me complaining about my RTE, decided to search. While I worked elsewhere he kept showing me more RTEs he found, and I kept pointing out the outpoints. He finally found one that looked promising, TinyMCE. MCE stands for “Moxiecode Editor”.
It is an open source editor that converts your textareas into RTE forms. Wow, perfect! I can use my normal names and ids for my textarea and they cross over. I looked into it more, and they had a wiki support form with a LOT of data, tons of example, some special plugins, etc. I decided to install it when I woke up.
The installation went quickly and it worked like a charm, no CSS hassles, the customization I needed was shown in clear examples on the website, was perfect. Well, I thought it was perfect, but then I found my validation didn’t work again. I was curious as to why.
It was a weird symptom because my validation would say it was an empty field when I submitted, when I submitted again (no changes) it found it filled. I found that a special call was being made on the form that takes the data and sticks it into the text area (all documented on their site), but this was done on the submit, and my validation ran right before the form was submitted. I simply placed an onclick event to my form, so that it called it BEFORE my validation got to it, and it worked perfectly. This was the code I added to my form: onclick=”tinyMCE.triggerSave();”
I also installed one of their plugins, TinyMCE Compressor (supports all major scripting languages besides classic ASP). This makes it load much faster, but I warn you, there is a bug. They have an installation guide to it in their wiki, which you should follow exactly except on one point. There is a plugins options and it lists a ton of plugins that the compressor will speed up. If you’re using any of the plugins, fine, leave them in. I found that when I left them at the default, my “add link” button wasn’t working, and found other people had the same thing. I was told to make plugins section empty, which I did and it worked fine. I have a feeling it was a plugin called “advLink”, but I’m unsure. I found this answer on their support forums when I did a couple of searches.
Now, it all works fine and I’m really happy with it. If you need help with any of the tweaks I did, let me know
-Kerry