ckeditor5 1.29.2 → 1.30.0
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 +4 -4
- data/README.md +73 -0
- data/lib/ckeditor5/rails/cdn/helpers.rb +1 -1
- data/lib/ckeditor5/rails/context/preset_builder.rb +2 -2
- data/lib/ckeditor5/rails/editor/helpers/config_helpers.rb +1 -1
- data/lib/ckeditor5/rails/editor/props_patch_plugin.rb +2 -2
- data/lib/ckeditor5/rails/engine.rb +3 -5
- data/lib/ckeditor5/rails/plugins/patches/fix_color_picker_race_condition.rb +50 -0
- data/lib/ckeditor5/rails/plugins.rb +15 -0
- data/lib/ckeditor5/rails/presets/concerns/plugin_methods.rb +19 -2
- data/lib/ckeditor5/rails/presets/manager.rb +4 -4
- data/lib/ckeditor5/rails/presets/preset_builder.rb +20 -8
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/lib/ckeditor5/rails/cdn/helpers_spec.rb +2 -2
- data/spec/lib/ckeditor5/rails/presets/manager_spec.rb +58 -2
- data/spec/lib/ckeditor5/rails/presets/preset_builder_spec.rb +24 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3153496741eaf1fd9b8713998c1078e52d96c6e863ffe710d215e7e3b098816
|
4
|
+
data.tar.gz: 35a1bc0b3e29d51876b4e906a38db93073a65a59ee3ab4436d5e394664bcd833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7d014c98e5c49572be2d2ccd2affcf57d9d91b0cd4f3ffd1cba2cc6834461075c5262aa112768d43ab5a0a9072dcded1fc7daf50beeb19e039b5ad2ff5b40d
|
7
|
+
data.tar.gz: a0d7ddf8085a98b4dc9d60e1606b1a9721e3cf9625b24743aca9fba0eb89ca15036b4f1664ed4e9e6c3d98eb6fc0e86b59c80705096a053738d3204c0bcc9063
|
data/README.md
CHANGED
@@ -146,10 +146,12 @@ For extending CKEditor's functionality, refer to the [plugins directory](https:/
|
|
146
146
|
- [`inline_plugin(name, code)` method](#inline_pluginname-code-method)
|
147
147
|
- [`external_plugin(name, script:, import_as: nil, window_name: nil, stylesheets: [])` method](#external_pluginname-script-import_as-nil-window_name-nil-stylesheets--method)
|
148
148
|
- [`patch_plugin(plugin)`](#patch_pluginplugin)
|
149
|
+
- [`apply_integration_patches(compress: false)` method](#apply_integration_patchescompress-false-method)
|
149
150
|
- [`simple_upload_adapter(url, compress: true)` method](#simple_upload_adapterurl-compress-true-method)
|
150
151
|
- [`special_characters(compress: true, &block)` method](#special_characterscompress-true-block-method)
|
151
152
|
- [`wproofreader(version: nil, cdn: nil, compress: true, **config)` method](#wproofreaderversion-nil-cdn-nil-compress-true-config-method)
|
152
153
|
- [`custom_translations(lang_code = nil, translations = {}, compress: true)` method](#custom_translationslang_code--nil-translations---compress-true-method)
|
154
|
+
- [`compression(enabled: true)` method](#compressionenabled-true-method)
|
153
155
|
- [Controller / View helpers 📦](#controller--view-helpers-)
|
154
156
|
- [`ckeditor5_translation_ref(key)` method](#ckeditor5_translation_refkey-method)
|
155
157
|
- [`ckeditor5_element_ref(selector)` method](#ckeditor5_element_refselector-method)
|
@@ -346,6 +348,20 @@ CKEditor5::Rails.configure do
|
|
346
348
|
end
|
347
349
|
```
|
348
350
|
|
351
|
+
In order to disable default patches, you can pass the `apply_patches: false` keyword argument to the `version` method.
|
352
|
+
|
353
|
+
```rb
|
354
|
+
# config/initializers/ckeditor5.rb
|
355
|
+
|
356
|
+
CKEditor5::Rails.configure do
|
357
|
+
# ... other configuration
|
358
|
+
|
359
|
+
version '44.3.0', apply_patches: false
|
360
|
+
end
|
361
|
+
```
|
362
|
+
|
363
|
+
The patches are defined in the `lib/ckeditor5/rails/plugins/patches` directory. If you want to apply custom patches, you can use the `patch_plugin` method.
|
364
|
+
|
349
365
|
</details>
|
350
366
|
|
351
367
|
#### `automatic_upgrades(enabled: true)` method
|
@@ -1038,6 +1054,29 @@ end
|
|
1038
1054
|
```
|
1039
1055
|
</details>
|
1040
1056
|
|
1057
|
+
#### `apply_integration_patches(compress: false)` method
|
1058
|
+
|
1059
|
+
<details>
|
1060
|
+
<summary>Apply patches to the specific versions of CKEditor 5</summary>
|
1061
|
+
|
1062
|
+
<br />
|
1063
|
+
|
1064
|
+
Defines a method that applies patches to the specific versions of CKEditor 5. The example below shows how to apply patches to the `44.1.0` version:
|
1065
|
+
|
1066
|
+
```rb
|
1067
|
+
# config/initializers/ckeditor5.rb
|
1068
|
+
|
1069
|
+
CKEditor5::Rails.configure do
|
1070
|
+
# ... other configuration
|
1071
|
+
|
1072
|
+
apply_integration_patches
|
1073
|
+
end
|
1074
|
+
```
|
1075
|
+
|
1076
|
+
It's useful when you want to apply patches to the specific versions of CKEditor 5. The patches are defined in the `lib/ckeditor5/rails/plugins/patches` directory.
|
1077
|
+
|
1078
|
+
</details>
|
1079
|
+
|
1041
1080
|
#### `simple_upload_adapter(url, compress: true)` method
|
1042
1081
|
|
1043
1082
|
<details>
|
@@ -1194,6 +1233,40 @@ end
|
|
1194
1233
|
|
1195
1234
|
</details>
|
1196
1235
|
|
1236
|
+
#### `compression(enabled: true)` method
|
1237
|
+
|
1238
|
+
<details>
|
1239
|
+
<summary>Enable or disable compression of the inline plugins or patches</summary>
|
1240
|
+
|
1241
|
+
<br />
|
1242
|
+
|
1243
|
+
Defines whether the inline plugins should be compressed. It **must** be called before the `inline_plugin` and `version` methods. The example below shows how to disable compression:
|
1244
|
+
|
1245
|
+
```rb
|
1246
|
+
# config/initializers/ckeditor5.rb
|
1247
|
+
|
1248
|
+
CKEditor5::Rails.configure do
|
1249
|
+
compression enabled: false
|
1250
|
+
|
1251
|
+
# ... other configuration
|
1252
|
+
end
|
1253
|
+
```
|
1254
|
+
|
1255
|
+
:warning: Compression is enabled by default, and it's recommended to keep it enabled for production environments. It reduces the size of the inline plugins and patches, which improves the loading time of the editor.
|
1256
|
+
If you want to disable compression for a specific plugin, you can pass the `compress: false` keyword argument to the `inline_plugin` method:
|
1257
|
+
|
1258
|
+
```rb
|
1259
|
+
# config/initializers/ckeditor5.rb
|
1260
|
+
|
1261
|
+
CKEditor5::Rails.configure do
|
1262
|
+
# ... other configuration
|
1263
|
+
|
1264
|
+
inline_plugin :MyCustomPlugin, plugin_code, compress: false
|
1265
|
+
end
|
1266
|
+
```
|
1267
|
+
|
1268
|
+
</details>
|
1269
|
+
|
1197
1270
|
### Controller / View helpers 📦
|
1198
1271
|
|
1199
1272
|
#### `ckeditor5_translation_ref(key)` method
|
@@ -12,7 +12,7 @@ module CKEditor5::Rails
|
|
12
12
|
#
|
13
13
|
# @example Basic preset definition
|
14
14
|
# preset = PresetBuilder.new do
|
15
|
-
# version '
|
15
|
+
# version '43.3.1'
|
16
16
|
# gpl
|
17
17
|
# type :classic
|
18
18
|
# toolbar :bold, :italic
|
@@ -35,7 +35,7 @@ module CKEditor5::Rails
|
|
35
35
|
# @param block [Proc] Optional configuration block
|
36
36
|
# @example Initialize with block
|
37
37
|
# PresetBuilder.new do
|
38
|
-
# version '
|
38
|
+
# version '43.3.1'
|
39
39
|
# toolbar :bold, :italic
|
40
40
|
# end
|
41
41
|
def initialize(&block)
|
@@ -44,7 +44,7 @@ module CKEditor5::Rails::Editor::Helpers
|
|
44
44
|
#
|
45
45
|
# @example Creating a custom preset in controller
|
46
46
|
# @preset = ckeditor5_preset do
|
47
|
-
# version '
|
47
|
+
# version '43.3.1'
|
48
48
|
# toolbar :sourceEditing, :|, :bold, :italic
|
49
49
|
# plugins :Essentials, :Paragraph, :Bold, :Italic
|
50
50
|
# end
|
@@ -7,8 +7,8 @@ module CKEditor5::Rails::Editor
|
|
7
7
|
class PropsPatchPlugin < PropsInlinePlugin
|
8
8
|
attr_reader :min_version, :max_version
|
9
9
|
|
10
|
-
def initialize(name, code, min_version: nil, max_version: nil)
|
11
|
-
super(name, code)
|
10
|
+
def initialize(name, code, min_version: nil, max_version: nil, compress: true)
|
11
|
+
super(name, code, compress: compress)
|
12
12
|
|
13
13
|
@min_version = min_version && CKEditor5::Rails::Semver.new(min_version)
|
14
14
|
@max_version = max_version && CKEditor5::Rails::Semver.new(max_version)
|
@@ -3,10 +3,7 @@
|
|
3
3
|
require 'rails/engine'
|
4
4
|
|
5
5
|
require_relative 'presets/manager'
|
6
|
-
require_relative 'plugins
|
7
|
-
require_relative 'plugins/wproofreader'
|
8
|
-
require_relative 'plugins/special_characters_bootstrap'
|
9
|
-
require_relative 'plugins/custom_translations_loader'
|
6
|
+
require_relative 'plugins'
|
10
7
|
|
11
8
|
module CKEditor5::Rails
|
12
9
|
class PresetNotFoundError < ArgumentError; end
|
@@ -84,7 +81,8 @@ module CKEditor5::Rails
|
|
84
81
|
:type, :menubar, :plugins, :plugin, :inline_plugin,
|
85
82
|
:toolbar, :block_toolbar, :balloon_toolbar,
|
86
83
|
:language, :ckbox, :configure, :automatic_upgrades, :simple_upload_adapter,
|
87
|
-
:editable_height, :wproofreader, :custom_translations,
|
84
|
+
:editable_height, :wproofreader, :custom_translations, :apply_integration_patches,
|
85
|
+
:compression, :compression?, to: :default_preset
|
88
86
|
|
89
87
|
def initialize(configuration)
|
90
88
|
@configuration = configuration
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../editor/props_patch_plugin'
|
4
|
+
|
5
|
+
module CKEditor5::Rails::Plugins::Patches
|
6
|
+
# Fixes focus management issues in the CKEditor5 color picker component
|
7
|
+
# by ensuring proper focus handling when the color picker is opened.
|
8
|
+
#
|
9
|
+
# The patch modifies the ColorPickerView's focus behavior to properly
|
10
|
+
# focus either the hex input field (when visible) or the first slider.
|
11
|
+
#
|
12
|
+
# @see https://github.com/ckeditor/ckeditor5/issues/17069
|
13
|
+
class FixColorPickerRaceCondition < CKEditor5::Rails::Editor::PropsPatchPlugin
|
14
|
+
PLUGIN_CODE = <<~JS
|
15
|
+
const { Plugin, ColorPickerView, debounce } = await import( 'ckeditor5' );
|
16
|
+
|
17
|
+
return class FixColorPickerRaceCondition extends Plugin {
|
18
|
+
static get pluginName() {
|
19
|
+
return 'FixColorPickerRaceCondition';
|
20
|
+
}
|
21
|
+
|
22
|
+
constructor(editor) {
|
23
|
+
super(editor);
|
24
|
+
this.editor = editor;
|
25
|
+
this.#applyPatch();
|
26
|
+
}
|
27
|
+
|
28
|
+
#applyPatch() {
|
29
|
+
const { focus } = ColorPickerView.prototype;
|
30
|
+
|
31
|
+
ColorPickerView.prototype.focus = function() {
|
32
|
+
try {
|
33
|
+
if (!this._config.hideInput) {
|
34
|
+
this.hexInputRow.children.get( 1 ).focus();
|
35
|
+
}
|
36
|
+
|
37
|
+
this.slidersView.first.focus();
|
38
|
+
} catch (error) {
|
39
|
+
focus.apply(this, arguments);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
JS
|
45
|
+
|
46
|
+
def initialize(**kwargs)
|
47
|
+
super(:FixColorPickerRaceCondition, PLUGIN_CODE, max_version: '44.4.0', **kwargs)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CKEditor5::Rails::Plugins
|
4
|
+
module Patches
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
# Core plugins
|
9
|
+
require_relative 'plugins/simple_upload_adapter'
|
10
|
+
require_relative 'plugins/wproofreader'
|
11
|
+
require_relative 'plugins/special_characters_bootstrap'
|
12
|
+
require_relative 'plugins/custom_translations_loader'
|
13
|
+
|
14
|
+
# Plugin patches and fixes
|
15
|
+
require_relative 'plugins/patches/fix_color_picker_race_condition'
|
@@ -18,6 +18,24 @@ module CKEditor5::Rails
|
|
18
18
|
attr_reader :disallow_inline_plugin_compression
|
19
19
|
end
|
20
20
|
|
21
|
+
# Sets compression of inline plugin code. Make sure that it is called before setting the version
|
22
|
+
# or adding plugins.
|
23
|
+
# @example Disable compression
|
24
|
+
# compression(enabled: false)
|
25
|
+
# @return [void]
|
26
|
+
# @note This method is useful for debugging purposes, as it allows you to see the uncompressed code.
|
27
|
+
def compression(enabled: false)
|
28
|
+
@disallow_inline_plugin_compression = !enabled
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check if compression is enabled
|
32
|
+
# @return [Boolean] True if compression is enabled, false otherwise
|
33
|
+
# @example Check if compression is enabled
|
34
|
+
# compression? # => true
|
35
|
+
def compression?
|
36
|
+
!@disallow_inline_plugin_compression
|
37
|
+
end
|
38
|
+
|
21
39
|
# Registers an external plugin loaded from a URL
|
22
40
|
#
|
23
41
|
# @param name [Symbol] Plugin name
|
@@ -51,7 +69,7 @@ module CKEditor5::Rails
|
|
51
69
|
# }
|
52
70
|
# }
|
53
71
|
# JS
|
54
|
-
def inline_plugin(name, code, compress:
|
72
|
+
def inline_plugin(name, code, compress: !@disallow_inline_plugin_compression)
|
55
73
|
if code.match?(/export default/)
|
56
74
|
raise UnsupportedESModuleError,
|
57
75
|
'Inline plugins must not use ES module syntax!' \
|
@@ -63,7 +81,6 @@ module CKEditor5::Rails
|
|
63
81
|
'Plugin code must return a class that extends Plugin!'
|
64
82
|
end
|
65
83
|
|
66
|
-
compress = false if @disallow_inline_plugin_compression
|
67
84
|
plugin = Editor::PropsInlinePlugin.new(name, code, compress: compress)
|
68
85
|
|
69
86
|
register_plugin(plugin)
|
@@ -27,7 +27,7 @@ module CKEditor5::Rails::Presets
|
|
27
27
|
# end
|
28
28
|
# @example Define preset from scratch
|
29
29
|
# presets.define :blank, inherit: false do
|
30
|
-
# version '
|
30
|
+
# version '43.3.1'
|
31
31
|
# gpl
|
32
32
|
# type :classic
|
33
33
|
# end
|
@@ -40,7 +40,7 @@ module CKEditor5::Rails::Presets
|
|
40
40
|
end
|
41
41
|
|
42
42
|
preset.instance_eval(&block)
|
43
|
-
preset.try_compress_inline_plugins!
|
43
|
+
preset.try_compress_inline_plugins! if preset.compression?
|
44
44
|
|
45
45
|
@presets[name] = preset
|
46
46
|
end
|
@@ -59,7 +59,7 @@ module CKEditor5::Rails::Presets
|
|
59
59
|
preset = @presets[name]
|
60
60
|
|
61
61
|
preset.instance_eval(&block)
|
62
|
-
preset.try_compress_inline_plugins!
|
62
|
+
preset.try_compress_inline_plugins! if preset.compression?
|
63
63
|
end
|
64
64
|
|
65
65
|
alias extend override
|
@@ -83,7 +83,7 @@ module CKEditor5::Rails::Presets
|
|
83
83
|
# @example Basic configuration
|
84
84
|
# CKEditor5::Rails.configure do
|
85
85
|
# presets.define :default do
|
86
|
-
# version '
|
86
|
+
# version '43.3.1'
|
87
87
|
# gpl
|
88
88
|
# type :classic
|
89
89
|
# menubar
|
@@ -6,14 +6,14 @@ require_relative 'special_characters_builder'
|
|
6
6
|
|
7
7
|
module CKEditor5::Rails
|
8
8
|
module Presets
|
9
|
-
class PresetBuilder
|
9
|
+
class PresetBuilder # rubocop:disable Metrics/ClassLength
|
10
10
|
include Editor::Helpers::Config
|
11
11
|
include Concerns::ConfigurationMethods
|
12
12
|
include Concerns::PluginMethods
|
13
13
|
|
14
14
|
# @example Basic initialization
|
15
15
|
# PresetBuilder.new do
|
16
|
-
# version '
|
16
|
+
# version '43.3.1'
|
17
17
|
# gpl
|
18
18
|
# type :classic
|
19
19
|
# end
|
@@ -27,6 +27,7 @@ module CKEditor5::Rails
|
|
27
27
|
@ckbox = nil
|
28
28
|
@editable_height = nil
|
29
29
|
@automatic_upgrades = false
|
30
|
+
@disallow_inline_plugin_compression = false
|
30
31
|
@custom_translations = {}
|
31
32
|
@config = {
|
32
33
|
plugins: [],
|
@@ -174,12 +175,15 @@ module CKEditor5::Rails
|
|
174
175
|
|
175
176
|
# Set or get editor version
|
176
177
|
# @param version [String, nil] Editor version to set
|
178
|
+
# @param apply_patches [Boolean] Whether to apply integration patches after setting version
|
177
179
|
# @example Set specific version
|
178
|
-
# version '
|
180
|
+
# version '43.3.1'
|
181
|
+
# @example Set version without applying patches
|
182
|
+
# version '43.3.1', apply_patches: false
|
179
183
|
# @example Get current version
|
180
184
|
# version # => "43.3.1"
|
181
185
|
# @return [String, nil] Current version string or nil if not set
|
182
|
-
def version(version = nil)
|
186
|
+
def version(version = nil, apply_patches: true)
|
183
187
|
return @version&.to_s if version.nil?
|
184
188
|
|
185
189
|
if @automatic_upgrades && version
|
@@ -192,6 +196,13 @@ module CKEditor5::Rails
|
|
192
196
|
# If there is no license key set, and the version if newer than 44.0.0, switch to GPL
|
193
197
|
# as the license key is now required in all versions
|
194
198
|
gpl if license_key.nil? && @version.major >= 44
|
199
|
+
apply_integration_patches if apply_patches
|
200
|
+
end
|
201
|
+
|
202
|
+
# Apply integration patches for the current version
|
203
|
+
# @return [void]
|
204
|
+
def apply_integration_patches(compress: !@disallow_inline_plugin_compression)
|
205
|
+
patch_plugin(Plugins::Patches::FixColorPickerRaceCondition.new(compress: compress))
|
195
206
|
end
|
196
207
|
|
197
208
|
# Enable or disable automatic version upgrades
|
@@ -347,7 +358,8 @@ module CKEditor5::Rails
|
|
347
358
|
# ]
|
348
359
|
# }
|
349
360
|
# @return [void]
|
350
|
-
def custom_translations(lang_code = nil, translations = {},
|
361
|
+
def custom_translations(lang_code = nil, translations = {},
|
362
|
+
compress: !@disallow_inline_plugin_compression)
|
351
363
|
return @custom_translations if lang_code.blank?
|
352
364
|
|
353
365
|
@custom_translations[lang_code.to_sym] ||= {}
|
@@ -385,7 +397,7 @@ module CKEditor5::Rails
|
|
385
397
|
# @param compress [Boolean] Enable compression
|
386
398
|
# @example Enable upload adapter
|
387
399
|
# simple_upload_adapter '/uploads'
|
388
|
-
def simple_upload_adapter(upload_url = '/uploads', compress:
|
400
|
+
def simple_upload_adapter(upload_url = '/uploads', compress: !@disallow_inline_plugin_compression)
|
389
401
|
plugins do
|
390
402
|
remove(:Base64UploadAdapter)
|
391
403
|
end
|
@@ -402,7 +414,7 @@ module CKEditor5::Rails
|
|
402
414
|
# @example Basic configuration
|
403
415
|
# wproofreader serviceId: 'your-service-ID',
|
404
416
|
# srcUrl: 'https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js'
|
405
|
-
def wproofreader(version: nil, cdn: nil, compress:
|
417
|
+
def wproofreader(version: nil, cdn: nil, compress: !@disallow_inline_plugin_compression, **config)
|
406
418
|
configure :wproofreader, config
|
407
419
|
plugins do
|
408
420
|
prepend(Plugins::WProofreaderSync.new(compress: compress))
|
@@ -438,7 +450,7 @@ module CKEditor5::Rails
|
|
438
450
|
# item 'heart', '❤️'
|
439
451
|
# end
|
440
452
|
# end
|
441
|
-
def special_characters(compress:
|
453
|
+
def special_characters(compress: !@disallow_inline_plugin_compression, &block)
|
442
454
|
builder = SpecialCharactersBuilder.new
|
443
455
|
builder.instance_eval(&block) if block_given?
|
444
456
|
|
@@ -20,7 +20,7 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
20
20
|
let(:helper) { test_class.new }
|
21
21
|
let(:preset) do
|
22
22
|
CKEditor5::Rails::Presets::PresetBuilder.new do
|
23
|
-
version '34.1.0'
|
23
|
+
version '34.1.0', apply_patches: false
|
24
24
|
type :classic
|
25
25
|
translations :pl
|
26
26
|
cdn :cloud
|
@@ -151,7 +151,7 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
151
151
|
context 'when overriding preset values' do
|
152
152
|
let(:preset) do
|
153
153
|
CKEditor5::Rails::Presets::PresetBuilder.new do
|
154
|
-
version '34.1.0'
|
154
|
+
version '34.1.0', apply_patches: false
|
155
155
|
type :classic
|
156
156
|
language :pl
|
157
157
|
cdn :cloud
|
@@ -20,7 +20,7 @@ RSpec.describe CKEditor5::Rails::Presets::Manager do
|
|
20
20
|
it 'creates new preset based on default' do
|
21
21
|
manager.define(:custom) do
|
22
22
|
automatic_upgrades enabled: false
|
23
|
-
version '36.0.0'
|
23
|
+
version '36.0.0', apply_patches: false
|
24
24
|
end
|
25
25
|
|
26
26
|
expect(manager[:custom].version).to eq('36.0.0')
|
@@ -32,13 +32,42 @@ RSpec.describe CKEditor5::Rails::Presets::Manager do
|
|
32
32
|
it 'creates completely new preset' do
|
33
33
|
manager.define(:custom, inherit: false) do
|
34
34
|
automatic_upgrades enabled: false
|
35
|
-
version '36.0.0'
|
35
|
+
version '36.0.0', apply_patches: false
|
36
36
|
end
|
37
37
|
|
38
38
|
expect(manager[:custom].version).to eq('36.0.0')
|
39
39
|
expect(manager[:custom].config).to eq({ plugins: [], toolbar: [] })
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
context 'with compression settings' do
|
44
|
+
it 'attempts compression when compression? returns true' do
|
45
|
+
preset = manager.define(:with_compression, inherit: false) do
|
46
|
+
version '36.0.0', apply_patches: true
|
47
|
+
inline_plugin 'Test', <<~JAVASCRIPT
|
48
|
+
const { Plugin } = await import( 'ckeditor5' );
|
49
|
+
|
50
|
+
return class Abc extends Plugin {}
|
51
|
+
JAVASCRIPT
|
52
|
+
end
|
53
|
+
|
54
|
+
expect(preset.config[:plugins].first.code).to include('const{Plugin:t,ColorPickerView:i,debounce:o}=')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'does not attempt compression when compression? returns false' do
|
58
|
+
preset = manager.define(:without_compression, inherit: false) do
|
59
|
+
compression enabled: false
|
60
|
+
version '36.0.0', apply_patches: true
|
61
|
+
inline_plugin 'Test', <<~JAVASCRIPT
|
62
|
+
const { Plugin } = await import( 'ckeditor5' );
|
63
|
+
|
64
|
+
return class Abc extends Plugin {}
|
65
|
+
JAVASCRIPT
|
66
|
+
end
|
67
|
+
|
68
|
+
expect(preset.config[:plugins].first.code).to include('const { Plugin, ColorPickerView, debounce }')
|
69
|
+
end
|
70
|
+
end
|
42
71
|
end
|
43
72
|
|
44
73
|
describe '#override/#extend' do
|
@@ -69,6 +98,33 @@ RSpec.describe CKEditor5::Rails::Presets::Manager do
|
|
69
98
|
|
70
99
|
expect(manager[:custom].version).to eq('36.0.0')
|
71
100
|
end
|
101
|
+
|
102
|
+
context 'with compression settings' do
|
103
|
+
let(:preset_builder) { instance_double(CKEditor5::Rails::Presets::PresetBuilder) }
|
104
|
+
|
105
|
+
before do
|
106
|
+
allow(preset_builder).to receive(:instance_eval)
|
107
|
+
manager.instance_variable_set(:@presets, { custom: preset_builder })
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'attempts compression when compression? returns true' do
|
111
|
+
allow(preset_builder).to receive(:compression?).and_return(true)
|
112
|
+
allow(preset_builder).to receive(:try_compress_inline_plugins!)
|
113
|
+
|
114
|
+
manager.override(:custom) {}
|
115
|
+
|
116
|
+
expect(preset_builder).to have_received(:try_compress_inline_plugins!).once
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'does not attempt compression when compression? returns false' do
|
120
|
+
allow(preset_builder).to receive(:compression?).and_return(false)
|
121
|
+
allow(preset_builder).to receive(:try_compress_inline_plugins!)
|
122
|
+
|
123
|
+
manager.override(:custom) {}
|
124
|
+
|
125
|
+
expect(preset_builder).not_to have_received(:try_compress_inline_plugins!)
|
126
|
+
end
|
127
|
+
end
|
72
128
|
end
|
73
129
|
|
74
130
|
describe '#[]' do
|
@@ -332,6 +332,14 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
332
332
|
end
|
333
333
|
end
|
334
334
|
|
335
|
+
describe '#disable_compression' do
|
336
|
+
it 'disables compression for inline plugins' do
|
337
|
+
builder.compression(enabled: false)
|
338
|
+
expect(builder.compression?).to be false
|
339
|
+
expect(builder.disallow_inline_plugin_compression).to be true
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
335
343
|
describe '#external_plugin' do
|
336
344
|
it 'adds external plugin to config' do
|
337
345
|
plugin = builder.external_plugin('Test', script: 'https://example.org/script.js')
|
@@ -710,7 +718,7 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
710
718
|
it 'applies patch when applicable' do
|
711
719
|
allow(patch_plugin).to receive(:applicable_for_version?).and_return(true)
|
712
720
|
|
713
|
-
builder.version('35.0.0')
|
721
|
+
builder.version('35.0.0', apply_patches: false)
|
714
722
|
builder.patch_plugin(patch_plugin)
|
715
723
|
|
716
724
|
plugin_names = builder.config[:plugins].map(&:name)
|
@@ -734,4 +742,19 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
734
742
|
expect(plugin_names).to include(:TestPatch)
|
735
743
|
end
|
736
744
|
end
|
745
|
+
|
746
|
+
describe '#apply_integration_patches' do
|
747
|
+
it 'applies known integration patches' do
|
748
|
+
builder.version('35.0.0', apply_patches: false)
|
749
|
+
expect { builder.apply_integration_patches }
|
750
|
+
.to change { builder.config[:plugins].count }
|
751
|
+
.by(1)
|
752
|
+
end
|
753
|
+
|
754
|
+
it 'apply patches when version is not set' do
|
755
|
+
expect { builder.apply_integration_patches }
|
756
|
+
.to change { builder.config[:plugins].count }
|
757
|
+
.by(1)
|
758
|
+
end
|
759
|
+
end
|
737
760
|
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.
|
4
|
+
version: 1.30.0
|
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: 2025-04-
|
12
|
+
date: 2025-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -89,7 +89,9 @@ files:
|
|
89
89
|
- lib/ckeditor5/rails/hooks/form.rb
|
90
90
|
- lib/ckeditor5/rails/hooks/importmap.rb
|
91
91
|
- lib/ckeditor5/rails/hooks/simple_form.rb
|
92
|
+
- lib/ckeditor5/rails/plugins.rb
|
92
93
|
- lib/ckeditor5/rails/plugins/custom_translations_loader.rb
|
94
|
+
- lib/ckeditor5/rails/plugins/patches/fix_color_picker_race_condition.rb
|
93
95
|
- lib/ckeditor5/rails/plugins/simple_upload_adapter.rb
|
94
96
|
- lib/ckeditor5/rails/plugins/special_characters_bootstrap.rb
|
95
97
|
- lib/ckeditor5/rails/plugins/wproofreader.rb
|