simple_form_markdown_editor 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adb8663c7956eda6d7f6da3d9588949076d92d1b
4
- data.tar.gz: 7cbcfc6052e035b1f179586138f37c6ac63b92c5
3
+ metadata.gz: 592ee458505ff3dbaf28900e7c629e63d9695ec6
4
+ data.tar.gz: 41bdfbdcbb2efd2c69652d2430d868ffec19ff03
5
5
  SHA512:
6
- metadata.gz: 3f0f670afbac9f84ece2c9bfd33506560910987769951da4adca79bdcb61d5c33f52fea60e8b458df71851b073070b2fdeced2266f2ec60c72c7790c75658f7c
7
- data.tar.gz: b791edd4f0d396e8bbbc8bbbddf4adaa4c48cbfa463b25316fe3bbc1f0adfb8e7bf45a1b06a69e360c544e1300b9ccf770fa9dbe56e047c4d4a6fbe6c14ec792
6
+ metadata.gz: 9a449ac9392d44f7a34cd1ac5347bf2f25af67e9d5914b2fdeb4fd7d24b860d804239832bd3ed36064ccc2aa6ed111042d930c5c573561dc8f432fa23edb12e5
7
+ data.tar.gz: a4a14137fc0ebd75c7e85d2b49a2ca2751696721a68ed96283dd738182b1592f8ec83b5d41848c2ffffe77eb40232ffd73f6d4fe27d44738276149cf2e755c41
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_form_markdown_editor (0.0.7)
4
+ simple_form_markdown_editor (0.0.8)
5
5
  rails (>= 4.2)
6
6
  redcarpet
7
7
  responders
@@ -13,12 +13,23 @@ module SimpleFormMarkdownEditor
13
13
 
14
14
  # overwrite this in your own controller
15
15
  def text_preview
16
- Renderer.call(preview_params)
16
+ Renderer.call(text, { render_class: render_class, extensions: extensions })
17
17
  end
18
18
 
19
- def preview_params
20
- return unless params[:text].present?
19
+ def text
21
20
  params.require(:text)
22
21
  end
22
+
23
+ def options
24
+ params.fetch(:options, {})
25
+ end
26
+
27
+ def render_class
28
+ options.fetch(:render_class, nil).to_s.safe_constantize
29
+ end
30
+
31
+ def extensions
32
+ options.fetch(:extensions, {})
33
+ end
23
34
  end
24
35
  end
@@ -36,6 +36,7 @@ do ($ = jQuery, window, document) ->
36
36
  data:
37
37
  _method: 'PUT'
38
38
  text: @get_textarea().val() || ''
39
+ options: @get_textarea_options()
39
40
  success: (html) =>
40
41
  @get_preview_div().html(html) or "<p>#{@get_nothing_to_preview_text()}</p>"
41
42
  )
@@ -51,6 +52,7 @@ do ($ = jQuery, window, document) ->
51
52
  get_preview_tab: -> @get_tab_lis().filter('.preview')
52
53
  get_edit_tab: -> @get_tab_lis().filter('.edit')
53
54
  get_nothing_to_preview_text: -> @get_preview_div().data('nothing-to-preview-text') or "Nothing to preview."
55
+ get_textarea_options: -> @$element.data('options')
54
56
 
55
57
  # ---------------------------------------------------------------------
56
58
 
@@ -19,7 +19,12 @@ module SimpleFormMarkdownEditor
19
19
  # =====================================================================
20
20
 
21
21
  def input(wrapper_options)
22
- template.content_tag :div, merge_wrapper_options(input_html_options, wrapper_options) do
22
+ attrs = merge_wrapper_options(input_html_options, wrapper_options)
23
+ attrs[:data] ||= {}
24
+ attrs[:data][:preview_path] = preview_path
25
+ attrs[:data][:options] = { render_class: render_class.to_s, render_options: render_options, extensions: extensions }
26
+
27
+ template.content_tag :div, attrs do
23
28
  template.concat header
24
29
  template.concat help
25
30
  template.concat editor
@@ -29,10 +34,8 @@ module SimpleFormMarkdownEditor
29
34
 
30
35
  private # =============================================================
31
36
 
32
- def input_html_options
33
- super[:data] ||= {}
34
- super[:data][:preview_path] = options.fetch(:route, MarkdownEditorInput.configuration.route)
35
- super
37
+ def preview_path
38
+ options.fetch(:route, MarkdownEditorInput.configuration.route)
36
39
  end
37
40
 
38
41
  def render_class
@@ -73,9 +76,11 @@ module SimpleFormMarkdownEditor
73
76
 
74
77
  def tab(name)
75
78
  template.content_tag :li, class: ['tab', name.to_s.underscore.downcase], data: { command: name.to_s } do
76
- template.content_tag :span,
77
- I18n.t(name.to_sym, scope: 'simple_form_markdown_editor.tabs'),
78
- class: name.to_s.underscore.downcase
79
+ template.content_tag(
80
+ :span,
81
+ I18n.t(name.to_sym, scope: 'simple_form_markdown_editor.tabs'),
82
+ class: name.to_s.underscore.downcase
83
+ )
79
84
  end
80
85
  end
81
86
 
@@ -104,7 +109,16 @@ module SimpleFormMarkdownEditor
104
109
  def button(b)
105
110
  return if b == 'help' && !help_enabled?
106
111
  template.content_tag :li, class: ['button', b], data: { toggle: b } do
107
- template.content_tag :button, I18n.t(b.to_sym, scope: 'simple_form_markdown_editor.buttons'), class: b, value: b, role: '', state: '', name: '', type: 'button'
112
+ template.content_tag(
113
+ :button,
114
+ I18n.t(b.to_sym, scope: 'simple_form_markdown_editor.buttons'),
115
+ class: b,
116
+ name: '',
117
+ role: '',
118
+ state: '',
119
+ type: 'button',
120
+ value: b
121
+ )
108
122
  end
109
123
  end
110
124
 
@@ -121,7 +135,12 @@ module SimpleFormMarkdownEditor
121
135
  end
122
136
 
123
137
  def preview
124
- template.content_tag :div, I18n.t(:loading, scope: 'simple_form_markdown_editor'), class: %w(preview), data: { :'nothing-to-preview-text' => I18n.t(:nothing_to_preview, scope: 'simple_form_markdown_editor') }
138
+ template.content_tag(
139
+ :div,
140
+ I18n.t(:loading, scope: 'simple_form_markdown_editor'),
141
+ class: %w(preview),
142
+ data: { nothing_to_preview_text: I18n.t(:nothing_to_preview, scope: 'simple_form_markdown_editor') }
143
+ )
125
144
  end
126
145
 
127
146
  # ---------------------------------------------------------------------
@@ -6,20 +6,20 @@ module SimpleFormMarkdownEditor
6
6
  new(*args).call
7
7
  end
8
8
 
9
- def options
10
- @options ||= {}
9
+ def initialize(str, options = {})
10
+ super(str, options)
11
11
  end
12
12
 
13
13
  def render_class
14
- @render_class ||= options.fetch(:render_class, MarkdownEditorInput.configuration.render_class)
14
+ options.fetch(:render_class, MarkdownEditorInput.configuration.render_class)
15
15
  end
16
16
 
17
17
  def render_options
18
- @render_options ||= options.fetch(:render_options, MarkdownEditorInput.configuration.render_options)
18
+ options.fetch(:render_options, MarkdownEditorInput.configuration.render_options)
19
19
  end
20
20
 
21
21
  def extensions
22
- @extensions ||= options.fetch(:extensions, MarkdownEditorInput.configuration.extensions)
22
+ options.fetch(:extensions, MarkdownEditorInput.configuration.extensions)
23
23
  end
24
24
 
25
25
  def call
@@ -27,12 +27,10 @@ module SimpleFormMarkdownEditor
27
27
  markdown_renderer.render(str).html_safe
28
28
  end
29
29
 
30
- private # =============================================================
30
+ private
31
31
 
32
32
  def markdown_renderer
33
- Redcarpet::Markdown.new(
34
- render_class.new(render_options), extensions
35
- )
33
+ Redcarpet::Markdown.new(render_class.new(render_options), extensions)
36
34
  end
37
35
  end
38
36
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormMarkdownEditor
2
- VERSION = '0.0.7'.freeze
2
+ VERSION = '0.0.8'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- simple_form_markdown_editor (0.0.7)
4
+ simple_form_markdown_editor (0.0.8)
5
5
  rails (>= 4.2)
6
6
  redcarpet
7
7
  responders
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_markdown_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna