active_admin_editor 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/README.md +38 -3
  2. data/app/assets/javascripts/active_admin/editor.js +0 -1
  3. data/app/assets/javascripts/active_admin/editor/config.js.erb +1 -0
  4. data/app/assets/javascripts/active_admin/editor/templates/toolbar.jst.ejs +2 -0
  5. data/lib/active_admin/editor.rb +1 -0
  6. data/lib/active_admin/editor/config.rb +4 -0
  7. data/lib/active_admin/editor/parser_rules.rb +550 -0
  8. data/lib/active_admin/editor/version.rb +1 -1
  9. data/spec/dummy/app/admin/dashboard.rb +33 -0
  10. data/spec/dummy/app/admin/pages.rb +1 -1
  11. data/spec/dummy/config/initializers/active_admin.rb +3 -0
  12. data/spec/dummy/config/initializers/devise.rb +0 -7
  13. data/spec/dummy/db/development.sqlite3 +0 -0
  14. data/spec/dummy/log/development.log +1631 -0
  15. data/spec/dummy/log/test.log +1162 -0
  16. data/spec/dummy/tmp/cache/assets/C17/7E0/sprockets%2F10282a65710402dd907a870692e08e54 +0 -0
  17. data/spec/dummy/tmp/cache/assets/C4C/360/sprockets%2F72117b2727aba75092e90773336f414e +0 -0
  18. data/spec/dummy/tmp/cache/assets/C55/FB0/sprockets%2F12d25fa97a62a49735017b39155987e0 +0 -0
  19. data/spec/dummy/tmp/cache/assets/C62/EB0/sprockets%2F11e66b9d26e35c6644e690739d767108 +0 -0
  20. data/spec/dummy/tmp/cache/assets/C7A/500/sprockets%2F1f1d4d009502fd535845b5459a83f340 +0 -0
  21. data/spec/dummy/tmp/cache/assets/C7E/A00/sprockets%2F792b6f07a3b1f6e7f7020544633d6163 +0 -0
  22. data/spec/dummy/tmp/cache/assets/C81/E20/sprockets%2F0b927ca32a706e522c5958878d7145a1 +0 -0
  23. data/spec/dummy/tmp/cache/assets/C8D/BD0/sprockets%2Fb7f30a05e9483519378748810c6b57ec +0 -0
  24. data/spec/dummy/tmp/cache/assets/C8F/100/sprockets%2F43f25b46ba5b45b6886d5672d5163797 +0 -0
  25. data/spec/dummy/tmp/cache/assets/C9D/E70/sprockets%2F4a5d05f556354e305a5184b065c62ac0 +0 -0
  26. data/spec/dummy/tmp/cache/assets/C9F/170/sprockets%2F5d65e155aad3374ae12771242be22580 +0 -0
  27. data/spec/dummy/tmp/cache/assets/CB0/480/sprockets%2F770d002c3b3fb7a27d7862f788702a91 +0 -0
  28. data/spec/dummy/tmp/cache/assets/CB2/5A0/sprockets%2F4e7c202a6f2335881a86d6fc17329d08 +0 -0
  29. data/spec/dummy/tmp/cache/assets/CB7/160/sprockets%2F9b2ab958728324ca63e77600c53e934e +0 -0
  30. data/spec/dummy/tmp/cache/assets/CC3/E30/sprockets%2F0911249a810f39f82185eef9e0959a9d +0 -0
  31. data/spec/dummy/tmp/cache/assets/CC7/830/sprockets%2F10abd9e76d16838868b873632597e4eb +0 -0
  32. data/spec/dummy/tmp/cache/assets/CCB/120/sprockets%2Fb9500896df13a12225b836bda0b7320e +0 -0
  33. data/spec/dummy/tmp/cache/assets/CCD/EC0/sprockets%2F9694fc1ad28709775e7a7f82369ed721 +0 -0
  34. data/spec/dummy/tmp/cache/assets/CD1/ED0/sprockets%2F242b4a53a4a4446f07c4a0e04e77847b +0 -0
  35. data/spec/dummy/tmp/cache/assets/CD6/810/sprockets%2F901ca591b49d076903b08128b26cbdb7 +0 -0
  36. data/spec/dummy/tmp/cache/assets/CDB/040/sprockets%2Fc732474e67003a4eb840eb44c5ca9385 +0 -0
  37. data/spec/dummy/tmp/cache/assets/CF4/BB0/sprockets%2Fd2509ee195cff97ad94e74257853b064 +0 -0
  38. data/spec/dummy/tmp/cache/assets/D00/490/sprockets%2F60ff8fc770f770b47a563e8cd4696994 +0 -0
  39. data/spec/dummy/tmp/cache/assets/D03/CD0/sprockets%2Ff025a9441aa20929b3175d8d6ab3c18e +0 -0
  40. data/spec/dummy/tmp/cache/assets/D2E/800/sprockets%2F4f418afd1d357065fa7bb580041a28aa +0 -0
  41. data/spec/dummy/tmp/cache/assets/D38/540/sprockets%2F86e1ad844bc9df4491a2a52b870421db +0 -0
  42. data/spec/dummy/tmp/cache/assets/D39/DF0/sprockets%2F1351e4754ff46cdca7cc05f72a1f1780 +0 -0
  43. data/spec/dummy/tmp/cache/assets/D3A/B20/sprockets%2F536a8c3e16caff754bd9a9216f51e101 +0 -0
  44. data/spec/dummy/tmp/cache/assets/D3D/E80/sprockets%2F4bcb20ff58693fa41b8729a79400dcb3 +0 -0
  45. data/spec/dummy/tmp/cache/assets/D41/2F0/sprockets%2Fe5d704d8dc364cb7e3e822bb4e253916 +0 -0
  46. data/spec/dummy/tmp/cache/assets/D46/3F0/sprockets%2F45e4032f9ee82213f32b98dae1e859cc +0 -0
  47. data/spec/dummy/tmp/cache/assets/D48/170/sprockets%2Fbc5e81bc580d8c262d3e9d7e984051b7 +0 -0
  48. data/spec/dummy/tmp/cache/assets/D48/640/sprockets%2F9f4f18d910b678b1d0777e04cdaf6f24 +0 -0
  49. data/spec/dummy/tmp/cache/assets/D4E/8C0/sprockets%2Ffa56f431b696af04ff09e2d98e286e32 +0 -0
  50. data/spec/dummy/tmp/cache/assets/D53/0B0/sprockets%2F4b2b0082dbfd4ae3f0af30c22612865c +0 -0
  51. data/spec/dummy/tmp/cache/assets/D59/D70/sprockets%2Fed9f0de1b65ae8d7ef89087c83728461 +0 -0
  52. data/spec/dummy/tmp/cache/assets/D5F/930/sprockets%2F0611d8badac9f948b70aaa227109bb29 +0 -0
  53. data/spec/dummy/tmp/cache/assets/D6D/FA0/sprockets%2Fa1bbb309c8c629a282e3f4f9ad3d4961 +0 -0
  54. data/spec/dummy/tmp/cache/assets/D72/9D0/sprockets%2Fdafb56b16522a94a679e5e35ff1f8b12 +0 -0
  55. data/spec/dummy/tmp/cache/assets/D76/730/sprockets%2Fd1699d0cbcfe965c5c51a95e31580df2 +0 -0
  56. data/spec/dummy/tmp/cache/assets/D79/890/sprockets%2F48245259266fbda2cbb676f6f8a91dae +0 -0
  57. data/spec/dummy/tmp/cache/assets/D93/4C0/sprockets%2F857ecd2092cee11f740b3cf2e373ad2a +0 -0
  58. data/spec/dummy/tmp/cache/assets/DA7/CD0/sprockets%2F63efd46c5c9b462b90a52bdfbf25b779 +0 -0
  59. data/spec/dummy/tmp/cache/assets/DBA/6B0/sprockets%2F4acc06bba5e909e9aab90dab06b19503 +0 -0
  60. data/spec/dummy/tmp/cache/assets/DBF/0B0/sprockets%2F1aacf4a74e2d4d026ee99e320d5b03ec +0 -0
  61. data/spec/dummy/tmp/cache/assets/DC5/910/sprockets%2F9afa316098cef0a0bdd49b93caa057f2 +0 -0
  62. data/spec/dummy/tmp/cache/assets/DCE/D40/sprockets%2F3c3feb2b696842feaff8cf3264c103ae +0 -0
  63. data/spec/dummy/tmp/cache/assets/DD5/C40/sprockets%2F7c17ce947d82be9ccfd0af20ea78930c +0 -0
  64. data/spec/dummy/tmp/cache/assets/DDE/420/sprockets%2Ffb8b186d5bf0307f86f65fc787d2adeb +0 -0
  65. data/spec/dummy/tmp/cache/assets/E0A/D60/sprockets%2Fc7e9f2f9555aafbec9bea658c1d6a047 +0 -0
  66. data/spec/dummy/tmp/cache/assets/E0D/340/sprockets%2Ffd1a919b3fcbf5838bfd543d2ced9f47 +0 -0
  67. data/spec/dummy/tmp/cache/assets/E2E/CD0/sprockets%2Fb7a4e9baedef6f6e60234cb94cd0d83a +0 -0
  68. data/spec/spec_helper.rb +0 -3
  69. metadata +7 -97
  70. data/app/assets/javascripts/active_admin/editor/parser_rules.js +0 -560
  71. data/spec/dummy/db/test.sqlite3 +0 -0
  72. data/spec/dummy/tmp/cache/assets/C94/D20/sprockets%2F3397997b6066dfc6995b0eaa23913907 +0 -0
  73. data/spec/dummy/tmp/cache/assets/C9F/4B0/sprockets%2Fad8482516a116a14c2049944dc5800cc +0 -0
  74. data/spec/dummy/tmp/cache/assets/CAB/5D0/sprockets%2Fae6053e1f832b219519600e978f40b1e +0 -0
  75. data/spec/dummy/tmp/cache/assets/CB7/940/sprockets%2F6d7c27e22691733a4db6968177c22d3c +0 -0
  76. data/spec/dummy/tmp/cache/assets/CCC/BA0/sprockets%2F0e0e79da1b5b3033c89cfa8211306074 +0 -0
  77. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  78. data/spec/dummy/tmp/cache/assets/CD9/350/sprockets%2F32028818c2c71992ada5fba5846a570a +0 -0
  79. data/spec/dummy/tmp/cache/assets/CDA/710/sprockets%2F62127bc83fb039a235ab75167b866cb5 +0 -0
  80. data/spec/dummy/tmp/cache/assets/CDF/420/sprockets%2F0be8c2291b745181fd56b7c4770a7d08 +0 -0
  81. data/spec/dummy/tmp/cache/assets/CE0/970/sprockets%2Fc9f200ae739b9f7b288228ac18346c20 +0 -0
  82. data/spec/dummy/tmp/cache/assets/CEE/C80/sprockets%2F18515cf2523bdc58f32fe536665ff657 +0 -0
  83. data/spec/dummy/tmp/cache/assets/CF2/380/sprockets%2Fb7f95440782366509acb6ddd5f6938a5 +0 -0
  84. data/spec/dummy/tmp/cache/assets/CF4/AE0/sprockets%2F764571ead1c1995d83a95d9269da457c +0 -0
  85. data/spec/dummy/tmp/cache/assets/CF7/570/sprockets%2F172af7030e61fae1056ee122c8f0a533 +0 -0
  86. data/spec/dummy/tmp/cache/assets/CF8/0B0/sprockets%2F1fc42b20103cc98d433f230c9e84b10d +0 -0
  87. data/spec/dummy/tmp/cache/assets/D08/C10/sprockets%2F1905d76e0c7ba5c68fad2376d44d1105 +0 -0
  88. data/spec/dummy/tmp/cache/assets/D10/420/sprockets%2Fa4dc298af1d087c33871f077b0f16f17 +0 -0
  89. data/spec/dummy/tmp/cache/assets/D23/ED0/sprockets%2F77308cdf3281f5ef8b5d188bf8e74036 +0 -0
  90. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  91. data/spec/dummy/tmp/cache/assets/D34/C90/sprockets%2Fda1e05e39683311b61cb095c6c2fdd63 +0 -0
  92. data/spec/dummy/tmp/cache/assets/D3C/DF0/sprockets%2Ff432a7e254a9b296d3dfa02ce86903a5 +0 -0
  93. data/spec/dummy/tmp/cache/assets/D3E/E70/sprockets%2F038e0e6d5f82f9562663ac2611bbedd4 +0 -0
  94. data/spec/dummy/tmp/cache/assets/D44/C10/sprockets%2F2266669d5531ceb6da3418dd26e7d2df +0 -0
  95. data/spec/dummy/tmp/cache/assets/D49/DA0/sprockets%2Fff38d1c9e2d93d45642fed29d3e30372 +0 -0
  96. data/spec/dummy/tmp/cache/assets/D5A/070/sprockets%2Fd8818fa8a8ef79eab35083ed7747366b +0 -0
  97. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  98. data/spec/dummy/tmp/cache/assets/D5D/520/sprockets%2Fbee57aef677100ff765e815f994b689b +0 -0
  99. data/spec/dummy/tmp/cache/assets/D60/5A0/sprockets%2Fa0350de718dad460b2072ddaee54d981 +0 -0
  100. data/spec/dummy/tmp/cache/assets/D76/DA0/sprockets%2F30e9a50c62e4c0e692f6ecd996ea319c +0 -0
  101. data/spec/dummy/tmp/cache/assets/D77/460/sprockets%2Fe55bb3a682bfa8d973ed7da8075f0760 +0 -0
  102. data/spec/dummy/tmp/cache/assets/D7A/060/sprockets%2F77ca5dbe828fbf2ffd35b5a246726483 +0 -0
  103. data/spec/dummy/tmp/cache/assets/D7C/C30/sprockets%2Ffff7e9e07a287afd2545a319a51e8c74 +0 -0
  104. data/spec/dummy/tmp/cache/assets/D84/5F0/sprockets%2F00b3982f58c6eccfe3eee6487b52f758 +0 -0
  105. data/spec/dummy/tmp/cache/assets/D8B/B30/sprockets%2F4dba4514d3a98322b21d72c8eab42cdd +0 -0
  106. data/spec/dummy/tmp/cache/assets/D97/B00/sprockets%2F6320e6270ecefff1d38a7e2ac651c45b +0 -0
  107. data/spec/dummy/tmp/cache/assets/D9E/100/sprockets%2Fa9bd0212de7fa8673e1b643ffb72e4a8 +0 -0
  108. data/spec/dummy/tmp/cache/assets/DA3/CB0/sprockets%2Feed56563f89ef40af5dc3446faa01a75 +0 -0
  109. data/spec/dummy/tmp/cache/assets/DB1/170/sprockets%2F39ccab8b246a72889ae697c84df5a4ce +0 -0
  110. data/spec/dummy/tmp/cache/assets/DC4/410/sprockets%2Fd83e593eb29628c1ce0cda1bb52bd3b6 +0 -0
  111. data/spec/dummy/tmp/cache/assets/DCF/600/sprockets%2F8da546237ce6e75da190e3b092eabeef +0 -0
  112. data/spec/dummy/tmp/cache/assets/DDC/320/sprockets%2F5da6cc4cce8f2187c3c329fdd752f69c +0 -0
  113. data/spec/dummy/tmp/cache/assets/DEC/8B0/sprockets%2F5cccef02565cd21f12b277c63abbfe1c +0 -0
  114. data/spec/dummy/tmp/cache/assets/E02/970/sprockets%2Fa5d6fd3fd2a6d81fbccd14cc929f8145 +0 -0
  115. data/spec/dummy/tmp/cache/assets/E3B/4F0/sprockets%2Fe52b61cae0b3e9ecd57a884f7eefe85b +0 -0
  116. data/spec/dummy/tmp/cache/assets/E54/600/sprockets%2Fec46dd83126fcd2afef6ac23c2c6cc1e +0 -0
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Active Admin Editor
2
-
3
- [![Build Status](https://travis-ci.org/ejholmes/active_admin_editor.png)](https://travis-ci.org/ejholmes/active_admin_editor)
2
+ [![Build Status](https://travis-ci.org/ejholmes/active_admin_editor.png?branch=master)](https://travis-ci.org/ejholmes/active_admin_editor) [![Code Climate](https://codeclimate.com/github/ejholmes/active_admin_editor.png)](https://codeclimate.com/github/ejholmes/active_admin_editor)
4
3
 
5
4
  This is a wysiwyg html editor for the [Active Admin](http://activeadmin.info/)
6
5
  interface using [wysihtml5](https://github.com/xing/wysihtml5).
@@ -90,10 +89,46 @@ ActiveAdmin.setup do |config|
90
89
  # ...
91
90
  config.editor.aws_access_key_id = '<your aws access key>'
92
91
  config.editor.s3_bucket = 'bucket'
93
- config.editor.stylesheets << 'custom_wysiwyg_styles.css'
94
92
  end
95
93
  ```
96
94
 
95
+ ## Parser Rules
96
+
97
+ [Parser rules](https://github.com/xing/wysihtml5/tree/master/parser_rules) can
98
+ be configured through the initializer:
99
+
100
+ ```ruby
101
+ ActiveAdmin::Editor.configure do |config|
102
+ config.parser_rules['tags']['strike'] = {
103
+ 'remove' => 0
104
+ }
105
+ end
106
+ ```
107
+
108
+ Be sure to clear your rails cache after changing the config:
109
+
110
+ ```bash
111
+ rm -rf tmp/cache
112
+ ```
113
+
114
+ ## Heroku
115
+
116
+ Since some of the javascript files need to be compiled with access to the env
117
+ vars, it's recommended that you add the [user-env-compile](https://devcenter.heroku.com/articles/labs-user-env-compile)
118
+ labs feature to your app.
119
+
120
+ 1. Tell your rails app to run initializers on asset compilation
121
+
122
+ ```ruby
123
+ # config/environments/production.rb
124
+ config.initialize_on_compile = true
125
+ ```
126
+ 2. Add the labs feature
127
+
128
+ ```bash
129
+ heroku labs:enable user-env-compile -a myapp
130
+ ```
131
+
97
132
  ## Contributing
98
133
 
99
134
  1. Fork it
@@ -1,7 +1,6 @@
1
1
  //= require wysihtml5
2
2
  //= require active_admin/editor/config
3
3
  //= require active_admin/editor/editor
4
- //= require active_admin/editor/parser_rules
5
4
 
6
5
  ;(function(window, $) {
7
6
  $(function() { $('.html_editor').editor(window.AA.editor_config) })
@@ -9,4 +9,5 @@
9
9
  config.stylesheets = <%= ActiveAdmin::Editor.configuration.stylesheets.map { |stylesheet| asset_path stylesheet }.to_json %>
10
10
  config.spinner = '<%= asset_path 'active_admin/editor/loader.gif' %>'
11
11
  config.uploads_enabled = <%= ActiveAdmin::Editor.configuration.s3_configured? %>
12
+ config.parserRules = <%= ActiveAdmin::Editor.configuration.parser_rules.to_json %>
12
13
  })(window)
@@ -7,6 +7,8 @@
7
7
  <li><a data-wysihtml5-command="insertImage" class="insertImage" title="Image">Image</a></li>
8
8
  <li><a data-wysihtml5-command="insertUnorderedList" title="Unordered list">Bulleted List</a></li>
9
9
  <li><a data-wysihtml5-command="insertOrderedList" title="Ordered list">Numbered List</a></li>
10
+ <li><a data-wysihtml5-command="indent" title="Indent">Indent</a></li>
11
+ <li><a data-wysihtml5-command="outdent" title="Outdent">Outdent</a></li>
10
12
  <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1">h1</a></li>
11
13
  <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2">h2</a></li>
12
14
  <li><a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h3">h3</a></li>
@@ -1,6 +1,7 @@
1
1
  require 'activeadmin'
2
2
 
3
3
  require 'active_admin/editor/version'
4
+ require 'active_admin/editor/parser_rules'
4
5
  require 'active_admin/editor/config'
5
6
  require 'active_admin/editor/policy'
6
7
  require 'active_admin/editor/engine'
@@ -46,6 +46,10 @@ module ActiveAdmin
46
46
  aws_access_secret.present? &&
47
47
  s3_bucket.present?
48
48
  end
49
+
50
+ def parser_rules
51
+ @parser_rules ||= PARSER_RULES.dup
52
+ end
49
53
  end
50
54
  end
51
55
  end
@@ -0,0 +1,550 @@
1
+ module ActiveAdmin
2
+ module Editor
3
+ # Full HTML5 compatibility rule set
4
+ # These rules define which tags and CSS classes are supported and which tags should be specially treated.
5
+ #
6
+ # Examples based on this rule set:
7
+ #
8
+ # <a href="http://foobar.com">foo</a>
9
+ # ... becomes ...
10
+ # <a href="http://foobar.com" target="_blank" rel="nofollow">foo</a>
11
+ #
12
+ # <img align="left" src="http://foobar.com/image.png">
13
+ # ... becomes ...
14
+ # <img class="wysiwyg-float-left" src="http://foobar.com/image.png" alt="">
15
+ #
16
+ # <div>foo<script>alert(document.cookie)</script></div>
17
+ # ... becomes ...
18
+ # <div>foo</div>
19
+ #
20
+ # <marquee>foo</marquee>
21
+ # ... becomes ...
22
+ # <span>foo</span>
23
+ #
24
+ # foo <br clear="both"> bar
25
+ # ... becomes ...
26
+ # foo <br class="wysiwyg-clear-both"> bar
27
+ #
28
+ # <div>hello <iframe src="http://google.com"></iframe></div>
29
+ # ... becomes ...
30
+ # <div>hello </div>
31
+ #
32
+ # <center>hello</center>
33
+ # ... becomes ...
34
+ # <div class="wysiwyg-text-align-center">hello</div>
35
+ PARSER_RULES = {
36
+ # CSS Class white-list
37
+ # Following CSS classes won't be removed when parsed by the wysihtml5 HTML parser
38
+ 'classes' => {
39
+ 'wysiwyg-clear-both' => 1,
40
+ 'wysiwyg-clear-left' => 1,
41
+ 'wysiwyg-clear-right' => 1,
42
+ 'wysiwyg-color-aqua' => 1,
43
+ 'wysiwyg-color-black' => 1,
44
+ 'wysiwyg-color-blue' => 1,
45
+ 'wysiwyg-color-fuchsia' => 1,
46
+ 'wysiwyg-color-gray' => 1,
47
+ 'wysiwyg-color-green' => 1,
48
+ 'wysiwyg-color-lime' => 1,
49
+ 'wysiwyg-color-maroon' => 1,
50
+ 'wysiwyg-color-navy' => 1,
51
+ 'wysiwyg-color-olive' => 1,
52
+ 'wysiwyg-color-purple' => 1,
53
+ 'wysiwyg-color-red' => 1,
54
+ 'wysiwyg-color-silver' => 1,
55
+ 'wysiwyg-color-teal' => 1,
56
+ 'wysiwyg-color-white' => 1,
57
+ 'wysiwyg-color-yellow' => 1,
58
+ 'wysiwyg-float-left' => 1,
59
+ 'wysiwyg-float-right' => 1,
60
+ 'wysiwyg-font-size-large' => 1,
61
+ 'wysiwyg-font-size-larger' => 1,
62
+ 'wysiwyg-font-size-medium' => 1,
63
+ 'wysiwyg-font-size-small' => 1,
64
+ 'wysiwyg-font-size-smaller' => 1,
65
+ 'wysiwyg-font-size-x-large' => 1,
66
+ 'wysiwyg-font-size-x-small' => 1,
67
+ 'wysiwyg-font-size-xx-large' => 1,
68
+ 'wysiwyg-font-size-xx-small' => 1,
69
+ 'wysiwyg-text-align-center' => 1,
70
+ 'wysiwyg-text-align-justify' => 1,
71
+ 'wysiwyg-text-align-left' => 1,
72
+ 'wysiwyg-text-align-right' => 1
73
+ },
74
+ # Tag list
75
+ #
76
+ # The following options are available:
77
+ #
78
+ # - add_class: converts and deletes the given HTML4 attribute (align, clear, ...) via the given method to a css class
79
+ # The following methods are implemented in wysihtml5.dom.parse:
80
+ # - align_text: converts align attribute values (right/left/center/justify) to their corresponding css class "wysiwyg-text-align-*")
81
+ # <p align="center">foo</p> ... becomes ... <p> class="wysiwyg-text-align-center">foo</p>
82
+ # - clear_br: converts clear attribute values left/right/all/both to their corresponding css class "wysiwyg-clear-*"
83
+ # <br clear="all"> ... becomes ... <br class="wysiwyg-clear-both">
84
+ # - align_img: converts align attribute values (right/left) on <img> to their corresponding css class "wysiwyg-float-*"
85
+ #
86
+ # - remove: removes the element and its content
87
+ #
88
+ # - rename_tag: renames the element to the given tag
89
+ #
90
+ # - set_class: adds the given class to the element (note: make sure that the class is in the "classes" white list above)
91
+ #
92
+ # - set_attributes: sets/overrides the given attributes
93
+ #
94
+ # - check_attributes: checks the given HTML attribute via the given method
95
+ # - url: allows only valid urls (starting with http:// or https://)
96
+ # - src: allows something like "/foobar.jpg", "http://google.com", ...
97
+ # - href: allows something like "mailto:bert@foo.com", "http://google.com", "/foobar.jpg"
98
+ # - alt: strips unwanted characters. if the attribute is not set, then it gets set (to ensure valid and compatible HTML)
99
+ # - numbers: ensures that the attribute only contains numeric characters
100
+ 'tags' => {
101
+ 'tr' => {
102
+ 'add_class' => {
103
+ 'align' => 'align_text'
104
+ }
105
+ },
106
+ 'strike' => {
107
+ 'remove' => 1
108
+ },
109
+ 'form' => {
110
+ 'rename_tag' => 'div'
111
+ },
112
+ 'rt' => {
113
+ 'rename_tag' => 'span'
114
+ },
115
+ 'code' => {},
116
+ 'acronym' => {
117
+ 'rename_tag' => 'span'
118
+ },
119
+ 'br' => {
120
+ 'add_class' => {
121
+ 'clear' => 'clear_br'
122
+ }
123
+ },
124
+ 'details' => {
125
+ 'rename_tag' => 'div'
126
+ },
127
+ 'h4' => {
128
+ 'add_class' => {
129
+ 'align' => 'align_text'
130
+ }
131
+ },
132
+ 'em' => {},
133
+ 'title' => {
134
+ 'remove' => 1
135
+ },
136
+ 'multicol' => {
137
+ 'rename_tag' => 'div'
138
+ },
139
+ 'figure' => {
140
+ 'rename_tag' => 'div'
141
+ },
142
+ 'xmp' => {
143
+ 'rename_tag' => 'span'
144
+ },
145
+ 'small' => {
146
+ 'rename_tag' => 'span',
147
+ 'set_class' => 'wysiwyg-font-size-smaller'
148
+ },
149
+ 'area' => {
150
+ 'remove' => 1
151
+ },
152
+ 'time' => {
153
+ 'rename_tag' => 'span'
154
+ },
155
+ 'dir' => {
156
+ 'rename_tag' => 'ul'
157
+ },
158
+ 'bdi' => {
159
+ 'rename_tag' => 'span'
160
+ },
161
+ 'command' => {
162
+ 'remove' => 1
163
+ },
164
+ 'ul' => {},
165
+ 'progress' => {
166
+ 'rename_tag' => 'span'
167
+ },
168
+ 'dfn' => {
169
+ 'rename_tag' => 'span'
170
+ },
171
+ 'iframe' => {
172
+ 'remove' => 1
173
+ },
174
+ 'figcaption' => {
175
+ 'rename_tag' => 'div'
176
+ },
177
+ 'a' => {
178
+ 'check_attributes' => {
179
+ 'href' => 'url' # if you compiled master manually then change this from 'url' to 'href'
180
+ },
181
+ 'set_attributes' => {
182
+ 'target' => '_blank'
183
+ }
184
+ },
185
+ 'img' => {
186
+ 'check_attributes' => {
187
+ 'width' => 'numbers',
188
+ 'alt' => 'alt',
189
+ 'src' => 'url', # if you compiled master manually then change this from 'url' to 'src'
190
+ 'height' => 'numbers'
191
+ },
192
+ 'add_class' => {
193
+ 'align' => 'align_img'
194
+ }
195
+ },
196
+ 'rb' => {
197
+ 'rename_tag' => 'span'
198
+ },
199
+ 'footer' => {
200
+ 'rename_tag' => 'div'
201
+ },
202
+ 'noframes' => {
203
+ 'remove' => 1
204
+ },
205
+ 'abbr' => {
206
+ 'rename_tag' => 'span'
207
+ },
208
+ 'u' => {},
209
+ 'bgsound' => {
210
+ 'remove' => 1
211
+ },
212
+ 'sup' => {
213
+ 'rename_tag' => 'span'
214
+ },
215
+ 'address' => {
216
+ 'rename_tag' => 'div'
217
+ },
218
+ 'basefont' => {
219
+ 'remove' => 1
220
+ },
221
+ 'nav' => {
222
+ 'rename_tag' => 'div'
223
+ },
224
+ 'h1' => {
225
+ 'add_class' => {
226
+ 'align' => 'align_text'
227
+ }
228
+ },
229
+ 'head' => {
230
+ 'remove' => 1
231
+ },
232
+ 'tbody' => {
233
+ 'add_class' => {
234
+ 'align' => 'align_text'
235
+ }
236
+ },
237
+ 'dd' => {
238
+ 'rename_tag' => 'div'
239
+ },
240
+ 's' => {
241
+ 'rename_tag' => 'span'
242
+ },
243
+ 'li' => {},
244
+ 'td' => {
245
+ 'check_attributes' => {
246
+ 'rowspan' => 'numbers',
247
+ 'colspan' => 'numbers'
248
+ },
249
+ 'add_class' => {
250
+ 'align' => 'align_text'
251
+ }
252
+ },
253
+ 'object' => {
254
+ 'remove' => 1
255
+ },
256
+ 'div' => {
257
+ 'add_class' => {
258
+ 'align' => 'align_text'
259
+ }
260
+ },
261
+ 'option' => {
262
+ 'rename_tag' => 'span'
263
+ },
264
+ 'select' => {
265
+ 'rename_tag' => 'span'
266
+ },
267
+ 'i' => {},
268
+ 'track' => {
269
+ 'remove' => 1
270
+ },
271
+ 'wbr' => {
272
+ 'remove' => 1
273
+ },
274
+ 'fieldset' => {
275
+ 'rename_tag' => 'div'
276
+ },
277
+ 'big' => {
278
+ 'rename_tag' => 'span',
279
+ 'set_class' => 'wysiwyg-font-size-larger'
280
+ },
281
+ 'button' => {
282
+ 'rename_tag' => 'span'
283
+ },
284
+ 'noscript' => {
285
+ 'remove' => 1
286
+ },
287
+ 'svg' => {
288
+ 'remove' => 1
289
+ },
290
+ 'input' => {
291
+ 'remove' => 1
292
+ },
293
+ 'table' => {},
294
+ 'keygen' => {
295
+ 'remove' => 1
296
+ },
297
+ 'h5' => {
298
+ 'add_class' => {
299
+ 'align' => 'align_text'
300
+ }
301
+ },
302
+ 'meta' => {
303
+ 'remove' => 1
304
+ },
305
+ 'map' => {
306
+ 'rename_tag' => 'div'
307
+ },
308
+ 'isindex' => {
309
+ 'remove' => 1
310
+ },
311
+ 'mark' => {
312
+ 'rename_tag' => 'span'
313
+ },
314
+ 'caption' => {
315
+ 'add_class' => {
316
+ 'align' => 'align_text'
317
+ }
318
+ },
319
+ 'tfoot' => {
320
+ 'add_class' => {
321
+ 'align' => 'align_text'
322
+ }
323
+ },
324
+ 'base' => {
325
+ 'remove' => 1
326
+ },
327
+ 'video' => {
328
+ 'remove' => 1
329
+ },
330
+ 'strong' => {},
331
+ 'canvas' => {
332
+ 'remove' => 1
333
+ },
334
+ 'output' => {
335
+ 'rename_tag' => 'span'
336
+ },
337
+ 'marquee' => {
338
+ 'rename_tag' => 'span'
339
+ },
340
+ 'b' => {},
341
+ 'q' => {
342
+ 'check_attributes' => {
343
+ 'cite' => 'url'
344
+ }
345
+ },
346
+ 'applet' => {
347
+ 'remove' => 1
348
+ },
349
+ 'span' => {},
350
+ 'rp' => {
351
+ 'rename_tag' => 'span'
352
+ },
353
+ 'spacer' => {
354
+ 'remove' => 1
355
+ },
356
+ 'source' => {
357
+ 'remove' => 1
358
+ },
359
+ 'aside' => {
360
+ 'rename_tag' => 'div'
361
+ },
362
+ 'frame' => {
363
+ 'remove' => 1
364
+ },
365
+ 'section' => {
366
+ 'rename_tag' => 'div'
367
+ },
368
+ 'body' => {
369
+ 'rename_tag' => 'div'
370
+ },
371
+ 'ol' => {},
372
+ 'nobr' => {
373
+ 'rename_tag' => 'span'
374
+ },
375
+ 'html' => {
376
+ 'rename_tag' => 'div'
377
+ },
378
+ 'summary' => {
379
+ 'rename_tag' => 'span'
380
+ },
381
+ 'var' => {
382
+ 'rename_tag' => 'span'
383
+ },
384
+ 'del' => {
385
+ 'remove' => 1
386
+ },
387
+ 'blockquote' => {
388
+ 'check_attributes' => {
389
+ 'cite' => 'url'
390
+ }
391
+ },
392
+ 'style' => {
393
+ 'remove' => 1
394
+ },
395
+ 'device' => {
396
+ 'remove' => 1
397
+ },
398
+ 'meter' => {
399
+ 'rename_tag' => 'span'
400
+ },
401
+ 'h3' => {
402
+ 'add_class' => {
403
+ 'align' => 'align_text'
404
+ }
405
+ },
406
+ 'textarea' => {
407
+ 'rename_tag' => 'span'
408
+ },
409
+ 'embed' => {
410
+ 'remove' => 1
411
+ },
412
+ 'hgroup' => {
413
+ 'rename_tag' => 'div'
414
+ },
415
+ 'font' => {
416
+ 'rename_tag' => 'span',
417
+ 'add_class' => {
418
+ 'size' => 'size_font'
419
+ }
420
+ },
421
+ 'tt' => {
422
+ 'rename_tag' => 'span'
423
+ },
424
+ 'noembed' => {
425
+ 'remove' => 1
426
+ },
427
+ 'thead' => {
428
+ 'add_class' => {
429
+ 'align' => 'align_text'
430
+ }
431
+ },
432
+ 'blink' => {
433
+ 'rename_tag' => 'span'
434
+ },
435
+ 'plaintext' => {
436
+ 'rename_tag' => 'span'
437
+ },
438
+ 'xml' => {
439
+ 'remove' => 1
440
+ },
441
+ 'h6' => {
442
+ 'add_class' => {
443
+ 'align' => 'align_text'
444
+ }
445
+ },
446
+ 'param' => {
447
+ 'remove' => 1
448
+ },
449
+ 'th' => {
450
+ 'check_attributes' => {
451
+ 'rowspan' => 'numbers',
452
+ 'colspan' => 'numbers'
453
+ },
454
+ 'add_class' => {
455
+ 'align' => 'align_text'
456
+ }
457
+ },
458
+ 'legend' => {
459
+ 'rename_tag' => 'span'
460
+ },
461
+ 'hr' => {},
462
+ 'label' => {
463
+ 'rename_tag' => 'span'
464
+ },
465
+ 'dl' => {
466
+ 'rename_tag' => 'div'
467
+ },
468
+ 'kbd' => {
469
+ 'rename_tag' => 'span'
470
+ },
471
+ 'listing' => {
472
+ 'rename_tag' => 'div'
473
+ },
474
+ 'dt' => {
475
+ 'rename_tag' => 'span'
476
+ },
477
+ 'nextid' => {
478
+ 'remove' => 1
479
+ },
480
+ 'pre' => {},
481
+ 'center' => {
482
+ 'rename_tag' => 'div',
483
+ 'set_class' => 'wysiwyg-text-align-center'
484
+ },
485
+ 'audio' => {
486
+ 'remove' => 1
487
+ },
488
+ 'datalist' => {
489
+ 'rename_tag' => 'span'
490
+ },
491
+ 'samp' => {
492
+ 'rename_tag' => 'span'
493
+ },
494
+ 'col' => {
495
+ 'remove' => 1
496
+ },
497
+ 'article' => {
498
+ 'rename_tag' => 'div'
499
+ },
500
+ 'cite' => {},
501
+ 'link' => {
502
+ 'remove' => 1
503
+ },
504
+ 'script' => {
505
+ 'remove' => 1
506
+ },
507
+ 'bdo' => {
508
+ 'rename_tag' => 'span'
509
+ },
510
+ 'menu' => {
511
+ 'rename_tag' => 'ul'
512
+ },
513
+ 'colgroup' => {
514
+ 'remove' => 1
515
+ },
516
+ 'ruby' => {
517
+ 'rename_tag' => 'span'
518
+ },
519
+ 'h2' => {
520
+ 'add_class' => {
521
+ 'align' => 'align_text'
522
+ }
523
+ },
524
+ 'ins' => {
525
+ 'rename_tag' => 'span'
526
+ },
527
+ 'p' => {
528
+ 'add_class' => {
529
+ 'align' => 'align_text'
530
+ }
531
+ },
532
+ 'sub' => {
533
+ 'rename_tag' => 'span'
534
+ },
535
+ 'comment' => {
536
+ 'remove' => 1
537
+ },
538
+ 'frameset' => {
539
+ 'remove' => 1
540
+ },
541
+ 'optgroup' => {
542
+ 'rename_tag' => 'span'
543
+ },
544
+ 'header' => {
545
+ 'rename_tag' => 'div'
546
+ }
547
+ }
548
+ }
549
+ end
550
+ end