Class: CodeEditorInput
- Inherits:
-
SimpleForm::Inputs::TextInput
- Object
- SimpleForm::Inputs::TextInput
- CodeEditorInput
- Defined in:
- app/inputs/code_editor_input.rb
Overview
Uses the CodeMirror editor
Instance Method Summary collapse
Instance Method Details
#input(wrapper_options) ⇒ Object
4 5 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 |
# File 'app/inputs/code_editor_input.rb', line 4 def input() [:mode] = ([:mode] || 'markdown').downcase editor_mode = case [:mode] when 'textile' :htmlmixed # no textile mode available when 'markdown' :markdown when 'html' :htmlmixed else :markdown end ['codemirror-editor'] = "" ['data-mode'] = editor_mode ['data-theme'] = [:theme] || :default editor_id = "codemirror_container_#{rand(1000)}" out = '' out << "<div class='cm_toolbar'>" out << " <a class='cm_cmd_bold_#{[:mode]}' href='javascript:void(0);' data-editor='\##{editor_id}'><i class='icon-bold'></i></a>" out << " <a class='cm_cmd_italic_#{[:mode]}' href='javascript:void(0);' data-editor='\##{editor_id}'><i class='icon-italic'></i></a>" out << " <a class='cm_cmd_link_#{[:mode]}' href='javascript:void(0);' data-editor='\##{editor_id}'><i class='icon-link5'></i></a>" out << " <a class='cm_cmd_fullscreen' title='Fullscreen (Esc exits)' href='javascript:void(0);' data-editor='\##{editor_id}'><i class='icon-expand'></i></a>" out << "</div>" out << "<div id='#{editor_id}'>" (out << @builder.text_area(attribute_name, )).html_safe out << "</div>" end |