ckeditor5 1.6.0 → 1.7.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4325c958e2805d971859c841f0b2694490e35a7e4600e2b8bb60f35672493146
|
4
|
+
data.tar.gz: 23aa528bcbfbec102647898aee0fb4c064e7d16bd051fc4bf45ae94b9ed16fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e12e3e13824889463c2500e5d26874c1dd7c1dac6c5dbf1d41b37e5bd66e25b642b92fdbcb943b4f99219302e9184bacc5c8b16902559511c69db2392e2d569
|
7
|
+
data.tar.gz: '090b221f5bebaedac65be2db6a230409537b891bce481258106a575a58555b59fa2a0f55b125ea114115554ecba1b2d0f80845e3b1bea14f6f743af627972810'
|
data/README.md
CHANGED
@@ -73,6 +73,7 @@ Voilà! You have CKEditor 5 integrated with your Rails application. 🎉
|
|
73
73
|
- [`gpl` method](#gpl-method)
|
74
74
|
- [`license_key(key)` method](#license_keykey-method)
|
75
75
|
- [`premium` method](#premium-method)
|
76
|
+
- [`editable_height(height)` method](#editable_heightheight-method)
|
76
77
|
- [`translations(*languages)` method](#translationslanguages-method)
|
77
78
|
- [`ckbox` method](#ckbox-method)
|
78
79
|
- [`type(type)` method](#typetype-method)
|
@@ -271,6 +272,20 @@ CKEditor5::Rails.configure do
|
|
271
272
|
end
|
272
273
|
```
|
273
274
|
|
275
|
+
#### `editable_height(height)` method
|
276
|
+
|
277
|
+
Defines the height of the editor. The example below shows how to set the height to `300px`:
|
278
|
+
|
279
|
+
```rb
|
280
|
+
# config/initializers/ckeditor5.rb
|
281
|
+
|
282
|
+
CKEditor5::Rails.configure do
|
283
|
+
# ... other configuration
|
284
|
+
|
285
|
+
editable_height 300
|
286
|
+
end
|
287
|
+
```
|
288
|
+
|
274
289
|
#### `translations(*languages)` method
|
275
290
|
|
276
291
|
Defines the translations of CKEditor 5. You can pass the language codes as arguments. The example below shows how tell integration to fetch Polish and Spanish translations:
|
@@ -808,6 +823,18 @@ If you want to override the configuration of the editor specified in default or
|
|
808
823
|
<%= ckeditor5_editor extra_config: { toolbar: [:Bold, :Italic] }, style: 'width: 600px' %>
|
809
824
|
```
|
810
825
|
|
826
|
+
It's possible to define the height of the editor by passing the `editable_height` keyword argument with the value in pixels:
|
827
|
+
|
828
|
+
```erb
|
829
|
+
<!-- app/views/demos/index.html.erb -->
|
830
|
+
|
831
|
+
<% content_for :head do %>
|
832
|
+
<%= ckeditor5_assets %>
|
833
|
+
<% end %>
|
834
|
+
|
835
|
+
<%= ckeditor5_editor editable_height: 300 %>
|
836
|
+
```
|
837
|
+
|
811
838
|
### Multiroot editor 🌳
|
812
839
|
|
813
840
|
The multiroot editor allows you to create an editor with multiple editable areas. It's useful when you want to create a CMS with multiple editable areas on a single page.
|
@@ -228,6 +228,7 @@ class CKEditorComponent extends HTMLElement {
|
|
228
228
|
this.instance = instance;
|
229
229
|
|
230
230
|
this.#setupContentSync();
|
231
|
+
this.#setupEditableHeight();
|
231
232
|
|
232
233
|
this.instancePromise.resolve(this.instance);
|
233
234
|
} catch (err) {
|
@@ -236,10 +237,18 @@ class CKEditorComponent extends HTMLElement {
|
|
236
237
|
}
|
237
238
|
}
|
238
239
|
|
240
|
+
/**
|
241
|
+
* Checks if current editor is classic type
|
242
|
+
*
|
243
|
+
* @returns {boolean}
|
244
|
+
*/
|
245
|
+
isClassic() {
|
246
|
+
return this.getAttribute('type') === 'ClassicEditor';
|
247
|
+
}
|
248
|
+
|
239
249
|
/**
|
240
250
|
* Checks if current editor is multiroot type
|
241
251
|
*
|
242
|
-
* @private
|
243
252
|
* @returns {boolean}
|
244
253
|
*/
|
245
254
|
isMultiroot() {
|
@@ -249,7 +258,6 @@ class CKEditorComponent extends HTMLElement {
|
|
249
258
|
/**
|
250
259
|
* Checks if current editor is decoupled type
|
251
260
|
*
|
252
|
-
* @private
|
253
261
|
* @returns {boolean}
|
254
262
|
*/
|
255
263
|
isDecoupled() {
|
@@ -259,7 +267,6 @@ class CKEditorComponent extends HTMLElement {
|
|
259
267
|
/**
|
260
268
|
* Checks if current editor has watchdog enabled
|
261
269
|
*
|
262
|
-
* @private
|
263
270
|
* @returns {boolean}
|
264
271
|
*/
|
265
272
|
hasWatchdog() {
|
@@ -378,6 +385,28 @@ class CKEditorComponent extends HTMLElement {
|
|
378
385
|
});
|
379
386
|
}
|
380
387
|
|
388
|
+
/**
|
389
|
+
* Sets up editable height for ClassicEditor
|
390
|
+
*
|
391
|
+
* @private
|
392
|
+
*/
|
393
|
+
#setupEditableHeight() {
|
394
|
+
if (!this.isClassic()) {
|
395
|
+
return;
|
396
|
+
}
|
397
|
+
|
398
|
+
const { instance } = this;
|
399
|
+
const height = Number.parseInt(this.getAttribute('editable-height'), 10);
|
400
|
+
|
401
|
+
if (Number.isNaN(height)) {
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
|
405
|
+
instance.editing.view.change((writer) => {
|
406
|
+
writer.setStyle('height', `${height}px`, instance.editing.view.document.getRoot());
|
407
|
+
});
|
408
|
+
}
|
409
|
+
|
381
410
|
/**
|
382
411
|
* Loads translation modules
|
383
412
|
*
|
@@ -8,26 +8,34 @@ module CKEditor5::Rails
|
|
8
8
|
module Editor::Helpers
|
9
9
|
class EditorContextError < StandardError; end
|
10
10
|
class PresetNotFoundError < ArgumentError; end
|
11
|
+
class InvalidEditableHeightError < ArgumentError; end
|
11
12
|
|
12
|
-
def ckeditor5_editor(
|
13
|
+
def ckeditor5_editor( # rubocop:disable Metrics/ParameterLists
|
13
14
|
config: nil, extra_config: {},
|
14
15
|
type: nil, preset: nil,
|
15
16
|
initial_data: nil, watchdog: true,
|
17
|
+
editable_height: nil,
|
16
18
|
**html_attributes, &block
|
17
19
|
)
|
18
20
|
validate_editor_input!(initial_data, block)
|
21
|
+
|
19
22
|
controller_context = validate_and_get_editor_context!
|
20
23
|
|
21
24
|
preset = resolve_editor_preset(preset || controller_context[:preset])
|
22
25
|
config = build_editor_config(preset, config, extra_config, initial_data)
|
23
26
|
type ||= preset.type
|
24
27
|
|
28
|
+
validated_height = validate_editable_height(type, editable_height) || preset.editable_height
|
25
29
|
editor_props = Editor::Props.new(
|
26
30
|
controller_context, type, config,
|
27
31
|
watchdog: watchdog
|
28
32
|
)
|
29
33
|
|
30
|
-
render_editor_component(
|
34
|
+
render_editor_component(
|
35
|
+
editor_props,
|
36
|
+
html_attributes.merge(validated_height ? { 'editable-height' => validated_height } : {}),
|
37
|
+
&block
|
38
|
+
)
|
31
39
|
end
|
32
40
|
|
33
41
|
def ckeditor5_editable(name = nil, **kwargs, &block)
|
@@ -83,5 +91,23 @@ module CKEditor5::Rails
|
|
83
91
|
def render_editor_component(props, html_attributes, &block)
|
84
92
|
tag.send(:'ckeditor-component', **props.to_attributes, **html_attributes, &block)
|
85
93
|
end
|
94
|
+
|
95
|
+
def validate_editable_height(type, height)
|
96
|
+
return nil if height.nil?
|
97
|
+
|
98
|
+
unless type == :classic
|
99
|
+
raise InvalidEditableHeightError,
|
100
|
+
'editable_height can be used only with ClassicEditor'
|
101
|
+
end
|
102
|
+
|
103
|
+
case height
|
104
|
+
when String, /^\d+px$/ then height
|
105
|
+
when Integer, /^\d+$/ then "#{height}px"
|
106
|
+
else
|
107
|
+
raise InvalidEditableHeightError,
|
108
|
+
"editable_height must be an integer representing pixels or string ending with 'px'\n" \
|
109
|
+
"(e.g. 500 or '500px'). Got: #{height.inspect}"
|
110
|
+
end
|
111
|
+
end
|
86
112
|
end
|
87
113
|
end
|
@@ -13,6 +13,7 @@ module CKEditor5::Rails
|
|
13
13
|
@license_key = nil
|
14
14
|
@type = :classic
|
15
15
|
@ckbox = nil
|
16
|
+
@editable_height = nil
|
16
17
|
@config = {
|
17
18
|
plugins: [],
|
18
19
|
toolbar: []
|
@@ -32,6 +33,12 @@ module CKEditor5::Rails
|
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
36
|
+
def editable_height(height = nil)
|
37
|
+
return @editable_height if height.nil?
|
38
|
+
|
39
|
+
@editable_height = height
|
40
|
+
end
|
41
|
+
|
35
42
|
def ckbox(version = nil, theme: :lark)
|
36
43
|
return @ckbox if version.nil?
|
37
44
|
|
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.
|
4
|
+
version: 1.7.0
|
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-11-
|
12
|
+
date: 2024-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|