tiny_mce
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:A Ruby on Rails plugin (pre-Rails 3.1) that allows easy implementation of the TinyMCE editor into your applications.
= 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/tiny_mce.git vendor/plugins/tiny_mce
* git submodule add git://github.com/kete/tiny_mce.git vendor/plugins/tiny_mce
* Download the latest files ( http://github.com/kete/tiny_mce/tarball/master ) and extract to vendor/plugins/tiny_mce

=== Step 2

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

  uses_tiny_mce

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.

  <%= include_tiny_mce_if_needed %>

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. uses_tiny_mce declaration. You set you own options here, used across all editors in the controller.
4. include_tiny_mce_if_needed 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/tiny_mce.yml. If the file exists, the tiny_mce 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 uses_tiny_mce declaration.

The options hash can contain any number of settings available in lib/tiny_mce/valid_tinymce_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

  uses_tiny_mce :options => {
                              :theme => 'advanced',
                              :theme_advanced_resizing => true,
                              :theme_advanced_resize_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 uses_tiny_mce 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

  uses_tiny_mce :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 



				
			
		
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。