mirador_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +13 -0
  7. data/README.md +97 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/mirador_rails.rb +16 -0
  12. data/lib/mirador_rails/version.rb +3 -0
  13. data/lib/mirador_rails/view_helpers.rb +30 -0
  14. data/mirador_rails.gemspec +30 -0
  15. data/vendor/assets/images/border_type_1.png +0 -0
  16. data/vendor/assets/images/border_type_2.png +0 -0
  17. data/vendor/assets/images/border_type_3.png +0 -0
  18. data/vendor/assets/images/debut_dark.png +0 -0
  19. data/vendor/assets/javascripts/mirador.js +1 -0
  20. data/vendor/assets/javascripts/mirador.min.js +88 -0
  21. data/vendor/assets/javascripts/mirador.min.js.map +1 -0
  22. data/vendor/assets/locales/ar/translation.json +42 -0
  23. data/vendor/assets/locales/de/translation.json +77 -0
  24. data/vendor/assets/locales/en/translation.json +82 -0
  25. data/vendor/assets/locales/es/translation.json +35 -0
  26. data/vendor/assets/locales/fr/translation.json +77 -0
  27. data/vendor/assets/locales/ga/translation.json +39 -0
  28. data/vendor/assets/locales/ja/translation.json +82 -0
  29. data/vendor/assets/locales/ko/translation.json +74 -0
  30. data/vendor/assets/locales/nl/translation.json +39 -0
  31. data/vendor/assets/locales/zh-CN/translation.json +74 -0
  32. data/vendor/assets/locales/zh-TW/translation.json +74 -0
  33. data/vendor/assets/locales/zh/translation.json +74 -0
  34. data/vendor/assets/plugins/plugins/advlist/plugin.js +97 -0
  35. data/vendor/assets/plugins/plugins/advlist/plugin.min.js +1 -0
  36. data/vendor/assets/plugins/plugins/anchor/plugin.js +45 -0
  37. data/vendor/assets/plugins/plugins/anchor/plugin.min.js +1 -0
  38. data/vendor/assets/plugins/plugins/autolink/plugin.js +194 -0
  39. data/vendor/assets/plugins/plugins/autolink/plugin.min.js +1 -0
  40. data/vendor/assets/plugins/plugins/autoresize/plugin.js +152 -0
  41. data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +1 -0
  42. data/vendor/assets/plugins/plugins/autosave/plugin.js +165 -0
  43. data/vendor/assets/plugins/plugins/autosave/plugin.min.js +1 -0
  44. data/vendor/assets/plugins/plugins/bbcode/plugin.js +123 -0
  45. data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +1 -0
  46. data/vendor/assets/plugins/plugins/charmap/plugin.js +370 -0
  47. data/vendor/assets/plugins/plugins/charmap/plugin.min.js +1 -0
  48. data/vendor/assets/plugins/plugins/code/plugin.js +60 -0
  49. data/vendor/assets/plugins/plugins/code/plugin.min.js +1 -0
  50. data/vendor/assets/plugins/plugins/colorpicker/plugin.js +112 -0
  51. data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +1 -0
  52. data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +118 -0
  53. data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
  54. data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
  55. data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
  56. data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
  57. data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
  58. data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
  59. data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
  60. data/vendor/assets/plugins/plugins/compat3x/plugin.js +297 -0
  61. data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +1 -0
  62. data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +542 -0
  63. data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +70 -0
  64. data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +210 -0
  65. data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +164 -0
  66. data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +252 -0
  67. data/vendor/assets/plugins/plugins/contextmenu/plugin.js +87 -0
  68. data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +1 -0
  69. data/vendor/assets/plugins/plugins/directionality/plugin.js +64 -0
  70. data/vendor/assets/plugins/plugins/directionality/plugin.min.js +1 -0
  71. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
  72. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
  73. data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  74. data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  75. data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
  76. data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
  77. data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
  78. data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
  79. data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  80. data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
  81. data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
  82. data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
  83. data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  84. data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
  85. data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
  86. data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
  87. data/vendor/assets/plugins/plugins/emoticons/plugin.js +65 -0
  88. data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +1 -0
  89. data/vendor/assets/plugins/plugins/example/dialog.html +8 -0
  90. data/vendor/assets/plugins/plugins/example/plugin.js +68 -0
  91. data/vendor/assets/plugins/plugins/example/plugin.min.js +1 -0
  92. data/vendor/assets/plugins/plugins/example_dependency/plugin.js +22 -0
  93. data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +1 -0
  94. data/vendor/assets/plugins/plugins/fullpage/plugin.js +490 -0
  95. data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +1 -0
  96. data/vendor/assets/plugins/plugins/fullscreen/plugin.js +136 -0
  97. data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +1 -0
  98. data/vendor/assets/plugins/plugins/hr/plugin.js +30 -0
  99. data/vendor/assets/plugins/plugins/hr/plugin.min.js +1 -0
  100. data/vendor/assets/plugins/plugins/image/plugin.js +439 -0
  101. data/vendor/assets/plugins/plugins/image/plugin.min.js +1 -0
  102. data/vendor/assets/plugins/plugins/importcss/plugin.js +195 -0
  103. data/vendor/assets/plugins/plugins/importcss/plugin.min.js +1 -0
  104. data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +121 -0
  105. data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +1 -0
  106. data/vendor/assets/plugins/plugins/layer/plugin.js +225 -0
  107. data/vendor/assets/plugins/plugins/layer/plugin.min.js +1 -0
  108. data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +211 -0
  109. data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +1 -0
  110. data/vendor/assets/plugins/plugins/link/plugin.js +400 -0
  111. data/vendor/assets/plugins/plugins/link/plugin.min.js +1 -0
  112. data/vendor/assets/plugins/plugins/lists/plugin.js +791 -0
  113. data/vendor/assets/plugins/plugins/lists/plugin.min.js +1 -0
  114. data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
  115. data/vendor/assets/plugins/plugins/media/plugin.js +774 -0
  116. data/vendor/assets/plugins/plugins/media/plugin.min.js +1 -0
  117. data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +53 -0
  118. data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +1 -0
  119. data/vendor/assets/plugins/plugins/noneditable/plugin.js +540 -0
  120. data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +1 -0
  121. data/vendor/assets/plugins/plugins/pagebreak/plugin.js +88 -0
  122. data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +1 -0
  123. data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +634 -0
  124. data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +110 -0
  125. data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +159 -0
  126. data/vendor/assets/plugins/plugins/paste/classes/Utils.js +130 -0
  127. data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +493 -0
  128. data/vendor/assets/plugins/plugins/paste/plugin.dev.js +120 -0
  129. data/vendor/assets/plugins/plugins/paste/plugin.js +1625 -0
  130. data/vendor/assets/plugins/plugins/paste/plugin.min.js +1 -0
  131. data/vendor/assets/plugins/plugins/preview/plugin.js +88 -0
  132. data/vendor/assets/plugins/plugins/preview/plugin.min.js +1 -0
  133. data/vendor/assets/plugins/plugins/print/plugin.js +32 -0
  134. data/vendor/assets/plugins/plugins/print/plugin.min.js +1 -0
  135. data/vendor/assets/plugins/plugins/save/plugin.js +94 -0
  136. data/vendor/assets/plugins/plugins/save/plugin.min.js +1 -0
  137. data/vendor/assets/plugins/plugins/searchreplace/plugin.js +594 -0
  138. data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +1 -0
  139. data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +470 -0
  140. data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +436 -0
  141. data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +117 -0
  142. data/vendor/assets/plugins/plugins/spellchecker/plugin.js +996 -0
  143. data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +1 -0
  144. data/vendor/assets/plugins/plugins/tabfocus/plugin.js +120 -0
  145. data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +1 -0
  146. data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +176 -0
  147. data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +749 -0
  148. data/vendor/assets/plugins/plugins/table/classes/Plugin.js +422 -0
  149. data/vendor/assets/plugins/plugins/table/classes/Quirks.js +372 -0
  150. data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +864 -0
  151. data/vendor/assets/plugins/plugins/table/plugin.dev.js +118 -0
  152. data/vendor/assets/plugins/plugins/table/plugin.js +2680 -0
  153. data/vendor/assets/plugins/plugins/table/plugin.min.js +1 -0
  154. data/vendor/assets/plugins/plugins/template/plugin.js +262 -0
  155. data/vendor/assets/plugins/plugins/template/plugin.min.js +1 -0
  156. data/vendor/assets/plugins/plugins/textcolor/plugin.js +272 -0
  157. data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +1 -0
  158. data/vendor/assets/plugins/plugins/textpattern/plugin.js +268 -0
  159. data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +1 -0
  160. data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +135 -0
  161. data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
  162. data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
  163. data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
  164. data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
  165. data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
  166. data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
  167. data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
  168. data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
  169. data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
  170. data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
  171. data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
  172. data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
  173. data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
  174. data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
  175. data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
  176. data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
  177. data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
  178. data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
  179. data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
  180. data/vendor/assets/plugins/plugins/visualblocks/plugin.js +86 -0
  181. data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +1 -0
  182. data/vendor/assets/plugins/plugins/visualchars/plugin.js +88 -0
  183. data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +1 -0
  184. data/vendor/assets/plugins/plugins/wordcount/plugin.js +69 -0
  185. data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +1 -0
  186. data/vendor/assets/skins/skins/lightgray/content.inline.min.css +1 -0
  187. data/vendor/assets/skins/skins/lightgray/content.min.css +1 -0
  188. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
  189. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +62 -0
  190. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  191. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
  192. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
  193. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +63 -0
  194. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
  195. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
  196. data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
  197. data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
  198. data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
  199. data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
  200. data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +1 -0
  201. data/vendor/assets/skins/skins/lightgray/skin.min.css +1 -0
  202. data/vendor/assets/stylesheets/mirador-combined.css +3969 -0
  203. data/vendor/assets/stylesheets/mirador.css +11 -0
  204. data/vendor/assets/themes/themes/modern/theme.js +617 -0
  205. data/vendor/assets/themes/themes/modern/theme.min.js +1 -0
  206. metadata +318 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Plugin.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /**
12
+ * This class contains the tinymce plugin logic for the paste plugin.
13
+ *
14
+ * @class tinymce.pasteplugin.Plugin
15
+ * @private
16
+ */
17
+ define("tinymce/pasteplugin/Plugin", [
18
+ "tinymce/PluginManager",
19
+ "tinymce/pasteplugin/Clipboard",
20
+ "tinymce/pasteplugin/WordFilter",
21
+ "tinymce/pasteplugin/Quirks"
22
+ ], function(PluginManager, Clipboard, WordFilter, Quirks) {
23
+ var userIsInformed;
24
+
25
+ PluginManager.add('paste', function(editor) {
26
+ var self = this, clipboard, settings = editor.settings;
27
+
28
+ function togglePlainTextPaste() {
29
+ if (clipboard.pasteFormat == "text") {
30
+ this.active(false);
31
+ clipboard.pasteFormat = "html";
32
+ } else {
33
+ clipboard.pasteFormat = "text";
34
+ this.active(true);
35
+
36
+ if (!userIsInformed) {
37
+ editor.windowManager.alert(
38
+ 'Paste is now in plain text mode. Contents will now ' +
39
+ 'be pasted as plain text until you toggle this option off.'
40
+ );
41
+
42
+ userIsInformed = true;
43
+ }
44
+ }
45
+ }
46
+
47
+ self.clipboard = clipboard = new Clipboard(editor);
48
+ self.quirks = new Quirks(editor);
49
+ self.wordFilter = new WordFilter(editor);
50
+
51
+ if (editor.settings.paste_as_text) {
52
+ self.clipboard.pasteFormat = "text";
53
+ }
54
+
55
+ if (settings.paste_preprocess) {
56
+ editor.on('PastePreProcess', function(e) {
57
+ settings.paste_preprocess.call(self, self, e);
58
+ });
59
+ }
60
+
61
+ if (settings.paste_postprocess) {
62
+ editor.on('PastePostProcess', function(e) {
63
+ settings.paste_postprocess.call(self, self, e);
64
+ });
65
+ }
66
+
67
+ editor.addCommand('mceInsertClipboardContent', function(ui, value) {
68
+ if (value.content) {
69
+ self.clipboard.pasteHtml(value.content);
70
+ }
71
+
72
+ if (value.text) {
73
+ self.clipboard.pasteText(value.text);
74
+ }
75
+ });
76
+
77
+ // Block all drag/drop events
78
+ if (editor.paste_block_drop) {
79
+ editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
80
+ e.preventDefault();
81
+ e.stopPropagation();
82
+ });
83
+ }
84
+
85
+ // Prevent users from dropping data images on Gecko
86
+ if (!editor.settings.paste_data_images) {
87
+ editor.on('drop', function(e) {
88
+ var dataTransfer = e.dataTransfer;
89
+
90
+ if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
91
+ e.preventDefault();
92
+ }
93
+ });
94
+ }
95
+
96
+ editor.addButton('pastetext', {
97
+ icon: 'pastetext',
98
+ tooltip: 'Paste as text',
99
+ onclick: togglePlainTextPaste,
100
+ active: self.clipboard.pasteFormat == "text"
101
+ });
102
+
103
+ editor.addMenuItem('pastetext', {
104
+ text: 'Paste as text',
105
+ selectable: true,
106
+ active: clipboard.pasteFormat,
107
+ onclick: togglePlainTextPaste
108
+ });
109
+ });
110
+ });
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Quirks.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /**
12
+ * This class contains various fixes for browsers. These issues can not be feature
13
+ * detected since we have no direct control over the clipboard. However we might be able
14
+ * to remove some of these fixes once the browsers gets updated/fixed.
15
+ *
16
+ * @class tinymce.pasteplugin.Quirks
17
+ * @private
18
+ */
19
+ define("tinymce/pasteplugin/Quirks", [
20
+ "tinymce/Env",
21
+ "tinymce/util/Tools",
22
+ "tinymce/pasteplugin/WordFilter",
23
+ "tinymce/pasteplugin/Utils"
24
+ ], function(Env, Tools, WordFilter, Utils) {
25
+ "use strict";
26
+
27
+ return function(editor) {
28
+ function addPreProcessFilter(filterFunc) {
29
+ editor.on('BeforePastePreProcess', function(e) {
30
+ e.content = filterFunc(e.content);
31
+ });
32
+ }
33
+
34
+ /**
35
+ * Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
36
+ * block element when pasting from word. This removes those elements.
37
+ *
38
+ * This:
39
+ * <p>a</p><br><p>b</p>
40
+ *
41
+ * Becomes:
42
+ * <p>a</p><p>b</p>
43
+ */
44
+ function removeExplorerBrElementsAfterBlocks(html) {
45
+ // Only filter word specific content
46
+ if (!WordFilter.isWordContent(html)) {
47
+ return html;
48
+ }
49
+
50
+ // Produce block regexp based on the block elements in schema
51
+ var blockElements = [];
52
+
53
+ Tools.each(editor.schema.getBlockElements(), function(block, blockName) {
54
+ blockElements.push(blockName);
55
+ });
56
+
57
+ var explorerBlocksRegExp = new RegExp(
58
+ '(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*',
59
+ 'g'
60
+ );
61
+
62
+ // Remove BR:s from: <BLOCK>X</BLOCK><BR>
63
+ html = Utils.filter(html, [
64
+ [explorerBlocksRegExp, '$1']
65
+ ]);
66
+
67
+ // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
68
+ html = Utils.filter(html, [
69
+ [/<br><br>/g, '<BR><BR>'], // Replace multiple BR elements with uppercase BR to keep them intact
70
+ [/<br>/g, ' '], // Replace single br elements with space since they are word wrap BR:s
71
+ [/<BR><BR>/g, '<br>'] // Replace back the double brs but into a single BR
72
+ ]);
73
+
74
+ return html;
75
+ }
76
+
77
+ /**
78
+ * WebKit has a nasty bug where the all computed styles gets added to style attributes when copy/pasting contents.
79
+ * This fix solves that by simply removing the whole style attribute.
80
+ *
81
+ * The paste_webkit_styles option can be set to specify what to keep:
82
+ * paste_webkit_styles: "none" // Keep no styles
83
+ * paste_webkit_styles: "all", // Keep all of them
84
+ * paste_webkit_styles: "font-weight color" // Keep specific ones
85
+ *
86
+ * @param {String} content Content that needs to be processed.
87
+ * @return {String} Processed contents.
88
+ */
89
+ function removeWebKitStyles(content) {
90
+ // Passthrough all styles from Word and let the WordFilter handle that junk
91
+ if (WordFilter.isWordContent(content)) {
92
+ return content;
93
+ }
94
+
95
+ // Filter away styles that isn't matching the target node
96
+ var webKitStyles = editor.settings.paste_webkit_styles;
97
+
98
+ if (editor.settings.paste_remove_styles_if_webkit === false || webKitStyles == "all") {
99
+ return content;
100
+ }
101
+
102
+ if (webKitStyles) {
103
+ webKitStyles = webKitStyles.split(/[, ]/);
104
+ }
105
+
106
+ // Keep specific styles that doesn't match the current node computed style
107
+ if (webKitStyles) {
108
+ var dom = editor.dom, node = editor.selection.getNode();
109
+
110
+ content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function(all, before, value, after) {
111
+ var inputStyles = dom.parseStyle(value, 'span'), outputStyles = {};
112
+
113
+ if (webKitStyles === "none") {
114
+ return before + after;
115
+ }
116
+
117
+ for (var i = 0; i < webKitStyles.length; i++) {
118
+ var inputValue = inputStyles[webKitStyles[i]], currentValue = dom.getStyle(node, webKitStyles[i], true);
119
+
120
+ if (/color/.test(webKitStyles[i])) {
121
+ inputValue = dom.toHex(inputValue);
122
+ currentValue = dom.toHex(currentValue);
123
+ }
124
+
125
+ if (currentValue != inputValue) {
126
+ outputStyles[webKitStyles[i]] = inputValue;
127
+ }
128
+ }
129
+
130
+ outputStyles = dom.serializeStyle(outputStyles, 'span');
131
+ if (outputStyles) {
132
+ return before + ' style="' + outputStyles + '"' + after;
133
+ }
134
+
135
+ return before + after;
136
+ });
137
+ } else {
138
+ // Remove all external styles
139
+ content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
140
+ }
141
+
142
+ // Keep internal styles
143
+ content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function(all, before, value, after) {
144
+ return before + ' style="' + value + '"' + after;
145
+ });
146
+
147
+ return content;
148
+ }
149
+
150
+ // Sniff browsers and apply fixes since we can't feature detect
151
+ if (Env.webkit) {
152
+ addPreProcessFilter(removeWebKitStyles);
153
+ }
154
+
155
+ if (Env.ie) {
156
+ addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
157
+ }
158
+ };
159
+ });
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Utils.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /**
12
+ * This class contails various utility functions for the paste plugin.
13
+ *
14
+ * @class tinymce.pasteplugin.Clipboard
15
+ * @private
16
+ */
17
+ define("tinymce/pasteplugin/Utils", [
18
+ "tinymce/util/Tools",
19
+ "tinymce/html/DomParser",
20
+ "tinymce/html/Schema"
21
+ ], function(Tools, DomParser, Schema) {
22
+ function filter(content, items) {
23
+ Tools.each(items, function(v) {
24
+ if (v.constructor == RegExp) {
25
+ content = content.replace(v, '');
26
+ } else {
27
+ content = content.replace(v[0], v[1]);
28
+ }
29
+ });
30
+
31
+ return content;
32
+ }
33
+
34
+ /**
35
+ * Gets the innerText of the specified element. It will handle edge cases
36
+ * and works better than textContent on Gecko.
37
+ *
38
+ * @param {String} html HTML string to get text from.
39
+ * @return {String} String of text with line feeds.
40
+ */
41
+ function innerText(html) {
42
+ var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
43
+ var shortEndedElements = schema.getShortEndedElements();
44
+ var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
45
+ var blockElements = schema.getBlockElements();
46
+
47
+ function walk(node) {
48
+ var name = node.name, currentNode = node;
49
+
50
+ if (name === 'br') {
51
+ text += '\n';
52
+ return;
53
+ }
54
+
55
+ // img/input/hr
56
+ if (shortEndedElements[name]) {
57
+ text += ' ';
58
+ }
59
+
60
+ // Ingore script, video contents
61
+ if (ignoreElements[name]) {
62
+ text += ' ';
63
+ return;
64
+ }
65
+
66
+ if (node.type == 3) {
67
+ text += node.value;
68
+ }
69
+
70
+ // Walk all children
71
+ if (!node.shortEnded) {
72
+ if ((node = node.firstChild)) {
73
+ do {
74
+ walk(node);
75
+ } while ((node = node.next));
76
+ }
77
+ }
78
+
79
+ // Add \n or \n\n for blocks or P
80
+ if (blockElements[name] && currentNode.next) {
81
+ text += '\n';
82
+
83
+ if (name == 'p') {
84
+ text += '\n';
85
+ }
86
+ }
87
+ }
88
+
89
+ html = filter(html, [
90
+ /<!\[[^\]]+\]>/g // Conditional comments
91
+ ]);
92
+
93
+ walk(domParser.parse(html));
94
+
95
+ return text;
96
+ }
97
+
98
+ /**
99
+ * Trims the specified HTML by removing all WebKit fragments, all elements wrapping the body trailing BR elements etc.
100
+ *
101
+ * @param {String} html Html string to trim contents on.
102
+ * @return {String} Html contents that got trimmed.
103
+ */
104
+ function trimHtml(html) {
105
+ function trimSpaces(all, s1, s2) {
106
+ // WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags,
107
+ // including the spans with inline styles created on paste
108
+ if (!s1 && !s2) {
109
+ return ' ';
110
+ }
111
+
112
+ return '\u00a0';
113
+ }
114
+
115
+ html = filter(html, [
116
+ /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g, // Remove anything but the contents within the BODY element
117
+ /<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
118
+ [/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
119
+ /<br>$/i // Trailing BR elements
120
+ ]);
121
+
122
+ return html;
123
+ }
124
+
125
+ return {
126
+ filter: filter,
127
+ innerText: innerText,
128
+ trimHtml: trimHtml
129
+ };
130
+ });
@@ -0,0 +1,493 @@
1
+ /**
2
+ * WordFilter.js
3
+ *
4
+ * Copyright, Moxiecode Systems AB
5
+ * Released under LGPL License.
6
+ *
7
+ * License: http://www.tinymce.com/license
8
+ * Contributing: http://www.tinymce.com/contributing
9
+ */
10
+
11
+ /**
12
+ * This class parses word HTML into proper TinyMCE markup.
13
+ *
14
+ * @class tinymce.pasteplugin.Quirks
15
+ * @private
16
+ */
17
+ define("tinymce/pasteplugin/WordFilter", [
18
+ "tinymce/util/Tools",
19
+ "tinymce/html/DomParser",
20
+ "tinymce/html/Schema",
21
+ "tinymce/html/Serializer",
22
+ "tinymce/html/Node",
23
+ "tinymce/pasteplugin/Utils"
24
+ ], function(Tools, DomParser, Schema, Serializer, Node, Utils) {
25
+ /**
26
+ * Checks if the specified content is from any of the following sources: MS Word/Office 365/Google docs.
27
+ */
28
+ function isWordContent(content) {
29
+ return (
30
+ (/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content) ||
31
+ (/class="OutlineElement/).test(content) ||
32
+ (/id="?docs\-internal\-guid\-/.test(content))
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Checks if the specified text starts with "1. " or "a. " etc.
38
+ */
39
+ function isNumericList(text) {
40
+ var found, patterns;
41
+
42
+ patterns = [
43
+ /^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
44
+ /^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
45
+ /^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
46
+ /^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
47
+ /^[0-9]+\.[ \u00a0]/, // Numeric lists
48
+ /^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, // Japanese
49
+ /^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ // Chinese
50
+ ];
51
+
52
+ text = text.replace(/^[\u00a0 ]+/, '');
53
+
54
+ Tools.each(patterns, function(pattern) {
55
+ if (pattern.test(text)) {
56
+ found = true;
57
+ return false;
58
+ }
59
+ });
60
+
61
+ return found;
62
+ }
63
+
64
+ function isBulletList(text) {
65
+ return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u00d8\u25CF]\s*/.test(text);
66
+ }
67
+
68
+ function WordFilter(editor) {
69
+ var settings = editor.settings;
70
+
71
+ editor.on('BeforePastePreProcess', function(e) {
72
+ var content = e.content, retainStyleProperties, validStyles;
73
+
74
+ retainStyleProperties = settings.paste_retain_style_properties;
75
+ if (retainStyleProperties) {
76
+ validStyles = Tools.makeMap(retainStyleProperties.split(/[, ]/));
77
+ }
78
+
79
+ /**
80
+ * Converts fake bullet and numbered lists to real semantic OL/UL.
81
+ *
82
+ * @param {tinymce.html.Node} node Root node to convert children of.
83
+ */
84
+ function convertFakeListsToProperLists(node) {
85
+ var currentListNode, prevListNode, lastLevel = 1;
86
+
87
+ function getText(node) {
88
+ var txt = '';
89
+
90
+ if (node.type === 3) {
91
+ return node.value;
92
+ }
93
+
94
+ if ((node = node.firstChild)) {
95
+ do {
96
+ txt += getText(node);
97
+ } while ((node = node.next));
98
+ }
99
+
100
+ return txt;
101
+ }
102
+
103
+ function trimListStart(node, regExp) {
104
+ if (node.type === 3) {
105
+ if (regExp.test(node.value)) {
106
+ node.value = node.value.replace(regExp, '');
107
+ return false;
108
+ }
109
+ }
110
+
111
+ if ((node = node.firstChild)) {
112
+ do {
113
+ if (!trimListStart(node, regExp)) {
114
+ return false;
115
+ }
116
+ } while ((node = node.next));
117
+ }
118
+
119
+ return true;
120
+ }
121
+
122
+ function removeIgnoredNodes(node) {
123
+ if (node._listIgnore) {
124
+ node.remove();
125
+ return;
126
+ }
127
+
128
+ if ((node = node.firstChild)) {
129
+ do {
130
+ removeIgnoredNodes(node);
131
+ } while ((node = node.next));
132
+ }
133
+ }
134
+
135
+ function convertParagraphToLi(paragraphNode, listName, start) {
136
+ var level = paragraphNode._listLevel || lastLevel;
137
+
138
+ // Handle list nesting
139
+ if (level != lastLevel) {
140
+ if (level < lastLevel) {
141
+ // Move to parent list
142
+ if (currentListNode) {
143
+ currentListNode = currentListNode.parent.parent;
144
+ }
145
+ } else {
146
+ // Create new list
147
+ prevListNode = currentListNode;
148
+ currentListNode = null;
149
+ }
150
+ }
151
+
152
+ if (!currentListNode || currentListNode.name != listName) {
153
+ prevListNode = prevListNode || currentListNode;
154
+ currentListNode = new Node(listName, 1);
155
+
156
+ if (start > 1) {
157
+ currentListNode.attr('start', '' + start);
158
+ }
159
+
160
+ paragraphNode.wrap(currentListNode);
161
+ } else {
162
+ currentListNode.append(paragraphNode);
163
+ }
164
+
165
+ paragraphNode.name = 'li';
166
+
167
+ // Append list to previous list if it exists
168
+ if (level > lastLevel && prevListNode) {
169
+ prevListNode.lastChild.append(currentListNode);
170
+ }
171
+
172
+ lastLevel = level;
173
+
174
+ // Remove start of list item "1. " or "&middot; " etc
175
+ removeIgnoredNodes(paragraphNode);
176
+ trimListStart(paragraphNode, /^\u00a0+/);
177
+ trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u00d8\u25CF]|\w+\.)/);
178
+ trimListStart(paragraphNode, /^\u00a0+/);
179
+ }
180
+
181
+ // Build a list of all root level elements before we start
182
+ // altering them in the loop below.
183
+ var elements = [], child = node.firstChild;
184
+ while (typeof child !== 'undefined' && child !== null) {
185
+ elements.push(child);
186
+
187
+ child = child.walk();
188
+ if (child !== null) {
189
+ while (typeof child !== 'undefined' && child.parent !== node) {
190
+ child = child.walk();
191
+ }
192
+ }
193
+ }
194
+
195
+ for (var i = 0; i < elements.length; i++) {
196
+ node = elements[i];
197
+
198
+ if (node.name == 'p' && node.firstChild) {
199
+ // Find first text node in paragraph
200
+ var nodeText = getText(node);
201
+
202
+ // Detect unordered lists look for bullets
203
+ if (isBulletList(nodeText)) {
204
+ convertParagraphToLi(node, 'ul');
205
+ continue;
206
+ }
207
+
208
+ // Detect ordered lists 1., a. or ixv.
209
+ if (isNumericList(nodeText)) {
210
+ // Parse OL start number
211
+ var matches = /([0-9]+)\./.exec(nodeText);
212
+ var start = 1;
213
+ if (matches) {
214
+ start = parseInt(matches[1], 10);
215
+ }
216
+
217
+ convertParagraphToLi(node, 'ol', start);
218
+ continue;
219
+ }
220
+
221
+ // Convert paragraphs marked as lists but doesn't look like anything
222
+ if (node._listLevel) {
223
+ convertParagraphToLi(node, 'ul', 1);
224
+ continue;
225
+ }
226
+
227
+ currentListNode = null;
228
+ } else {
229
+ // If the root level element isn't a p tag which can be
230
+ // processed by convertParagraphToLi, it interrupts the
231
+ // lists, causing a new list to start instead of having
232
+ // elements from the next list inserted above this tag.
233
+ prevListNode = currentListNode;
234
+ currentListNode = null;
235
+ }
236
+ }
237
+ }
238
+
239
+ function filterStyles(node, styleValue) {
240
+ var outputStyles = {}, matches, styles = editor.dom.parseStyle(styleValue);
241
+
242
+ Tools.each(styles, function(value, name) {
243
+ // Convert various MS styles to W3C styles
244
+ switch (name) {
245
+ case 'mso-list':
246
+ // Parse out list indent level for lists
247
+ matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
248
+ if (matches) {
249
+ node._listLevel = parseInt(matches[1], 10);
250
+ }
251
+
252
+ // Remove these nodes <span style="mso-list:Ignore">o</span>
253
+ // Since the span gets removed we mark the text node and the span
254
+ if (/Ignore/i.test(value) && node.firstChild) {
255
+ node._listIgnore = true;
256
+ node.firstChild._listIgnore = true;
257
+ }
258
+
259
+ break;
260
+
261
+ case "horiz-align":
262
+ name = "text-align";
263
+ break;
264
+
265
+ case "vert-align":
266
+ name = "vertical-align";
267
+ break;
268
+
269
+ case "font-color":
270
+ case "mso-foreground":
271
+ name = "color";
272
+ break;
273
+
274
+ case "mso-background":
275
+ case "mso-highlight":
276
+ name = "background";
277
+ break;
278
+
279
+ case "font-weight":
280
+ case "font-style":
281
+ if (value != "normal") {
282
+ outputStyles[name] = value;
283
+ }
284
+ return;
285
+
286
+ case "mso-element":
287
+ // Remove track changes code
288
+ if (/^(comment|comment-list)$/i.test(value)) {
289
+ node.remove();
290
+ return;
291
+ }
292
+
293
+ break;
294
+ }
295
+
296
+ if (name.indexOf('mso-comment') === 0) {
297
+ node.remove();
298
+ return;
299
+ }
300
+
301
+ // Never allow mso- prefixed names
302
+ if (name.indexOf('mso-') === 0) {
303
+ return;
304
+ }
305
+
306
+ // Output only valid styles
307
+ if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
308
+ outputStyles[name] = value;
309
+ }
310
+ });
311
+
312
+ // Convert bold style to "b" element
313
+ if (/(bold)/i.test(outputStyles["font-weight"])) {
314
+ delete outputStyles["font-weight"];
315
+ node.wrap(new Node("b", 1));
316
+ }
317
+
318
+ // Convert italic style to "i" element
319
+ if (/(italic)/i.test(outputStyles["font-style"])) {
320
+ delete outputStyles["font-style"];
321
+ node.wrap(new Node("i", 1));
322
+ }
323
+
324
+ // Serialize the styles and see if there is something left to keep
325
+ outputStyles = editor.dom.serializeStyle(outputStyles, node.name);
326
+ if (outputStyles) {
327
+ return outputStyles;
328
+ }
329
+
330
+ return null;
331
+ }
332
+
333
+ if (settings.paste_enable_default_filters === false) {
334
+ return;
335
+ }
336
+
337
+ // Detect is the contents is Word junk HTML
338
+ if (isWordContent(e.content)) {
339
+ e.wordContent = true; // Mark it for other processors
340
+
341
+ // Remove basic Word junk
342
+ content = Utils.filter(content, [
343
+ // Word comments like conditional comments etc
344
+ /<!--[\s\S]+?-->/gi,
345
+
346
+ // Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
347
+ // MS Office namespaced tags, and a few other tags
348
+ /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
349
+
350
+ // Convert <s> into <strike> for line-though
351
+ [/<(\/?)s>/gi, "<$1strike>"],
352
+
353
+ // Replace nsbp entites to char since it's easier to handle
354
+ [/&nbsp;/gi, "\u00a0"],
355
+
356
+ // Convert <span style="mso-spacerun:yes">___</span> to string of alternating
357
+ // breaking/non-breaking spaces of same length
358
+ [/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
359
+ function(str, spaces) {
360
+ return (spaces.length > 0) ?
361
+ spaces.replace(/./, " ").slice(Math.floor(spaces.length / 2)).split("").join("\u00a0") : "";
362
+ }
363
+ ]
364
+ ]);
365
+
366
+ var validElements = settings.paste_word_valid_elements;
367
+ if (!validElements) {
368
+ validElements = (
369
+ '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
370
+ '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' +
371
+ 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'
372
+ );
373
+ }
374
+
375
+ // Setup strict schema
376
+ var schema = new Schema({
377
+ valid_elements: validElements,
378
+ valid_children: '-li[p]'
379
+ });
380
+
381
+ // Add style/class attribute to all element rules since the user might have removed them from
382
+ // paste_word_valid_elements config option and we need to check them for properties
383
+ Tools.each(schema.elements, function(rule) {
384
+ if (!rule.attributes["class"]) {
385
+ rule.attributes["class"] = {};
386
+ rule.attributesOrder.push("class");
387
+ }
388
+
389
+ if (!rule.attributes.style) {
390
+ rule.attributes.style = {};
391
+ rule.attributesOrder.push("style");
392
+ }
393
+ });
394
+
395
+ // Parse HTML into DOM structure
396
+ var domParser = new DomParser({}, schema);
397
+
398
+ // Filter styles to remove "mso" specific styles and convert some of them
399
+ domParser.addAttributeFilter('style', function(nodes) {
400
+ var i = nodes.length, node;
401
+
402
+ while (i--) {
403
+ node = nodes[i];
404
+ node.attr('style', filterStyles(node, node.attr('style')));
405
+
406
+ // Remove pointess spans
407
+ if (node.name == 'span' && node.parent && !node.attributes.length) {
408
+ node.unwrap();
409
+ }
410
+ }
411
+ });
412
+
413
+ // Check the class attribute for comments or del items and remove those
414
+ domParser.addAttributeFilter('class', function(nodes) {
415
+ var i = nodes.length, node, className;
416
+
417
+ while (i--) {
418
+ node = nodes[i];
419
+
420
+ className = node.attr('class');
421
+ if (/^(MsoCommentReference|MsoCommentText|msoDel|MsoCaption)$/i.test(className)) {
422
+ node.remove();
423
+ }
424
+
425
+ node.attr('class', null);
426
+ }
427
+ });
428
+
429
+ // Remove all del elements since we don't want the track changes code in the editor
430
+ domParser.addNodeFilter('del', function(nodes) {
431
+ var i = nodes.length;
432
+
433
+ while (i--) {
434
+ nodes[i].remove();
435
+ }
436
+ });
437
+
438
+ // Keep some of the links and anchors
439
+ domParser.addNodeFilter('a', function(nodes) {
440
+ var i = nodes.length, node, href, name;
441
+
442
+ while (i--) {
443
+ node = nodes[i];
444
+ href = node.attr('href');
445
+ name = node.attr('name');
446
+
447
+ if (href && href.indexOf('#_msocom_') != -1) {
448
+ node.remove();
449
+ continue;
450
+ }
451
+
452
+ if (href && href.indexOf('file://') === 0) {
453
+ href = href.split('#')[1];
454
+ if (href) {
455
+ href = '#' + href;
456
+ }
457
+ }
458
+
459
+ if (!href && !name) {
460
+ node.unwrap();
461
+ } else {
462
+ // Remove all named anchors that aren't specific to TOC, Footnotes or Endnotes
463
+ if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) {
464
+ node.unwrap();
465
+ continue;
466
+ }
467
+
468
+ node.attr({
469
+ href: href,
470
+ name: name
471
+ });
472
+ }
473
+ }
474
+ });
475
+
476
+ // Parse into DOM structure
477
+ var rootNode = domParser.parse(content);
478
+
479
+ // Process DOM
480
+ if (settings.paste_convert_word_fake_lists !== false) {
481
+ convertFakeListsToProperLists(rootNode);
482
+ }
483
+
484
+ // Serialize DOM back to HTML
485
+ e.content = new Serializer({}, schema).serialize(rootNode);
486
+ }
487
+ });
488
+ }
489
+
490
+ WordFilter.isWordContent = isWordContent;
491
+
492
+ return WordFilter;
493
+ });