ckeditor5 1.24.2 → 1.24.4

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: afb2870df1641fcf9fc15b9a7951c80e887991808078d56cc9ec67febad405c3
4
- data.tar.gz: 725cb66917c42b51c48ecbc41161359ff73e81de17c0a0f95e6ddcc3b58bb7bc
3
+ metadata.gz: cca06dbc54bf1070cfebfd54b85ea203ada266e4316e65f3c1862f9897728b06
4
+ data.tar.gz: 142ea208fe9629f060e44c641f15a0b5f6f3bdebaae11756e3dd3389cc5785d1
5
5
  SHA512:
6
- metadata.gz: 5c8729eb7e323a8f240d4877171d64e27a5dab46567921c1372f57b9be635b4eac0d4e9492fd6693b0ef448533ca56a233498fe570866f734f2da5377c4140b3
7
- data.tar.gz: 3ed9851296ad8cce6282a0c9262120436118552c7166490059bafd29ad82e83f8930c93a3464a780672b4c38aa9468b34a36cf1e8e613cfc34114b8523c22942
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
@@ -76,7 +76,8 @@ module CKEditor5::Rails
76
76
  delegate :presets, to: :@configuration
77
77
 
78
78
  delegate :version, :gpl, :premium, :cdn, :translations, :license_key,
79
- :type, :menubar, :toolbar, :plugins, :plugin, :inline_plugin,
79
+ :type, :menubar, :plugins, :plugin, :inline_plugin,
80
+ :toolbar, :block_toolbar, :balloon_toolbar,
80
81
  :language, :ckbox, :configure, :automatic_upgrades, :simple_upload_adapter,
81
82
  :editable_height, :wproofreader, to: :default_preset
82
83
 
@@ -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.2'
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.2
4
+ version: 1.24.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński