bootstrap-wysihtml5-rails 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -5
- data/lib/bootstrap-wysihtml5-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-wysihtml5.js +290 -304
- metadata +4 -4
data/README.md
CHANGED
@@ -32,17 +32,15 @@ and run bundle install.
|
|
32
32
|
|
33
33
|
This gem doesn't include Bootstrap. You can get Bootstrap here: https://github.com/anjlab/bootstrap-rails
|
34
34
|
|
35
|
-
##
|
35
|
+
## Configuration
|
36
36
|
|
37
|
-
|
37
|
+
app/assets/stylesheets/application.css
|
38
38
|
|
39
39
|
``` css
|
40
40
|
*= require bootstrap-wysihtml5
|
41
41
|
```
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
Bootstrap-wysihtml5 depends on jquery and bootstrap-button.
|
43
|
+
Bootstrap-wysihtml5 depends on jquery and bootstrap-button. Make sure to require it in the manifest file.
|
46
44
|
|
47
45
|
``` javascript
|
48
46
|
//= require jquery # Not included
|
@@ -60,6 +58,8 @@ or
|
|
60
58
|
//= require bootstrap-wysihtml5-all
|
61
59
|
```
|
62
60
|
|
61
|
+
You may need to restart your rails server.
|
62
|
+
|
63
63
|
## Using bootstrap-wysihtml5-rails
|
64
64
|
|
65
65
|
Just call wysihtml5() with any selector.
|
@@ -1,308 +1,294 @@
|
|
1
1
|
!function($, wysi) {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var templates = {
|
5
|
+
"font-styles": "<li class='dropdown'>" +
|
6
|
+
"<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
|
7
|
+
"<i class='icon-font'></i> <span class='current-font'>Normal text</span> <b class='caret'></b>" +
|
8
|
+
"</a>" +
|
9
|
+
"<ul class='dropdown-menu'>" +
|
10
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>Normal text</a></li>" +
|
11
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>Heading 1</a></li>" +
|
12
|
+
"<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>Heading 2</a></li>" +
|
13
|
+
"</ul>" +
|
14
|
+
"</li>",
|
15
|
+
"emphasis": "<li>" +
|
16
|
+
"<div class='btn-group'>" +
|
17
|
+
"<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>Bold</a>" +
|
18
|
+
"<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>Italic</a>" +
|
19
|
+
"<a class='btn' data-wysihtml5-command='underline' title='CTRL+U'>Underline</a>" +
|
20
|
+
"</div>" +
|
21
|
+
"</li>",
|
22
|
+
"lists": "<li>" +
|
23
|
+
"<div class='btn-group'>" +
|
24
|
+
"<a class='btn' data-wysihtml5-command='insertUnorderedList' title='Unordered List'><i class='icon-list'></i></a>" +
|
25
|
+
"<a class='btn' data-wysihtml5-command='insertOrderedList' title='Ordered List'><i class='icon-th-list'></i></a>" +
|
26
|
+
"<a class='btn' data-wysihtml5-command='Outdent' title='Outdent'><i class='icon-indent-right'></i></a>" +
|
27
|
+
"<a class='btn' data-wysihtml5-command='Indent' title='Indent'><i class='icon-indent-left'></i></a>" +
|
28
|
+
"</div>" +
|
29
|
+
"</li>",
|
30
|
+
"link": "<li>" +
|
31
|
+
"<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
|
32
|
+
"<div class='modal-header'>" +
|
33
|
+
"<a class='close' data-dismiss='modal'>×</a>" +
|
34
|
+
"<h3>Insert Link</h3>" +
|
35
|
+
"</div>" +
|
36
|
+
"<div class='modal-body'>" +
|
37
|
+
"<input value='http://' class='bootstrap-wysihtml5-insert-link-url input-xlarge'>" +
|
38
|
+
"</div>" +
|
39
|
+
"<div class='modal-footer'>" +
|
40
|
+
"<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +
|
41
|
+
"<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert link</a>" +
|
42
|
+
"</div>" +
|
43
|
+
"</div>" +
|
44
|
+
"<a class='btn' data-wysihtml5-command='createLink' title='Link'><i class='icon-share'></i></a>" +
|
45
|
+
"</li>",
|
46
|
+
"image": "<li>" +
|
47
|
+
"<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
|
48
|
+
"<div class='modal-header'>" +
|
49
|
+
"<a class='close' data-dismiss='modal'>×</a>" +
|
50
|
+
"<h3>Insert Image</h3>" +
|
51
|
+
"</div>" +
|
52
|
+
"<div class='modal-body'>" +
|
53
|
+
"<input value='http://' class='bootstrap-wysihtml5-insert-image-url input-xlarge'>" +
|
54
|
+
"</div>" +
|
55
|
+
"<div class='modal-footer'>" +
|
56
|
+
"<a href='#' class='btn' data-dismiss='modal'>Cancel</a>" +
|
57
|
+
"<a href='#' class='btn btn-primary' data-dismiss='modal'>Insert image</a>" +
|
58
|
+
"</div>" +
|
59
|
+
"</div>" +
|
60
|
+
"<a class='btn' data-wysihtml5-command='insertImage' title='Insert image'><i class='icon-picture'></i></a>" +
|
61
|
+
"</li>",
|
62
|
+
|
63
|
+
"html":
|
64
|
+
"<li>" +
|
65
|
+
"<div class='btn-group'>" +
|
66
|
+
"<a class='btn' data-wysihtml5-action='change_view' title='Edit HTML'><i class='icon-pencil'></i></a>" +
|
67
|
+
"</div>" +
|
68
|
+
"</li>"
|
69
|
+
};
|
70
|
+
|
71
|
+
var defaultOptions = {
|
72
|
+
"font-styles": true,
|
73
|
+
"emphasis": true,
|
74
|
+
"lists": true,
|
75
|
+
"html": false,
|
76
|
+
"link": true,
|
77
|
+
"image": true,
|
78
|
+
events: {},
|
79
|
+
parserRules: {
|
80
|
+
tags: {
|
81
|
+
"b": {},
|
82
|
+
"i": {},
|
83
|
+
"br": {},
|
84
|
+
"ol": {},
|
85
|
+
"ul": {},
|
86
|
+
"li": {},
|
87
|
+
"h1": {},
|
88
|
+
"h2": {},
|
89
|
+
"u": 1,
|
90
|
+
"img": {
|
91
|
+
"check_attributes": {
|
92
|
+
"width": "numbers",
|
93
|
+
"alt": "alt",
|
94
|
+
"src": "url",
|
95
|
+
"height": "numbers"
|
96
|
+
}
|
97
|
+
},
|
98
|
+
"a": {
|
99
|
+
set_attributes: {
|
100
|
+
target: "_blank",
|
101
|
+
rel: "nofollow"
|
102
|
+
},
|
103
|
+
check_attributes: {
|
104
|
+
href: "url" // important to avoid XSS
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
},
|
109
|
+
stylesheets: []
|
110
|
+
};
|
111
|
+
|
112
|
+
var Wysihtml5 = function(el, options) {
|
113
|
+
this.el = el;
|
114
|
+
this.toolbar = this.createToolbar(el, options || defaultOptions);
|
115
|
+
this.editor = this.createEditor(options);
|
116
|
+
|
117
|
+
window.editor = this.editor;
|
118
|
+
|
119
|
+
$('iframe.wysihtml5-sandbox').each(function(i, el){
|
120
|
+
$(el.contentWindow).off('focus.wysihtml5').on({
|
121
|
+
'focus.wysihtml5' : function(){
|
122
|
+
$('li.dropdown').removeClass('open');
|
123
|
+
}
|
124
|
+
});
|
125
|
+
});
|
126
|
+
};
|
127
|
+
|
128
|
+
Wysihtml5.prototype = {
|
129
|
+
|
130
|
+
constructor: Wysihtml5,
|
131
|
+
|
132
|
+
createEditor: function(options) {
|
133
|
+
options = $.extend(defaultOptions, options || {});
|
134
|
+
options.toolbar = this.toolbar[0];
|
135
|
+
|
136
|
+
var editor = new wysi.Editor(this.el[0], options);
|
137
|
+
|
138
|
+
if(options && options.events) {
|
139
|
+
for(var eventName in options.events) {
|
140
|
+
editor.on(eventName, options.events[eventName]);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
return editor;
|
145
|
+
},
|
146
|
+
|
147
|
+
createToolbar: function(el, options) {
|
148
|
+
var self = this;
|
149
|
+
var toolbar = $("<ul/>", {
|
150
|
+
'class' : "wysihtml5-toolbar",
|
151
|
+
'style': "display:none"
|
152
|
+
});
|
153
|
+
|
154
|
+
for(var key in defaultOptions) {
|
155
|
+
var value = false;
|
156
|
+
|
157
|
+
if(options[key] !== undefined) {
|
158
|
+
if(options[key] === true) {
|
159
|
+
value = true;
|
160
|
+
}
|
161
|
+
} else {
|
162
|
+
value = defaultOptions[key];
|
163
|
+
}
|
164
|
+
|
165
|
+
if(value === true) {
|
166
|
+
toolbar.append(templates[key]);
|
167
|
+
|
168
|
+
if(key == "html") {
|
169
|
+
this.initHtml(toolbar);
|
170
|
+
}
|
171
|
+
|
172
|
+
if(key == "link") {
|
173
|
+
this.initInsertLink(toolbar);
|
174
|
+
}
|
175
|
+
|
176
|
+
if(key == "image") {
|
177
|
+
this.initInsertImage(toolbar);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
|
183
|
+
var el = $(e.srcElement);
|
184
|
+
self.toolbar.find('.current-font').text(el.html());
|
185
|
+
});
|
186
|
+
|
187
|
+
this.el.before(toolbar);
|
188
|
+
|
189
|
+
return toolbar;
|
190
|
+
},
|
191
|
+
|
192
|
+
initHtml: function(toolbar) {
|
193
|
+
var changeViewSelector = "a[data-wysihtml5-action='change_view']";
|
194
|
+
toolbar.find(changeViewSelector).click(function(e) {
|
195
|
+
toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
|
196
|
+
});
|
197
|
+
},
|
198
|
+
|
199
|
+
initInsertImage: function(toolbar) {
|
200
|
+
var self = this;
|
201
|
+
var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
|
202
|
+
var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
|
203
|
+
var insertButton = insertImageModal.find('a.btn-primary');
|
204
|
+
var initialValue = urlInput.val();
|
205
|
+
|
206
|
+
var insertImage = function() {
|
207
|
+
var url = urlInput.val();
|
208
|
+
urlInput.val(initialValue);
|
209
|
+
self.editor.composer.commands.exec("insertImage", url);
|
210
|
+
};
|
211
|
+
|
212
|
+
urlInput.keypress(function(e) {
|
213
|
+
if(e.which == 13) {
|
214
|
+
insertImage();
|
215
|
+
insertImageModal.modal('hide');
|
216
|
+
}
|
217
|
+
});
|
218
|
+
|
219
|
+
insertButton.click(insertImage);
|
220
|
+
|
221
|
+
insertImageModal.on('shown', function() {
|
222
|
+
urlInput.focus();
|
223
|
+
});
|
224
|
+
|
225
|
+
insertImageModal.on('hide', function() {
|
226
|
+
self.editor.currentView.element.focus();
|
227
|
+
});
|
228
|
+
|
229
|
+
toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
|
230
|
+
insertImageModal.modal('show');
|
231
|
+
insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
232
|
+
e.stopPropagation();
|
233
|
+
});
|
234
|
+
return false;
|
235
|
+
});
|
236
|
+
},
|
237
|
+
|
238
|
+
initInsertLink: function(toolbar) {
|
239
|
+
var self = this;
|
240
|
+
var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
|
241
|
+
var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
|
242
|
+
var insertButton = insertLinkModal.find('a.btn-primary');
|
243
|
+
var initialValue = urlInput.val();
|
244
|
+
|
245
|
+
var insertLink = function() {
|
246
|
+
var url = urlInput.val();
|
247
|
+
urlInput.val(initialValue);
|
248
|
+
self.editor.composer.commands.exec("createLink", {
|
249
|
+
href: url,
|
250
|
+
target: "_blank",
|
251
|
+
rel: "nofollow"
|
252
|
+
});
|
253
|
+
};
|
254
|
+
var pressedEnter = false;
|
255
|
+
|
256
|
+
urlInput.keypress(function(e) {
|
257
|
+
if(e.which == 13) {
|
258
|
+
insertLink();
|
259
|
+
insertLinkModal.modal('hide');
|
260
|
+
}
|
261
|
+
});
|
262
|
+
|
263
|
+
insertButton.click(insertLink);
|
264
|
+
|
265
|
+
insertLinkModal.on('shown', function() {
|
266
|
+
urlInput.focus();
|
267
|
+
});
|
268
|
+
|
269
|
+
insertLinkModal.on('hide', function() {
|
270
|
+
self.editor.currentView.element.focus();
|
271
|
+
});
|
272
|
+
|
273
|
+
toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
|
274
|
+
insertLinkModal.modal('show');
|
275
|
+
insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
|
276
|
+
e.stopPropagation();
|
271
277
|
});
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
insertLinkModal.on('hide', function() {
|
289
|
-
self.editor.currentView.element.focus();
|
290
|
-
});
|
291
|
-
|
292
|
-
toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
|
293
|
-
insertLinkModal.modal('show');
|
294
|
-
return false;
|
295
|
-
});
|
296
|
-
}
|
297
|
-
};
|
298
|
-
|
299
|
-
$.fn.wysihtml5 = function (options) {
|
300
|
-
return this.each(function () {
|
301
|
-
var $this = $(this);
|
302
|
-
$this.data('wysihtml5', new Wysihtml5($this, options));
|
303
|
-
})
|
304
|
-
};
|
305
|
-
|
306
|
-
$.fn.wysihtml5.Constructor = Wysihtml5;
|
278
|
+
return false;
|
279
|
+
});
|
280
|
+
|
281
|
+
|
282
|
+
}
|
283
|
+
};
|
284
|
+
|
285
|
+
$.fn.wysihtml5 = function (options) {
|
286
|
+
return this.each(function () {
|
287
|
+
var $this = $(this);
|
288
|
+
$this.data('wysihtml5', new Wysihtml5($this, options));
|
289
|
+
});
|
290
|
+
};
|
291
|
+
|
292
|
+
$.fn.wysihtml5.Constructor = Wysihtml5;
|
307
293
|
|
308
294
|
}(window.jQuery, window.wysihtml5);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-wysihtml5-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: 2897459941583643557
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
segments:
|
105
105
|
- 0
|
106
|
-
hash:
|
106
|
+
hash: 2897459941583643557
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
109
|
rubygems_version: 1.8.24
|