Class: MarkdownInput
- Inherits:
-
FormtasticBootstrap::Inputs::TextInput
- Object
- FormtasticBootstrap::Inputs::TextInput
- MarkdownInput
- Defined in:
- app/inputs/markdown_input.rb
Instance Method Summary collapse
- #editor_id ⇒ Object
- #id ⇒ Object
- #input_html_options ⇒ Object
- #markdown_hint ⇒ Object
- #textarea_id ⇒ Object
- #to_html ⇒ Object
Instance Method Details
#editor_id ⇒ Object
20 21 22 |
# File 'app/inputs/markdown_input.rb', line 20 def editor_id "#{dom_id}_editor-#{id}" end |
#id ⇒ Object
12 13 14 |
# File 'app/inputs/markdown_input.rb', line 12 def id builder.object.id || 'new' end |
#input_html_options ⇒ Object
24 25 26 27 28 |
# File 'app/inputs/markdown_input.rb', line 24 def { class: "col-md-12", }.merge(super).merge(id: textarea_id) end |
#markdown_hint ⇒ Object
30 31 32 |
# File 'app/inputs/markdown_input.rb', line 30 def markdown_hint "Use markdown syntax for formatting. You can also use HTML directly. <a href=\"#{builder.template.guide_path('markdown')}\" data-toggle=\"remote-load\" data-target=\"#content-guide\">See our markdown syntax reference</a>".html_safe end |
#textarea_id ⇒ Object
16 17 18 |
# File 'app/inputs/markdown_input.rb', line 16 def textarea_id "#{dom_id}-#{id}" end |
#to_html ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/inputs/markdown_input.rb', line 3 def to_html self.[:hint] = markdown_hint if self.[:hint].blank? bootstrap_wrapping do builder.text_area(method, ) + builder.template.content_tag(:div, nil, id: editor_id, class: 'ace_editor', data: { id: id, type: :markdown, name: dom_id, init: "$('##{editor_id}').smithy_editor()".html_safe, assets_url: builder.template.selector_modal_assets_path, pages_url: builder.template.selector_modal_pages_path }) + builder.template.content_tag(:div, nil, id: 'content-guide') end end |