Class: Effective::FormInputs::Editor
Constant Summary
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
#name, #options
Instance Method Summary
collapse
#feedback_options, #hint_options, #initialize, #input_group_options, #label_options, #to_html, #wrapper_options
Instance Method Details
#active_storage ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'app/models/effective/form_inputs/editor.rb', line 67
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
|
7
8
9
10
11
12
|
# File 'app/models/effective/form_inputs/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')) +
content_tag(:div, '', class: 'ql-effective', id: unique_id + '_editor')
end
|
#content_mode ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/models/effective/form_inputs/editor.rb', line 77
def content_mode return @content_mode unless @content_mode.nil?
@content_mode = (
if options.delete(:delta)
:delta
elsif options.delete(:html)
:html
elsif options.delete(:code)
:code
else
:delta
end
)
end
|
#imageDropAndPaste ⇒ Object
47
48
49
|
# File 'app/models/effective/form_inputs/editor.rb', line 47
def imageDropAndPaste
active_storage && !(content_mode == :code)
end
|
#imageResize ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/models/effective/form_inputs/editor.rb', line 51
def imageResize
{
displaySize: true,
displayStyles: {
backgroundColor: 'black',
border: 'none',
color: 'white'
},
modules: [ 'Resize', 'DisplaySize' ]
}
end
|
14
15
16
|
# File 'app/models/effective/form_inputs/editor.rb', line 14
def input_html_options
{ class: 'effective_editor form-control', id: unique_id }
end
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/models/effective/form_inputs/editor.rb', line 18
def input_js_options
{
modules: {
toolbar: toolbar,
imageResize: imageResize,
imageDropAndPaste: imageDropAndPaste,
magicUrl: magicUrl,
syntax: (content_mode == :code)
},
theme: 'snow',
placeholder: "Add #{name.to_s.pluralize}...",
content_mode: content_mode,
active_storage: active_storage
}
end
|
#magicUrl ⇒ Object
63
64
65
|
# File 'app/models/effective/form_inputs/editor.rb', line 63
def magicUrl
true
end
|
Commented out ‘Full’ toolbar options because currently we don’t want headers / source / code options
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/models/effective/form_inputs/editor.rb', line 35
def toolbar
return false if content_mode == :code
[
['bold', 'italic', 'underline'],
['link', 'image', 'video'], [{'list': 'ordered'}, {'list': 'bullet'}, 'blockquote'],
[{'align': [] }, 'clean']
]
end
|