views:

977

answers:

3

I'm pretty much just looking for the code they used that is very similar this this WYSIWYG when adding a comment. I want them to be able to hit return and it automatically throws in a <br /> tag. I know very simple way to get it to work in a text area if they know the HTML tags, but almost no users will. So I just want a few buttons like bold, italic, and link and have it automatically do <br />'s on return. Nothing real fancy.

It can be either a jquery or a rails solution as I am using both. Thanks for any leads/help. I looked briefly into some like TinyMCE, but those do a lot more than I want users to be able to do.

A: 

Try a combo of RecCloth and TEH. To have it show up under the text area as they type look into observe_field.

Jarrod
The documentation for RedCloth is horrible. Can you give me a sample of how to implement it into rails code?
Mike
Sure. First install the gem - gem install RedCloth. Then in your view pass some text for it to format - RedCloth.new(@my_text).to_html. Any textile formatted text will be processed, so your database just stores plain text. Here's a reference for textile: http://redcloth.org/textile/. The documentation is short because there's just not that much to it.
Jarrod
A: 

I'm not sure if I completely understand your question, but you could have a look at wysihat. I haven't used it before, but it does look promising for some basic 'rich text' formatting.

Or, you could use Markdown to format the copy that the user inputted. There are a bunch of libraries that will parse Markdown, I typically use RDiscount.

Hope this helps. Cheers.

theIV
+2  A: 

I've used fckeditor, fairly easy to get running:

http://www.fckeditor.net/

but will consider the Yahoo rich text editor for my next app:

http://developer.yahoo.com/yui/editor/

klochner
I tried out the Yahoo RTE. It's pretty decent and I have it functioning except when I click submit the text in the textarea isn't getting submitted to the database. If I work that out, then I'll go with this one.
Mike
I got that working. Now my only issue is with the link function. Say i want the link to go to www.yahoo.com. I tries to take me to www.mysite.com/www.yahoo.com
Mike
the Flickr plugin for the YUI WYSIWYG editor rocks!
Tony