ckeditor5 1.24.0 → 1.24.2
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 +4 -4
- data/lib/ckeditor5/rails/context/preset_builder.rb +1 -0
- data/lib/ckeditor5/rails/editor/props_inline_plugin.rb +1 -1
- data/lib/ckeditor5/rails/presets/concerns/plugin_methods.rb +6 -2
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/lib/ckeditor5/rails/cdn/helpers_spec.rb +23 -0
- data/spec/lib/ckeditor5/rails/context/preset_builder_spec.rb +1 -3
- data/spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb2870df1641fcf9fc15b9a7951c80e887991808078d56cc9ec67febad405c3
|
4
|
+
data.tar.gz: 725cb66917c42b51c48ecbc41161359ff73e81de17c0a0f95e6ddcc3b58bb7bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8729eb7e323a8f240d4877171d64e27a5dab46567921c1372f57b9be635b4eac0d4e9492fd6693b0ef448533ca56a233498fe570866f734f2da5377c4140b3
|
7
|
+
data.tar.gz: 3ed9851296ad8cce6282a0c9262120436118552c7166490059bafd29ad82e83f8930c93a3464a780672b4c38aa9468b34a36cf1e8e613cfc34114b8523c22942
|
@@ -14,7 +14,7 @@ module CKEditor5::Rails
|
|
14
14
|
class UnsupportedESModuleError < StandardError; end
|
15
15
|
|
16
16
|
included do
|
17
|
-
attr_reader :disallow_inline_plugins
|
17
|
+
attr_reader :disallow_inline_plugins, :disallow_inline_plugin_compression
|
18
18
|
end
|
19
19
|
|
20
20
|
# Registers an external plugin loaded from a URL
|
@@ -62,7 +62,11 @@ module CKEditor5::Rails
|
|
62
62
|
end
|
63
63
|
|
64
64
|
wrapped_code = "(async () => { #{code} })();"
|
65
|
-
minified_code =
|
65
|
+
minified_code = wrapped_code
|
66
|
+
|
67
|
+
unless disallow_inline_plugin_compression
|
68
|
+
minified_code = Terser.new(compress: false, mangle: true).compile(minified_code)
|
69
|
+
end
|
66
70
|
|
67
71
|
register_plugin(Editor::PropsInlinePlugin.new(name, minified_code))
|
68
72
|
end
|
@@ -427,6 +427,29 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
427
427
|
expect(result).to have_tag('script', with: { nonce: 'test-nonce' })
|
428
428
|
end
|
429
429
|
|
430
|
+
context 'event listener' do
|
431
|
+
it 'adds event listeners for ckeditor:request-cjs-plugin' do
|
432
|
+
result = helper.ckeditor5_inline_plugins_tags(preset)
|
433
|
+
|
434
|
+
expect(result).to include("window.addEventListener('ckeditor:request-cjs-plugin:Plugin1'")
|
435
|
+
expect(result).to include("window.addEventListener('ckeditor:request-cjs-plugin:Plugin2'")
|
436
|
+
end
|
437
|
+
|
438
|
+
it 'adds event listeners only once' do
|
439
|
+
result = helper.ckeditor5_inline_plugins_tags(preset)
|
440
|
+
|
441
|
+
expect(result.scan("window.addEventListener('ckeditor:request-cjs-plugin:Plugin1'").count).to eq(1)
|
442
|
+
expect(result.scan("window.addEventListener('ckeditor:request-cjs-plugin:Plugin2'").count).to eq(1)
|
443
|
+
end
|
444
|
+
|
445
|
+
it('each event listener has once option') do
|
446
|
+
result = helper.ckeditor5_inline_plugins_tags(preset)
|
447
|
+
|
448
|
+
expect(result).to include('{ once: true }')
|
449
|
+
expect(result.scan('{ once: true }').length).to eq(2)
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
430
453
|
context 'with preset having no inline plugins' do
|
431
454
|
let(:empty_preset) do
|
432
455
|
CKEditor5::Rails::Presets::PresetBuilder.new do
|
@@ -102,9 +102,7 @@ RSpec.describe CKEditor5::Rails::Context::PresetBuilder do
|
|
102
102
|
it 'accepts plugin options' do
|
103
103
|
plugin = builder.inline_plugin('Test', plugin_code)
|
104
104
|
|
105
|
-
expect(plugin.code).to eq(
|
106
|
-
'(async()=>{const{Plugin:t}=await import("ckeditor5");return class n extends t{}})();'
|
107
|
-
)
|
105
|
+
expect(plugin.code).to eq("(async () => { #{plugin_code} })();")
|
108
106
|
end
|
109
107
|
end
|
110
108
|
|
@@ -36,3 +36,35 @@ RSpec.describe CKEditor5::Rails::Editor::PropsInlinePlugin do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
RSpec.describe CKEditor5::Rails::Editor::InlinePluginWindowInitializer do
|
41
|
+
let(:plugin) do
|
42
|
+
CKEditor5::Rails::Editor::PropsInlinePlugin.new(:CustomPlugin, 'const plugin = {}')
|
43
|
+
end
|
44
|
+
|
45
|
+
subject(:initializer) { described_class.new(plugin) }
|
46
|
+
|
47
|
+
describe '#to_html' do
|
48
|
+
it 'generates script tag with event listener' do
|
49
|
+
result = initializer.to_html
|
50
|
+
|
51
|
+
expect(result).to be_html_safe
|
52
|
+
expect(result).to include('script')
|
53
|
+
expect(result).to include("window.addEventListener('ckeditor:request-cjs-plugin:CustomPlugin'")
|
54
|
+
expect(result).to include("window['CustomPlugin']")
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'adds nonce attribute when provided' do
|
58
|
+
result = initializer.to_html(nonce: 'test-nonce')
|
59
|
+
|
60
|
+
expect(result).to include('nonce="test-nonce"')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'wraps plugin code in event handler' do
|
64
|
+
result = initializer.to_html
|
65
|
+
|
66
|
+
expect(result).to include('const plugin = {}')
|
67
|
+
expect(result).to include('{ once: true }')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
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.24.
|
4
|
+
version: 1.24.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Bagiński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-12-
|
12
|
+
date: 2024-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|