action_markdown 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/app/helpers/action_markdown/tag_helper.rb +37 -0
- data/app/models/action_markdown/markdown_text.rb +1 -0
- data/lib/action_markdown/engine.rb +6 -0
- data/lib/action_markdown/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8a81aff87626aae72f69e3be289da05a2b876e9245e31431715152690d48b0
|
4
|
+
data.tar.gz: db012c37bdca4c232184ecd68b727e1eb7294c4cfaa387450990e2bb62e958ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 696d0b60182b7baa446ecfed938304de4673fdb406db11e21248b2cdc118951a46dcbc6f516f9d7637d59f93ceb2d97f2b0e7e165ad07374ab45b59873d69937
|
7
|
+
data.tar.gz: 9953248c9fcd4f28047b06404a619925ac752828b00981d01cded14b75ac09b4840c314035704f0d31e60bc3006729d809676354a812347410cb6af0eed94368
|
data/README.md
CHANGED
@@ -63,6 +63,17 @@ In the view above, the Markdown content will automatically be converted to the f
|
|
63
63
|
<p>This is a paragraph.</p>
|
64
64
|
```
|
65
65
|
|
66
|
+
**Note**: To use a Markdown fields in forms, we should use the `markdown_field` helper like in the following example:
|
67
|
+
|
68
|
+
```erb
|
69
|
+
<%= form_with model: article do |f| %>
|
70
|
+
<%= f.label :content %>
|
71
|
+
<%= f.markdown_field :content %>
|
72
|
+
|
73
|
+
<%= f.submit "Save" %>
|
74
|
+
<% end %>
|
75
|
+
```
|
76
|
+
|
66
77
|
## License
|
67
78
|
|
68
79
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "action_view/helpers/tags/placeholderable"
|
2
|
+
|
3
|
+
module ActionMarkdown
|
4
|
+
module TagHelper
|
5
|
+
def markdown_field_tag(name, value = nil, options = {})
|
6
|
+
options = options.symbolize_keys
|
7
|
+
|
8
|
+
content_tag("textarea", value, options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ActionView::Helpers
|
14
|
+
class Tags::ActionMarkdown < Tags::Base
|
15
|
+
include Tags::Placeholderable
|
16
|
+
|
17
|
+
def render
|
18
|
+
options = @options.stringify_keys
|
19
|
+
options["value"] = options.fetch("value") { value&.to_markdown }
|
20
|
+
add_default_name_and_id(options)
|
21
|
+
|
22
|
+
@template_object.markdown_field_tag("textarea", options["value"], options.except("value"))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module FormHelper
|
27
|
+
def markdown_field(object_name, method, options = {})
|
28
|
+
Tags::ActionMarkdown.new(object_name, method, self, options).render
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class FormBuilder
|
33
|
+
def markdown_field(method, options = {})
|
34
|
+
@template.markdown_field(@object_name, method, objectify_options(options))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Ruban
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- MIT-LICENSE
|
63
63
|
- README.md
|
64
64
|
- app/assets/stylesheets/action_markdown/action_markdown.css
|
65
|
+
- app/helpers/action_markdown/tag_helper.rb
|
65
66
|
- app/models/action_markdown/application_record.rb
|
66
67
|
- app/models/action_markdown/markdown_text.rb
|
67
68
|
- app/views/action_markdown/contents/_content.html.erb
|