ckeditor5 1.26.0 → 1.26.1
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/lib/ckeditor5/rails/editor/helpers/editor_helpers.rb +1 -1
- data/lib/ckeditor5/rails/plugins/patches/fix_color_picker_race_condition.rb +1 -1
- data/lib/ckeditor5/rails/presets/concerns/plugin_methods.rb +6 -4
- data/lib/ckeditor5/rails/presets/preset_builder.rb +3 -0
- data/lib/ckeditor5/rails/semver.rb +7 -0
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/lib/ckeditor5/rails/editor/helpers/editor_helpers_spec.rb +13 -0
- data/spec/lib/ckeditor5/rails/editor/props_patch_plugin_spec.rb +92 -6
- data/spec/lib/ckeditor5/rails/presets/preset_builder_spec.rb +64 -30
- data/spec/lib/ckeditor5/rails/semver_spec.rb +9 -0
- 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: b30c6cdd98e034209f4dd07ffa70d5a209c207fc1f7a7b37dfd58192a12ac4bc
|
4
|
+
data.tar.gz: e36f7f055fc52af917e2b146653879172a840af29e16665a650c6331092a18a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de3f06d82c4dedc97d34e3082a2f1aaf13323b9fb15ed0bc68d126fa4f63890234206e5fc52528e27332937d9330fc70440b687cc91a7facfe6f8a7b04271836
|
7
|
+
data.tar.gz: 26c4eeb0617420bd283841c0bd4bd77a3516eef5287e59a7388591bc6f8538838c7abba67ccc20fc4a32db5662daa8c168954767eb158a96a4cfcc626ed36310
|
@@ -73,7 +73,7 @@ module CKEditor5::Rails
|
|
73
73
|
type ||= preset.type
|
74
74
|
|
75
75
|
# Add some fallbacks
|
76
|
-
config[:licenseKey] ||= context[:license_key]
|
76
|
+
config[:licenseKey] ||= context[:license_key] || preset.license_key
|
77
77
|
config[:language] = { ui: language } if language
|
78
78
|
|
79
79
|
editor_props = Editor::Props.new(
|
@@ -80,7 +80,7 @@ module CKEditor5::Rails
|
|
80
80
|
raise InvalidPatchPluginError, 'Provided plugin must be a PropsPatchPlugin instance'
|
81
81
|
end
|
82
82
|
|
83
|
-
return unless plugin.applicable_for_version?(
|
83
|
+
return unless !@version || plugin.applicable_for_version?(@version)
|
84
84
|
|
85
85
|
register_plugin(plugin)
|
86
86
|
end
|
@@ -127,8 +127,10 @@ module CKEditor5::Rails
|
|
127
127
|
# Check if the plugin looks like an inline plugin
|
128
128
|
# @param plugin [Editor::PropsBasePlugin] Plugin instance
|
129
129
|
# @return [Boolean] True if the plugin is an inline plugin
|
130
|
-
def
|
131
|
-
plugin.respond_to?(:code) &&
|
130
|
+
def looks_like_unsafe_inline_plugin?(plugin)
|
131
|
+
plugin.respond_to?(:code) &&
|
132
|
+
plugin.code.present? &&
|
133
|
+
!plugin.is_a?(CKEditor5::Rails::Editor::PropsPatchPlugin)
|
132
134
|
end
|
133
135
|
|
134
136
|
# Register a plugin in the editor configuration.
|
@@ -140,7 +142,7 @@ module CKEditor5::Rails
|
|
140
142
|
# @param plugin_obj [Editor::PropsBasePlugin] Plugin instance to register
|
141
143
|
# @return [Editor::PropsBasePlugin] The registered plugin
|
142
144
|
def register_plugin(plugin_obj)
|
143
|
-
if disallow_inline_plugins &&
|
145
|
+
if disallow_inline_plugins && looks_like_unsafe_inline_plugin?(plugin_obj)
|
144
146
|
raise DisallowedInlinePluginError, 'Inline plugins are not allowed here.'
|
145
147
|
end
|
146
148
|
|
@@ -191,6 +191,9 @@ module CKEditor5::Rails
|
|
191
191
|
@version = Semver.new(version)
|
192
192
|
end
|
193
193
|
|
194
|
+
# If there is no license key set, and the version if newer than 44.0.0, switch to GPL
|
195
|
+
# as the license key is now required in all versions
|
196
|
+
gpl if license_key.nil? && @version.major >= 44
|
194
197
|
apply_integration_patches if apply_patches
|
195
198
|
end
|
196
199
|
|
@@ -10,6 +10,13 @@ module CKEditor5
|
|
10
10
|
include Comparable
|
11
11
|
|
12
12
|
def initialize(version_string)
|
13
|
+
if version_string.is_a?(Semver)
|
14
|
+
@major = version_string.major
|
15
|
+
@minor = version_string.minor
|
16
|
+
@patch = version_string.patch
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
13
20
|
validate!(version_string)
|
14
21
|
@major, @minor, @patch = version_string.split('.').map(&:to_i)
|
15
22
|
end
|
@@ -24,6 +24,7 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
24
24
|
allow(preset).to receive(:config).and_return({})
|
25
25
|
allow(preset).to receive(:automatic_upgrades?).and_return(false)
|
26
26
|
allow(preset).to receive(:editable_height).and_return(nil)
|
27
|
+
allow(preset).to receive(:license_key).and_return(nil)
|
27
28
|
end
|
28
29
|
|
29
30
|
before do
|
@@ -225,6 +226,18 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
225
226
|
expect(helper.ckeditor5_editor(editable_height: 600)).to include('editable-height="600px"')
|
226
227
|
end
|
227
228
|
end
|
229
|
+
|
230
|
+
context 'when using license key' do
|
231
|
+
it 'uses license key from preset when no other license key is provided' do
|
232
|
+
custom_context = { preset: :default, bundle: 'custom-bundle' }
|
233
|
+
allow(helper).to receive(:ckeditor5_context_or_fallback).and_return(custom_context)
|
234
|
+
|
235
|
+
allow(preset).to receive(:license_key).and_return('preset-license-key')
|
236
|
+
|
237
|
+
result = helper.ckeditor5_editor
|
238
|
+
expect(result).to include('preset-license-key')
|
239
|
+
end
|
240
|
+
end
|
228
241
|
end
|
229
242
|
|
230
243
|
describe '#ckeditor5_editable' do
|
@@ -36,6 +36,62 @@ RSpec.describe CKEditor5::Rails::Editor::PropsPatchPlugin do
|
|
36
36
|
expect(result).to be true
|
37
37
|
end
|
38
38
|
|
39
|
+
it 'returns true when version is equal to min constraint' do
|
40
|
+
result = described_class.applicable_for_version?(
|
41
|
+
'29.0.0',
|
42
|
+
min_version: '29.0.0'
|
43
|
+
)
|
44
|
+
expect(result).to be true
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns true when version is equal to max constraint' do
|
48
|
+
result = described_class.applicable_for_version?(
|
49
|
+
'30.0.0',
|
50
|
+
max_version: '30.0.0'
|
51
|
+
)
|
52
|
+
expect(result).to be true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns true when version is higher than min constraint (patch)' do
|
56
|
+
result = described_class.applicable_for_version?(
|
57
|
+
'29.0.1',
|
58
|
+
min_version: '29.0.0'
|
59
|
+
)
|
60
|
+
expect(result).to be true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns true when version is higher than min constraint (minor)' do
|
64
|
+
result = described_class.applicable_for_version?(
|
65
|
+
'29.1.0',
|
66
|
+
min_version: '29.0.0'
|
67
|
+
)
|
68
|
+
expect(result).to be true
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns true when version is higher than min constraint (major)' do
|
72
|
+
result = described_class.applicable_for_version?(
|
73
|
+
'30.0.0',
|
74
|
+
min_version: '29.0.0'
|
75
|
+
)
|
76
|
+
expect(result).to be true
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns false when version is not equal to max constraint (patch)' do
|
80
|
+
result = described_class.applicable_for_version?(
|
81
|
+
'30.0.1',
|
82
|
+
max_version: '30.0.0'
|
83
|
+
)
|
84
|
+
expect(result).to be false
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns false when version is not equal to min constraint (minor)' do
|
88
|
+
result = described_class.applicable_for_version?(
|
89
|
+
'29.1.0',
|
90
|
+
max_version: '29.0.0'
|
91
|
+
)
|
92
|
+
expect(result).to be false
|
93
|
+
end
|
94
|
+
|
39
95
|
it 'returns false when version is too low' do
|
40
96
|
result = described_class.applicable_for_version?(
|
41
97
|
'28.9.9',
|
@@ -56,16 +112,46 @@ RSpec.describe CKEditor5::Rails::Editor::PropsPatchPlugin do
|
|
56
112
|
end
|
57
113
|
|
58
114
|
describe '#applicable_for_version?' do
|
59
|
-
|
60
|
-
|
115
|
+
context 'with both version constraints' do
|
116
|
+
let(:plugin) do
|
117
|
+
described_class.new(plugin_name, plugin_code, min_version: '29.0.0', max_version: '30.0.0')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'returns true for version within constraints' do
|
121
|
+
expect(plugin.applicable_for_version?('29.1.0')).to be true
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns false for version outside constraints' do
|
125
|
+
expect(plugin.applicable_for_version?('28.9.9')).to be false
|
126
|
+
end
|
61
127
|
end
|
62
128
|
|
63
|
-
|
64
|
-
|
129
|
+
context 'with only min_version constraint' do
|
130
|
+
let(:plugin) do
|
131
|
+
described_class.new(plugin_name, plugin_code, min_version: '29.0.0')
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'returns true for version above min_version' do
|
135
|
+
expect(plugin.applicable_for_version?('30.0.0')).to be true
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'returns false for version below min_version' do
|
139
|
+
expect(plugin.applicable_for_version?('28.9.9')).to be false
|
140
|
+
end
|
65
141
|
end
|
66
142
|
|
67
|
-
|
68
|
-
|
143
|
+
context 'with only max_version constraint' do
|
144
|
+
let(:plugin) do
|
145
|
+
described_class.new(plugin_name, plugin_code, max_version: '30.0.0')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'returns true for version below max_version' do
|
149
|
+
expect(plugin.applicable_for_version?('29.0.0')).to be true
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'returns false for version above max_version' do
|
153
|
+
expect(plugin.applicable_for_version?('30.0.1')).to be false
|
154
|
+
end
|
69
155
|
end
|
70
156
|
end
|
71
157
|
end
|
@@ -31,6 +31,34 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe '#version' do
|
35
|
+
it 'sets version' do
|
36
|
+
builder.version '35.0.0'
|
37
|
+
expect(builder.version).to eq('35.0.0')
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with version >= 44.0.0' do
|
41
|
+
it 'sets GPL license when no license key is set' do
|
42
|
+
builder.version('44.0.0')
|
43
|
+
expect(builder.license_key).to eq('GPL')
|
44
|
+
expect(builder.premium?).to be false
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not change license when license key is already set' do
|
48
|
+
builder.license_key('commercial-key')
|
49
|
+
builder.version('44.0.0')
|
50
|
+
expect(builder.license_key).to eq('commercial-key')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with version < 44.0.0' do
|
55
|
+
it 'does not set GPL license automatically' do
|
56
|
+
builder.version('43.0.0')
|
57
|
+
expect(builder.license_key).to be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
34
62
|
describe '#initialize_copy' do
|
35
63
|
let(:original) do
|
36
64
|
described_class.new do
|
@@ -520,6 +548,10 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
520
548
|
end
|
521
549
|
|
522
550
|
describe '#special_characters' do
|
551
|
+
it 'should not crash if block is not provided' do
|
552
|
+
expect { builder.special_characters }.not_to raise_error
|
553
|
+
end
|
554
|
+
|
523
555
|
it 'configures special characters with groups and items' do # rubocop:disable Metrics/BlockLength
|
524
556
|
builder.special_characters do
|
525
557
|
group 'Emoji', label: 'Emoticons' do
|
@@ -542,36 +574,38 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
542
574
|
order :Text, :Arrows, :Emoji, :Mixed
|
543
575
|
end
|
544
576
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
577
|
+
data = {
|
578
|
+
groups: [
|
579
|
+
{
|
580
|
+
name: 'Emoji',
|
581
|
+
items: [
|
582
|
+
{ title: 'smiley', character: '😊' },
|
583
|
+
{ title: 'heart', character: '❤️' }
|
584
|
+
],
|
585
|
+
options: { label: 'Emoticons' }
|
586
|
+
},
|
587
|
+
{
|
588
|
+
name: 'Arrows',
|
589
|
+
items: [
|
590
|
+
{ title: 'right', character: '→' },
|
591
|
+
{ title: 'left', character: '←' }
|
592
|
+
],
|
593
|
+
options: {}
|
594
|
+
},
|
595
|
+
{
|
596
|
+
name: 'Mixed',
|
597
|
+
items: [
|
598
|
+
{ title: 'star', character: '⭐' },
|
599
|
+
{ title: 'heart', character: '❤️' }
|
600
|
+
],
|
601
|
+
options: { label: 'Mixed Characters' }
|
602
|
+
}
|
603
|
+
],
|
604
|
+
order: %w[Text Arrows Emoji Mixed],
|
605
|
+
packs: []
|
606
|
+
}
|
607
|
+
|
608
|
+
expect(builder.config[:specialCharactersBootstrap]).to eq(data)
|
575
609
|
|
576
610
|
plugin_names = builder.config[:plugins].map(&:name)
|
577
611
|
expect(plugin_names).to include(:SpecialCharacters)
|
@@ -8,6 +8,15 @@ RSpec.describe CKEditor5::Rails::Semver do
|
|
8
8
|
it 'accepts version in x.y.z format' do
|
9
9
|
expect { described_class.new('1.2.3') }.not_to raise_error
|
10
10
|
end
|
11
|
+
|
12
|
+
it 'accepts Semver object' do
|
13
|
+
original = described_class.new('1.2.3')
|
14
|
+
copied = described_class.new(original)
|
15
|
+
|
16
|
+
expect(copied.major).to eq(1)
|
17
|
+
expect(copied.minor).to eq(2)
|
18
|
+
expect(copied.patch).to eq(3)
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
context 'with invalid version' do
|