tinymce-rails 4.5.6 → 4.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -2
- data/app/assets/javascripts/tinymce/preinit.js.erb +0 -6
- data/app/assets/javascripts/tinymce/rails.js +51 -0
- data/app/assets/javascripts/tinymce-jquery.js +1 -2
- data/app/assets/javascripts/tinymce.js +1 -0
- data/app/assets/source/tinymce/tinymce.js +27440 -49212
- data/lib/tinymce/rails/asset_installer/compile.rb +6 -6
- data/lib/tinymce/rails/asset_installer/copy.rb +11 -9
- data/lib/tinymce/rails/asset_installer/copy_no_preserve.rb +14 -0
- data/lib/tinymce/rails/asset_installer.rb +11 -10
- data/lib/tinymce/rails/asset_manifest.rb +25 -25
- data/lib/tinymce/rails/configuration.rb +86 -29
- data/lib/tinymce/rails/configuration_file.rb +11 -11
- data/lib/tinymce/rails/engine.rb +5 -1
- data/lib/tinymce/rails/helper.rb +29 -17
- data/lib/tinymce/rails/version.rb +2 -2
- data/lib/tinymce/rails.rb +8 -0
- data/vendor/assets/config/tinymce-rails.manifest.js +8 -0
- data/vendor/assets/javascripts/tinymce/jquery.tinymce.js +1 -1
- data/vendor/assets/javascripts/tinymce/license.txt +6 -6
- data/vendor/assets/javascripts/tinymce/plugins/advlist/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autolink/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/autosave/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/bbcode/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/code/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/codesample/css/prism.css +46 -46
- data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/colorpicker/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/contextmenu/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/emoticons/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/fullpage/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/help/img/logo.png +0 -0
- data/vendor/assets/javascripts/tinymce/plugins/help/plugin.js +1 -0
- data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/image/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/imagetools/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/insertdatetime/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/legacyoutput/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/link/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/media/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/nonbreaking/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/noneditable/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/pagebreak/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/preview/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/print/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/save/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/searchreplace/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/spellchecker/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +1 -2
- data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/textcolor/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/textpattern/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/toc/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/visualblocks/css/visualblocks.css +95 -76
- data/vendor/assets/javascripts/tinymce/plugins/visualblocks/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/visualchars/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/plugins/wordcount/plugin.js +1 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/content.inline.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/content.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/content.mobile.min.css +1 -0
- data/vendor/assets/javascripts/tinymce/skins/lightgray/fonts/tinymce-mobile.woff +0 -0
- data/vendor/assets/javascripts/tinymce/skins/lightgray/fonts/tinymce.eot +0 -0
- data/vendor/assets/javascripts/tinymce/skins/lightgray/fonts/tinymce.svg +2 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/fonts/tinymce.ttf +0 -0
- data/vendor/assets/javascripts/tinymce/skins/lightgray/fonts/tinymce.woff +0 -0
- data/vendor/assets/javascripts/tinymce/skins/lightgray/skin.min.css +1 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/skin.mobile.min.css +2 -0
- data/vendor/assets/javascripts/tinymce/themes/inlite/theme.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/mobile/theme.js +1 -0
- data/vendor/assets/javascripts/tinymce/themes/modern/theme.js +1 -1
- data/vendor/assets/javascripts/tinymce/tinymce.js +2 -14
- metadata +12 -10
- data/vendor/assets/javascripts/tinymce/plugins/example/dialog.html +0 -8
- data/vendor/assets/javascripts/tinymce/plugins/example/plugin.js +0 -1
- data/vendor/assets/javascripts/tinymce/plugins/example_dependency/plugin.js +0 -1
- data/vendor/assets/javascripts/tinymce/plugins/layer/plugin.js +0 -1
- data/vendor/assets/javascripts/tinymce/skins/lightgray/skin.ie7.min.css +0 -1
@@ -3,15 +3,15 @@ module TinyMCE
|
|
3
3
|
class AssetInstaller
|
4
4
|
class Compile
|
5
5
|
delegate :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(installer)
|
8
8
|
@installer = installer
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def call
|
12
12
|
symlink_assets
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
private
|
16
16
|
def symlink_assets
|
17
17
|
manifest.each(/^tinymce\//) do |asset|
|
@@ -20,17 +20,17 @@ module TinyMCE
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def symlink_asset(src, dest)
|
25
25
|
with_asset(src, dest) do |src, dest|
|
26
26
|
create_symlink(src, dest)
|
27
27
|
create_symlink("#{src}.gz", "#{dest}.gz") if File.exists?("#{src}.gz")
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def create_symlink(src, dest)
|
32
32
|
target = File.basename(src)
|
33
|
-
|
33
|
+
|
34
34
|
unless File.exists?(dest) && File.symlink?(dest) && File.readlink(dest) == target
|
35
35
|
logger.info "Creating symlink #{dest}"
|
36
36
|
FileUtils.ln_s(target, dest, :force => true)
|
@@ -3,19 +3,19 @@ module TinyMCE
|
|
3
3
|
class AssetInstaller
|
4
4
|
class Copy
|
5
5
|
delegate :assets, :target, :manifest, :logger, :logical_path, :with_asset, :to => :@installer
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(installer)
|
8
8
|
@installer = installer
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def call
|
12
12
|
cleanup_assets
|
13
13
|
copy_assets
|
14
14
|
append_to_manifest
|
15
|
-
|
15
|
+
|
16
16
|
manifest.write
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
private
|
20
20
|
def cleanup_assets
|
21
21
|
manifest.each(/^tinymce\//) do |asset|
|
@@ -24,25 +24,27 @@ module TinyMCE
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def copy_assets
|
29
|
-
logger.info "Copying assets to #{File.join(target, "tinymce")}"
|
29
|
+
logger.info "Copying assets (preserving modes) to #{File.join(target, "tinymce")}"
|
30
30
|
FileUtils.cp_r(assets, target, :preserve => true)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def append_to_manifest
|
34
34
|
asset_files.each do |file|
|
35
35
|
manifest.append(logical_path(file), file)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def move_asset(src, dest)
|
40
40
|
with_asset(src, dest) do |src, dest|
|
41
41
|
logger.info "Removing digest from #{src}"
|
42
|
+
|
43
|
+
FileUtils.rm(dest) if File.exist?(dest)
|
42
44
|
FileUtils.mv(src, dest, :force => true)
|
43
45
|
end
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
def asset_files
|
47
49
|
Pathname.glob("#{assets}/**/*").select(&:file?)
|
48
50
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "tinymce/rails/asset_installer/copy"
|
2
|
+
|
3
|
+
module TinyMCE
|
4
|
+
module Rails
|
5
|
+
class AssetInstaller
|
6
|
+
class CopyNoPreserve < Copy
|
7
|
+
def copy_assets
|
8
|
+
logger.info "Copying assets (without preserving modes) to #{File.join(target, "tinymce")}"
|
9
|
+
FileUtils.cp_r(assets, target)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "tinymce/rails/asset_manifest"
|
2
2
|
|
3
3
|
require "tinymce/rails/asset_installer/copy"
|
4
|
+
require "tinymce/rails/asset_installer/copy_no_preserve"
|
4
5
|
require "tinymce/rails/asset_installer/compile"
|
5
6
|
|
6
7
|
module TinyMCE
|
@@ -8,20 +9,20 @@ module TinyMCE
|
|
8
9
|
class AssetInstaller
|
9
10
|
attr_reader :assets, :target, :strategy
|
10
11
|
attr_accessor :logger
|
11
|
-
|
12
|
+
|
12
13
|
def initialize(assets, target, manifest_path)
|
13
14
|
@assets = assets
|
14
15
|
@target = target
|
15
16
|
@manifest_path = manifest_path || target
|
16
|
-
|
17
|
+
|
17
18
|
@logger = Logger.new($stderr)
|
18
19
|
@logger.level = Logger::INFO
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
def install
|
22
23
|
(strategy || Copy).new(self).call
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
def log_level
|
26
27
|
@logger.level
|
27
28
|
end
|
@@ -33,28 +34,28 @@ module TinyMCE
|
|
33
34
|
@logger.level = Logger.const_get(level.to_s.upcase)
|
34
35
|
end
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
def strategy=(strategy)
|
38
39
|
if strategy.is_a?(Class)
|
39
40
|
@strategy = strategy
|
40
41
|
else
|
41
|
-
@strategy = self.class.const_get(strategy.to_s.
|
42
|
+
@strategy = self.class.const_get(strategy.to_s.classify)
|
42
43
|
end
|
43
44
|
end
|
44
|
-
|
45
|
+
|
45
46
|
def manifest
|
46
47
|
@manifest ||= AssetManifest.load(@manifest_path)
|
47
48
|
end
|
48
|
-
|
49
|
+
|
49
50
|
def logical_path(file)
|
50
51
|
file.relative_path_from(@assets.parent).to_s
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
def with_asset(src, dest)
|
54
55
|
if src != dest
|
55
56
|
src = File.join(@target, src)
|
56
57
|
dest = File.join(@target, dest)
|
57
|
-
|
58
|
+
|
58
59
|
yield src, dest if File.exists?(src)
|
59
60
|
end
|
60
61
|
end
|
@@ -9,7 +9,7 @@ module TinyMCE
|
|
9
9
|
YamlManifest.try(manifest_path) ||
|
10
10
|
NullManifest.new
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def each(pattern)
|
14
14
|
assets.each_key do |asset|
|
15
15
|
if asset =~ pattern && !index_asset?(asset)
|
@@ -17,77 +17,77 @@ module TinyMCE
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def asset_path(logical_path)
|
22
22
|
if digested = assets[logical_path]
|
23
23
|
yield digested, logical_path if block_given?
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def to_s
|
28
28
|
dump
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
protected
|
32
32
|
def index_asset?(asset)
|
33
33
|
asset =~ /\/index[^\/]*\.\w+$/
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
class YamlManifest < AssetManifest
|
38
38
|
def self.try(manifest_path)
|
39
39
|
yaml_file = File.join(manifest_path, "manifest.yml")
|
40
40
|
new(yaml_file) if File.exists?(yaml_file)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def initialize(file)
|
44
44
|
@file = file
|
45
45
|
@manifest = YAML.load_file(file)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def append(logical_path, file)
|
49
49
|
assets[logical_path] = logical_path
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def remove(logical_path)
|
53
53
|
assets.delete(logical_path)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def remove_digest(logical_path)
|
57
57
|
asset_path(logical_path) do |digested, logical_path|
|
58
58
|
assets[logical_path] = logical_path
|
59
|
-
|
59
|
+
|
60
60
|
yield digested, logical_path if block_given?
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def assets
|
65
65
|
@manifest
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def dump(io=nil)
|
69
69
|
YAML.dump(@manifest, io)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
def write
|
73
73
|
File.open(@file, "wb") { |f| dump(f) }
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
class JsonManifest < AssetManifest
|
78
78
|
def self.try(manifest_path, pattern)
|
79
79
|
paths = Dir[File.join(manifest_path, pattern)]
|
80
80
|
new(paths.first) if paths.any?
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
def initialize(file)
|
84
84
|
@file = file
|
85
85
|
@manifest = JSON.parse(File.read(file))
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def append(logical_path, file)
|
89
89
|
stat = File.stat(file)
|
90
|
-
|
90
|
+
|
91
91
|
assets[logical_path] = logical_path
|
92
92
|
files[logical_path] = {
|
93
93
|
"logical_path" => logical_path,
|
@@ -96,39 +96,39 @@ module TinyMCE
|
|
96
96
|
"digest" => nil
|
97
97
|
}
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
def remove(logical_path)
|
101
101
|
if digested = assets.delete(logical_path)
|
102
102
|
files.delete(digested)
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
def remove_digest(logical_path)
|
107
107
|
asset_path(logical_path) do |digested, logical_path|
|
108
108
|
assets[logical_path] = logical_path
|
109
109
|
files[logical_path] = files.delete(digested).tap { |f| f["digest"] = nil }
|
110
|
-
|
110
|
+
|
111
111
|
yield digested, logical_path if block_given?
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def assets
|
116
116
|
@manifest["assets"]
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
def files
|
120
120
|
@manifest["files"]
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
def dump
|
124
124
|
JSON.generate(@manifest)
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
def write
|
128
128
|
File.open(@file, "wb") { |f| f.write(dump) }
|
129
129
|
end
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
class NullManifest < AssetManifest
|
133
133
|
def append(*); end
|
134
134
|
def remove(*); end
|
@@ -7,17 +7,20 @@ module TinyMCE::Rails
|
|
7
7
|
self
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def self.defaults
|
12
12
|
{
|
13
13
|
"selector" => "textarea.tinymce"
|
14
14
|
}
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
FUNCTION_REGEX = /^function\s*\(/
|
18
|
+
RELATIVE_PATH_REGEX = /^(\/|\.{1,2})\S*/
|
19
|
+
|
17
20
|
COMMA = ",".freeze
|
18
21
|
SPACE = " ".freeze
|
19
22
|
SEMICOLON = ";".freeze
|
20
|
-
|
23
|
+
|
21
24
|
OPTION_SEPARATORS = {
|
22
25
|
"plugins" => COMMA,
|
23
26
|
"custom_elements" => COMMA,
|
@@ -39,60 +42,114 @@ module TinyMCE::Rails
|
|
39
42
|
"paste_retain_style_properties" => SPACE,
|
40
43
|
"spellchecker_languages" => COMMA
|
41
44
|
}
|
42
|
-
|
45
|
+
|
46
|
+
OPTION_TRANSFORMERS = {
|
47
|
+
# Check for files provided in the content_css option to replace them with their actual path.
|
48
|
+
# If no corresponding stylesheet is found for a file, it will remain unchanged.
|
49
|
+
"content_css" => ->(value) {
|
50
|
+
helpers = ActionView::Base.new(ActionView::LookupContext.new([]))
|
51
|
+
separator = OPTION_SEPARATORS["content_css"]
|
52
|
+
|
53
|
+
value.split(separator).map { |file|
|
54
|
+
next file if RELATIVE_PATH_REGEX =~ file
|
55
|
+
helpers.stylesheet_path(file.strip) || file
|
56
|
+
}.join(separator)
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
43
60
|
attr_reader :options
|
44
|
-
|
61
|
+
|
45
62
|
def initialize(options)
|
46
63
|
@options = options
|
47
64
|
end
|
48
|
-
|
65
|
+
|
49
66
|
def self.new_with_defaults(options={})
|
50
67
|
config = new(defaults)
|
51
68
|
config = config.merge(options) if options
|
52
69
|
config
|
53
70
|
end
|
54
|
-
|
71
|
+
|
72
|
+
# Converts options into a String representing a JavaScript object
|
73
|
+
# that can be passed directly to tinyMCE.init
|
74
|
+
def to_javascript
|
75
|
+
options_to_javascript(options_for_tinymce)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Converts options into a TinyMCE-friendly format.
|
79
|
+
#
|
80
|
+
# 1. Joins array values using OPTION_SEPARATORS
|
81
|
+
# 2. Converts JavaScript function() strings to Function objects
|
82
|
+
# 3. Applies transformations from OPTION_TRANSFORMERS
|
55
83
|
def options_for_tinymce
|
84
|
+
preprocess_options(options)
|
85
|
+
end
|
86
|
+
|
87
|
+
def merge(options)
|
88
|
+
self.class.new(self.options.merge(options))
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
def array_option?(key, value)
|
93
|
+
value.is_a?(Array) && OPTION_SEPARATORS[key]
|
94
|
+
end
|
95
|
+
|
96
|
+
def function_option?(value)
|
97
|
+
FUNCTION_REGEX =~ value.to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
def preprocess_options(options)
|
56
101
|
result = {}
|
57
|
-
|
102
|
+
|
58
103
|
options.each do |key, value|
|
59
|
-
|
60
|
-
result[key] = value.join(OPTION_SEPARATORS[key])
|
61
|
-
elsif value.to_s.starts_with?("function(")
|
62
|
-
result[key] = Function.new(value)
|
63
|
-
else
|
64
|
-
result[key] = value
|
65
|
-
end
|
104
|
+
result[key] = preprocess_option(key, value)
|
66
105
|
end
|
67
|
-
|
106
|
+
|
68
107
|
result
|
69
108
|
end
|
70
|
-
|
71
|
-
def
|
72
|
-
|
73
|
-
|
109
|
+
|
110
|
+
def preprocess_option(key, value)
|
111
|
+
result = value
|
112
|
+
|
113
|
+
if result.is_a?(Hash)
|
114
|
+
result = preprocess_options(value)
|
115
|
+
elsif array_option?(key, value)
|
116
|
+
result = value.join(OPTION_SEPARATORS[key])
|
117
|
+
elsif function_option?(value)
|
118
|
+
result = Function.new(value)
|
119
|
+
end
|
120
|
+
|
121
|
+
if transformer = OPTION_TRANSFORMERS[key]
|
122
|
+
result = transformer.call(result)
|
123
|
+
end
|
124
|
+
|
125
|
+
result
|
126
|
+
end
|
127
|
+
|
128
|
+
def options_to_javascript(options, indent="")
|
129
|
+
next_indent = indent + " "
|
130
|
+
|
131
|
+
pairs = options.inject([]) do |result, (k, v)|
|
132
|
+
if v.is_a?(Hash)
|
133
|
+
v = options_to_javascript(v, next_indent)
|
134
|
+
elsif v.respond_to?(:to_javascript)
|
74
135
|
v = v.to_javascript
|
75
136
|
elsif v.respond_to?(:to_json)
|
76
137
|
v = v.to_json
|
77
138
|
end
|
78
|
-
|
139
|
+
|
79
140
|
result << [k, v].join(": ")
|
80
141
|
end
|
81
|
-
|
82
|
-
"{\n
|
83
|
-
end
|
84
|
-
|
85
|
-
def merge(options)
|
86
|
-
self.class.new(self.options.merge(options))
|
142
|
+
|
143
|
+
"{\n#{next_indent}#{pairs.join(",\n#{next_indent}")}\n#{indent}}"
|
87
144
|
end
|
88
145
|
end
|
89
|
-
|
146
|
+
|
90
147
|
class MultipleConfiguration < ActiveSupport::HashWithIndifferentAccess
|
91
148
|
def initialize(configurations={})
|
92
149
|
configurations = configurations.each_with_object({}) { |(name, options), h|
|
93
150
|
h[name] = Configuration.new_with_defaults(options)
|
94
151
|
}
|
95
|
-
|
152
|
+
|
96
153
|
super(configurations)
|
97
154
|
end
|
98
155
|
end
|
@@ -1,47 +1,47 @@
|
|
1
1
|
module TinyMCE::Rails
|
2
2
|
class ConfigurationFile
|
3
3
|
attr_reader :path
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(path)
|
6
6
|
@path = path
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def configuration
|
10
10
|
@configuration = load_configuration if reload?
|
11
11
|
@configuration
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def reload?
|
15
15
|
@configuration.nil? || (reloadable? && changed?)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def changed?
|
19
19
|
@last_loaded != last_updated
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
private
|
23
23
|
def reloadable?
|
24
24
|
!::Rails.application.config.cache_classes
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def last_updated
|
28
28
|
File.exists?(path) && File.mtime(path)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def load_configuration
|
32
32
|
@last_loaded = last_updated
|
33
|
-
|
33
|
+
|
34
34
|
return Configuration.new_with_defaults if !File.exists?(path)
|
35
|
-
|
35
|
+
|
36
36
|
options = load_yaml(path)
|
37
|
-
|
37
|
+
|
38
38
|
if options && options.has_key?('default')
|
39
39
|
MultipleConfiguration.new(options)
|
40
40
|
else
|
41
41
|
Configuration.new_with_defaults(options)
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def load_yaml(path)
|
46
46
|
YAML::load(ERB.new(IO.read(path)).result)
|
47
47
|
end
|
data/lib/tinymce/rails/engine.rb
CHANGED
@@ -14,7 +14,11 @@ module TinyMCE::Rails
|
|
14
14
|
config.tinymce.install = :compile
|
15
15
|
|
16
16
|
initializer "precompile", :group => :all do |app|
|
17
|
-
|
17
|
+
if config.tinymce.install == :compile
|
18
|
+
app.config.assets.precompile << "tinymce-rails.manifest.js" # Sprockets 4 manifest
|
19
|
+
app.config.assets.precompile << "tinymce/*" # Sprockets 3
|
20
|
+
end
|
21
|
+
|
18
22
|
app.config.assets.precompile << "tinymce.js"
|
19
23
|
end
|
20
24
|
|
data/lib/tinymce/rails/helper.rb
CHANGED
@@ -14,26 +14,37 @@ module TinyMCE::Rails
|
|
14
14
|
# override these defaults.
|
15
15
|
#
|
16
16
|
# @example
|
17
|
-
# <%= tinymce(:
|
17
|
+
# <%= tinymce(selector: "editorClass", theme: "inlite") %>
|
18
18
|
def tinymce(config=:default, options={})
|
19
|
-
javascript_tag
|
19
|
+
javascript_tag(nonce: true) do
|
20
|
+
unless @_tinymce_configurations_added
|
21
|
+
concat tinymce_configurations_javascript
|
22
|
+
concat "\n"
|
23
|
+
@_tinymce_configurations_added = true
|
24
|
+
end
|
25
|
+
|
26
|
+
concat tinymce_javascript(config, options)
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
# Returns the JavaScript code required to initialize TinyMCE.
|
23
31
|
def tinymce_javascript(config=:default, options={})
|
24
|
-
|
25
|
-
(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
options, config = config, :default if config.is_a?(Hash)
|
33
|
+
options = Configuration.new(options)
|
34
|
+
|
35
|
+
"TinyMCERails.initialize('#{config}', #{options.to_javascript});".html_safe
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the JavaScript code for initializing each configuration defined within tinymce.yml.
|
39
|
+
def tinymce_configurations_javascript(options={})
|
40
|
+
javascript = []
|
41
|
+
|
42
|
+
TinyMCE::Rails.each_configuration do |name, config|
|
43
|
+
config = config.merge(options) if options.present?
|
44
|
+
javascript << "TinyMCERails.configuration.#{name} = #{config.to_javascript};".html_safe
|
45
|
+
end
|
46
|
+
|
47
|
+
safe_join(javascript, "\n")
|
37
48
|
end
|
38
49
|
|
39
50
|
# Returns the TinyMCE configuration object.
|
@@ -53,11 +64,12 @@ module TinyMCE::Rails
|
|
53
64
|
|
54
65
|
# Includes TinyMCE javascript assets via a script tag.
|
55
66
|
def tinymce_assets
|
56
|
-
javascript_include_tag "tinymce"
|
67
|
+
javascript_include_tag "tinymce", "data-turbolinks-track" => "reload"
|
57
68
|
end
|
58
69
|
|
59
70
|
# Allow methods to be called as module functions:
|
60
71
|
# e.g. TinyMCE::Rails.tinymce_javascript
|
61
|
-
module_function :tinymce, :tinymce_javascript, :tinymce_configuration
|
72
|
+
module_function :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration
|
73
|
+
public :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration
|
62
74
|
end
|
63
75
|
end
|
data/lib/tinymce/rails.rb
CHANGED
@@ -15,5 +15,13 @@ module TinyMCE
|
|
15
15
|
def self.configuration=(configuration)
|
16
16
|
@configuration = configuration
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.each_configuration(&block)
|
20
|
+
if configuration.is_a?(MultipleConfiguration)
|
21
|
+
configuration.each(&block)
|
22
|
+
else
|
23
|
+
yield :default, configuration
|
24
|
+
end
|
25
|
+
end
|
18
26
|
end
|
19
27
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
//= link_tree ../javascripts/tinymce .js
|
2
|
+
//= link_tree ../javascripts/tinymce .css
|
3
|
+
//= link_tree ../javascripts/tinymce .png
|
4
|
+
//= link_tree ../javascripts/tinymce .gif
|
5
|
+
//= link_tree ../javascripts/tinymce .ttf
|
6
|
+
//= link_tree ../javascripts/tinymce .svg
|
7
|
+
//= link_tree ../javascripts/tinymce .woff
|
8
|
+
//= link_tree ../javascripts/tinymce .eot
|