ckeditor5 1.24.3 → 1.24.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ckeditor5/rails/editor/props_inline_plugin.rb +7 -8
- data/lib/ckeditor5/rails/plugins/simple_upload_adapter.rb +1 -1
- data/lib/ckeditor5/rails/plugins/wproofreader.rb +26 -17
- data/lib/ckeditor5/rails/presets/concerns/plugin_methods.rb +3 -7
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/lib/ckeditor5/rails/context/preset_builder_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca06dbc54bf1070cfebfd54b85ea203ada266e4316e65f3c1862f9897728b06
|
4
|
+
data.tar.gz: 142ea208fe9629f060e44c641f15a0b5f6f3bdebaae11756e3dd3389cc5785d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
13
|
-
|
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
|
-
|
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
return class WproofreaderSync extends Plugin {
|
39
|
+
static get pluginName() {
|
40
|
+
return 'WProofreaderSync';
|
41
|
+
}
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
async init() {
|
44
|
+
const { editor } = this;
|
44
45
|
|
45
|
-
|
46
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
53
|
+
if (!wproofreaderConfig || !editorLangCode) {
|
54
|
+
return;
|
55
|
+
}
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
65
|
-
|
64
|
+
plugin = Editor::PropsInlinePlugin.new(name, code)
|
65
|
+
plugin.compress! unless disallow_inline_plugin_compression
|
66
66
|
|
67
|
-
|
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
|
@@ -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
|
|