views:

3753

answers:

9

Is there a good ruby gem for a WYSIWYG editor that will easily work with a rails app?

+7  A: 

Though it's certainly not a direct answer, in the past I've found I prefer to use RedCloth (or a Markdown parser if you don't enjoy Textile) and use a simple textarea with an AJAXy preview. Generally speaking, WYSIWYG editors have a long history of creating redundant tags and similar, leading to potentially broken pieces of HTML.

wfarr
I'd like to strongly recommend at least thinking about going with Textile as a solution. For a lot of cases anything complex enough you NEED a WYSIWYG editor is complex enough a WYSIWYG editor won't work well.
Cody Hatch
Can you recommend an editor to go with Textile?
jpartogi
+4  A: 

I'm not sure about a Ruby Gem, but TinyMCE is a customizable, generally stable WYSIWYG editor that is fairly simple to integrate w/ any project. I've used it a number of times.

kamens
+3  A: 

I use FCKEditorOnRails plugin: http://github.com/UnderpantsGnome/fckeditor_on_rails/tree/master

Note that you can generally drop in the latest version of FCKEditor without much tweaking if you're running into bugs in the older version.

Matt Rogish
+2  A: 

There is a plugin to use TinyMCE with rails, lots of information on the rails wiki.

John Duff
link is broken or deprecated on the rails wiki
ChuckB
+6  A: 

While I know this has been answered I wanted to add regarding the use of textile... I completely agree, but I'd recommend processing it in a before_save filter. Let's say you have a database field called "details" - just add one called "details_html". Then do something like this...

before_save :convert_details

def convert_details
  return if self.details.nil?
  self.details_html = RedCloth.new(self.details).to_html
end

RedCloth can get a little process heavy and if you are constantly processing the stuff on each render you're going to run into some memory issues... this will just help lower some of your needed resources.

Tim K.
+2  A: 

Have a look at http://livepipe.net/control/textarea for a WYSIWYG markdown editor with the AJAXY preview mentioned in the chosen answer.

Brian Armstrong
+1  A: 

+1 for FCKEditor - there is a great Rails plugin that includes helpers. However it is often overkill as it features everything. In many cases something a little simpler such as jQuery's WYSIWYG editor is great for wrapping a text area input.

+2  A: 

A similar question: http://stackoverflow.com/questions/2658969/2661586

I just pasted my same solution here too.

I strongly suggest you give WYSIHAT a try. The biggest problem with the editors mentioned above is its bulky size and "hard-to-customize"(ability). The bad code in most of these editors is a big turn-off. WYSIHAT is more like a framework for a WYSIWYG editor. Extremely easy to customize. Easy to configure. And what more.. Its backed by 37signals. What i would appreiciate about TinyMCE is its paste from word feature which preserves the layout. But if not for that one feature i find the rest really bulky.

Please do read this article: http://37signals.com/svn/posts/1330-introducing-wysihat-an-eventually-better-open-source-wysiwyg-editor

Tutorial on using WYSIHAT: Part 1: http://jrmehle.com/2009/01/25/wysiwhat-wysihat-part-1/

Part 2: http://jrmehle.com/2009/02/13/wysiwhat-wysihat-part-2/

And to make your life even easier theres an awesome rails-engine developed by Jeff Kreeftmeijer (80beans.com) for the 37signals WYSIHAT editor: http://github.com/80beans/wysihat-engine

And heres an article by Jeff Kreeftmeijer: http://www.80beans.com/2009/10/01/wysihat-engine/

Shripad K
+1  A: 

Update for 2010. I just implemented TinyMCE in a Rails app using the tinyMCE gem.

You can find it here: http://github.com/kete/tiny_mce

It took less than 5 minutes and in my basic testing, it's working perfectly. There was a commit in June 2010, so it looks like this is an actively developed gem.

Hope that helps some googlers.

MikeH