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::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES

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



5
6
7
8
# File 'app/models/effective/form_inputs/ck_editor.rb', line 5

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

#contentsCssObject



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

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



38
39
40
# File 'app/models/effective/form_inputs/ck_editor.rb', line 38

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

#input_html_optionsObject



10
11
12
# File 'app/models/effective/form_inputs/ck_editor.rb', line 10

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

#input_js_optionsObject



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

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



34
35
36
# File 'app/models/effective/form_inputs/ck_editor.rb', line 34

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

#widthObject



42
43
44
# File 'app/models/effective/form_inputs/ck_editor.rb', line 42

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