Class: Effective::FormInputs::ArticleEditor

Inherits:
Effective::FormInput show all
Defined in:
app/models/effective/form_inputs/article_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

Class Method Summary collapse

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

Class Method Details

.defaultsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/models/effective/form_inputs/article_editor.rb', line 6

def self.defaults
  {
    active_storage: nil,
    css: ['/assets/article_editor/arx-frame.min.css'],
    custom: {
      css: ['/assets/effective_bootstrap_article_editor.css']
    },
    classes: {
      body: 'article-editor-body',
      table: 'table'
    },
    filelink: nil,
    grid: {
      classname: 'row',
      columns: 12,
      gutter: '1px',
      offset: {
        left: '15px',
        right: '15px',
      },
      patterns: {
        '6|6': 'col-sm-6|col-sm-6',
        '4|4|4': 'col-sm-4|col-sm-4|col-sm-4',
        '3|3|3|3': 'col-sm-3|col-sm-3|col-sm-3|col-sm-3',
        '2|2|2|2|2|2': 'col-sm-2|col-sm-2|col-sm-2|col-sm-2|col-sm-2|col-sm-2',
        '3|6|3': 'col-sm-3|col-sm-6|col-sm-3',
        '2|8|2': 'col-sm-2|col-sm-8|col-sm-2',
        '5|7': 'col-sm-5|col-sm-7',
        '7|5': 'col-sm-7|col-sm-5',
        '4|8': 'col-sm-4|col-sm-8',
        '8|4': 'col-sm-8|col-sm-4',
        '3|9': 'col-sm-3|col-sm-9',
        '9|3': 'col-sm-9|col-sm-3',
        '2|10': 'col-sm-2|col-sm-10',
        '10|2': 'col-sm-10|col-sm-2',
        '12': 'col-sm-12'
      }
    },
    plugins: ['blockcode', 'cellcolor', 'imageposition', 'imageresize', 'inlineformat', 'listitem', 'removeformat', 'reorder', 'style', 'filelink'],
    quote: {
      template: '<blockquote><p></p></blockquote>'
    },
    styles: {
      table: {
        'bordered': { title: 'Bordered', classname: 'table-bordered' },
        'responsive': { title: 'Responsive', classname: 'table-responsive' },
        'small': { title: 'Small', classname: 'table-sm' },
        'striped': { title: 'Striped', classname: 'table-striped' },
      }
    },
    cellcolors: {
      'primary': { title: 'Primary', classname: 'table-primary' },
      'secondary': { title: 'Secondary', classname: 'table-secondary' },
      'active': { title: 'Active', classname: 'table-active' },
      'success': { title: 'Success', classname: 'table-success' },
      'danger': { title: 'Danger', classname: 'table-danger' },
      'warning': { title: 'Warning', classname: 'table-warning' },
      'info': { title: 'Info', classname: 'table-info' },
      'light': { title: 'Light', classname: 'table-light' },
      'dark': { title: 'Dark', classname: 'table-dark' }
    }
  }
end

Instance Method Details

#active_storageObject



90
91
92
93
94
95
96
97
98
# File 'app/models/effective/form_inputs/article_editor.rb', line 90

def active_storage
  return @active_storage unless @active_storage.nil?

  @active_storage = if options.key?(:active_storage)
    options.delete(:active_storage)
  else
    defined?(ActiveStorage).present?
  end
end

#build_input(&block) ⇒ Object



70
71
72
# File 'app/models/effective/form_inputs/article_editor.rb', line 70

def build_input(&block)
  @builder.super_text_area(name, options[:input])
end

#custom_cssObject



82
83
84
85
86
87
88
# File 'app/models/effective/form_inputs/article_editor.rb', line 82

def custom_css
  [
    (@template.asset_pack_path('application.css') if @template.respond_to?(:asset_pack_path)),
    (@template.asset_path('application.css') if @template.respond_to?(:asset_path)),
    ('/assets/effective_bootstrap_article_editor.css')
  ]
end

#input_html_optionsObject



74
75
76
# File 'app/models/effective/form_inputs/article_editor.rb', line 74

def input_html_options
  { class: 'effective_article_editor form-control', id: unique_id, autocomplete: 'off' }
end

#input_js_optionsObject



78
79
80
# File 'app/models/effective/form_inputs/article_editor.rb', line 78

def input_js_options
  self.class.defaults.merge(active_storage: active_storage, custom: { css: custom_css })
end