ckeditor5 1.23.0 → 1.23.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/Gemfile +16 -12
- data/README.md +50 -3
- data/lib/ckeditor5/rails/assets/webcomponents/components/editor.mjs +10 -1
- data/lib/ckeditor5/rails/editor/editable_height_normalizer.rb +2 -2
- data/lib/ckeditor5/rails/presets/preset_builder.rb +38 -4
- data/lib/ckeditor5/rails/version.rb +1 -1
- data/spec/lib/ckeditor5/rails/editor/editable_height_normalizer_spec.rb +13 -5
- data/spec/lib/ckeditor5/rails/presets/preset_builder_spec.rb +44 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2de59df11814137ec61eddc70cdb6b8e2ad41a3ce36a1b05f1465bcc34f0e3cf
|
|
4
|
+
data.tar.gz: 6758a10a972ca02b7f004bc1829ddabf7b98f4200e05cd6006ee7ca4ecbb2a22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 119d9e0202d230327df5a5cd9feff5fde6777682c0a6578af70dcd4aeaf4ee1639cee87b38fa532ecebaa53b94a157299549fa7109cb127bf6c3f4f8426b05d9
|
|
7
|
+
data.tar.gz: 4576053427f4b2a464810dac8a14c23b90cdd64ae3e26368cd64154e71e1a63a35b9418ee062e33b65c987598e0f23ec5dd01e047ccc24a7b1fadeaf50966f23
|
data/Gemfile
CHANGED
|
@@ -3,26 +3,30 @@
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
4
|
|
|
5
5
|
gem 'bundler', '~> 2.5', '>= 2.5.21'
|
|
6
|
+
gem 'importmap-rails'
|
|
7
|
+
gem 'propshaft'
|
|
8
|
+
gem 'pry', '~> 0.15', '>= 0.15.0'
|
|
9
|
+
gem 'pry-rails', '~> 0.3', '>= 0.3.11'
|
|
10
|
+
gem 'rails', '~> 8.0', '>= 8.0.0'
|
|
11
|
+
gem 'rake', '~> 13.2', '>= 13.2.1'
|
|
12
|
+
gem 'simple_form', '~> 5.3', '>= 5.3.0'
|
|
13
|
+
gem 'slim', '~> 5.2', '>= 5.2.0'
|
|
14
|
+
gem 'sqlite3', '~> 2.4', '>= 2.4.1'
|
|
15
|
+
gem 'stimulus-rails'
|
|
16
|
+
gem 'terser', '~> 1.1', '>= 1.1.1'
|
|
17
|
+
gem 'turbo-rails'
|
|
18
|
+
|
|
19
|
+
group :production do
|
|
20
|
+
gem 'puma', '~> 6.5'
|
|
21
|
+
end
|
|
6
22
|
|
|
7
23
|
group :development do
|
|
8
24
|
gem 'brakeman', '~> 6.1', '>= 6.1.1', require: false
|
|
9
25
|
gem 'guard', '~> 2.19', '>= 2.19.0'
|
|
10
26
|
gem 'guard-process', '~> 1.2'
|
|
11
|
-
gem 'importmap-rails'
|
|
12
|
-
gem 'propshaft'
|
|
13
|
-
gem 'pry', '~> 0.15', '>= 0.15.0'
|
|
14
|
-
gem 'pry-rails', '~> 0.3', '>= 0.3.11'
|
|
15
|
-
gem 'rails', '~> 8.0', '>= 8.0.0'
|
|
16
|
-
gem 'rake', '~> 13.2', '>= 13.2.1'
|
|
17
27
|
gem 'rubocop', '~> 1.66', require: false
|
|
18
28
|
gem 'rubocop-rails', '~> 2.26', '>= 2.26.2', require: false
|
|
19
29
|
gem 'rubocop-rails-omakase', '~> 1.0.0', require: false
|
|
20
|
-
gem 'simple_form', '~> 5.3', '>= 5.3.0'
|
|
21
|
-
gem 'slim', '~> 5.2', '>= 5.2.0'
|
|
22
|
-
gem 'sqlite3', '>= 1.4'
|
|
23
|
-
gem 'stimulus-rails'
|
|
24
|
-
gem 'terser', '~> 1.1', '>= 1.1.1'
|
|
25
|
-
gem 'turbo-rails'
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
group :test, :development do
|
data/README.md
CHANGED
|
@@ -32,9 +32,8 @@ In your layout:
|
|
|
32
32
|
<head>
|
|
33
33
|
<!--
|
|
34
34
|
⚠️ **Important**: When using `importmap-rails`, make sure the importmap
|
|
35
|
-
tags are rendered after `ckeditor5_assets` helper.
|
|
36
|
-
|
|
37
|
-
This is crucial for CKEditor 5 to work correctly.
|
|
35
|
+
tags are rendered after `ckeditor5_assets` helper. In this scenario,
|
|
36
|
+
content is yielded before rendering `javascript_importmap_tags`.
|
|
38
37
|
-->
|
|
39
38
|
<!-- javascript_importmap_tags -->
|
|
40
39
|
<%= yield :head %>
|
|
@@ -131,6 +130,8 @@ For extending CKEditor's functionality, refer to the [plugins directory](https:/
|
|
|
131
130
|
- [`ckbox` method](#ckbox-method)
|
|
132
131
|
- [`type(type)` method](#typetype-method)
|
|
133
132
|
- [`toolbar(*items, should_group_when_full: true, &block)` method](#toolbaritems-should_group_when_full-true-block-method)
|
|
133
|
+
- [`block_toolbar(*items, should_group_when_full: true, &block)` method](#block_toolbaritems-should_group_when_full-true-block-method)
|
|
134
|
+
- [`balloon_toolbar(*items, should_group_when_full: true, &block)` method](#balloon_toolbaritems-should_group_when_full-true-block-method)
|
|
134
135
|
- [`menubar(visible: true)` method](#menubarvisible-true-method)
|
|
135
136
|
- [`configure(name, value)` method](#configurename-value-method)
|
|
136
137
|
- [`plugin(name, premium:, import_name:)` method](#pluginname-premium-import_name-method)
|
|
@@ -645,6 +646,52 @@ end
|
|
|
645
646
|
|
|
646
647
|
</details>
|
|
647
648
|
|
|
649
|
+
#### `block_toolbar(*items, should_group_when_full: true, &block)` method
|
|
650
|
+
|
|
651
|
+
<details>
|
|
652
|
+
<summary>Define block toolbar items and their grouping behavior</summary>
|
|
653
|
+
|
|
654
|
+
<br />
|
|
655
|
+
|
|
656
|
+
API is identical to the `toolbar` method, but it's used for block toolbar items. The example below shows how to define block toolbar items:
|
|
657
|
+
|
|
658
|
+
```rb
|
|
659
|
+
# config/initializers/ckeditor5.rb
|
|
660
|
+
|
|
661
|
+
CKEditor5::Rails.configure do
|
|
662
|
+
# ... other configuration
|
|
663
|
+
|
|
664
|
+
block_toolbar :paragraph, :heading, :blockQuote, :|, :bulletedList, :numberedList, :todoList
|
|
665
|
+
end
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
It is useful when you want to use Block Balloon Editor or Block Toolbar features.
|
|
669
|
+
|
|
670
|
+
</details>
|
|
671
|
+
|
|
672
|
+
#### `balloon_toolbar(*items, should_group_when_full: true, &block)` method
|
|
673
|
+
|
|
674
|
+
<details>
|
|
675
|
+
<summary>Define balloon toolbar items and their grouping behavior</summary>
|
|
676
|
+
|
|
677
|
+
<br />
|
|
678
|
+
|
|
679
|
+
API is identical to the `toolbar` method, but it's used for balloon toolbar items. The example below shows how to define balloon toolbar items:
|
|
680
|
+
|
|
681
|
+
```rb
|
|
682
|
+
# config/initializers/ckeditor5.rb
|
|
683
|
+
|
|
684
|
+
CKEditor5::Rails.configure do
|
|
685
|
+
# ... other configuration
|
|
686
|
+
|
|
687
|
+
balloon_toolbar :bold, :italic, :underline, :link, :insertImage, :mediaEmbed, :insertTable, :blockQuote
|
|
688
|
+
end
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
It is useful when you want to use Balloon Editor or Balloon Toolbar features.
|
|
692
|
+
|
|
693
|
+
</details>
|
|
694
|
+
|
|
648
695
|
#### `menubar(visible: true)` method
|
|
649
696
|
|
|
650
697
|
<details>
|
|
@@ -407,6 +407,15 @@ class CKEditorComponent extends HTMLElement {
|
|
|
407
407
|
return this.getAttribute('type') === 'ClassicEditor';
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
/**
|
|
411
|
+
* Checks if current editor is balloon type
|
|
412
|
+
*
|
|
413
|
+
* @returns {boolean}
|
|
414
|
+
*/
|
|
415
|
+
isBallon() {
|
|
416
|
+
return this.getAttribute('type') === 'BalloonEditor';
|
|
417
|
+
}
|
|
418
|
+
|
|
410
419
|
/**
|
|
411
420
|
* Checks if current editor is multiroot type
|
|
412
421
|
*
|
|
@@ -542,7 +551,7 @@ class CKEditorComponent extends HTMLElement {
|
|
|
542
551
|
* @private
|
|
543
552
|
*/
|
|
544
553
|
#setupEditableHeight() {
|
|
545
|
-
if (!this.isClassic()) {
|
|
554
|
+
if (!this.isClassic() && !this.isBallon()) {
|
|
546
555
|
return;
|
|
547
556
|
}
|
|
548
557
|
|
|
@@ -20,10 +20,10 @@ module CKEditor5::Rails::Editor
|
|
|
20
20
|
attr_reader :editor_type
|
|
21
21
|
|
|
22
22
|
def validate_editor_type!
|
|
23
|
-
return if editor_type
|
|
23
|
+
return if %i[classic balloon].include?(editor_type)
|
|
24
24
|
|
|
25
25
|
raise InvalidEditableHeightError,
|
|
26
|
-
'editable_height can be used only with ClassicEditor'
|
|
26
|
+
'editable_height can be used only with ClassicEditor or BalloonEditor'
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def convert_to_pixel_value(value)
|
|
@@ -263,19 +263,53 @@ module CKEditor5::Rails
|
|
|
263
263
|
# remove :heading
|
|
264
264
|
# end
|
|
265
265
|
# @return [ToolbarBuilder] Toolbar configuration
|
|
266
|
-
def toolbar(*items, should_group_when_full: true, &block)
|
|
267
|
-
if @config[
|
|
268
|
-
@config[
|
|
266
|
+
def toolbar(*items, should_group_when_full: true, type: :toolbar, &block)
|
|
267
|
+
if @config[type].blank? || !items.empty?
|
|
268
|
+
@config[type] = {
|
|
269
269
|
items: items,
|
|
270
270
|
shouldNotGroupWhenFull: !should_group_when_full
|
|
271
271
|
}
|
|
272
272
|
end
|
|
273
273
|
|
|
274
|
-
builder = ToolbarBuilder.new(@config[
|
|
274
|
+
builder = ToolbarBuilder.new(@config[type][:items])
|
|
275
275
|
builder.instance_eval(&block) if block_given?
|
|
276
276
|
builder
|
|
277
277
|
end
|
|
278
278
|
|
|
279
|
+
# Configure block toolbar items and grouping
|
|
280
|
+
# @param items [Array<Symbol>] Toolbar items to include
|
|
281
|
+
# @param kwargs [Hash] Additional toolbar configuration options
|
|
282
|
+
# @option kwargs [Boolean] :should_group_when_full Enable/disable toolbar item grouping
|
|
283
|
+
# @yield Optional block for additional toolbar configuration
|
|
284
|
+
# @return [ToolbarBuilder] Toolbar configuration
|
|
285
|
+
# @example Configure block toolbar items
|
|
286
|
+
# block_toolbar :heading, :paragraph, :blockQuote
|
|
287
|
+
# @example Configure with block
|
|
288
|
+
# block_toolbar do
|
|
289
|
+
# append :table
|
|
290
|
+
# remove :paragraph
|
|
291
|
+
# end
|
|
292
|
+
def block_toolbar(*items, **kwargs, &block)
|
|
293
|
+
toolbar(*items, **kwargs, type: :blockToolbar, &block)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Configure balloon toolbar items and grouping
|
|
297
|
+
# @param items [Array<Symbol>] Toolbar items to include
|
|
298
|
+
# @param kwargs [Hash] Additional toolbar configuration options
|
|
299
|
+
# @option kwargs [Boolean] :should_group_when_full Enable/disable toolbar item grouping
|
|
300
|
+
# @yield Optional block for additional toolbar configuration
|
|
301
|
+
# @return [ToolbarBuilder] Toolbar configuration
|
|
302
|
+
# @example Configure balloon toolbar items
|
|
303
|
+
# balloon_toolbar :bold, :italic, :link
|
|
304
|
+
# @example Configure with block
|
|
305
|
+
# balloon_toolbar do
|
|
306
|
+
# append :textColor
|
|
307
|
+
# remove :italic
|
|
308
|
+
# end
|
|
309
|
+
def balloon_toolbar(*items, **kwargs, &block)
|
|
310
|
+
toolbar(*items, **kwargs, type: :balloonToolbar, &block)
|
|
311
|
+
end
|
|
312
|
+
|
|
279
313
|
# Check if language is configured
|
|
280
314
|
# @return [Boolean]
|
|
281
315
|
def language?
|
|
@@ -6,9 +6,7 @@ RSpec.describe CKEditor5::Rails::Editor::EditableHeightNormalizer do
|
|
|
6
6
|
subject(:normalizer) { described_class.new(editor_type) }
|
|
7
7
|
|
|
8
8
|
describe '#normalize' do
|
|
9
|
-
|
|
10
|
-
let(:editor_type) { :classic }
|
|
11
|
-
|
|
9
|
+
shared_examples 'height normalization' do
|
|
12
10
|
it 'returns nil when value is nil' do
|
|
13
11
|
expect(normalizer.normalize(nil)).to be_nil
|
|
14
12
|
end
|
|
@@ -36,13 +34,23 @@ RSpec.describe CKEditor5::Rails::Editor::EditableHeightNormalizer do
|
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
context 'when editor type is
|
|
37
|
+
context 'when editor type is classic' do
|
|
38
|
+
let(:editor_type) { :classic }
|
|
39
|
+
include_examples 'height normalization'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
context 'when editor type is balloon' do
|
|
43
|
+
let(:editor_type) { :balloon }
|
|
44
|
+
include_examples 'height normalization'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when editor type is not supported' do
|
|
40
48
|
let(:editor_type) { :inline }
|
|
41
49
|
|
|
42
50
|
it 'raises error' do
|
|
43
51
|
expect { normalizer.normalize(500) }.to raise_error(
|
|
44
52
|
CKEditor5::Rails::Editor::InvalidEditableHeightError,
|
|
45
|
-
'editable_height can be used only with ClassicEditor'
|
|
53
|
+
'editable_height can be used only with ClassicEditor or BalloonEditor'
|
|
46
54
|
)
|
|
47
55
|
end
|
|
48
56
|
end
|
|
@@ -194,6 +194,50 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
|
|
|
194
194
|
expect(plugin_names).to include(:SimpleUploadAdapter)
|
|
195
195
|
end
|
|
196
196
|
end
|
|
197
|
+
|
|
198
|
+
describe '#block_toolbar' do
|
|
199
|
+
it 'configures block toolbar items' do
|
|
200
|
+
builder.block_toolbar(:heading, :paragraph, should_group_when_full: false)
|
|
201
|
+
expect(builder.config[:blockToolbar]).to eq({
|
|
202
|
+
items: %i[heading paragraph],
|
|
203
|
+
shouldNotGroupWhenFull: true
|
|
204
|
+
})
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'accepts a configuration block' do
|
|
208
|
+
builder.block_toolbar do
|
|
209
|
+
append :table
|
|
210
|
+
remove :paragraph
|
|
211
|
+
end
|
|
212
|
+
expect(builder.config[:blockToolbar][:items]).to include(:table)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it 'returns ToolbarBuilder instance if no block provided' do
|
|
216
|
+
expect(builder.block_toolbar).to be_a(CKEditor5::Rails::Presets::ToolbarBuilder)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
describe '#balloon_toolbar' do
|
|
221
|
+
it 'configures balloon toolbar items' do
|
|
222
|
+
builder.balloon_toolbar(:bold, :italic, should_group_when_full: false)
|
|
223
|
+
expect(builder.config[:balloonToolbar]).to eq({
|
|
224
|
+
items: %i[bold italic],
|
|
225
|
+
shouldNotGroupWhenFull: true
|
|
226
|
+
})
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it 'accepts a configuration block' do
|
|
230
|
+
builder.balloon_toolbar do
|
|
231
|
+
append :textColor
|
|
232
|
+
remove :italic
|
|
233
|
+
end
|
|
234
|
+
expect(builder.config[:balloonToolbar][:items]).to include(:textColor)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it 'returns ToolbarBuilder instance if no block provided' do
|
|
238
|
+
expect(builder.balloon_toolbar).to be_a(CKEditor5::Rails::Presets::ToolbarBuilder)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
197
241
|
end
|
|
198
242
|
|
|
199
243
|
describe '#inline_plugin' do
|
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.23.
|
|
4
|
+
version: 1.23.1
|
|
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-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|