ckeditor5 1.1.5 → 1.1.7

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: d8a3607d5a38c9654f181481a3c84f0b62119bf82aa5821c4e679eb3624323a5
4
- data.tar.gz: 9c1f3765da1ad876a02c326141645eb4f941db6ecb2f12cb8bc16b04d9ebf965
3
+ metadata.gz: a512b289e611ca5d7480b5088b14f83ed459481b6f99f0c15b4467e627c464e7
4
+ data.tar.gz: dc3969b71fd184b7e9bc39a95fc7d0702280203c940197925d8e8f8d17d22a50
5
5
  SHA512:
6
- metadata.gz: 6372388ead48cef2105d1f5f25fb34e650687bf3a5197f2d3d30a65b27b4197418e53504ecf153c4b373db32a574511da1afda0c59ec4a3d60a84656bbcc4828
7
- data.tar.gz: fca6e5780732f512f0b0d380777cb6b95a881e714b1a9b91ddfc624391d6ca4d77a555e29eb04eb9d1ecd6e94e9d0796751c481543cfbf24df032ceabe055caf
6
+ metadata.gz: d3491c052e7e736f1ed484a67eaf7fae034fd73874977c4bcfd671295e5fe5d9673d7c27845df6877fb527a4a29763ad3529c58e30fcee893f8a174fe066ac84
7
+ data.tar.gz: e579d1032b12e79d265da252ad74af5b090922aeb0eb4d68ab12c252d9ed173ec9b1f5e4cc904f4fcc62c4dbc0cb20b4b79ae87ee9cfff40afc33b1497caf464
data/README.md CHANGED
@@ -490,7 +490,7 @@ If you want to use CKEditor 5 under the GPL license, you can include the assets
490
490
  <!-- app/views/demos/index.html.erb -->
491
491
 
492
492
  <% content_for :head do %>
493
- <%= ckeditor5_assets version: '43.3.0' %>
493
+ <%= ckeditor5_assets %>
494
494
  <% end %>
495
495
  ```
496
496
 
@@ -524,7 +524,7 @@ In order to use `unpkg` CDN, you can pass the `cdn` keyword argument with the va
524
524
  <!-- app/views/demos/index.html.erb -->
525
525
 
526
526
  <% content_for :head do %>
527
- <%= ckeditor5_assets version: '43.3.0', cdn: :unpkg %>
527
+ <%= ckeditor5_assets cdn: :unpkg %>
528
528
  <% end %>
529
529
  ```
530
530
 
@@ -534,7 +534,7 @@ or using helper function:
534
534
  <!-- app/views/demos/index.html.erb -->
535
535
 
536
536
  <% content_for :head do %>
537
- <%= ckeditor5_jsdelivr_assets version: '43.3.0' %>
537
+ <%= ckeditor5_jsdelivr_assets %>
538
538
  <% end %>
539
539
  ```
540
540
 
@@ -544,7 +544,7 @@ Translating CKEditor 5 is possible by passing the `translations` keyword argumen
544
544
  <!-- app/views/demos/index.html.erb -->
545
545
 
546
546
  <% content_for :head do %>
547
- <%= ckeditor5_assets version: '43.3.0', translations: [:pl] %>
547
+ <%= ckeditor5_assets translations: [:pl] %>
548
548
  <% end %>
549
549
  ```
550
550
 
@@ -1,52 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails/engine'
4
- require_relative 'presets'
4
+
5
+ require_relative 'presets/manager'
5
6
  require_relative 'hooks/form'
6
7
 
7
8
  module CKEditor5::Rails
8
9
  class Engine < ::Rails::Engine
9
10
  config.ckeditor5 = ActiveSupport::OrderedOptions.new
10
-
11
- # Specifies configuration of editors generated by gem.
12
- config.ckeditor5.presets = PresetsManager.new
11
+ config.ckeditor5.presets = Presets::Manager.new
13
12
 
14
13
  initializer 'helper' do
15
- ActiveSupport.on_load(:action_view) do
16
- include Helpers
17
- end
14
+ ActiveSupport.on_load(:action_view) { include Helpers }
18
15
  end
19
16
 
20
- initializer 'ckeditor5.simple_form' do
21
- next unless defined?(::SimpleForm)
22
-
17
+ initializer 'ckeditor5.simple_form', if: -> { defined?(::SimpleForm) } do
23
18
  require_relative 'hooks/simple_form'
24
-
25
19
  ::SimpleForm::FormBuilder.map_type :ckeditor5, to: Hooks::SimpleForm::CKEditor5Input
26
20
  end
27
21
 
28
22
  initializer 'ckeditor5.form_builder' do
29
23
  require_relative 'hooks/form'
30
-
31
- ActionView::Helpers::FormBuilder.include(
32
- Hooks::Form::FormBuilderExtension
33
- )
24
+ ActionView::Helpers::FormBuilder.include(Hooks::Form::FormBuilderExtension)
34
25
  end
35
26
 
36
- def self.base
37
- config.ckeditor5
38
- end
27
+ class << self
28
+ def base
29
+ config.ckeditor5
30
+ end
39
31
 
40
- def self.default_preset
41
- config.ckeditor5.presets.default
42
- end
32
+ def default_preset
33
+ config.ckeditor5.presets.default
34
+ end
43
35
 
44
- def self.configure
45
- yield config.ckeditor5
36
+ def configure
37
+ yield config.ckeditor5
38
+ end
46
39
  end
47
40
  end
48
41
 
49
- def configure(&block)
42
+ def self.configure(&block)
50
43
  Engine.configure(&block)
51
44
  end
52
45
  end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'preset_builder'
4
+ require_relative 'toolbar_builder'
5
+
6
+ module CKEditor5::Rails::Presets
7
+ class Manager
8
+ attr_reader :presets
9
+
10
+ def initialize
11
+ @presets = {}
12
+ define_default_preset
13
+ end
14
+
15
+ def define(name, &block)
16
+ preset = PresetBuilder.new
17
+ preset.instance_eval(&block)
18
+ @presets[name] = preset
19
+ end
20
+
21
+ def override(name, &block)
22
+ @presets[name].instance_eval(&block)
23
+ end
24
+
25
+ def default
26
+ @presets[:default] || {}
27
+ end
28
+
29
+ def [](name)
30
+ @presets[name] || {}
31
+ end
32
+
33
+ private
34
+
35
+ def define_default_preset # rubocop:disable Metrics/MethodLength
36
+ define :default do
37
+ gpl
38
+ type :classic
39
+ menubar
40
+
41
+ toolbar :undo, :redo, :|, :heading, :|, :bold, :italic, :underline, :|,
42
+ :link, :insertImage, :mediaEmbed, :insertTable, :blockQuote, :|,
43
+ :bulletedList, :numberedList, :todoList, :outdent, :indent
44
+
45
+ plugins :AccessibilityHelp, :Autoformat, :AutoImage, :Autosave,
46
+ :BlockQuote, :Bold, :CloudServices,
47
+ :Essentials, :Heading, :ImageBlock, :ImageCaption, :ImageInline,
48
+ :ImageInsert, :ImageInsertViaUrl, :ImageResize, :ImageStyle,
49
+ :ImageTextAlternative, :ImageToolbar, :ImageUpload, :Indent,
50
+ :IndentBlock, :Italic, :Link, :LinkImage, :List, :ListProperties,
51
+ :MediaEmbed, :Paragraph, :PasteFromOffice, :PictureEditing,
52
+ :SelectAll, :Table, :TableCaption, :TableCellProperties,
53
+ :TableColumnResize, :TableProperties, :TableToolbar,
54
+ :TextTransformation, :TodoList, :Underline, :Undo, :Base64UploadAdapter
55
+
56
+ configure :image, {
57
+ toolbar: ['imageTextAlternative', 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side']
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CKEditor5::Rails
4
+ module Presets
5
+ class PresetBuilder
6
+ attr_reader :config
7
+
8
+ def initialize
9
+ @version = nil
10
+ @premium = false
11
+ @cdn = :jsdelivr
12
+ @translations = []
13
+ @license_key = nil
14
+ @type = :classic
15
+ @ckbox = nil
16
+ @config = {
17
+ plugins: [],
18
+ toolbar: []
19
+ }
20
+ end
21
+
22
+ def to_h_with_overrides(**overrides)
23
+ {
24
+ version: overrides.fetch(:version, version),
25
+ premium: overrides.fetch(:premium, premium),
26
+ cdn: overrides.fetch(:cdn, cdn),
27
+ translations: overrides.fetch(:translations, translations),
28
+ license_key: overrides.fetch(:license_key, license_key),
29
+ type: overrides.fetch(:type, type),
30
+ ckbox: overrides.fetch(:ckbox, ckbox),
31
+ config: config.merge(overrides.fetch(:config, {}))
32
+ }
33
+ end
34
+
35
+ def ckbox(version = nil, theme: :lark)
36
+ return @ckbox if version.nil?
37
+
38
+ @ckbox = { version: version, theme: theme }
39
+ end
40
+
41
+ def license_key(license_key = nil)
42
+ return @license_key if license_key.nil?
43
+
44
+ @license_key = license_key
45
+ end
46
+
47
+ def gpl
48
+ license_key('GPL')
49
+ premium(false)
50
+ end
51
+
52
+ def premium(premium = nil)
53
+ return @premium if premium.nil?
54
+
55
+ @premium = premium
56
+ end
57
+
58
+ def translations(*translations)
59
+ return @translations if translations.empty?
60
+
61
+ @translations = translations
62
+ end
63
+
64
+ def version(version = nil)
65
+ return @version.to_s if version.nil?
66
+
67
+ @version = Semver.new(version)
68
+ end
69
+
70
+ def cdn(cdn = nil)
71
+ return @cdn if cdn.nil?
72
+
73
+ @cdn = cdn
74
+ end
75
+
76
+ def type(type = nil)
77
+ return @type if type.nil?
78
+ raise ArgumentError, "Invalid editor type: #{type}" unless Editor::Props.valid_editor_type?(type)
79
+
80
+ @type = type
81
+ end
82
+
83
+ def configure(key, value)
84
+ @config[key] = value
85
+ end
86
+
87
+ def menubar(visible: true)
88
+ @config[:menuBar] = {
89
+ isVisible: visible
90
+ }
91
+ end
92
+
93
+ def toolbar(*items, should_group_when_full: true, &block)
94
+ if @config[:toolbar].blank? || !items.empty?
95
+ @config[:toolbar] = {
96
+ items: items,
97
+ shouldNotGroupWhenFull: !should_group_when_full
98
+ }
99
+ end
100
+
101
+ return unless block
102
+
103
+ builder = ToolbarBuilder.new(@config[:toolbar])
104
+ builder.instance_eval(&block)
105
+ end
106
+
107
+ def inline_plugin(name, code)
108
+ @config[:plugins] << Editor::PropsInlinePlugin.new(name, code)
109
+ end
110
+
111
+ def plugin(name, **kwargs)
112
+ @config[:plugins] << Editor::PropsPlugin.new(name, **kwargs)
113
+ end
114
+
115
+ def plugins(*names, **kwargs)
116
+ names.each { |name| plugin(name, **kwargs) }
117
+ end
118
+
119
+ def language(ui, content: ui) # rubocop:disable Naming/MethodParameterName
120
+ @config[:language] = {
121
+ ui: ui,
122
+ content: content
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CKEditor5::Rails::Presets
4
+ class ToolbarBuilder
5
+ def initialize(toolbar_config)
6
+ @toolbar_config = toolbar_config
7
+ end
8
+
9
+ def items
10
+ @toolbar_config[:items]
11
+ end
12
+
13
+ def remove(*removed_items)
14
+ removed_items.each { |item| items.delete(item) }
15
+ end
16
+
17
+ def prepend(*prepended_items, before: nil)
18
+ if before
19
+ index = items.index(before)
20
+ raise ArgumentError, "Item '#{before}' not found in toolbar" unless index
21
+
22
+ items.insert(index, *prepended_items)
23
+ else
24
+ items.insert(0, *prepended_items)
25
+ end
26
+ end
27
+
28
+ def append(*appended_items, after: nil)
29
+ if after
30
+ index = items.index(after)
31
+ raise ArgumentError, "Item '#{after}' not found in toolbar" unless index
32
+
33
+ items.insert(index + 1, *appended_items)
34
+ else
35
+ items.push(*appended_items)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CKEditor5::Rails
4
- VERSION = '1.1.5'
4
+ VERSION = '1.1.7'
5
5
  end
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.1.5
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński
@@ -59,7 +59,9 @@ files:
59
59
  - lib/ckeditor5/rails/helpers.rb
60
60
  - lib/ckeditor5/rails/hooks/form.rb
61
61
  - lib/ckeditor5/rails/hooks/simple_form.rb
62
- - lib/ckeditor5/rails/presets.rb
62
+ - lib/ckeditor5/rails/presets/manager.rb
63
+ - lib/ckeditor5/rails/presets/preset_builder.rb
64
+ - lib/ckeditor5/rails/presets/toolbar_builder.rb
63
65
  - lib/ckeditor5/rails/semver.rb
64
66
  - lib/ckeditor5/rails/version.rb
65
67
  homepage: https://github.com/Mati365/ckeditor5-rails
@@ -1,220 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CKEditor5::Rails
4
- class PresetsManager
5
- attr_reader :presets
6
-
7
- def initialize
8
- @presets = {}
9
- define_default_preset
10
- end
11
-
12
- def define(name, &block)
13
- preset = PresetBuilder.new
14
- preset.instance_eval(&block)
15
- @presets[name] = preset
16
- end
17
-
18
- def override(name, &block)
19
- @presets[name].instance_eval(&block)
20
- end
21
-
22
- def default
23
- @presets[:default] || {}
24
- end
25
-
26
- def [](name)
27
- @presets[name] || {}
28
- end
29
-
30
- private
31
-
32
- def define_default_preset # rubocop:disable Metrics/MethodLength
33
- define :default do
34
- gpl
35
-
36
- type :classic
37
-
38
- menubar
39
-
40
- toolbar :undo, :redo, :|, :heading, :|, :bold, :italic, :underline, :|,
41
- :link, :insertImage, :mediaEmbed, :insertTable, :blockQuote, :|,
42
- :bulletedList, :numberedList, :todoList, :outdent, :indent
43
-
44
- plugins :AccessibilityHelp, :Autoformat, :AutoImage, :Autosave,
45
- :BlockQuote, :Bold, :CloudServices,
46
- :Essentials, :Heading, :ImageBlock, :ImageCaption, :ImageInline,
47
- :ImageInsert, :ImageInsertViaUrl, :ImageResize, :ImageStyle,
48
- :ImageTextAlternative, :ImageToolbar, :ImageUpload, :Indent,
49
- :IndentBlock, :Italic, :Link, :LinkImage, :List, :ListProperties,
50
- :MediaEmbed, :Paragraph, :PasteFromOffice, :PictureEditing,
51
- :SelectAll, :Table, :TableCaption, :TableCellProperties,
52
- :TableColumnResize, :TableProperties, :TableToolbar,
53
- :TextTransformation, :TodoList, :Underline, :Undo, :Base64UploadAdapter
54
-
55
- configure :image, {
56
- toolbar: ['imageTextAlternative', 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side']
57
- }
58
- end
59
- end
60
- end
61
-
62
- class PresetBuilder
63
- attr_reader :config
64
-
65
- def initialize
66
- @version = nil
67
- @premium = false
68
- @cdn = :jsdelivr
69
- @translations = []
70
- @license_key = nil
71
- @type = :classic
72
- @ckbox = nil
73
- @config = {
74
- plugins: [],
75
- toolbar: []
76
- }
77
- end
78
-
79
- def to_h_with_overrides(**overrides)
80
- {
81
- version: overrides.fetch(:version, version),
82
- premium: overrides.fetch(:premium, premium),
83
- cdn: overrides.fetch(:cdn, cdn),
84
- translations: overrides.fetch(:translations, translations),
85
- license_key: overrides.fetch(:license_key, license_key),
86
- type: overrides.fetch(:type, type),
87
- ckbox: overrides.fetch(:ckbox, ckbox),
88
- config: config.merge(overrides.fetch(:config, {}))
89
- }
90
- end
91
-
92
- def ckbox(version = nil, theme: :lark)
93
- return @ckbox if version.nil?
94
-
95
- @ckbox = { version: version, theme: theme }
96
- end
97
-
98
- def license_key(license_key = nil)
99
- return @license_key if license_key.nil?
100
-
101
- @license_key = license_key
102
- end
103
-
104
- def gpl
105
- license_key('GPL')
106
- premium(false)
107
- end
108
-
109
- def premium(premium = nil)
110
- return @premium if premium.nil?
111
-
112
- @premium = premium
113
- end
114
-
115
- def translations(*translations)
116
- return @translations if translations.empty?
117
-
118
- @translations = translations
119
- end
120
-
121
- def version(version = nil)
122
- return @version.to_s if version.nil?
123
-
124
- @version = Semver.new(version)
125
- end
126
-
127
- def cdn(cdn = nil)
128
- return @cdn if cdn.nil?
129
-
130
- @cdn = cdn
131
- end
132
-
133
- def type(type = nil)
134
- return @type if type.nil?
135
-
136
- raise ArgumentError, "Invalid editor type: #{type}" unless Editor::Props.valid_editor_type?(type)
137
-
138
- @type = type
139
- end
140
-
141
- def configure(key, value)
142
- @config[key] = value
143
- end
144
-
145
- def menubar(visible: true)
146
- @config[:menuBar] = {
147
- isVisible: visible
148
- }
149
- end
150
-
151
- def toolbar(*items, should_group_when_full: true, &block)
152
- if @config[:toolbar].blank? || !items.empty?
153
- @config[:toolbar] = {
154
- items: items,
155
- shouldNotGroupWhenFull: !should_group_when_full
156
- }
157
- end
158
-
159
- return unless block
160
-
161
- builder = ToolbarBuilder.new(@config[:toolbar])
162
- builder.instance_eval(&block)
163
- end
164
-
165
- def inline_plugin(name, code)
166
- @config[:plugins] << Editor::PropsInlinePlugin.new(name, code)
167
- end
168
-
169
- def plugin(name, **kwargs)
170
- @config[:plugins] << Editor::PropsPlugin.new(name, **kwargs)
171
- end
172
-
173
- def plugins(*names, **kwargs)
174
- names.each { |name| plugin(name, **kwargs) }
175
- end
176
-
177
- def language(ui, content: ui) # rubocop:disable Naming/MethodParameterName
178
- @config[:language] = {
179
- ui: ui,
180
- content: content
181
- }
182
- end
183
- end
184
-
185
- class ToolbarBuilder
186
- def initialize(toolbar_config)
187
- @toolbar_config = toolbar_config
188
- end
189
-
190
- def items
191
- @toolbar_config[:items]
192
- end
193
-
194
- def remove(*removed_items)
195
- removed_items.each { |item| items.delete(item) }
196
- end
197
-
198
- def prepend(*prepended_items, before: nil)
199
- if before
200
- index = items.index(before)
201
- raise ArgumentError, "Item '#{before}' not found in toolbar" unless index
202
-
203
- items.insert(index, *prepended_items)
204
- else
205
- items.insert(0, *prepended_items)
206
- end
207
- end
208
-
209
- def append(*appended_items, after: nil)
210
- if after
211
- index = items.index(after)
212
- raise ArgumentError, "Item '#{after}' not found in toolbar" unless index
213
-
214
- items.insert(index + 1, *appended_items)
215
- else
216
- items.push(*appended_items)
217
- end
218
- end
219
- end
220
- end