views:

2144

answers:

5

I'd like to use Rich Text Editing in place on forms in order to let admins change instructions. What are the best options for doing this?

[To be more clear - the admins are non-technical but may want to control some formatting without using markup or with as little markup as possible. What I'd like is for them to be able to edit inline all AJAXy with an RTE featuring some formatting controls and then submit and be able to see what the instructions will look like to the end user without changing pages.

With Regards to plugins specifically, what I'd like to know is which Rich Test Editing plugins are the best for use in Rails. Easiest to implement, clearest API, easiest to use inline, etc... ]

+3  A: 

I'm not sure if I fully understand the question, but if you just ask about which editor to use, there are many options and none of them is a matter of Rails - you can use any of them just by adding a little piece of javascript into your markup. Nice and up to date overview can be found here: http://bulletproofbox.com/web-based-rich-text-editors-compared/.

Edit: Changed link to google cachce, since the original link is not working.

Milan Novota
Sorry the link is broken. Update it if you can.
JasonOng
Oh. Looks like the site is down. I changed the link to google cachce version, so you have at least something of it.
Milan Novota
+2  A: 

There are a number of templating languages implemented for Rails that give relatively simple syntax for markup. I've used RedCloth before, a gem implementation of Textile (http://redcloth.org/), and it's quite good. Things like Liquid (http://www.liquidmarkup.org/) are a little more powerful, allowing templates to actually include database information inline. Depending on your project's needs, both would potentially be a good fit.

Neither of these solutions alone would give an in-place rich text editor, but are a good starting place on the backend for what might be a drop-in solution. If you're only letting admins enter information though, I'd imagine they wouldn't be frightened of a little plaintext entry.

Misplaced
+2  A: 

For Tumblon, we started with TinyMCE but we are switching to Yahoo's Rich Text Editor because there were some weird issues with the way TinyMCE worked and because the Rich Text Editor documentation and default look-and-feel is superior.

Both are pretty easy to integrate with Rails (they are just JavaScript, after all). There are plugins, but you don't really need one.

Luke Francl
+2  A: 

The link in Milan's answer is broken. Thankfully Ajaxian.com did a nice summary of the post with links to all the various RTE in the post and its comments.

Link: http://ajaxian.com/archives/richtexteditors-compared

JasonOng
+1  A: 

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:

  1. There is a typo under "Usage", <% yield :head %> should be <%= yield :head %>
  2. 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!