Wednesday, February 04, 2009

Still Wigging Out Over WYSIWYG

Once upon a time I managed to embed a WYSIWYG rich text web editor into a web site I built with Ruby on Rails. Once upon a time as in about a year and a half back. It worked OK, after some shoehorning, except that it offered more than I needed and I never could get it to produce paragraph breaks. Sort of a serious shortcoming.

Lately I've been looking for something else to do the same job. I have a different site up with a sort of one-way blog on it where I can login and add text directly into the database, and then see it on the proper page. And since there is no provision for comments I don't have to deal with random input from the outside.

But the problem is that I'm pasting text into a dumb textarea, so to add anything as basic as a paragraph break (how hard should this be?) I first have to manually format the text, then paste it in.

I've been playing with various ideas about automatically formatting text, but you immediatedly get deep into the valley of endless, regressing trouble if you try to write something like this.

Option B is to embed an editor again, with all the plumbing work, fiddling, maintenance and endless possibilities for strange side effects.

I checked out 37Signals's early attempt at working this out, but it's still too early to bother with. And though I really hate to use this cliche, they are reinventing the wheel. Let's say they might be closer to reinventing the meat grinder and sticking their heads into it. One commenter thought that since they were not satisfied with anything they found, they'd be much better off taking what looked closest and forking the code. I think I agree, but don't get to vote.

Option C is to use Textile, Markdown, or something similar, which is just another form of embedding extraneous code inside my application, and then getting to learn a whole new command language. And I did have the idea of finding something that would be simple but powerful enough for potential customers to use. Fighting with customers over the vagaries of Textile was 37Signals's motivation to go ahead and launch a whole new editor. So there.

I thought I was out of options.

But wait! There's more!

Firefox addons. There were two candidates. I'm going to try one of them.

Write Area by AlfonsoML uses FCKEditor. I could't get it to produce paragraphs from pasted-in text. It does fine if you type text and hit the enter key after each line, but typing in single lines is not the same as pasting in dozens or hundreds at a time.

OK, second and last option: Xinha Here! by Hypercubed. Bingo. It works. In a clunky way, but it works.

After fiddling around for quite a while I found a menu option that lets you format highlighted text to the "Normal" format, after you paste it in. Doing this replaces all the default break tags with nice beginning and ending paragraph tags. This will work. It is based on Xinha, another embeddable editor.

The cool part of this is that I don't have to muck up my application (or rebuild it). All it takes is installing the addon into Firefox, and then using Firefox. This would not work for a blog with comments, or a forum or wiki, but it could work at a customer site, as a sort of really quick, light, and clean content management system.

Just add a logon page and the ability to create, edit, and delete content, through Rails, and turn them loose on it. When a textarea pops up, you right click on it, and a Xinha Here! window opens. You do your editing there, save it to the textarea, save that, and get on with your business.

There probably is no way to configure an editor like this, short of learning how to create and edit Firefox addons, but it should be easy enough to use only a few options, or to instruct someone else how to use it with restraint.

After all, any solution, even a multi-thousand dollar content management system, requires training, thought, and restraint, and this little gem is free.

So in the process of doing my research I found a lot of good infomation on WYSIWYG rich text web editors. More than I need, so I'm sharing it.

References:

Xinha Here!
Write Area
Genii Software Ltd. list of WYSIWYG rich text web editors
2007 Evaluation of WYSIWYG editors
37signals's WYSIHAT editor
Discussion of WYSIHAT at hacker news


0 comments :

Post a Comment