ckeditor5 1.17.0 → 1.17.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 843e4c645212f665f1c8e1efe8ae6b623d84e8a42cfd5c4e8181def8450e0dde
4
- data.tar.gz: b0980b0adcf055278856758e38e304d5eaa3927d3dd75a703abec2bd7366d5fb
3
+ metadata.gz: 78094e2b7cf2ec9677a1eb9ee629918df4b6e9de62104cd6e2c8713b02ae7776
4
+ data.tar.gz: 63816a1caf2f2c42f08321f0169fb14e54e2f6424bc80834890dfde68a76f22f
5
5
  SHA512:
6
- metadata.gz: 315c863ea830f41cc5b68e6bbfbd736fdb89facab2233d75648313befecaa419ffe9e42a84545da347e0575db6c6da58f0f690ce32c6fc989fa5408a48d8110d
7
- data.tar.gz: 6dafb2dc99b0cb3496e5e106f0a90a0d8cd93f25ee78e86d5e4d2a3f67cd987c59af0aad45d1d4b0651cf237606856e4399f48d1d6a0a20b3a31639f094641f1
6
+ metadata.gz: b3691b024f1cedc6da4086fea1754f6f4d7acdc2d3d9a10f5628b0b54c539e941073cff74459dd776956c758fe4da1f78b54a6c8ab0128248e1ecc9b308ba168
7
+ data.tar.gz: a5d4109cc5f559144a66abd7ba1b672a27d1ad41131bdead590c144d4c4b2d1eb518953267bfee9fb6fa14c9cce027416de28dece065ed852c198fd4587e08dc
data/README.md CHANGED
@@ -234,6 +234,8 @@ CKEditor5::Rails.configure do
234
234
  end
235
235
  ```
236
236
 
237
+ You can define presets in the controller using the `ckeditor5_preset` helper method. See it in the section below ([Controller / View helpers](#controller--view-helpers-)).
238
+
237
239
  Configuration of the editor can be complex, and it's recommended to use the [CKEditor 5 online builder](https://ckeditor.com/ckeditor-5/online-builder/) to generate the configuration. It allows you to select the features you want to include and generate the configuration code in JavaScript format. Keep in mind that you need to convert the JavaScript configuration to Ruby format before using it in this gem.
238
240
 
239
241
  ### Automatic upgrades 🔄
@@ -866,9 +868,31 @@ In order to use the preset in the view, you can pass it to the `ckeditor5_assets
866
868
 
867
869
  <%= ckeditor5_editor %>
868
870
  ```
869
- </details>
870
871
 
871
- If `name` is provided then the preset is returned.
872
+ If you want to override the preset defined in the initializer, you can search for the preset by name and then override it (it'll create copy of the preset):
873
+
874
+ ```rb
875
+ # app/controllers/application_controller.rb
876
+
877
+ class ApplicationController < ActionController::Base
878
+ def show
879
+ @preset = ckeditor5_preset(:default).override do
880
+ version '43.3.1'
881
+
882
+ toolbar :sourceEditing, :|, :bold, :italic, :underline, :strikethrough,
883
+ :subscript, :superscript, :removeFormat, :|, :bulletedList, :numberedList,
884
+ :fontFamily, :fontSize, :|, :link, :anchor, :|,
885
+ :fontColor, :fontBackgroundColor
886
+
887
+ plugins :Essentials, :Paragraph, :Bold, :Italic, :Underline, :Strikethrough,
888
+ :Subscript, :Superscript, :RemoveFormat, :List, :Link, :Font,
889
+ :FontFamily, :FontSize, :FontColor, :FontBackgroundColor, :SourceEditing, :Essentials, :Paragraph
890
+ end
891
+ end
892
+ end
893
+ ```
894
+
895
+ </details>
872
896
 
873
897
  ## Including CKEditor 5 assets 📦
874
898
 
@@ -55,6 +55,12 @@ module CKEditor5::Rails
55
55
  end
56
56
  end
57
57
 
58
+ def override(&block)
59
+ clone.tap do |preset|
60
+ preset.instance_eval(&block)
61
+ end
62
+ end
63
+
58
64
  def merge_with_hash!(language: nil, **overrides) # rubocop:disable Metrics/AbcSize
59
65
  @version = Semver.new(overrides[:version]) if overrides.key?(:version)
60
66
  @premium = overrides.fetch(:premium, premium)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CKEditor5
4
4
  module Rails
5
- VERSION = '1.17.0'
5
+ VERSION = '1.17.1'
6
6
 
7
7
  DEFAULT_CKEDITOR_VERSION = '43.3.1'
8
8
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'e2e/spec_helper'
4
+
5
+ RSpec.describe 'Editor localization', type: :system do
6
+ describe 'setting locale via assets' do
7
+ it 'displays menubar in Polish' do
8
+ visit '/locale_via_assets'
9
+
10
+ expect(page).to have_css('.ck-editor__main')
11
+
12
+ within('.ck-menu-bar') do
13
+ expect(page).to have_content('Zmiana')
14
+ expect(page).to have_content('Wstaw')
15
+ expect(page).to have_content('Format')
16
+ end
17
+ end
18
+ end
19
+
20
+ describe 'setting locale via editor prop' do
21
+ it 'displays menubar in Spanish' do
22
+ visit '/locale_via_editor'
23
+
24
+ expect(page).to have_css('.ck-editor__main')
25
+
26
+ within('.ck-menu-bar') do
27
+ expect(page).to have_content('Editar')
28
+ expect(page).to have_content('Insertar')
29
+ expect(page).to have_content('Formato')
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'setting locale via preset' do
35
+ it 'displays menubar in Russian' do
36
+ visit '/locale_via_preset'
37
+
38
+ expect(page).to have_css('.ck-editor__main')
39
+
40
+ within('.ck-menu-bar') do
41
+ expect(page).to have_content('Редактировать')
42
+ expect(page).to have_content('Вставить')
43
+ expect(page).to have_content('Формат')
44
+ end
45
+ end
46
+ end
47
+ end
@@ -70,6 +70,22 @@ RSpec.describe CKEditor5::Rails::Presets::PresetBuilder do
70
70
  end
71
71
  end
72
72
 
73
+ describe '#override' do
74
+ it 'returns a new instance with overridden values' do
75
+ builder.version '35.0.0'
76
+ builder.translations :en, :pl
77
+
78
+ overridden = builder.override do
79
+ version '36.0.0'
80
+ translations :de
81
+ end
82
+
83
+ expect(builder.version).to eq('35.0.0')
84
+ expect(overridden.version).to eq('36.0.0')
85
+ expect(overridden.translations).to eq([:de])
86
+ end
87
+ end
88
+
73
89
  describe 'configuration methods' do
74
90
  describe '#automatic_upgrades' do
75
91
  it 'enables automatic upgrades' 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.17.0
4
+ version: 1.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński
@@ -82,6 +82,7 @@ files:
82
82
  - spec/e2e/features/context_spec.rb
83
83
  - spec/e2e/features/editor_types_spec.rb
84
84
  - spec/e2e/features/form_integration_spec.rb
85
+ - spec/e2e/features/locale_spec.rb
85
86
  - spec/e2e/spec_helper.rb
86
87
  - spec/e2e/support/eventually.rb
87
88
  - spec/e2e/support/form_helpers.rb
@@ -139,6 +140,7 @@ test_files:
139
140
  - spec/e2e/features/context_spec.rb
140
141
  - spec/e2e/features/editor_types_spec.rb
141
142
  - spec/e2e/features/form_integration_spec.rb
143
+ - spec/e2e/features/locale_spec.rb
142
144
  - spec/e2e/spec_helper.rb
143
145
  - spec/e2e/support/eventually.rb
144
146
  - spec/e2e/support/form_helpers.rb