Sha256: d912c2393921eeec2a0c913e0cf1aed5c80c05e577b743b393d7ec69c8d452b7

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'formtastic-bootstrap/inputs/text_input'
class MarkdownInput < FormtasticBootstrap::Inputs::TextInput
  def to_html
    self.options[:hint] = markdown_hint if self.options[:hint].blank?
    bootstrap_wrapping do
      builder.text_area(method, form_control_input_html_options) +
      builder.template.content_tag(:div, nil, id: editor_id, class: 'ace_editor', data: { id: id, type: :markdown, name: dom_id, 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

  def id
    builder.object.id || 'new'
  end

  def textarea_id
    "#{dom_id}-#{id}"
  end

  def editor_id
    "#{dom_id}_editor-#{id}"
  end

  def input_html_options
    {
      class: "col-md-12",
    }.merge(super).merge(id: textarea_id)
  end

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smithycms-0.6.5 app/inputs/markdown_input.rb
smithycms-0.6.4 app/inputs/markdown_input.rb