Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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.

A similar question: What is the best WYSIWYG for Rails - Ruby on Rails Blog

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/

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.

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

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

+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.

I'm really loving CKeditor gem. It's much, much more elegant than TinyMCE, especially if you deal with raw HTML. CKeditor displays on page--TinyMCE gives a popup. CKeditor allows access to things like all headings right out of the box, too. TinyMCE requires hacking.

RedCloth's inability to support ALL HTML was a dealbreaker for me. (Among other things, you can't support giving an image a description OR a caption!!!!) I didn't mind the markup so much as the complete lack of flexibility. Plus, it was like learning a new language--a lot of the markup was the opposite of intuitive (like image alignment), and I couldn't possibly imagine asking contributors to learn all that.

For comments, I will use something much lighter weight, though.

I had bad experiences with CKEditor (gem "ckeditor") .. I managed to get it to work on local maschine but had a lot problems when trying to deploy it to Heroku .. It seems like code is too heavy to automatically precompile the code on Heroku ... That means it is quite useless ...

EDIT: Solution: make sure that you precompile javascript before deploying it on Heroku.

I would use Tiny MCE it is a Java Script solution I have integrated with Web Applications to edit HTML.

http://www.tinymce.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top