I've gone through similar struggles in the past, and had settled on YUI. Unfortunately, YUI results (at least for me, and admittedly, I rushed through and never re-factored), in awful html.
Then tonight, when I stumbled on this post, I found PunyMCE. There are 2 awesome things about it: 1) its incredibly lightweight (as its name implies), and 2) there is a rails plugin that has already been created for it: puny_mce on github.
The documentation is good enough, except for a couple of things that I overlooked/had me scratching my head:
- There is a typo under "Usage", <%
yield :head %> should be <%= yield
:head %>
- If you want to use more
than the basic toolbar, you need to
include either a) the pre-setup
profile or b) the toolbar items and
required plugins for those items in
BOTH the
include_puny_mce
call
AND the puny_mce
call. This makes
sense -- the include_puny_mce
is
instructing the page on which
javascripts it needs, and the
puny_mce
call is actually building
the javascript output required to
generate the rich editor.
Here is an example I put together to demonstrate:
<% content_for :head do %>
<%= include_puny_mce :profiles => [:full] %>
<% end %>
<h1>New post</h1>
<% form_for(@post) do |f| %>
<%= f.error_messages %>
<%= f.label :title, "Title" %><br />
<%= f.text_field :title %><br />
<%= f.label :content, "Post Content" %><br />
<%= f.text_area :content, :cols => 100 %>
<%= puny_mce 'post_content', 'post_content', :profile => :full %>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
I hope this helps!