ckeditor5 1.24.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80009856e5d1548b4c74e6d17306213edf82cbad045af31c051fa7cdd8a2f82e
4
- data.tar.gz: 67b02d03c42342a7ee8fe36d02d7c8d13e3c7765eb4f2bf96275389260050c74
3
+ metadata.gz: afb2870df1641fcf9fc15b9a7951c80e887991808078d56cc9ec67febad405c3
4
+ data.tar.gz: 725cb66917c42b51c48ecbc41161359ff73e81de17c0a0f95e6ddcc3b58bb7bc
5
5
  SHA512:
6
- metadata.gz: 28e347bb06d411fda5a66c37ff21785e8e558cd7b0724c674b2f8d55cdf5e3c5ef2f980f8ec95a952d69314f996d7c2379fb8291634b116a66b248dc6f42b19f
7
- data.tar.gz: 1dbbc64df4d51d3ffb8f7192d3f7f0871217bfbe9e17168b8d4d6bedcfdb8f5cbb01b108542078fef4c9b77527b0ee293e4c2c6022606bc8bd488f88eb3dd164
6
+ metadata.gz: 5c8729eb7e323a8f240d4877171d64e27a5dab46567921c1372f57b9be635b4eac0d4e9492fd6693b0ef448533ca56a233498fe570866f734f2da5377c4140b3
7
+ data.tar.gz: 3ed9851296ad8cce6282a0c9262120436118552c7166490059bafd29ad82e83f8930c93a3464a780672b4c38aa9468b34a36cf1e8e613cfc34114b8523c22942
@@ -46,7 +46,7 @@ module CKEditor5::Rails::Editor
46
46
  <<~JS
47
47
  window.addEventListener('ckeditor:request-cjs-plugin:#{@plugin.name}', () => {
48
48
  window['#{@plugin.name}'] = #{code.html_safe};
49
- });
49
+ }, { once: true });
50
50
  JS
51
51
  end
52
52
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.24.1'
5
+ VERSION = '1.24.2'
6
6
 
7
7
  DEFAULT_CKEDITOR_VERSION = '44.1.0'
8
8
  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
@@ -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.1
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-20 00:00:00.000000000 Z
12
+ date: 2024-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails