Class: CKEditor5::Rails::Editor::Props

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

Constant Summary collapse

EDITOR_TYPES =
{
  classic: 'ClassicEditor',
  inline: 'InlineEditor',
  balloon: 'BalloonEditor',
  decoupled: 'DecoupledEditor',
  multiroot: 'MultiRootEditor'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, config, bundle: nil, watchdog: true, editable_height: nil) ⇒ Props

Returns a new instance of Props.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ckeditor5/rails/editor/props.rb', line 16

def initialize(
  type, config,
  bundle: nil,
  watchdog: true,
  editable_height: nil
)
  raise ArgumentError, "Invalid editor type: #{type}" unless Props.valid_editor_type?(type)

  @bundle = bundle
  @watchdog = watchdog
  @type = type
  @config = config
  @editable_height = EditableHeightNormalizer.new(type).normalize(editable_height)
end

Class Method Details

.valid_editor_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ckeditor5/rails/editor/props.rb', line 38

def self.valid_editor_type?(type)
  EDITOR_TYPES.key?(type)
end

Instance Method Details

#to_attributesObject



31
32
33
34
35
36
# File 'lib/ckeditor5/rails/editor/props.rb', line 31

def to_attributes
  {
    type: EDITOR_TYPES[@type],
    **serialized_attributes
  }
end