mirador_rails 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/app/controllers/mirador_rails/locales_controller.rb +10 -0
  4. data/config/routes.rb +7 -0
  5. data/lib/mirador_rails/exceptions.rb +6 -0
  6. data/lib/mirador_rails/locale.rb +24 -0
  7. data/lib/mirador_rails/version.rb +1 -1
  8. data/lib/mirador_rails.rb +9 -2
  9. data/mirador_rails.gemspec +3 -0
  10. data/tasks/mirador_rails.rake +44 -10
  11. data/vendor/assets/images/border_type_4.png +0 -0
  12. data/vendor/assets/images/border_type_5.png +0 -0
  13. data/vendor/assets/javascripts/mirador/mirador.js.erb +20105 -0
  14. data/vendor/assets/javascripts/mirador.js +4 -1
  15. data/vendor/assets/locales/de/translation.json +3 -0
  16. data/vendor/assets/locales/en/translation.json +11 -7
  17. data/vendor/assets/locales/ko/translation.json +18 -9
  18. data/vendor/assets/stylesheets/enhancements.scss +36 -0
  19. data/vendor/assets/stylesheets/mirador-combined.css +1488 -1642
  20. data/vendor/assets/stylesheets/mirador.css +1 -0
  21. metadata +52 -174
  22. data/vendor/assets/javascripts/mirador.min.js +0 -89
  23. data/vendor/assets/javascripts/mirador.min.js.map +0 -1
  24. data/vendor/assets/plugins/plugins/advlist/plugin.js +0 -97
  25. data/vendor/assets/plugins/plugins/advlist/plugin.min.js +0 -1
  26. data/vendor/assets/plugins/plugins/anchor/plugin.js +0 -45
  27. data/vendor/assets/plugins/plugins/anchor/plugin.min.js +0 -1
  28. data/vendor/assets/plugins/plugins/autolink/plugin.js +0 -194
  29. data/vendor/assets/plugins/plugins/autolink/plugin.min.js +0 -1
  30. data/vendor/assets/plugins/plugins/autoresize/plugin.js +0 -152
  31. data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +0 -1
  32. data/vendor/assets/plugins/plugins/autosave/plugin.js +0 -165
  33. data/vendor/assets/plugins/plugins/autosave/plugin.min.js +0 -1
  34. data/vendor/assets/plugins/plugins/bbcode/plugin.js +0 -123
  35. data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +0 -1
  36. data/vendor/assets/plugins/plugins/charmap/plugin.js +0 -370
  37. data/vendor/assets/plugins/plugins/charmap/plugin.min.js +0 -1
  38. data/vendor/assets/plugins/plugins/code/plugin.js +0 -60
  39. data/vendor/assets/plugins/plugins/code/plugin.min.js +0 -1
  40. data/vendor/assets/plugins/plugins/colorpicker/plugin.js +0 -112
  41. data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +0 -1
  42. data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +0 -118
  43. data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
  44. data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
  45. data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
  46. data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
  47. data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
  48. data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
  49. data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
  50. data/vendor/assets/plugins/plugins/compat3x/plugin.js +0 -297
  51. data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +0 -1
  52. data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +0 -542
  53. data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +0 -70
  54. data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +0 -210
  55. data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +0 -164
  56. data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +0 -252
  57. data/vendor/assets/plugins/plugins/contextmenu/plugin.js +0 -87
  58. data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +0 -1
  59. data/vendor/assets/plugins/plugins/directionality/plugin.js +0 -64
  60. data/vendor/assets/plugins/plugins/directionality/plugin.min.js +0 -1
  61. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
  62. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
  63. data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  64. data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  65. data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
  66. data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
  67. data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
  68. data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
  69. data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  70. data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
  71. data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
  72. data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
  73. data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  74. data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
  75. data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
  76. data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
  77. data/vendor/assets/plugins/plugins/emoticons/plugin.js +0 -65
  78. data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +0 -1
  79. data/vendor/assets/plugins/plugins/example/dialog.html +0 -8
  80. data/vendor/assets/plugins/plugins/example/plugin.js +0 -68
  81. data/vendor/assets/plugins/plugins/example/plugin.min.js +0 -1
  82. data/vendor/assets/plugins/plugins/example_dependency/plugin.js +0 -22
  83. data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +0 -1
  84. data/vendor/assets/plugins/plugins/fullpage/plugin.js +0 -490
  85. data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +0 -1
  86. data/vendor/assets/plugins/plugins/fullscreen/plugin.js +0 -136
  87. data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +0 -1
  88. data/vendor/assets/plugins/plugins/hr/plugin.js +0 -30
  89. data/vendor/assets/plugins/plugins/hr/plugin.min.js +0 -1
  90. data/vendor/assets/plugins/plugins/image/plugin.js +0 -439
  91. data/vendor/assets/plugins/plugins/image/plugin.min.js +0 -1
  92. data/vendor/assets/plugins/plugins/importcss/plugin.js +0 -195
  93. data/vendor/assets/plugins/plugins/importcss/plugin.min.js +0 -1
  94. data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +0 -121
  95. data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +0 -1
  96. data/vendor/assets/plugins/plugins/layer/plugin.js +0 -225
  97. data/vendor/assets/plugins/plugins/layer/plugin.min.js +0 -1
  98. data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +0 -211
  99. data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +0 -1
  100. data/vendor/assets/plugins/plugins/link/plugin.js +0 -400
  101. data/vendor/assets/plugins/plugins/link/plugin.min.js +0 -1
  102. data/vendor/assets/plugins/plugins/lists/plugin.js +0 -791
  103. data/vendor/assets/plugins/plugins/lists/plugin.min.js +0 -1
  104. data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
  105. data/vendor/assets/plugins/plugins/media/plugin.js +0 -774
  106. data/vendor/assets/plugins/plugins/media/plugin.min.js +0 -1
  107. data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +0 -53
  108. data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +0 -1
  109. data/vendor/assets/plugins/plugins/noneditable/plugin.js +0 -540
  110. data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +0 -1
  111. data/vendor/assets/plugins/plugins/pagebreak/plugin.js +0 -88
  112. data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +0 -1
  113. data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +0 -634
  114. data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +0 -110
  115. data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +0 -159
  116. data/vendor/assets/plugins/plugins/paste/classes/Utils.js +0 -130
  117. data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +0 -493
  118. data/vendor/assets/plugins/plugins/paste/plugin.dev.js +0 -120
  119. data/vendor/assets/plugins/plugins/paste/plugin.js +0 -1625
  120. data/vendor/assets/plugins/plugins/paste/plugin.min.js +0 -1
  121. data/vendor/assets/plugins/plugins/preview/plugin.js +0 -88
  122. data/vendor/assets/plugins/plugins/preview/plugin.min.js +0 -1
  123. data/vendor/assets/plugins/plugins/print/plugin.js +0 -32
  124. data/vendor/assets/plugins/plugins/print/plugin.min.js +0 -1
  125. data/vendor/assets/plugins/plugins/save/plugin.js +0 -94
  126. data/vendor/assets/plugins/plugins/save/plugin.min.js +0 -1
  127. data/vendor/assets/plugins/plugins/searchreplace/plugin.js +0 -594
  128. data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +0 -1
  129. data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +0 -470
  130. data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +0 -436
  131. data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +0 -117
  132. data/vendor/assets/plugins/plugins/spellchecker/plugin.js +0 -996
  133. data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +0 -1
  134. data/vendor/assets/plugins/plugins/tabfocus/plugin.js +0 -120
  135. data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +0 -1
  136. data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +0 -176
  137. data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +0 -749
  138. data/vendor/assets/plugins/plugins/table/classes/Plugin.js +0 -422
  139. data/vendor/assets/plugins/plugins/table/classes/Quirks.js +0 -372
  140. data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +0 -864
  141. data/vendor/assets/plugins/plugins/table/plugin.dev.js +0 -118
  142. data/vendor/assets/plugins/plugins/table/plugin.js +0 -2680
  143. data/vendor/assets/plugins/plugins/table/plugin.min.js +0 -1
  144. data/vendor/assets/plugins/plugins/template/plugin.js +0 -262
  145. data/vendor/assets/plugins/plugins/template/plugin.min.js +0 -1
  146. data/vendor/assets/plugins/plugins/textcolor/plugin.js +0 -272
  147. data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +0 -1
  148. data/vendor/assets/plugins/plugins/textpattern/plugin.js +0 -268
  149. data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +0 -1
  150. data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +0 -135
  151. data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
  152. data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
  153. data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
  154. data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
  155. data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
  156. data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
  157. data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
  158. data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
  159. data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
  160. data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
  161. data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
  162. data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
  163. data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
  164. data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
  165. data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
  166. data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
  167. data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
  168. data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
  169. data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
  170. data/vendor/assets/plugins/plugins/visualblocks/plugin.js +0 -86
  171. data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +0 -1
  172. data/vendor/assets/plugins/plugins/visualchars/plugin.js +0 -88
  173. data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +0 -1
  174. data/vendor/assets/plugins/plugins/wordcount/plugin.js +0 -69
  175. data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +0 -1
  176. data/vendor/assets/skins/skins/lightgray/content.inline.min.css +0 -1
  177. data/vendor/assets/skins/skins/lightgray/content.min.css +0 -1
  178. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
  179. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +0 -62
  180. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  181. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
  182. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
  183. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +0 -63
  184. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
  185. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
  186. data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
  187. data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
  188. data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
  189. data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
  190. data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +0 -1
  191. data/vendor/assets/skins/skins/lightgray/skin.min.css +0 -1
  192. data/vendor/assets/themes/themes/modern/theme.js +0 -617
  193. data/vendor/assets/themes/themes/modern/theme.min.js +0 -1
@@ -1,634 +0,0 @@
1
- /**
2
- * Clipboard.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 logic for getting HTML contents out of the clipboard.
13
- *
14
- * We need to make a lot of ugly hacks to get the contents out of the clipboard since
15
- * the W3C Clipboard API is broken in all browsers that have it: Gecko/WebKit/Blink.
16
- * We might rewrite this the way those API:s stabilize. Browsers doesn't handle pasting
17
- * from applications like Word the same way as it does when pasting into a contentEditable area
18
- * so we need to do lots of extra work to try to get to this clipboard data.
19
- *
20
- * Current implementation steps:
21
- * 1. On keydown with paste keys Ctrl+V or Shift+Insert create
22
- * a paste bin element and move focus to that element.
23
- * 2. Wait for the browser to fire a "paste" event and get the contents out of the paste bin.
24
- * 3. Check if the paste was successful if true, process the HTML.
25
- * (4). If the paste was unsuccessful use IE execCommand, Clipboard API, document.dataTransfer old WebKit API etc.
26
- *
27
- * @class tinymce.pasteplugin.Clipboard
28
- * @private
29
- */
30
- define("tinymce/pasteplugin/Clipboard", [
31
- "tinymce/Env",
32
- "tinymce/util/VK",
33
- "tinymce/pasteplugin/Utils"
34
- ], function(Env, VK, Utils) {
35
- return function(editor) {
36
- var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0, draggingInternally = false;
37
- var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
38
-
39
- /**
40
- * Pastes the specified HTML. This means that the HTML is filtered and then
41
- * inserted at the current selection in the editor. It will also fire paste events
42
- * for custom user filtering.
43
- *
44
- * @param {String} html HTML code to paste into the current selection.
45
- */
46
- function pasteHtml(html) {
47
- var args, dom = editor.dom;
48
-
49
- args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
50
- args = editor.fire('PastePreProcess', args);
51
- html = args.content;
52
-
53
- if (!args.isDefaultPrevented()) {
54
- // User has bound PastePostProcess events then we need to pass it through a DOM node
55
- // This is not ideal but we don't want to let the browser mess up the HTML for example
56
- // some browsers add   to P tags etc
57
- if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
58
- // We need to attach the element to the DOM so Sizzle selectors work on the contents
59
- var tempBody = dom.add(editor.getBody(), 'div', {style: 'display:none'}, html);
60
- args = editor.fire('PastePostProcess', {node: tempBody});
61
- dom.remove(tempBody);
62
- html = args.node.innerHTML;
63
- }
64
-
65
- if (!args.isDefaultPrevented()) {
66
- editor.insertContent(html, {merge: editor.settings.paste_merge_formats !== false});
67
- }
68
- }
69
- }
70
-
71
- /**
72
- * Pastes the specified text. This means that the plain text is processed
73
- * and converted into BR and P elements. It will fire paste events for custom filtering.
74
- *
75
- * @param {String} text Text to paste as the current selection location.
76
- */
77
- function pasteText(text) {
78
- text = editor.dom.encode(text).replace(/\r\n/g, '\n');
79
-
80
- var startBlock = editor.dom.getParent(editor.selection.getStart(), editor.dom.isBlock);
81
-
82
- // Create start block html for example <p attr="value">
83
- var forcedRootBlockName = editor.settings.forced_root_block;
84
- var forcedRootBlockStartHtml;
85
- if (forcedRootBlockName) {
86
- forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
87
- forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
88
- }
89
-
90
- if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
91
- text = Utils.filter(text, [
92
- [/\n/g, "<br>"]
93
- ]);
94
- } else {
95
- text = Utils.filter(text, [
96
- [/\n\n/g, "</p>" + forcedRootBlockStartHtml],
97
- [/^(.*<\/p>)(<p>)$/, forcedRootBlockStartHtml + '$1'],
98
- [/\n/g, "<br />"]
99
- ]);
100
-
101
- if (text.indexOf('<p>') != -1) {
102
- text = forcedRootBlockStartHtml + text;
103
- }
104
- }
105
-
106
- pasteHtml(text);
107
- }
108
-
109
- /**
110
- * Creates a paste bin element as close as possible to the current caret location and places the focus inside that element
111
- * so that when the real paste event occurs the contents gets inserted into this element
112
- * instead of the current editor selection element.
113
- */
114
- function createPasteBin() {
115
- var dom = editor.dom, body = editor.getBody();
116
- var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
117
- var scrollContainer;
118
-
119
- lastRng = editor.selection.getRng();
120
-
121
- if (editor.inline) {
122
- scrollContainer = editor.selection.getScrollContainer();
123
-
124
- // Can't always rely on scrollTop returning a useful value.
125
- // It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable
126
- if (scrollContainer && scrollContainer.scrollTop > 0) {
127
- scrollTop = scrollContainer.scrollTop;
128
- }
129
- }
130
-
131
- /**
132
- * Returns the rect of the current caret if the caret is in an empty block before a
133
- * BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
134
- *
135
- * TODO: This might be useful in core.
136
- */
137
- function getCaretRect(rng) {
138
- var rects, textNode, node, container = rng.startContainer;
139
-
140
- rects = rng.getClientRects();
141
- if (rects.length) {
142
- return rects[0];
143
- }
144
-
145
- if (!rng.collapsed || container.nodeType != 1) {
146
- return;
147
- }
148
-
149
- node = container.childNodes[lastRng.startOffset];
150
-
151
- // Skip empty whitespace nodes
152
- while (node && node.nodeType == 3 && !node.data.length) {
153
- node = node.nextSibling;
154
- }
155
-
156
- if (!node) {
157
- return;
158
- }
159
-
160
- // Check if the location is |<br>
161
- // TODO: Might need to expand this to say |<table>
162
- if (node.tagName == 'BR') {
163
- textNode = dom.doc.createTextNode('\uFEFF');
164
- node.parentNode.insertBefore(textNode, node);
165
-
166
- rng = dom.createRng();
167
- rng.setStartBefore(textNode);
168
- rng.setEndAfter(textNode);
169
-
170
- rects = rng.getClientRects();
171
- dom.remove(textNode);
172
- }
173
-
174
- if (rects.length) {
175
- return rects[0];
176
- }
177
- }
178
-
179
- // Calculate top cordinate this is needed to avoid scrolling to top of document
180
- // We want the paste bin to be as close to the caret as possible to avoid scrolling
181
- if (lastRng.getClientRects) {
182
- var rect = getCaretRect(lastRng);
183
-
184
- if (rect) {
185
- // Client rects gets us closes to the actual
186
- // caret location in for example a wrapped paragraph block
187
- top = scrollTop + (rect.top - dom.getPos(body).y);
188
- } else {
189
- top = scrollTop;
190
-
191
- // Check if we can find a closer location by checking the range element
192
- var container = lastRng.startContainer;
193
- if (container) {
194
- if (container.nodeType == 3 && container.parentNode != body) {
195
- container = container.parentNode;
196
- }
197
-
198
- if (container.nodeType == 1) {
199
- top = dom.getPos(container, scrollContainer || body).y;
200
- }
201
- }
202
- }
203
- }
204
-
205
- // Create a pastebin
206
- pasteBinElm = dom.add(editor.getBody(), 'div', {
207
- id: "mcepastebin",
208
- contentEditable: true,
209
- "data-mce-bogus": "all",
210
- style: 'position: absolute; top: ' + top + 'px;' +
211
- 'width: 10px; height: 10px; overflow: hidden; opacity: 0'
212
- }, pasteBinDefaultContent);
213
-
214
- // Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko
215
- if (Env.ie || Env.gecko) {
216
- dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
217
- }
218
-
219
- // Prevent focus events from bubbeling fixed FocusManager issues
220
- dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
221
- e.stopPropagation();
222
- });
223
-
224
- pasteBinElm.focus();
225
- editor.selection.select(pasteBinElm, true);
226
- }
227
-
228
- /**
229
- * Removes the paste bin if it exists.
230
- */
231
- function removePasteBin() {
232
- if (pasteBinElm) {
233
- var pasteBinClone;
234
-
235
- // WebKit/Blink might clone the div so
236
- // lets make sure we remove all clones
237
- // TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
238
- while ((pasteBinClone = editor.dom.get('mcepastebin'))) {
239
- editor.dom.remove(pasteBinClone);
240
- editor.dom.unbind(pasteBinClone);
241
- }
242
-
243
- if (lastRng) {
244
- editor.selection.setRng(lastRng);
245
- }
246
- }
247
-
248
- pasteBinElm = lastRng = null;
249
- }
250
-
251
- /**
252
- * Returns the contents of the paste bin as a HTML string.
253
- *
254
- * @return {String} Get the contents of the paste bin.
255
- */
256
- function getPasteBinHtml() {
257
- var html = '', pasteBinClones, i, clone, cloneHtml;
258
-
259
- // Since WebKit/Chrome might clone the paste bin when pasting
260
- // for example: <img style="float: right"> we need to check if any of them contains some useful html.
261
- // TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
262
- pasteBinClones = editor.dom.select('div[id=mcepastebin]');
263
- for (i = 0; i < pasteBinClones.length; i++) {
264
- clone = pasteBinClones[i];
265
-
266
- // Pasting plain text produces pastebins in pastebinds makes sence right!?
267
- if (clone.firstChild && clone.firstChild.id == 'mcepastebin') {
268
- clone = clone.firstChild;
269
- }
270
-
271
- cloneHtml = clone.innerHTML;
272
- if (html != pasteBinDefaultContent) {
273
- html += cloneHtml;
274
- }
275
- }
276
-
277
- return html;
278
- }
279
-
280
- /**
281
- * Gets various content types out of a datatransfer object.
282
- *
283
- * @param {DataTransfer} dataTransfer Event fired on paste.
284
- * @return {Object} Object with mime types and data for those mime types.
285
- */
286
- function getDataTransferItems(dataTransfer) {
287
- var data = {};
288
-
289
- if (dataTransfer) {
290
- // Use old WebKit/IE API
291
- if (dataTransfer.getData) {
292
- var legacyText = dataTransfer.getData('Text');
293
- if (legacyText && legacyText.length > 0) {
294
- data['text/plain'] = legacyText;
295
- }
296
- }
297
-
298
- if (dataTransfer.types) {
299
- for (var i = 0; i < dataTransfer.types.length; i++) {
300
- var contentType = dataTransfer.types[i];
301
- data[contentType] = dataTransfer.getData(contentType);
302
- }
303
- }
304
- }
305
-
306
- return data;
307
- }
308
-
309
- /**
310
- * Gets various content types out of the Clipboard API. It will also get the
311
- * plain text using older IE and WebKit API:s.
312
- *
313
- * @param {ClipboardEvent} clipboardEvent Event fired on paste.
314
- * @return {Object} Object with mime types and data for those mime types.
315
- */
316
- function getClipboardContent(clipboardEvent) {
317
- return getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
318
- }
319
-
320
- /**
321
- * Checks if the clipboard contains image data if it does it will take that data
322
- * and convert it into a data url image and paste that image at the caret location.
323
- *
324
- * @param {ClipboardEvent} e Paste/drop event object.
325
- * @param {DOMRange} rng Optional rng object to move selection to.
326
- * @return {Boolean} true/false if the image data was found or not.
327
- */
328
- function pasteImageData(e, rng) {
329
- var dataTransfer = e.clipboardData || e.dataTransfer;
330
-
331
- function processItems(items) {
332
- var i, item, reader;
333
-
334
- function pasteImage() {
335
- if (rng) {
336
- editor.selection.setRng(rng);
337
- rng = null;
338
- }
339
-
340
- pasteHtml('<img src="' + reader.result + '">');
341
- }
342
-
343
- if (items) {
344
- for (i = 0; i < items.length; i++) {
345
- item = items[i];
346
-
347
- if (/^image\/(jpeg|png|gif)$/.test(item.type)) {
348
- reader = new FileReader();
349
- reader.onload = pasteImage;
350
- reader.readAsDataURL(item.getAsFile ? item.getAsFile() : item);
351
-
352
- e.preventDefault();
353
- return true;
354
- }
355
- }
356
- }
357
- }
358
-
359
- if (editor.settings.paste_data_images && dataTransfer) {
360
- return processItems(dataTransfer.items) || processItems(dataTransfer.files);
361
- }
362
- }
363
-
364
- /**
365
- * Chrome on Android doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
366
- *
367
- * @param {Event} e Paste event object to check if it contains any data.
368
- * @return {Boolean} true/false if the clipboard is empty or not.
369
- */
370
- function isBrokenAndroidClipboardEvent(e) {
371
- var clipboardData = e.clipboardData;
372
-
373
- return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
374
- }
375
-
376
- function getCaretRangeFromEvent(e) {
377
- var doc = editor.getDoc(), rng, point;
378
-
379
- if (doc.caretPositionFromPoint) {
380
- point = doc.caretPositionFromPoint(e.clientX, e.clientY);
381
- rng = doc.createRange();
382
- rng.setStart(point.offsetNode, point.offset);
383
- rng.collapse(true);
384
- } else if (doc.caretRangeFromPoint) {
385
- rng = doc.caretRangeFromPoint(e.clientX, e.clientY);
386
- } else if (doc.body.createTextRange) {
387
- rng = doc.body.createTextRange();
388
-
389
- try {
390
- rng.moveToPoint(e.clientX, e.clientY);
391
- rng.collapse(true);
392
- } catch (ex) {
393
- // Append to top or bottom depending on drop location
394
- rng.collapse(e.clientY < doc.body.clientHeight);
395
- }
396
- }
397
-
398
- return rng;
399
- }
400
-
401
- function hasContentType(clipboardContent, mimeType) {
402
- return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
403
- }
404
-
405
- function isKeyboardPasteEvent(e) {
406
- return (VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45);
407
- }
408
-
409
- function registerEventHandlers() {
410
- editor.on('keydown', function(e) {
411
- function removePasteBinOnKeyUp(e) {
412
- // Ctrl+V or Shift+Insert
413
- if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
414
- removePasteBin();
415
- }
416
- }
417
-
418
- // Ctrl+V or Shift+Insert
419
- if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
420
- keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
421
-
422
- // Edge case on Safari on Mac where it doesn't handle Cmd+Shift+V correctly
423
- // it fires the keydown but no paste or keyup so we are left with a paste bin
424
- if (keyboardPastePlainTextState && Env.webkit && navigator.userAgent.indexOf('Version/') != -1) {
425
- return;
426
- }
427
-
428
- // Prevent undoManager keydown handler from making an undo level with the pastebin in it
429
- e.stopImmediatePropagation();
430
-
431
- keyboardPasteTimeStamp = new Date().getTime();
432
-
433
- // IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
434
- // so lets fake a paste event and let IE use the execCommand/dataTransfer methods
435
- if (Env.ie && keyboardPastePlainTextState) {
436
- e.preventDefault();
437
- editor.fire('paste', {ieFake: true});
438
- return;
439
- }
440
-
441
- removePasteBin();
442
- createPasteBin();
443
-
444
- // Remove pastebin if we get a keyup and no paste event
445
- // For example pasting a file in IE 11 will not produce a paste event
446
- editor.once('keyup', removePasteBinOnKeyUp);
447
- editor.once('paste', function() {
448
- editor.off('keyup', removePasteBinOnKeyUp);
449
- });
450
- }
451
- });
452
-
453
- editor.on('paste', function(e) {
454
- // Getting content from the Clipboard can take some time
455
- var clipboardTimer = new Date().getTime();
456
- var clipboardContent = getClipboardContent(e);
457
- var clipboardDelay = new Date().getTime() - clipboardTimer;
458
-
459
- var isKeyBoardPaste = (new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay) < 1000;
460
- var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
461
-
462
- keyboardPastePlainTextState = false;
463
-
464
- if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
465
- removePasteBin();
466
- return;
467
- }
468
-
469
- if (pasteImageData(e)) {
470
- removePasteBin();
471
- return;
472
- }
473
-
474
- // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
475
- if (!isKeyBoardPaste) {
476
- e.preventDefault();
477
- }
478
-
479
- // Try IE only method if paste isn't a keyboard paste
480
- if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
481
- createPasteBin();
482
-
483
- editor.dom.bind(pasteBinElm, 'paste', function(e) {
484
- e.stopPropagation();
485
- });
486
-
487
- editor.getDoc().execCommand('Paste', false, null);
488
- clipboardContent["text/html"] = getPasteBinHtml();
489
- }
490
-
491
- setTimeout(function() {
492
- var content;
493
-
494
- // Grab HTML from Clipboard API or paste bin as a fallback
495
- if (hasContentType(clipboardContent, 'text/html')) {
496
- content = clipboardContent['text/html'];
497
- } else {
498
- content = getPasteBinHtml();
499
-
500
- // If paste bin is empty try using plain text mode
501
- // since that is better than nothing right
502
- if (content == pasteBinDefaultContent) {
503
- plainTextMode = true;
504
- }
505
- }
506
-
507
- content = Utils.trimHtml(content);
508
-
509
- // WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
510
- // so we need to force plain text mode in this case
511
- if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
512
- plainTextMode = true;
513
- }
514
-
515
- removePasteBin();
516
-
517
- // If we got nothing from clipboard API and pastebin then we could try the last resort: plain/text
518
- if (!content.length) {
519
- plainTextMode = true;
520
- }
521
-
522
- // Grab plain text from Clipboard API or convert existing HTML to plain text
523
- if (plainTextMode) {
524
- // Use plain text contents from Clipboard API unless the HTML contains paragraphs then
525
- // we should convert the HTML to plain text since works better when pasting HTML/Word contents as plain text
526
- if (hasContentType(clipboardContent, 'text/plain') && content.indexOf('</p>') == -1) {
527
- content = clipboardContent['text/plain'];
528
- } else {
529
- content = Utils.innerText(content);
530
- }
531
- }
532
-
533
- // If the content is the paste bin default HTML then it was
534
- // impossible to get the cliboard data out.
535
- if (content == pasteBinDefaultContent) {
536
- if (!isKeyBoardPaste) {
537
- editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
538
- }
539
-
540
- return;
541
- }
542
-
543
- if (plainTextMode) {
544
- pasteText(content);
545
- } else {
546
- pasteHtml(content);
547
- }
548
- }, 0);
549
- });
550
-
551
- editor.on('dragstart dragend', function(e) {
552
- draggingInternally = e.type == 'dragstart';
553
- });
554
-
555
- editor.on('drop', function(e) {
556
- var rng = getCaretRangeFromEvent(e);
557
-
558
- if (e.isDefaultPrevented() || draggingInternally) {
559
- return;
560
- }
561
-
562
- if (pasteImageData(e, rng)) {
563
- return;
564
- }
565
-
566
- if (rng && editor.settings.paste_filter_drop !== false) {
567
- var dropContent = getDataTransferItems(e.dataTransfer);
568
- var content = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
569
-
570
- if (content) {
571
- e.preventDefault();
572
-
573
- editor.undoManager.transact(function() {
574
- if (dropContent['mce-internal']) {
575
- editor.execCommand('Delete');
576
- }
577
-
578
- editor.selection.setRng(rng);
579
-
580
- content = Utils.trimHtml(content);
581
-
582
- if (!dropContent['text/html']) {
583
- pasteText(content);
584
- } else {
585
- pasteHtml(content);
586
- }
587
- });
588
- }
589
- }
590
- });
591
-
592
- editor.on('dragover dragend', function(e) {
593
- var i, dataTransfer = e.dataTransfer;
594
-
595
- if (editor.settings.paste_data_images && dataTransfer) {
596
- for (i = 0; i < dataTransfer.types.length; i++) {
597
- // Prevent default if we have files dragged into the editor since the pasteImageData handles that
598
- if (dataTransfer.types[i] == "Files") {
599
- e.preventDefault();
600
- return false;
601
- }
602
- }
603
- }
604
- });
605
- }
606
-
607
- self.pasteHtml = pasteHtml;
608
- self.pasteText = pasteText;
609
-
610
- editor.on('preInit', function() {
611
- registerEventHandlers();
612
-
613
- // Remove all data images from paste for example from Gecko
614
- // except internal images like video elements
615
- editor.parser.addNodeFilter('img', function(nodes) {
616
- if (!editor.settings.paste_data_images) {
617
- var i = nodes.length;
618
-
619
- while (i--) {
620
- var src = nodes[i].attributes.map.src;
621
-
622
- // Some browsers automatically produce data uris on paste
623
- // Safari on Mac produces webkit-fake-url see: https://bugs.webkit.org/show_bug.cgi?id=49141
624
- if (src && /^(data:image|webkit\-fake\-url)/.test(src)) {
625
- if (!nodes[i].attr('data-mce-object') && src !== Env.transparentSrc) {
626
- nodes[i].remove();
627
- }
628
- }
629
- }
630
- }
631
- });
632
- });
633
- };
634
- });