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

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of PropsPlugin.



7
8
9
10
11
12
13
14
# File 'lib/ckeditor5/rails/editor/props_plugin.rb', line 7

def initialize(name, premium: false, **js_import_meta)
  @name = name
  @js_import_meta = if js_import_meta.empty?
                      { import_name: premium ? 'ckeditor5-premium-features' : 'ckeditor5' }
                    else
                      js_import_meta
                    end
end

Class Method Details

.normalize(plugin) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ckeditor5/rails/editor/props_plugin.rb', line 16

def self.normalize(plugin)
  case plugin
  when String, Symbol then new(plugin)
  when PropsPlugin, PropsInlinePlugin then plugin
  else raise ArgumentError, "Invalid plugin: #{plugin}"
  end
end

Instance Method Details

#to_hObject



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

def to_h
  meta = ::CKEditor5::Rails::Assets::JSImportMeta.new(
    import_as: js_import_meta[:window_name] ? nil : name,
    **js_import_meta
  ).to_h

  meta.merge!({ type: :external })
  meta
end