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(controller_context, type, config, watchdog: true, editable_height: nil, language: nil) ⇒ Props

Returns a new instance of Props.

Raises:

  • (ArgumentError)


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

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

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

Class Method Details

.valid_editor_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#to_attributesObject



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

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