ckeditor5 1.23.0 → 1.23.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6209f7ab70666ad0c3e5c368f47832871d740429238bb62199c5956ca73fe77
4
- data.tar.gz: 3e3af0099b5150b6c2df7bb578a11cd63b81f88cb9ded596806e5ea980ebf90a
3
+ metadata.gz: d4e4581fc1d9ebbf70b9213ce10a444b5ad2633f45334a7e343f875a8f7180ee
4
+ data.tar.gz: 251313b3f5eb8152f9385b9f4e159e30223b9a2bf0edff5009d3b85459d062c4
5
5
  SHA512:
6
- metadata.gz: 1d7f113a286468066aa941cba9d735c5312d8558ed83a1d3f9fa7e4a2959d7c58a843f6b0bf8fd4e296b0ab34dedc303f0a6533c5adf6af1c60a1a77dbe4c5e9
7
- data.tar.gz: c4304b80a54b9bf94629b9aa8c27d640e2ff0783e3d78d2a577400d3cd29df337aa1a8b40fc7bc8f050bc3ee3c528becfa0a12b68158fdb980df5ea2b897b6f8
6
+ metadata.gz: bdce490b8f96f7c365b3cdb782afccb02c8b372c93df042c76cfb10540d56f742b355af8c4d55a638399db4bccf661469117ae55c9cdd1a92b16e993bab37980
7
+ data.tar.gz: 9d54670405e3030075495bc0cbceb60524803658e23535f84bf5a72570917cbbdc32ab7130b0c1d1554c5f3065b3d7067afef3df4ae93df260608d20de8b6725
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. The importmap must
36
- be included in the head section to ensure proper loading order.
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 %>
@@ -81,7 +80,7 @@ CKEditor5::Rails.configure do
81
80
 
82
81
  # Optionally, you can specify version of CKEditor 5 to use.
83
82
  # If it's not specified the default version specified in the gem will be used.
84
- # version '44.0.0'
83
+ # version '44.1.0'
85
84
 
86
85
  # Upload images to the server using the simple upload adapter, instead of Base64 encoding.
87
86
  # simple_upload_adapter
@@ -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)
@@ -197,7 +198,7 @@ You can create your own by defining it in the `config/initializers/ckeditor5.rb`
197
198
 
198
199
  CKEditor5::Rails.configure do
199
200
  # It's possible to override the default preset right in the initializer.
200
- version '44.0.0'
201
+ version '44.1.0'
201
202
 
202
203
  # New presets inherit properties from the default preset defined in the initializer.
203
204
  # In this example, the custom preset inherits everything from default but disables the menubar:
@@ -207,7 +208,7 @@ CKEditor5::Rails.configure do
207
208
 
208
209
  # In order to define preset from scratch, you can use the `inherit: false` option.
209
210
  presets.define :blank_preset, inherit: false do
210
- version '44.0.0'
211
+ version '44.1.0'
211
212
 
212
213
  # It tells the integration to fetch the newest security patches and bug fixes.
213
214
  # It may be disabled, but it's highly recommended to keep it enabled to avoid
@@ -329,7 +330,7 @@ Defines the version of CKEditor 5 to be used. The example below shows how to set
329
330
  CKEditor5::Rails.configure do
330
331
  # ... other configuration
331
332
 
332
- version '44.0.0'
333
+ version '44.1.0'
333
334
  end
334
335
  ```
335
336
  </details>
@@ -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>
@@ -1029,7 +1076,7 @@ It may be useful when you want to define a preset based on the current user or r
1029
1076
  class ApplicationController < ActionController::Base
1030
1077
  def show
1031
1078
  @preset = ckeditor5_preset do
1032
- version '44.0.0'
1079
+ version '44.1.0'
1033
1080
 
1034
1081
  toolbar :sourceEditing, :|, :bold, :italic, :underline, :strikethrough,
1035
1082
  :subscript, :superscript, :removeFormat, :|, :bulletedList, :numberedList,
@@ -1064,7 +1111,7 @@ If you want to override the preset defined in the initializer, you can search fo
1064
1111
  class ApplicationController < ActionController::Base
1065
1112
  def show
1066
1113
  @preset = ckeditor5_preset(:default).override do
1067
- version '44.0.0'
1114
+ version '44.1.0'
1068
1115
 
1069
1116
  toolbar :sourceEditing, :|, :bold, :italic, :underline, :strikethrough,
1070
1117
  :subscript, :superscript, :removeFormat, :|, :bulletedList, :numberedList,
@@ -1237,7 +1284,7 @@ In that scenario it's recommended to add `gpl` method to the initializer along w
1237
1284
 
1238
1285
  CKEditor5::Rails.configure do
1239
1286
  gpl
1240
- version '44.0.0'
1287
+ version '44.1.0'
1241
1288
  end
1242
1289
  ```
1243
1290
 
@@ -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 == :classic
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[:toolbar].blank? || !items.empty?
268
- @config[:toolbar] = {
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[:toolbar][:items])
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?
@@ -2,8 +2,8 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.23.0'
5
+ VERSION = '1.23.2'
6
6
 
7
- DEFAULT_CKEDITOR_VERSION = '44.0.0'
7
+ DEFAULT_CKEDITOR_VERSION = '44.1.0'
8
8
  end
9
9
  end
@@ -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
- context 'when editor type is classic' do
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 not classic' do
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.0
4
+ version: 1.23.2
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-04 00:00:00.000000000 Z
12
+ date: 2024-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails