ckeditor5 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ckeditor5/rails/engine.rb +2 -5
- data/lib/ckeditor5/rails/{presets_manager.rb → presets/manager.rb} +5 -2
- data/lib/ckeditor5/rails/presets/preset_builder.rb +127 -0
- data/lib/ckeditor5/rails/{toolbar_builder.rb → presets/toolbar_builder.rb} +1 -1
- data/lib/ckeditor5/rails/version.rb +1 -1
- metadata +4 -4
- data/lib/ckeditor5/rails/preset_builder.rb +0 -125
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a512b289e611ca5d7480b5088b14f83ed459481b6f99f0c15b4467e627c464e7
|
4
|
+
data.tar.gz: dc3969b71fd184b7e9bc39a95fc7d0702280203c940197925d8e8f8d17d22a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3491c052e7e736f1ed484a67eaf7fae034fd73874977c4bcfd671295e5fe5d9673d7c27845df6877fb527a4a29763ad3529c58e30fcee893f8a174fe066ac84
|
7
|
+
data.tar.gz: e579d1032b12e79d265da252ad74af5b090922aeb0eb4d68ab12c252d9ed173ec9b1f5e4cc904f4fcc62c4dbc0cb20b4b79ae87ee9cfff40afc33b1497caf464
|
@@ -2,16 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'rails/engine'
|
4
4
|
|
5
|
-
require_relative '
|
6
|
-
require_relative 'preset_builder'
|
7
|
-
require_relative 'presets_manager'
|
8
|
-
|
5
|
+
require_relative 'presets/manager'
|
9
6
|
require_relative 'hooks/form'
|
10
7
|
|
11
8
|
module CKEditor5::Rails
|
12
9
|
class Engine < ::Rails::Engine
|
13
10
|
config.ckeditor5 = ActiveSupport::OrderedOptions.new
|
14
|
-
config.ckeditor5.presets =
|
11
|
+
config.ckeditor5.presets = Presets::Manager.new
|
15
12
|
|
16
13
|
initializer 'helper' do
|
17
14
|
ActiveSupport.on_load(:action_view) { include Helpers }
|
@@ -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
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Bagiński
|
@@ -59,10 +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/
|
63
|
-
- lib/ckeditor5/rails/
|
62
|
+
- lib/ckeditor5/rails/presets/manager.rb
|
63
|
+
- lib/ckeditor5/rails/presets/preset_builder.rb
|
64
|
+
- lib/ckeditor5/rails/presets/toolbar_builder.rb
|
64
65
|
- lib/ckeditor5/rails/semver.rb
|
65
|
-
- lib/ckeditor5/rails/toolbar_builder.rb
|
66
66
|
- lib/ckeditor5/rails/version.rb
|
67
67
|
homepage: https://github.com/Mati365/ckeditor5-rails
|
68
68
|
licenses:
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CKEditor5::Rails
|
4
|
-
class PresetBuilder
|
5
|
-
attr_reader :config
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@version = nil
|
9
|
-
@premium = false
|
10
|
-
@cdn = :jsdelivr
|
11
|
-
@translations = []
|
12
|
-
@license_key = nil
|
13
|
-
@type = :classic
|
14
|
-
@ckbox = nil
|
15
|
-
@config = {
|
16
|
-
plugins: [],
|
17
|
-
toolbar: []
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_h_with_overrides(**overrides)
|
22
|
-
{
|
23
|
-
version: overrides.fetch(:version, version),
|
24
|
-
premium: overrides.fetch(:premium, premium),
|
25
|
-
cdn: overrides.fetch(:cdn, cdn),
|
26
|
-
translations: overrides.fetch(:translations, translations),
|
27
|
-
license_key: overrides.fetch(:license_key, license_key),
|
28
|
-
type: overrides.fetch(:type, type),
|
29
|
-
ckbox: overrides.fetch(:ckbox, ckbox),
|
30
|
-
config: config.merge(overrides.fetch(:config, {}))
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def ckbox(version = nil, theme: :lark)
|
35
|
-
return @ckbox if version.nil?
|
36
|
-
|
37
|
-
@ckbox = { version: version, theme: theme }
|
38
|
-
end
|
39
|
-
|
40
|
-
def license_key(license_key = nil)
|
41
|
-
return @license_key if license_key.nil?
|
42
|
-
|
43
|
-
@license_key = license_key
|
44
|
-
end
|
45
|
-
|
46
|
-
def gpl
|
47
|
-
license_key('GPL')
|
48
|
-
premium(false)
|
49
|
-
end
|
50
|
-
|
51
|
-
def premium(premium = nil)
|
52
|
-
return @premium if premium.nil?
|
53
|
-
|
54
|
-
@premium = premium
|
55
|
-
end
|
56
|
-
|
57
|
-
def translations(*translations)
|
58
|
-
return @translations if translations.empty?
|
59
|
-
|
60
|
-
@translations = translations
|
61
|
-
end
|
62
|
-
|
63
|
-
def version(version = nil)
|
64
|
-
return @version.to_s if version.nil?
|
65
|
-
|
66
|
-
@version = Semver.new(version)
|
67
|
-
end
|
68
|
-
|
69
|
-
def cdn(cdn = nil)
|
70
|
-
return @cdn if cdn.nil?
|
71
|
-
|
72
|
-
@cdn = cdn
|
73
|
-
end
|
74
|
-
|
75
|
-
def type(type = nil)
|
76
|
-
return @type if type.nil?
|
77
|
-
raise ArgumentError, "Invalid editor type: #{type}" unless Editor::Props.valid_editor_type?(type)
|
78
|
-
|
79
|
-
@type = type
|
80
|
-
end
|
81
|
-
|
82
|
-
def configure(key, value)
|
83
|
-
@config[key] = value
|
84
|
-
end
|
85
|
-
|
86
|
-
def menubar(visible: true)
|
87
|
-
@config[:menuBar] = {
|
88
|
-
isVisible: visible
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
def toolbar(*items, should_group_when_full: true, &block)
|
93
|
-
if @config[:toolbar].blank? || !items.empty?
|
94
|
-
@config[:toolbar] = {
|
95
|
-
items: items,
|
96
|
-
shouldNotGroupWhenFull: !should_group_when_full
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
return unless block
|
101
|
-
|
102
|
-
builder = ToolbarBuilder.new(@config[:toolbar])
|
103
|
-
builder.instance_eval(&block)
|
104
|
-
end
|
105
|
-
|
106
|
-
def inline_plugin(name, code)
|
107
|
-
@config[:plugins] << Editor::PropsInlinePlugin.new(name, code)
|
108
|
-
end
|
109
|
-
|
110
|
-
def plugin(name, **kwargs)
|
111
|
-
@config[:plugins] << Editor::PropsPlugin.new(name, **kwargs)
|
112
|
-
end
|
113
|
-
|
114
|
-
def plugins(*names, **kwargs)
|
115
|
-
names.each { |name| plugin(name, **kwargs) }
|
116
|
-
end
|
117
|
-
|
118
|
-
def language(ui, content: ui) # rubocop:disable Naming/MethodParameterName
|
119
|
-
@config[:language] = {
|
120
|
-
ui: ui,
|
121
|
-
content: content
|
122
|
-
}
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|