8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/trix/form.rb', line 8
def trix_editor_tag(name, value = nil, options = {})
options.symbolize_keys!
css_class = Array.wrap(options[:class]).join(' ')
attributes = { class: "formatted_content trix-content #{css_class}".squish }
attributes[:autofocus] = true if options[:autofocus]
attributes[:input] = options[:input] || "trix_input_#{TrixEditorHelper.id += 1}"
valid_html_options = [:placeholder, :spellcheck, :toolbar, :tabindex]
attributes.merge!(options.slice(*valid_html_options))
editor_tag = content_tag('trix-editor', '', attributes)
input_tag = hidden_field_tag(name, value, id: attributes[:input])
input_tag + editor_tag
end
|