ckeditor5 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +127 -54
  3. data/lib/ckeditor5/rails/version.rb +1 -1
  4. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0babe5c17bf5e8492ad7e372a23d0c5c3bc900552d18c22f14702d1b1ef27cb4
4
- data.tar.gz: b4a3eb8f291deb3584dcce52cd3e404c97311321b4d7ccf6767c26face6dcb37
3
+ metadata.gz: ffcf4f20d7134eefdd8ed70322d880862886c260c5b68295154e5932eb7aed8f
4
+ data.tar.gz: 63c20e49867be66eee43e90a0b473e13971648216675927408d82265f483d8b8
5
5
  SHA512:
6
- metadata.gz: 629844431fc4c4eedf849b65d90a05f7df0591c90a24cb44f22c80c348ae84afbaae2428902f0eb47e56bfaaaf6057365f1256a5330d62b759300159dd6c7855
7
- data.tar.gz: fa122e9c537fd3d17eba7a9c98e39e3d24f15377a03be2cf72df07e85220e9fdbb72ee1dc8c9942ba23216e3b58334e874d2c7d334a2a21fa8ceccc4f3c7f8c9
6
+ metadata.gz: f5d9f8eb254a1210c9792ddfea0885f58b4c11c9d049a14ee9e269f753204f7a10e3eacade18f502497becb02544f7440641414f6dd1495798428ef10fa40c47
7
+ data.tar.gz: 88fb52bde4a26017c7e122ac71dcaad9568ccbd1a4163f41a55cbf5d9f67ee19a2acdc8f7a37edfde92444fbbc230a34f20bfde005630d95cd7f29b52085b16b
data/README.md CHANGED
@@ -20,7 +20,7 @@ Add this line to your application's Gemfile:
20
20
  gem 'ckeditor5'
21
21
  ```
22
22
 
23
- In your config:
23
+ In your config (the default config is defined [here](https://github.com/Mati365/ckeditor5-rails/blob/main/lib/ckeditor5/rails/presets/manager.rb)):
24
24
 
25
25
  ```rb
26
26
  # config/initializers/ckeditor5.rb
@@ -67,6 +67,10 @@ Voilà! You have CKEditor 5 integrated with your Rails application. 🎉
67
67
  - [`plugins(*names, **kwargs)` method](#pluginsnames-kwargs-method)
68
68
  - [`inline_plugin(name, code)` method](#inline_pluginname-code-method)
69
69
  - [Including CKEditor 5 assets 📦](#including-ckeditor-5-assets-)
70
+ - [Format 📝](#format-)
71
+ - [Using default preset](#using-default-preset)
72
+ - [Custom preset](#custom-preset)
73
+ - [Inline preset definition](#inline-preset-definition)
70
74
  - [Lazy loading 🚀](#lazy-loading-)
71
75
  - [GPL usage 🆓](#gpl-usage-)
72
76
  - [Commercial usage 💰](#commercial-usage-)
@@ -141,16 +145,18 @@ CKEditor5::Rails.configure do
141
145
  end
142
146
  ```
143
147
 
144
- In order to override existing presets, you can use the `config.presets.override` method. The method takes the name of the preset you want to override and a block with the old configuration. The example below shows how to hide the menubar in the default preset:
148
+ In order to override existing presets, you can use the `presets.override` method. The method takes the name of the preset you want to override and a block with the old configuration. The example below shows how to hide the menubar in the default preset:
145
149
 
146
150
  ```rb
147
151
  # config/initializers/ckeditor5.rb
148
152
 
149
153
  CKEditor5::Rails.configure do
150
- menubar visible: false
154
+ presets.override :custom do
155
+ menubar visible: false
151
156
 
152
- toolbar do
153
- remove :underline, :heading
157
+ toolbar do
158
+ remove :underline, :heading
159
+ end
154
160
  end
155
161
  end
156
162
  ```
@@ -169,7 +175,7 @@ Defines the CDN to be used for CKEditor 5 assets. The example below shows how to
169
175
  ```rb
170
176
  # config/initializers/ckeditor5.rb
171
177
 
172
- config.presets.define :custom do
178
+ CKEditor5::Rails.configure do
173
179
  # ... other configuration
174
180
 
175
181
  cdn :jsdelivr
@@ -181,7 +187,7 @@ It also allows you to define a custom CDN by passing a block with the bundle, ve
181
187
  ```rb
182
188
  # config/initializers/ckeditor5.rb
183
189
 
184
- config.presets.define :custom do
190
+ CKEditor5::Rails.configure do
185
191
  # ... other configuration
186
192
 
187
193
  cdn do |bundle, version, path|
@@ -199,7 +205,7 @@ Defines the version of CKEditor 5 to be used. The example below shows how to set
199
205
  ```rb
200
206
  # config/initializers/ckeditor5.rb
201
207
 
202
- config.presets.define :custom do
208
+ CKEditor5::Rails.configure do
203
209
  # ... other configuration
204
210
 
205
211
  version '43.2.0'
@@ -213,7 +219,7 @@ Defines the license of CKEditor 5. The example below shows how to set the licens
213
219
  ```rb
214
220
  # config/initializers/ckeditor5.rb
215
221
 
216
- config.presets.define :custom do
222
+ CKEditor5::Rails.configure do
217
223
  # ... other configuration
218
224
 
219
225
  gpl
@@ -227,7 +233,7 @@ Defines the license key of CKEditor 5. It calls `premium` method internally. The
227
233
  ```rb
228
234
  # config/initializers/ckeditor5.rb
229
235
 
230
- config.presets.define :custom do
236
+ CKEditor5::Rails.configure do
231
237
  # ... other configuration
232
238
 
233
239
  license_key 'your-license-key'
@@ -241,7 +247,7 @@ Defines if premium package should be included in JS assets. The example below sh
241
247
  ```rb
242
248
  # config/initializers/ckeditor5.rb
243
249
 
244
- config.presets.define :custom do
250
+ CKEditor5::Rails.configure do
245
251
  # ... other configuration
246
252
 
247
253
  premium
@@ -255,7 +261,7 @@ Defines the translations of CKEditor 5. You can pass the language codes as argum
255
261
  ```rb
256
262
  # config/initializers/ckeditor5.rb
257
263
 
258
- config.presets.define :custom do
264
+ CKEditor5::Rails.configure do
259
265
  # ... other configuration
260
266
 
261
267
  translations :pl, :es
@@ -267,9 +273,10 @@ end
267
273
  ```rb
268
274
  # config/initializers/ckeditor5.rb
269
275
 
270
- config.presets.define :custom do
271
- translations :pl
276
+ CKEditor5::Rails.configure do
277
+ # ... other configuration
272
278
 
279
+ translations :pl
273
280
  language :pl
274
281
  end
275
282
  ```
@@ -281,7 +288,7 @@ Defines the CKBox plugin to be included in the editor. The example below shows h
281
288
  ```rb
282
289
  # config/initializers/ckeditor5.rb
283
290
 
284
- config.presets.define :custom do
291
+ CKEditor5::Rails.configure do
285
292
  # ... other configuration
286
293
 
287
294
  ckbox '2.5.4', theme: :lark
@@ -303,7 +310,7 @@ The example below sets the editor type to `multiroot` in the custom preset:
303
310
  ```rb
304
311
  # config/initializers/ckeditor5.rb
305
312
 
306
- config.presets.define :custom do
313
+ CKEditor5::Rails.configure do
307
314
  # ... other configuration
308
315
 
309
316
  type :multiroot
@@ -322,7 +329,7 @@ The `should_group_when_full` keyword argument determines whether the toolbar sho
322
329
  ```rb
323
330
  # config/initializers/ckeditor5.rb
324
331
 
325
- config.presets.define :custom do
332
+ CKEditor5::Rails.configure do
326
333
  # ... other configuration
327
334
 
328
335
  toolbar :undo, :redo, :|, :heading, :|, :bold, :italic, :underline, :|,
@@ -338,7 +345,7 @@ If you want to add or prepend items to the existing toolbar, you can use the blo
338
345
  ```rb
339
346
  # config/initializers/ckeditor5.rb
340
347
 
341
- config.presets.override :default do
348
+ CKEditor5::Rails.configure do
342
349
  # ... other configuration
343
350
 
344
351
  toolbar do
@@ -353,7 +360,7 @@ If you want to remove items from the toolbar, you can use the `remove` method:
353
360
  ```rb
354
361
  # config/initializers/ckeditor5.rb
355
362
 
356
- config.presets.override :default do
363
+ CKEditor5::Rails.configure do
357
364
  # ... other configuration
358
365
 
359
366
  toolbar do
@@ -369,7 +376,7 @@ Defines the visibility of the menubar. By default, it's set to `true`.
369
376
  ```rb
370
377
  # config/initializers/ckeditor5.rb
371
378
 
372
- config.presets.define :custom do
379
+ CKEditor5::Rails.configure do
373
380
  # ... other configuration
374
381
 
375
382
  toolbar :undo, :redo, :|, :heading, :|, :bold, :italic, :underline, :|,
@@ -385,7 +392,7 @@ Defines the language of the editor. You can pass the language code as an argumen
385
392
  ```rb
386
393
  # config/initializers/ckeditor5.rb
387
394
 
388
- config.presets.define :custom do
395
+ CKEditor5::Rails.configure do
389
396
  # ... other configuration
390
397
 
391
398
  language :pl
@@ -397,7 +404,7 @@ In order to set the language for the content, you can pass the `content` keyword
397
404
  ```rb
398
405
  # config/initializers/ckeditor5.rb
399
406
 
400
- config.presets.define :custom do
407
+ CKEditor5::Rails.configure do
401
408
  # ... other configuration
402
409
 
403
410
  language :en, content: :pl
@@ -411,7 +418,7 @@ Allows you to set custom configuration options. You can pass the name of the opt
411
418
  ```rb
412
419
  # config/initializers/ckeditor5.rb
413
420
 
414
- config.presets.define :custom do
421
+ CKEditor5::Rails.configure do
415
422
  # ... other configuration
416
423
 
417
424
  configure :link, {
@@ -429,7 +436,7 @@ The example below show how to import Bold plugin from the `ckeditor5` npm packag
429
436
  ```rb
430
437
  # config/initializers/ckeditor5.rb
431
438
 
432
- config.presets.define :custom do
439
+ CKEditor5::Rails.configure do
433
440
  # ... other configuration
434
441
 
435
442
  plugin :Bold
@@ -441,7 +448,7 @@ In order to import a plugin from a custom ESM package, you can pass the `import_
441
448
  ```rb
442
449
  # config/initializers/ckeditor5.rb
443
450
 
444
- config.presets.define :custom do
451
+ CKEditor5::Rails.configure do
445
452
  # ... other configuration
446
453
 
447
454
  plugin :YourPlugin, import_name: 'your-package'
@@ -453,7 +460,7 @@ In order to import a plugin from a custom Window entry, you can pass the `window
453
460
  ```rb
454
461
  # config/initializers/ckeditor5.rb
455
462
 
456
- config.presets.define :custom do
463
+ CKEditor5::Rails.configure do
457
464
  # ... other configuration
458
465
 
459
466
  plugin :YourPlugin, window_name: 'YourPlugin'
@@ -467,7 +474,7 @@ Defines the plugins to be included in the editor. You can specify multiple plugi
467
474
  ```rb
468
475
  # config/initializers/ckeditor5.rb
469
476
 
470
- config.presets.define :custom do
477
+ CKEditor5::Rails.configure do
471
478
  # ... other configuration
472
479
 
473
480
  plugins :Bold, :Italic, :Underline, :Link
@@ -481,7 +488,7 @@ Use with caution as this is an inline definition of the plugin code, and you can
481
488
  ```rb
482
489
  # config/initializers/ckeditor5.rb
483
490
 
484
- config.presets.define :custom do
491
+ CKEditor5::Rails.configure do
485
492
  # ... other configuration
486
493
 
487
494
  inline_plugin :MyCustomPlugin, <<~JS
@@ -507,32 +514,88 @@ To include CKEditor 5 assets in your application, you can use the `ckeditor5_ass
507
514
 
508
515
  Keep in mind that you need to include the helper result in the `head` section of your layout. In examples below, we use `content_for` helper to include the assets in the `head` section of the view.
509
516
 
510
- ### Lazy loading 🚀
517
+ ### Format 📝
511
518
 
512
- <details>
513
- <summary>Loading JS and CSS Assets</summary>
519
+ #### Using default preset
514
520
 
515
- All JS assets defined by the `ckeditor5_assets` helper method are loaded **asynchronously**. It means that the assets are loaded in the background without blocking the rendering of the page. However, the CSS assets are loaded **synchronously** to prevent the flash of unstyled content and ensure that the editor is styled correctly.
521
+ The example below users the default preset defined [here](https://github.com/Mati365/ckeditor5-rails/blob/main/lib/ckeditor5/rails/presets/manager.rb).
516
522
 
517
- It has been achieved by using web components, together with import maps, which are supported by modern browsers. The web components are used to define the editor and its plugins, while the import maps are used to define the dependencies between the assets.
523
+ ```erb
524
+ <!-- app/views/demos/index.html.erb -->
518
525
 
519
- </details>
526
+ <% content_for :head do %>
527
+ <%= ckeditor5_assets %>
528
+ <% end %>
529
+ ```
520
530
 
521
- ### GPL usage 🆓
531
+ If you want to fetch some additional translations, you can extend your initializer with the following configuration:
532
+
533
+ ```rb
534
+ # config/initializers/ckeditor5.rb
535
+
536
+ CKEditor5::Rails.configure do
537
+ # ... rest of the configuration
538
+
539
+ translations :pl, :es
540
+ end
541
+ ```
522
542
 
523
- If you want to use CKEditor 5 under the GPL license, you can include the assets using the `ckeditor5_assets` without passing any arguments. However you can pass the `version` keyword argument with the version of CKEditor 5 you want to use:
543
+ #### Custom preset
544
+
545
+ To specify a custom preset, you need to pass the `preset` keyword argument with the name of the preset. The example below shows how to include the assets for the custom preset:
524
546
 
525
547
  ```erb
526
548
  <!-- app/views/demos/index.html.erb -->
527
549
 
528
550
  <% content_for :head do %>
529
- <%= ckeditor5_assets version: '43.3.0' %>
551
+ <%= ckeditor5_assets preset: :custom %>
530
552
  <% end %>
531
553
  ```
532
554
 
533
- It'll include the necessary assets for the GPL license from one of the most popular CDNs. In our scenario, we use the `jsdelivr` CDN which is the default one.
555
+ In order to define such preset, you can use the following configuration:
556
+
557
+ ```rb
558
+ # config/initializers/ckeditor5.rb
559
+
560
+ CKEditor5::Rails.configure do
561
+ # ... rest of the configuration
562
+
563
+ presets.define :custom do
564
+ # ... your preset configuration
565
+
566
+ translations :pl, :es
567
+ end
568
+ end
569
+ ```
570
+
571
+ #### Inline preset definition
572
+
573
+ It's possible to define the preset directly in the `ckeditor5_assets` helper method. It allows you to dynamically specify version, cdn provider or even translations in the view. The example below inherits the default preset and adds Polish translations and other options:
574
+
575
+ ```erb
576
+ <!-- app/views/demos/index.html.erb -->
577
+
578
+ <% content_for :head do %>
579
+ <%= ckeditor5_assets version: '43.3.0', cdn: :jsdelivr, translations: [:pl], license_key: '<YOUR KEY> OR GPL' %>
580
+ <% end %>
581
+ ```
582
+
583
+ ### Lazy loading 🚀
584
+
585
+ <details>
586
+ <summary>Loading JS and CSS Assets</summary>
587
+
588
+ All JS assets defined by the `ckeditor5_assets` helper method are loaded **asynchronously**. It means that the assets are loaded in the background without blocking the rendering of the page. However, the CSS assets are loaded **synchronously** to prevent the flash of unstyled content and ensure that the editor is styled correctly.
589
+
590
+ It has been achieved by using web components, together with import maps, which are supported by modern browsers. The web components are used to define the editor and its plugins, while the import maps are used to define the dependencies between the assets.
591
+
592
+ </details>
593
+
594
+ ### GPL usage 🆓
534
595
 
535
- Version is optional as long as you defined it in the `config/initializers/ckeditor5.rb` file. If you want to use the default version, you can omit the `version` keyword argument:
596
+ If you want to use CKEditor 5 under the GPL license, you can include the assets using the `ckeditor5_assets` without passing any arguments. It'll include the necessary assets for the GPL license from one of the most popular CDNs. In our scenario, we use the `jsdelivr` CDN which is the default one.
597
+
598
+ Example:
536
599
 
537
600
  ```erb
538
601
  <!-- app/views/demos/index.html.erb -->
@@ -542,7 +605,7 @@ Version is optional as long as you defined it in the `config/initializers/ckedit
542
605
  <% end %>
543
606
  ```
544
607
 
545
- Set the version in the `config/initializers/ckeditor5.rb` file:
608
+ In that scenario it's recommended to add `gpl` method to the initializer along with the version:
546
609
 
547
610
  ```rb
548
611
  # config/initializers/ckeditor5.rb
@@ -553,49 +616,59 @@ CKEditor5::Rails.configure do
553
616
  end
554
617
  ```
555
618
 
556
- In order to use `unpkg` CDN, you can pass the `cdn` keyword argument with the value `:unpkg`:
619
+ In order to use `unpkg` CDN, you can extend your initializer with the following configuration:
557
620
 
558
- ```erb
559
- <!-- app/views/demos/index.html.erb -->
621
+ ```rb
622
+ # config/initializers/ckeditor5.rb
560
623
 
561
- <% content_for :head do %>
562
- <%= ckeditor5_assets cdn: :unpkg %>
563
- <% end %>
624
+ CKEditor5::Rails.configure do
625
+ # ... rest of the configuration
626
+
627
+ cdn :unpkg
628
+ end
564
629
  ```
565
630
 
566
- or using helper function:
631
+ However, you can also specify the CDN directly in the view:
567
632
 
568
633
  ```erb
569
634
  <!-- app/views/demos/index.html.erb -->
570
635
 
571
636
  <% content_for :head do %>
572
- <%= ckeditor5_jsdelivr_assets %>
637
+ <%= ckeditor5_assets cdn: :unpkg %>
573
638
  <% end %>
574
639
  ```
575
640
 
576
- Translating CKEditor 5 is possible by passing the `translations` keyword argument with the languages codes array. The example below shows how to include the Polish translations:
641
+ or using helper function:
577
642
 
578
643
  ```erb
579
644
  <!-- app/views/demos/index.html.erb -->
580
645
 
581
646
  <% content_for :head do %>
582
- <%= ckeditor5_assets translations: [:pl] %>
647
+ <%= ckeditor5_jsdelivr_assets %>
583
648
  <% end %>
584
649
  ```
585
650
 
586
- Keep in mind, that you need to include the translations in the `config/initializers/ckeditor5.rb` file:
651
+ ### Commercial usage 💰
652
+
653
+ If you want to use CKEditor 5 under a commercial license, you have to specify license key. It can be done in the initializer:
587
654
 
588
655
  ```rb
589
656
  # config/initializers/ckeditor5.rb
590
657
 
591
658
  CKEditor5::Rails.configure do
592
- language :pl
659
+ license_key 'your-license-key'
593
660
  end
594
661
  ```
595
662
 
596
- ### Commercial usage 💰
663
+ ```erb
664
+ <!-- app/views/demos/index.html.erb -->
665
+
666
+ <% content_for :head do %>
667
+ <%= ckeditor5_assets %>
668
+ <% end %>
669
+ ```
597
670
 
598
- If you want to use CKEditor 5 under a commercial license, you can include the assets using the `ckeditor5_assets` helper method with the `license_key` keyword argument. The example below shows how to include the assets for the commercial license:
671
+ or directly in the view:
599
672
 
600
673
  ```erb
601
674
  <!-- app/views/demos/index.html.erb -->
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CKEditor5::Rails
4
- VERSION = '1.5.0'
4
+ VERSION = '1.5.1'
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.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Bagiński
@@ -9,28 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-04 00:00:00.000000000 Z
12
+ date: 2024-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '7.0'
21
18
  - - ">="
22
19
  - !ruby/object:Gem::Version
23
- version: 7.0.3
20
+ version: '6.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '8.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: '7.0'
31
28
  - - ">="
32
29
  - !ruby/object:Gem::Version
33
- version: 7.0.3
30
+ version: '6.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '8.0'
34
34
  description:
35
35
  email: cziken58@gmail.com
36
36
  executables: []