tinymce-rails 3.5.9 → 3.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +98 -44
- data/lib/tasks/tinymce-assets.rake +6 -3
- data/lib/tinymce/rails.rb +1 -1
- data/lib/tinymce/rails/asset_installer.rb +34 -36
- data/lib/tinymce/rails/asset_installer/compile.rb +44 -0
- data/lib/tinymce/rails/asset_installer/copy.rb +52 -0
- data/lib/tinymce/rails/asset_manifest.rb +108 -89
- data/lib/tinymce/rails/configuration.rb +29 -5
- data/lib/tinymce/rails/engine.rb +40 -1
- data/lib/tinymce/rails/helper.rb +4 -4
- data/lib/tinymce/rails/version.rb +2 -2
- data/vendor/assets/javascripts/tinymce/plugins/fullscreen/fullscreen.htm +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/inlinepopups/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/inlinepopups/editor_plugin_src.js +13 -13
- data/vendor/assets/javascripts/tinymce/plugins/paste/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/paste/editor_plugin_src.js +7 -5
- data/vendor/assets/javascripts/tinymce/plugins/searchreplace/js/searchreplace.js +4 -0
- data/vendor/assets/javascripts/tinymce/plugins/wordcount/editor_plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/wordcount/editor_plugin_src.js +1 -1
- data/vendor/assets/javascripts/tinymce/tiny_mce.js +1 -1
- data/vendor/assets/javascripts/tinymce/tiny_mce_jquery.js +1 -1
- data/vendor/assets/javascripts/tinymce/tiny_mce_jquery_src.js +32 -3
- data/vendor/assets/javascripts/tinymce/tiny_mce_src.js +32 -3
- metadata +18 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab211e85e16ec0692551345d36b4a9795cfd76b6
|
4
|
+
data.tar.gz: 1ce16e077f0a32322bf516d638c57286267a838d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 460047537ca0db474d68ffc3b2de2f993f77d386cc82275e3ec1fabea52a8e52176b00c0d0c272c298dc228fc8a7511f046fe5cb596613a3bd7affdb23eddbef
|
7
|
+
data.tar.gz: 1569dcb35a58fbf3bd9194493faae09a43a62495aa7c2323379945e44c76bb7342958207d03a3e9949da273994a4dbb2ae0756f2d9f3620ab01a3443f26d0480
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -5,51 +5,58 @@ The `tinymce-rails` gem integrates the [TinyMCE](http://www.tinymce.com/) editor
|
|
5
5
|
|
6
6
|
This gem is compatible with Rails 3.1.1 and higher (including Rails 4).
|
7
7
|
|
8
|
-
|
8
|
+
This is the branch for TinyMCE 3.5.x. For TinyMCE 4, please see the [master branch](https://github.com/spohlenz/tinymce-rails).
|
9
9
|
|
10
|
-
[](https://travis-ci.org/spohlenz/tinymce-rails)
|
11
11
|
|
12
|
+
**New in 3.5.11, 4.1.10 and 4.2.1:** Alternative asset installation methods (copy vs compile/symlink). See the [Asset Compilation](#asset-compilation) section below for details.
|
12
13
|
|
13
14
|
Instructions
|
14
15
|
------------
|
15
16
|
|
16
17
|
**1. Add `tinymce-rails` to your Gemfile**
|
17
18
|
|
18
|
-
|
19
|
+
```ruby
|
20
|
+
gem 'tinymce-rails'
|
21
|
+
```
|
19
22
|
|
20
23
|
Be sure to add to the global group, not the `assets` group. Then run `bundle install`.
|
21
24
|
|
22
25
|
|
23
26
|
**2. Create a `config/tinymce.yml` file with your global configuration options:**
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
```yml
|
29
|
+
theme_advanced_toolbar_location: top
|
30
|
+
theme_advanced_toolbar_align: left
|
31
|
+
theme_advanced_statusbar_location: bottom
|
32
|
+
theme_advanced_buttons3_add:
|
33
|
+
- tablecontrols
|
34
|
+
- fullscreen
|
35
|
+
plugins:
|
36
|
+
- table
|
37
|
+
- fullscreen
|
38
|
+
```
|
34
39
|
|
35
40
|
The Rails server no longer needs to be restarted when this file is updated in development mode.
|
36
41
|
|
37
42
|
To define multiple configuration sets, follow this syntax (a default configuration must be specified):
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
```yml
|
45
|
+
default:
|
46
|
+
theme_advanced_toolbar_align: left
|
47
|
+
theme_advanced_buttons3_add:
|
48
|
+
- tablecontrols
|
49
|
+
plugins:
|
50
|
+
- table
|
51
|
+
|
52
|
+
alternate:
|
53
|
+
theme_advanced_toolbar_location: top
|
54
|
+
theme_advanced_toolbar_align: left
|
55
|
+
theme_advanced_buttons3_add:
|
56
|
+
- tablecontrols
|
57
|
+
plugins:
|
58
|
+
- table
|
59
|
+
```
|
53
60
|
|
54
61
|
See the [TinyMCE 3 Documentation](http://www.tinymce.com/wiki.php/Configuration3x) for a full list of configuration options.
|
55
62
|
|
@@ -60,51 +67,70 @@ Use *one* of the following options to include TinyMCE assets.
|
|
60
67
|
|
61
68
|
(1) Add to your application.js:
|
62
69
|
|
63
|
-
|
70
|
+
```js
|
71
|
+
//= require tinymce
|
72
|
+
```
|
64
73
|
|
65
74
|
or (2) with jQuery integration:
|
66
75
|
|
67
|
-
|
76
|
+
```js
|
77
|
+
//= require tinymce-jquery
|
78
|
+
```
|
68
79
|
|
69
80
|
(3) The TinyMCE assets can be included on a per-page basis using the `tinymce_assets` helper:
|
70
81
|
|
71
|
-
|
72
|
-
|
73
|
-
|
82
|
+
```erb
|
83
|
+
<%= tinymce_assets %>
|
84
|
+
#=> <script type="text/javascript" src="/assets/tinymce.js">
|
85
|
+
```
|
74
86
|
|
75
87
|
**4. Initialize TinyMCE**
|
76
88
|
|
77
89
|
For each textarea that you want to use with TinyMCE, add the "tinymce" class and ensure it has a unique ID:
|
78
90
|
|
79
|
-
|
91
|
+
```erb
|
92
|
+
<%= text_area_tag :content, "", :class => "tinymce", :rows => 40, :cols => 120 %>
|
93
|
+
```
|
94
|
+
|
95
|
+
or if you are using Rails' form builders:
|
96
|
+
|
97
|
+
```erb
|
98
|
+
<%= f.text_area :content, :class => "tinymce", :rows => 40, :cols => 120 %>
|
99
|
+
```
|
80
100
|
|
81
101
|
Then invoke the `tinymce` helper to initialize TinyMCE:
|
82
102
|
|
83
|
-
|
103
|
+
```erb
|
104
|
+
<%= tinymce %>
|
105
|
+
```
|
84
106
|
|
85
107
|
Custom options can be passed to `tinymce` to override the global options specified in `config/tinymce.yml`:
|
86
108
|
|
87
|
-
|
109
|
+
```erb
|
110
|
+
<%= tinymce :theme => "simple", :language => "de", :plugins => ["inlinepopups", "paste"] %>
|
111
|
+
```
|
88
112
|
|
89
113
|
Alternate configurations defined in 'config/tinymce.yml' can be used with:
|
90
114
|
|
91
|
-
|
92
|
-
|
115
|
+
```erb
|
116
|
+
<%= tinymce :alternate %>
|
117
|
+
```
|
93
118
|
|
94
119
|
Manual Initialization
|
95
120
|
---------------------
|
96
121
|
|
97
122
|
Using the `tinymce` helper and global configuration file is entirely optional. The `tinyMCE.init` function can be invoked manually if desired.
|
98
123
|
|
99
|
-
|
100
|
-
|
101
|
-
<script type="text/javascript">
|
102
|
-
tinyMCE.init({
|
103
|
-
mode: 'textareas',
|
104
|
-
theme: 'advanced'
|
105
|
-
});
|
106
|
-
</script>
|
124
|
+
```erb
|
125
|
+
<%= text_area_tag :editor, "", :rows => 40, :cols => 120 %>
|
107
126
|
|
127
|
+
<script type="text/javascript">
|
128
|
+
tinyMCE.init({
|
129
|
+
mode: 'textareas',
|
130
|
+
theme: 'advanced'
|
131
|
+
});
|
132
|
+
</script>
|
133
|
+
```
|
108
134
|
|
109
135
|
Language Packs
|
110
136
|
--------------
|
@@ -112,6 +138,34 @@ Language Packs
|
|
112
138
|
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.
|
113
139
|
|
114
140
|
|
141
|
+
Asset Compilation
|
142
|
+
-----------------
|
143
|
+
|
144
|
+
Since TinyMCE loads most of its files dynamically, some workarounds are required to ensure that the TinyMCE asset files are accessible using non-digested filenames.
|
145
|
+
|
146
|
+
As of tinymce-rails 3.5.11, 4.1.10 and 4.2.1, two alternative asset installation methods are available, which can be changed by setting `config.tinymce.install` within your `config/application.rb` file. Both methods are called when you run `rake asset:precompile` (via `Rake::Task#enhance`) after the regular application assets are compiled.
|
147
|
+
|
148
|
+
The default method, `copy`, copies the TinyMCE assets directly into `public/assets` and appends the file information into the asset manifest.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
config.tinymce.install = :copy
|
152
|
+
```
|
153
|
+
|
154
|
+
The new method, `compile`, adds the TinyMCE paths to the Sprockets precompilation paths and then creates symlinks from the non-digested filenames to their digested versions.
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
config.tinymce.install = :compile
|
158
|
+
```
|
159
|
+
|
160
|
+
Due to compilation times, this method is only recommended using Rails 4 and up. This method is intended to eventually become the default, so please try it if it suits your environment and report any issues.
|
161
|
+
|
162
|
+
If you are including TinyMCE via `application.js` or using the `tinymce_assets` helper, you do not need to manually alter the precompile paths. However if you wish to include `tinymce-jquery.js` independently (i.e. using `javascript_include_tag`), you will need to add it to the precompile list in `config/environments/production.rb`:
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
config.assets.precompile << "tinymce-jquery.js"
|
166
|
+
```
|
167
|
+
|
168
|
+
|
115
169
|
Custom Plugins & Skins
|
116
170
|
----------------------
|
117
171
|
|
@@ -2,12 +2,15 @@ assets_task = Rake::Task.task_defined?('assets:precompile:primary') ? 'assets:pr
|
|
2
2
|
|
3
3
|
Rake::Task[assets_task].enhance do
|
4
4
|
require "tinymce/rails/asset_installer"
|
5
|
-
|
6
|
-
assets = Pathname.new(File.expand_path(File.dirname(__FILE__) + "/../../vendor/assets/javascripts/tinymce"))
|
7
5
|
|
6
|
+
assets = Pathname.new(File.expand_path(File.dirname(__FILE__) + "/../../vendor/assets/javascripts/tinymce"))
|
7
|
+
|
8
8
|
config = Rails.application.config
|
9
9
|
target = File.join(Rails.public_path, config.assets.prefix)
|
10
10
|
manifest = config.assets.manifest
|
11
11
|
|
12
|
-
TinyMCE::Rails::AssetInstaller.new(assets, target, manifest)
|
12
|
+
installer = TinyMCE::Rails::AssetInstaller.new(assets, target, manifest)
|
13
|
+
installer.log_level = Logger::INFO
|
14
|
+
installer.strategy = config.tinymce.install
|
15
|
+
installer.install
|
13
16
|
end
|
data/lib/tinymce/rails.rb
CHANGED
@@ -7,7 +7,7 @@ module TinyMCE
|
|
7
7
|
require "tinymce/rails/helper"
|
8
8
|
|
9
9
|
def self.configuration
|
10
|
-
@configuration ||= ConfigurationFile.new(
|
10
|
+
@configuration ||= ConfigurationFile.new(Engine.config_path)
|
11
11
|
@configuration.respond_to?(:configuration) ? @configuration.configuration : @configuration
|
12
12
|
end
|
13
13
|
|
@@ -1,64 +1,62 @@
|
|
1
1
|
require "tinymce/rails/asset_manifest"
|
2
2
|
|
3
|
+
require "tinymce/rails/asset_installer/copy"
|
4
|
+
require "tinymce/rails/asset_installer/compile"
|
5
|
+
|
3
6
|
module TinyMCE
|
4
7
|
module Rails
|
5
8
|
class AssetInstaller
|
9
|
+
attr_reader :assets, :target, :strategy
|
10
|
+
attr_accessor :logger
|
11
|
+
|
6
12
|
def initialize(assets, target, manifest_path)
|
7
13
|
@assets = assets
|
8
14
|
@target = target
|
9
15
|
@manifest_path = manifest_path || target
|
16
|
+
|
17
|
+
@logger = Logger.new($stderr)
|
18
|
+
@logger.level = Logger::INFO
|
10
19
|
end
|
11
20
|
|
12
21
|
def install
|
13
|
-
|
14
|
-
copy_assets
|
15
|
-
append_to_manifest
|
16
|
-
|
17
|
-
manifest.write
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def manifest
|
22
|
-
@manifest ||= AssetManifest.load(@manifest_path)
|
22
|
+
(strategy || Copy).new(self).call
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
27
|
-
manifest.remove(asset) if index_asset?(asset)
|
28
|
-
|
29
|
-
manifest.remove_digest(asset) do |src, dest|
|
30
|
-
move_asset(src, dest)
|
31
|
-
end
|
32
|
-
end
|
25
|
+
def log_level
|
26
|
+
@logger.level
|
33
27
|
end
|
34
|
-
|
35
|
-
def
|
36
|
-
|
28
|
+
|
29
|
+
def log_level=(level)
|
30
|
+
if level.is_a?(Integer)
|
31
|
+
@logger.level = level
|
32
|
+
else
|
33
|
+
@logger.level = Logger.const_get(level.to_s.upcase)
|
34
|
+
end
|
37
35
|
end
|
38
36
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
37
|
+
def strategy=(strategy)
|
38
|
+
if strategy.is_a?(Class)
|
39
|
+
@strategy = strategy
|
40
|
+
else
|
41
|
+
@strategy = self.class.const_get(strategy.to_s.titlecase)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def manifest
|
46
|
+
@manifest ||= AssetManifest.load(@manifest_path)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def logical_path(file)
|
50
50
|
file.relative_path_from(@assets.parent).to_s
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
src
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def index_asset?(asset)
|
61
|
-
asset =~ /\/index\.js$/
|
53
|
+
def with_asset(src, dest)
|
54
|
+
if src != dest
|
55
|
+
src = File.join(@target, src)
|
56
|
+
dest = File.join(@target, dest)
|
57
|
+
|
58
|
+
yield src, dest if File.exists?(src)
|
59
|
+
end
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module TinyMCE
|
2
|
+
module Rails
|
3
|
+
class AssetInstaller
|
4
|
+
class Compile
|
5
|
+
delegate :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
|
6
|
+
|
7
|
+
def initialize(installer)
|
8
|
+
@installer = installer
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
symlink_assets
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def symlink_assets
|
17
|
+
manifest.each(/^tinymce\//) do |asset|
|
18
|
+
manifest.asset_path(asset) do |src, dest|
|
19
|
+
symlink_asset(src, dest)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def symlink_asset(src, dest)
|
25
|
+
with_asset(src, dest) do |src, dest|
|
26
|
+
create_symlink(src, dest)
|
27
|
+
create_symlink("#{src}.gz", "#{dest}.gz") if File.exists?("#{src}.gz")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_symlink(src, dest)
|
32
|
+
target = File.basename(src)
|
33
|
+
|
34
|
+
unless File.exists?(dest) && File.symlink?(dest) && File.readlink(dest) == target
|
35
|
+
logger.info "Creating symlink #{dest}"
|
36
|
+
FileUtils.ln_s(target, dest, :force => true)
|
37
|
+
else
|
38
|
+
logger.debug "Skipping symlink #{dest}, already exists"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module TinyMCE
|
2
|
+
module Rails
|
3
|
+
class AssetInstaller
|
4
|
+
class Copy
|
5
|
+
delegate :assets, :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
|
6
|
+
|
7
|
+
def initialize(installer)
|
8
|
+
@installer = installer
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
cleanup_assets
|
13
|
+
copy_assets
|
14
|
+
append_to_manifest
|
15
|
+
|
16
|
+
manifest.write
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def cleanup_assets
|
21
|
+
manifest.each(/^tinymce\//) do |asset|
|
22
|
+
manifest.remove_digest(asset) do |src, dest|
|
23
|
+
move_asset(src, dest)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_assets
|
29
|
+
logger.info "Copying assets to #{File.join(target, "tinymce")}"
|
30
|
+
FileUtils.cp_r(assets, target, :preserve => true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def append_to_manifest
|
34
|
+
asset_files.each do |file|
|
35
|
+
manifest.append(logical_path(file), file)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def move_asset(src, dest)
|
40
|
+
with_asset(src, dest) do |src, dest|
|
41
|
+
logger.info "Removing digest from #{src}"
|
42
|
+
FileUtils.mv(src, dest, :force => true)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def asset_files
|
47
|
+
Pathname.glob("#{assets}/**/*").select(&:file?)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|