pagedown-bootstrap-rails 2.1.2 → 2.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 +79 -47
- data/lib/pagedown_bootstrap/rails/version.rb +1 -1
- data/vendor/assets/javascripts/markdown.editor.js.erb +5 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32aa899d2beb4ae6ea2782eca91c1d707dc02836
|
4
|
+
data.tar.gz: 9625daceed7838e72d31d07c1c72832236a70a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18cbcdc00bd93f72ca4264cdc0de1d28d59ae191e37c51513770b89bfc08014da1b192486e649e706995cb11e31060fb4e0bc2ec026a07081f25b1b6135a1ac9
|
7
|
+
data.tar.gz: 4d9644eb6fff0a6fe4fe1ff76e87c3c7144710007e74d785f05580a50341a21a608e510fb74a775fa5610cb5f43d783640aa1b2388e9e187060df9806fefb4cc
|
data/Readme.md
CHANGED
@@ -6,71 +6,103 @@ A Ruby gem version of [https://github.com/tchapi/pagedown-bootstrap](https://git
|
|
6
6
|
|
7
7
|
Add to your `Gemfile`:
|
8
8
|
|
9
|
-
|
9
|
+
``` ruby
|
10
|
+
gem 'pagedown-bootstrap-rails'
|
11
|
+
```
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
You will also need Bootstrap and FontAwesome for PageDown Bootstrap Rails to work.
|
13
|
+
You’ll also need Bootstrap 3 (Sass version) and Font Awesome.
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
Require the CSS with Sprockets:
|
18
18
|
|
19
|
-
|
19
|
+
``` css
|
20
|
+
/*= require pagedown_bootstrap */
|
21
|
+
```
|
20
22
|
|
21
|
-
Or with
|
23
|
+
Or with an SCSS import:
|
22
24
|
|
23
|
-
|
25
|
+
``` scss
|
26
|
+
@import "pagedown_bootstrap";
|
27
|
+
```
|
24
28
|
|
25
29
|
Sprockets require the JS too:
|
26
30
|
|
27
|
-
|
31
|
+
``` javascript
|
32
|
+
//= require pagedown_bootstrap
|
33
|
+
```
|
28
34
|
|
29
35
|
Or individually as you please:
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
37
|
+
``` javascript
|
38
|
+
//= require markdown.converter
|
39
|
+
//= require markdown.editor
|
40
|
+
//= require markdown.sanitizer
|
41
|
+
//= require markdown.extra
|
42
|
+
```
|
43
|
+
|
44
|
+
You will need to initialize PageDown in your form, so PageDown Bootstrap Rails comes with `pagedown_init` for you to optionally include:
|
45
|
+
|
46
|
+
``` coffee
|
47
|
+
$ ->
|
48
|
+
$('textarea.wmd-input').each (i, input) ->
|
49
|
+
attr = $(input).attr('id').split('wmd-input')[1]
|
50
|
+
converter = new Markdown.Converter()
|
51
|
+
Markdown.Extra.init(converter)
|
52
|
+
help =
|
53
|
+
handler: () ->
|
54
|
+
window.open('http://daringfireball.net/projects/markdown/syntax')
|
55
|
+
return false
|
56
|
+
title: "<%= I18n.t('components.markdown_editor.help', default: 'Markdown Editing Help') %>"
|
57
|
+
editor = new Markdown.Editor(converter, attr, help)
|
58
|
+
editor.run()
|
59
|
+
```
|
60
|
+
|
61
|
+
Just require it after `pagedown_bootstrap`:
|
62
|
+
|
63
|
+
``` javascript
|
64
|
+
//= require pagedown_bootstrap
|
65
|
+
//= require pagedown_init
|
66
|
+
```
|
67
|
+
|
68
|
+
This obviously requires CoffeeScript and jQuery, so if you’re not using these then feel free to write your own initializer. Additionally, if you’re using Turbolinks then I suggest either using [jQuery Turbolinks](https://github.com/kossnocorp/jquery.turbolinks) or writing
|
69
|
+
your own initializer that does not rely on `jQuery.ready()` like the one above.
|
70
|
+
|
71
|
+
## SimpleForm
|
72
|
+
|
73
|
+
Here’s a [SimpleForm](https://github.com/plataformatec/simple_form) input that creates the correct HTML for the initializer above.
|
74
|
+
|
75
|
+
``` ruby
|
76
|
+
class PagedownInput < SimpleForm::Inputs::TextInput
|
77
|
+
def input
|
78
|
+
out = "<div id=\"wmd-button-bar-#{attribute_name}\"></div>#{wmd_input}"
|
79
|
+
|
80
|
+
if input_html_options[:preview]
|
81
|
+
out << "<div id=\"wmd-preview-#{attribute_name}\" class=\"wmd-preview\"></div>"
|
68
82
|
end
|
69
83
|
|
84
|
+
out.html_safe
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def wmd_input
|
90
|
+
@builder.text_area(
|
91
|
+
attribute_name,
|
92
|
+
input_html_options.merge(
|
93
|
+
class: 'wmd-input form-control', id: "wmd-input-#{attribute_name}"
|
94
|
+
)
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
70
100
|
Which you use in your form like so:
|
71
101
|
|
72
|
-
|
102
|
+
``` ruby
|
103
|
+
= f.input :description, as: :pagedown, input_html: { preview: true, rows: 10 }
|
104
|
+
```
|
73
105
|
|
74
106
|
This is how it looks:
|
75
107
|
|
76
|
-

|
@@ -1378,11 +1378,11 @@
|
|
1378
1378
|
return group
|
1379
1379
|
};
|
1380
1380
|
|
1381
|
-
group1 = makeGroup(1);
|
1381
|
+
var group1 = makeGroup(1);
|
1382
1382
|
buttons.bold = makeButton("wmd-bold-button", "<%= I18n.t('components.markdown_editor.bold.button_title', default: 'Bold (Ctrl+B)') %>", "fa fa-bold", bindCommand("doBold"), group1);
|
1383
1383
|
buttons.italic = makeButton("wmd-italic-button", "<%= I18n.t('components.markdown_editor.italic.button_title', default: 'Italic (Ctrl+I)') %>", "fa fa-italic", bindCommand("doItalic"), group1);
|
1384
1384
|
|
1385
|
-
group2 = makeGroup(2);
|
1385
|
+
var group2 = makeGroup(2);
|
1386
1386
|
buttons.link = makeButton("wmd-link-button", "<%= I18n.t('components.markdown_editor.insert_link.button_title', default: 'Link (Ctrl+L)') %>", "fa fa-link", bindCommand(function (chunk, postProcessing) {
|
1387
1387
|
return this.doLinkOrImage(chunk, postProcessing, false);
|
1388
1388
|
}), group2);
|
@@ -1392,7 +1392,7 @@
|
|
1392
1392
|
buttons.quote = makeButton("wmd-quote-button", "<%= I18n.t('components.markdown_editor.blockquoute.button_title', default: 'Blockquote (Ctrl+Q)') %>", "fa fa-quote-left", bindCommand("doBlockquote"), group2);
|
1393
1393
|
buttons.code = makeButton("wmd-code-button", "<%= I18n.t('components.markdown_editor.code_sample.button_title', default: 'Code Sample (Ctrl+K)') %>", "fa fa-code", bindCommand("doCode"), group2);
|
1394
1394
|
|
1395
|
-
group3 = makeGroup(3);
|
1395
|
+
var group3 = makeGroup(3);
|
1396
1396
|
buttons.ulist = makeButton("wmd-ulist-button", "<%= I18n.t('components.markdown_editor.bulleted_list.button_title', default: 'Bulleted List (Ctrl+U)') %>", "fa fa-list-ul", bindCommand(function (chunk, postProcessing) {
|
1397
1397
|
this.doList(chunk, postProcessing, false);
|
1398
1398
|
}), group3);
|
@@ -1401,7 +1401,7 @@
|
|
1401
1401
|
}), group3);
|
1402
1402
|
buttons.heading = makeButton("wmd-heading-button", "<%= I18n.t('components.markdown_editor.heading.button_title', default: 'Heading (Ctrl+H)') %>", "fa fa-font", bindCommand("doHeading"), group3);
|
1403
1403
|
|
1404
|
-
group4 = makeGroup(4);
|
1404
|
+
var group4 = makeGroup(4);
|
1405
1405
|
buttons.undo = makeButton("wmd-undo-button", "<%= I18n.t('components.markdown_editor.undo.button_title', default: 'Undo (Ctrl+Z)') %>", "fa fa-undo", null, group4);
|
1406
1406
|
buttons.undo.execute = function (manager) { if (manager) manager.undo(); };
|
1407
1407
|
|
@@ -1413,7 +1413,7 @@
|
|
1413
1413
|
buttons.redo.execute = function (manager) { if (manager) manager.redo(); };
|
1414
1414
|
|
1415
1415
|
if (helpOptions) {
|
1416
|
-
group5 = makeGroup(5);
|
1416
|
+
var group5 = makeGroup(5);
|
1417
1417
|
group5.className = group5.className + " pull-right";
|
1418
1418
|
var helpButton = document.createElement("button");
|
1419
1419
|
var helpButtonImage = document.createElement("i");
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagedown-bootstrap-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugh Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.5.1
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: This gem makes PageDown Bootstrap available in the Rails asset pipeline.
|