ckeditor5 1.28.0 → 1.28.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39c0b30fe11a1a335c30f52c445b61480286c61271c74114989f1cca4bed2ef7
4
- data.tar.gz: 2b11f4b5e0a642fd277b05113f4e01bf0549be9ae99106b0bbf300e6f9b709ab
3
+ metadata.gz: 7c28d638338e7bdb2e029d6eb1a81a65126dfbe16b31828563e5d7a0efc3a51e
4
+ data.tar.gz: c87327aa99851db71ff50f0d12c606c58194b3840a4c13eb99e7ca22c6e87734
5
5
  SHA512:
6
- metadata.gz: 95dbd7fdd830669bd3e9598cfd99ae59455080b49a990c04bc52c4aa3ff79d76875fff04d02375540e293c64c0b51cf6b687df7d1524c7d825fbef7bffe38ee3
7
- data.tar.gz: 827c5a2e54a22d9d6be3fdf41d5fe51537b94667769e1dae5cfa9b0cc80075b3a16496c9d1ac3c147002ab1e8bb807551cbe085c76b3e13f1a0336287a2d2e6f
6
+ metadata.gz: 015fd8f7850a4620aa13d62c8ffee059a417fb8d6e2808f3699753843eb99eeb7c281ee03c949e0bf3458690a406d9854e56190bc0960dd1e2729f4ef56a008b
7
+ data.tar.gz: 914079678cd53137163f389df3d6a2a42992b7c1f9d84cdd6cd628b878973210eb442de79c5bea4b8cc7e01b0f05534afe0763fdd56534e3c4041c8703d20776
@@ -32,16 +32,34 @@ module CKEditor5::Rails::Assets
32
32
 
33
33
  def to_json(*_args)
34
34
  {
35
- scripts: scripts.map(&:to_h),
36
- stylesheets: stylesheets
35
+ scripts: unique_scripts(scripts).map(&:to_h),
36
+ stylesheets: unique_stylesheets(stylesheets)
37
37
  }.to_json
38
38
  end
39
39
 
40
40
  def <<(other)
41
41
  raise TypeError, 'other must be an instance of AssetsBundle' unless other.is_a?(AssetsBundle)
42
42
 
43
- @scripts = scripts + other.scripts
44
- @stylesheets = stylesheets + other.stylesheets
43
+ @scripts = unique_scripts(scripts + other.scripts)
44
+ @stylesheets = unique_stylesheets(stylesheets + other.stylesheets)
45
+ end
46
+
47
+ private
48
+
49
+ def unique_scripts(scripts_array)
50
+ with_url, without_url = scripts_array.partition { |script| script.respond_to?(:url) && script.url }
51
+ unique_with_url = with_url.uniq { |script| drop_version_from_url(script.url) }
52
+ unique_with_url + without_url
53
+ end
54
+
55
+ def unique_stylesheets(stylesheets_array)
56
+ stylesheets_array.uniq { |stylesheet| drop_version_from_url(stylesheet) }
57
+ end
58
+
59
+ def drop_version_from_url(url)
60
+ url.to_s
61
+ .gsub(%r{/v?\d+\.\d+\.\d+(-[a-z0-9.]+)?/}, '/')
62
+ .gsub(%r{@\d+\.\d+\.\d+(-[a-z0-9.]+)?/?}, '')
45
63
  end
46
64
  end
47
65
 
@@ -35,7 +35,7 @@ module CKEditor5::Rails::Editor
35
35
  def to_html(nonce: nil)
36
36
  code = wrap_with_handlers(@plugin.code)
37
37
 
38
- tag.script(code.html_safe, nonce: nonce)
38
+ tag.script(code.html_safe, type: 'module', nonce: nonce)
39
39
  end
40
40
 
41
41
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.28.0'
5
+ VERSION = '1.28.1'
6
6
 
7
7
  DEFAULT_CKEDITOR_VERSION = '44.3.0'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckeditor5
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.0
4
+ version: 1.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński