Mati365 / ckeditor5-rails

🚀 CKEditor 5 Ruby gem - seamless integration with Rails through web components and helper methods. 💎 Supports both GPL and commercial licenses with flexible CDN options and translations. 🎨 Easy configuration with presets, extensive plugin system, and modern async loading.
https://ckeditor.com/
GNU General Public License v2.0
21 stars 1 forks source link

Are you planning to add a file manager to the CKEditor 5 gem? #11

Closed dil-prmishra closed 6 days ago

dil-prmishra commented 6 days ago

✨ Feature Request

Hi @Mati365, Are you planning to add a file manager to the CKEditor 5 gem, similar to the one in the CKEditor 4 gem?

🎯 Feature Description

Screenshot 2024-11-26 at 2 55 00 PM
Mati365 commented 6 days ago

I don't. Afair, it's ootb feature of ckbox

dil-bparihar commented 6 days ago

@Mati365 This is not ckbox feature. It is a custom file manager in ckeditor gem for ckeditor 4.

https://github.com/galetahub/ckeditor

Above is the gem which we were using for ckeditor 4. Can we implement like this with this gem and reuse the piece of code if possible. Or please suggests better way. it would be great to have this feature in this gem.

dil-bparihar commented 6 days ago

@Mati365 Also can you please help how do we set dynamic language for ckeditor using I18n.locale.

Mati365 commented 6 days ago

@dil-bparihar

Above is the gem which we were using for ckeditor 4. Can we implement like this with this gem and reuse the piece of code if possible. Or please suggests better way. it would be great to have this feature in this gem.

I'd suggest creating a new plugin somewhere on the window that mounts grid handled by React / Vue or any other modern framework. It should receive editor as the property and do some of the operations on images. Reusing code from CKEditor 4 is impossible due to fundamental changes in architecture of the editor.

Also can you please help how do we set dynamic language for ckeditor using I18n.locale.

You can load translations using this helper: https://github.com/Mati365/ckeditor5-rails?tab=readme-ov-file#translationslanguages-method

and assign them to the editor using this one: https://github.com/Mati365/ckeditor5-rails?tab=readme-ov-file#languageui-content-method

If you want to decode I18n.locale depending on the request, then you should define preset in your controller: https://github.com/Mati365/ckeditor5-rails/tree/main?tab=readme-ov-file#ckeditor5_presetname--nil-block-method

dil-bparihar commented 6 days ago

@Mati365 Can't we set it using javascript method. I have editor in multiple places not ones.

document.getElementById('editor').addEventListener('editor-ready', () => {
  console.log('Editor is ready');
});

or

Can we set preset: language: I18n.locale ( Like this ) in the view

If possible we can create a language method and call it for setting language in editor used in form or with ckeditor5_editor

for eg: = f.ckeditor5 :welcome,value: f.object.customized_welcome, editable_height: 400, id: 'ckeditor-5', language: 'en'

Mati365 commented 6 days ago

@dil-bparihar

Can't we set it using javascript method. I have editor in multiple places not ones.

You can, you can also import plugin that bootstrap your gallery in each place you use.

If possible we can create a language method and call it for setting language in editor used in form or with ckeditor5_editor

It should be possible, as ckeditor5 helper should accept extra configuration using extra_config property. Something like that:

# It overrides translations from default preset, and loads only `:pl`
= ckeditor5_assets translations: [:pl]

= f.ckeditor5 :welcome, 
    value: f.object.customized_welcome, 
    editable_height: 400, 
    id: 'ckeditor-5', 
    extra_config: { language: { ui: :pl } }

extra_config accepts raw format used by CKEditor 5

dil-bparihar commented 6 days ago

@Mati365 Can we also language keyword to set language in below method:

def ckeditor5_assets(preset: :default, **kwargs)
      merge_with_editor_preset(preset, **kwargs) => {
        cdn:,
        version:,
        translations:,
        ckbox:,
        license_key:,
        premium:,
        **kwargs
      }

      bundle = build_base_cdn_bundle(cdn, version, translations)
      bundle << build_premium_cdn_bundle(cdn, version, translations) if premium
      bundle << build_ckbox_cdn_bundle(ckbox) if ckbox

      @__ckeditor_context = {
        license_key: license_key,
        bundle: bundle,
        preset: preset
      }

      Assets::AssetsBundleHtmlSerializer.new(bundle).to_html
    end
Mati365 commented 6 days ago

@dil-bparihar / @dil-prmishra I added support for language kwarg argument in ckeditor5_assets and ckeditor5_editor. If language is specified in ckeditor5_assets then there is no need to pass translations, as proper translation will be fetched automatically.

Please upgrade to 1.17.1.

Examples:

language in ckeditor5_editor

= ckeditor5_assets translations: [:pl, :es, :en] # Preload few translations packs

...

= f.ckeditor5 :welcome, language: :pl 
= f.ckeditor5 :welcome_2, language: :es

language in ckeditor5_assets

# Both editors will use `es` language. Translation pack will be loaded automatically.
= ckeditor5_assets language: :es 
...

= f.ckeditor5 :welcome
= f.ckeditor5 :welcome_2

I updated docs. Please check demos: https://github.com/Mati365/ckeditor5-rails/tree/main/sandbox/app/views/demos

Mati365 commented 6 days ago

@dil-prmishra / @dil-bparihar I pushed minor improvement. If no language is specified, then I18n.locale is used to determine the language of the editor. Please take a look at 1.17.2. Thanks!

dil-bparihar commented 6 days ago

@Mati365 Thanks for this As it would help a lot.