by kete

kete / tiny_mce

A Ruby on Rails plugin (pre-Rails 3.1) that allows easy implementation of the TinyMCE editor into yo...

423 Stars 74 Forks Last release: Not found MIT License 161 Commits 6 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

= TinyMCE for Rails

This gem is being depreciated because I don't have time to maintain it and the code base is in an inconsistent state! Seem following notes.

Note for Rails 3.1 users: in light of the improvements for JavaScript libraries in Rails 3.1's asset pipeline, this gem/plugin is NOT recommended for Rails 3.1 or above. Use https://github.com/spohlenz/tinymce-rails!

Note for Rails 3.0 users: consider if https://github.com/mikehoward/use_tinymce will suit your needs.

Note for Rails 2.3x users: I recommend checking the commit messags on forks of this gem at https://github.com/kete/tiny_mce/network. You'll probably have to do a bit of trial and error to get one that works for you. Learn how to build and install a gem from local source.

Final note: I may come back to fixing this gem's codebase, but I can't guarantee it, thus I recommend you explore alternatives.

This gem/plugin provides for the installation and utilization of TinyMCE in Ruby on Rails applications of version 2.3.5 and onward.

TinyMCE is a WYSIWYG HTML editing component released under the GNU Lesser General Public License 2.1 (LGPL 2.1) by Moxiecode Systems (http://tinymce.moxiecode.com/).

== Denpendency

As of 0.1.7, this gem depends on jQuery being loaded before the TinyMCE init declaration. If you are like me and also load Prototype, consider adding something like this after your jQuery load:

<%= javascript_tag('jQuery.noConflict();') -%>

== Installation

Installing TinyMCE for Rails takes no more than a few minutes to install.

=== Step 1

The recommended installation method for getting tiny_mce working in your application is to use the gem version. To do so, open the console and run:

[sudo] gem install tiny_mce

Then add this to config/environment.rb of your Rails application:

config.gem 'tiny_mce'

For Rails 3, you will need to add the following line to file Gemfile:

gem 'tiny_mce'

Alternatively, you can install it as a plugin. To do so, open a console, and in the root of you Rails application, install the plugin by running one of the following (depending on the method you use to import plugins):

  • script/plugin install git://github.com/kete/tiny_mce.git
  • piston import git://github.com/kete/tinymce.git vendor/plugins/tinymce
  • git submodule add git://github.com/kete/tinymce.git vendor/plugins/tinymce
  • Download the latest files ( http://github.com/kete/tinymce/tarball/master ) and extract to vendor/plugins/tinymce

=== Step 2

For the page you want to add TinyMCE, go to the view's controller and add:


Then append the following to the text area you want to transform into a TinyMCE editor. You can change the name of the class you want to use by editing the 'editor_selector' param in the controller code options.

:class => "mceEditor"

Lastly, add the following line(s) under the

element of your application view. Note you may need to add this to the view's layout.

<%= includetinymceifneeded %>

Now you're all set! Start your server. The gem/plugin will automatically copy the sources to the public javascripts directory when the server is started.

== Configuration

There are several ways to configure the plugin to get the desirable effect you're looking for. The following ways can be combined to create complex tiny mce setups

=== Load Order

A load order is present so that you have finer grained control over what shows up where. The load order currently looks like this. The later ones receive more power, that is, the overwrite similar settings in previous configurations.

  1. The default tiny_mce plugin settings. Sets it to work on textareas with class of mceEditor, with the english advanced theme.
  2. config/tiny_mce.yml if present. You set your own options here, used across all editors on the site.
  3. usestinymce declaration. You set you own options here, used across all editors in the controller.
  4. includetinymceifneeded declaration. You set your own options here, used across all editors contained within that layout.

Below, I'll cover how to use #2, and #3, which are the most likely ones you'll want to use.

=== Global Options

If you have a set of default options that is used throughout all editors in your application, you might want to make them global. You can do this by putting your settings into config/tinymce.yml. If the file exists, the tinymce plugin will parse the options in it first.

==== Example

theme: advanced plugins: - table - fullscreen

=== TinyMCE options

You can change the theme, order/choice of buttons, selectors Id, plugins, and many more by passing an :options hash to the usestinymce declaration.

The options hash can contain any number of settings available in lib/tinymce/validtinymce_options.yml (a copy of the settings available per version).

If an option is misspelled, invalid, or deprecated (no longer in TinyMCE), when you go to a page containing your editor, you will receive an Exception, which must be dealt with before continuing.

You can read about all these options at http://tinymce.moxiecode.com/documentation.php

==== Example

usestinymce :options => { :theme => 'advanced', :themeadvancedresizing => true, :themeadvancedresize_horizontal => false, :plugins => %w{ table fullscreen } }

=== Filter options

If, like most applications, you only need the editor on the new, create, edit, and update pages, then tell the usestinymce declaration this, so it doesn't load up all the files unnecessarily.

The declaration accepts any number of default parameters a normal controller filter would.

==== Example

usestinymce :only => [:new, :create, :edit, :update]

=== Additional Javascript options

Sometimes, when you need complex arrays of data for plugins or such, the plugin helpers aren't complex enough to do what you need. But you can always fall back to supplying your own options. You can this by passing a raw javascript (no

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.