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 @@
1
+ tinymce.PluginManager.add("noneditable",function(a){function b(a){var b;if(1===a.nodeType){if(b=a.getAttribute(k),b&&"inherit"!==b)return b;if(b=a.contentEditable,"inherit"!==b)return b}return null}function c(a){for(var c;a;){if(c=b(a))return"false"===c?a:null;a=a.parentNode}}function d(){function d(a){for(;a;){if(a.id===n)return a;a=a.parentNode}}function e(a){var b;if(a)for(b=new i(a,a),a=b.current();a;a=b.next())if(3===a.nodeType)return a}function f(c,d){var e,f;return"false"===b(c)&&k.isBlock(c)?void m.select(c):(f=k.createRng(),"true"===b(c)&&(c.firstChild||c.appendChild(a.getDoc().createTextNode("\xa0")),c=c.firstChild,d=!0),e=k.create("span",{id:n,"data-mce-bogus":!0},o),d?c.parentNode.insertBefore(e,c):k.insertAfter(e,c),f.setStart(e.firstChild,1),f.collapse(!0),m.setRng(f),e)}function g(a){var b,c,f,g;if(a)b=m.getRng(!0),b.setStartBefore(a),b.setEndBefore(a),c=e(a),c&&c.nodeValue.charAt(0)==o&&(c=c.deleteData(0,1)),k.remove(a,!0),m.setRng(b);else for(f=d(m.getStart());(a=k.get(n))&&a!==g;)f!==a&&(c=e(a),c&&c.nodeValue.charAt(0)==o&&(c=c.deleteData(0,1)),k.remove(a,!0)),g=a}function h(){function a(a,c){var d,e,f,g,h;if(d=j.startContainer,e=j.startOffset,3==d.nodeType){if(h=d.nodeValue.length,e>0&&h>e||(c?e==h:0===e))return}else{if(!(e<d.childNodes.length))return c?null:a;var k=!c&&e>0?e-1:e;d=d.childNodes[k],d.hasChildNodes()&&(d=d.firstChild)}for(f=new i(d,a);g=f[c?"prev":"next"]();){if(3===g.nodeType&&g.nodeValue.length>0)return;if("true"===b(g))return g}return a}var d,e,h,j,k;g(),h=m.isCollapsed(),d=c(m.getStart()),e=c(m.getEnd()),(d||e)&&(j=m.getRng(!0),h?(d=d||e,(k=a(d,!0))?f(k,!0):(k=a(d,!1))?f(k,!1):m.select(d)):(j=m.getRng(!0),d&&j.setStartBefore(d),e&&j.setEndAfter(e),m.setRng(j)))}function j(e){function f(a,b){for(;a=a[b?"previousSibling":"nextSibling"];)if(3!==a.nodeType||a.nodeValue.length>0)return a}function j(a,b){m.select(a),m.collapse(b)}function n(e){function f(a){for(var b=j;b;){if(b===a)return;b=b.parentNode}k.remove(a),h()}function g(){var d,g,h=a.schema.getNonEmptyElements();for(g=new tinymce.dom.TreeWalker(j,a.getBody());(d=e?g.prev():g.next())&&!h[d.nodeName.toLowerCase()]&&!(3===d.nodeType&&tinymce.trim(d.nodeValue).length>0);)if("false"===b(d))return f(d),!0;return c(d)?!0:!1}var i,j,l,n;if(m.isCollapsed()){if(i=m.getRng(!0),j=i.startContainer,l=i.startOffset,j=d(j)||j,n=c(j))return f(n),!1;if(3==j.nodeType&&(e?l>0:l<j.nodeValue.length))return!0;if(1==j.nodeType&&(j=j.childNodes[l]||j),g())return!1}return!0}var o,p,q,r,s=e.keyCode;if(q=m.getStart(),r=m.getEnd(),o=c(q)||c(r),o&&(112>s||s>124)&&s!=l.DELETE&&s!=l.BACKSPACE){if((tinymce.isMac?e.metaKey:e.ctrlKey)&&(67==s||88==s||86==s))return;if(e.preventDefault(),s==l.LEFT||s==l.RIGHT){var t=s==l.LEFT;if(a.dom.isBlock(o)){var u=t?o.previousSibling:o.nextSibling,v=new i(u,u),w=t?v.prev():v.next();j(w,!t)}else j(o,t)}}else if(s==l.LEFT||s==l.RIGHT||s==l.BACKSPACE||s==l.DELETE){if(p=d(q)){if(s==l.LEFT||s==l.BACKSPACE)if(o=f(p,!0),o&&"false"===b(o)){if(e.preventDefault(),s!=l.LEFT)return void k.remove(o);j(o,!0)}else g(p);if(s==l.RIGHT||s==l.DELETE)if(o=f(p),o&&"false"===b(o)){if(e.preventDefault(),s!=l.RIGHT)return void k.remove(o);j(o,!1)}else g(p)}if((s==l.BACKSPACE||s==l.DELETE)&&!n(s==l.BACKSPACE))return e.preventDefault(),!1}}var k=a.dom,m=a.selection,n="mce_noneditablecaret",o="\ufeff";a.on("mousedown",function(c){var d=a.selection.getNode();"false"===b(d)&&d==c.target&&h()}),a.on("mouseup keyup",h),a.on("keydown",j)}function e(b){var c=h.length,d=b.content,e=tinymce.trim(g);if("raw"!=b.format){for(;c--;)d=d.replace(h[c],function(b){var c=arguments,f=c[c.length-2];return f>0&&'"'==d.charAt(f-1)?b:'<span class="'+e+'" data-mce-content="'+a.dom.encode(c[0])+'">'+a.dom.encode("string"==typeof c[1]?c[1]:c[0])+"</span>"});b.content=d}}var f,g,h,i=tinymce.dom.TreeWalker,j="contenteditable",k="data-mce-"+j,l=tinymce.util.VK;f=" "+tinymce.trim(a.getParam("noneditable_editable_class","mceEditable"))+" ",g=" "+tinymce.trim(a.getParam("noneditable_noneditable_class","mceNonEditable"))+" ",h=a.getParam("noneditable_regexp"),h&&!h.length&&(h=[h]),a.on("PreInit",function(){d(),h&&a.on("BeforeSetContent",e),a.parser.addAttributeFilter("class",function(a){for(var b,c,d=a.length;d--;)c=a[d],b=" "+c.attr("class")+" ",-1!==b.indexOf(f)?c.attr(k,"true"):-1!==b.indexOf(g)&&c.attr(k,"false")}),a.serializer.addAttributeFilter(k,function(a){for(var b,c=a.length;c--;)b=a[c],h&&b.attr("data-mce-content")?(b.name="#text",b.type=3,b.raw=!0,b.value=b.attr("data-mce-content")):(b.attr(j,null),b.attr(k,null))}),a.parser.addAttributeFilter(j,function(a){for(var b,c=a.length;c--;)b=a[c],b.attr(k,b.attr(j)),b.attr(j,null)})}),a.on("drop",function(a){c(a.target)&&a.preventDefault()})});
@@ -0,0 +1,88 @@
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
+ /*global tinymce:true */
12
+
13
+ tinymce.PluginManager.add('pagebreak', function(editor) {
14
+ var pageBreakClass = 'mce-pagebreak', separatorHtml = editor.getParam('pagebreak_separator', '<!-- pagebreak -->');
15
+
16
+ var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {
17
+ return '\\' + a;
18
+ }), 'gi');
19
+
20
+ var pageBreakPlaceHolderHtml = '<img src="' + tinymce.Env.transparentSrc + '" class="' +
21
+ pageBreakClass + '" data-mce-resize="false" />';
22
+
23
+ // Register commands
24
+ editor.addCommand('mcePageBreak', function() {
25
+ if (editor.settings.pagebreak_split_block) {
26
+ editor.insertContent('<p>' + pageBreakPlaceHolderHtml + '</p>');
27
+ } else {
28
+ editor.insertContent(pageBreakPlaceHolderHtml);
29
+ }
30
+ });
31
+
32
+ // Register buttons
33
+ editor.addButton('pagebreak', {
34
+ title: 'Page break',
35
+ cmd: 'mcePageBreak'
36
+ });
37
+
38
+ editor.addMenuItem('pagebreak', {
39
+ text: 'Page break',
40
+ icon: 'pagebreak',
41
+ cmd: 'mcePageBreak',
42
+ context: 'insert'
43
+ });
44
+
45
+ editor.on('ResolveName', function(e) {
46
+ if (e.target.nodeName == 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) {
47
+ e.name = 'pagebreak';
48
+ }
49
+ });
50
+
51
+ editor.on('click', function(e) {
52
+ e = e.target;
53
+
54
+ if (e.nodeName === 'IMG' && editor.dom.hasClass(e, pageBreakClass)) {
55
+ editor.selection.select(e);
56
+ }
57
+ });
58
+
59
+ editor.on('BeforeSetContent', function(e) {
60
+ e.content = e.content.replace(pageBreakSeparatorRegExp, pageBreakPlaceHolderHtml);
61
+ });
62
+
63
+ editor.on('PreInit', function() {
64
+ editor.serializer.addNodeFilter('img', function(nodes) {
65
+ var i = nodes.length, node, className;
66
+
67
+ while (i--) {
68
+ node = nodes[i];
69
+ className = node.attr('class');
70
+ if (className && className.indexOf('mce-pagebreak') !== -1) {
71
+ // Replace parent block node if pagebreak_split_block is enabled
72
+ var parentNode = node.parent;
73
+ if (editor.schema.getBlockElements()[parentNode.name] && editor.settings.pagebreak_split_block) {
74
+ parentNode.type = 3;
75
+ parentNode.value = separatorHtml;
76
+ parentNode.raw = true;
77
+ node.remove();
78
+ continue;
79
+ }
80
+
81
+ node.type = 3;
82
+ node.value = separatorHtml;
83
+ node.raw = true;
84
+ }
85
+ }
86
+ });
87
+ });
88
+ });
@@ -0,0 +1 @@
1
+ tinymce.PluginManager.add("pagebreak",function(a){var b="mce-pagebreak",c=a.getParam("pagebreak_separator","<!-- pagebreak -->"),d=new RegExp(c.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(a){return"\\"+a}),"gi"),e='<img src="'+tinymce.Env.transparentSrc+'" class="'+b+'" data-mce-resize="false" />';a.addCommand("mcePageBreak",function(){a.insertContent(a.settings.pagebreak_split_block?"<p>"+e+"</p>":e)}),a.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),a.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"}),a.on("ResolveName",function(c){"IMG"==c.target.nodeName&&a.dom.hasClass(c.target,b)&&(c.name="pagebreak")}),a.on("click",function(c){c=c.target,"IMG"===c.nodeName&&a.dom.hasClass(c,b)&&a.selection.select(c)}),a.on("BeforeSetContent",function(a){a.content=a.content.replace(d,e)}),a.on("PreInit",function(){a.serializer.addNodeFilter("img",function(b){for(var d,e,f=b.length;f--;)if(d=b[f],e=d.attr("class"),e&&-1!==e.indexOf("mce-pagebreak")){var g=d.parent;if(a.schema.getBlockElements()[g.name]&&a.settings.pagebreak_split_block){g.type=3,g.value=c,g.raw=!0,d.remove();continue}d.type=3,d.value=c,d.raw=!0}})})});
@@ -0,0 +1,634 @@
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 &nbsp; 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
+ });