wysihtml5x-rails 0.4.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10e5ed1fe2bb83162d69e930bdfbd0b11c95775d
4
+ data.tar.gz: 427ead699edfbd243b6fc541abe08899f7a67911
5
+ SHA512:
6
+ metadata.gz: 160acaadaff4c6f83952d4425532f52caf6e6afd29405952285a43c0b3340daa18dfb0ca3f53e4c294899093aa59f8c77470a56ced622900767d463abebbcb08
7
+ data.tar.gz: 1edc09f5c22231f13b9b2a49553f25865a42f667e21fc8560396430740e37fdf50755c54cf9882a53cc96eb977ff1fa32031c3eefed8449f077cc38e3b9a9d8f
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wysihtml5x-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tanel Jakobsoo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # wysihtml5x for Rails
2
+
3
+ [Edicy/wysihtml5x](http://edicy.github.io/wysihtml5/) is an extended and less strict approach on [xing/wysihtml5](http://xing.github.io/wysihtml5/) open source rich text editor based on HTML5 technology.
4
+
5
+ This gem adds wysihtml5x to Rails assets pipeline.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'wysihtml5x-rails'
13
+ ```
14
+
15
+ Or you can install from latest build:
16
+
17
+ ```ruby
18
+ gem 'wysihtml5x-rails', :git => 'https://github.com/Edicy/wysihtml5x-rails.git'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```sh
24
+ bundle
25
+ ```
26
+
27
+ Or install it yourself as:
28
+
29
+ ```sh
30
+ $ gem install wysihtml5x-rails
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Require it in your JS manifest's file `application.js`:
36
+
37
+ ```js
38
+ //= require wysihtml5x
39
+ ```
40
+
41
+ or if you need wysihtml with built-in toolbar:
42
+
43
+ ```js
44
+ //= require wysihtml5x-toolbar
45
+ ```
46
+
47
+ Additionally include predefined `simple`, `advanced` or `advanced_unwrap` parsing rules in your `application.js`:
48
+
49
+ ```js
50
+ //= require parser_rules/advanced_unwrap
51
+ ```
52
+
53
+ Additionally include predefined `wysihtml5x` stiles in your `application.css.scss` file:
54
+
55
+ ```scss
56
+ *= require wysihtml5x
57
+ ```
58
+
59
+ The simple initialise:
60
+
61
+ ```html
62
+ <script>
63
+ var editor = new wysihtml5.Editor("wysihtml5-textarea", { // id of textarea element
64
+ toolbar: "wysihtml5-toolbar", // id of toolbar element
65
+ stylesheets: "<%= stylesheet_path('wysihtml5x') %>", // optional, css to style the editor's content
66
+ parserRules: wysihtml5ParserRules, // defined in parser rules set
67
+ //showToolbarAfterInit: false
68
+ });
69
+ </script>
70
+ ```
71
+
72
+ ## Contributing
73
+
74
+ 1. Fork it
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Wysihtml5x
2
+ module Rails
3
+ VERSION = "0.4.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "wysihtml5x/rails/version"
2
+
3
+ module Wysihtml5x
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Wysihtml5x::Rails
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,553 @@
1
+ /**
2
+ * Full HTML5 compatibility rule set
3
+ * These rules define which tags and CSS classes are supported and which tags should be specially treated.
4
+ *
5
+ * Examples based on this rule set:
6
+ *
7
+ * <a href="http://foobar.com">foo</a>
8
+ * ... becomes ...
9
+ * <a href="http://foobar.com" target="_blank" rel="nofollow">foo</a>
10
+ *
11
+ * <img align="left" src="http://foobar.com/image.png">
12
+ * ... becomes ...
13
+ * <img class="wysiwyg-float-left" src="http://foobar.com/image.png" alt="">
14
+ *
15
+ * <div>foo<script>alert(document.cookie)</script></div>
16
+ * ... becomes ...
17
+ * <div>foo</div>
18
+ *
19
+ * <marquee>foo</marquee>
20
+ * ... becomes ...
21
+ * <span>foo</span>
22
+ *
23
+ * foo <br clear="both"> bar
24
+ * ... becomes ...
25
+ * foo <br class="wysiwyg-clear-both"> bar
26
+ *
27
+ * <div>hello <iframe src="http://google.com"></iframe></div>
28
+ * ... becomes ...
29
+ * <div>hello </div>
30
+ *
31
+ * <center>hello</center>
32
+ * ... becomes ...
33
+ * <div class="wysiwyg-text-align-center">hello</div>
34
+ */
35
+ var wysihtml5ParserRules = {
36
+ /**
37
+ * CSS Class white-list
38
+ * Following CSS classes won't be removed when parsed by the wysihtml5 HTML parser
39
+ */
40
+ "classes": {
41
+ "wysiwyg-clear-both": 1,
42
+ "wysiwyg-clear-left": 1,
43
+ "wysiwyg-clear-right": 1,
44
+ "wysiwyg-color-aqua": 1,
45
+ "wysiwyg-color-black": 1,
46
+ "wysiwyg-color-blue": 1,
47
+ "wysiwyg-color-fuchsia": 1,
48
+ "wysiwyg-color-gray": 1,
49
+ "wysiwyg-color-green": 1,
50
+ "wysiwyg-color-lime": 1,
51
+ "wysiwyg-color-maroon": 1,
52
+ "wysiwyg-color-navy": 1,
53
+ "wysiwyg-color-olive": 1,
54
+ "wysiwyg-color-purple": 1,
55
+ "wysiwyg-color-red": 1,
56
+ "wysiwyg-color-silver": 1,
57
+ "wysiwyg-color-teal": 1,
58
+ "wysiwyg-color-white": 1,
59
+ "wysiwyg-color-yellow": 1,
60
+ "wysiwyg-float-left": 1,
61
+ "wysiwyg-float-right": 1,
62
+ "wysiwyg-font-size-large": 1,
63
+ "wysiwyg-font-size-larger": 1,
64
+ "wysiwyg-font-size-medium": 1,
65
+ "wysiwyg-font-size-small": 1,
66
+ "wysiwyg-font-size-smaller": 1,
67
+ "wysiwyg-font-size-x-large": 1,
68
+ "wysiwyg-font-size-x-small": 1,
69
+ "wysiwyg-font-size-xx-large": 1,
70
+ "wysiwyg-font-size-xx-small": 1,
71
+ "wysiwyg-text-align-center": 1,
72
+ "wysiwyg-text-align-justify": 1,
73
+ "wysiwyg-text-align-left": 1,
74
+ "wysiwyg-text-align-right": 1
75
+ },
76
+ /**
77
+ * Tag list
78
+ *
79
+ * The following options are available:
80
+ *
81
+ * - add_class: converts and deletes the given HTML4 attribute (align, clear, ...) via the given method to a css class
82
+ * The following methods are implemented in wysihtml5.dom.parse:
83
+ * - align_text: converts align attribute values (right/left/center/justify) to their corresponding css class "wysiwyg-text-align-*")
84
+ * <p align="center">foo</p> ... becomes ... <p> class="wysiwyg-text-align-center">foo</p>
85
+ * - clear_br: converts clear attribute values left/right/all/both to their corresponding css class "wysiwyg-clear-*"
86
+ * <br clear="all"> ... becomes ... <br class="wysiwyg-clear-both">
87
+ * - align_img: converts align attribute values (right/left) on <img> to their corresponding css class "wysiwyg-float-*"
88
+ *
89
+ * - remove: removes the element and its content
90
+ *
91
+ * - rename_tag: renames the element to the given tag
92
+ *
93
+ * - set_class: adds the given class to the element (note: make sure that the class is in the "classes" white list above)
94
+ *
95
+ * - set_attributes: sets/overrides the given attributes
96
+ *
97
+ * - check_attributes: checks the given HTML attribute via the given method
98
+ * - url: allows only valid urls (starting with http:// or https://)
99
+ * - src: allows something like "/foobar.jpg", "http://google.com", ...
100
+ * - href: allows something like "mailto:bert@foo.com", "http://google.com", "/foobar.jpg"
101
+ * - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
102
+ * - numbers: ensures that the attribute only contains numeric characters
103
+ */
104
+ "tags": {
105
+ "tr": {
106
+ "add_class": {
107
+ "align": "align_text"
108
+ }
109
+ },
110
+ "strike": {
111
+ "remove": 1
112
+ },
113
+ "form": {
114
+ "rename_tag": "div"
115
+ },
116
+ "rt": {
117
+ "rename_tag": "span"
118
+ },
119
+ "code": {},
120
+ "acronym": {
121
+ "rename_tag": "span"
122
+ },
123
+ "br": {
124
+ "add_class": {
125
+ "clear": "clear_br"
126
+ }
127
+ },
128
+ "details": {
129
+ "rename_tag": "div"
130
+ },
131
+ "h4": {
132
+ "add_class": {
133
+ "align": "align_text"
134
+ }
135
+ },
136
+ "em": {},
137
+ "title": {
138
+ "remove": 1
139
+ },
140
+ "multicol": {
141
+ "rename_tag": "div"
142
+ },
143
+ "figure": {
144
+ "rename_tag": "div"
145
+ },
146
+ "xmp": {
147
+ "rename_tag": "span"
148
+ },
149
+ "small": {
150
+ "rename_tag": "span",
151
+ "set_class": "wysiwyg-font-size-smaller"
152
+ },
153
+ "area": {
154
+ "remove": 1
155
+ },
156
+ "time": {
157
+ "rename_tag": "span"
158
+ },
159
+ "dir": {
160
+ "rename_tag": "ul"
161
+ },
162
+ "bdi": {
163
+ "rename_tag": "span"
164
+ },
165
+ "command": {
166
+ "remove": 1
167
+ },
168
+ "ul": {},
169
+ "progress": {
170
+ "rename_tag": "span"
171
+ },
172
+ "dfn": {
173
+ "rename_tag": "span"
174
+ },
175
+ "iframe": {
176
+ "remove": 1
177
+ },
178
+ "figcaption": {
179
+ "rename_tag": "div"
180
+ },
181
+ "a": {
182
+ "check_attributes": {
183
+ "href": "url" // if you compiled master manually then change this from 'url' to 'href'
184
+ },
185
+ "set_attributes": {
186
+ "rel": "nofollow",
187
+ "target": "_blank"
188
+ }
189
+ },
190
+ "img": {
191
+ "check_attributes": {
192
+ "width": "numbers",
193
+ "alt": "alt",
194
+ "src": "url", // if you compiled master manually then change this from 'url' to 'src'
195
+ "height": "numbers"
196
+ },
197
+ "add_class": {
198
+ "align": "align_img"
199
+ }
200
+ },
201
+ "rb": {
202
+ "rename_tag": "span"
203
+ },
204
+ "footer": {
205
+ "rename_tag": "div"
206
+ },
207
+ "noframes": {
208
+ "remove": 1
209
+ },
210
+ "abbr": {
211
+ "rename_tag": "span"
212
+ },
213
+ "u": {},
214
+ "bgsound": {
215
+ "remove": 1
216
+ },
217
+ "sup": {
218
+ "rename_tag": "span"
219
+ },
220
+ "address": {
221
+ "rename_tag": "div"
222
+ },
223
+ "basefont": {
224
+ "remove": 1
225
+ },
226
+ "nav": {
227
+ "rename_tag": "div"
228
+ },
229
+ "h1": {
230
+ "add_class": {
231
+ "align": "align_text"
232
+ }
233
+ },
234
+ "head": {
235
+ "remove": 1
236
+ },
237
+ "tbody": {
238
+ "add_class": {
239
+ "align": "align_text"
240
+ }
241
+ },
242
+ "dd": {
243
+ "rename_tag": "div"
244
+ },
245
+ "s": {
246
+ "rename_tag": "span"
247
+ },
248
+ "li": {},
249
+ "td": {
250
+ "check_attributes": {
251
+ "rowspan": "numbers",
252
+ "colspan": "numbers"
253
+ },
254
+ "add_class": {
255
+ "align": "align_text"
256
+ }
257
+ },
258
+ "object": {
259
+ "remove": 1
260
+ },
261
+ "div": {
262
+ "add_class": {
263
+ "align": "align_text"
264
+ }
265
+ },
266
+ "option": {
267
+ "rename_tag": "span"
268
+ },
269
+ "select": {
270
+ "rename_tag": "span"
271
+ },
272
+ "i": {},
273
+ "track": {
274
+ "remove": 1
275
+ },
276
+ "wbr": {
277
+ "remove": 1
278
+ },
279
+ "fieldset": {
280
+ "rename_tag": "div"
281
+ },
282
+ "big": {
283
+ "rename_tag": "span",
284
+ "set_class": "wysiwyg-font-size-larger"
285
+ },
286
+ "button": {
287
+ "rename_tag": "span"
288
+ },
289
+ "noscript": {
290
+ "remove": 1
291
+ },
292
+ "svg": {
293
+ "remove": 1
294
+ },
295
+ "input": {
296
+ "remove": 1
297
+ },
298
+ "table": {},
299
+ "keygen": {
300
+ "remove": 1
301
+ },
302
+ "h5": {
303
+ "add_class": {
304
+ "align": "align_text"
305
+ }
306
+ },
307
+ "meta": {
308
+ "remove": 1
309
+ },
310
+ "map": {
311
+ "rename_tag": "div"
312
+ },
313
+ "isindex": {
314
+ "remove": 1
315
+ },
316
+ "mark": {
317
+ "rename_tag": "span"
318
+ },
319
+ "caption": {
320
+ "add_class": {
321
+ "align": "align_text"
322
+ }
323
+ },
324
+ "tfoot": {
325
+ "add_class": {
326
+ "align": "align_text"
327
+ }
328
+ },
329
+ "base": {
330
+ "remove": 1
331
+ },
332
+ "video": {
333
+ "remove": 1
334
+ },
335
+ "strong": {},
336
+ "canvas": {
337
+ "remove": 1
338
+ },
339
+ "output": {
340
+ "rename_tag": "span"
341
+ },
342
+ "marquee": {
343
+ "rename_tag": "span"
344
+ },
345
+ "b": {},
346
+ "q": {
347
+ "check_attributes": {
348
+ "cite": "url"
349
+ }
350
+ },
351
+ "applet": {
352
+ "remove": 1
353
+ },
354
+ "span": {},
355
+ "rp": {
356
+ "rename_tag": "span"
357
+ },
358
+ "spacer": {
359
+ "remove": 1
360
+ },
361
+ "source": {
362
+ "remove": 1
363
+ },
364
+ "aside": {
365
+ "rename_tag": "div"
366
+ },
367
+ "frame": {
368
+ "remove": 1
369
+ },
370
+ "section": {
371
+ "rename_tag": "div"
372
+ },
373
+ "body": {
374
+ "rename_tag": "div"
375
+ },
376
+ "ol": {},
377
+ "nobr": {
378
+ "rename_tag": "span"
379
+ },
380
+ "html": {
381
+ "rename_tag": "div"
382
+ },
383
+ "summary": {
384
+ "rename_tag": "span"
385
+ },
386
+ "var": {
387
+ "rename_tag": "span"
388
+ },
389
+ "del": {
390
+ "remove": 1
391
+ },
392
+ "blockquote": {
393
+ "check_attributes": {
394
+ "cite": "url"
395
+ }
396
+ },
397
+ "style": {
398
+ "remove": 1
399
+ },
400
+ "device": {
401
+ "remove": 1
402
+ },
403
+ "meter": {
404
+ "rename_tag": "span"
405
+ },
406
+ "h3": {
407
+ "add_class": {
408
+ "align": "align_text"
409
+ }
410
+ },
411
+ "textarea": {
412
+ "rename_tag": "span"
413
+ },
414
+ "embed": {
415
+ "remove": 1
416
+ },
417
+ "hgroup": {
418
+ "rename_tag": "div"
419
+ },
420
+ "font": {
421
+ "rename_tag": "span",
422
+ "add_class": {
423
+ "size": "size_font"
424
+ }
425
+ },
426
+ "tt": {
427
+ "rename_tag": "span"
428
+ },
429
+ "noembed": {
430
+ "remove": 1
431
+ },
432
+ "thead": {
433
+ "add_class": {
434
+ "align": "align_text"
435
+ }
436
+ },
437
+ "blink": {
438
+ "rename_tag": "span"
439
+ },
440
+ "plaintext": {
441
+ "rename_tag": "span"
442
+ },
443
+ "xml": {
444
+ "remove": 1
445
+ },
446
+ "h6": {
447
+ "add_class": {
448
+ "align": "align_text"
449
+ }
450
+ },
451
+ "param": {
452
+ "remove": 1
453
+ },
454
+ "th": {
455
+ "check_attributes": {
456
+ "rowspan": "numbers",
457
+ "colspan": "numbers"
458
+ },
459
+ "add_class": {
460
+ "align": "align_text"
461
+ }
462
+ },
463
+ "legend": {
464
+ "rename_tag": "span"
465
+ },
466
+ "hr": {},
467
+ "label": {
468
+ "rename_tag": "span"
469
+ },
470
+ "dl": {
471
+ "rename_tag": "div"
472
+ },
473
+ "kbd": {
474
+ "rename_tag": "span"
475
+ },
476
+ "listing": {
477
+ "rename_tag": "div"
478
+ },
479
+ "dt": {
480
+ "rename_tag": "span"
481
+ },
482
+ "nextid": {
483
+ "remove": 1
484
+ },
485
+ "pre": {},
486
+ "center": {
487
+ "rename_tag": "div",
488
+ "set_class": "wysiwyg-text-align-center"
489
+ },
490
+ "audio": {
491
+ "remove": 1
492
+ },
493
+ "datalist": {
494
+ "rename_tag": "span"
495
+ },
496
+ "samp": {
497
+ "rename_tag": "span"
498
+ },
499
+ "col": {
500
+ "remove": 1
501
+ },
502
+ "article": {
503
+ "rename_tag": "div"
504
+ },
505
+ "cite": {},
506
+ "link": {
507
+ "remove": 1
508
+ },
509
+ "script": {
510
+ "remove": 1
511
+ },
512
+ "bdo": {
513
+ "rename_tag": "span"
514
+ },
515
+ "menu": {
516
+ "rename_tag": "ul"
517
+ },
518
+ "colgroup": {
519
+ "remove": 1
520
+ },
521
+ "ruby": {
522
+ "rename_tag": "span"
523
+ },
524
+ "h2": {
525
+ "add_class": {
526
+ "align": "align_text"
527
+ }
528
+ },
529
+ "ins": {
530
+ "rename_tag": "span"
531
+ },
532
+ "p": {
533
+ "add_class": {
534
+ "align": "align_text"
535
+ }
536
+ },
537
+ "sub": {
538
+ "rename_tag": "span"
539
+ },
540
+ "comment": {
541
+ "remove": 1
542
+ },
543
+ "frameset": {
544
+ "remove": 1
545
+ },
546
+ "optgroup": {
547
+ "rename_tag": "span"
548
+ },
549
+ "header": {
550
+ "rename_tag": "div"
551
+ }
552
+ }
553
+ };