ckeditor5 1.24.8 → 1.24.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c35c8f39b99348a0ee09b5310615a94a94209cb5349c6933c16b421efdd6bd7
4
- data.tar.gz: b340af703a46590660d3f2a84388533edc11589212828b6525c0687e7f5cf42c
3
+ metadata.gz: bbaa06c0cde62bfe01904bb70ca7c8e0f4db04610d2f71543d1fbd657182e781
4
+ data.tar.gz: 36ac98e55c8d927fc094cac0b60dd23284a0667ca0d3387b0858d980bc0f33bd
5
5
  SHA512:
6
- metadata.gz: b7c04e1eef833834a9770494a5b817750b184c1416324b7848bf80af4943aecfe9816e8ce3a6e66d8da65173711aedc6f5e6d47e336082c4db31427abf1df059
7
- data.tar.gz: 385a2b21314d8c79a511a3023e44da03188f976af9942c88b05648b0d03e840e155fc3af76b482977516b8f2767849196813aa7971db8bfdc69e6bc1d7ad0fae
6
+ metadata.gz: 525255ffbc1aadedfe42eea761822f123f3f4de0617e19a443dcb3051d95841ced3f3fda0c8d73241094c84c4e6eac410f26b33ea9ebd1271d9ddd15ab52bcf3
7
+ data.tar.gz: 85f17299ba06f3187f7211eb345e93c4d5e7efbd6c2772fb855df883c7af732fd61ce8f32c788899fba3012fcb90770627c33b52182a280b70329a88f8361ce6
data/README.md CHANGED
@@ -794,6 +794,23 @@ CKEditor5::Rails.configure do
794
794
  plugin :YourPlugin, window_name: 'YourPlugin'
795
795
  end
796
796
  ```
797
+
798
+ If there is no `window.YourPlugin` object, the plugin will dispatch window event to load. To handle this event, you can use the `window.addEventListener` method:
799
+
800
+ ```js
801
+ window.addEventListener('ckeditor:request-cjs-plugin:YourPlugin', () => {
802
+ window.YourPlugin = (async () => {
803
+ const { Plugin } = await import('ckeditor5');
804
+
805
+ return class YourPlugin extends Plugin {
806
+ // Your plugin code
807
+ };
808
+ })();
809
+ });
810
+ ```
811
+
812
+ ⚠️ The event handler must be attached before the plugin is requested. If the plugin is requested before the event handler is attached, the plugin will not be loaded.
813
+
797
814
  </details>
798
815
 
799
816
  #### `plugins(*names, **kwargs)` method
@@ -1865,7 +1882,7 @@ end
1865
1882
 
1866
1883
  ```js
1867
1884
  // app/javascript/custom_plugins/highlight.js
1868
- import { Plugin, Command, ButtonView } from 'ckeditor5';
1885
+ const { Plugin, Command, ButtonView } = await import('ckeditor5');
1869
1886
 
1870
1887
  return class MyCustomPlugin extends Plugin {
1871
1888
  static get pluginName() {
@@ -7,16 +7,20 @@ module CKEditor5::Rails::Editor
7
7
  def initialize(name, premium: false, **js_import_meta_attrs)
8
8
  super(name)
9
9
 
10
- js_import_meta_attrs[:import_name] ||= if premium
11
- 'ckeditor5-premium-features'
12
- else
13
- 'ckeditor5'
14
- end
10
+ if js_import_meta_attrs[:window_name]
11
+ @js_import_meta = ::CKEditor5::Rails::Assets::JSImportMeta.new(**js_import_meta_attrs)
12
+ else
13
+ js_import_meta_attrs[:import_name] ||= if premium
14
+ 'ckeditor5-premium-features'
15
+ else
16
+ 'ckeditor5'
17
+ end
15
18
 
16
- @js_import_meta = ::CKEditor5::Rails::Assets::JSImportMeta.new(
17
- import_as: js_import_meta_attrs[:window_name] ? nil : name,
18
- **js_import_meta_attrs
19
- )
19
+ @js_import_meta = ::CKEditor5::Rails::Assets::JSImportMeta.new(
20
+ import_as: name,
21
+ **js_import_meta_attrs
22
+ )
23
+ end
20
24
  end
21
25
 
22
26
  # Compress a little bit default plugins to make output smaller
@@ -167,7 +167,7 @@ module CKEditor5::Rails
167
167
  def translations(*translations)
168
168
  return @translations if translations.empty?
169
169
 
170
- @translations = translations
170
+ @translations = translations.map { |t| t.to_sym.downcase }
171
171
  end
172
172
 
173
173
  # Set or get editor version
@@ -328,7 +328,11 @@ module CKEditor5::Rails
328
328
  def language(ui = nil, content: ui) # rubocop:disable Naming/MethodParameterName
329
329
  return config[:language] if ui.nil?
330
330
 
331
- @translations << ui.to_sym unless @translations.map(&:to_sym).include?(ui.to_sym)
331
+ # Normalize language codes, as the translation packs used to be in lowercase
332
+ ui = ui.to_sym.downcase
333
+ content = content.to_sym.downcase
334
+
335
+ @translations << ui unless @translations.map(&:to_sym).include?(ui)
332
336
 
333
337
  config[:language] = {
334
338
  ui: ui,
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.24.8'
5
+ VERSION = '1.24.10'
6
6
 
7
7
  DEFAULT_CKEDITOR_VERSION = '44.1.0'
8
8
  end
@@ -96,6 +96,15 @@ RSpec.describe 'CKEditor5 Types Integration', type: :feature, js: true do
96
96
  expect(plugin_exists).to be true
97
97
  end
98
98
  end
99
+
100
+ it 'initializes the window plugin' do
101
+ visit 'classic'
102
+
103
+ eventually do
104
+ plugin_exists = page.evaluate_script('window.__customWindowPlugin !== undefined')
105
+ expect(plugin_exists).to be true
106
+ end
107
+ end
99
108
  end
100
109
 
101
110
  describe 'Decoupled Editor' do
@@ -450,6 +450,22 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
450
450
  builder.language(:pl, content: :en)
451
451
  expect(builder.config[:language]).to eq({ ui: :pl, content: :en })
452
452
  end
453
+
454
+ it 'normalizes language codes to lowercase symbols when string provided' do
455
+ builder.language('PL', content: 'EN')
456
+ expect(builder.config[:language]).to eq({ ui: :pl, content: :en })
457
+ end
458
+
459
+ it 'adds normalized UI language to translations' do
460
+ builder.language('PL')
461
+ expect(builder.translations).to include(:pl)
462
+ expect(builder.translations).not_to include('PL')
463
+ end
464
+
465
+ it 'handles mixed string and symbol inputs' do
466
+ builder.language('PL', content: :EN)
467
+ expect(builder.config[:language]).to eq({ ui: :pl, content: :en })
468
+ end
453
469
  end
454
470
 
455
471
  describe '#deep_copy_toolbar' do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckeditor5
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.24.8
4
+ version: 1.24.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński
8
8
  - Łukasz Modliński
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-01-11 00:00:00.000000000 Z
12
+ date: 2025-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
- description:
48
+ description:
49
49
  email: cziken58@gmail.com
50
50
  executables: []
51
51
  extensions: []
@@ -147,7 +147,7 @@ metadata:
147
147
  documentation_uri: https://github.com/Mati365/ckeditor5-rails
148
148
  source_code_uri: https://github.com/Mati365/ckeditor5-rails
149
149
  bug_tracker_uri: https://github.com/Mati365/ckeditor5-rails/issues
150
- post_install_message:
150
+ post_install_message:
151
151
  rdoc_options: []
152
152
  require_paths:
153
153
  - lib
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubygems_version: 3.5.22
166
- signing_key:
166
+ signing_key:
167
167
  specification_version: 4
168
168
  summary: CKEditor 5 for Rails
169
169
  test_files: