ckeditor5 1.24.3 → 1.24.4

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: 9f055d3f42eb575c384ca38f7d33dc7fcdae317c3bf7c5ce96b900a71d88e7c9
4
- data.tar.gz: 2c728f08960a47918d9d4368fb7bf7ba355da60cad6229ffb11b98ef071a05eb
3
+ metadata.gz: cca06dbc54bf1070cfebfd54b85ea203ada266e4316e65f3c1862f9897728b06
4
+ data.tar.gz: 142ea208fe9629f060e44c641f15a0b5f6f3bdebaae11756e3dd3389cc5785d1
5
5
  SHA512:
6
- metadata.gz: 913b061f13cbc27f469daf6ae0dfc4904a621544633d63a19b95ed054bbef7b62caf9ac4c66f37d06ff3d544bd10d14f15c588a506a58686d64499d3d65d36d3
7
- data.tar.gz: '01906e3eea20a465be97546237cb4509db208b3673dac5439917bad1b412b3eae35e2f331aa5633f189d7349d5f1fb37af5c054ca7122c0ded9dc80f8fdc1782'
6
+ metadata.gz: 47a5040ef3c012676d0c2fb4ded7798ccb1d9f6a0a59ac399b6d8584ed0b07041cbce13b8fefbca040d64eedde569a3cc899ad70d9fdb8aa7295e5a36dcf733f
7
+ data.tar.gz: 394210568ca3100e7c0af2e14565b923348b0fce2918c1bb02d01ae3840b3c8fe7b9c82c1c805bbbb320fa9fa50c2767436458de2a03fe61c5293648cbf180b3
@@ -9,8 +9,13 @@ module CKEditor5::Rails::Editor
9
9
  def initialize(name, code)
10
10
  super(name)
11
11
 
12
- @code = code
13
- validate_code!
12
+ raise ArgumentError, 'Code must be a String' unless code.is_a?(String)
13
+
14
+ @code = "(async () => { #{code.html_safe} })()"
15
+ end
16
+
17
+ def compress!
18
+ @code = Terser.new(compress: false, mangle: true).compile(@code)
14
19
  end
15
20
 
16
21
  def to_h
@@ -19,12 +24,6 @@ module CKEditor5::Rails::Editor
19
24
  window_name: name
20
25
  }
21
26
  end
22
-
23
- private
24
-
25
- def validate_code!
26
- raise ArgumentError, 'Code must be a String' unless code.is_a?(String)
27
- end
28
27
  end
29
28
 
30
29
  class InlinePluginWindowInitializer
@@ -3,7 +3,7 @@
3
3
  module CKEditor5::Rails::Plugins
4
4
  class SimpleUploadAdapter < CKEditor5::Rails::Editor::PropsInlinePlugin
5
5
  PLUGIN_CODE = <<~JS
6
- import { Plugin, FileRepository } from 'ckeditor5';
6
+ const { Plugin, FileRepository } = await import( 'ckeditor5' );
7
7
 
8
8
  return class SimpleUploadAdapter extends Plugin {
9
9
  static get requires() {
@@ -26,6 +26,7 @@ module CKEditor5::Rails::Plugins
26
26
  # Sync I18n language from editor to WProofreader plugin
27
27
  class WProofreaderSync < CKEditor5::Rails::Editor::PropsInlinePlugin
28
28
  PLUGIN_CODE = <<~JS
29
+ const { Plugin, FileRepository } = await import( 'ckeditor5' );
29
30
  const CORRECTION_LANGUAGES = [
30
31
  'en_US', 'en_GB', 'pt_BR', 'da_DK',
31
32
  'nl_NL', 'en_CA', 'fi_FI', 'fr_FR',
@@ -34,27 +35,35 @@ module CKEditor5::Rails::Plugins
34
35
  'uk_UA', 'auto'
35
36
  ];
36
37
 
37
- export default function WProofreaderSync(editor) {
38
- const wproofreaderConfig = editor.config.get('wproofreader');
39
- const editorLangCode = (() => {
40
- const config = editor.config.get('language');
38
+ return class WproofreaderSync extends Plugin {
39
+ static get pluginName() {
40
+ return 'WProofreaderSync';
41
+ }
41
42
 
42
- return config.content || config.ui;
43
- })();
43
+ async init() {
44
+ const { editor } = this;
44
45
 
45
- if (!wproofreaderConfig || !editorLangCode) {
46
- return;
47
- }
46
+ const wproofreaderConfig = editor.config.get('wproofreader');
47
+ const editorLangCode = (() => {
48
+ const config = editor.config.get('language');
49
+
50
+ return config.content || config.ui;
51
+ })();
48
52
 
49
- const lang = CORRECTION_LANGUAGES.find(
50
- lang => lang.startsWith(editorLangCode.toLowerCase())
51
- ) || 'auto';
53
+ if (!wproofreaderConfig || !editorLangCode) {
54
+ return;
55
+ }
52
56
 
53
- editor.config.set('wproofreader', {
54
- lang,
55
- localization: editorLangCode,
56
- ...wproofreaderConfig,
57
- });
57
+ const lang = CORRECTION_LANGUAGES.find(
58
+ lang => lang.startsWith(editorLangCode.toLowerCase())
59
+ ) || 'auto';
60
+
61
+ editor.config.set('wproofreader', {
62
+ lang,
63
+ localization: editorLangCode,
64
+ ...wproofreaderConfig,
65
+ });
66
+ }
58
67
  }
59
68
  JS
60
69
 
@@ -61,14 +61,10 @@ module CKEditor5::Rails
61
61
  'Plugin code must return a class that extends Plugin!'
62
62
  end
63
63
 
64
- wrapped_code = "(async () => { #{code} })();"
65
- minified_code = wrapped_code
64
+ plugin = Editor::PropsInlinePlugin.new(name, code)
65
+ plugin.compress! unless disallow_inline_plugin_compression
66
66
 
67
- unless disallow_inline_plugin_compression
68
- minified_code = Terser.new(compress: false, mangle: true).compile(minified_code)
69
- end
70
-
71
- register_plugin(Editor::PropsInlinePlugin.new(name, minified_code))
67
+ register_plugin(plugin)
72
68
  end
73
69
 
74
70
  # Register a single plugin by name
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.24.3'
5
+ VERSION = '1.24.4'
6
6
 
7
7
  DEFAULT_CKEDITOR_VERSION = '44.1.0'
8
8
  end
@@ -102,7 +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("(async () => { #{plugin_code} })();")
105
+ expect(plugin.code).to eq("(async () => { #{plugin_code} })()")
106
106
  end
107
107
  end
108
108
 
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.3
4
+ version: 1.24.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński