ckeditor5 1.20.1 → 1.21.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 +66 -2
- data/lib/ckeditor5/rails/assets/assets_bundle.rb +11 -1
- data/lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb +5 -10
- data/lib/ckeditor5/rails/assets/webcomponent_bundle.rb +10 -3
- data/lib/ckeditor5/rails/assets/webcomponents/components/editor.mjs +35 -2
- data/lib/ckeditor5/rails/assets/webcomponents/utils.mjs +36 -2
- data/lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb +57 -0
- data/lib/ckeditor5/rails/cdn/helpers.rb +62 -55
- data/lib/ckeditor5/rails/editor/helpers/editor_helpers.rb +25 -19
- data/lib/ckeditor5/rails/editor/props.rb +7 -14
- data/lib/ckeditor5/rails/engine.rb +13 -0
- data/lib/ckeditor5/rails/presets/manager.rb +2 -0
- data/lib/ckeditor5/rails/presets/preset_builder.rb +1 -1
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/e2e/features/ajax_form_integration_spec.rb +78 -0
- data/spec/e2e/features/lazy_assets_spec.rb +54 -0
- data/spec/e2e/support/form_helpers.rb +4 -1
- data/spec/lib/ckeditor5/rails/assets/assets_bundle_hml_serializer_spec.rb +53 -0
- data/spec/lib/ckeditor5/rails/assets/assets_bundle_spec.rb +2 -1
- data/spec/lib/ckeditor5/rails/cdn/helpers_spec.rb +95 -3
- data/spec/lib/ckeditor5/rails/editor/helpers/editor_helpers_spec.rb +85 -25
- data/spec/lib/ckeditor5/rails/editor/props_spec.rb +14 -34
- data/spec/lib/ckeditor5/rails/engine_spec.rb +10 -0
- data/spec/lib/ckeditor5/rails/hooks/form_spec.rb +15 -2
- data/spec/lib/ckeditor5/rails/plugins/wproofreader_spec.rb +2 -0
- data/spec/lib/ckeditor5/rails/version_detector_spec.rb +1 -1
- metadata +7 -2
@@ -3,34 +3,29 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe CKEditor5::Rails::Editor::Props do
|
6
|
-
let(:
|
7
|
-
{
|
8
|
-
bundle: double('Bundle', translations_scripts: [{ path: 'translations/en.js' }]),
|
9
|
-
license_key: nil
|
10
|
-
}
|
11
|
-
end
|
6
|
+
let(:bundle) { CKEditor5::Rails::Assets::AssetsBundle.new }
|
12
7
|
let(:type) { :classic }
|
13
8
|
let(:config) { { plugins: [], toolbar: { items: [] } } }
|
14
9
|
|
15
10
|
describe '#initialize' do
|
16
11
|
it 'accepts valid editor type' do
|
17
|
-
expect { described_class.new(
|
12
|
+
expect { described_class.new(type, {}, bundle: bundle) }.not_to raise_error
|
18
13
|
end
|
19
14
|
|
20
15
|
it 'raises error for invalid editor type' do
|
21
|
-
expect { described_class.new(
|
16
|
+
expect { described_class.new(:invalid, {}, bundle: bundle) }
|
22
17
|
.to raise_error(ArgumentError, 'Invalid editor type: invalid')
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
21
|
describe '#to_attributes' do
|
27
|
-
subject(:props) { described_class.new(
|
22
|
+
subject(:props) { described_class.new(type, config, bundle: bundle) }
|
28
23
|
|
29
24
|
it 'includes required attributes' do
|
30
25
|
attributes = props.to_attributes
|
31
26
|
expect(attributes).to include(
|
32
27
|
type: 'ClassicEditor',
|
33
|
-
|
28
|
+
bundle: String,
|
34
29
|
plugins: String,
|
35
30
|
config: String,
|
36
31
|
watchdog: true
|
@@ -38,33 +33,18 @@ RSpec.describe CKEditor5::Rails::Editor::Props do
|
|
38
33
|
end
|
39
34
|
|
40
35
|
context 'with editable height' do
|
41
|
-
subject(:props) { described_class.new(
|
36
|
+
subject(:props) { described_class.new(type, config, bundle: bundle, editable_height: '500px') }
|
42
37
|
|
43
38
|
it 'includes editable-height attribute' do
|
44
39
|
expect(props.to_attributes['editable-height']).to eq('500px')
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
|
-
context 'with
|
49
|
-
subject(:props) { described_class.new(
|
50
|
-
|
51
|
-
it 'includes language in config' do
|
52
|
-
config_json = props.to_attributes[:config]
|
53
|
-
|
54
|
-
expect(config_json).to include('language')
|
55
|
-
expect(JSON.parse(config_json)['language']).to eq({ 'ui' => 'pl' })
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with license key' do
|
60
|
-
let(:controller_context) do
|
61
|
-
{ bundle: double('Bundle', translations_scripts: []), license_key: 'ABC123' }
|
62
|
-
end
|
43
|
+
context 'with watchdog disabled' do
|
44
|
+
subject(:props) { described_class.new(type, config, bundle: bundle, watchdog: false) }
|
63
45
|
|
64
|
-
it 'includes
|
65
|
-
|
66
|
-
expect(config_json).to include('licenseKey')
|
67
|
-
expect(JSON.parse(config_json)['licenseKey']).to eq('ABC123')
|
46
|
+
it 'includes watchdog: false in attributes' do
|
47
|
+
expect(props.to_attributes[:watchdog]).to be false
|
68
48
|
end
|
69
49
|
end
|
70
50
|
end
|
@@ -87,7 +67,7 @@ RSpec.describe CKEditor5::Rails::Editor::Props do
|
|
87
67
|
|
88
68
|
it 'raises error when editable height is set' do
|
89
69
|
expect do
|
90
|
-
described_class.new(
|
70
|
+
described_class.new(type, config, bundle: bundle, editable_height: '500px')
|
91
71
|
end.to raise_error(CKEditor5::Rails::Editor::InvalidEditableHeightError)
|
92
72
|
end
|
93
73
|
end
|
@@ -96,18 +76,18 @@ RSpec.describe CKEditor5::Rails::Editor::Props do
|
|
96
76
|
let(:type) { :classic }
|
97
77
|
|
98
78
|
it 'accepts integer values' do
|
99
|
-
props = described_class.new(
|
79
|
+
props = described_class.new(type, config, bundle: bundle, editable_height: 500)
|
100
80
|
expect(props.to_attributes['editable-height']).to eq('500px')
|
101
81
|
end
|
102
82
|
|
103
83
|
it 'accepts pixel string values' do
|
104
|
-
props = described_class.new(
|
84
|
+
props = described_class.new(type, config, bundle: bundle, editable_height: '500px')
|
105
85
|
expect(props.to_attributes['editable-height']).to eq('500px')
|
106
86
|
end
|
107
87
|
|
108
88
|
it 'raises error for invalid values' do
|
109
89
|
expect do
|
110
|
-
described_class.new(
|
90
|
+
described_class.new(type, config, bundle: bundle, editable_height: '500em')
|
111
91
|
end.to raise_error(CKEditor5::Rails::Editor::InvalidEditableHeightError)
|
112
92
|
end
|
113
93
|
end
|
@@ -61,6 +61,16 @@ RSpec.describe CKEditor5::Rails::Engine do
|
|
61
61
|
expect(described_class.find_preset(:custom)).to eq(preset)
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe '.presets' do
|
66
|
+
before do
|
67
|
+
RSpec::Mocks.space.proxy_for(described_class).reset
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns presets from configuration' do
|
71
|
+
expect(described_class.presets).to eq(described_class.base.presets)
|
72
|
+
end
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
76
|
describe 'initializers' do
|
@@ -11,18 +11,31 @@ RSpec.describe CKEditor5::Rails::Hooks::Form do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
template.ckeditor5_assets(version: '34.1.0')
|
14
|
+
template.ckeditor5_assets(version: '34.1.0', automatic_upgrades: false, cdn: :jsdelivr)
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '#build_editor' do
|
18
18
|
subject(:rendered_editor) { builder.build_editor(:content) }
|
19
19
|
|
20
20
|
it 'renders ckeditor element' do
|
21
|
+
bundle_json = {
|
22
|
+
scripts: [
|
23
|
+
{
|
24
|
+
import_name: 'ckeditor5',
|
25
|
+
url: 'https://cdn.jsdelivr.net/npm/ckeditor5@34.1.0/dist/browser/ckeditor5.js',
|
26
|
+
translation: false
|
27
|
+
}
|
28
|
+
],
|
29
|
+
stylesheets: [
|
30
|
+
'https://cdn.jsdelivr.net/npm/ckeditor5@34.1.0/dist/browser/ckeditor5.css'
|
31
|
+
]
|
32
|
+
}.to_json
|
33
|
+
|
21
34
|
attrs = {
|
22
35
|
name: 'post[content]',
|
23
36
|
id: 'post_content',
|
24
37
|
type: 'ClassicEditor',
|
25
|
-
|
38
|
+
bundle: bundle_json,
|
26
39
|
watchdog: 'true'
|
27
40
|
}
|
28
41
|
|
@@ -24,6 +24,7 @@ RSpec.describe CKEditor5::Rails::Plugins::WProofreader do
|
|
24
24
|
expected_hash = {
|
25
25
|
type: :external,
|
26
26
|
stylesheets: ["#{default_cdn}@#{default_version}/dist/browser/index.css"],
|
27
|
+
translation: false,
|
27
28
|
url: "#{default_cdn}@#{default_version}/dist/browser/index.js",
|
28
29
|
import_name: "#{default_cdn}@#{default_version}/dist/browser/index.js",
|
29
30
|
import_as: 'WProofreader'
|
@@ -47,6 +48,7 @@ RSpec.describe CKEditor5::Rails::Plugins::WProofreader do
|
|
47
48
|
expected_hash = {
|
48
49
|
type: :external,
|
49
50
|
stylesheets: ["#{custom_cdn}@#{custom_version}/dist/browser/index.css"],
|
51
|
+
translation: false,
|
50
52
|
url: "#{custom_cdn}@#{custom_version}/dist/browser/index.js",
|
51
53
|
import_name: "#{custom_cdn}@#{custom_version}/dist/browser/index.js",
|
52
54
|
import_as: 'WProofreader'
|
@@ -118,7 +118,7 @@ RSpec.describe CKEditor5::Rails::VersionDetector do
|
|
118
118
|
|
119
119
|
private
|
120
120
|
|
121
|
-
def setup_http_mock(response)
|
121
|
+
def setup_http_mock(response)
|
122
122
|
allow(Net::HTTP).to receive(:new).and_return(
|
123
123
|
double('Net::HTTP').tap do |http|
|
124
124
|
allow(http).to receive(:use_ssl=)
|
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.21.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: 2024-12-
|
12
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/ckeditor5/rails/assets/webcomponents/utils.mjs
|
54
54
|
- lib/ckeditor5/rails/cdn/ckbox_bundle.rb
|
55
55
|
- lib/ckeditor5/rails/cdn/ckeditor_bundle.rb
|
56
|
+
- lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb
|
56
57
|
- lib/ckeditor5/rails/cdn/helpers.rb
|
57
58
|
- lib/ckeditor5/rails/cdn/url_generator.rb
|
58
59
|
- lib/ckeditor5/rails/context/helpers.rb
|
@@ -83,9 +84,11 @@ files:
|
|
83
84
|
- lib/ckeditor5/rails/semver.rb
|
84
85
|
- lib/ckeditor5/rails/version.rb
|
85
86
|
- lib/ckeditor5/rails/version_detector.rb
|
87
|
+
- spec/e2e/features/ajax_form_integration_spec.rb
|
86
88
|
- spec/e2e/features/context_spec.rb
|
87
89
|
- spec/e2e/features/editor_types_spec.rb
|
88
90
|
- spec/e2e/features/form_integration_spec.rb
|
91
|
+
- spec/e2e/features/lazy_assets_spec.rb
|
89
92
|
- spec/e2e/features/locale_spec.rb
|
90
93
|
- spec/e2e/spec_helper.rb
|
91
94
|
- spec/e2e/support/eventually.rb
|
@@ -149,9 +152,11 @@ signing_key:
|
|
149
152
|
specification_version: 4
|
150
153
|
summary: CKEditor 5 for Rails
|
151
154
|
test_files:
|
155
|
+
- spec/e2e/features/ajax_form_integration_spec.rb
|
152
156
|
- spec/e2e/features/context_spec.rb
|
153
157
|
- spec/e2e/features/editor_types_spec.rb
|
154
158
|
- spec/e2e/features/form_integration_spec.rb
|
159
|
+
- spec/e2e/features/lazy_assets_spec.rb
|
155
160
|
- spec/e2e/features/locale_spec.rb
|
156
161
|
- spec/e2e/spec_helper.rb
|
157
162
|
- spec/e2e/support/eventually.rb
|