Class: Effective::FormInputs::CkEditor

Inherits:
Effective::FormInput show all
Defined in:
app/models/effective/form_inputs/ck_editor.rb

Constant Summary

Constants inherited from Effective::FormInput

Effective::FormInput::BLANK, Effective::FormInput::DEFAULT_FEEDBACK_OPTIONS, Effective::FormInput::DEFAULT_INPUT_GROUP_OPTIONS, Effective::FormInput::EMPTY_HASH, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES, Effective::FormInput::HORIZONTAL_LABEL_OPTIONS, Effective::FormInput::HORIZONTAL_WRAPPER_OPTIONS, Effective::FormInput::INLINE_LABEL_OPTIONS, Effective::FormInput::VERTICAL_WRAPPER_OPTIONS

Instance Attribute Summary

Attributes inherited from Effective::FormInput

#name, #options

Instance Method Summary collapse

Methods inherited from Effective::FormInput

#feedback_options, #hint_options, #initialize, #input_group_options, #label_options, #to_html, #wrapper_options

Constructor Details

This class inherits a constructor from Effective::FormInput

Instance Method Details

#build_input(&block) ⇒ Object



7
8
9
10
# File 'app/models/effective/form_inputs/ck_editor.rb', line 7

def build_input(&block)
  content = value.presence || (capture(&block) if block_given?)
  @builder.super_text_area(name, (options[:input] || {}).merge(autocomplete: 'off'))
end

#contentsCssObject



27
28
29
30
31
32
33
34
# File 'app/models/effective/form_inputs/ck_editor.rb', line 27

def contentsCss
  @contents_css ||= case (obj = options.delete(:contentsCss))
  when :bootstrap
    'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css'
  when false then nil
  else obj || asset_path('application.css')
  end
end

#heightObject



40
41
42
# File 'app/models/effective/form_inputs/ck_editor.rb', line 40

def height
  @height ||= options.delete(:height)
end

#input_html_optionsObject



12
13
14
# File 'app/models/effective/form_inputs/ck_editor.rb', line 12

def input_html_options
  { class: 'effective_ck_editor form-control', id: unique_id }
end

#input_js_optionsObject



16
17
18
19
20
21
22
23
24
25
# File 'app/models/effective/form_inputs/ck_editor.rb', line 16

def input_js_options
  {
    effective_ckeditor_js_path: asset_path('effective_ckeditor.js'),
    effective_ckeditor_css_path: asset_path('effective_ckeditor.css'),
    contentsCss: contentsCss,
    toolbar: toolbar,
    height: height,
    width: width
  }.compact
end

#toolbarObject



36
37
38
# File 'app/models/effective/form_inputs/ck_editor.rb', line 36

def toolbar
  @toolbar ||= (options.delete(:toolbar) || :full)
end

#widthObject



44
45
46
# File 'app/models/effective/form_inputs/ck_editor.rb', line 44

def width
  @width ||= options.delete(:width)
end