<commit_before>Rails Integration for TinyMCE
=============================

The `tinymce-rails` gem integrates the [TinyMCE](http://www.tinymce.com/) editor with the Rails asset pipeline.

This gem is compatible with Rails 3.1.1 and higher (including Rails 4).

This is the branch for TinyMCE 4. TinyMCE 3.5.x is currently available in the [master branch](https://github.com/spohlenz/tinymce-rails). For the time being, parallel versions of TinyMCE (3.5.x and 4.x) will be maintained. However TinyMCE 4 will eventually be promoted to the master branch.

[![Build Status](https://travis-ci.org/spohlenz/tinymce-rails.png?branch=tinymce-4)](https://travis-ci.org/spohlenz/tinymce-rails)


Instructions
------------

**1. Add `tinymce-rails` to your Gemfile**

    gem 'tinymce-rails'

Be sure to add to the global group, not the `assets` group. Then run `bundle install`.


**2. Create a `config/tinymce.yml` file with your global configuration options:**

    toolbar1: styleselect | bold italic | link image | undo redo
    toolbar2: table | fullscreen
    plugins:
      - table
      - fullscreen
      
The Rails server no longer needs to be restarted when this file is updated in development mode.

To define multiple configuration sets, follow this syntax (a default configuration must be specified):

    default:
      plugins:
        - image
        - link
    
    alternate:
      selector: textarea.table-editor
      toolbar: styleselect | bold italic | link image | undo redo | table
      plugins:
        - table

See the [TinyMCE 4 Documentation](http://www.tinymce.com/wiki.php/Configuration) for a full list of configuration options.


**3. Include the TinyMCE assets**

Use *one* of the following options to include TinyMCE assets.

(1) Add to your application.js:

    //= require tinymce

or (2) with jQuery integration:

    //= require tinymce-jquery

(3) The TinyMCE assets can be included on a per-page basis using the `tinymce_assets` helper:

    <%= tinymce_assets %>
    #=> <script type="text/javascript" src="/assets/tinymce.js">


**4. Initialize TinyMCE**

For each textarea that you want to use with TinyMCE, add the "tinymce" class and ensure it has a unique ID:

    <%= text_area_tag :content, "", :class => "tinymce", :rows => 40, :cols => 120 %>
    
or if you are using Rails' form builders:

    <%= f.text_area :content, :class => "tinymce", :rows => 40, :cols => 120 %>

Then invoke the `tinymce` helper to initialize TinyMCE:

    <%= tinymce %>

Custom options can be passed to `tinymce` to override the global options specified in `config/tinymce.yml`:

    <%= tinymce :theme => "simple", :language => "de", :plugins => ["wordcount", "paste"] %>

Alternate configurations defined in 'config/tinymce.yml' can be used with:

    <%= tinymce :alternate %>


Language Packs
--------------

See the [tinymce-rails-langs](https://github.com/spohlenz/tinymce-rails-langs) gem for additional language packs for TinyMCE. The `tinymce` helper will use the current locale as the language if available, falling back to English if the core language files are missing.


Manual Initialization
---------------------

Using the `tinymce` helper and global configuration file is entirely optional. The `tinyMCE.init` function can be invoked manually if desired.

    <%= text_area_tag :editor, "", :rows => 40, :cols => 120 %>

    <script type="text/javascript">
      tinyMCE.init({
        selector: 'textarea.editor'
      });
    </script>


Asset Compilation
-----------------

If you are including TinyMCE via `application.js` or using the `tinymce_assets` helper, the TinyMCE assets will be automatically precompiled when you run `rake assets:precompile`.

However if you wish to include `tinymce-jquery.js` independently, you will need to add it to the precompile list in `config/environments/production.rb`:

    config.assets.precompile << "tinymce-jquery.js"
<commit_msg>Added syntax highlighting to README.md<commit_after>Rails Integration for TinyMCE
=============================

The `tinymce-rails` gem integrates the [TinyMCE](http://www.tinymce.com/) editor with the Rails asset pipeline.

This gem is compatible with Rails 3.1.1 and higher (including Rails 4).

This is the branch for TinyMCE 4. TinyMCE 3.5.x is currently available in the [master branch](https://github.com/spohlenz/tinymce-rails). For the time being, parallel versions of TinyMCE (3.5.x and 4.x) will be maintained. However TinyMCE 4 will eventually be promoted to the master branch.

[![Build Status](https://travis-ci.org/spohlenz/tinymce-rails.png?branch=tinymce-4)](https://travis-ci.org/spohlenz/tinymce-rails)


Instructions
------------

**1. Add `tinymce-rails` to your Gemfile**

```ruby
gem 'tinymce-rails'
```

Be sure to add to the global group, not the `assets` group. Then run `bundle install`.


**2. Create a `config/tinymce.yml` file with your global configuration options:**

```yml
toolbar1: styleselect | bold italic | link image | undo redo
toolbar2: table | fullscreen
plugins:
  - table
  - fullscreen
```

The Rails server no longer needs to be restarted when this file is updated in development mode.

To define multiple configuration sets, follow this syntax (a default configuration must be specified):

```yml
default:
  plugins:
    - image
    - link

alternate:
  selector: textarea.table-editor
  toolbar: styleselect | bold italic | link image | undo redo | table
  plugins:
    - table
```

See the [TinyMCE 4 Documentation](http://www.tinymce.com/wiki.php/Configuration) for a full list of configuration options.


**3. Include the TinyMCE assets**

Use *one* of the following options to include TinyMCE assets.

(1) Add to your application.js:

```js
//= require tinymce
```

or (2) with jQuery integration:

```js
//= require tinymce-jquery
```

(3) The TinyMCE assets can be included on a per-page basis using the `tinymce_assets` helper:

```erb
<%= tinymce_assets %>
#=> <script type="text/javascript" src="/assets/tinymce.js">
```


**4. Initialize TinyMCE**

For each textarea that you want to use with TinyMCE, add the "tinymce" class and ensure it has a unique ID:

```erb
<%= text_area_tag :content, "", :class => "tinymce", :rows => 40, :cols => 120 %>
```
 
or if you are using Rails' form builders:

```erb
<%= f.text_area :content, :class => "tinymce", :rows => 40, :cols => 120 %>
```

Then invoke the `tinymce` helper to initialize TinyMCE:

```erb
<%= tinymce %>
```

Custom options can be passed to `tinymce` to override the global options specified in `config/tinymce.yml`:

```erb
<%= tinymce :theme => "simple", :language => "de", :plugins => ["wordcount", "paste"] %>
```

Alternate configurations defined in 'config/tinymce.yml' can be used with:

```erb
<%= tinymce :alternate %>
```


Language Packs
--------------

See the [tinymce-rails-langs](https://github.com/spohlenz/tinymce-rails-langs) gem for additional language packs for TinyMCE. The `tinymce` helper will use the current locale as the language if available, falling back to English if the core language files are missing.


Manual Initialization
---------------------

Using the `tinymce` helper and global configuration file is entirely optional. The `tinyMCE.init` function can be invoked manually if desired.

```erb
<%= text_area_tag :editor, "", :rows => 40, :cols => 120 %>

<script type="text/javascript">
  tinyMCE.init({
    selector: 'textarea.editor'
  });
</script>
```


Asset Compilation
-----------------

If you are including TinyMCE via `application.js` or using the `tinymce_assets` helper, the TinyMCE assets will be automatically precompiled when you run `rake assets:precompile`.

However if you wish to include `tinymce-jquery.js` independently, you will need to add it to the precompile list in `config/environments/production.rb`:

```ruby
config.assets.precompile << "tinymce-jquery.js"
```

{'fraction_non_alphanumeric': 0.1332230563684947, 'fraction_numerical': 0.009415956228527802, 'mean_word_length': 3.7150569886022797, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 47, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2781072', 'n_tokens_mistral': 2617, 'n_tokens_neox': 2343, 'n_words': 893}