ckeditor5 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/ckeditor5/rails/engine.rb +19 -23
- data/lib/ckeditor5/rails/{presets.rb → preset_builder.rb} +0 -95
- data/lib/ckeditor5/rails/presets_manager.rb +59 -0
- data/lib/ckeditor5/rails/toolbar_builder.rb +39 -0
- data/lib/ckeditor5/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b95ee184f10909e8acc238dcc5650a4bcbd828cb8cb32719cb98465223c7bc6c
|
4
|
+
data.tar.gz: 31364b050c64792a5561b4a9fd9de3dfe86a8a338f6a8f8075ca334c1558758d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 916eee6c8da16ad1b6d5ed9c7cd4358724e2a07d64b08b1ba77fdb03e2164a9633d3ce5403a6af70d938f0e1ef73e3a725549b83d93689b43c6225b0700456ea
|
7
|
+
data.tar.gz: c19f382d14e66e8fc8a0f0b49dfa18687cad2697de005700a39532bd6a19928b7f1093ec1aea4fc5d067e36b4edb20ce0476b67946b0700d77045af38d1545e8
|
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
|
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
|
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
|
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
|
547
|
+
<%= ckeditor5_assets translations: [:pl] %>
|
548
548
|
<% end %>
|
549
549
|
```
|
550
550
|
|
@@ -1,52 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rails/engine'
|
4
|
-
|
4
|
+
|
5
|
+
require_relative 'toolbar_builder'
|
6
|
+
require_relative 'preset_builder'
|
7
|
+
require_relative 'presets_manager'
|
8
|
+
|
5
9
|
require_relative 'hooks/form'
|
6
10
|
|
7
11
|
module CKEditor5::Rails
|
8
12
|
class Engine < ::Rails::Engine
|
9
13
|
config.ckeditor5 = ActiveSupport::OrderedOptions.new
|
10
|
-
|
11
|
-
# Specifies configuration of editors generated by gem.
|
12
14
|
config.ckeditor5.presets = PresetsManager.new
|
13
15
|
|
14
16
|
initializer 'helper' do
|
15
|
-
ActiveSupport.on_load(:action_view)
|
16
|
-
include Helpers
|
17
|
-
end
|
17
|
+
ActiveSupport.on_load(:action_view) { include Helpers }
|
18
18
|
end
|
19
19
|
|
20
|
-
initializer 'ckeditor5.simple_form' do
|
21
|
-
next unless defined?(::SimpleForm)
|
22
|
-
|
20
|
+
initializer 'ckeditor5.simple_form', if: -> { defined?(::SimpleForm) } do
|
23
21
|
require_relative 'hooks/simple_form'
|
24
|
-
|
25
22
|
::SimpleForm::FormBuilder.map_type :ckeditor5, to: Hooks::SimpleForm::CKEditor5Input
|
26
23
|
end
|
27
24
|
|
28
25
|
initializer 'ckeditor5.form_builder' do
|
29
26
|
require_relative 'hooks/form'
|
30
|
-
|
31
|
-
ActionView::Helpers::FormBuilder.include(
|
32
|
-
Hooks::Form::FormBuilderExtension
|
33
|
-
)
|
27
|
+
ActionView::Helpers::FormBuilder.include(Hooks::Form::FormBuilderExtension)
|
34
28
|
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
class << self
|
31
|
+
def base
|
32
|
+
config.ckeditor5
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
def default_preset
|
36
|
+
config.ckeditor5.presets.default
|
37
|
+
end
|
43
38
|
|
44
|
-
|
45
|
-
|
39
|
+
def configure
|
40
|
+
yield config.ckeditor5
|
41
|
+
end
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
49
|
-
def configure(&block)
|
45
|
+
def self.configure(&block)
|
50
46
|
Engine.configure(&block)
|
51
47
|
end
|
52
48
|
end
|
@@ -1,64 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
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
4
|
class PresetBuilder
|
63
5
|
attr_reader :config
|
64
6
|
|
@@ -132,7 +74,6 @@ module CKEditor5::Rails
|
|
132
74
|
|
133
75
|
def type(type = nil)
|
134
76
|
return @type if type.nil?
|
135
|
-
|
136
77
|
raise ArgumentError, "Invalid editor type: #{type}" unless Editor::Props.valid_editor_type?(type)
|
137
78
|
|
138
79
|
@type = type
|
@@ -181,40 +122,4 @@ module CKEditor5::Rails
|
|
181
122
|
}
|
182
123
|
end
|
183
124
|
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
125
|
end
|
@@ -0,0 +1,59 @@
|
|
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
|
+
type :classic
|
36
|
+
menubar
|
37
|
+
|
38
|
+
toolbar :undo, :redo, :|, :heading, :|, :bold, :italic, :underline, :|,
|
39
|
+
:link, :insertImage, :mediaEmbed, :insertTable, :blockQuote, :|,
|
40
|
+
:bulletedList, :numberedList, :todoList, :outdent, :indent
|
41
|
+
|
42
|
+
plugins :AccessibilityHelp, :Autoformat, :AutoImage, :Autosave,
|
43
|
+
:BlockQuote, :Bold, :CloudServices,
|
44
|
+
:Essentials, :Heading, :ImageBlock, :ImageCaption, :ImageInline,
|
45
|
+
:ImageInsert, :ImageInsertViaUrl, :ImageResize, :ImageStyle,
|
46
|
+
:ImageTextAlternative, :ImageToolbar, :ImageUpload, :Indent,
|
47
|
+
:IndentBlock, :Italic, :Link, :LinkImage, :List, :ListProperties,
|
48
|
+
:MediaEmbed, :Paragraph, :PasteFromOffice, :PictureEditing,
|
49
|
+
:SelectAll, :Table, :TableCaption, :TableCellProperties,
|
50
|
+
:TableColumnResize, :TableProperties, :TableToolbar,
|
51
|
+
:TextTransformation, :TodoList, :Underline, :Undo, :Base64UploadAdapter
|
52
|
+
|
53
|
+
configure :image, {
|
54
|
+
toolbar: ['imageTextAlternative', 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side']
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CKEditor5::Rails
|
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
|
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.
|
4
|
+
version: 1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Bagiński
|
@@ -59,8 +59,10 @@ 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/
|
62
|
+
- lib/ckeditor5/rails/preset_builder.rb
|
63
|
+
- lib/ckeditor5/rails/presets_manager.rb
|
63
64
|
- lib/ckeditor5/rails/semver.rb
|
65
|
+
- lib/ckeditor5/rails/toolbar_builder.rb
|
64
66
|
- lib/ckeditor5/rails/version.rb
|
65
67
|
homepage: https://github.com/Mati365/ckeditor5-rails
|
66
68
|
licenses:
|