Class: CKEditor5::Rails::Editor::PropsPlugin

Inherits:
PropsBasePlugin show all
Defined in:
lib/ckeditor5/rails/editor/props_plugin.rb

Instance Attribute Summary

Attributes inherited from PropsBasePlugin

#assets_bundle, #name

Instance Method Summary collapse

Methods inherited from PropsBasePlugin

normalize, #preload_assets_bundle

Constructor Details

#initialize(name, premium: false, **js_import_meta_attrs) ⇒ PropsPlugin

Returns a new instance of PropsPlugin.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ckeditor5/rails/editor/props_plugin.rb', line 7

def initialize(name, premium: false, **js_import_meta_attrs)
  super(name)

  js_import_meta_attrs[:import_name] ||= if premium
                                           'ckeditor5-premium-features'
                                         else
                                           'ckeditor5'
                                         end

  @js_import_meta = ::CKEditor5::Rails::Assets::JSImportMeta.new(
    import_as: js_import_meta_attrs[:window_name] ? nil : name,
    **js_import_meta_attrs
  )
end

Instance Method Details

#to_hObject

Compress a little bit default plugins to make output smaller



23
24
25
26
27
28
29
# File 'lib/ckeditor5/rails/editor/props_plugin.rb', line 23

def to_h
  if @js_import_meta.import_name == 'ckeditor5'
    @js_import_meta.import_as.to_s
  else
    @js_import_meta.to_h
  end
end