Class: CKEditor5::Rails::Editor::PropsInlinePlugin

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

Instance Attribute Summary collapse

Attributes inherited from PropsBasePlugin

#assets_bundle, #name

Instance Method Summary collapse

Methods inherited from PropsBasePlugin

normalize, #preload_assets_bundle

Constructor Details

#initialize(name, code) ⇒ PropsInlinePlugin

Returns a new instance of PropsInlinePlugin.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
# File 'lib/ckeditor5/rails/editor/props_inline_plugin.rb', line 9

def initialize(name, code)
  super(name)

  raise ArgumentError, 'Code must be a String' unless code.is_a?(String)

  @code = "(async () => { #{code.html_safe} })()"
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



7
8
9
# File 'lib/ckeditor5/rails/editor/props_inline_plugin.rb', line 7

def code
  @code
end

Instance Method Details

#compress!Object



17
18
19
# File 'lib/ckeditor5/rails/editor/props_inline_plugin.rb', line 17

def compress!
  @code = Terser.new(compress: false, mangle: true).compile(@code)
end

#to_hObject



21
22
23
24
25
# File 'lib/ckeditor5/rails/editor/props_inline_plugin.rb', line 21

def to_h
  {
    window_name: name
  }
end