Class: Effective::FormInputs::Editor
- Inherits:
-
Effective::FormInput
- Object
- Effective::FormInput
- Effective::FormInputs::Editor
- Defined in:
- app/models/effective/form_inputs/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
Instance Method Summary collapse
- #build_input(&block) ⇒ Object
-
#content_mode ⇒ Object
default false.
- #input_html_options ⇒ Object
- #input_js_options ⇒ Object
-
#toolbar ⇒ Object
Commented out ‘Full’ toolbar options because currently we don’t want headers / source / code options.
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 9 10 |
# File 'app/models/effective/form_inputs/editor.rb', line 5 def build_input(&block) content = value.presence || (capture(&block) if block_given?) @builder.super_text_area(name, ([:input] || {}).merge(autocomplete: 'off')) + content_tag(:div, '', class: 'ql-effective', id: unique_id + '_editor') end |
#content_mode ⇒ Object
default false
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/models/effective/form_inputs/editor.rb', line 38 def content_mode # default false return @content_mode unless @content_mode.nil? @content_mode = ( if .delete(:delta) :delta elsif .delete(:html) :html elsif .delete(:code) :code else :delta end ) end |
#input_html_options ⇒ Object
12 13 14 |
# File 'app/models/effective/form_inputs/editor.rb', line 12 def { class: 'effective_editor form-control', id: unique_id } end |
#input_js_options ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/models/effective/form_inputs/editor.rb', line 16 def { modules: { toolbar: , syntax: (content_mode == :code) }, theme: 'snow', placeholder: "Add #{name.to_s.pluralize}...", content_mode: content_mode } end |
#toolbar ⇒ Object
Commented out ‘Full’ toolbar options because currently we don’t want headers / source / code options
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/effective/form_inputs/editor.rb', line 26 def return false if content_mode == :code [ # [{'header': [1, 2, 3, 4, false] }], ['bold', 'italic', 'underline'], ['link', 'image', 'video'], # also 'code-block' [{'list': 'ordered'}, {'list': 'bullet'}, 'blockquote'], [{'align': [] }, 'clean'] ] end |