ckeditor5 1.35.1 → 1.82.3
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.
Potentially problematic release.
This version of ckeditor5 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +25 -158
- data/lib/ckeditor5/rails/assets/assets_bundle_html_serializer.rb +2 -2
- data/lib/ckeditor5/rails/assets/webcomponent_bundle.rb +21 -2
- data/lib/ckeditor5/rails/assets/webcomponents/components/context.mjs +123 -0
- data/lib/ckeditor5/rails/assets/webcomponents/components/editable.mjs +113 -0
- data/lib/ckeditor5/rails/assets/webcomponents/components/editor.mjs +778 -0
- data/lib/ckeditor5/rails/assets/webcomponents/components/ui-part.mjs +26 -0
- data/lib/ckeditor5/rails/assets/webcomponents/utils.mjs +235 -0
- data/lib/ckeditor5/rails/cdn/ckeditor_bundle.rb +2 -2
- data/lib/ckeditor5/rails/cdn/concerns/bundle_builder.rb +7 -5
- data/lib/ckeditor5/rails/cdn/helpers.rb +2 -2
- data/lib/ckeditor5/rails/context/helpers.rb +1 -6
- 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/helpers/editor_helpers.rb +4 -14
- data/lib/ckeditor5/rails/editor/props.rb +12 -7
- data/lib/ckeditor5/rails/editor/props_inline_plugin.rb +3 -6
- data/lib/ckeditor5/rails/editor/props_patch_plugin.rb +4 -2
- data/lib/ckeditor5/rails/engine.rb +6 -7
- data/lib/ckeditor5/rails/plugins/custom_translations_loader.rb +4 -3
- data/lib/ckeditor5/rails/plugins/simple_upload_adapter.rb +3 -2
- data/lib/ckeditor5/rails/plugins/special_characters_bootstrap.rb +3 -2
- data/lib/ckeditor5/rails/plugins/wproofreader.rb +3 -2
- data/lib/ckeditor5/rails/presets/concerns/plugin_methods.rb +3 -39
- data/lib/ckeditor5/rails/presets/manager.rb +3 -8
- data/lib/ckeditor5/rails/presets/preset_builder.rb +18 -28
- data/lib/ckeditor5/rails/presets/special_characters_builder.rb +2 -1
- data/lib/ckeditor5/rails/semver.rb +1 -1
- data/lib/ckeditor5/rails/version.rb +2 -2
- data/spec/e2e/features/context_spec.rb +1 -1
- data/spec/e2e/spec_helper.rb +1 -1
- data/spec/lib/ckeditor5/rails/cdn/helpers_spec.rb +12 -15
- data/spec/lib/ckeditor5/rails/context/preset_builder_spec.rb +0 -18
- data/spec/lib/ckeditor5/rails/editor/helpers/editor_helpers_spec.rb +0 -27
- data/spec/lib/ckeditor5/rails/editor/props_inline_plugin_spec.rb +0 -28
- data/spec/lib/ckeditor5/rails/editor/props_spec.rb +3 -13
- data/spec/lib/ckeditor5/rails/presets/manager_spec.rb +2 -58
- data/spec/lib/ckeditor5/rails/presets/preset_builder_spec.rb +2 -26
- data/spec/spec_helper.rb +1 -1
- metadata +10 -47
- data/lib/ckeditor5/rails/plugins/patches/fix_color_picker_race_condition.rb +0 -50
- data/lib/ckeditor5/rails/plugins.rb +0 -15
- data/npm_package/dist/index.cjs +0 -2
- data/npm_package/dist/index.cjs.map +0 -1
- data/npm_package/dist/index.d.ts +0 -1
- data/npm_package/dist/index.mjs +0 -723
- data/npm_package/dist/index.mjs.map +0 -1
- data/npm_package/dist/src/components/context.d.ts +0 -24
- data/npm_package/dist/src/components/context.d.ts.map +0 -1
- data/npm_package/dist/src/components/editable.d.ts +0 -34
- data/npm_package/dist/src/components/editable.d.ts.map +0 -1
- data/npm_package/dist/src/components/editor/editor.d.ts +0 -79
- data/npm_package/dist/src/components/editor/editor.d.ts.map +0 -1
- data/npm_package/dist/src/components/editor/index.d.ts +0 -3
- data/npm_package/dist/src/components/editor/index.d.ts.map +0 -1
- data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts +0 -36
- data/npm_package/dist/src/components/editor/multiroot-editables-tracker.d.ts.map +0 -1
- data/npm_package/dist/src/components/index.d.ts +0 -5
- data/npm_package/dist/src/components/index.d.ts.map +0 -1
- data/npm_package/dist/src/components/ui-part.d.ts +0 -2
- data/npm_package/dist/src/components/ui-part.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts +0 -7
- data/npm_package/dist/src/helpers/exec-if-dom-ready.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/index.d.ts +0 -8
- data/npm_package/dist/src/helpers/index.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/inject-script.d.ts +0 -8
- data/npm_package/dist/src/helpers/inject-script.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/is-safe-key.d.ts +0 -8
- data/npm_package/dist/src/helpers/is-safe-key.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/load-async-css.d.ts +0 -9
- data/npm_package/dist/src/helpers/load-async-css.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/load-async-imports.d.ts +0 -25
- data/npm_package/dist/src/helpers/load-async-imports.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts +0 -9
- data/npm_package/dist/src/helpers/resolve-config-element-references.d.ts.map +0 -1
- data/npm_package/dist/src/helpers/uid.d.ts +0 -7
- data/npm_package/dist/src/helpers/uid.d.ts.map +0 -1
- data/npm_package/dist/src/index.d.ts +0 -1
- data/npm_package/dist/src/index.d.ts.map +0 -1
- data/npm_package/dist/vite.config.d.ts +0 -3
- data/npm_package/dist/vite.config.d.ts.map +0 -1
- data/npm_package/package.json +0 -41
|
@@ -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 '44.3.0'
|
|
31
31
|
# gpl
|
|
32
32
|
# type :classic
|
|
33
33
|
# end
|
|
@@ -40,8 +40,6 @@ module CKEditor5::Rails::Presets
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
preset.instance_eval(&block)
|
|
43
|
-
preset.try_compress_inline_plugins! if preset.compression?
|
|
44
|
-
|
|
45
43
|
@presets[name] = preset
|
|
46
44
|
end
|
|
47
45
|
|
|
@@ -56,10 +54,7 @@ module CKEditor5::Rails::Presets
|
|
|
56
54
|
# end
|
|
57
55
|
# end
|
|
58
56
|
def override(name, &block)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
preset.instance_eval(&block)
|
|
62
|
-
preset.try_compress_inline_plugins! if preset.compression?
|
|
57
|
+
@presets[name].instance_eval(&block)
|
|
63
58
|
end
|
|
64
59
|
|
|
65
60
|
alias extend override
|
|
@@ -83,7 +78,7 @@ module CKEditor5::Rails::Presets
|
|
|
83
78
|
# @example Basic configuration
|
|
84
79
|
# CKEditor5::Rails.configure do
|
|
85
80
|
# presets.define :default do
|
|
86
|
-
# version '
|
|
81
|
+
# version '44.3.0'
|
|
87
82
|
# gpl
|
|
88
83
|
# type :classic
|
|
89
84
|
# 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
|
|
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 '44.3.0'
|
|
17
17
|
# gpl
|
|
18
18
|
# type :classic
|
|
19
19
|
# end
|
|
@@ -27,7 +27,6 @@ module CKEditor5::Rails
|
|
|
27
27
|
@ckbox = nil
|
|
28
28
|
@editable_height = nil
|
|
29
29
|
@automatic_upgrades = false
|
|
30
|
-
@disallow_inline_plugin_compression = false
|
|
31
30
|
@custom_translations = {}
|
|
32
31
|
@config = {
|
|
33
32
|
plugins: [],
|
|
@@ -37,6 +36,12 @@ module CKEditor5::Rails
|
|
|
37
36
|
instance_eval(&block) if block_given?
|
|
38
37
|
end
|
|
39
38
|
|
|
39
|
+
def deconstruct_keys(keys)
|
|
40
|
+
keys.index_with do |key|
|
|
41
|
+
public_send(key)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
40
45
|
# @example Copy preset and modify it
|
|
41
46
|
# original = PresetBuilder.new
|
|
42
47
|
# copied = original.initialize_copy(original)
|
|
@@ -169,15 +174,12 @@ module CKEditor5::Rails
|
|
|
169
174
|
|
|
170
175
|
# Set or get editor version
|
|
171
176
|
# @param version [String, nil] Editor version to set
|
|
172
|
-
# @param apply_patches [Boolean] Whether to apply integration patches after setting version
|
|
173
177
|
# @example Set specific version
|
|
174
|
-
# version '
|
|
175
|
-
# @example Set version without applying patches
|
|
176
|
-
# version '43.3.1', apply_patches: false
|
|
178
|
+
# version '44.3.0'
|
|
177
179
|
# @example Get current version
|
|
178
180
|
# version # => "43.3.1"
|
|
179
181
|
# @return [String, nil] Current version string or nil if not set
|
|
180
|
-
def version(version = nil
|
|
182
|
+
def version(version = nil)
|
|
181
183
|
return @version&.to_s if version.nil?
|
|
182
184
|
|
|
183
185
|
if @automatic_upgrades && version
|
|
@@ -190,13 +192,6 @@ module CKEditor5::Rails
|
|
|
190
192
|
# If there is no license key set, and the version if newer than 44.0.0, switch to GPL
|
|
191
193
|
# as the license key is now required in all versions
|
|
192
194
|
gpl if license_key.nil? && @version.major >= 44
|
|
193
|
-
apply_integration_patches if apply_patches
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
# Apply integration patches for the current version
|
|
197
|
-
# @return [void]
|
|
198
|
-
def apply_integration_patches(compress: !@disallow_inline_plugin_compression)
|
|
199
|
-
patch_plugin(Plugins::Patches::FixColorPickerRaceCondition.new(compress: compress))
|
|
200
195
|
end
|
|
201
196
|
|
|
202
197
|
# Enable or disable automatic version upgrades
|
|
@@ -333,7 +328,6 @@ module CKEditor5::Rails
|
|
|
333
328
|
# Configure custom translations for the editor
|
|
334
329
|
# @param lang_code [Symbol] Language code for translations (e.g. :en, :pl)
|
|
335
330
|
# @param translations [Hash] A hash containing translations in format { key => translation }
|
|
336
|
-
# @param compress [Boolean] Whether to compress the translations
|
|
337
331
|
# @example Add multiple translations
|
|
338
332
|
# custom_translations :en, {
|
|
339
333
|
# 'my.button': 'My Button'
|
|
@@ -352,15 +346,14 @@ module CKEditor5::Rails
|
|
|
352
346
|
# ]
|
|
353
347
|
# }
|
|
354
348
|
# @return [void]
|
|
355
|
-
def custom_translations(lang_code = nil, translations = {}
|
|
356
|
-
compress: !@disallow_inline_plugin_compression)
|
|
349
|
+
def custom_translations(lang_code = nil, translations = {})
|
|
357
350
|
return @custom_translations if lang_code.blank?
|
|
358
351
|
|
|
359
352
|
@custom_translations[lang_code.to_sym] ||= {}
|
|
360
353
|
@custom_translations[lang_code.to_sym].merge!(translations)
|
|
361
354
|
|
|
362
355
|
plugins.remove(:CustomTranslationsLoader)
|
|
363
|
-
plugins.prepend(Plugins::CustomTranslationsLoader.new(@custom_translations
|
|
356
|
+
plugins.prepend(Plugins::CustomTranslationsLoader.new(@custom_translations))
|
|
364
357
|
end
|
|
365
358
|
|
|
366
359
|
# Configure editor language
|
|
@@ -388,37 +381,34 @@ module CKEditor5::Rails
|
|
|
388
381
|
|
|
389
382
|
# Configure simple upload adapter
|
|
390
383
|
# @param upload_url [String] Upload endpoint URL
|
|
391
|
-
# @param compress [Boolean] Enable compression
|
|
392
384
|
# @example Enable upload adapter
|
|
393
385
|
# simple_upload_adapter '/uploads'
|
|
394
|
-
def simple_upload_adapter(upload_url = '/uploads'
|
|
386
|
+
def simple_upload_adapter(upload_url = '/uploads')
|
|
395
387
|
plugins do
|
|
396
388
|
remove(:Base64UploadAdapter)
|
|
397
389
|
end
|
|
398
390
|
|
|
399
|
-
plugin(Plugins::SimpleUploadAdapter.new
|
|
391
|
+
plugin(Plugins::SimpleUploadAdapter.new)
|
|
400
392
|
configure(:simpleUpload, { uploadUrl: upload_url })
|
|
401
393
|
end
|
|
402
394
|
|
|
403
395
|
# Configure WProofreader plugin
|
|
404
396
|
# @param version [String, nil] Plugin version
|
|
405
397
|
# @param cdn [String, nil] CDN URL
|
|
406
|
-
# @param compress [Boolean] Enable compression
|
|
407
398
|
# @param config [Hash] Plugin configuration
|
|
408
399
|
# @example Basic configuration
|
|
409
400
|
# wproofreader serviceId: 'your-service-ID',
|
|
410
401
|
# srcUrl: 'https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js'
|
|
411
|
-
def wproofreader(version: nil, cdn: nil,
|
|
402
|
+
def wproofreader(version: nil, cdn: nil, **config)
|
|
412
403
|
configure :wproofreader, config
|
|
413
404
|
plugins do
|
|
414
|
-
prepend(Plugins::WProofreaderSync.new
|
|
405
|
+
prepend(Plugins::WProofreaderSync.new)
|
|
415
406
|
append(Plugins::WProofreader.new(version: version, cdn: cdn))
|
|
416
407
|
end
|
|
417
408
|
end
|
|
418
409
|
|
|
419
410
|
# Configure special characters plugin
|
|
420
411
|
#
|
|
421
|
-
# @param compress [Boolean] Enable compression
|
|
422
412
|
# @yield Block for configuring special characters
|
|
423
413
|
# @example Basic configuration with block
|
|
424
414
|
# special_characters do
|
|
@@ -444,14 +434,14 @@ module CKEditor5::Rails
|
|
|
444
434
|
# item 'heart', '❤️'
|
|
445
435
|
# end
|
|
446
436
|
# end
|
|
447
|
-
def special_characters(
|
|
437
|
+
def special_characters(&block)
|
|
448
438
|
builder = SpecialCharactersBuilder.new
|
|
449
439
|
builder.instance_eval(&block) if block_given?
|
|
450
440
|
|
|
451
441
|
plugins do
|
|
452
442
|
append(:SpecialCharacters)
|
|
453
443
|
builder.packs_plugins.each { |pack| append(pack) }
|
|
454
|
-
prepend(Plugins::SpecialCharactersBootstrap.new
|
|
444
|
+
prepend(Plugins::SpecialCharactersBootstrap.new)
|
|
455
445
|
end
|
|
456
446
|
|
|
457
447
|
configure(:specialCharactersBootstrap, builder.to_h)
|
|
@@ -20,7 +20,8 @@ module CKEditor5::Rails::Presets
|
|
|
20
20
|
# group = Group.new('Emoji', label: 'Emoticons')
|
|
21
21
|
# group.item('smiley', '😊')
|
|
22
22
|
class Group
|
|
23
|
-
attr_reader :name, :label
|
|
23
|
+
attr_reader :name, :label
|
|
24
|
+
private attr_reader :items
|
|
24
25
|
|
|
25
26
|
# Initialize a new special characters group
|
|
26
27
|
#
|
|
@@ -17,7 +17,7 @@ RSpec.describe 'CKEditor5 Context Integration', type: :feature, js: true do
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'allows editing content in context editors' do
|
|
20
|
-
editors = all('.ck-editor__editable'
|
|
20
|
+
editors = all('.ck-editor__editable')
|
|
21
21
|
|
|
22
22
|
# Test first editor
|
|
23
23
|
editors[0].click
|
data/spec/e2e/spec_helper.rb
CHANGED
|
@@ -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'
|
|
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'
|
|
155
155
|
type :classic
|
|
156
156
|
language :pl
|
|
157
157
|
cdn :cloud
|
|
@@ -200,13 +200,16 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
|
200
200
|
|
|
201
201
|
expect(context[:preset].language).to eq({ ui: :pl, content: :pl })
|
|
202
202
|
end
|
|
203
|
+
end
|
|
203
204
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
context 'with missing required parameters' do
|
|
206
|
+
before do
|
|
207
|
+
allow(helper).to receive(:merge_with_editor_preset).and_return({})
|
|
208
|
+
end
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
it 'raises error about missing required parameters' do
|
|
211
|
+
expect { helper.ckeditor5_assets(preset: :default) }
|
|
212
|
+
.to raise_error(NoMatchingPatternKeyError)
|
|
210
213
|
end
|
|
211
214
|
end
|
|
212
215
|
|
|
@@ -358,7 +361,7 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
|
358
361
|
|
|
359
362
|
describe '#ckeditor5_inline_plugins_tags' do
|
|
360
363
|
let(:preset) do
|
|
361
|
-
|
|
364
|
+
CKEditor5::Rails::Presets::PresetBuilder.new do
|
|
362
365
|
inline_plugin 'Plugin1', <<~JAVASCRIPT
|
|
363
366
|
const { Plugin } = await import( 'ckeditor5' );
|
|
364
367
|
|
|
@@ -379,13 +382,10 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
|
379
382
|
}
|
|
380
383
|
JAVASCRIPT
|
|
381
384
|
end
|
|
382
|
-
|
|
383
|
-
preset.try_compress_inline_plugins!
|
|
384
|
-
preset
|
|
385
385
|
end
|
|
386
386
|
|
|
387
387
|
let(:another_preset) do
|
|
388
|
-
|
|
388
|
+
CKEditor5::Rails::Presets::PresetBuilder.new do
|
|
389
389
|
inline_plugin 'Plugin3', <<~JAVASCRIPT
|
|
390
390
|
const { Plugin } = await import( 'ckeditor5' );
|
|
391
391
|
|
|
@@ -396,9 +396,6 @@ RSpec.describe CKEditor5::Rails::Cdn::Helpers do
|
|
|
396
396
|
}
|
|
397
397
|
JAVASCRIPT
|
|
398
398
|
end
|
|
399
|
-
|
|
400
|
-
preset.try_compress_inline_plugins!
|
|
401
|
-
preset
|
|
402
399
|
end
|
|
403
400
|
|
|
404
401
|
before do
|
|
@@ -83,24 +83,6 @@ RSpec.describe CKEditor5::Rails::Context::PresetBuilder do
|
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
describe 'try_compress_inline_plugins!' do
|
|
87
|
-
let(:plugin_code) do
|
|
88
|
-
<<~JAVASCRIPT
|
|
89
|
-
const { Plugin } = await import( 'ckeditor5' );
|
|
90
|
-
|
|
91
|
-
return class Abc extends Plugin {}
|
|
92
|
-
JAVASCRIPT
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'raises CompressionDisabledError when compression is disabled' do
|
|
96
|
-
builder.instance_variable_set(:@disallow_inline_plugin_compression, true)
|
|
97
|
-
|
|
98
|
-
expect do
|
|
99
|
-
builder.try_compress_inline_plugins!
|
|
100
|
-
end.to raise_error(CKEditor5::Rails::Presets::Concerns::PluginMethods::CompressionDisabledError)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
86
|
describe '#inline_plugin' do
|
|
105
87
|
let(:plugin_code) do
|
|
106
88
|
<<~JAVASCRIPT
|
|
@@ -238,13 +238,6 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
|
238
238
|
expect(result).to include('preset-license-key')
|
|
239
239
|
end
|
|
240
240
|
end
|
|
241
|
-
|
|
242
|
-
context 'turbo temporary attribute' do
|
|
243
|
-
it 'includes data-turbo-temporary attribute in the editor component' do
|
|
244
|
-
result = helper.ckeditor5_editor
|
|
245
|
-
expect(result).to include('data-turbo-temporary="true"')
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
241
|
end
|
|
249
242
|
|
|
250
243
|
describe '#ckeditor5_editable' do
|
|
@@ -254,11 +247,6 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
|
254
247
|
with: { name: 'content' }
|
|
255
248
|
)
|
|
256
249
|
end
|
|
257
|
-
|
|
258
|
-
it 'includes data-turbo-temporary attribute in the editable component' do
|
|
259
|
-
result = helper.ckeditor5_editable('content')
|
|
260
|
-
expect(result).to include('data-turbo-temporary="true"')
|
|
261
|
-
end
|
|
262
250
|
end
|
|
263
251
|
|
|
264
252
|
describe '#ckeditor5_ui_part' do
|
|
@@ -268,11 +256,6 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
|
268
256
|
with: { name: 'toolbar' }
|
|
269
257
|
)
|
|
270
258
|
end
|
|
271
|
-
|
|
272
|
-
it 'includes data-turbo-temporary attribute in the ui part component' do
|
|
273
|
-
result = helper.ckeditor5_ui_part('toolbar')
|
|
274
|
-
expect(result).to include('data-turbo-temporary="true"')
|
|
275
|
-
end
|
|
276
259
|
end
|
|
277
260
|
|
|
278
261
|
describe '#ckeditor5_toolbar' do
|
|
@@ -282,11 +265,6 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
|
282
265
|
with: { name: 'toolbar' }
|
|
283
266
|
)
|
|
284
267
|
end
|
|
285
|
-
|
|
286
|
-
it 'includes data-turbo-temporary attribute in the toolbar component' do
|
|
287
|
-
result = helper.ckeditor5_toolbar
|
|
288
|
-
expect(result).to include('data-turbo-temporary="true"')
|
|
289
|
-
end
|
|
290
268
|
end
|
|
291
269
|
|
|
292
270
|
describe '#ckeditor5_menubar' do
|
|
@@ -296,10 +274,5 @@ RSpec.describe CKEditor5::Rails::Editor::Helpers::Editor do
|
|
|
296
274
|
with: { name: 'menuBarView' }
|
|
297
275
|
)
|
|
298
276
|
end
|
|
299
|
-
|
|
300
|
-
it 'includes data-turbo-temporary attribute in the menubar component' do
|
|
301
|
-
result = helper.ckeditor5_menubar
|
|
302
|
-
expect(result).to include('data-turbo-temporary="true"')
|
|
303
|
-
end
|
|
304
277
|
end
|
|
305
278
|
end
|
|
@@ -26,34 +26,6 @@ RSpec.describe CKEditor5::Rails::Editor::PropsInlinePlugin do
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
describe '#try_compress!' do
|
|
30
|
-
let(:plugin) { described_class.new(:CustomPlugin, valid_code) }
|
|
31
|
-
let(:compiled_code) { '(async()=>{const compressed_code})()' }
|
|
32
|
-
let(:terser_instance) { instance_double('Terser') }
|
|
33
|
-
|
|
34
|
-
context 'when compression is enabled' do
|
|
35
|
-
it 'compresses the code using Terser' do
|
|
36
|
-
expect(Terser).to receive(:new).with(compress: false, mangle: true).and_return(terser_instance)
|
|
37
|
-
expect(terser_instance).to receive(:compile).with(plugin.code).and_return(compiled_code)
|
|
38
|
-
|
|
39
|
-
plugin.try_compress!
|
|
40
|
-
expect(plugin.code).to eq(compiled_code)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context 'when compression is disabled' do
|
|
45
|
-
let(:plugin) { described_class.new(:CustomPlugin, valid_code, compress: false) }
|
|
46
|
-
let(:original_code) { plugin.code.dup }
|
|
47
|
-
|
|
48
|
-
it 'does not modify the code' do
|
|
49
|
-
expect(Terser).not_to receive(:new)
|
|
50
|
-
|
|
51
|
-
plugin.try_compress!
|
|
52
|
-
expect(plugin.code).to eq(original_code)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
29
|
describe '#to_h' do
|
|
58
30
|
it 'returns correct hash representation' do
|
|
59
31
|
plugin = described_class.new(:CustomPlugin, valid_code)
|
|
@@ -32,21 +32,11 @@ RSpec.describe CKEditor5::Rails::Editor::Props do
|
|
|
32
32
|
)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
context 'when bundle is nil' do
|
|
36
|
-
let(:bundle) { nil }
|
|
37
|
-
|
|
38
|
-
it 'includes bundle attribute with nil value' do
|
|
39
|
-
attributes = props.to_attributes
|
|
40
|
-
expect(attributes).to have_key(:bundle)
|
|
41
|
-
expect(attributes[:bundle]).to be_nil
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
35
|
context 'with editable height' do
|
|
46
36
|
subject(:props) { described_class.new(type, config, bundle: bundle, editable_height: '500px') }
|
|
47
37
|
|
|
48
38
|
it 'includes editable-height attribute' do
|
|
49
|
-
expect(props.to_attributes[
|
|
39
|
+
expect(props.to_attributes['editable-height']).to eq('500px')
|
|
50
40
|
end
|
|
51
41
|
end
|
|
52
42
|
|
|
@@ -87,12 +77,12 @@ RSpec.describe CKEditor5::Rails::Editor::Props do
|
|
|
87
77
|
|
|
88
78
|
it 'accepts integer values' do
|
|
89
79
|
props = described_class.new(type, config, bundle: bundle, editable_height: 500)
|
|
90
|
-
expect(props.to_attributes[
|
|
80
|
+
expect(props.to_attributes['editable-height']).to eq('500px')
|
|
91
81
|
end
|
|
92
82
|
|
|
93
83
|
it 'accepts pixel string values' do
|
|
94
84
|
props = described_class.new(type, config, bundle: bundle, editable_height: '500px')
|
|
95
|
-
expect(props.to_attributes[
|
|
85
|
+
expect(props.to_attributes['editable-height']).to eq('500px')
|
|
96
86
|
end
|
|
97
87
|
|
|
98
88
|
it 'raises error for invalid values' do
|
|
@@ -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'
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
expect(manager[:custom].version).to eq('36.0.0')
|
|
@@ -32,42 +32,13 @@ 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'
|
|
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
|
|
71
42
|
end
|
|
72
43
|
|
|
73
44
|
describe '#override/#extend' do
|
|
@@ -98,33 +69,6 @@ RSpec.describe CKEditor5::Rails::Presets::Manager do
|
|
|
98
69
|
|
|
99
70
|
expect(manager[:custom].version).to eq('36.0.0')
|
|
100
71
|
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
|
|
128
72
|
end
|
|
129
73
|
|
|
130
74
|
describe '#[]' do
|
|
@@ -280,8 +280,7 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
|
280
280
|
end
|
|
281
281
|
|
|
282
282
|
it 'adds inline plugin to configuration' do
|
|
283
|
-
builder.inline_plugin(:CustomPlugin, plugin_code
|
|
284
|
-
builder.try_compress_inline_plugins!
|
|
283
|
+
builder.inline_plugin(:CustomPlugin, plugin_code)
|
|
285
284
|
|
|
286
285
|
plugin = builder.config[:plugins].first
|
|
287
286
|
expect(plugin).to be_a(CKEditor5::Rails::Editor::PropsInlinePlugin)
|
|
@@ -332,14 +331,6 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
|
332
331
|
end
|
|
333
332
|
end
|
|
334
333
|
|
|
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
|
-
|
|
343
334
|
describe '#external_plugin' do
|
|
344
335
|
it 'adds external plugin to config' do
|
|
345
336
|
plugin = builder.external_plugin('Test', script: 'https://example.org/script.js')
|
|
@@ -718,7 +709,7 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
|
718
709
|
it 'applies patch when applicable' do
|
|
719
710
|
allow(patch_plugin).to receive(:applicable_for_version?).and_return(true)
|
|
720
711
|
|
|
721
|
-
builder.version('35.0.0'
|
|
712
|
+
builder.version('35.0.0')
|
|
722
713
|
builder.patch_plugin(patch_plugin)
|
|
723
714
|
|
|
724
715
|
plugin_names = builder.config[:plugins].map(&:name)
|
|
@@ -742,19 +733,4 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
|
742
733
|
expect(plugin_names).to include(:TestPatch)
|
|
743
734
|
end
|
|
744
735
|
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
|
|
760
736
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -34,7 +34,7 @@ require 'rspec/rails'
|
|
|
34
34
|
require 'rspec/expectations'
|
|
35
35
|
require 'rspec-html-matchers'
|
|
36
36
|
|
|
37
|
-
Dir[File.expand_path('support/**/*.rb', __dir__)].
|
|
37
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
|
|
38
38
|
|
|
39
39
|
Rails.application.initialize! unless Rails.application.initialized?
|
|
40
40
|
|