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
23 24 25 |
# File 'app/inputs/markdown_input.rb', line 23 def editor_id "#{dom_id}_editor-#{id}" end |
#id ⇒ Object
15 16 17 |
# File 'app/inputs/markdown_input.rb', line 15 def id builder.object.id || 'new' end |
#input_html_options ⇒ Object
27 28 29 30 31 |
# File 'app/inputs/markdown_input.rb', line 27 def { class: "col-md-12", }.merge(super).merge(id: textarea_id) end |
#markdown_hint ⇒ Object
33 34 35 |
# File 'app/inputs/markdown_input.rb', line 33 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
19 20 21 |
# File 'app/inputs/markdown_input.rb', line 19 def textarea_id "#{dom_id}-#{id}" end |
#to_html ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'app/inputs/markdown_input.rb', line 3 def to_html self.[:hint] = markdown_hint if self.[:hint].blank? bootstrap_wrapping do text_area = builder.text_area(method, ) editor = builder.template.content_tag :div do 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 text_area + editor end end |