tinymce-rails 6.8.4 → 6.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -4
  3. data/app/assets/source/tinymce/tinymce.js +889 -867
  4. data/lib/tinymce/rails/asset_installer/copy_no_preserve.rb +1 -1
  5. data/lib/tinymce/rails/asset_installer.rb +4 -4
  6. data/lib/tinymce/rails/asset_manifest/json_manifest.rb +62 -0
  7. data/lib/tinymce/rails/asset_manifest/null_manifest.rb +12 -0
  8. data/lib/tinymce/rails/asset_manifest/propshaft_manifest.rb +43 -0
  9. data/lib/tinymce/rails/asset_manifest/yaml_manifest.rb +43 -0
  10. data/lib/tinymce/rails/asset_manifest.rb +6 -108
  11. data/lib/tinymce/rails/engine.rb +15 -2
  12. data/lib/tinymce/rails/helper.rb +19 -5
  13. data/lib/tinymce/rails/propshaft/asset.rb +11 -0
  14. data/lib/tinymce/rails/version.rb +2 -2
  15. data/lib/tinymce/rails.rb +2 -2
  16. data/vendor/assets/javascripts/tinymce/models/dom/model.js +1 -1
  17. data/vendor/assets/javascripts/tinymce/plugins/accordion/plugin.js +1 -1
  18. data/vendor/assets/javascripts/tinymce/plugins/advlist/plugin.js +1 -1
  19. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.js +1 -1
  20. data/vendor/assets/javascripts/tinymce/plugins/autolink/plugin.js +1 -1
  21. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.js +1 -1
  22. data/vendor/assets/javascripts/tinymce/plugins/autosave/plugin.js +1 -1
  23. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.js +1 -1
  24. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.js +1 -1
  25. data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +1 -1
  26. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.js +1 -1
  27. data/vendor/assets/javascripts/tinymce/plugins/emoticons/plugin.js +1 -1
  28. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +1 -1
  29. data/vendor/assets/javascripts/tinymce/plugins/help/plugin.js +1 -1
  30. data/vendor/assets/javascripts/tinymce/plugins/image/plugin.js +1 -1
  31. data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
  32. data/vendor/assets/javascripts/tinymce/plugins/insertdatetime/plugin.js +1 -1
  33. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.js +1 -1
  34. data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +1 -1
  35. data/vendor/assets/javascripts/tinymce/plugins/media/plugin.js +1 -1
  36. data/vendor/assets/javascripts/tinymce/plugins/nonbreaking/plugin.js +1 -1
  37. data/vendor/assets/javascripts/tinymce/plugins/pagebreak/plugin.js +1 -1
  38. data/vendor/assets/javascripts/tinymce/plugins/preview/plugin.js +1 -1
  39. data/vendor/assets/javascripts/tinymce/plugins/quickbars/plugin.js +1 -1
  40. data/vendor/assets/javascripts/tinymce/plugins/save/plugin.js +1 -1
  41. data/vendor/assets/javascripts/tinymce/plugins/searchreplace/plugin.js +1 -1
  42. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +1 -1
  43. data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
  44. data/vendor/assets/javascripts/tinymce/plugins/visualblocks/plugin.js +1 -1
  45. data/vendor/assets/javascripts/tinymce/plugins/visualchars/plugin.js +1 -1
  46. data/vendor/assets/javascripts/tinymce/plugins/wordcount/plugin.js +1 -1
  47. data/vendor/assets/javascripts/tinymce/themes/silver/theme.js +382 -2
  48. data/vendor/assets/javascripts/tinymce/tinymce.js +382 -2
  49. metadata +13 -8
  50. /data/app/assets/{javascripts → sprockets}/tinymce/preinit.js.erb +0 -0
  51. /data/app/assets/{javascripts → sprockets}/tinymce.js +0 -0
@@ -1,4 +1,4 @@
1
- require "tinymce/rails/asset_installer/copy"
1
+ require_relative "copy"
2
2
 
3
3
  module TinyMCE
4
4
  module Rails
@@ -1,8 +1,8 @@
1
- require "tinymce/rails/asset_manifest"
1
+ require_relative "asset_manifest"
2
2
 
3
- require "tinymce/rails/asset_installer/copy"
4
- require "tinymce/rails/asset_installer/copy_no_preserve"
5
- require "tinymce/rails/asset_installer/compile"
3
+ require_relative "asset_installer/copy"
4
+ require_relative "asset_installer/copy_no_preserve"
5
+ require_relative "asset_installer/compile"
6
6
 
7
7
  module TinyMCE
8
8
  module Rails
@@ -0,0 +1,62 @@
1
+ module TinyMCE
2
+ module Rails
3
+ class JsonManifest < AssetManifest
4
+ def self.try(manifest_path, pattern=nil)
5
+ if pattern
6
+ paths = Dir[File.join(manifest_path, pattern)]
7
+ new(paths.first) if paths.any?
8
+ elsif File.file?(manifest_path)
9
+ new(manifest_path)
10
+ end
11
+ end
12
+
13
+ def initialize(file)
14
+ @file = file
15
+ @manifest = JSON.parse(File.read(file))
16
+ end
17
+
18
+ def append(logical_path, file)
19
+ stat = File.stat(file)
20
+
21
+ assets[logical_path] = logical_path
22
+ files[logical_path] = {
23
+ "logical_path" => logical_path,
24
+ "mtime" => stat.mtime.iso8601,
25
+ "size" => stat.size,
26
+ "digest" => nil
27
+ }
28
+ end
29
+
30
+ def remove(logical_path)
31
+ if digested = assets.delete(logical_path)
32
+ files.delete(digested)
33
+ end
34
+ end
35
+
36
+ def remove_digest(logical_path)
37
+ asset_path(logical_path) do |digested, logical_path|
38
+ assets[logical_path] = logical_path
39
+ files[logical_path] = files.delete(digested).tap { |f| f["digest"] = nil }
40
+
41
+ yield digested, logical_path if block_given?
42
+ end
43
+ end
44
+
45
+ def assets
46
+ @manifest["assets"]
47
+ end
48
+
49
+ def files
50
+ @manifest["files"]
51
+ end
52
+
53
+ def dump
54
+ JSON.generate(@manifest)
55
+ end
56
+
57
+ def write
58
+ File.open(@file, "wb") { |f| f.write(dump) }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,12 @@
1
+ module TinyMCE
2
+ module Rails
3
+ class NullManifest < AssetManifest
4
+ def append(*); end
5
+ def remove(*); end
6
+ def remove_digest(*); end
7
+ def assets; {}; end
8
+ def each(*); end
9
+ def write; end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,43 @@
1
+ module TinyMCE
2
+ module Rails
3
+ class PropshaftManifest < AssetManifest
4
+ def self.try(manifest_path)
5
+ json_file = File.join(manifest_path, ".manifest.json")
6
+ new(json_file) if File.exist?(json_file)
7
+ end
8
+
9
+ def initialize(file)
10
+ @file = file
11
+ @manifest = JSON.parse(File.read(file))
12
+ end
13
+
14
+ def append(logical_path, file)
15
+ assets[logical_path] = logical_path
16
+ end
17
+
18
+ def remove(logical_path)
19
+ assets.delete(logical_path)
20
+ end
21
+
22
+ def remove_digest(logical_path)
23
+ asset_path(logical_path) do |digested, logical_path|
24
+ assets[logical_path] = logical_path
25
+
26
+ yield digested, logical_path if block_given?
27
+ end
28
+ end
29
+
30
+ def assets
31
+ @manifest
32
+ end
33
+
34
+ def dump
35
+ JSON.generate(@manifest)
36
+ end
37
+
38
+ def write
39
+ File.open(@file, "wb") { |f| f.write(dump) }
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ module TinyMCE
2
+ module Rails
3
+ class YamlManifest < AssetManifest
4
+ def self.try(manifest_path)
5
+ yaml_file = File.join(manifest_path, "manifest.yml")
6
+ new(yaml_file) if File.exist?(yaml_file)
7
+ end
8
+
9
+ def initialize(file)
10
+ @file = file
11
+ @manifest = YAML.load_file(file)
12
+ end
13
+
14
+ def append(logical_path, file)
15
+ assets[logical_path] = logical_path
16
+ end
17
+
18
+ def remove(logical_path)
19
+ assets.delete(logical_path)
20
+ end
21
+
22
+ def remove_digest(logical_path)
23
+ asset_path(logical_path) do |digested, logical_path|
24
+ assets[logical_path] = logical_path
25
+
26
+ yield digested, logical_path if block_given?
27
+ end
28
+ end
29
+
30
+ def assets
31
+ @manifest
32
+ end
33
+
34
+ def dump(io=nil)
35
+ YAML.dump(@manifest, io)
36
+ end
37
+
38
+ def write
39
+ File.open(@file, "wb") { |f| dump(f) }
40
+ end
41
+ end
42
+ end
43
+ end
@@ -4,7 +4,8 @@ module TinyMCE
4
4
  attr_reader :file
5
5
 
6
6
  def self.load(manifest_path)
7
- JsonManifest.try(manifest_path, ".sprockets-manifest*.json") ||
7
+ PropshaftManifest.try(manifest_path) ||
8
+ JsonManifest.try(manifest_path, ".sprockets-manifest*.json") ||
8
9
  JsonManifest.try(manifest_path, "manifest*.json") ||
9
10
  JsonManifest.try(manifest_path) ||
10
11
  YamlManifest.try(manifest_path) ||
@@ -35,112 +36,9 @@ module TinyMCE
35
36
  end
36
37
  end
37
38
 
38
- class YamlManifest < AssetManifest
39
- def self.try(manifest_path)
40
- yaml_file = File.join(manifest_path, "manifest.yml")
41
- new(yaml_file) if File.exist?(yaml_file)
42
- end
43
-
44
- def initialize(file)
45
- @file = file
46
- @manifest = YAML.load_file(file)
47
- end
48
-
49
- def append(logical_path, file)
50
- assets[logical_path] = logical_path
51
- end
52
-
53
- def remove(logical_path)
54
- assets.delete(logical_path)
55
- end
56
-
57
- def remove_digest(logical_path)
58
- asset_path(logical_path) do |digested, logical_path|
59
- assets[logical_path] = logical_path
60
-
61
- yield digested, logical_path if block_given?
62
- end
63
- end
64
-
65
- def assets
66
- @manifest
67
- end
68
-
69
- def dump(io=nil)
70
- YAML.dump(@manifest, io)
71
- end
72
-
73
- def write
74
- File.open(@file, "wb") { |f| dump(f) }
75
- end
76
- end
77
-
78
- class JsonManifest < AssetManifest
79
- def self.try(manifest_path, pattern=nil)
80
- if pattern
81
- paths = Dir[File.join(manifest_path, pattern)]
82
- new(paths.first) if paths.any?
83
- elsif File.file?(manifest_path)
84
- new(manifest_path)
85
- end
86
- end
87
-
88
- def initialize(file)
89
- @file = file
90
- @manifest = JSON.parse(File.read(file))
91
- end
92
-
93
- def append(logical_path, file)
94
- stat = File.stat(file)
95
-
96
- assets[logical_path] = logical_path
97
- files[logical_path] = {
98
- "logical_path" => logical_path,
99
- "mtime" => stat.mtime.iso8601,
100
- "size" => stat.size,
101
- "digest" => nil
102
- }
103
- end
104
-
105
- def remove(logical_path)
106
- if digested = assets.delete(logical_path)
107
- files.delete(digested)
108
- end
109
- end
110
-
111
- def remove_digest(logical_path)
112
- asset_path(logical_path) do |digested, logical_path|
113
- assets[logical_path] = logical_path
114
- files[logical_path] = files.delete(digested).tap { |f| f["digest"] = nil }
115
-
116
- yield digested, logical_path if block_given?
117
- end
118
- end
119
-
120
- def assets
121
- @manifest["assets"]
122
- end
123
-
124
- def files
125
- @manifest["files"]
126
- end
127
-
128
- def dump
129
- JSON.generate(@manifest)
130
- end
131
-
132
- def write
133
- File.open(@file, "wb") { |f| f.write(dump) }
134
- end
135
- end
136
-
137
- class NullManifest < AssetManifest
138
- def append(*); end
139
- def remove(*); end
140
- def remove_digest(*); end
141
- def assets; {}; end
142
- def each(*); end
143
- def write; end
144
- end
39
+ require_relative "asset_manifest/json_manifest"
40
+ require_relative "asset_manifest/null_manifest"
41
+ require_relative "asset_manifest/propshaft_manifest"
42
+ require_relative "asset_manifest/yaml_manifest"
145
43
  end
146
44
  end
@@ -13,14 +13,27 @@ module TinyMCE::Rails
13
13
  # :copy - copies across the TinyMCE assets statically
14
14
  config.tinymce.install = :compile
15
15
 
16
+ # Set default attributes for script source tags (defaults to data-turbolinks-track="reload" for backwards compatibility)
17
+ config.tinymce.default_script_attributes = { "data-turbolinks-track" => "reload" }
18
+
16
19
  initializer "precompile", :group => :all do |app|
17
20
  if config.tinymce.install == :compile
18
21
  app.config.assets.precompile << "tinymce-rails.manifest.js" # Sprockets 4 manifest
19
22
  app.config.assets.precompile << "tinymce/*" # Sprockets 3
20
23
  end
21
24
 
22
- app.config.assets.precompile << "tinymce.js"
23
- end
25
+ app.config.assets.precompile << "tinymce.js" << "tinymce-jquery.js"
26
+ end if defined?(Sprockets)
27
+
28
+ initializer "propshaft" do |app|
29
+ config.assets.excluded_paths << root.join("app/assets/sprockets")
30
+
31
+ if config.assets.server
32
+ # Monkey-patch Propshaft::Asset to enable access
33
+ # of TinyMCE assets without a hash digest.
34
+ require_relative "propshaft/asset"
35
+ end
36
+ end if defined?(Propshaft)
24
37
 
25
38
  initializer "helper" do |app|
26
39
  ActiveSupport.on_load(:action_view) do
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/hash/keys'
1
+ require "active_support/core_ext/hash/keys"
2
2
 
3
3
  module TinyMCE::Rails
4
4
  module Helper
@@ -63,13 +63,27 @@ module TinyMCE::Rails
63
63
  end
64
64
 
65
65
  # Includes TinyMCE javascript assets via a script tag.
66
- def tinymce_assets
67
- javascript_include_tag "tinymce", "data-turbolinks-track" => "reload"
66
+ def tinymce_assets(options=Rails.application.config.tinymce.default_script_attributes)
67
+ if defined?(Sprockets)
68
+ javascript_include_tag("tinymce", options)
69
+ else
70
+ safe_join([
71
+ tinymce_preinit,
72
+ javascript_include_tag("tinymce/tinymce", options),
73
+ javascript_include_tag("tinymce/rails", options)
74
+ ], "\n")
75
+ end
76
+ end
77
+
78
+ # Configures where dynamically loaded TinyMCE assets are located and named
79
+ def tinymce_preinit(base=TinyMCE::Rails::Engine.base)
80
+ js = "window.tinymce = window.tinymce || { base: '#{base}', suffix: '' };"
81
+ javascript_tag(js, nonce: true)
68
82
  end
69
83
 
70
84
  # Allow methods to be called as module functions:
71
85
  # e.g. TinyMCE::Rails.tinymce_javascript
72
- module_function :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration
73
- public :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration
86
+ module_function :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration, :tinymce_preinit
87
+ public :tinymce, :tinymce_javascript, :tinymce_configurations_javascript, :tinymce_configuration, :tinymce_preinit
74
88
  end
75
89
  end
@@ -0,0 +1,11 @@
1
+ require "propshaft/asset"
2
+
3
+ class Propshaft::Asset
4
+ alias fresh_without_tinymce_exception? fresh?
5
+
6
+ # Allow TinyMCE assets to be accessed (in development mode) without a digest
7
+ def fresh?(digest)
8
+ fresh_without_tinymce_exception?(digest) ||
9
+ (digest.blank? && logical_path.to_s.starts_with?("tinymce/"))
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  module TinyMCE
2
2
  module Rails
3
- VERSION = "6.8.4"
4
- TINYMCE_VERSION = "6.8.4"
3
+ VERSION = "6.8.5"
4
+ TINYMCE_VERSION = "6.8.5"
5
5
  end
6
6
  end
data/lib/tinymce/rails.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module TinyMCE
2
2
  module Rails
3
- require 'tinymce/rails/engine'
4
- require 'tinymce/rails/version'
3
+ require "tinymce/rails/engine"
4
+ require "tinymce/rails/version"
5
5
  require "tinymce/rails/configuration"
6
6
  require "tinymce/rails/configuration_file"
7
7
  require "tinymce/rails/helper"