wysihtml-rails 0.5.0.beta2

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: 267eee793c065a025baf524f402e873eef5cae91
4
+ data.tar.gz: eb78cce4979a2cb6bcb168c101896d5e6601eaa1
5
+ SHA512:
6
+ metadata.gz: f9913fd89e5135d18bfcc84c6e01e24d2caf0958c423eac23aa1b862c4eaf4327ef4c7a1c476d5be0ae35780062deb5bcb9ecad2e8945c139079298c6b0842ea
7
+ data.tar.gz: d9ac39c4a3a64b6dd779e943472439239afd73789de27acb936d029063a515c90aa01a7aee252c05c1f181082b645e03bb9d406982b53c7047dc32380c84eb10
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 wysihtml-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
+ # wysihtml for Rails
2
+
3
+ [Voog/wysihtml](https://github.com/Voog/wysihtml) 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 wysihtml to Rails assets pipeline.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'wysihtml-rails'
13
+ ```
14
+
15
+ Or you can install from latest build:
16
+
17
+ ```ruby
18
+ gem 'wysihtml-rails', :git => 'https://github.com/Voog/wysihtml-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 wysihtml-rails
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Require it in your JS manifest's file `application.js`:
36
+
37
+ ```js
38
+ //= require wysihtml
39
+ ```
40
+
41
+ or if you need wysihtml with built-in toolbar:
42
+
43
+ ```js
44
+ //= require wysihtml-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 `wysihtml` stiles in your `application.css.scss` file:
54
+
55
+ ```scss
56
+ *= require wysihtml
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('wysihtml') %>", // 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,9 @@
1
+ require "wysihtml/rails/version"
2
+
3
+ module Wysihtml
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Wysihtml::Rails
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Wysihtml
2
+ module Rails
3
+ VERSION = "0.5.0.beta2"
4
+ end
5
+ end
@@ -0,0 +1,562 @@
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
+ * - add_style: converts and deletes the given HTML4 attribute (align) via the given method to a css style
90
+ * The following methods are implemented in wysihtml5.dom.parse:
91
+ * - align_text: converts align attribute values (right/left/center) to their corresponding css style)
92
+ * <p align="center">foo</p> ... becomes ... <p style="text-align:center">foo</p>
93
+ *
94
+ * - remove: removes the element and its content
95
+ *
96
+ * - unwrap removes element but leaves content
97
+ *
98
+ * - rename_tag: renames the element to the given tag
99
+ *
100
+ * - set_class: adds the given class to the element (note: make sure that the class is in the "classes" white list above)
101
+ *
102
+ * - set_attributes: sets/overrides the given attributes
103
+ *
104
+ * - check_attributes: checks the given HTML attribute via the given method
105
+ * - url: allows only valid urls (starting with http:// or https://)
106
+ * - src: allows something like "/foobar.jpg", "http://google.com", ...
107
+ * - href: allows something like "mailto:bert@foo.com", "http://google.com", "/foobar.jpg"
108
+ * - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
109
+ * - numbers: ensures that the attribute only contains numeric (integer) characters (no float values or units)
110
+ * - dimension: for with/height attributes where floating point numbrs and percentages are allowed
111
+ * - any: allows anything to pass
112
+ */
113
+ "tags": {
114
+ "tr": {
115
+ "add_class": {
116
+ "align": "align_text"
117
+ }
118
+ },
119
+ "strike": {
120
+ "remove": 1
121
+ },
122
+ "form": {
123
+ "rename_tag": "div"
124
+ },
125
+ "rt": {
126
+ "rename_tag": "span"
127
+ },
128
+ "code": {},
129
+ "acronym": {
130
+ "rename_tag": "span"
131
+ },
132
+ "br": {
133
+ "add_class": {
134
+ "clear": "clear_br"
135
+ }
136
+ },
137
+ "details": {
138
+ "rename_tag": "div"
139
+ },
140
+ "h4": {
141
+ "add_class": {
142
+ "align": "align_text"
143
+ }
144
+ },
145
+ "em": {},
146
+ "title": {
147
+ "remove": 1
148
+ },
149
+ "multicol": {
150
+ "rename_tag": "div"
151
+ },
152
+ "figure": {
153
+ "rename_tag": "div"
154
+ },
155
+ "xmp": {
156
+ "rename_tag": "span"
157
+ },
158
+ "small": {
159
+ "rename_tag": "span",
160
+ "set_class": "wysiwyg-font-size-smaller"
161
+ },
162
+ "area": {
163
+ "remove": 1
164
+ },
165
+ "time": {
166
+ "rename_tag": "span"
167
+ },
168
+ "dir": {
169
+ "rename_tag": "ul"
170
+ },
171
+ "bdi": {
172
+ "rename_tag": "span"
173
+ },
174
+ "command": {
175
+ "remove": 1
176
+ },
177
+ "ul": {},
178
+ "progress": {
179
+ "rename_tag": "span"
180
+ },
181
+ "dfn": {
182
+ "rename_tag": "span"
183
+ },
184
+ "iframe": {
185
+ "remove": 1
186
+ },
187
+ "figcaption": {
188
+ "rename_tag": "div"
189
+ },
190
+ "a": {
191
+ "check_attributes": {
192
+ "target": "any",
193
+ "href": "url" // if you compiled master manually then change this from 'url' to 'href'
194
+ },
195
+ "set_attributes": {
196
+ "rel": "nofollow"
197
+ }
198
+ },
199
+ "img": {
200
+ "check_attributes": {
201
+ "width": "dimension",
202
+ "alt": "alt",
203
+ "src": "url", // if you compiled master manually then change this from 'url' to 'src'
204
+ "height": "dimension"
205
+ },
206
+ "add_class": {
207
+ "align": "align_img"
208
+ }
209
+ },
210
+ "rb": {
211
+ "rename_tag": "span"
212
+ },
213
+ "footer": {
214
+ "rename_tag": "div"
215
+ },
216
+ "noframes": {
217
+ "remove": 1
218
+ },
219
+ "abbr": {
220
+ "rename_tag": "span"
221
+ },
222
+ "u": {},
223
+ "bgsound": {
224
+ "remove": 1
225
+ },
226
+ "sup": {
227
+ "rename_tag": "span"
228
+ },
229
+ "address": {
230
+ "rename_tag": "div"
231
+ },
232
+ "basefont": {
233
+ "remove": 1
234
+ },
235
+ "nav": {
236
+ "rename_tag": "div"
237
+ },
238
+ "h1": {
239
+ "add_class": {
240
+ "align": "align_text"
241
+ }
242
+ },
243
+ "head": {
244
+ "remove": 1
245
+ },
246
+ "tbody": {
247
+ "add_class": {
248
+ "align": "align_text"
249
+ }
250
+ },
251
+ "dd": {
252
+ "rename_tag": "div"
253
+ },
254
+ "s": {
255
+ "rename_tag": "span"
256
+ },
257
+ "li": {},
258
+ "td": {
259
+ "check_attributes": {
260
+ "rowspan": "numbers",
261
+ "colspan": "numbers"
262
+ },
263
+ "add_class": {
264
+ "align": "align_text"
265
+ }
266
+ },
267
+ "object": {
268
+ "remove": 1
269
+ },
270
+ "div": {
271
+ "add_class": {
272
+ "align": "align_text"
273
+ }
274
+ },
275
+ "option": {
276
+ "rename_tag": "span"
277
+ },
278
+ "select": {
279
+ "rename_tag": "span"
280
+ },
281
+ "i": {},
282
+ "track": {
283
+ "remove": 1
284
+ },
285
+ "wbr": {
286
+ "remove": 1
287
+ },
288
+ "fieldset": {
289
+ "rename_tag": "div"
290
+ },
291
+ "big": {
292
+ "rename_tag": "span",
293
+ "set_class": "wysiwyg-font-size-larger"
294
+ },
295
+ "button": {
296
+ "rename_tag": "span"
297
+ },
298
+ "noscript": {
299
+ "remove": 1
300
+ },
301
+ "svg": {
302
+ "remove": 1
303
+ },
304
+ "input": {
305
+ "remove": 1
306
+ },
307
+ "table": {},
308
+ "keygen": {
309
+ "remove": 1
310
+ },
311
+ "h5": {
312
+ "add_class": {
313
+ "align": "align_text"
314
+ }
315
+ },
316
+ "meta": {
317
+ "remove": 1
318
+ },
319
+ "map": {
320
+ "rename_tag": "div"
321
+ },
322
+ "isindex": {
323
+ "remove": 1
324
+ },
325
+ "mark": {
326
+ "rename_tag": "span"
327
+ },
328
+ "caption": {
329
+ "add_class": {
330
+ "align": "align_text"
331
+ }
332
+ },
333
+ "tfoot": {
334
+ "add_class": {
335
+ "align": "align_text"
336
+ }
337
+ },
338
+ "base": {
339
+ "remove": 1
340
+ },
341
+ "video": {
342
+ "remove": 1
343
+ },
344
+ "strong": {},
345
+ "canvas": {
346
+ "remove": 1
347
+ },
348
+ "output": {
349
+ "rename_tag": "span"
350
+ },
351
+ "marquee": {
352
+ "rename_tag": "span"
353
+ },
354
+ "b": {},
355
+ "q": {
356
+ "check_attributes": {
357
+ "cite": "url"
358
+ }
359
+ },
360
+ "applet": {
361
+ "remove": 1
362
+ },
363
+ "span": {},
364
+ "rp": {
365
+ "rename_tag": "span"
366
+ },
367
+ "spacer": {
368
+ "remove": 1
369
+ },
370
+ "source": {
371
+ "remove": 1
372
+ },
373
+ "aside": {
374
+ "rename_tag": "div"
375
+ },
376
+ "frame": {
377
+ "remove": 1
378
+ },
379
+ "section": {
380
+ "rename_tag": "div"
381
+ },
382
+ "body": {
383
+ "rename_tag": "div"
384
+ },
385
+ "ol": {},
386
+ "nobr": {
387
+ "rename_tag": "span"
388
+ },
389
+ "html": {
390
+ "rename_tag": "div"
391
+ },
392
+ "summary": {
393
+ "rename_tag": "span"
394
+ },
395
+ "var": {
396
+ "rename_tag": "span"
397
+ },
398
+ "del": {
399
+ "remove": 1
400
+ },
401
+ "blockquote": {
402
+ "check_attributes": {
403
+ "cite": "url"
404
+ }
405
+ },
406
+ "style": {
407
+ "remove": 1
408
+ },
409
+ "device": {
410
+ "remove": 1
411
+ },
412
+ "meter": {
413
+ "rename_tag": "span"
414
+ },
415
+ "h3": {
416
+ "add_class": {
417
+ "align": "align_text"
418
+ }
419
+ },
420
+ "textarea": {
421
+ "rename_tag": "span"
422
+ },
423
+ "embed": {
424
+ "remove": 1
425
+ },
426
+ "hgroup": {
427
+ "rename_tag": "div"
428
+ },
429
+ "font": {
430
+ "rename_tag": "span",
431
+ "add_class": {
432
+ "size": "size_font"
433
+ }
434
+ },
435
+ "tt": {
436
+ "rename_tag": "span"
437
+ },
438
+ "noembed": {
439
+ "remove": 1
440
+ },
441
+ "thead": {
442
+ "add_class": {
443
+ "align": "align_text"
444
+ }
445
+ },
446
+ "blink": {
447
+ "rename_tag": "span"
448
+ },
449
+ "plaintext": {
450
+ "rename_tag": "span"
451
+ },
452
+ "xml": {
453
+ "remove": 1
454
+ },
455
+ "h6": {
456
+ "add_class": {
457
+ "align": "align_text"
458
+ }
459
+ },
460
+ "param": {
461
+ "remove": 1
462
+ },
463
+ "th": {
464
+ "check_attributes": {
465
+ "rowspan": "numbers",
466
+ "colspan": "numbers"
467
+ },
468
+ "add_class": {
469
+ "align": "align_text"
470
+ }
471
+ },
472
+ "legend": {
473
+ "rename_tag": "span"
474
+ },
475
+ "hr": {},
476
+ "label": {
477
+ "rename_tag": "span"
478
+ },
479
+ "dl": {
480
+ "rename_tag": "div"
481
+ },
482
+ "kbd": {
483
+ "rename_tag": "span"
484
+ },
485
+ "listing": {
486
+ "rename_tag": "div"
487
+ },
488
+ "dt": {
489
+ "rename_tag": "span"
490
+ },
491
+ "nextid": {
492
+ "remove": 1
493
+ },
494
+ "pre": {},
495
+ "center": {
496
+ "rename_tag": "div",
497
+ "set_class": "wysiwyg-text-align-center"
498
+ },
499
+ "audio": {
500
+ "remove": 1
501
+ },
502
+ "datalist": {
503
+ "rename_tag": "span"
504
+ },
505
+ "samp": {
506
+ "rename_tag": "span"
507
+ },
508
+ "col": {
509
+ "remove": 1
510
+ },
511
+ "article": {
512
+ "rename_tag": "div"
513
+ },
514
+ "cite": {},
515
+ "link": {
516
+ "remove": 1
517
+ },
518
+ "script": {
519
+ "remove": 1
520
+ },
521
+ "bdo": {
522
+ "rename_tag": "span"
523
+ },
524
+ "menu": {
525
+ "rename_tag": "ul"
526
+ },
527
+ "colgroup": {
528
+ "remove": 1
529
+ },
530
+ "ruby": {
531
+ "rename_tag": "span"
532
+ },
533
+ "h2": {
534
+ "add_class": {
535
+ "align": "align_text"
536
+ }
537
+ },
538
+ "ins": {
539
+ "rename_tag": "span"
540
+ },
541
+ "p": {
542
+ "add_class": {
543
+ "align": "align_text"
544
+ }
545
+ },
546
+ "sub": {
547
+ "rename_tag": "span"
548
+ },
549
+ "comment": {
550
+ "remove": 1
551
+ },
552
+ "frameset": {
553
+ "remove": 1
554
+ },
555
+ "optgroup": {
556
+ "rename_tag": "span"
557
+ },
558
+ "header": {
559
+ "rename_tag": "div"
560
+ }
561
+ }
562
+ };