ckeditor5 1.5.4 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +16 -0
 - data/lib/ckeditor5/rails/cdn/helpers.rb +2 -1
 - data/lib/ckeditor5/rails/editor/helpers.rb +21 -8
 - data/lib/ckeditor5/rails/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4ad96eb676ba96b39112d59c4f4404dbdb0c0fbce2b4f550b35c3e101912c18f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f58e26500ca145f1b4a4cb8421ee525f9dd3865e545a012cac132b9e667489ab
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: deffecb44d57d886e23adacb80e2849517e43f5528154ee0e956dac016cd0ce541bd949e8d707049f1750687ecb4e9c872b89c719f7b76c1ad2550fceec51aed
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 595a4e6f3ea8a192ec28973452074dad87d3f6da84b2ff926868c4921afea8238bc2642649ca0a0d45c734d8dfdfb88fb0b23f84686d9ba10727c5778845a59e
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            [](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
         
     | 
| 
       4 
4 
     | 
    
         
             
            
         
     | 
| 
      
 5 
     | 
    
         
            +
            
         
     | 
| 
       5 
6 
     | 
    
         
             
            [](http://makeapullrequest.com)
         
     | 
| 
       6 
7 
     | 
    
         
             
            
         
     | 
| 
       7 
8 
     | 
    
         
             
            [](https://github.com/Mati365/ckeditor5-rails/issues)
         
     | 
| 
         @@ -566,6 +567,9 @@ To specify a custom preset, you need to pass the `preset` keyword argument with 
     | 
|
| 
       566 
567 
     | 
    
         
             
            <% content_for :head do %>
         
     | 
| 
       567 
568 
     | 
    
         
             
              <%= ckeditor5_assets preset: :custom %>
         
     | 
| 
       568 
569 
     | 
    
         
             
            <% end %>
         
     | 
| 
      
 570 
     | 
    
         
            +
             
     | 
| 
      
 571 
     | 
    
         
            +
            <%-# This editor will use `custom` preset defined in `ckeditor5_assets` above %>
         
     | 
| 
      
 572 
     | 
    
         
            +
            <%= ckeditor5_editor %>
         
     | 
| 
       569 
573 
     | 
    
         
             
            ```
         
     | 
| 
       570 
574 
     | 
    
         | 
| 
       571 
575 
     | 
    
         
             
            In order to define such preset, you can use the following configuration:
         
     | 
| 
         @@ -584,6 +588,18 @@ CKEditor5::Rails.configure do 
     | 
|
| 
       584 
588 
     | 
    
         
             
            end
         
     | 
| 
       585 
589 
     | 
    
         
             
            ```
         
     | 
| 
       586 
590 
     | 
    
         | 
| 
      
 591 
     | 
    
         
            +
            :warning: Keep in mind that all `ckeditor5_editor` helpers will use the configuration from the preset defined in the `ckeditor5_assets`. If you want to use a different preset for a specific editor, you can pass the `preset` keyword argument to the `ckeditor5_editor` helper.
         
     | 
| 
      
 592 
     | 
    
         
            +
             
     | 
| 
      
 593 
     | 
    
         
            +
            ```erb
         
     | 
| 
      
 594 
     | 
    
         
            +
            <!-- app/views/demos/index.html.erb -->
         
     | 
| 
      
 595 
     | 
    
         
            +
             
     | 
| 
      
 596 
     | 
    
         
            +
            <% content_for :head do %>
         
     | 
| 
      
 597 
     | 
    
         
            +
              <%= ckeditor5_assets preset: :custom %>
         
     | 
| 
      
 598 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 599 
     | 
    
         
            +
             
     | 
| 
      
 600 
     | 
    
         
            +
            <%= ckeditor5_editor preset: :default %>
         
     | 
| 
      
 601 
     | 
    
         
            +
            ```
         
     | 
| 
      
 602 
     | 
    
         
            +
             
     | 
| 
       587 
603 
     | 
    
         
             
            #### Inline preset definition
         
     | 
| 
       588 
604 
     | 
    
         | 
| 
       589 
605 
     | 
    
         
             
            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:
         
     | 
| 
         @@ -11,21 +11,17 @@ module CKEditor5::Rails 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                def ckeditor5_editor( # rubocop:disable Metrics/ParameterLists
         
     | 
| 
       13 
13 
     | 
    
         
             
                  config: nil, extra_config: {},
         
     | 
| 
       14 
     | 
    
         
            -
                  type: nil, preset:  
     | 
| 
      
 14 
     | 
    
         
            +
                  type: nil, preset: nil,
         
     | 
| 
       15 
15 
     | 
    
         
             
                  initial_data: nil, watchdog: true,
         
     | 
| 
       16 
16 
     | 
    
         
             
                  **html_attributes, &block
         
     | 
| 
       17 
17 
     | 
    
         
             
                )
         
     | 
| 
      
 18 
     | 
    
         
            +
                  validate_editor_input!(initial_data, block)
         
     | 
| 
       18 
19 
     | 
    
         
             
                  controller_context = validate_and_get_editor_context!
         
     | 
| 
       19 
     | 
    
         
            -
                  preset = fetch_editor_preset(preset)
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 21 
     | 
    
         
            +
                  preset = resolve_editor_preset(preset || controller_context[:preset])
         
     | 
| 
      
 22 
     | 
    
         
            +
                  config = build_editor_config(preset, config, extra_config, initial_data)
         
     | 
| 
       22 
23 
     | 
    
         
             
                  type ||= preset.type
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                  config = config.deep_merge(extra_config)
         
     | 
| 
       25 
     | 
    
         
            -
                  config[:initialData] = initial_data if initial_data
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  raise ArgumentError, 'Cannot pass initial data and block at the same time.' if initial_data && block
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
25 
     | 
    
         
             
                  editor_props = Editor::Props.new(
         
     | 
| 
       30 
26 
     | 
    
         
             
                    controller_context, type, config,
         
     | 
| 
       31 
27 
     | 
    
         
             
                    watchdog: watchdog
         
     | 
| 
         @@ -52,6 +48,23 @@ module CKEditor5::Rails 
     | 
|
| 
       52 
48 
     | 
    
         | 
| 
       53 
49 
     | 
    
         
             
                private
         
     | 
| 
       54 
50 
     | 
    
         | 
| 
      
 51 
     | 
    
         
            +
                def validate_editor_input!(initial_data, block)
         
     | 
| 
      
 52 
     | 
    
         
            +
                  return unless initial_data && block
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  raise ArgumentError, 'Cannot pass initial data and block at the same time.'
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                def resolve_editor_preset(preset_name)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  fetch_editor_preset(preset_name || :default)
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                def build_editor_config(preset, config, extra_config, initial_data)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  editor_config = config || preset.config
         
     | 
| 
      
 63 
     | 
    
         
            +
                  editor_config = editor_config.deep_merge(extra_config)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  editor_config[:initialData] = initial_data if initial_data
         
     | 
| 
      
 65 
     | 
    
         
            +
                  editor_config
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       55 
68 
     | 
    
         
             
                def validate_and_get_editor_context!
         
     | 
| 
       56 
69 
     | 
    
         
             
                  unless defined?(@__ckeditor_context)
         
     | 
| 
       57 
70 
     | 
    
         
             
                    raise EditorContextError,
         
     |